Context
stringlengths
57
92.3k
file_name
stringlengths
21
79
start
int64
14
3.67k
end
int64
18
3.69k
theorem
stringlengths
25
2.71k
proof
stringlengths
5
10.6k
import Mathlib.Data.Real.Sqrt import Mathlib.Analysis.NormedSpace.Star.Basic import Mathlib.Analysis.NormedSpace.ContinuousLinearMap import Mathlib.Analysis.NormedSpace.Basic #align_import data.is_R_or_C.basic from "leanprover-community/mathlib"@"baa88307f3e699fa7054ef04ec79fa4f056169cb" section local notation "π“š" => algebraMap ℝ _ open ComplexConjugate class RCLike (K : semiOutParam Type*) extends DenselyNormedField K, StarRing K, NormedAlgebra ℝ K, CompleteSpace K where re : K β†’+ ℝ im : K β†’+ ℝ I : K I_re_ax : re I = 0 I_mul_I_ax : I = 0 ∨ I * I = -1 re_add_im_ax : βˆ€ z : K, π“š (re z) + π“š (im z) * I = z ofReal_re_ax : βˆ€ r : ℝ, re (π“š r) = r ofReal_im_ax : βˆ€ r : ℝ, im (π“š r) = 0 mul_re_ax : βˆ€ z w : K, re (z * w) = re z * re w - im z * im w mul_im_ax : βˆ€ z w : K, im (z * w) = re z * im w + im z * re w conj_re_ax : βˆ€ z : K, re (conj z) = re z conj_im_ax : βˆ€ z : K, im (conj z) = -im z conj_I_ax : conj I = -I norm_sq_eq_def_ax : βˆ€ z : K, β€–zβ€– ^ 2 = re z * re z + im z * im z mul_im_I_ax : βˆ€ z : K, im z * im I = im z [toPartialOrder : PartialOrder K] le_iff_re_im {z w : K} : z ≀ w ↔ re z ≀ re w ∧ im z = im w -- note we cannot put this in the `extends` clause [toDecidableEq : DecidableEq K] #align is_R_or_C RCLike scoped[ComplexOrder] attribute [instance 100] RCLike.toPartialOrder attribute [instance 100] RCLike.toDecidableEq end variable {K E : Type*} [RCLike K] namespace RCLike open ComplexConjugate @[coe] abbrev ofReal : ℝ β†’ K := Algebra.cast noncomputable instance (priority := 900) algebraMapCoe : CoeTC ℝ K := ⟨ofReal⟩ #align is_R_or_C.algebra_map_coe RCLike.algebraMapCoe theorem ofReal_alg (x : ℝ) : (x : K) = x β€’ (1 : K) := Algebra.algebraMap_eq_smul_one x #align is_R_or_C.of_real_alg RCLike.ofReal_alg theorem real_smul_eq_coe_mul (r : ℝ) (z : K) : r β€’ z = (r : K) * z := Algebra.smul_def r z #align is_R_or_C.real_smul_eq_coe_mul RCLike.real_smul_eq_coe_mul theorem real_smul_eq_coe_smul [AddCommGroup E] [Module K E] [Module ℝ E] [IsScalarTower ℝ K E] (r : ℝ) (x : E) : r β€’ x = (r : K) β€’ x := by rw [RCLike.ofReal_alg, smul_one_smul] #align is_R_or_C.real_smul_eq_coe_smul RCLike.real_smul_eq_coe_smul theorem algebraMap_eq_ofReal : ⇑(algebraMap ℝ K) = ofReal := rfl #align is_R_or_C.algebra_map_eq_of_real RCLike.algebraMap_eq_ofReal @[simp, rclike_simps] theorem re_add_im (z : K) : (re z : K) + im z * I = z := RCLike.re_add_im_ax z #align is_R_or_C.re_add_im RCLike.re_add_im @[simp, norm_cast, rclike_simps] theorem ofReal_re : βˆ€ r : ℝ, re (r : K) = r := RCLike.ofReal_re_ax #align is_R_or_C.of_real_re RCLike.ofReal_re @[simp, norm_cast, rclike_simps] theorem ofReal_im : βˆ€ r : ℝ, im (r : K) = 0 := RCLike.ofReal_im_ax #align is_R_or_C.of_real_im RCLike.ofReal_im @[simp, rclike_simps] theorem mul_re : βˆ€ z w : K, re (z * w) = re z * re w - im z * im w := RCLike.mul_re_ax #align is_R_or_C.mul_re RCLike.mul_re @[simp, rclike_simps] theorem mul_im : βˆ€ z w : K, im (z * w) = re z * im w + im z * re w := RCLike.mul_im_ax #align is_R_or_C.mul_im RCLike.mul_im theorem ext_iff {z w : K} : z = w ↔ re z = re w ∧ im z = im w := ⟨fun h => h β–Έ ⟨rfl, rfl⟩, fun ⟨h₁, hβ‚‚βŸ© => re_add_im z β–Έ re_add_im w β–Έ h₁ β–Έ hβ‚‚ β–Έ rfl⟩ #align is_R_or_C.ext_iff RCLike.ext_iff theorem ext {z w : K} (hre : re z = re w) (him : im z = im w) : z = w := ext_iff.2 ⟨hre, him⟩ #align is_R_or_C.ext RCLike.ext @[norm_cast] theorem ofReal_zero : ((0 : ℝ) : K) = 0 := algebraMap.coe_zero #align is_R_or_C.of_real_zero RCLike.ofReal_zero @[rclike_simps] theorem zero_re' : re (0 : K) = (0 : ℝ) := map_zero re #align is_R_or_C.zero_re' RCLike.zero_re' @[norm_cast] theorem ofReal_one : ((1 : ℝ) : K) = 1 := map_one (algebraMap ℝ K) #align is_R_or_C.of_real_one RCLike.ofReal_one @[simp, rclike_simps] theorem one_re : re (1 : K) = 1 := by rw [← ofReal_one, ofReal_re] #align is_R_or_C.one_re RCLike.one_re @[simp, rclike_simps] theorem one_im : im (1 : K) = 0 := by rw [← ofReal_one, ofReal_im] #align is_R_or_C.one_im RCLike.one_im theorem ofReal_injective : Function.Injective ((↑) : ℝ β†’ K) := (algebraMap ℝ K).injective #align is_R_or_C.of_real_injective RCLike.ofReal_injective @[norm_cast] theorem ofReal_inj {z w : ℝ} : (z : K) = (w : K) ↔ z = w := algebraMap.coe_inj #align is_R_or_C.of_real_inj RCLike.ofReal_inj -- replaced by `RCLike.ofNat_re` #noalign is_R_or_C.bit0_re #noalign is_R_or_C.bit1_re -- replaced by `RCLike.ofNat_im` #noalign is_R_or_C.bit0_im #noalign is_R_or_C.bit1_im theorem ofReal_eq_zero {x : ℝ} : (x : K) = 0 ↔ x = 0 := algebraMap.lift_map_eq_zero_iff x #align is_R_or_C.of_real_eq_zero RCLike.ofReal_eq_zero theorem ofReal_ne_zero {x : ℝ} : (x : K) β‰  0 ↔ x β‰  0 := ofReal_eq_zero.not #align is_R_or_C.of_real_ne_zero RCLike.ofReal_ne_zero @[simp, rclike_simps, norm_cast] theorem ofReal_add (r s : ℝ) : ((r + s : ℝ) : K) = r + s := algebraMap.coe_add _ _ #align is_R_or_C.of_real_add RCLike.ofReal_add -- replaced by `RCLike.ofReal_ofNat` #noalign is_R_or_C.of_real_bit0 #noalign is_R_or_C.of_real_bit1 @[simp, norm_cast, rclike_simps] theorem ofReal_neg (r : ℝ) : ((-r : ℝ) : K) = -r := algebraMap.coe_neg r #align is_R_or_C.of_real_neg RCLike.ofReal_neg @[simp, norm_cast, rclike_simps] theorem ofReal_sub (r s : ℝ) : ((r - s : ℝ) : K) = r - s := map_sub (algebraMap ℝ K) r s #align is_R_or_C.of_real_sub RCLike.ofReal_sub @[simp, rclike_simps, norm_cast] theorem ofReal_sum {Ξ± : Type*} (s : Finset Ξ±) (f : Ξ± β†’ ℝ) : ((βˆ‘ i ∈ s, f i : ℝ) : K) = βˆ‘ i ∈ s, (f i : K) := map_sum (algebraMap ℝ K) _ _ #align is_R_or_C.of_real_sum RCLike.ofReal_sum @[simp, rclike_simps, norm_cast] theorem ofReal_finsupp_sum {Ξ± M : Type*} [Zero M] (f : Ξ± β†’β‚€ M) (g : Ξ± β†’ M β†’ ℝ) : ((f.sum fun a b => g a b : ℝ) : K) = f.sum fun a b => (g a b : K) := map_finsupp_sum (algebraMap ℝ K) f g #align is_R_or_C.of_real_finsupp_sum RCLike.ofReal_finsupp_sum @[simp, norm_cast, rclike_simps] theorem ofReal_mul (r s : ℝ) : ((r * s : ℝ) : K) = r * s := algebraMap.coe_mul _ _ #align is_R_or_C.of_real_mul RCLike.ofReal_mul @[simp, norm_cast, rclike_simps] theorem ofReal_pow (r : ℝ) (n : β„•) : ((r ^ n : ℝ) : K) = (r : K) ^ n := map_pow (algebraMap ℝ K) r n #align is_R_or_C.of_real_pow RCLike.ofReal_pow @[simp, rclike_simps, norm_cast] theorem ofReal_prod {Ξ± : Type*} (s : Finset Ξ±) (f : Ξ± β†’ ℝ) : ((∏ i ∈ s, f i : ℝ) : K) = ∏ i ∈ s, (f i : K) := map_prod (algebraMap ℝ K) _ _ #align is_R_or_C.of_real_prod RCLike.ofReal_prod @[simp, rclike_simps, norm_cast] theorem ofReal_finsupp_prod {Ξ± M : Type*} [Zero M] (f : Ξ± β†’β‚€ M) (g : Ξ± β†’ M β†’ ℝ) : ((f.prod fun a b => g a b : ℝ) : K) = f.prod fun a b => (g a b : K) := map_finsupp_prod _ f g #align is_R_or_C.of_real_finsupp_prod RCLike.ofReal_finsupp_prod @[simp, norm_cast, rclike_simps] theorem real_smul_ofReal (r x : ℝ) : r β€’ (x : K) = (r : K) * (x : K) := real_smul_eq_coe_mul _ _ #align is_R_or_C.real_smul_of_real RCLike.real_smul_ofReal @[rclike_simps] theorem re_ofReal_mul (r : ℝ) (z : K) : re (↑r * z) = r * re z := by simp only [mul_re, ofReal_im, zero_mul, ofReal_re, sub_zero] #align is_R_or_C.of_real_mul_re RCLike.re_ofReal_mul @[rclike_simps] theorem im_ofReal_mul (r : ℝ) (z : K) : im (↑r * z) = r * im z := by simp only [add_zero, ofReal_im, zero_mul, ofReal_re, mul_im] #align is_R_or_C.of_real_mul_im RCLike.im_ofReal_mul @[rclike_simps] theorem smul_re (r : ℝ) (z : K) : re (r β€’ z) = r * re z := by rw [real_smul_eq_coe_mul, re_ofReal_mul] #align is_R_or_C.smul_re RCLike.smul_re @[rclike_simps] theorem smul_im (r : ℝ) (z : K) : im (r β€’ z) = r * im z := by rw [real_smul_eq_coe_mul, im_ofReal_mul] #align is_R_or_C.smul_im RCLike.smul_im @[simp, norm_cast, rclike_simps] theorem norm_ofReal (r : ℝ) : β€–(r : K)β€– = |r| := norm_algebraMap' K r #align is_R_or_C.norm_of_real RCLike.norm_ofReal -- see Note [lower instance priority] instance (priority := 100) charZero_rclike : CharZero K := (RingHom.charZero_iff (algebraMap ℝ K).injective).1 inferInstance set_option linter.uppercaseLean3 false in #align is_R_or_C.char_zero_R_or_C RCLike.charZero_rclike @[simp, rclike_simps] theorem I_re : re (I : K) = 0 := I_re_ax set_option linter.uppercaseLean3 false in #align is_R_or_C.I_re RCLike.I_re @[simp, rclike_simps] theorem I_im (z : K) : im z * im (I : K) = im z := mul_im_I_ax z set_option linter.uppercaseLean3 false in #align is_R_or_C.I_im RCLike.I_im @[simp, rclike_simps] theorem I_im' (z : K) : im (I : K) * im z = im z := by rw [mul_comm, I_im] set_option linter.uppercaseLean3 false in #align is_R_or_C.I_im' RCLike.I_im' @[rclike_simps] -- porting note (#10618): was `simp` theorem I_mul_re (z : K) : re (I * z) = -im z := by simp only [I_re, zero_sub, I_im', zero_mul, mul_re] set_option linter.uppercaseLean3 false in #align is_R_or_C.I_mul_re RCLike.I_mul_re theorem I_mul_I : (I : K) = 0 ∨ (I : K) * I = -1 := I_mul_I_ax set_option linter.uppercaseLean3 false in #align is_R_or_C.I_mul_I RCLike.I_mul_I variable (π•œ) in lemma I_eq_zero_or_im_I_eq_one : (I : K) = 0 ∨ im (I : K) = 1 := I_mul_I (K := K) |>.imp_right fun h ↦ by simpa [h] using (I_mul_re (I : K)).symm @[simp, rclike_simps] theorem conj_re (z : K) : re (conj z) = re z := RCLike.conj_re_ax z #align is_R_or_C.conj_re RCLike.conj_re @[simp, rclike_simps] theorem conj_im (z : K) : im (conj z) = -im z := RCLike.conj_im_ax z #align is_R_or_C.conj_im RCLike.conj_im @[simp, rclike_simps] theorem conj_I : conj (I : K) = -I := RCLike.conj_I_ax set_option linter.uppercaseLean3 false in #align is_R_or_C.conj_I RCLike.conj_I @[simp, rclike_simps] theorem conj_ofReal (r : ℝ) : conj (r : K) = (r : K) := by rw [ext_iff] simp only [ofReal_im, conj_im, eq_self_iff_true, conj_re, and_self_iff, neg_zero] #align is_R_or_C.conj_of_real RCLike.conj_ofReal -- replaced by `RCLike.conj_ofNat` #noalign is_R_or_C.conj_bit0 #noalign is_R_or_C.conj_bit1 theorem conj_nat_cast (n : β„•) : conj (n : K) = n := map_natCast _ _ -- See note [no_index around OfNat.ofNat] theorem conj_ofNat (n : β„•) [n.AtLeastTwo] : conj (no_index (OfNat.ofNat n : K)) = OfNat.ofNat n := map_ofNat _ _ @[rclike_simps] -- Porting note (#10618): was a `simp` but `simp` can prove it theorem conj_neg_I : conj (-I) = (I : K) := by rw [map_neg, conj_I, neg_neg] set_option linter.uppercaseLean3 false in #align is_R_or_C.conj_neg_I RCLike.conj_neg_I theorem conj_eq_re_sub_im (z : K) : conj z = re z - im z * I := (congr_arg conj (re_add_im z).symm).trans <| by rw [map_add, map_mul, conj_I, conj_ofReal, conj_ofReal, mul_neg, sub_eq_add_neg] #align is_R_or_C.conj_eq_re_sub_im RCLike.conj_eq_re_sub_im theorem sub_conj (z : K) : z - conj z = 2 * im z * I := calc z - conj z = re z + im z * I - (re z - im z * I) := by rw [re_add_im, ← conj_eq_re_sub_im] _ = 2 * im z * I := by rw [add_sub_sub_cancel, ← two_mul, mul_assoc] #align is_R_or_C.sub_conj RCLike.sub_conj @[rclike_simps] theorem conj_smul (r : ℝ) (z : K) : conj (r β€’ z) = r β€’ conj z := by rw [conj_eq_re_sub_im, conj_eq_re_sub_im, smul_re, smul_im, ofReal_mul, ofReal_mul, real_smul_eq_coe_mul r (_ - _), mul_sub, mul_assoc] #align is_R_or_C.conj_smul RCLike.conj_smul theorem add_conj (z : K) : z + conj z = 2 * re z := calc z + conj z = re z + im z * I + (re z - im z * I) := by rw [re_add_im, conj_eq_re_sub_im] _ = 2 * re z := by rw [add_add_sub_cancel, two_mul] #align is_R_or_C.add_conj RCLike.add_conj theorem re_eq_add_conj (z : K) : ↑(re z) = (z + conj z) / 2 := by rw [add_conj, mul_div_cancel_leftβ‚€ (re z : K) two_ne_zero] #align is_R_or_C.re_eq_add_conj RCLike.re_eq_add_conj theorem im_eq_conj_sub (z : K) : ↑(im z) = I * (conj z - z) / 2 := by rw [← neg_inj, ← ofReal_neg, ← I_mul_re, re_eq_add_conj, map_mul, conj_I, ← neg_div, ← mul_neg, neg_sub, mul_sub, neg_mul, sub_eq_add_neg] #align is_R_or_C.im_eq_conj_sub RCLike.im_eq_conj_sub open List in theorem is_real_TFAE (z : K) : TFAE [conj z = z, βˆƒ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by tfae_have 1 β†’ 4 Β· intro h rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div, ofReal_zero] tfae_have 4 β†’ 3 Β· intro h conv_rhs => rw [← re_add_im z, h, ofReal_zero, zero_mul, add_zero] tfae_have 3 β†’ 2 Β· exact fun h => ⟨_, h⟩ tfae_have 2 β†’ 1 Β· exact fun ⟨r, hr⟩ => hr β–Έ conj_ofReal _ tfae_finish #align is_R_or_C.is_real_tfae RCLike.is_real_TFAE theorem conj_eq_iff_real {z : K} : conj z = z ↔ βˆƒ r : ℝ, z = (r : K) := ((is_real_TFAE z).out 0 1).trans <| by simp only [eq_comm] #align is_R_or_C.conj_eq_iff_real RCLike.conj_eq_iff_real theorem conj_eq_iff_re {z : K} : conj z = z ↔ (re z : K) = z := (is_real_TFAE z).out 0 2 #align is_R_or_C.conj_eq_iff_re RCLike.conj_eq_iff_re theorem conj_eq_iff_im {z : K} : conj z = z ↔ im z = 0 := (is_real_TFAE z).out 0 3 #align is_R_or_C.conj_eq_iff_im RCLike.conj_eq_iff_im @[simp] theorem star_def : (Star.star : K β†’ K) = conj := rfl #align is_R_or_C.star_def RCLike.star_def variable (K) abbrev conjToRingEquiv : K ≃+* Kᡐᡒᡖ := starRingEquiv #align is_R_or_C.conj_to_ring_equiv RCLike.conjToRingEquiv variable {K} {z : K} def normSq : K β†’*β‚€ ℝ where toFun z := re z * re z + im z * im z map_zero' := by simp only [add_zero, mul_zero, map_zero] map_one' := by simp only [one_im, add_zero, mul_one, one_re, mul_zero] map_mul' z w := by simp only [mul_im, mul_re] ring #align is_R_or_C.norm_sq RCLike.normSq theorem normSq_apply (z : K) : normSq z = re z * re z + im z * im z := rfl #align is_R_or_C.norm_sq_apply RCLike.normSq_apply theorem norm_sq_eq_def {z : K} : β€–zβ€– ^ 2 = re z * re z + im z * im z := norm_sq_eq_def_ax z #align is_R_or_C.norm_sq_eq_def RCLike.norm_sq_eq_def theorem normSq_eq_def' (z : K) : normSq z = β€–zβ€– ^ 2 := norm_sq_eq_def.symm #align is_R_or_C.norm_sq_eq_def' RCLike.normSq_eq_def' @[rclike_simps] theorem normSq_zero : normSq (0 : K) = 0 := normSq.map_zero #align is_R_or_C.norm_sq_zero RCLike.normSq_zero @[rclike_simps] theorem normSq_one : normSq (1 : K) = 1 := normSq.map_one #align is_R_or_C.norm_sq_one RCLike.normSq_one theorem normSq_nonneg (z : K) : 0 ≀ normSq z := add_nonneg (mul_self_nonneg _) (mul_self_nonneg _) #align is_R_or_C.norm_sq_nonneg RCLike.normSq_nonneg @[rclike_simps] -- porting note (#10618): was `simp` theorem normSq_eq_zero {z : K} : normSq z = 0 ↔ z = 0 := map_eq_zero _ #align is_R_or_C.norm_sq_eq_zero RCLike.normSq_eq_zero @[simp, rclike_simps] theorem normSq_pos {z : K} : 0 < normSq z ↔ z β‰  0 := by rw [lt_iff_le_and_ne, Ne, eq_comm]; simp [normSq_nonneg] #align is_R_or_C.norm_sq_pos RCLike.normSq_pos @[simp, rclike_simps] theorem normSq_neg (z : K) : normSq (-z) = normSq z := by simp only [normSq_eq_def', norm_neg] #align is_R_or_C.norm_sq_neg RCLike.normSq_neg @[simp, rclike_simps] theorem normSq_conj (z : K) : normSq (conj z) = normSq z := by simp only [normSq_apply, neg_mul, mul_neg, neg_neg, rclike_simps] #align is_R_or_C.norm_sq_conj RCLike.normSq_conj @[rclike_simps] -- porting note (#10618): was `simp` theorem normSq_mul (z w : K) : normSq (z * w) = normSq z * normSq w := map_mul _ z w #align is_R_or_C.norm_sq_mul RCLike.normSq_mul theorem normSq_add (z w : K) : normSq (z + w) = normSq z + normSq w + 2 * re (z * conj w) := by simp only [normSq_apply, map_add, rclike_simps] ring #align is_R_or_C.norm_sq_add RCLike.normSq_add theorem re_sq_le_normSq (z : K) : re z * re z ≀ normSq z := le_add_of_nonneg_right (mul_self_nonneg _) #align is_R_or_C.re_sq_le_norm_sq RCLike.re_sq_le_normSq theorem im_sq_le_normSq (z : K) : im z * im z ≀ normSq z := le_add_of_nonneg_left (mul_self_nonneg _) #align is_R_or_C.im_sq_le_norm_sq RCLike.im_sq_le_normSq theorem mul_conj (z : K) : z * conj z = β€–zβ€– ^ 2 := by apply ext <;> simp [← ofReal_pow, norm_sq_eq_def, mul_comm] #align is_R_or_C.mul_conj RCLike.mul_conj theorem conj_mul (z : K) : conj z * z = β€–zβ€– ^ 2 := by rw [mul_comm, mul_conj] #align is_R_or_C.conj_mul RCLike.conj_mul lemma inv_eq_conj (hz : β€–zβ€– = 1) : z⁻¹ = conj z := inv_eq_of_mul_eq_one_left $ by simp_rw [conj_mul, hz, algebraMap.coe_one, one_pow] theorem normSq_sub (z w : K) : normSq (z - w) = normSq z + normSq w - 2 * re (z * conj w) := by simp only [normSq_add, sub_eq_add_neg, map_neg, mul_neg, normSq_neg, map_neg] #align is_R_or_C.norm_sq_sub RCLike.normSq_sub theorem sqrt_normSq_eq_norm {z : K} : √(normSq z) = β€–zβ€– := by rw [normSq_eq_def', Real.sqrt_sq (norm_nonneg _)] #align is_R_or_C.sqrt_norm_sq_eq_norm RCLike.sqrt_normSq_eq_norm @[simp, norm_cast, rclike_simps] theorem ofReal_inv (r : ℝ) : ((r⁻¹ : ℝ) : K) = (r : K)⁻¹ := map_invβ‚€ _ r #align is_R_or_C.of_real_inv RCLike.ofReal_inv theorem inv_def (z : K) : z⁻¹ = conj z * ((β€–zβ€– ^ 2)⁻¹ : ℝ) := by rcases eq_or_ne z 0 with (rfl | hβ‚€) Β· simp Β· apply inv_eq_of_mul_eq_one_right rw [← mul_assoc, mul_conj, ofReal_inv, ofReal_pow, mul_inv_cancel] simpa #align is_R_or_C.inv_def RCLike.inv_def @[simp, rclike_simps] theorem inv_re (z : K) : re z⁻¹ = re z / normSq z := by rw [inv_def, normSq_eq_def', mul_comm, re_ofReal_mul, conj_re, div_eq_inv_mul] #align is_R_or_C.inv_re RCLike.inv_re @[simp, rclike_simps] theorem inv_im (z : K) : im z⁻¹ = -im z / normSq z := by rw [inv_def, normSq_eq_def', mul_comm, im_ofReal_mul, conj_im, div_eq_inv_mul] #align is_R_or_C.inv_im RCLike.inv_im theorem div_re (z w : K) : re (z / w) = re z * re w / normSq w + im z * im w / normSq w := by simp only [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, neg_mul, mul_neg, neg_neg, map_neg, rclike_simps] #align is_R_or_C.div_re RCLike.div_re theorem div_im (z w : K) : im (z / w) = im z * re w / normSq w - re z * im w / normSq w := by simp only [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, add_comm, neg_mul, mul_neg, map_neg, rclike_simps] #align is_R_or_C.div_im RCLike.div_im @[rclike_simps] -- porting note (#10618): was `simp` theorem conj_inv (x : K) : conj x⁻¹ = (conj x)⁻¹ := star_inv' _ #align is_R_or_C.conj_inv RCLike.conj_inv lemma conj_div (x y : K) : conj (x / y) = conj x / conj y := map_div' conj conj_inv _ _ --TODO: Do we rather want the map as an explicit definition? lemma exists_norm_eq_mul_self (x : K) : βˆƒ c, β€–cβ€– = 1 ∧ ↑‖xβ€– = c * x := by obtain rfl | hx := eq_or_ne x 0 Β· exact ⟨1, by simp⟩ Β· exact βŸ¨β€–xβ€– / x, by simp [norm_ne_zero_iff.2, hx]⟩ lemma exists_norm_mul_eq_self (x : K) : βˆƒ c, β€–cβ€– = 1 ∧ c * β€–xβ€– = x := by obtain rfl | hx := eq_or_ne x 0 Β· exact ⟨1, by simp⟩ Β· exact ⟨x / β€–xβ€–, by simp [norm_ne_zero_iff.2, hx]⟩ @[simp, norm_cast, rclike_simps] theorem ofReal_div (r s : ℝ) : ((r / s : ℝ) : K) = r / s := map_divβ‚€ (algebraMap ℝ K) r s #align is_R_or_C.of_real_div RCLike.ofReal_div theorem div_re_ofReal {z : K} {r : ℝ} : re (z / r) = re z / r := by rw [div_eq_inv_mul, div_eq_inv_mul, ← ofReal_inv, re_ofReal_mul] #align is_R_or_C.div_re_of_real RCLike.div_re_ofReal @[simp, norm_cast, rclike_simps] theorem ofReal_zpow (r : ℝ) (n : β„€) : ((r ^ n : ℝ) : K) = (r : K) ^ n := map_zpowβ‚€ (algebraMap ℝ K) r n #align is_R_or_C.of_real_zpow RCLike.ofReal_zpow theorem I_mul_I_of_nonzero : (I : K) β‰  0 β†’ (I : K) * I = -1 := I_mul_I_ax.resolve_left set_option linter.uppercaseLean3 false in #align is_R_or_C.I_mul_I_of_nonzero RCLike.I_mul_I_of_nonzero @[simp, rclike_simps] theorem inv_I : (I : K)⁻¹ = -I := by by_cases h : (I : K) = 0 Β· simp [h] Β· field_simp [I_mul_I_of_nonzero h] set_option linter.uppercaseLean3 false in #align is_R_or_C.inv_I RCLike.inv_I @[simp, rclike_simps] theorem div_I (z : K) : z / I = -(z * I) := by rw [div_eq_mul_inv, inv_I, mul_neg] set_option linter.uppercaseLean3 false in #align is_R_or_C.div_I RCLike.div_I @[rclike_simps] -- porting note (#10618): was `simp` theorem normSq_inv (z : K) : normSq z⁻¹ = (normSq z)⁻¹ := map_invβ‚€ normSq z #align is_R_or_C.norm_sq_inv RCLike.normSq_inv @[rclike_simps] -- porting note (#10618): was `simp` theorem normSq_div (z w : K) : normSq (z / w) = normSq z / normSq w := map_divβ‚€ normSq z w #align is_R_or_C.norm_sq_div RCLike.normSq_div @[rclike_simps] -- porting note (#10618): was `simp` theorem norm_conj {z : K} : β€–conj zβ€– = β€–zβ€– := by simp only [← sqrt_normSq_eq_norm, normSq_conj] #align is_R_or_C.norm_conj RCLike.norm_conj instance (priority := 100) : CstarRing K where norm_star_mul_self {x} := (norm_mul _ _).trans <| congr_arg (Β· * β€–xβ€–) norm_conj @[simp, rclike_simps, norm_cast] theorem ofReal_natCast (n : β„•) : ((n : ℝ) : K) = n := map_natCast (algebraMap ℝ K) n #align is_R_or_C.of_real_nat_cast RCLike.ofReal_natCast @[simp, rclike_simps] -- Porting note: removed `norm_cast` theorem natCast_re (n : β„•) : re (n : K) = n := by rw [← ofReal_natCast, ofReal_re] #align is_R_or_C.nat_cast_re RCLike.natCast_re @[simp, rclike_simps, norm_cast] theorem natCast_im (n : β„•) : im (n : K) = 0 := by rw [← ofReal_natCast, ofReal_im] #align is_R_or_C.nat_cast_im RCLike.natCast_im -- See note [no_index around OfNat.ofNat] @[simp, rclike_simps] theorem ofNat_re (n : β„•) [n.AtLeastTwo] : re (no_index (OfNat.ofNat n) : K) = OfNat.ofNat n := natCast_re n -- See note [no_index around OfNat.ofNat] @[simp, rclike_simps] theorem ofNat_im (n : β„•) [n.AtLeastTwo] : im (no_index (OfNat.ofNat n) : K) = 0 := natCast_im n -- See note [no_index around OfNat.ofNat] @[simp, rclike_simps, norm_cast] theorem ofReal_ofNat (n : β„•) [n.AtLeastTwo] : ((no_index (OfNat.ofNat n) : ℝ) : K) = OfNat.ofNat n := ofReal_natCast n theorem ofNat_mul_re (n : β„•) [n.AtLeastTwo] (z : K) : re (OfNat.ofNat n * z) = OfNat.ofNat n * re z := by rw [← ofReal_ofNat, re_ofReal_mul]
Mathlib/Analysis/RCLike/Basic.lean
662
664
theorem ofNat_mul_im (n : β„•) [n.AtLeastTwo] (z : K) : im (OfNat.ofNat n * z) = OfNat.ofNat n * im z := by
rw [← ofReal_ofNat, im_ofReal_mul]
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
Mathlib/Analysis/Calculus/ContDiff/Basic.lean
1,415
1,416
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
import Mathlib.Algebra.Order.CauSeq.BigOperators import Mathlib.Data.Complex.Abs import Mathlib.Data.Complex.BigOperators import Mathlib.Data.Nat.Choose.Sum #align_import data.complex.exponential from "leanprover-community/mathlib"@"a8b2226cfb0a79f5986492053fc49b1a0c6aeffb" open CauSeq Finset IsAbsoluteValue open scoped Classical ComplexConjugate namespace Complex variable (x y : β„‚) @[simp] theorem exp_zero : exp 0 = 1 := by rw [exp] refine lim_eq_of_equiv_const fun Ξ΅ Ξ΅0 => ⟨1, fun j hj => ?_⟩ convert (config := .unfoldSameFun) Ξ΅0 -- Porting note: Ξ΅0 : Ξ΅ > 0 but goal is _ < Ξ΅ cases' j with j j Β· exact absurd hj (not_le_of_gt zero_lt_one) Β· dsimp [exp'] induction' j with j ih Β· dsimp [exp']; simp [show Nat.succ 0 = 1 from rfl] Β· rw [← ih (by simp [Nat.succ_le_succ])] simp only [sum_range_succ, pow_succ] simp #align complex.exp_zero Complex.exp_zero theorem exp_add : exp (x + y) = exp x * exp y := by have hj : βˆ€ j : β„•, (βˆ‘ m ∈ range j, (x + y) ^ m / m.factorial) = βˆ‘ i ∈ range j, βˆ‘ k ∈ range (i + 1), x ^ k / k.factorial * (y ^ (i - k) / (i - k).factorial) := by intro j refine Finset.sum_congr rfl fun m _ => ?_ rw [add_pow, div_eq_mul_inv, sum_mul] refine Finset.sum_congr rfl fun I hi => ?_ have h₁ : (m.choose I : β„‚) β‰  0 := Nat.cast_ne_zero.2 (pos_iff_ne_zero.1 (Nat.choose_pos (Nat.le_of_lt_succ (mem_range.1 hi)))) have hβ‚‚ := Nat.choose_mul_factorial_mul_factorial (Nat.le_of_lt_succ <| Finset.mem_range.1 hi) rw [← hβ‚‚, Nat.cast_mul, Nat.cast_mul, mul_inv, mul_inv] simp only [mul_left_comm (m.choose I : β„‚), mul_assoc, mul_left_comm (m.choose I : β„‚)⁻¹, mul_comm (m.choose I : β„‚)] rw [inv_mul_cancel h₁] simp [div_eq_mul_inv, mul_comm, mul_assoc, mul_left_comm] simp_rw [exp, exp', lim_mul_lim] apply (lim_eq_lim_of_equiv _).symm simp only [hj] exact cauchy_product (isCauSeq_abs_exp x) (isCauSeq_exp y) #align complex.exp_add Complex.exp_add -- Porting note (#11445): new definition noncomputable def expMonoidHom : MonoidHom (Multiplicative β„‚) β„‚ := { toFun := fun z => exp (Multiplicative.toAdd z), map_one' := by simp, map_mul' := by simp [exp_add] } theorem exp_list_sum (l : List β„‚) : exp l.sum = (l.map exp).prod := map_list_prod (M := Multiplicative β„‚) expMonoidHom l #align complex.exp_list_sum Complex.exp_list_sum theorem exp_multiset_sum (s : Multiset β„‚) : exp s.sum = (s.map exp).prod := @MonoidHom.map_multiset_prod (Multiplicative β„‚) β„‚ _ _ expMonoidHom s #align complex.exp_multiset_sum Complex.exp_multiset_sum theorem exp_sum {Ξ± : Type*} (s : Finset Ξ±) (f : Ξ± β†’ β„‚) : exp (βˆ‘ x ∈ s, f x) = ∏ x ∈ s, exp (f x) := map_prod (Ξ² := Multiplicative β„‚) expMonoidHom f s #align complex.exp_sum Complex.exp_sum lemma exp_nsmul (x : β„‚) (n : β„•) : exp (n β€’ x) = exp x ^ n := @MonoidHom.map_pow (Multiplicative β„‚) β„‚ _ _ expMonoidHom _ _ theorem exp_nat_mul (x : β„‚) : βˆ€ n : β„•, exp (n * x) = exp x ^ n | 0 => by rw [Nat.cast_zero, zero_mul, exp_zero, pow_zero] | Nat.succ n => by rw [pow_succ, Nat.cast_add_one, add_mul, exp_add, ← exp_nat_mul _ n, one_mul] #align complex.exp_nat_mul Complex.exp_nat_mul theorem exp_ne_zero : exp x β‰  0 := fun h => zero_ne_one <| by rw [← exp_zero, ← add_neg_self x, exp_add, h]; simp #align complex.exp_ne_zero Complex.exp_ne_zero theorem exp_neg : exp (-x) = (exp x)⁻¹ := by rw [← mul_right_inj' (exp_ne_zero x), ← exp_add]; simp [mul_inv_cancel (exp_ne_zero x)] #align complex.exp_neg Complex.exp_neg theorem exp_sub : exp (x - y) = exp x / exp y := by simp [sub_eq_add_neg, exp_add, exp_neg, div_eq_mul_inv] #align complex.exp_sub Complex.exp_sub theorem exp_int_mul (z : β„‚) (n : β„€) : Complex.exp (n * z) = Complex.exp z ^ n := by cases n Β· simp [exp_nat_mul] Β· simp [exp_add, add_mul, pow_add, exp_neg, exp_nat_mul] #align complex.exp_int_mul Complex.exp_int_mul @[simp] theorem exp_conj : exp (conj x) = conj (exp x) := by dsimp [exp] rw [← lim_conj] refine congr_arg CauSeq.lim (CauSeq.ext fun _ => ?_) dsimp [exp', Function.comp_def, cauSeqConj] rw [map_sum (starRingEnd _)] refine sum_congr rfl fun n _ => ?_ rw [map_divβ‚€, map_pow, ← ofReal_natCast, conj_ofReal] #align complex.exp_conj Complex.exp_conj @[simp] theorem ofReal_exp_ofReal_re (x : ℝ) : ((exp x).re : β„‚) = exp x := conj_eq_iff_re.1 <| by rw [← exp_conj, conj_ofReal] #align complex.of_real_exp_of_real_re Complex.ofReal_exp_ofReal_re @[simp, norm_cast] theorem ofReal_exp (x : ℝ) : (Real.exp x : β„‚) = exp x := ofReal_exp_ofReal_re _ #align complex.of_real_exp Complex.ofReal_exp @[simp] theorem exp_ofReal_im (x : ℝ) : (exp x).im = 0 := by rw [← ofReal_exp_ofReal_re, ofReal_im] #align complex.exp_of_real_im Complex.exp_ofReal_im theorem exp_ofReal_re (x : ℝ) : (exp x).re = Real.exp x := rfl #align complex.exp_of_real_re Complex.exp_ofReal_re theorem two_sinh : 2 * sinh x = exp x - exp (-x) := mul_div_cancelβ‚€ _ two_ne_zero #align complex.two_sinh Complex.two_sinh theorem two_cosh : 2 * cosh x = exp x + exp (-x) := mul_div_cancelβ‚€ _ two_ne_zero #align complex.two_cosh Complex.two_cosh @[simp] theorem sinh_zero : sinh 0 = 0 := by simp [sinh] #align complex.sinh_zero Complex.sinh_zero @[simp] theorem sinh_neg : sinh (-x) = -sinh x := by simp [sinh, exp_neg, (neg_div _ _).symm, add_mul] #align complex.sinh_neg Complex.sinh_neg private theorem sinh_add_aux {a b c d : β„‚} : (a - b) * (c + d) + (a + b) * (c - d) = 2 * (a * c - b * d) := by ring theorem sinh_add : sinh (x + y) = sinh x * cosh y + cosh x * sinh y := by rw [← mul_right_inj' (two_ne_zero' β„‚), two_sinh, exp_add, neg_add, exp_add, eq_comm, mul_add, ← mul_assoc, two_sinh, mul_left_comm, two_sinh, ← mul_right_inj' (two_ne_zero' β„‚), mul_add, mul_left_comm, two_cosh, ← mul_assoc, two_cosh] exact sinh_add_aux #align complex.sinh_add Complex.sinh_add @[simp] theorem cosh_zero : cosh 0 = 1 := by simp [cosh] #align complex.cosh_zero Complex.cosh_zero @[simp] theorem cosh_neg : cosh (-x) = cosh x := by simp [add_comm, cosh, exp_neg] #align complex.cosh_neg Complex.cosh_neg private theorem cosh_add_aux {a b c d : β„‚} : (a + b) * (c + d) + (a - b) * (c - d) = 2 * (a * c + b * d) := by ring theorem cosh_add : cosh (x + y) = cosh x * cosh y + sinh x * sinh y := by rw [← mul_right_inj' (two_ne_zero' β„‚), two_cosh, exp_add, neg_add, exp_add, eq_comm, mul_add, ← mul_assoc, two_cosh, ← mul_assoc, two_sinh, ← mul_right_inj' (two_ne_zero' β„‚), mul_add, mul_left_comm, two_cosh, mul_left_comm, two_sinh] exact cosh_add_aux #align complex.cosh_add Complex.cosh_add theorem sinh_sub : sinh (x - y) = sinh x * cosh y - cosh x * sinh y := by simp [sub_eq_add_neg, sinh_add, sinh_neg, cosh_neg] #align complex.sinh_sub Complex.sinh_sub theorem cosh_sub : cosh (x - y) = cosh x * cosh y - sinh x * sinh y := by simp [sub_eq_add_neg, cosh_add, sinh_neg, cosh_neg] #align complex.cosh_sub Complex.cosh_sub theorem sinh_conj : sinh (conj x) = conj (sinh x) := by rw [sinh, ← RingHom.map_neg, exp_conj, exp_conj, ← RingHom.map_sub, sinh, map_divβ‚€] -- Porting note: not nice simp [← one_add_one_eq_two] #align complex.sinh_conj Complex.sinh_conj @[simp] theorem ofReal_sinh_ofReal_re (x : ℝ) : ((sinh x).re : β„‚) = sinh x := conj_eq_iff_re.1 <| by rw [← sinh_conj, conj_ofReal] #align complex.of_real_sinh_of_real_re Complex.ofReal_sinh_ofReal_re @[simp, norm_cast] theorem ofReal_sinh (x : ℝ) : (Real.sinh x : β„‚) = sinh x := ofReal_sinh_ofReal_re _ #align complex.of_real_sinh Complex.ofReal_sinh @[simp] theorem sinh_ofReal_im (x : ℝ) : (sinh x).im = 0 := by rw [← ofReal_sinh_ofReal_re, ofReal_im] #align complex.sinh_of_real_im Complex.sinh_ofReal_im theorem sinh_ofReal_re (x : ℝ) : (sinh x).re = Real.sinh x := rfl #align complex.sinh_of_real_re Complex.sinh_ofReal_re theorem cosh_conj : cosh (conj x) = conj (cosh x) := by rw [cosh, ← RingHom.map_neg, exp_conj, exp_conj, ← RingHom.map_add, cosh, map_divβ‚€] -- Porting note: not nice simp [← one_add_one_eq_two] #align complex.cosh_conj Complex.cosh_conj theorem ofReal_cosh_ofReal_re (x : ℝ) : ((cosh x).re : β„‚) = cosh x := conj_eq_iff_re.1 <| by rw [← cosh_conj, conj_ofReal] #align complex.of_real_cosh_of_real_re Complex.ofReal_cosh_ofReal_re @[simp, norm_cast] theorem ofReal_cosh (x : ℝ) : (Real.cosh x : β„‚) = cosh x := ofReal_cosh_ofReal_re _ #align complex.of_real_cosh Complex.ofReal_cosh @[simp] theorem cosh_ofReal_im (x : ℝ) : (cosh x).im = 0 := by rw [← ofReal_cosh_ofReal_re, ofReal_im] #align complex.cosh_of_real_im Complex.cosh_ofReal_im @[simp] theorem cosh_ofReal_re (x : ℝ) : (cosh x).re = Real.cosh x := rfl #align complex.cosh_of_real_re Complex.cosh_ofReal_re theorem tanh_eq_sinh_div_cosh : tanh x = sinh x / cosh x := rfl #align complex.tanh_eq_sinh_div_cosh Complex.tanh_eq_sinh_div_cosh @[simp] theorem tanh_zero : tanh 0 = 0 := by simp [tanh] #align complex.tanh_zero Complex.tanh_zero @[simp] theorem tanh_neg : tanh (-x) = -tanh x := by simp [tanh, neg_div] #align complex.tanh_neg Complex.tanh_neg theorem tanh_conj : tanh (conj x) = conj (tanh x) := by rw [tanh, sinh_conj, cosh_conj, ← map_divβ‚€, tanh] #align complex.tanh_conj Complex.tanh_conj @[simp] theorem ofReal_tanh_ofReal_re (x : ℝ) : ((tanh x).re : β„‚) = tanh x := conj_eq_iff_re.1 <| by rw [← tanh_conj, conj_ofReal] #align complex.of_real_tanh_of_real_re Complex.ofReal_tanh_ofReal_re @[simp, norm_cast] theorem ofReal_tanh (x : ℝ) : (Real.tanh x : β„‚) = tanh x := ofReal_tanh_ofReal_re _ #align complex.of_real_tanh Complex.ofReal_tanh @[simp] theorem tanh_ofReal_im (x : ℝ) : (tanh x).im = 0 := by rw [← ofReal_tanh_ofReal_re, ofReal_im] #align complex.tanh_of_real_im Complex.tanh_ofReal_im theorem tanh_ofReal_re (x : ℝ) : (tanh x).re = Real.tanh x := rfl #align complex.tanh_of_real_re Complex.tanh_ofReal_re @[simp] theorem cosh_add_sinh : cosh x + sinh x = exp x := by rw [← mul_right_inj' (two_ne_zero' β„‚), mul_add, two_cosh, two_sinh, add_add_sub_cancel, two_mul] #align complex.cosh_add_sinh Complex.cosh_add_sinh @[simp] theorem sinh_add_cosh : sinh x + cosh x = exp x := by rw [add_comm, cosh_add_sinh] #align complex.sinh_add_cosh Complex.sinh_add_cosh @[simp] theorem exp_sub_cosh : exp x - cosh x = sinh x := sub_eq_iff_eq_add.2 (sinh_add_cosh x).symm #align complex.exp_sub_cosh Complex.exp_sub_cosh @[simp] theorem exp_sub_sinh : exp x - sinh x = cosh x := sub_eq_iff_eq_add.2 (cosh_add_sinh x).symm #align complex.exp_sub_sinh Complex.exp_sub_sinh @[simp] theorem cosh_sub_sinh : cosh x - sinh x = exp (-x) := by rw [← mul_right_inj' (two_ne_zero' β„‚), mul_sub, two_cosh, two_sinh, add_sub_sub_cancel, two_mul] #align complex.cosh_sub_sinh Complex.cosh_sub_sinh @[simp] theorem sinh_sub_cosh : sinh x - cosh x = -exp (-x) := by rw [← neg_sub, cosh_sub_sinh] #align complex.sinh_sub_cosh Complex.sinh_sub_cosh @[simp] theorem cosh_sq_sub_sinh_sq : cosh x ^ 2 - sinh x ^ 2 = 1 := by rw [sq_sub_sq, cosh_add_sinh, cosh_sub_sinh, ← exp_add, add_neg_self, exp_zero] #align complex.cosh_sq_sub_sinh_sq Complex.cosh_sq_sub_sinh_sq theorem cosh_sq : cosh x ^ 2 = sinh x ^ 2 + 1 := by rw [← cosh_sq_sub_sinh_sq x] ring #align complex.cosh_sq Complex.cosh_sq theorem sinh_sq : sinh x ^ 2 = cosh x ^ 2 - 1 := by rw [← cosh_sq_sub_sinh_sq x] ring #align complex.sinh_sq Complex.sinh_sq theorem cosh_two_mul : cosh (2 * x) = cosh x ^ 2 + sinh x ^ 2 := by rw [two_mul, cosh_add, sq, sq] #align complex.cosh_two_mul Complex.cosh_two_mul theorem sinh_two_mul : sinh (2 * x) = 2 * sinh x * cosh x := by rw [two_mul, sinh_add] ring #align complex.sinh_two_mul Complex.sinh_two_mul theorem cosh_three_mul : cosh (3 * x) = 4 * cosh x ^ 3 - 3 * cosh x := by have h1 : x + 2 * x = 3 * x := by ring rw [← h1, cosh_add x (2 * x)] simp only [cosh_two_mul, sinh_two_mul] have h2 : sinh x * (2 * sinh x * cosh x) = 2 * cosh x * sinh x ^ 2 := by ring rw [h2, sinh_sq] ring #align complex.cosh_three_mul Complex.cosh_three_mul theorem sinh_three_mul : sinh (3 * x) = 4 * sinh x ^ 3 + 3 * sinh x := by have h1 : x + 2 * x = 3 * x := by ring rw [← h1, sinh_add x (2 * x)] simp only [cosh_two_mul, sinh_two_mul] have h2 : cosh x * (2 * sinh x * cosh x) = 2 * sinh x * cosh x ^ 2 := by ring rw [h2, cosh_sq] ring #align complex.sinh_three_mul Complex.sinh_three_mul @[simp] theorem sin_zero : sin 0 = 0 := by simp [sin] #align complex.sin_zero Complex.sin_zero @[simp] theorem sin_neg : sin (-x) = -sin x := by simp [sin, sub_eq_add_neg, exp_neg, (neg_div _ _).symm, add_mul] #align complex.sin_neg Complex.sin_neg theorem two_sin : 2 * sin x = (exp (-x * I) - exp (x * I)) * I := mul_div_cancelβ‚€ _ two_ne_zero #align complex.two_sin Complex.two_sin theorem two_cos : 2 * cos x = exp (x * I) + exp (-x * I) := mul_div_cancelβ‚€ _ two_ne_zero #align complex.two_cos Complex.two_cos theorem sinh_mul_I : sinh (x * I) = sin x * I := by rw [← mul_right_inj' (two_ne_zero' β„‚), two_sinh, ← mul_assoc, two_sin, mul_assoc, I_mul_I, mul_neg_one, neg_sub, neg_mul_eq_neg_mul] set_option linter.uppercaseLean3 false in #align complex.sinh_mul_I Complex.sinh_mul_I theorem cosh_mul_I : cosh (x * I) = cos x := by rw [← mul_right_inj' (two_ne_zero' β„‚), two_cosh, two_cos, neg_mul_eq_neg_mul] set_option linter.uppercaseLean3 false in #align complex.cosh_mul_I Complex.cosh_mul_I theorem tanh_mul_I : tanh (x * I) = tan x * I := by rw [tanh_eq_sinh_div_cosh, cosh_mul_I, sinh_mul_I, mul_div_right_comm, tan] set_option linter.uppercaseLean3 false in #align complex.tanh_mul_I Complex.tanh_mul_I theorem cos_mul_I : cos (x * I) = cosh x := by rw [← cosh_mul_I]; ring_nf; simp set_option linter.uppercaseLean3 false in #align complex.cos_mul_I Complex.cos_mul_I theorem sin_mul_I : sin (x * I) = sinh x * I := by have h : I * sin (x * I) = -sinh x := by rw [mul_comm, ← sinh_mul_I] ring_nf simp rw [← neg_neg (sinh x), ← h] apply Complex.ext <;> simp set_option linter.uppercaseLean3 false in #align complex.sin_mul_I Complex.sin_mul_I theorem tan_mul_I : tan (x * I) = tanh x * I := by rw [tan, sin_mul_I, cos_mul_I, mul_div_right_comm, tanh_eq_sinh_div_cosh] set_option linter.uppercaseLean3 false in #align complex.tan_mul_I Complex.tan_mul_I theorem sin_add : sin (x + y) = sin x * cos y + cos x * sin y := by rw [← mul_left_inj' I_ne_zero, ← sinh_mul_I, add_mul, add_mul, mul_right_comm, ← sinh_mul_I, mul_assoc, ← sinh_mul_I, ← cosh_mul_I, ← cosh_mul_I, sinh_add] #align complex.sin_add Complex.sin_add @[simp] theorem cos_zero : cos 0 = 1 := by simp [cos] #align complex.cos_zero Complex.cos_zero @[simp] theorem cos_neg : cos (-x) = cos x := by simp [cos, sub_eq_add_neg, exp_neg, add_comm] #align complex.cos_neg Complex.cos_neg private theorem cos_add_aux {a b c d : β„‚} : (a + b) * (c + d) - (b - a) * (d - c) * -1 = 2 * (a * c + b * d) := by ring theorem cos_add : cos (x + y) = cos x * cos y - sin x * sin y := by rw [← cosh_mul_I, add_mul, cosh_add, cosh_mul_I, cosh_mul_I, sinh_mul_I, sinh_mul_I, mul_mul_mul_comm, I_mul_I, mul_neg_one, sub_eq_add_neg] #align complex.cos_add Complex.cos_add theorem sin_sub : sin (x - y) = sin x * cos y - cos x * sin y := by simp [sub_eq_add_neg, sin_add, sin_neg, cos_neg] #align complex.sin_sub Complex.sin_sub theorem cos_sub : cos (x - y) = cos x * cos y + sin x * sin y := by simp [sub_eq_add_neg, cos_add, sin_neg, cos_neg] #align complex.cos_sub Complex.cos_sub theorem sin_add_mul_I (x y : β„‚) : sin (x + y * I) = sin x * cosh y + cos x * sinh y * I := by rw [sin_add, cos_mul_I, sin_mul_I, mul_assoc] set_option linter.uppercaseLean3 false in #align complex.sin_add_mul_I Complex.sin_add_mul_I theorem sin_eq (z : β„‚) : sin z = sin z.re * cosh z.im + cos z.re * sinh z.im * I := by convert sin_add_mul_I z.re z.im; exact (re_add_im z).symm #align complex.sin_eq Complex.sin_eq theorem cos_add_mul_I (x y : β„‚) : cos (x + y * I) = cos x * cosh y - sin x * sinh y * I := by rw [cos_add, cos_mul_I, sin_mul_I, mul_assoc] set_option linter.uppercaseLean3 false in #align complex.cos_add_mul_I Complex.cos_add_mul_I theorem cos_eq (z : β„‚) : cos z = cos z.re * cosh z.im - sin z.re * sinh z.im * I := by convert cos_add_mul_I z.re z.im; exact (re_add_im z).symm #align complex.cos_eq Complex.cos_eq theorem sin_sub_sin : sin x - sin y = 2 * sin ((x - y) / 2) * cos ((x + y) / 2) := by have s1 := sin_add ((x + y) / 2) ((x - y) / 2) have s2 := sin_sub ((x + y) / 2) ((x - y) / 2) rw [div_add_div_same, add_sub, add_right_comm, add_sub_cancel_right, half_add_self] at s1 rw [div_sub_div_same, ← sub_add, add_sub_cancel_left, half_add_self] at s2 rw [s1, s2] ring #align complex.sin_sub_sin Complex.sin_sub_sin theorem cos_sub_cos : cos x - cos y = -2 * sin ((x + y) / 2) * sin ((x - y) / 2) := by have s1 := cos_add ((x + y) / 2) ((x - y) / 2) have s2 := cos_sub ((x + y) / 2) ((x - y) / 2) rw [div_add_div_same, add_sub, add_right_comm, add_sub_cancel_right, half_add_self] at s1 rw [div_sub_div_same, ← sub_add, add_sub_cancel_left, half_add_self] at s2 rw [s1, s2] ring #align complex.cos_sub_cos Complex.cos_sub_cos theorem sin_add_sin : sin x + sin y = 2 * sin ((x + y) / 2) * cos ((x - y) / 2) := by simpa using sin_sub_sin x (-y) theorem cos_add_cos : cos x + cos y = 2 * cos ((x + y) / 2) * cos ((x - y) / 2) := by calc cos x + cos y = cos ((x + y) / 2 + (x - y) / 2) + cos ((x + y) / 2 - (x - y) / 2) := ?_ _ = cos ((x + y) / 2) * cos ((x - y) / 2) - sin ((x + y) / 2) * sin ((x - y) / 2) + (cos ((x + y) / 2) * cos ((x - y) / 2) + sin ((x + y) / 2) * sin ((x - y) / 2)) := ?_ _ = 2 * cos ((x + y) / 2) * cos ((x - y) / 2) := ?_ Β· congr <;> field_simp Β· rw [cos_add, cos_sub] ring #align complex.cos_add_cos Complex.cos_add_cos theorem sin_conj : sin (conj x) = conj (sin x) := by rw [← mul_left_inj' I_ne_zero, ← sinh_mul_I, ← conj_neg_I, ← RingHom.map_mul, ← RingHom.map_mul, sinh_conj, mul_neg, sinh_neg, sinh_mul_I, mul_neg] #align complex.sin_conj Complex.sin_conj @[simp] theorem ofReal_sin_ofReal_re (x : ℝ) : ((sin x).re : β„‚) = sin x := conj_eq_iff_re.1 <| by rw [← sin_conj, conj_ofReal] #align complex.of_real_sin_of_real_re Complex.ofReal_sin_ofReal_re @[simp, norm_cast] theorem ofReal_sin (x : ℝ) : (Real.sin x : β„‚) = sin x := ofReal_sin_ofReal_re _ #align complex.of_real_sin Complex.ofReal_sin @[simp] theorem sin_ofReal_im (x : ℝ) : (sin x).im = 0 := by rw [← ofReal_sin_ofReal_re, ofReal_im] #align complex.sin_of_real_im Complex.sin_ofReal_im theorem sin_ofReal_re (x : ℝ) : (sin x).re = Real.sin x := rfl #align complex.sin_of_real_re Complex.sin_ofReal_re theorem cos_conj : cos (conj x) = conj (cos x) := by rw [← cosh_mul_I, ← conj_neg_I, ← RingHom.map_mul, ← cosh_mul_I, cosh_conj, mul_neg, cosh_neg] #align complex.cos_conj Complex.cos_conj @[simp] theorem ofReal_cos_ofReal_re (x : ℝ) : ((cos x).re : β„‚) = cos x := conj_eq_iff_re.1 <| by rw [← cos_conj, conj_ofReal] #align complex.of_real_cos_of_real_re Complex.ofReal_cos_ofReal_re @[simp, norm_cast] theorem ofReal_cos (x : ℝ) : (Real.cos x : β„‚) = cos x := ofReal_cos_ofReal_re _ #align complex.of_real_cos Complex.ofReal_cos @[simp] theorem cos_ofReal_im (x : ℝ) : (cos x).im = 0 := by rw [← ofReal_cos_ofReal_re, ofReal_im] #align complex.cos_of_real_im Complex.cos_ofReal_im theorem cos_ofReal_re (x : ℝ) : (cos x).re = Real.cos x := rfl #align complex.cos_of_real_re Complex.cos_ofReal_re @[simp] theorem tan_zero : tan 0 = 0 := by simp [tan] #align complex.tan_zero Complex.tan_zero theorem tan_eq_sin_div_cos : tan x = sin x / cos x := rfl #align complex.tan_eq_sin_div_cos Complex.tan_eq_sin_div_cos theorem tan_mul_cos {x : β„‚} (hx : cos x β‰  0) : tan x * cos x = sin x := by rw [tan_eq_sin_div_cos, div_mul_cancelβ‚€ _ hx] #align complex.tan_mul_cos Complex.tan_mul_cos @[simp] theorem tan_neg : tan (-x) = -tan x := by simp [tan, neg_div] #align complex.tan_neg Complex.tan_neg theorem tan_conj : tan (conj x) = conj (tan x) := by rw [tan, sin_conj, cos_conj, ← map_divβ‚€, tan] #align complex.tan_conj Complex.tan_conj @[simp] theorem ofReal_tan_ofReal_re (x : ℝ) : ((tan x).re : β„‚) = tan x := conj_eq_iff_re.1 <| by rw [← tan_conj, conj_ofReal] #align complex.of_real_tan_of_real_re Complex.ofReal_tan_ofReal_re @[simp, norm_cast] theorem ofReal_tan (x : ℝ) : (Real.tan x : β„‚) = tan x := ofReal_tan_ofReal_re _ #align complex.of_real_tan Complex.ofReal_tan @[simp] theorem tan_ofReal_im (x : ℝ) : (tan x).im = 0 := by rw [← ofReal_tan_ofReal_re, ofReal_im] #align complex.tan_of_real_im Complex.tan_ofReal_im theorem tan_ofReal_re (x : ℝ) : (tan x).re = Real.tan x := rfl #align complex.tan_of_real_re Complex.tan_ofReal_re theorem cos_add_sin_I : cos x + sin x * I = exp (x * I) := by rw [← cosh_add_sinh, sinh_mul_I, cosh_mul_I] set_option linter.uppercaseLean3 false in #align complex.cos_add_sin_I Complex.cos_add_sin_I theorem cos_sub_sin_I : cos x - sin x * I = exp (-x * I) := by rw [neg_mul, ← cosh_sub_sinh, sinh_mul_I, cosh_mul_I] set_option linter.uppercaseLean3 false in #align complex.cos_sub_sin_I Complex.cos_sub_sin_I @[simp] theorem sin_sq_add_cos_sq : sin x ^ 2 + cos x ^ 2 = 1 := Eq.trans (by rw [cosh_mul_I, sinh_mul_I, mul_pow, I_sq, mul_neg_one, sub_neg_eq_add, add_comm]) (cosh_sq_sub_sinh_sq (x * I)) #align complex.sin_sq_add_cos_sq Complex.sin_sq_add_cos_sq @[simp] theorem cos_sq_add_sin_sq : cos x ^ 2 + sin x ^ 2 = 1 := by rw [add_comm, sin_sq_add_cos_sq] #align complex.cos_sq_add_sin_sq Complex.cos_sq_add_sin_sq
Mathlib/Data/Complex/Exponential.lean
720
720
theorem cos_two_mul' : cos (2 * x) = cos x ^ 2 - sin x ^ 2 := by
rw [two_mul, cos_add, ← sq, ← sq]
import Mathlib.Analysis.Normed.Group.InfiniteSum import Mathlib.Analysis.Normed.MulAction import Mathlib.Topology.Algebra.Order.LiminfLimsup import Mathlib.Topology.PartialHomeomorph #align_import analysis.asymptotics.asymptotics from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open Filter Set open scoped Classical open Topology Filter NNReal namespace Asymptotics set_option linter.uppercaseLean3 false variable {Ξ± : Type*} {Ξ² : Type*} {E : Type*} {F : Type*} {G : Type*} {E' : Type*} {F' : Type*} {G' : Type*} {E'' : Type*} {F'' : Type*} {G'' : Type*} {E''' : Type*} {R : Type*} {R' : Type*} {π•œ : Type*} {π•œ' : Type*} variable [Norm E] [Norm F] [Norm G] variable [SeminormedAddCommGroup E'] [SeminormedAddCommGroup F'] [SeminormedAddCommGroup G'] [NormedAddCommGroup E''] [NormedAddCommGroup F''] [NormedAddCommGroup G''] [SeminormedRing R] [SeminormedAddGroup E'''] [SeminormedRing R'] variable [NormedDivisionRing π•œ] [NormedDivisionRing π•œ'] variable {c c' c₁ cβ‚‚ : ℝ} {f : Ξ± β†’ E} {g : Ξ± β†’ F} {k : Ξ± β†’ G} variable {f' : Ξ± β†’ E'} {g' : Ξ± β†’ F'} {k' : Ξ± β†’ G'} variable {f'' : Ξ± β†’ E''} {g'' : Ξ± β†’ F''} {k'' : Ξ± β†’ G''} variable {l l' : Filter Ξ±} theorem IsBigOWith.isBigO (h : IsBigOWith c l f g) : f =O[l] g := by rw [IsBigO_def]; exact ⟨c, h⟩ #align asymptotics.is_O_with.is_O Asymptotics.IsBigOWith.isBigO theorem IsLittleO.isBigOWith (hgf : f =o[l] g) : IsBigOWith 1 l f g := hgf.def' zero_lt_one #align asymptotics.is_o.is_O_with Asymptotics.IsLittleO.isBigOWith theorem IsLittleO.isBigO (hgf : f =o[l] g) : f =O[l] g := hgf.isBigOWith.isBigO #align asymptotics.is_o.is_O Asymptotics.IsLittleO.isBigO theorem IsBigO.isBigOWith : f =O[l] g β†’ βˆƒ c : ℝ, IsBigOWith c l f g := isBigO_iff_isBigOWith.1 #align asymptotics.is_O.is_O_with Asymptotics.IsBigO.isBigOWith theorem IsBigOWith.weaken (h : IsBigOWith c l f g') (hc : c ≀ c') : IsBigOWith c' l f g' := IsBigOWith.of_bound <| mem_of_superset h.bound fun x hx => calc β€–f xβ€– ≀ c * β€–g' xβ€– := hx _ ≀ _ := by gcongr #align asymptotics.is_O_with.weaken Asymptotics.IsBigOWith.weaken theorem IsBigOWith.exists_pos (h : IsBigOWith c l f g') : βˆƒ c' > 0, IsBigOWith c' l f g' := ⟨max c 1, lt_of_lt_of_le zero_lt_one (le_max_right c 1), h.weaken <| le_max_left c 1⟩ #align asymptotics.is_O_with.exists_pos Asymptotics.IsBigOWith.exists_pos theorem IsBigO.exists_pos (h : f =O[l] g') : βˆƒ c > 0, IsBigOWith c l f g' := let ⟨_c, hc⟩ := h.isBigOWith hc.exists_pos #align asymptotics.is_O.exists_pos Asymptotics.IsBigO.exists_pos theorem IsBigOWith.exists_nonneg (h : IsBigOWith c l f g') : βˆƒ c' β‰₯ 0, IsBigOWith c' l f g' := let ⟨c, cpos, hc⟩ := h.exists_pos ⟨c, le_of_lt cpos, hc⟩ #align asymptotics.is_O_with.exists_nonneg Asymptotics.IsBigOWith.exists_nonneg theorem IsBigO.exists_nonneg (h : f =O[l] g') : βˆƒ c β‰₯ 0, IsBigOWith c l f g' := let ⟨_c, hc⟩ := h.isBigOWith hc.exists_nonneg #align asymptotics.is_O.exists_nonneg Asymptotics.IsBigO.exists_nonneg theorem isBigO_iff_eventually_isBigOWith : f =O[l] g' ↔ βˆ€αΆ  c in atTop, IsBigOWith c l f g' := isBigO_iff_isBigOWith.trans ⟨fun ⟨c, hc⟩ => mem_atTop_sets.2 ⟨c, fun _c' hc' => hc.weaken hc'⟩, fun h => h.exists⟩ #align asymptotics.is_O_iff_eventually_is_O_with Asymptotics.isBigO_iff_eventually_isBigOWith theorem isBigO_iff_eventually : f =O[l] g' ↔ βˆ€αΆ  c in atTop, βˆ€αΆ  x in l, β€–f xβ€– ≀ c * β€–g' xβ€– := isBigO_iff_eventually_isBigOWith.trans <| by simp only [IsBigOWith_def] #align asymptotics.is_O_iff_eventually Asymptotics.isBigO_iff_eventually theorem IsBigO.exists_mem_basis {ΞΉ} {p : ΞΉ β†’ Prop} {s : ΞΉ β†’ Set Ξ±} (h : f =O[l] g') (hb : l.HasBasis p s) : βˆƒ c > 0, βˆƒ i : ΞΉ, p i ∧ βˆ€ x ∈ s i, β€–f xβ€– ≀ c * β€–g' xβ€– := flip Exists.imp h.exists_pos fun c h => by simpa only [isBigOWith_iff, hb.eventually_iff, exists_prop] using h #align asymptotics.is_O.exists_mem_basis Asymptotics.IsBigO.exists_mem_basis theorem isBigOWith_inv (hc : 0 < c) : IsBigOWith c⁻¹ l f g ↔ βˆ€αΆ  x in l, c * β€–f xβ€– ≀ β€–g xβ€– := by simp only [IsBigOWith_def, ← div_eq_inv_mul, le_div_iff' hc] #align asymptotics.is_O_with_inv Asymptotics.isBigOWith_inv -- We prove this lemma with strange assumptions to get two lemmas below automatically theorem isLittleO_iff_nat_mul_le_aux (hβ‚€ : (βˆ€ x, 0 ≀ β€–f xβ€–) ∨ βˆ€ x, 0 ≀ β€–g xβ€–) : f =o[l] g ↔ βˆ€ n : β„•, βˆ€αΆ  x in l, ↑n * β€–f xβ€– ≀ β€–g xβ€– := by constructor Β· rintro H (_ | n) Β· refine (H.def one_pos).mono fun x hβ‚€' => ?_ rw [Nat.cast_zero, zero_mul] refine hβ‚€.elim (fun hf => (hf x).trans ?_) fun hg => hg x rwa [one_mul] at hβ‚€' Β· have : (0 : ℝ) < n.succ := Nat.cast_pos.2 n.succ_pos exact (isBigOWith_inv this).1 (H.def' <| inv_pos.2 this) Β· refine fun H => isLittleO_iff.2 fun Ξ΅ Ξ΅0 => ?_ rcases exists_nat_gt Ρ⁻¹ with ⟨n, hn⟩ have hnβ‚€ : (0 : ℝ) < n := (inv_pos.2 Ξ΅0).trans hn refine ((isBigOWith_inv hnβ‚€).2 (H n)).bound.mono fun x hfg => ?_ refine hfg.trans (mul_le_mul_of_nonneg_right (inv_le_of_inv_le Ξ΅0 hn.le) ?_) refine hβ‚€.elim (fun hf => nonneg_of_mul_nonneg_right ((hf x).trans hfg) ?_) fun h => h x exact inv_pos.2 hnβ‚€ #align asymptotics.is_o_iff_nat_mul_le_aux Asymptotics.isLittleO_iff_nat_mul_le_aux theorem isLittleO_iff_nat_mul_le : f =o[l] g' ↔ βˆ€ n : β„•, βˆ€αΆ  x in l, ↑n * β€–f xβ€– ≀ β€–g' xβ€– := isLittleO_iff_nat_mul_le_aux (Or.inr fun _x => norm_nonneg _) #align asymptotics.is_o_iff_nat_mul_le Asymptotics.isLittleO_iff_nat_mul_le theorem isLittleO_iff_nat_mul_le' : f' =o[l] g ↔ βˆ€ n : β„•, βˆ€αΆ  x in l, ↑n * β€–f' xβ€– ≀ β€–g xβ€– := isLittleO_iff_nat_mul_le_aux (Or.inl fun _x => norm_nonneg _) #align asymptotics.is_o_iff_nat_mul_le' Asymptotics.isLittleO_iff_nat_mul_le' @[nontriviality] theorem isLittleO_of_subsingleton [Subsingleton E'] : f' =o[l] g' := IsLittleO.of_bound fun c hc => by simp [Subsingleton.elim (f' _) 0, mul_nonneg hc.le] #align asymptotics.is_o_of_subsingleton Asymptotics.isLittleO_of_subsingleton @[nontriviality] theorem isBigO_of_subsingleton [Subsingleton E'] : f' =O[l] g' := isLittleO_of_subsingleton.isBigO #align asymptotics.is_O_of_subsingleton Asymptotics.isBigO_of_subsingleton theorem IsBigOWith.comp_tendsto (hcfg : IsBigOWith c l f g) {k : Ξ² β†’ Ξ±} {l' : Filter Ξ²} (hk : Tendsto k l' l) : IsBigOWith c l' (f ∘ k) (g ∘ k) := IsBigOWith.of_bound <| hk hcfg.bound #align asymptotics.is_O_with.comp_tendsto Asymptotics.IsBigOWith.comp_tendsto theorem IsBigO.comp_tendsto (hfg : f =O[l] g) {k : Ξ² β†’ Ξ±} {l' : Filter Ξ²} (hk : Tendsto k l' l) : (f ∘ k) =O[l'] (g ∘ k) := isBigO_iff_isBigOWith.2 <| hfg.isBigOWith.imp fun _c h => h.comp_tendsto hk #align asymptotics.is_O.comp_tendsto Asymptotics.IsBigO.comp_tendsto theorem IsLittleO.comp_tendsto (hfg : f =o[l] g) {k : Ξ² β†’ Ξ±} {l' : Filter Ξ²} (hk : Tendsto k l' l) : (f ∘ k) =o[l'] (g ∘ k) := IsLittleO.of_isBigOWith fun _c cpos => (hfg.forall_isBigOWith cpos).comp_tendsto hk #align asymptotics.is_o.comp_tendsto Asymptotics.IsLittleO.comp_tendsto @[simp] theorem isBigOWith_map {k : Ξ² β†’ Ξ±} {l : Filter Ξ²} : IsBigOWith c (map k l) f g ↔ IsBigOWith c l (f ∘ k) (g ∘ k) := by simp only [IsBigOWith_def] exact eventually_map #align asymptotics.is_O_with_map Asymptotics.isBigOWith_map @[simp] theorem isBigO_map {k : Ξ² β†’ Ξ±} {l : Filter Ξ²} : f =O[map k l] g ↔ (f ∘ k) =O[l] (g ∘ k) := by simp only [IsBigO_def, isBigOWith_map] #align asymptotics.is_O_map Asymptotics.isBigO_map @[simp] theorem isLittleO_map {k : Ξ² β†’ Ξ±} {l : Filter Ξ²} : f =o[map k l] g ↔ (f ∘ k) =o[l] (g ∘ k) := by simp only [IsLittleO_def, isBigOWith_map] #align asymptotics.is_o_map Asymptotics.isLittleO_map theorem IsBigOWith.mono (h : IsBigOWith c l' f g) (hl : l ≀ l') : IsBigOWith c l f g := IsBigOWith.of_bound <| hl h.bound #align asymptotics.is_O_with.mono Asymptotics.IsBigOWith.mono theorem IsBigO.mono (h : f =O[l'] g) (hl : l ≀ l') : f =O[l] g := isBigO_iff_isBigOWith.2 <| h.isBigOWith.imp fun _c h => h.mono hl #align asymptotics.is_O.mono Asymptotics.IsBigO.mono theorem IsLittleO.mono (h : f =o[l'] g) (hl : l ≀ l') : f =o[l] g := IsLittleO.of_isBigOWith fun _c cpos => (h.forall_isBigOWith cpos).mono hl #align asymptotics.is_o.mono Asymptotics.IsLittleO.mono theorem IsBigOWith.trans (hfg : IsBigOWith c l f g) (hgk : IsBigOWith c' l g k) (hc : 0 ≀ c) : IsBigOWith (c * c') l f k := by simp only [IsBigOWith_def] at * filter_upwards [hfg, hgk] with x hx hx' calc β€–f xβ€– ≀ c * β€–g xβ€– := hx _ ≀ c * (c' * β€–k xβ€–) := by gcongr _ = c * c' * β€–k xβ€– := (mul_assoc _ _ _).symm #align asymptotics.is_O_with.trans Asymptotics.IsBigOWith.trans @[trans] theorem IsBigO.trans {f : Ξ± β†’ E} {g : Ξ± β†’ F'} {k : Ξ± β†’ G} (hfg : f =O[l] g) (hgk : g =O[l] k) : f =O[l] k := let ⟨_c, cnonneg, hc⟩ := hfg.exists_nonneg let ⟨_c', hc'⟩ := hgk.isBigOWith (hc.trans hc' cnonneg).isBigO #align asymptotics.is_O.trans Asymptotics.IsBigO.trans instance transIsBigOIsBigO : @Trans (Ξ± β†’ E) (Ξ± β†’ F') (Ξ± β†’ G) (Β· =O[l] Β·) (Β· =O[l] Β·) (Β· =O[l] Β·) where trans := IsBigO.trans theorem IsLittleO.trans_isBigOWith (hfg : f =o[l] g) (hgk : IsBigOWith c l g k) (hc : 0 < c) : f =o[l] k := by simp only [IsLittleO_def] at * intro c' c'pos have : 0 < c' / c := div_pos c'pos hc exact ((hfg this).trans hgk this.le).congr_const (div_mul_cancelβ‚€ _ hc.ne') #align asymptotics.is_o.trans_is_O_with Asymptotics.IsLittleO.trans_isBigOWith @[trans] theorem IsLittleO.trans_isBigO {f : Ξ± β†’ E} {g : Ξ± β†’ F} {k : Ξ± β†’ G'} (hfg : f =o[l] g) (hgk : g =O[l] k) : f =o[l] k := let ⟨_c, cpos, hc⟩ := hgk.exists_pos hfg.trans_isBigOWith hc cpos #align asymptotics.is_o.trans_is_O Asymptotics.IsLittleO.trans_isBigO instance transIsLittleOIsBigO : @Trans (Ξ± β†’ E) (Ξ± β†’ F) (Ξ± β†’ G') (Β· =o[l] Β·) (Β· =O[l] Β·) (Β· =o[l] Β·) where trans := IsLittleO.trans_isBigO theorem IsBigOWith.trans_isLittleO (hfg : IsBigOWith c l f g) (hgk : g =o[l] k) (hc : 0 < c) : f =o[l] k := by simp only [IsLittleO_def] at * intro c' c'pos have : 0 < c' / c := div_pos c'pos hc exact (hfg.trans (hgk this) hc.le).congr_const (mul_div_cancelβ‚€ _ hc.ne') #align asymptotics.is_O_with.trans_is_o Asymptotics.IsBigOWith.trans_isLittleO @[trans] theorem IsBigO.trans_isLittleO {f : Ξ± β†’ E} {g : Ξ± β†’ F'} {k : Ξ± β†’ G} (hfg : f =O[l] g) (hgk : g =o[l] k) : f =o[l] k := let ⟨_c, cpos, hc⟩ := hfg.exists_pos hc.trans_isLittleO hgk cpos #align asymptotics.is_O.trans_is_o Asymptotics.IsBigO.trans_isLittleO instance transIsBigOIsLittleO : @Trans (Ξ± β†’ E) (Ξ± β†’ F') (Ξ± β†’ G) (Β· =O[l] Β·) (Β· =o[l] Β·) (Β· =o[l] Β·) where trans := IsBigO.trans_isLittleO @[trans] theorem IsLittleO.trans {f : Ξ± β†’ E} {g : Ξ± β†’ F} {k : Ξ± β†’ G} (hfg : f =o[l] g) (hgk : g =o[l] k) : f =o[l] k := hfg.trans_isBigOWith hgk.isBigOWith one_pos #align asymptotics.is_o.trans Asymptotics.IsLittleO.trans instance transIsLittleOIsLittleO : @Trans (Ξ± β†’ E) (Ξ± β†’ F) (Ξ± β†’ G) (Β· =o[l] Β·) (Β· =o[l] Β·) (Β· =o[l] Β·) where trans := IsLittleO.trans theorem _root_.Filter.Eventually.trans_isBigO {f : Ξ± β†’ E} {g : Ξ± β†’ F'} {k : Ξ± β†’ G} (hfg : βˆ€αΆ  x in l, β€–f xβ€– ≀ β€–g xβ€–) (hgk : g =O[l] k) : f =O[l] k := (IsBigO.of_bound' hfg).trans hgk #align filter.eventually.trans_is_O Filter.Eventually.trans_isBigO theorem _root_.Filter.Eventually.isBigO {f : Ξ± β†’ E} {g : Ξ± β†’ ℝ} {l : Filter Ξ±} (hfg : βˆ€αΆ  x in l, β€–f xβ€– ≀ g x) : f =O[l] g := IsBigO.of_bound' <| hfg.mono fun _x hx => hx.trans <| Real.le_norm_self _ #align filter.eventually.is_O Filter.Eventually.isBigO section variable (l) theorem isBigOWith_of_le' (hfg : βˆ€ x, β€–f xβ€– ≀ c * β€–g xβ€–) : IsBigOWith c l f g := IsBigOWith.of_bound <| univ_mem' hfg #align asymptotics.is_O_with_of_le' Asymptotics.isBigOWith_of_le' theorem isBigOWith_of_le (hfg : βˆ€ x, β€–f xβ€– ≀ β€–g xβ€–) : IsBigOWith 1 l f g := isBigOWith_of_le' l fun x => by rw [one_mul] exact hfg x #align asymptotics.is_O_with_of_le Asymptotics.isBigOWith_of_le theorem isBigO_of_le' (hfg : βˆ€ x, β€–f xβ€– ≀ c * β€–g xβ€–) : f =O[l] g := (isBigOWith_of_le' l hfg).isBigO #align asymptotics.is_O_of_le' Asymptotics.isBigO_of_le' theorem isBigO_of_le (hfg : βˆ€ x, β€–f xβ€– ≀ β€–g xβ€–) : f =O[l] g := (isBigOWith_of_le l hfg).isBigO #align asymptotics.is_O_of_le Asymptotics.isBigO_of_le end theorem isBigOWith_refl (f : Ξ± β†’ E) (l : Filter Ξ±) : IsBigOWith 1 l f f := isBigOWith_of_le l fun _ => le_rfl #align asymptotics.is_O_with_refl Asymptotics.isBigOWith_refl theorem isBigO_refl (f : Ξ± β†’ E) (l : Filter Ξ±) : f =O[l] f := (isBigOWith_refl f l).isBigO #align asymptotics.is_O_refl Asymptotics.isBigO_refl theorem _root_.Filter.EventuallyEq.isBigO {f₁ fβ‚‚ : Ξ± β†’ E} (hf : f₁ =αΆ [l] fβ‚‚) : f₁ =O[l] fβ‚‚ := hf.trans_isBigO (isBigO_refl _ _) theorem IsBigOWith.trans_le (hfg : IsBigOWith c l f g) (hgk : βˆ€ x, β€–g xβ€– ≀ β€–k xβ€–) (hc : 0 ≀ c) : IsBigOWith c l f k := (hfg.trans (isBigOWith_of_le l hgk) hc).congr_const <| mul_one c #align asymptotics.is_O_with.trans_le Asymptotics.IsBigOWith.trans_le theorem IsBigO.trans_le (hfg : f =O[l] g') (hgk : βˆ€ x, β€–g' xβ€– ≀ β€–k xβ€–) : f =O[l] k := hfg.trans (isBigO_of_le l hgk) #align asymptotics.is_O.trans_le Asymptotics.IsBigO.trans_le theorem IsLittleO.trans_le (hfg : f =o[l] g) (hgk : βˆ€ x, β€–g xβ€– ≀ β€–k xβ€–) : f =o[l] k := hfg.trans_isBigOWith (isBigOWith_of_le _ hgk) zero_lt_one #align asymptotics.is_o.trans_le Asymptotics.IsLittleO.trans_le theorem isLittleO_irrefl' (h : βˆƒαΆ  x in l, β€–f' xβ€– β‰  0) : Β¬f' =o[l] f' := by intro ho rcases ((ho.bound one_half_pos).and_frequently h).exists with ⟨x, hle, hne⟩ rw [one_div, ← div_eq_inv_mul] at hle exact (half_lt_self (lt_of_le_of_ne (norm_nonneg _) hne.symm)).not_le hle #align asymptotics.is_o_irrefl' Asymptotics.isLittleO_irrefl' theorem isLittleO_irrefl (h : βˆƒαΆ  x in l, f'' x β‰  0) : Β¬f'' =o[l] f'' := isLittleO_irrefl' <| h.mono fun _x => norm_ne_zero_iff.mpr #align asymptotics.is_o_irrefl Asymptotics.isLittleO_irrefl theorem IsBigO.not_isLittleO (h : f'' =O[l] g') (hf : βˆƒαΆ  x in l, f'' x β‰  0) : Β¬g' =o[l] f'' := fun h' => isLittleO_irrefl hf (h.trans_isLittleO h') #align asymptotics.is_O.not_is_o Asymptotics.IsBigO.not_isLittleO theorem IsLittleO.not_isBigO (h : f'' =o[l] g') (hf : βˆƒαΆ  x in l, f'' x β‰  0) : Β¬g' =O[l] f'' := fun h' => isLittleO_irrefl hf (h.trans_isBigO h') #align asymptotics.is_o.not_is_O Asymptotics.IsLittleO.not_isBigO @[simp] theorem isBigOWith_pure {x} : IsBigOWith c (pure x) f g ↔ β€–f xβ€– ≀ c * β€–g xβ€– := isBigOWith_iff #align asymptotics.is_O_with_pure Asymptotics.isBigOWith_pure theorem IsBigOWith.sup (h : IsBigOWith c l f g) (h' : IsBigOWith c l' f g) : IsBigOWith c (l βŠ” l') f g := IsBigOWith.of_bound <| mem_sup.2 ⟨h.bound, h'.bound⟩ #align asymptotics.is_O_with.sup Asymptotics.IsBigOWith.sup theorem IsBigOWith.sup' (h : IsBigOWith c l f g') (h' : IsBigOWith c' l' f g') : IsBigOWith (max c c') (l βŠ” l') f g' := IsBigOWith.of_bound <| mem_sup.2 ⟨(h.weaken <| le_max_left c c').bound, (h'.weaken <| le_max_right c c').bound⟩ #align asymptotics.is_O_with.sup' Asymptotics.IsBigOWith.sup' theorem IsBigO.sup (h : f =O[l] g') (h' : f =O[l'] g') : f =O[l βŠ” l'] g' := let ⟨_c, hc⟩ := h.isBigOWith let ⟨_c', hc'⟩ := h'.isBigOWith (hc.sup' hc').isBigO #align asymptotics.is_O.sup Asymptotics.IsBigO.sup theorem IsLittleO.sup (h : f =o[l] g) (h' : f =o[l'] g) : f =o[l βŠ” l'] g := IsLittleO.of_isBigOWith fun _c cpos => (h.forall_isBigOWith cpos).sup (h'.forall_isBigOWith cpos) #align asymptotics.is_o.sup Asymptotics.IsLittleO.sup @[simp] theorem isBigO_sup : f =O[l βŠ” l'] g' ↔ f =O[l] g' ∧ f =O[l'] g' := ⟨fun h => ⟨h.mono le_sup_left, h.mono le_sup_right⟩, fun h => h.1.sup h.2⟩ #align asymptotics.is_O_sup Asymptotics.isBigO_sup @[simp] theorem isLittleO_sup : f =o[l βŠ” l'] g ↔ f =o[l] g ∧ f =o[l'] g := ⟨fun h => ⟨h.mono le_sup_left, h.mono le_sup_right⟩, fun h => h.1.sup h.2⟩ #align asymptotics.is_o_sup Asymptotics.isLittleO_sup theorem isBigOWith_insert [TopologicalSpace Ξ±] {x : Ξ±} {s : Set Ξ±} {C : ℝ} {g : Ξ± β†’ E} {g' : Ξ± β†’ F} (h : β€–g xβ€– ≀ C * β€–g' xβ€–) : IsBigOWith C (𝓝[insert x s] x) g g' ↔ IsBigOWith C (𝓝[s] x) g g' := by simp_rw [IsBigOWith_def, nhdsWithin_insert, eventually_sup, eventually_pure, h, true_and_iff] #align asymptotics.is_O_with_insert Asymptotics.isBigOWith_insert protected theorem IsBigOWith.insert [TopologicalSpace Ξ±] {x : Ξ±} {s : Set Ξ±} {C : ℝ} {g : Ξ± β†’ E} {g' : Ξ± β†’ F} (h1 : IsBigOWith C (𝓝[s] x) g g') (h2 : β€–g xβ€– ≀ C * β€–g' xβ€–) : IsBigOWith C (𝓝[insert x s] x) g g' := (isBigOWith_insert h2).mpr h1 #align asymptotics.is_O_with.insert Asymptotics.IsBigOWith.insert theorem isLittleO_insert [TopologicalSpace Ξ±] {x : Ξ±} {s : Set Ξ±} {g : Ξ± β†’ E'} {g' : Ξ± β†’ F'} (h : g x = 0) : g =o[𝓝[insert x s] x] g' ↔ g =o[𝓝[s] x] g' := by simp_rw [IsLittleO_def] refine forall_congr' fun c => forall_congr' fun hc => ?_ rw [isBigOWith_insert] rw [h, norm_zero] exact mul_nonneg hc.le (norm_nonneg _) #align asymptotics.is_o_insert Asymptotics.isLittleO_insert protected theorem IsLittleO.insert [TopologicalSpace Ξ±] {x : Ξ±} {s : Set Ξ±} {g : Ξ± β†’ E'} {g' : Ξ± β†’ F'} (h1 : g =o[𝓝[s] x] g') (h2 : g x = 0) : g =o[𝓝[insert x s] x] g' := (isLittleO_insert h2).mpr h1 #align asymptotics.is_o.insert Asymptotics.IsLittleO.insert @[simp]
Mathlib/Analysis/Asymptotics/Asymptotics.lean
897
898
theorem isBigOWith_neg_right : (IsBigOWith c l f fun x => -g' x) ↔ IsBigOWith c l f g' := by
simp only [IsBigOWith_def, norm_neg]
import Mathlib.Algebra.CharP.Defs import Mathlib.Algebra.GroupPower.IterateHom import Mathlib.Algebra.GroupWithZero.Divisibility import Mathlib.Data.Int.ModEq import Mathlib.Data.Set.Pointwise.Basic import Mathlib.Dynamics.PeriodicPts import Mathlib.GroupTheory.Index import Mathlib.Order.Interval.Finset.Nat import Mathlib.Order.Interval.Set.Infinite #align_import group_theory.order_of_element from "leanprover-community/mathlib"@"d07245fd37786daa997af4f1a73a49fa3b748408" open Function Fintype Nat Pointwise Subgroup Submonoid variable {G H A Ξ± Ξ² : Type*} section Monoid variable [Monoid G] {a b x y : G} {n m : β„•} @[to_additive "`addOrderOf a` is the order of the element `a`, i.e. the `n β‰₯ 1`, s.t. `n β€’ a = 0` if it exists. Otherwise, i.e. if `a` is of infinite order, then `addOrderOf a` is `0` by convention."] noncomputable def orderOf (x : G) : β„• := minimalPeriod (x * Β·) 1 #align order_of orderOf #align add_order_of addOrderOf @[simp] theorem addOrderOf_ofMul_eq_orderOf (x : G) : addOrderOf (Additive.ofMul x) = orderOf x := rfl #align add_order_of_of_mul_eq_order_of addOrderOf_ofMul_eq_orderOf @[simp] lemma orderOf_ofAdd_eq_addOrderOf {Ξ± : Type*} [AddMonoid Ξ±] (a : Ξ±) : orderOf (Multiplicative.ofAdd a) = addOrderOf a := rfl #align order_of_of_add_eq_add_order_of orderOf_ofAdd_eq_addOrderOf @[to_additive] protected lemma IsOfFinOrder.orderOf_pos (h : IsOfFinOrder x) : 0 < orderOf x := minimalPeriod_pos_of_mem_periodicPts h #align order_of_pos' IsOfFinOrder.orderOf_pos #align add_order_of_pos' IsOfFinAddOrder.addOrderOf_pos @[to_additive addOrderOf_nsmul_eq_zero]
Mathlib/GroupTheory/OrderOfElement.lean
177
180
theorem pow_orderOf_eq_one (x : G) : x ^ orderOf x = 1 := by
convert Eq.trans _ (isPeriodicPt_minimalPeriod (x * Β·) 1) -- Porting note(#12129): additional beta reduction needed in the middle of the rewrite rw [orderOf, mul_left_iterate]; beta_reduce; rw [mul_one]
import Mathlib.NumberTheory.NumberField.Basic import Mathlib.RingTheory.Localization.NormTrace #align_import number_theory.number_field.norm from "leanprover-community/mathlib"@"00f91228655eecdcd3ac97a7fd8dbcb139fe990a" open scoped NumberField open Finset NumberField Algebra FiniteDimensional namespace RingOfIntegers variable {L : Type*} (K : Type*) [Field K] [Field L] [Algebra K L] [FiniteDimensional K L] noncomputable def norm [IsSeparable K L] : π“ž L β†’* π“ž K := RingOfIntegers.restrict_monoidHom ((Algebra.norm K).comp (algebraMap (π“ž L) L : (π“ž L) β†’* L)) fun x => isIntegral_norm K x.2 #align ring_of_integers.norm RingOfIntegers.norm @[simp] lemma coe_norm [IsSeparable K L] (x : π“ž L) : norm K x = Algebra.norm K (x : L) := rfl theorem coe_algebraMap_norm [IsSeparable K L] (x : π“ž L) : (algebraMap (π“ž K) (π“ž L) (norm K x) : L) = algebraMap K L (Algebra.norm K (x : L)) := rfl #align ring_of_integers.coe_algebra_map_norm RingOfIntegers.coe_algebraMap_norm theorem algebraMap_norm_algebraMap [IsSeparable K L] (x : π“ž K) : algebraMap _ K (norm K (algebraMap (π“ž K) (π“ž L) x)) = Algebra.norm K (algebraMap K L (algebraMap _ _ x)) := rfl #align ring_of_integers.coe_norm_algebra_map RingOfIntegers.algebraMap_norm_algebraMap theorem norm_algebraMap [IsSeparable K L] (x : π“ž K) : norm K (algebraMap (π“ž K) (π“ž L) x) = x ^ finrank K L := by rw [RingOfIntegers.ext_iff, RingOfIntegers.coe_eq_algebraMap, RingOfIntegers.algebraMap_norm_algebraMap, Algebra.norm_algebraMap, RingOfIntegers.coe_eq_algebraMap, map_pow] #align ring_of_integers.norm_algebra_map RingOfIntegers.norm_algebraMap theorem isUnit_norm_of_isGalois [IsGalois K L] {x : π“ž L} : IsUnit (norm K x) ↔ IsUnit x := by classical refine ⟨fun hx => ?_, IsUnit.map _⟩ replace hx : IsUnit (algebraMap (π“ž K) (π“ž L) <| norm K x) := hx.map (algebraMap (π“ž K) <| π“ž L) refine @isUnit_of_mul_isUnit_right (π“ž L) _ ⟨(univ \ {AlgEquiv.refl}).prod fun Οƒ : L ≃ₐ[K] L => Οƒ x, prod_mem fun Οƒ _ => x.2.map (Οƒ : L β†’+* L).toIntAlgHom⟩ _ ?_ convert hx using 1 ext convert_to ((univ \ {AlgEquiv.refl}).prod fun Οƒ : L ≃ₐ[K] L => Οƒ x) * ∏ Οƒ ∈ {(AlgEquiv.refl : L ≃ₐ[K] L)}, Οƒ x = _ Β· rw [prod_singleton, AlgEquiv.coe_refl, _root_.id, RingOfIntegers.coe_eq_algebraMap, map_mul, RingOfIntegers.map_mk] Β· rw [prod_sdiff <| subset_univ _, ← norm_eq_prod_automorphisms, coe_algebraMap_norm] #align ring_of_integers.is_unit_norm_of_is_galois RingOfIntegers.isUnit_norm_of_isGalois
Mathlib/NumberTheory/NumberField/Norm.lean
90
99
theorem dvd_norm [IsGalois K L] (x : π“ž L) : x ∣ algebraMap (π“ž K) (π“ž L) (norm K x) := by
classical have hint : IsIntegral β„€ (∏ Οƒ ∈ univ.erase (AlgEquiv.refl : L ≃ₐ[K] L), Οƒ x) := IsIntegral.prod _ (fun Οƒ _ => ((RingOfIntegers.isIntegral_coe x).map Οƒ)) refine ⟨⟨_, hint⟩, ?_⟩ ext rw [coe_algebraMap_norm K x, norm_eq_prod_automorphisms] simp [← Finset.mul_prod_erase _ _ (mem_univ AlgEquiv.refl)]
import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Algebra.BigOperators.Ring.List import Mathlib.Data.Int.ModEq import Mathlib.Data.Nat.Bits import Mathlib.Data.Nat.Log import Mathlib.Data.List.Indexes import Mathlib.Data.List.Palindrome import Mathlib.Tactic.IntervalCases import Mathlib.Tactic.Linarith import Mathlib.Tactic.Ring #align_import data.nat.digits from "leanprover-community/mathlib"@"369525b73f229ccd76a6ec0e0e0bf2be57599768" namespace Nat variable {n : β„•} def digitsAux0 : β„• β†’ List β„• | 0 => [] | n + 1 => [n + 1] #align nat.digits_aux_0 Nat.digitsAux0 def digitsAux1 (n : β„•) : List β„• := List.replicate n 1 #align nat.digits_aux_1 Nat.digitsAux1 def digitsAux (b : β„•) (h : 2 ≀ b) : β„• β†’ List β„• | 0 => [] | n + 1 => ((n + 1) % b) :: digitsAux b h ((n + 1) / b) decreasing_by exact Nat.div_lt_self (Nat.succ_pos _) h #align nat.digits_aux Nat.digitsAux @[simp] theorem digitsAux_zero (b : β„•) (h : 2 ≀ b) : digitsAux b h 0 = [] := by rw [digitsAux] #align nat.digits_aux_zero Nat.digitsAux_zero theorem digitsAux_def (b : β„•) (h : 2 ≀ b) (n : β„•) (w : 0 < n) : digitsAux b h n = (n % b) :: digitsAux b h (n / b) := by cases n Β· cases w Β· rw [digitsAux] #align nat.digits_aux_def Nat.digitsAux_def def digits : β„• β†’ β„• β†’ List β„• | 0 => digitsAux0 | 1 => digitsAux1 | b + 2 => digitsAux (b + 2) (by norm_num) #align nat.digits Nat.digits @[simp] theorem digits_zero (b : β„•) : digits b 0 = [] := by rcases b with (_ | ⟨_ | ⟨_⟩⟩) <;> simp [digits, digitsAux0, digitsAux1] #align nat.digits_zero Nat.digits_zero -- @[simp] -- Porting note (#10618): simp can prove this theorem digits_zero_zero : digits 0 0 = [] := rfl #align nat.digits_zero_zero Nat.digits_zero_zero @[simp] theorem digits_zero_succ (n : β„•) : digits 0 n.succ = [n + 1] := rfl #align nat.digits_zero_succ Nat.digits_zero_succ theorem digits_zero_succ' : βˆ€ {n : β„•}, n β‰  0 β†’ digits 0 n = [n] | 0, h => (h rfl).elim | _ + 1, _ => rfl #align nat.digits_zero_succ' Nat.digits_zero_succ' @[simp] theorem digits_one (n : β„•) : digits 1 n = List.replicate n 1 := rfl #align nat.digits_one Nat.digits_one -- @[simp] -- Porting note (#10685): dsimp can prove this theorem digits_one_succ (n : β„•) : digits 1 (n + 1) = 1 :: digits 1 n := rfl #align nat.digits_one_succ Nat.digits_one_succ theorem digits_add_two_add_one (b n : β„•) : digits (b + 2) (n + 1) = ((n + 1) % (b + 2)) :: digits (b + 2) ((n + 1) / (b + 2)) := by simp [digits, digitsAux_def] #align nat.digits_add_two_add_one Nat.digits_add_two_add_one @[simp] lemma digits_of_two_le_of_pos {b : β„•} (hb : 2 ≀ b) (hn : 0 < n) : Nat.digits b n = n % b :: Nat.digits b (n / b) := by rw [Nat.eq_add_of_sub_eq hb rfl, Nat.eq_add_of_sub_eq hn rfl, Nat.digits_add_two_add_one] theorem digits_def' : βˆ€ {b : β„•} (_ : 1 < b) {n : β„•} (_ : 0 < n), digits b n = (n % b) :: digits b (n / b) | 0, h => absurd h (by decide) | 1, h => absurd h (by decide) | b + 2, _ => digitsAux_def _ (by simp) _ #align nat.digits_def' Nat.digits_def' @[simp] theorem digits_of_lt (b x : β„•) (hx : x β‰  0) (hxb : x < b) : digits b x = [x] := by rcases exists_eq_succ_of_ne_zero hx with ⟨x, rfl⟩ rcases Nat.exists_eq_add_of_le' ((Nat.le_add_left 1 x).trans_lt hxb) with ⟨b, rfl⟩ rw [digits_add_two_add_one, div_eq_of_lt hxb, digits_zero, mod_eq_of_lt hxb] #align nat.digits_of_lt Nat.digits_of_lt theorem digits_add (b : β„•) (h : 1 < b) (x y : β„•) (hxb : x < b) (hxy : x β‰  0 ∨ y β‰  0) : digits b (x + b * y) = x :: digits b y := by rcases Nat.exists_eq_add_of_le' h with ⟨b, rfl : _ = _ + 2⟩ cases y Β· simp [hxb, hxy.resolve_right (absurd rfl)] dsimp [digits] rw [digitsAux_def] Β· congr Β· simp [Nat.add_mod, mod_eq_of_lt hxb] Β· simp [add_mul_div_left, div_eq_of_lt hxb] Β· apply Nat.succ_pos #align nat.digits_add Nat.digits_add -- If we had a function converting a list into a polynomial, -- and appropriate lemmas about that function, -- we could rewrite this in terms of that. def ofDigits {Ξ± : Type*} [Semiring Ξ±] (b : Ξ±) : List β„• β†’ Ξ± | [] => 0 | h :: t => h + b * ofDigits b t #align nat.of_digits Nat.ofDigits theorem ofDigits_eq_foldr {Ξ± : Type*} [Semiring Ξ±] (b : Ξ±) (L : List β„•) : ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L := by induction' L with d L ih Β· rfl Β· dsimp [ofDigits] rw [ih] #align nat.of_digits_eq_foldr Nat.ofDigits_eq_foldr theorem ofDigits_eq_sum_map_with_index_aux (b : β„•) (l : List β„•) : ((List.range l.length).zipWith ((fun i a : β„• => a * b ^ (i + 1))) l).sum = b * ((List.range l.length).zipWith (fun i a => a * b ^ i) l).sum := by suffices (List.range l.length).zipWith (fun i a : β„• => a * b ^ (i + 1)) l = (List.range l.length).zipWith (fun i a => b * (a * b ^ i)) l by simp [this] congr; ext; simp [pow_succ]; ring #align nat.of_digits_eq_sum_map_with_index_aux Nat.ofDigits_eq_sum_map_with_index_aux theorem ofDigits_eq_sum_mapIdx (b : β„•) (L : List β„•) : ofDigits b L = (L.mapIdx fun i a => a * b ^ i).sum := by rw [List.mapIdx_eq_enum_map, List.enum_eq_zip_range, List.map_uncurry_zip_eq_zipWith, ofDigits_eq_foldr] induction' L with hd tl hl Β· simp Β· simpa [List.range_succ_eq_map, List.zipWith_map_left, ofDigits_eq_sum_map_with_index_aux] using Or.inl hl #align nat.of_digits_eq_sum_map_with_index Nat.ofDigits_eq_sum_mapIdx @[simp] theorem ofDigits_nil {b : β„•} : ofDigits b [] = 0 := rfl @[simp] theorem ofDigits_singleton {b n : β„•} : ofDigits b [n] = n := by simp [ofDigits] #align nat.of_digits_singleton Nat.ofDigits_singleton @[simp] theorem ofDigits_one_cons {Ξ± : Type*} [Semiring Ξ±] (h : β„•) (L : List β„•) : ofDigits (1 : Ξ±) (h :: L) = h + ofDigits 1 L := by simp [ofDigits] #align nat.of_digits_one_cons Nat.ofDigits_one_cons theorem ofDigits_cons {b hd} {tl : List β„•} : ofDigits b (hd :: tl) = hd + b * ofDigits b tl := rfl theorem ofDigits_append {b : β„•} {l1 l2 : List β„•} : ofDigits b (l1 ++ l2) = ofDigits b l1 + b ^ l1.length * ofDigits b l2 := by induction' l1 with hd tl IH Β· simp [ofDigits] Β· rw [ofDigits, List.cons_append, ofDigits, IH, List.length_cons, pow_succ'] ring #align nat.of_digits_append Nat.ofDigits_append @[norm_cast] theorem coe_ofDigits (Ξ± : Type*) [Semiring Ξ±] (b : β„•) (L : List β„•) : ((ofDigits b L : β„•) : Ξ±) = ofDigits (b : Ξ±) L := by induction' L with d L ih Β· simp [ofDigits] Β· dsimp [ofDigits]; push_cast; rw [ih] #align nat.coe_of_digits Nat.coe_ofDigits @[norm_cast] theorem coe_int_ofDigits (b : β„•) (L : List β„•) : ((ofDigits b L : β„•) : β„€) = ofDigits (b : β„€) L := by induction' L with d L _ Β· rfl Β· dsimp [ofDigits]; push_cast; simp only #align nat.coe_int_of_digits Nat.coe_int_ofDigits theorem digits_zero_of_eq_zero {b : β„•} (h : b β‰  0) : βˆ€ {L : List β„•} (_ : ofDigits b L = 0), βˆ€ l ∈ L, l = 0 | _ :: _, h0, _, List.Mem.head .. => Nat.eq_zero_of_add_eq_zero_right h0 | _ :: _, h0, _, List.Mem.tail _ hL => digits_zero_of_eq_zero h (mul_right_injectiveβ‚€ h (Nat.eq_zero_of_add_eq_zero_left h0)) _ hL #align nat.digits_zero_of_eq_zero Nat.digits_zero_of_eq_zero theorem digits_ofDigits (b : β„•) (h : 1 < b) (L : List β„•) (w₁ : βˆ€ l ∈ L, l < b) (wβ‚‚ : βˆ€ h : L β‰  [], L.getLast h β‰  0) : digits b (ofDigits b L) = L := by induction' L with d L ih Β· dsimp [ofDigits] simp Β· dsimp [ofDigits] replace wβ‚‚ := wβ‚‚ (by simp) rw [digits_add b h] Β· rw [ih] Β· intro l m apply w₁ exact List.mem_cons_of_mem _ m Β· intro h rw [List.getLast_cons h] at wβ‚‚ convert wβ‚‚ Β· exact w₁ d (List.mem_cons_self _ _) Β· by_cases h' : L = [] Β· rcases h' with rfl left simpa using wβ‚‚ Β· right contrapose! wβ‚‚ refine digits_zero_of_eq_zero h.ne_bot wβ‚‚ _ ?_ rw [List.getLast_cons h'] exact List.getLast_mem h' #align nat.digits_of_digits Nat.digits_ofDigits theorem ofDigits_digits (b n : β„•) : ofDigits b (digits b n) = n := by cases' b with b Β· cases' n with n Β· rfl Β· change ofDigits 0 [n + 1] = n + 1 dsimp [ofDigits] Β· cases' b with b Β· induction' n with n ih Β· rfl Β· rw [Nat.zero_add] at ih ⊒ simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ] Β· apply Nat.strongInductionOn n _ clear n intro n h cases n Β· rw [digits_zero] rfl Β· simp only [Nat.succ_eq_add_one, digits_add_two_add_one] dsimp [ofDigits] rw [h _ (Nat.div_lt_self' _ b)] rw [Nat.mod_add_div] #align nat.of_digits_digits Nat.ofDigits_digits theorem ofDigits_one (L : List β„•) : ofDigits 1 L = L.sum := by induction' L with _ _ ih Β· rfl Β· simp [ofDigits, List.sum_cons, ih] #align nat.of_digits_one Nat.ofDigits_one theorem digits_eq_nil_iff_eq_zero {b n : β„•} : digits b n = [] ↔ n = 0 := by constructor Β· intro h have : ofDigits b (digits b n) = ofDigits b [] := by rw [h] convert this rw [ofDigits_digits] Β· rintro rfl simp #align nat.digits_eq_nil_iff_eq_zero Nat.digits_eq_nil_iff_eq_zero theorem digits_ne_nil_iff_ne_zero {b n : β„•} : digits b n β‰  [] ↔ n β‰  0 := not_congr digits_eq_nil_iff_eq_zero #align nat.digits_ne_nil_iff_ne_zero Nat.digits_ne_nil_iff_ne_zero theorem digits_eq_cons_digits_div {b n : β„•} (h : 1 < b) (w : n β‰  0) : digits b n = (n % b) :: digits b (n / b) := by rcases b with (_ | _ | b) Β· rw [digits_zero_succ' w, Nat.mod_zero, Nat.div_zero, Nat.digits_zero_zero] Β· norm_num at h rcases n with (_ | n) Β· norm_num at w Β· simp only [digits_add_two_add_one, ne_eq] #align nat.digits_eq_cons_digits_div Nat.digits_eq_cons_digits_div theorem digits_getLast {b : β„•} (m : β„•) (h : 1 < b) (p q) : (digits b m).getLast p = (digits b (m / b)).getLast q := by by_cases hm : m = 0 Β· simp [hm] simp only [digits_eq_cons_digits_div h hm] rw [List.getLast_cons] #align nat.digits_last Nat.digits_getLast theorem digits.injective (b : β„•) : Function.Injective b.digits := Function.LeftInverse.injective (ofDigits_digits b) #align nat.digits.injective Nat.digits.injective @[simp] theorem digits_inj_iff {b n m : β„•} : b.digits n = b.digits m ↔ n = m := (digits.injective b).eq_iff #align nat.digits_inj_iff Nat.digits_inj_iff theorem digits_len (b n : β„•) (hb : 1 < b) (hn : n β‰  0) : (b.digits n).length = b.log n + 1 := by induction' n using Nat.strong_induction_on with n IH rw [digits_eq_cons_digits_div hb hn, List.length] by_cases h : n / b = 0 Β· have hb0 : b β‰  0 := (Nat.succ_le_iff.1 hb).ne_bot simp [h, log_eq_zero_iff, ← Nat.div_eq_zero_iff hb0.bot_lt] Β· have : n / b < n := div_lt_self (Nat.pos_of_ne_zero hn) hb rw [IH _ this h, log_div_base, tsub_add_cancel_of_le] refine Nat.succ_le_of_lt (log_pos hb ?_) contrapose! h exact div_eq_of_lt h #align nat.digits_len Nat.digits_len theorem getLast_digit_ne_zero (b : β„•) {m : β„•} (hm : m β‰  0) : (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) β‰  0 := by rcases b with (_ | _ | b) Β· cases m Β· cases hm rfl Β· simp Β· cases m Β· cases hm rfl rename β„• => m simp only [zero_add, digits_one, List.getLast_replicate_succ m 1] exact Nat.one_ne_zero revert hm apply Nat.strongInductionOn m intro n IH hn by_cases hnb : n < b + 2 Β· simpa only [digits_of_lt (b + 2) n hn hnb] Β· rw [digits_getLast n (le_add_left 2 b)] refine IH _ (Nat.div_lt_self hn.bot_lt (one_lt_succ_succ b)) ?_ rw [← pos_iff_ne_zero] exact Nat.div_pos (le_of_not_lt hnb) (zero_lt_succ (succ b)) #align nat.last_digit_ne_zero Nat.getLast_digit_ne_zero theorem mul_ofDigits (n : β„•) {b : β„•} {l : List β„•} : n * ofDigits b l = ofDigits b (l.map (n * Β·)) := by induction l with | nil => rfl | cons hd tl ih => rw [List.map_cons, ofDigits_cons, ofDigits_cons, ← ih] ring theorem ofDigits_add_ofDigits_eq_ofDigits_zipWith_of_length_eq {b : β„•} {l1 l2 : List β„•} (h : l1.length = l2.length) : ofDigits b l1 + ofDigits b l2 = ofDigits b (l1.zipWith (Β· + Β·) l2) := by induction l1 generalizing l2 with | nil => simp_all [eq_comm, List.length_eq_zero, ofDigits] | cons hd₁ tl₁ ih₁ => induction l2 generalizing tl₁ with | nil => simp_all | cons hdβ‚‚ tlβ‚‚ ihβ‚‚ => simp_all only [List.length_cons, succ_eq_add_one, ofDigits_cons, add_left_inj, eq_comm, List.zipWith_cons_cons, add_eq] rw [← ih₁ h.symm, mul_add] ac_rfl theorem digits_lt_base' {b m : β„•} : βˆ€ {d}, d ∈ digits (b + 2) m β†’ d < b + 2 := by apply Nat.strongInductionOn m intro n IH d hd cases' n with n Β· rw [digits_zero] at hd cases hd -- base b+2 expansion of 0 has no digits rw [digits_add_two_add_one] at hd cases hd Β· exact n.succ.mod_lt (by simp) -- Porting note: Previous code (single line) contained linarith. -- . exact IH _ (Nat.div_lt_self (Nat.succ_pos _) (by linarith)) hd Β· apply IH ((n + 1) / (b + 2)) Β· apply Nat.div_lt_self <;> omega Β· assumption #align nat.digits_lt_base' Nat.digits_lt_base' theorem digits_lt_base {b m d : β„•} (hb : 1 < b) (hd : d ∈ digits b m) : d < b := by rcases b with (_ | _ | b) <;> try simp_all exact digits_lt_base' hd #align nat.digits_lt_base Nat.digits_lt_base theorem ofDigits_lt_base_pow_length' {b : β„•} {l : List β„•} (hl : βˆ€ x ∈ l, x < b + 2) : ofDigits (b + 2) l < (b + 2) ^ l.length := by induction' l with hd tl IH Β· simp [ofDigits] Β· rw [ofDigits, List.length_cons, pow_succ] have : (ofDigits (b + 2) tl + 1) * (b + 2) ≀ (b + 2) ^ tl.length * (b + 2) := mul_le_mul (IH fun x hx => hl _ (List.mem_cons_of_mem _ hx)) (by rfl) (by simp only [zero_le]) (Nat.zero_le _) suffices ↑hd < b + 2 by linarith exact hl hd (List.mem_cons_self _ _) #align nat.of_digits_lt_base_pow_length' Nat.ofDigits_lt_base_pow_length' theorem ofDigits_lt_base_pow_length {b : β„•} {l : List β„•} (hb : 1 < b) (hl : βˆ€ x ∈ l, x < b) : ofDigits b l < b ^ l.length := by rcases b with (_ | _ | b) <;> try simp_all exact ofDigits_lt_base_pow_length' hl #align nat.of_digits_lt_base_pow_length Nat.ofDigits_lt_base_pow_length theorem lt_base_pow_length_digits' {b m : β„•} : m < (b + 2) ^ (digits (b + 2) m).length := by convert @ofDigits_lt_base_pow_length' b (digits (b + 2) m) fun _ => digits_lt_base' rw [ofDigits_digits (b + 2) m] #align nat.lt_base_pow_length_digits' Nat.lt_base_pow_length_digits' theorem lt_base_pow_length_digits {b m : β„•} (hb : 1 < b) : m < b ^ (digits b m).length := by rcases b with (_ | _ | b) <;> try simp_all exact lt_base_pow_length_digits' #align nat.lt_base_pow_length_digits Nat.lt_base_pow_length_digits theorem ofDigits_digits_append_digits {b m n : β„•} : ofDigits b (digits b n ++ digits b m) = n + b ^ (digits b n).length * m := by rw [ofDigits_append, ofDigits_digits, ofDigits_digits] #align nat.of_digits_digits_append_digits Nat.ofDigits_digits_append_digits theorem digits_append_digits {b m n : β„•} (hb : 0 < b) : digits b n ++ digits b m = digits b (n + b ^ (digits b n).length * m) := by rcases eq_or_lt_of_le (Nat.succ_le_of_lt hb) with (rfl | hb) Β· simp [List.replicate_add] rw [← ofDigits_digits_append_digits] refine (digits_ofDigits b hb _ (fun l hl => ?_) (fun h_append => ?_)).symm Β· rcases (List.mem_append.mp hl) with (h | h) <;> exact digits_lt_base hb h Β· by_cases h : digits b m = [] Β· simp only [h, List.append_nil] at h_append ⊒ exact getLast_digit_ne_zero b <| digits_ne_nil_iff_ne_zero.mp h_append Β· exact (List.getLast_append' _ _ h) β–Έ (getLast_digit_ne_zero _ <| digits_ne_nil_iff_ne_zero.mp h) theorem digits_len_le_digits_len_succ (b n : β„•) : (digits b n).length ≀ (digits b (n + 1)).length := by rcases Decidable.eq_or_ne n 0 with (rfl | hn) Β· simp rcases le_or_lt b 1 with hb | hb Β· interval_cases b <;> simp_arith [digits_zero_succ', hn] simpa [digits_len, hb, hn] using log_mono_right (le_succ _) #align nat.digits_len_le_digits_len_succ Nat.digits_len_le_digits_len_succ theorem le_digits_len_le (b n m : β„•) (h : n ≀ m) : (digits b n).length ≀ (digits b m).length := monotone_nat_of_le_succ (digits_len_le_digits_len_succ b) h #align nat.le_digits_len_le Nat.le_digits_len_le @[mono] theorem ofDigits_monotone {p q : β„•} (L : List β„•) (h : p ≀ q) : ofDigits p L ≀ ofDigits q L := by induction' L with _ _ hi Β· rfl Β· simp only [ofDigits, cast_id, add_le_add_iff_left] exact Nat.mul_le_mul h hi theorem sum_le_ofDigits {p : β„•} (L : List β„•) (h : 1 ≀ p) : L.sum ≀ ofDigits p L := (ofDigits_one L).symm β–Έ ofDigits_monotone L h theorem digit_sum_le (p n : β„•) : List.sum (digits p n) ≀ n := by induction' n with n Β· exact digits_zero _ β–Έ Nat.le_refl (List.sum []) Β· induction' p with p Β· rw [digits_zero_succ, List.sum_cons, List.sum_nil, add_zero] Β· nth_rw 2 [← ofDigits_digits p.succ (n + 1)] rw [← ofDigits_one <| digits p.succ n.succ] exact ofDigits_monotone (digits p.succ n.succ) <| Nat.succ_pos p theorem pow_length_le_mul_ofDigits {b : β„•} {l : List β„•} (hl : l β‰  []) (hl2 : l.getLast hl β‰  0) : (b + 2) ^ l.length ≀ (b + 2) * ofDigits (b + 2) l := by rw [← List.dropLast_append_getLast hl] simp only [List.length_append, List.length, zero_add, List.length_dropLast, ofDigits_append, List.length_dropLast, ofDigits_singleton, add_comm (l.length - 1), pow_add, pow_one] apply Nat.mul_le_mul_left refine le_trans ?_ (Nat.le_add_left _ _) have : 0 < l.getLast hl := by rwa [pos_iff_ne_zero] convert Nat.mul_le_mul_left ((b + 2) ^ (l.length - 1)) this using 1 rw [Nat.mul_one] #align nat.pow_length_le_mul_of_digits Nat.pow_length_le_mul_ofDigits theorem base_pow_length_digits_le' (b m : β„•) (hm : m β‰  0) : (b + 2) ^ (digits (b + 2) m).length ≀ (b + 2) * m := by have : digits (b + 2) m β‰  [] := digits_ne_nil_iff_ne_zero.mpr hm convert @pow_length_le_mul_ofDigits b (digits (b+2) m) this (getLast_digit_ne_zero _ hm) rw [ofDigits_digits] #align nat.base_pow_length_digits_le' Nat.base_pow_length_digits_le' theorem base_pow_length_digits_le (b m : β„•) (hb : 1 < b) : m β‰  0 β†’ b ^ (digits b m).length ≀ b * m := by rcases b with (_ | _ | b) <;> try simp_all exact base_pow_length_digits_le' b m #align nat.base_pow_length_digits_le Nat.base_pow_length_digits_le lemma ofDigits_div_eq_ofDigits_tail {p : β„•} (hpos : 0 < p) (digits : List β„•) (w₁ : βˆ€ l ∈ digits, l < p) : ofDigits p digits / p = ofDigits p digits.tail := by induction' digits with hd tl Β· simp [ofDigits] Β· refine Eq.trans (add_mul_div_left hd _ hpos) ?_ rw [Nat.div_eq_of_lt <| w₁ _ <| List.mem_cons_self _ _, zero_add] rfl lemma ofDigits_div_pow_eq_ofDigits_drop {p : β„•} (i : β„•) (hpos : 0 < p) (digits : List β„•) (w₁ : βˆ€ l ∈ digits, l < p) : ofDigits p digits / p ^ i = ofDigits p (digits.drop i) := by induction' i with i hi Β· simp Β· rw [Nat.pow_succ, ← Nat.div_div_eq_div_mul, hi, ofDigits_div_eq_ofDigits_tail hpos (List.drop i digits) fun x hx ↦ w₁ x <| List.mem_of_mem_drop hx, ← List.drop_one, List.drop_drop, add_comm] lemma self_div_pow_eq_ofDigits_drop {p : β„•} (i n : β„•) (h : 2 ≀ p): n / p ^ i = ofDigits p ((p.digits n).drop i) := by convert ofDigits_div_pow_eq_ofDigits_drop i (zero_lt_of_lt h) (p.digits n) (fun l hl ↦ digits_lt_base h hl) exact (ofDigits_digits p n).symm open Finset theorem sub_one_mul_sum_div_pow_eq_sub_sum_digits {p : β„•} (L : List β„•) {h_nonempty} (h_ne_zero : L.getLast h_nonempty β‰  0) (h_lt : βˆ€ l ∈ L, l < p) : (p - 1) * βˆ‘ i ∈ range L.length, (ofDigits p L) / p ^ i.succ = (ofDigits p L) - L.sum := by obtain h | rfl | h : 1 < p ∨ 1 = p ∨ p < 1 := trichotomous 1 p Β· induction' L with hd tl ih Β· simp [ofDigits] Β· simp only [List.length_cons, List.sum_cons, self_div_pow_eq_ofDigits_drop _ _ h, digits_ofDigits p h (hd :: tl) h_lt (fun _ => h_ne_zero)] simp only [ofDigits] rw [sum_range_succ, Nat.cast_id] simp only [List.drop, List.drop_length] obtain rfl | h' := em <| tl = [] Β· simp [ofDigits] Β· have w₁' := fun l hl ↦ h_lt l <| List.mem_cons_of_mem hd hl have wβ‚‚' := fun (h : tl β‰  []) ↦ (List.getLast_cons h) β–Έ h_ne_zero have ih := ih (wβ‚‚' h') w₁' simp only [self_div_pow_eq_ofDigits_drop _ _ h, digits_ofDigits p h tl w₁' wβ‚‚', ← Nat.one_add] at ih have := sum_singleton (fun x ↦ ofDigits p <| tl.drop x) tl.length rw [← Ico_succ_singleton, List.drop_length, ofDigits] at this have h₁ : 1 ≀ tl.length := List.length_pos.mpr h' rw [← sum_range_add_sum_Ico _ <| h₁, ← add_zero (βˆ‘ x ∈ Ico _ _, ofDigits p (tl.drop x)), ← this, sum_Ico_consecutive _ h₁ <| (le_add_right tl.length 1), ← sum_Ico_add _ 0 tl.length 1, Ico_zero_eq_range, mul_add, mul_add, ih, range_one, sum_singleton, List.drop, ofDigits, mul_zero, add_zero, ← Nat.add_sub_assoc <| sum_le_ofDigits _ <| Nat.le_of_lt h] nth_rw 2 [← one_mul <| ofDigits p tl] rw [← add_mul, one_eq_succ_zero, Nat.sub_add_cancel <| zero_lt_of_lt h, Nat.add_sub_add_left] Β· simp [ofDigits_one] Β· simp [lt_one_iff.mp h] cases L Β· rfl Β· simp [ofDigits] theorem sub_one_mul_sum_log_div_pow_eq_sub_sum_digits {p : β„•} (n : β„•) : (p - 1) * βˆ‘ i ∈ range (log p n).succ, n / p ^ i.succ = n - (p.digits n).sum := by obtain h | rfl | h : 1 < p ∨ 1 = p ∨ p < 1 := trichotomous 1 p Β· rcases eq_or_ne n 0 with rfl | hn Β· simp Β· convert sub_one_mul_sum_div_pow_eq_sub_sum_digits (p.digits n) (getLast_digit_ne_zero p hn) <| (fun l a ↦ digits_lt_base h a) Β· refine (digits_len p n h hn).symm all_goals exact (ofDigits_digits p n).symm Β· simp Β· simp [lt_one_iff.mp h] cases n all_goals simp theorem digits_two_eq_bits (n : β„•) : digits 2 n = n.bits.map fun b => cond b 1 0 := by induction' n using Nat.binaryRecFromOne with b n h ih Β· simp Β· rfl rw [bits_append_bit _ _ fun hn => absurd hn h] cases b Β· rw [digits_def' one_lt_two] Β· simpa [Nat.bit, Nat.bit0_val n] Β· simpa [pos_iff_ne_zero, Nat.bit0_eq_zero] Β· simpa [Nat.bit, Nat.bit1_val n, add_comm, digits_add 2 one_lt_two 1 n, Nat.add_mul_div_left] #align nat.digits_two_eq_bits Nat.digits_two_eq_bits -- This is really a theorem about polynomials. theorem dvd_ofDigits_sub_ofDigits {Ξ± : Type*} [CommRing Ξ±] {a b k : Ξ±} (h : k ∣ a - b) (L : List β„•) : k ∣ ofDigits a L - ofDigits b L := by induction' L with d L ih Β· change k ∣ 0 - 0 simp Β· simp only [ofDigits, add_sub_add_left_eq_sub] exact dvd_mul_sub_mul h ih #align nat.dvd_of_digits_sub_of_digits Nat.dvd_ofDigits_sub_ofDigits theorem ofDigits_modEq' (b b' : β„•) (k : β„•) (h : b ≑ b' [MOD k]) (L : List β„•) : ofDigits b L ≑ ofDigits b' L [MOD k] := by induction' L with d L ih Β· rfl Β· dsimp [ofDigits] dsimp [Nat.ModEq] at * conv_lhs => rw [Nat.add_mod, Nat.mul_mod, h, ih] conv_rhs => rw [Nat.add_mod, Nat.mul_mod] #align nat.of_digits_modeq' Nat.ofDigits_modEq' theorem ofDigits_modEq (b k : β„•) (L : List β„•) : ofDigits b L ≑ ofDigits (b % k) L [MOD k] := ofDigits_modEq' b (b % k) k (b.mod_modEq k).symm L #align nat.of_digits_modeq Nat.ofDigits_modEq theorem ofDigits_mod (b k : β„•) (L : List β„•) : ofDigits b L % k = ofDigits (b % k) L % k := ofDigits_modEq b k L #align nat.of_digits_mod Nat.ofDigits_mod theorem ofDigits_mod_eq_head! (b : β„•) (l : List β„•) : ofDigits b l % b = l.head! % b := by induction l <;> simp [Nat.ofDigits, Int.ModEq] theorem head!_digits {b n : β„•} (h : b β‰  1) : (Nat.digits b n).head! = n % b := by by_cases hb : 1 < b Β· rcases n with _ | n Β· simp Β· nth_rw 2 [← Nat.ofDigits_digits b (n + 1)] rw [Nat.ofDigits_mod_eq_head! _ _] exact (Nat.mod_eq_of_lt (Nat.digits_lt_base hb <| List.head!_mem_self <| Nat.digits_ne_nil_iff_ne_zero.mpr <| Nat.succ_ne_zero n)).symm Β· rcases n with _ | _ <;> simp_all [show b = 0 by omega] theorem ofDigits_zmodeq' (b b' : β„€) (k : β„•) (h : b ≑ b' [ZMOD k]) (L : List β„•) : ofDigits b L ≑ ofDigits b' L [ZMOD k] := by induction' L with d L ih Β· rfl Β· dsimp [ofDigits] dsimp [Int.ModEq] at * conv_lhs => rw [Int.add_emod, Int.mul_emod, h, ih] conv_rhs => rw [Int.add_emod, Int.mul_emod] #align nat.of_digits_zmodeq' Nat.ofDigits_zmodeq' theorem ofDigits_zmodeq (b : β„€) (k : β„•) (L : List β„•) : ofDigits b L ≑ ofDigits (b % k) L [ZMOD k] := ofDigits_zmodeq' b (b % k) k (b.mod_modEq ↑k).symm L #align nat.of_digits_zmodeq Nat.ofDigits_zmodeq theorem ofDigits_zmod (b : β„€) (k : β„•) (L : List β„•) : ofDigits b L % k = ofDigits (b % k) L % k := ofDigits_zmodeq b k L #align nat.of_digits_zmod Nat.ofDigits_zmod theorem modEq_digits_sum (b b' : β„•) (h : b' % b = 1) (n : β„•) : n ≑ (digits b' n).sum [MOD b] := by rw [← ofDigits_one] conv => congr Β· skip Β· rw [← ofDigits_digits b' n] convert ofDigits_modEq b' b (digits b' n) exact h.symm #align nat.modeq_digits_sum Nat.modEq_digits_sum theorem modEq_three_digits_sum (n : β„•) : n ≑ (digits 10 n).sum [MOD 3] := modEq_digits_sum 3 10 (by norm_num) n #align nat.modeq_three_digits_sum Nat.modEq_three_digits_sum theorem modEq_nine_digits_sum (n : β„•) : n ≑ (digits 10 n).sum [MOD 9] := modEq_digits_sum 9 10 (by norm_num) n #align nat.modeq_nine_digits_sum Nat.modEq_nine_digits_sum theorem zmodeq_ofDigits_digits (b b' : β„•) (c : β„€) (h : b' ≑ c [ZMOD b]) (n : β„•) : n ≑ ofDigits c (digits b' n) [ZMOD b] := by conv => congr Β· skip Β· rw [← ofDigits_digits b' n] rw [coe_int_ofDigits] apply ofDigits_zmodeq' _ _ _ h #align nat.zmodeq_of_digits_digits Nat.zmodeq_ofDigits_digits theorem ofDigits_neg_one : βˆ€ L : List β„•, ofDigits (-1 : β„€) L = (L.map fun n : β„• => (n : β„€)).alternatingSum | [] => rfl | [n] => by simp [ofDigits, List.alternatingSum] | a :: b :: t => by simp only [ofDigits, List.alternatingSum, List.map_cons, ofDigits_neg_one t] ring #align nat.of_digits_neg_one Nat.ofDigits_neg_one theorem modEq_eleven_digits_sum (n : β„•) : n ≑ ((digits 10 n).map fun n : β„• => (n : β„€)).alternatingSum [ZMOD 11] := by have t := zmodeq_ofDigits_digits 11 10 (-1 : β„€) (by unfold Int.ModEq; rfl) n rwa [ofDigits_neg_one] at t #align nat.modeq_eleven_digits_sum Nat.modEq_eleven_digits_sum theorem dvd_iff_dvd_digits_sum (b b' : β„•) (h : b' % b = 1) (n : β„•) : b ∣ n ↔ b ∣ (digits b' n).sum := by rw [← ofDigits_one] conv_lhs => rw [← ofDigits_digits b' n] rw [Nat.dvd_iff_mod_eq_zero, Nat.dvd_iff_mod_eq_zero, ofDigits_mod, h] #align nat.dvd_iff_dvd_digits_sum Nat.dvd_iff_dvd_digits_sum theorem three_dvd_iff (n : β„•) : 3 ∣ n ↔ 3 ∣ (digits 10 n).sum := dvd_iff_dvd_digits_sum 3 10 (by norm_num) n #align nat.three_dvd_iff Nat.three_dvd_iff theorem nine_dvd_iff (n : β„•) : 9 ∣ n ↔ 9 ∣ (digits 10 n).sum := dvd_iff_dvd_digits_sum 9 10 (by norm_num) n #align nat.nine_dvd_iff Nat.nine_dvd_iff theorem dvd_iff_dvd_ofDigits (b b' : β„•) (c : β„€) (h : (b : β„€) ∣ (b' : β„€) - c) (n : β„•) : b ∣ n ↔ (b : β„€) ∣ ofDigits c (digits b' n) := by rw [← Int.natCast_dvd_natCast] exact dvd_iff_dvd_of_dvd_sub (zmodeq_ofDigits_digits b b' c (Int.modEq_iff_dvd.2 h).symm _).symm.dvd #align nat.dvd_iff_dvd_of_digits Nat.dvd_iff_dvd_ofDigits theorem eleven_dvd_iff : 11 ∣ n ↔ (11 : β„€) ∣ ((digits 10 n).map fun n : β„• => (n : β„€)).alternatingSum := by have t := dvd_iff_dvd_ofDigits 11 10 (-1 : β„€) (by norm_num) n rw [ofDigits_neg_one] at t exact t #align nat.eleven_dvd_iff Nat.eleven_dvd_iff theorem eleven_dvd_of_palindrome (p : (digits 10 n).Palindrome) (h : Even (digits 10 n).length) : 11 ∣ n := by let dig := (digits 10 n).map fun n : β„• => (n : β„€) replace h : Even dig.length := by rwa [List.length_map] refine eleven_dvd_iff.2 ⟨0, (?_ : dig.alternatingSum = 0)⟩ have := dig.alternatingSum_reverse rw [(p.map _).reverse_eq, _root_.pow_succ', h.neg_one_pow, mul_one, neg_one_zsmul] at this exact eq_zero_of_neg_eq this.symm #align nat.eleven_dvd_of_palindrome Nat.eleven_dvd_of_palindrome lemma toDigitsCore_lens_eq_aux (b f : Nat) : βˆ€ (n : Nat) (l1 l2 : List Char), l1.length = l2.length β†’ (Nat.toDigitsCore b f n l1).length = (Nat.toDigitsCore b f n l2).length := by induction f with (simp only [Nat.toDigitsCore, List.length]; intro n l1 l2 hlen) | zero => assumption | succ f ih => if hx : n / b = 0 then simp only [hx, if_true, List.length, congrArg (fun l ↦ l + 1) hlen] else simp only [hx, if_false] specialize ih (n / b) (Nat.digitChar (n % b) :: l1) (Nat.digitChar (n % b) :: l2) simp only [List.length, congrArg (fun l ↦ l + 1) hlen] at ih exact ih trivial @[deprecated (since := "2024-02-19")] alias to_digits_core_lens_eq_aux:= toDigitsCore_lens_eq_aux lemma toDigitsCore_lens_eq (b f : Nat) : βˆ€ (n : Nat) (c : Char) (tl : List Char), (Nat.toDigitsCore b f n (c :: tl)).length = (Nat.toDigitsCore b f n tl).length + 1 := by induction f with (intro n c tl; simp only [Nat.toDigitsCore, List.length]) | succ f ih => if hnb : (n / b) = 0 then simp only [hnb, if_true, List.length] else generalize hx: Nat.digitChar (n % b) = x simp only [hx, hnb, if_false] at ih simp only [hnb, if_false] specialize ih (n / b) c (x :: tl) rw [← ih] have lens_eq : (x :: (c :: tl)).length = (c :: x :: tl).length := by simp apply toDigitsCore_lens_eq_aux exact lens_eq @[deprecated (since := "2024-02-19")] alias to_digits_core_lens_eq:= toDigitsCore_lens_eq lemma nat_repr_len_aux (n b e : Nat) (h_b_pos : 0 < b) : n < b ^ e.succ β†’ n / b < b ^ e := by simp only [Nat.pow_succ] exact (@Nat.div_lt_iff_lt_mul b n (b ^ e) h_b_pos).mpr lemma toDigitsCore_length (b : Nat) (h : 2 <= b) (f n e : Nat) (hlt : n < b ^ e) (h_e_pos: 0 < e) : (Nat.toDigitsCore b f n []).length <= e := by induction f generalizing n e hlt h_e_pos with simp only [Nat.toDigitsCore, List.length, Nat.zero_le] | succ f ih => cases e with | zero => exact False.elim (Nat.lt_irrefl 0 h_e_pos) | succ e => if h_pred_pos : 0 < e then have _ : 0 < b := Nat.lt_trans (by decide) h specialize ih (n / b) e (nat_repr_len_aux n b e β€Ή0 < bβ€Ί hlt) h_pred_pos if hdiv_ten : n / b = 0 then simp only [hdiv_ten]; exact Nat.le.step h_pred_pos else simp only [hdiv_ten, toDigitsCore_lens_eq b f (n / b) (Nat.digitChar <| n % b), if_false] exact Nat.succ_le_succ ih else obtain rfl : e = 0 := Nat.eq_zero_of_not_pos h_pred_pos have _ : b ^ 1 = b := by simp only [Nat.pow_succ, pow_zero, Nat.one_mul] have _ : n < b := β€Ήb ^ 1 = bβ€Ί β–Έ hlt simp [(@Nat.div_eq_of_lt n b β€Ήn < bβ€Ί : n / b = 0)] @[deprecated (since := "2024-02-19")] alias to_digits_core_length := toDigitsCore_length lemma repr_length (n e : Nat) : 0 < e β†’ n < 10 ^ e β†’ (Nat.repr n).length <= e := by cases n with (intro e0 he; simp only [Nat.repr, Nat.toDigits, String.length, List.asString]) | zero => assumption | succ n => if hterm : n.succ / 10 = 0 then simp only [hterm, Nat.toDigitsCore]; assumption else exact toDigitsCore_length 10 (by decide) (Nat.succ n + 1) (Nat.succ n) e he e0 namespace NormDigits theorem digits_succ (b n m r l) (e : r + b * m = n) (hr : r < b) (h : Nat.digits b m = l ∧ 1 < b ∧ 0 < m) : (Nat.digits b n = r :: l) ∧ 1 < b ∧ 0 < n := by rcases h with ⟨h, b2, m0⟩ have b0 : 0 < b := by omega have n0 : 0 < n := by linarith [mul_pos b0 m0] refine ⟨?_, b2, n0⟩ obtain ⟨rfl, rfl⟩ := (Nat.div_mod_unique b0).2 ⟨e, hr⟩ subst h; exact Nat.digits_def' b2 n0 #align nat.norm_digits.digits_succ Nat.NormDigits.digits_succ
Mathlib/Data/Nat/Digits.lean
876
881
theorem digits_one (b n) (n0 : 0 < n) (nb : n < b) : Nat.digits b n = [n] ∧ 1 < b ∧ 0 < n := by
have b2 : 1 < b := lt_iff_add_one_le.mpr (le_trans (add_le_add_right (lt_iff_add_one_le.mp n0) 1) nb) refine ⟨?_, b2, n0⟩ rw [Nat.digits_def' b2 n0, Nat.mod_eq_of_lt nb, (Nat.div_eq_zero_iff ((zero_le n).trans_lt nb)).2 nb, Nat.digits_zero]
import Mathlib.GroupTheory.GroupAction.ConjAct import Mathlib.GroupTheory.GroupAction.Quotient import Mathlib.GroupTheory.QuotientGroup import Mathlib.Topology.Algebra.Monoid import Mathlib.Topology.Algebra.Constructions #align_import topology.algebra.group.basic from "leanprover-community/mathlib"@"3b1890e71632be9e3b2086ab512c3259a7e9a3ef" open scoped Classical open Set Filter TopologicalSpace Function Topology Pointwise MulOpposite universe u v w x variable {G : Type w} {H : Type x} {Ξ± : Type u} {Ξ² : Type v} class ContinuousNeg (G : Type u) [TopologicalSpace G] [Neg G] : Prop where continuous_neg : Continuous fun a : G => -a #align has_continuous_neg ContinuousNeg -- Porting note: added attribute [continuity] ContinuousNeg.continuous_neg @[to_additive (attr := continuity)] class ContinuousInv (G : Type u) [TopologicalSpace G] [Inv G] : Prop where continuous_inv : Continuous fun a : G => a⁻¹ #align has_continuous_inv ContinuousInv --#align has_continuous_neg ContinuousNeg -- Porting note: added attribute [continuity] ContinuousInv.continuous_inv export ContinuousInv (continuous_inv) export ContinuousNeg (continuous_neg) section ContinuousInv variable [TopologicalSpace G] [Inv G] [ContinuousInv G] @[to_additive] protected theorem Specializes.inv {x y : G} (h : x β€³ y) : (x⁻¹) β€³ (y⁻¹) := h.map continuous_inv @[to_additive] protected theorem Inseparable.inv {x y : G} (h : Inseparable x y) : Inseparable (x⁻¹) (y⁻¹) := h.map continuous_inv @[to_additive] protected theorem Specializes.zpow {G : Type*} [DivInvMonoid G] [TopologicalSpace G] [ContinuousMul G] [ContinuousInv G] {x y : G} (h : x β€³ y) : βˆ€ m : β„€, (x ^ m) β€³ (y ^ m) | .ofNat n => by simpa using h.pow n | .negSucc n => by simpa using (h.pow (n + 1)).inv @[to_additive] protected theorem Inseparable.zpow {G : Type*} [DivInvMonoid G] [TopologicalSpace G] [ContinuousMul G] [ContinuousInv G] {x y : G} (h : Inseparable x y) (m : β„€) : Inseparable (x ^ m) (y ^ m) := (h.specializes.zpow m).antisymm (h.specializes'.zpow m) @[to_additive] instance : ContinuousInv (ULift G) := ⟨continuous_uLift_up.comp (continuous_inv.comp continuous_uLift_down)⟩ @[to_additive] theorem continuousOn_inv {s : Set G} : ContinuousOn Inv.inv s := continuous_inv.continuousOn #align continuous_on_inv continuousOn_inv #align continuous_on_neg continuousOn_neg @[to_additive] theorem continuousWithinAt_inv {s : Set G} {x : G} : ContinuousWithinAt Inv.inv s x := continuous_inv.continuousWithinAt #align continuous_within_at_inv continuousWithinAt_inv #align continuous_within_at_neg continuousWithinAt_neg @[to_additive] theorem continuousAt_inv {x : G} : ContinuousAt Inv.inv x := continuous_inv.continuousAt #align continuous_at_inv continuousAt_inv #align continuous_at_neg continuousAt_neg @[to_additive] theorem tendsto_inv (a : G) : Tendsto Inv.inv (𝓝 a) (𝓝 a⁻¹) := continuousAt_inv #align tendsto_inv tendsto_inv #align tendsto_neg tendsto_neg @[to_additive "If a function converges to a value in an additive topological group, then its negation converges to the negation of this value."] theorem Filter.Tendsto.inv {f : Ξ± β†’ G} {l : Filter Ξ±} {y : G} (h : Tendsto f l (𝓝 y)) : Tendsto (fun x => (f x)⁻¹) l (𝓝 y⁻¹) := (continuous_inv.tendsto y).comp h #align filter.tendsto.inv Filter.Tendsto.inv #align filter.tendsto.neg Filter.Tendsto.neg variable [TopologicalSpace Ξ±] {f : Ξ± β†’ G} {s : Set Ξ±} {x : Ξ±} @[to_additive (attr := continuity, fun_prop)] theorem Continuous.inv (hf : Continuous f) : Continuous fun x => (f x)⁻¹ := continuous_inv.comp hf #align continuous.inv Continuous.inv #align continuous.neg Continuous.neg @[to_additive (attr := fun_prop)] theorem ContinuousAt.inv (hf : ContinuousAt f x) : ContinuousAt (fun x => (f x)⁻¹) x := continuousAt_inv.comp hf #align continuous_at.inv ContinuousAt.inv #align continuous_at.neg ContinuousAt.neg @[to_additive (attr := fun_prop)] theorem ContinuousOn.inv (hf : ContinuousOn f s) : ContinuousOn (fun x => (f x)⁻¹) s := continuous_inv.comp_continuousOn hf #align continuous_on.inv ContinuousOn.inv #align continuous_on.neg ContinuousOn.neg @[to_additive] theorem ContinuousWithinAt.inv (hf : ContinuousWithinAt f s x) : ContinuousWithinAt (fun x => (f x)⁻¹) s x := Filter.Tendsto.inv hf #align continuous_within_at.inv ContinuousWithinAt.inv #align continuous_within_at.neg ContinuousWithinAt.neg @[to_additive] instance Prod.continuousInv [TopologicalSpace H] [Inv H] [ContinuousInv H] : ContinuousInv (G Γ— H) := ⟨continuous_inv.fst'.prod_mk continuous_inv.snd'⟩ variable {ΞΉ : Type*} @[to_additive] instance Pi.continuousInv {C : ΞΉ β†’ Type*} [βˆ€ i, TopologicalSpace (C i)] [βˆ€ i, Inv (C i)] [βˆ€ i, ContinuousInv (C i)] : ContinuousInv (βˆ€ i, C i) where continuous_inv := continuous_pi fun i => (continuous_apply i).inv #align pi.has_continuous_inv Pi.continuousInv #align pi.has_continuous_neg Pi.continuousNeg @[to_additive "A version of `Pi.continuousNeg` for non-dependent functions. It is needed because sometimes Lean fails to use `Pi.continuousNeg` for non-dependent functions."] instance Pi.has_continuous_inv' : ContinuousInv (ΞΉ β†’ G) := Pi.continuousInv #align pi.has_continuous_inv' Pi.has_continuous_inv' #align pi.has_continuous_neg' Pi.has_continuous_neg' @[to_additive] instance (priority := 100) continuousInv_of_discreteTopology [TopologicalSpace H] [Inv H] [DiscreteTopology H] : ContinuousInv H := ⟨continuous_of_discreteTopology⟩ #align has_continuous_inv_of_discrete_topology continuousInv_of_discreteTopology #align has_continuous_neg_of_discrete_topology continuousNeg_of_discreteTopology @[to_additive] theorem Inducing.continuousInv {G H : Type*} [Inv G] [Inv H] [TopologicalSpace G] [TopologicalSpace H] [ContinuousInv H] {f : G β†’ H} (hf : Inducing f) (hf_inv : βˆ€ x, f x⁻¹ = (f x)⁻¹) : ContinuousInv G := ⟨hf.continuous_iff.2 <| by simpa only [(Β· ∘ Β·), hf_inv] using hf.continuous.inv⟩ #align inducing.has_continuous_inv Inducing.continuousInv #align inducing.has_continuous_neg Inducing.continuousNeg section TopologicalGroup -- Porting note (#11215): TODO should this docstring be extended -- to match the multiplicative version? class TopologicalAddGroup (G : Type u) [TopologicalSpace G] [AddGroup G] extends ContinuousAdd G, ContinuousNeg G : Prop #align topological_add_group TopologicalAddGroup -- Porting note: check that these ↑ names exist once they've been ported in the future. @[to_additive] class TopologicalGroup (G : Type*) [TopologicalSpace G] [Group G] extends ContinuousMul G, ContinuousInv G : Prop #align topological_group TopologicalGroup --#align topological_add_group TopologicalAddGroup variable [TopologicalSpace G] [Group G] [TopologicalGroup G] [TopologicalSpace Ξ±] {f : Ξ± β†’ G} {s : Set Ξ±} {x : Ξ±} instance : TopologicalGroup (ULift G) where @[to_additive] instance [TopologicalSpace H] [Group H] [TopologicalGroup H] : TopologicalGroup (G Γ— H) where continuous_inv := continuous_inv.prod_map continuous_inv @[to_additive] instance Pi.topologicalGroup {C : Ξ² β†’ Type*} [βˆ€ b, TopologicalSpace (C b)] [βˆ€ b, Group (C b)] [βˆ€ b, TopologicalGroup (C b)] : TopologicalGroup (βˆ€ b, C b) where continuous_inv := continuous_pi fun i => (continuous_apply i).inv #align pi.topological_group Pi.topologicalGroup #align pi.topological_add_group Pi.topologicalAddGroup open MulOpposite @[to_additive] instance [Inv Ξ±] [ContinuousInv Ξ±] : ContinuousInv αᡐᡒᡖ := opHomeomorph.symm.inducing.continuousInv unop_inv @[to_additive "If addition is continuous in `Ξ±`, then it also is in `αᡃᡒᡖ`."] instance [Group Ξ±] [TopologicalGroup Ξ±] : TopologicalGroup αᡐᡒᡖ where variable (G) @[to_additive] theorem nhds_one_symm : comap Inv.inv (𝓝 (1 : G)) = 𝓝 (1 : G) := ((Homeomorph.inv G).comap_nhds_eq _).trans (congr_arg nhds inv_one) #align nhds_one_symm nhds_one_symm #align nhds_zero_symm nhds_zero_symm @[to_additive] theorem nhds_one_symm' : map Inv.inv (𝓝 (1 : G)) = 𝓝 (1 : G) := ((Homeomorph.inv G).map_nhds_eq _).trans (congr_arg nhds inv_one) #align nhds_one_symm' nhds_one_symm' #align nhds_zero_symm' nhds_zero_symm' @[to_additive]
Mathlib/Topology/Algebra/Group/Basic.lean
672
673
theorem inv_mem_nhds_one {S : Set G} (hS : S ∈ (𝓝 1 : Filter G)) : S⁻¹ ∈ 𝓝 (1 : G) := by
rwa [← nhds_one_symm'] at hS
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 {R : Type*} [CancelCommMonoidWithZero R] [UniqueFactorizationMonoid R] theorem isRelPrime_iff_no_prime_factors {a b : R} (ha : a β‰  0) : IsRelPrime a b ↔ βˆ€ ⦃d⦄, d ∣ a β†’ d ∣ b β†’ Β¬Prime d := ⟨fun h _ ha hb ↦ (Β·.not_unit <| h ha hb), fun h ↦ WfDvdMonoid.isRelPrime_of_no_irreducible_factors (ha Β·.1) fun _ irr ha hb ↦ h ha hb (UniqueFactorizationMonoid.irreducible_iff_prime.mp irr)⟩ #align unique_factorization_monoid.no_factors_of_no_prime_factors UniqueFactorizationMonoid.isRelPrime_iff_no_prime_factors theorem dvd_of_dvd_mul_left_of_no_prime_factors {a b c : R} (ha : a β‰  0) (h : βˆ€ ⦃d⦄, d ∣ a β†’ d ∣ c β†’ Β¬Prime d) : a ∣ b * c β†’ a ∣ b := ((isRelPrime_iff_no_prime_factors ha).mpr h).dvd_of_dvd_mul_right #align unique_factorization_monoid.dvd_of_dvd_mul_left_of_no_prime_factors UniqueFactorizationMonoid.dvd_of_dvd_mul_left_of_no_prime_factors theorem dvd_of_dvd_mul_right_of_no_prime_factors {a b c : R} (ha : a β‰  0) (no_factors : βˆ€ {d}, d ∣ a β†’ d ∣ b β†’ Β¬Prime d) : a ∣ b * c β†’ a ∣ c := by simpa [mul_comm b c] using dvd_of_dvd_mul_left_of_no_prime_factors ha @no_factors #align unique_factorization_monoid.dvd_of_dvd_mul_right_of_no_prime_factors UniqueFactorizationMonoid.dvd_of_dvd_mul_right_of_no_prime_factors theorem exists_reduced_factors : βˆ€ a β‰  (0 : R), βˆ€ b, βˆƒ a' b' c', IsRelPrime a' b' ∧ c' * a' = a ∧ c' * b' = b := by intro a refine induction_on_prime a ?_ ?_ ?_ Β· intros contradiction Β· intro a a_unit _ b use a, b, 1 constructor Β· intro p p_dvd_a _ exact isUnit_of_dvd_unit p_dvd_a a_unit Β· simp Β· intro a p a_ne_zero p_prime ih_a pa_ne_zero b by_cases h : p ∣ b Β· rcases h with ⟨b, rfl⟩ obtain ⟨a', b', c', no_factor, ha', hb'⟩ := ih_a a_ne_zero b refine ⟨a', b', p * c', @no_factor, ?_, ?_⟩ Β· rw [mul_assoc, ha'] Β· rw [mul_assoc, hb'] Β· obtain ⟨a', b', c', coprime, rfl, rfl⟩ := ih_a a_ne_zero b refine ⟨p * a', b', c', ?_, mul_left_comm _ _ _, rfl⟩ intro q q_dvd_pa' q_dvd_b' cases' p_prime.left_dvd_or_dvd_right_of_dvd_mul q_dvd_pa' with p_dvd_q q_dvd_a' Β· have : p ∣ c' * b' := dvd_mul_of_dvd_right (p_dvd_q.trans q_dvd_b') _ contradiction exact coprime q_dvd_a' q_dvd_b' #align unique_factorization_monoid.exists_reduced_factors UniqueFactorizationMonoid.exists_reduced_factors theorem exists_reduced_factors' (a b : R) (hb : b β‰  0) : βˆƒ a' b' c', IsRelPrime a' b' ∧ c' * a' = a ∧ c' * b' = b := let ⟨b', a', c', no_factor, hb, ha⟩ := exists_reduced_factors b hb a ⟨a', b', c', fun _ hpb hpa => no_factor hpa hpb, ha, hb⟩ #align unique_factorization_monoid.exists_reduced_factors' UniqueFactorizationMonoid.exists_reduced_factors' theorem pow_right_injective {a : R} (ha0 : a β‰  0) (ha1 : Β¬IsUnit a) : Function.Injective (a ^ Β· : β„• β†’ R) := by letI := Classical.decEq R intro i j hij letI : Nontrivial R := ⟨⟨a, 0, ha0⟩⟩ letI : NormalizationMonoid R := UniqueFactorizationMonoid.normalizationMonoid obtain ⟨p', hp', dvd'⟩ := WfDvdMonoid.exists_irreducible_factor ha1 ha0 obtain ⟨p, mem, _⟩ := exists_mem_normalizedFactors_of_dvd ha0 hp' dvd' have := congr_arg (fun x => Multiset.count p (normalizedFactors x)) hij simp only [normalizedFactors_pow, Multiset.count_nsmul] at this exact mul_right_cancelβ‚€ (Multiset.count_ne_zero.mpr mem) this #align unique_factorization_monoid.pow_right_injective UniqueFactorizationMonoid.pow_right_injective theorem pow_eq_pow_iff {a : R} (ha0 : a β‰  0) (ha1 : Β¬IsUnit a) {i j : β„•} : a ^ i = a ^ j ↔ i = j := (pow_right_injective ha0 ha1).eq_iff #align unique_factorization_monoid.pow_eq_pow_iff UniqueFactorizationMonoid.pow_eq_pow_iff namespace Associates open UniqueFactorizationMonoid Associated Multiset variable [CancelCommMonoidWithZero Ξ±] abbrev FactorSet.{u} (Ξ± : Type u) [CancelCommMonoidWithZero Ξ±] : Type u := WithTop (Multiset { a : Associates Ξ± // Irreducible a }) #align associates.factor_set Associates.FactorSet attribute [local instance] Associated.setoid theorem FactorSet.coe_add {a b : Multiset { a : Associates Ξ± // Irreducible a }} : (↑(a + b) : FactorSet Ξ±) = a + b := by norm_cast #align associates.factor_set.coe_add Associates.FactorSet.coe_add theorem FactorSet.sup_add_inf_eq_add [DecidableEq (Associates Ξ±)] : βˆ€ a b : FactorSet Ξ±, a βŠ” b + a βŠ“ b = a + b | ⊀, b => show ⊀ βŠ” b + ⊀ βŠ“ b = ⊀ + b by simp | a, ⊀ => show a βŠ” ⊀ + a βŠ“ ⊀ = a + ⊀ by simp | WithTop.some a, WithTop.some b => show (a : FactorSet Ξ±) βŠ” b + (a : FactorSet Ξ±) βŠ“ b = a + b by rw [← WithTop.coe_sup, ← WithTop.coe_inf, ← WithTop.coe_add, ← WithTop.coe_add, WithTop.coe_eq_coe] exact Multiset.union_add_inter _ _ #align associates.factor_set.sup_add_inf_eq_add Associates.FactorSet.sup_add_inf_eq_add def FactorSet.prod : FactorSet Ξ± β†’ Associates Ξ± | ⊀ => 0 | WithTop.some s => (s.map (↑)).prod #align associates.factor_set.prod Associates.FactorSet.prod @[simp] theorem prod_top : (⊀ : FactorSet Ξ±).prod = 0 := rfl #align associates.prod_top Associates.prod_top @[simp] theorem prod_coe {s : Multiset { a : Associates Ξ± // Irreducible a }} : FactorSet.prod (s : FactorSet Ξ±) = (s.map (↑)).prod := rfl #align associates.prod_coe Associates.prod_coe @[simp] theorem prod_add : βˆ€ a b : FactorSet Ξ±, (a + b).prod = a.prod * b.prod | ⊀, b => show (⊀ + b).prod = (⊀ : FactorSet Ξ±).prod * b.prod by simp | a, ⊀ => show (a + ⊀).prod = a.prod * (⊀ : FactorSet Ξ±).prod by simp | WithTop.some a, WithTop.some b => by rw [← FactorSet.coe_add, prod_coe, prod_coe, prod_coe, Multiset.map_add, Multiset.prod_add] #align associates.prod_add Associates.prod_add @[gcongr] theorem prod_mono : βˆ€ {a b : FactorSet Ξ±}, a ≀ b β†’ a.prod ≀ b.prod | ⊀, b, h => by have : b = ⊀ := top_unique h rw [this, prod_top] | a, ⊀, _ => show a.prod ≀ (⊀ : FactorSet Ξ±).prod by simp | WithTop.some a, WithTop.some b, h => prod_le_prod <| Multiset.map_le_map <| WithTop.coe_le_coe.1 <| h #align associates.prod_mono Associates.prod_mono theorem FactorSet.prod_eq_zero_iff [Nontrivial Ξ±] (p : FactorSet Ξ±) : p.prod = 0 ↔ p = ⊀ := by unfold FactorSet at p induction p -- TODO: `induction_eliminator` doesn't work with `abbrev` Β· simp only [iff_self_iff, eq_self_iff_true, Associates.prod_top] Β· rw [prod_coe, Multiset.prod_eq_zero_iff, Multiset.mem_map, eq_false WithTop.coe_ne_top, iff_false_iff, not_exists] exact fun a => not_and_of_not_right _ a.prop.ne_zero #align associates.factor_set.prod_eq_zero_iff Associates.FactorSet.prod_eq_zero_iff theorem prod_le [Nontrivial Ξ±] {a b : FactorSet Ξ±} : a.prod ≀ b.prod ↔ a ≀ b := by refine ⟨fun h ↦ ?_, prod_mono⟩ have : a.prod.factors ≀ b.prod.factors := factors_mono h rwa [prod_factors, prod_factors] at this #align associates.prod_le Associates.prod_le open Classical in noncomputable instance : Sup (Associates Ξ±) := ⟨fun a b => (a.factors βŠ” b.factors).prod⟩ open Classical in noncomputable instance : Inf (Associates Ξ±) := ⟨fun a b => (a.factors βŠ“ b.factors).prod⟩ open Classical in noncomputable instance : Lattice (Associates Ξ±) := { Associates.instPartialOrder with sup := (Β· βŠ” Β·) inf := (Β· βŠ“ Β·) sup_le := fun _ _ c hac hbc => factors_prod c β–Έ prod_mono (sup_le (factors_mono hac) (factors_mono hbc)) le_sup_left := fun a _ => le_trans (le_of_eq (factors_prod a).symm) <| prod_mono <| le_sup_left le_sup_right := fun _ b => le_trans (le_of_eq (factors_prod b).symm) <| prod_mono <| le_sup_right le_inf := fun a _ _ hac hbc => factors_prod a β–Έ prod_mono (le_inf (factors_mono hac) (factors_mono hbc)) inf_le_left := fun a _ => le_trans (prod_mono inf_le_left) (le_of_eq (factors_prod a)) inf_le_right := fun _ b => le_trans (prod_mono inf_le_right) (le_of_eq (factors_prod b)) } open Classical in theorem sup_mul_inf (a b : Associates Ξ±) : (a βŠ” b) * (a βŠ“ b) = a * b := show (a.factors βŠ” b.factors).prod * (a.factors βŠ“ b.factors).prod = a * b by nontriviality Ξ± refine eq_of_factors_eq_factors ?_ rw [← prod_add, prod_factors, factors_mul, FactorSet.sup_add_inf_eq_add] #align associates.sup_mul_inf Associates.sup_mul_inf theorem dvd_of_mem_factors {a p : Associates Ξ±} (hm : p ∈ factors a) : p ∣ a := by rcases eq_or_ne a 0 with rfl | ha0 Β· exact dvd_zero p obtain ⟨a0, nza, ha'⟩ := exists_non_zero_rep ha0 rw [← Associates.factors_prod a] rw [← ha', factors_mk a0 nza] at hm ⊒ rw [prod_coe] apply Multiset.dvd_prod; apply Multiset.mem_map.mpr exact ⟨⟨p, irreducible_of_mem_factorSet hm⟩, mem_factorSet_some.mp hm, rfl⟩ #align associates.dvd_of_mem_factors Associates.dvd_of_mem_factors theorem dvd_of_mem_factors' {a : Ξ±} {p : Associates Ξ±} {hp : Irreducible p} {hz : a β‰  0} (h_mem : Subtype.mk p hp ∈ factors' a) : p ∣ Associates.mk a := by haveI := Classical.decEq (Associates Ξ±) apply dvd_of_mem_factors rw [factors_mk _ hz] apply mem_factorSet_some.2 h_mem #align associates.dvd_of_mem_factors' Associates.dvd_of_mem_factors' theorem mem_factors'_of_dvd {a p : Ξ±} (ha0 : a β‰  0) (hp : Irreducible p) (hd : p ∣ a) : Subtype.mk (Associates.mk p) (irreducible_mk.2 hp) ∈ factors' a := by obtain ⟨q, hq, hpq⟩ := exists_mem_factors_of_dvd ha0 hp hd apply Multiset.mem_pmap.mpr; use q; use hq exact Subtype.eq (Eq.symm (mk_eq_mk_iff_associated.mpr hpq)) #align associates.mem_factors'_of_dvd Associates.mem_factors'_of_dvd theorem mem_factors'_iff_dvd {a p : Ξ±} (ha0 : a β‰  0) (hp : Irreducible p) : Subtype.mk (Associates.mk p) (irreducible_mk.2 hp) ∈ factors' a ↔ p ∣ a := by constructor Β· rw [← mk_dvd_mk] apply dvd_of_mem_factors' apply ha0 Β· apply mem_factors'_of_dvd ha0 hp #align associates.mem_factors'_iff_dvd Associates.mem_factors'_iff_dvd theorem mem_factors_of_dvd {a p : Ξ±} (ha0 : a β‰  0) (hp : Irreducible p) (hd : p ∣ a) : Associates.mk p ∈ factors (Associates.mk a) := by rw [factors_mk _ ha0] exact mem_factorSet_some.mpr (mem_factors'_of_dvd ha0 hp hd) #align associates.mem_factors_of_dvd Associates.mem_factors_of_dvd theorem mem_factors_iff_dvd {a p : Ξ±} (ha0 : a β‰  0) (hp : Irreducible p) : Associates.mk p ∈ factors (Associates.mk a) ↔ p ∣ a := by constructor Β· rw [← mk_dvd_mk] apply dvd_of_mem_factors Β· apply mem_factors_of_dvd ha0 hp #align associates.mem_factors_iff_dvd Associates.mem_factors_iff_dvd open Classical in theorem exists_prime_dvd_of_not_inf_one {a b : Ξ±} (ha : a β‰  0) (hb : b β‰  0) (h : Associates.mk a βŠ“ Associates.mk b β‰  1) : βˆƒ p : Ξ±, Prime p ∧ p ∣ a ∧ p ∣ b := by have hz : factors (Associates.mk a) βŠ“ factors (Associates.mk b) β‰  0 := by contrapose! h with hf change (factors (Associates.mk a) βŠ“ factors (Associates.mk b)).prod = 1 rw [hf] exact Multiset.prod_zero rw [factors_mk a ha, factors_mk b hb, ← WithTop.coe_inf] at hz obtain ⟨⟨p0, p0_irr⟩, p0_mem⟩ := Multiset.exists_mem_of_ne_zero ((mt WithTop.coe_eq_coe.mpr) hz) rw [Multiset.inf_eq_inter] at p0_mem obtain ⟨p, rfl⟩ : βˆƒ p, Associates.mk p = p0 := Quot.exists_rep p0 refine ⟨p, ?_, ?_, ?_⟩ Β· rw [← UniqueFactorizationMonoid.irreducible_iff_prime, ← irreducible_mk] exact p0_irr Β· apply dvd_of_mk_le_mk apply dvd_of_mem_factors' (Multiset.mem_inter.mp p0_mem).left apply ha Β· apply dvd_of_mk_le_mk apply dvd_of_mem_factors' (Multiset.mem_inter.mp p0_mem).right apply hb #align associates.exists_prime_dvd_of_not_inf_one Associates.exists_prime_dvd_of_not_inf_one theorem coprime_iff_inf_one {a b : Ξ±} (ha0 : a β‰  0) (hb0 : b β‰  0) : Associates.mk a βŠ“ Associates.mk b = 1 ↔ βˆ€ {d : Ξ±}, d ∣ a β†’ d ∣ b β†’ Β¬Prime d := by constructor Β· intro hg p ha hb hp refine (Associates.prime_mk.mpr hp).not_unit (isUnit_of_dvd_one ?_) rw [← hg] exact le_inf (mk_le_mk_of_dvd ha) (mk_le_mk_of_dvd hb) Β· contrapose intro hg hc obtain ⟨p, hp, hpa, hpb⟩ := exists_prime_dvd_of_not_inf_one ha0 hb0 hg exact hc hpa hpb hp #align associates.coprime_iff_inf_one Associates.coprime_iff_inf_one theorem factors_self [Nontrivial Ξ±] {p : Associates Ξ±} (hp : Irreducible p) : p.factors = WithTop.some {⟨p, hp⟩} := eq_of_prod_eq_prod (by rw [factors_prod, FactorSet.prod]; dsimp; rw [prod_singleton]) #align associates.factors_self Associates.factors_self theorem factors_prime_pow [Nontrivial Ξ±] {p : Associates Ξ±} (hp : Irreducible p) (k : β„•) : factors (p ^ k) = WithTop.some (Multiset.replicate k ⟨p, hp⟩) := eq_of_prod_eq_prod (by rw [Associates.factors_prod, FactorSet.prod] dsimp; rw [Multiset.map_replicate, Multiset.prod_replicate, Subtype.coe_mk]) #align associates.factors_prime_pow Associates.factors_prime_pow theorem prime_pow_le_iff_le_bcount [DecidableEq (Associates Ξ±)] {m p : Associates Ξ±} (h₁ : m β‰  0) (hβ‚‚ : Irreducible p) {k : β„•} : p ^ k ≀ m ↔ k ≀ bcount ⟨p, hβ‚‚βŸ© m.factors := by rcases Associates.exists_non_zero_rep h₁ with ⟨m, hm, rfl⟩ have := nontrivial_of_ne _ _ hm rw [bcount, factors_mk, Multiset.le_count_iff_replicate_le, ← factors_le, factors_prime_pow, factors_mk, WithTop.coe_le_coe] <;> assumption section count variable [DecidableEq (Associates Ξ±)] [βˆ€ p : Associates Ξ±, Decidable (Irreducible p)] theorem prime_pow_dvd_iff_le {m p : Associates Ξ±} (h₁ : m β‰  0) (hβ‚‚ : Irreducible p) {k : β„•} : p ^ k ≀ m ↔ k ≀ count p m.factors := by rw [count, dif_pos hβ‚‚, prime_pow_le_iff_le_bcount h₁] #align associates.prime_pow_dvd_iff_le Associates.prime_pow_dvd_iff_le theorem le_of_count_ne_zero {m p : Associates Ξ±} (h0 : m β‰  0) (hp : Irreducible p) : count p m.factors β‰  0 β†’ p ≀ m := by nontriviality Ξ± rw [← pos_iff_ne_zero] intro h rw [← pow_one p] apply (prime_pow_dvd_iff_le h0 hp).2 simpa only #align associates.le_of_count_ne_zero Associates.le_of_count_ne_zero theorem count_ne_zero_iff_dvd {a p : Ξ±} (ha0 : a β‰  0) (hp : Irreducible p) : (Associates.mk p).count (Associates.mk a).factors β‰  0 ↔ p ∣ a := by nontriviality Ξ± rw [← Associates.mk_le_mk_iff_dvd] refine ⟨fun h => Associates.le_of_count_ne_zero (Associates.mk_ne_zero.mpr ha0) (Associates.irreducible_mk.mpr hp) h, fun h => ?_⟩ rw [← pow_one (Associates.mk p), Associates.prime_pow_dvd_iff_le (Associates.mk_ne_zero.mpr ha0) (Associates.irreducible_mk.mpr hp)] at h exact (zero_lt_one.trans_le h).ne' #align associates.count_ne_zero_iff_dvd Associates.count_ne_zero_iff_dvd theorem count_self [Nontrivial Ξ±] [DecidableEq (Associates Ξ±)] {p : Associates Ξ±} (hp : Irreducible p) : p.count p.factors = 1 := by simp [factors_self hp, Associates.count_some hp] #align associates.count_self Associates.count_self theorem count_eq_zero_of_ne [DecidableEq (Associates Ξ±)] {p q : Associates Ξ±} (hp : Irreducible p) (hq : Irreducible q) (h : p β‰  q) : p.count q.factors = 0 := not_ne_iff.mp fun h' ↦ h <| associated_iff_eq.mp <| hp.associated_of_dvd hq <| le_of_count_ne_zero hq.ne_zero hp h' #align associates.count_eq_zero_of_ne Associates.count_eq_zero_of_ne theorem count_mul [DecidableEq (Associates Ξ±)] {a : Associates Ξ±} (ha : a β‰  0) {b : Associates Ξ±} (hb : b β‰  0) {p : Associates Ξ±} (hp : Irreducible p) : count p (factors (a * b)) = count p a.factors + count p b.factors := by obtain ⟨a0, nza, rfl⟩ := exists_non_zero_rep ha obtain ⟨b0, nzb, rfl⟩ := exists_non_zero_rep hb rw [factors_mul, factors_mk a0 nza, factors_mk b0 nzb, ← FactorSet.coe_add, count_some hp, Multiset.count_add, count_some hp, count_some hp] #align associates.count_mul Associates.count_mul theorem count_of_coprime [DecidableEq (Associates Ξ±)] {a : Associates Ξ±} (ha : a β‰  0) {b : Associates Ξ±} (hb : b β‰  0) (hab : βˆ€ d, d ∣ a β†’ d ∣ b β†’ Β¬Prime d) {p : Associates Ξ±} (hp : Irreducible p) : count p a.factors = 0 ∨ count p b.factors = 0 := by rw [or_iff_not_imp_left, ← Ne] intro hca contrapose! hab with hcb exact ⟨p, le_of_count_ne_zero ha hp hca, le_of_count_ne_zero hb hp hcb, UniqueFactorizationMonoid.irreducible_iff_prime.mp hp⟩ #align associates.count_of_coprime Associates.count_of_coprime theorem count_mul_of_coprime [DecidableEq (Associates Ξ±)] {a : Associates Ξ±} {b : Associates Ξ±} (hb : b β‰  0) {p : Associates Ξ±} (hp : Irreducible p) (hab : βˆ€ d, d ∣ a β†’ d ∣ b β†’ Β¬Prime d) : count p a.factors = 0 ∨ count p a.factors = count p (a * b).factors := by by_cases ha : a = 0 Β· simp [ha] cases' count_of_coprime ha hb hab hp with hz hb0; Β· tauto apply Or.intro_right rw [count_mul ha hb hp, hb0, add_zero] #align associates.count_mul_of_coprime Associates.count_mul_of_coprime theorem count_mul_of_coprime' [DecidableEq (Associates Ξ±)] {a b : Associates Ξ±} {p : Associates Ξ±} (hp : Irreducible p) (hab : βˆ€ d, d ∣ a β†’ d ∣ b β†’ Β¬Prime d) : count p (a * b).factors = count p a.factors ∨ count p (a * b).factors = count p b.factors := by by_cases ha : a = 0 Β· simp [ha] by_cases hb : b = 0 Β· simp [hb] rw [count_mul ha hb hp] cases' count_of_coprime ha hb hab hp with ha0 hb0 Β· apply Or.intro_right rw [ha0, zero_add] Β· apply Or.intro_left rw [hb0, add_zero] #align associates.count_mul_of_coprime' Associates.count_mul_of_coprime' theorem dvd_count_of_dvd_count_mul [DecidableEq (Associates Ξ±)] {a b : Associates Ξ±} (hb : b β‰  0) {p : Associates Ξ±} (hp : Irreducible p) (hab : βˆ€ d, d ∣ a β†’ d ∣ b β†’ Β¬Prime d) {k : β„•} (habk : k ∣ count p (a * b).factors) : k ∣ count p a.factors := by by_cases ha : a = 0 Β· simpa [*] using habk cases' count_of_coprime ha hb hab hp with hz h Β· rw [hz] exact dvd_zero k Β· rw [count_mul ha hb hp, h] at habk exact habk #align associates.dvd_count_of_dvd_count_mul Associates.dvd_count_of_dvd_count_mul @[simp] theorem factors_one [Nontrivial Ξ±] : factors (1 : Associates Ξ±) = 0 := by apply eq_of_prod_eq_prod rw [Associates.factors_prod] exact Multiset.prod_zero #align associates.factors_one Associates.factors_one @[simp] theorem pow_factors [Nontrivial Ξ±] {a : Associates Ξ±} {k : β„•} : (a ^ k).factors = k β€’ a.factors := by induction' k with n h Β· rw [zero_nsmul, pow_zero] exact factors_one Β· rw [pow_succ, succ_nsmul, factors_mul, h] #align associates.pow_factors Associates.pow_factors theorem count_pow [Nontrivial Ξ±] [DecidableEq (Associates Ξ±)] {a : Associates Ξ±} (ha : a β‰  0) {p : Associates Ξ±} (hp : Irreducible p) (k : β„•) : count p (a ^ k).factors = k * count p a.factors := by induction' k with n h Β· rw [pow_zero, factors_one, zero_mul, count_zero hp] Β· rw [pow_succ', count_mul ha (pow_ne_zero _ ha) hp, h] ring #align associates.count_pow Associates.count_pow
Mathlib/RingTheory/UniqueFactorizationDomain.lean
1,849
1,852
theorem dvd_count_pow [Nontrivial Ξ±] [DecidableEq (Associates Ξ±)] {a : Associates Ξ±} (ha : a β‰  0) {p : Associates Ξ±} (hp : Irreducible p) (k : β„•) : k ∣ count p (a ^ k).factors := by
rw [count_pow ha hp] apply dvd_mul_right
import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Algebra.Star.Unitary import Mathlib.Data.Nat.ModEq import Mathlib.NumberTheory.Zsqrtd.Basic import Mathlib.Tactic.Monotonicity #align_import number_theory.pell_matiyasevic from "leanprover-community/mathlib"@"795b501869b9fa7aa716d5fdadd00c03f983a605" namespace Pell open Nat section variable {d : β„€} def IsPell : β„€βˆšd β†’ Prop | ⟨x, y⟩ => x * x - d * y * y = 1 #align pell.is_pell Pell.IsPell theorem isPell_norm : βˆ€ {b : β„€βˆšd}, IsPell b ↔ b * star b = 1 | ⟨x, y⟩ => by simp [Zsqrtd.ext_iff, IsPell, mul_comm]; ring_nf #align pell.is_pell_norm Pell.isPell_norm theorem isPell_iff_mem_unitary : βˆ€ {b : β„€βˆšd}, IsPell b ↔ b ∈ unitary (β„€βˆšd) | ⟨x, y⟩ => by rw [unitary.mem_iff, isPell_norm, mul_comm (star _), and_self_iff] #align pell.is_pell_iff_mem_unitary Pell.isPell_iff_mem_unitary theorem isPell_mul {b c : β„€βˆšd} (hb : IsPell b) (hc : IsPell c) : IsPell (b * c) := isPell_norm.2 (by simp [mul_comm, mul_left_comm c, mul_assoc, star_mul, isPell_norm.1 hb, isPell_norm.1 hc]) #align pell.is_pell_mul Pell.isPell_mul theorem isPell_star : βˆ€ {b : β„€βˆšd}, IsPell b ↔ IsPell (star b) | ⟨x, y⟩ => by simp [IsPell, Zsqrtd.star_mk] #align pell.is_pell_star Pell.isPell_star end section -- Porting note: was parameter in Lean3 variable {a : β„•} (a1 : 1 < a) private def d (_a1 : 1 < a) := a * a - 1 @[simp] theorem d_pos : 0 < d a1 := tsub_pos_of_lt (mul_lt_mul a1 (le_of_lt a1) (by decide) (Nat.zero_le _) : 1 * 1 < a * a) #align pell.d_pos Pell.d_pos -- TODO(lint): Fix double namespace issue --@[nolint dup_namespace] def pell : β„• β†’ β„• Γ— β„• -- Porting note: used pattern matching because `Nat.recOn` is noncomputable | 0 => (1, 0) | n+1 => ((pell n).1 * a + d a1 * (pell n).2, (pell n).1 + (pell n).2 * a) #align pell.pell Pell.pell def xn (n : β„•) : β„• := (pell a1 n).1 #align pell.xn Pell.xn def yn (n : β„•) : β„• := (pell a1 n).2 #align pell.yn Pell.yn @[simp] theorem pell_val (n : β„•) : pell a1 n = (xn a1 n, yn a1 n) := show pell a1 n = ((pell a1 n).1, (pell a1 n).2) from match pell a1 n with | (_, _) => rfl #align pell.pell_val Pell.pell_val @[simp] theorem xn_zero : xn a1 0 = 1 := rfl #align pell.xn_zero Pell.xn_zero @[simp] theorem yn_zero : yn a1 0 = 0 := rfl #align pell.yn_zero Pell.yn_zero @[simp] theorem xn_succ (n : β„•) : xn a1 (n + 1) = xn a1 n * a + d a1 * yn a1 n := rfl #align pell.xn_succ Pell.xn_succ @[simp] theorem yn_succ (n : β„•) : yn a1 (n + 1) = xn a1 n + yn a1 n * a := rfl #align pell.yn_succ Pell.yn_succ --@[simp] Porting note (#10618): `simp` can prove it theorem xn_one : xn a1 1 = a := by simp #align pell.xn_one Pell.xn_one --@[simp] Porting note (#10618): `simp` can prove it theorem yn_one : yn a1 1 = 1 := by simp #align pell.yn_one Pell.yn_one def xz (n : β„•) : β„€ := xn a1 n #align pell.xz Pell.xz def yz (n : β„•) : β„€ := yn a1 n #align pell.yz Pell.yz section def az (a : β„•) : β„€ := a #align pell.az Pell.az end theorem asq_pos : 0 < a * a := le_trans (le_of_lt a1) (by have := @Nat.mul_le_mul_left 1 a a (le_of_lt a1); rwa [mul_one] at this) #align pell.asq_pos Pell.asq_pos theorem dz_val : ↑(d a1) = az a * az a - 1 := have : 1 ≀ a * a := asq_pos a1 by rw [Pell.d, Int.ofNat_sub this]; rfl #align pell.dz_val Pell.dz_val @[simp] theorem xz_succ (n : β„•) : (xz a1 (n + 1)) = xz a1 n * az a + d a1 * yz a1 n := rfl #align pell.xz_succ Pell.xz_succ @[simp] theorem yz_succ (n : β„•) : yz a1 (n + 1) = xz a1 n + yz a1 n * az a := rfl #align pell.yz_succ Pell.yz_succ def pellZd (n : β„•) : β„€βˆš(d a1) := ⟨xn a1 n, yn a1 n⟩ #align pell.pell_zd Pell.pellZd @[simp] theorem pellZd_re (n : β„•) : (pellZd a1 n).re = xn a1 n := rfl #align pell.pell_zd_re Pell.pellZd_re @[simp] theorem pellZd_im (n : β„•) : (pellZd a1 n).im = yn a1 n := rfl #align pell.pell_zd_im Pell.pellZd_im theorem isPell_nat {x y : β„•} : IsPell (⟨x, y⟩ : β„€βˆš(d a1)) ↔ x * x - d a1 * y * y = 1 := ⟨fun h => Nat.cast_inj.1 (by rw [Int.ofNat_sub (Int.le_of_ofNat_le_ofNat <| Int.le.intro_sub _ h)]; exact h), fun h => show ((x * x : β„•) - (d a1 * y * y : β„•) : β„€) = 1 by rw [← Int.ofNat_sub <| le_of_lt <| Nat.lt_of_sub_eq_succ h, h]; rfl⟩ #align pell.is_pell_nat Pell.isPell_nat @[simp] theorem pellZd_succ (n : β„•) : pellZd a1 (n + 1) = pellZd a1 n * ⟨a, 1⟩ := by ext <;> simp #align pell.pell_zd_succ Pell.pellZd_succ theorem isPell_one : IsPell (⟨a, 1⟩ : β„€βˆš(d a1)) := show az a * az a - d a1 * 1 * 1 = 1 by simp [dz_val] #align pell.is_pell_one Pell.isPell_one theorem isPell_pellZd : βˆ€ n : β„•, IsPell (pellZd a1 n) | 0 => rfl | n + 1 => by let o := isPell_one a1 simp; exact Pell.isPell_mul (isPell_pellZd n) o #align pell.is_pell_pell_zd Pell.isPell_pellZd @[simp] theorem pell_eqz (n : β„•) : xz a1 n * xz a1 n - d a1 * yz a1 n * yz a1 n = 1 := isPell_pellZd a1 n #align pell.pell_eqz Pell.pell_eqz @[simp] theorem pell_eq (n : β„•) : xn a1 n * xn a1 n - d a1 * yn a1 n * yn a1 n = 1 := let pn := pell_eqz a1 n have h : (↑(xn a1 n * xn a1 n) : β„€) - ↑(d a1 * yn a1 n * yn a1 n) = 1 := by repeat' rw [Int.ofNat_mul]; exact pn have hl : d a1 * yn a1 n * yn a1 n ≀ xn a1 n * xn a1 n := Nat.cast_le.1 <| Int.le.intro _ <| add_eq_of_eq_sub' <| Eq.symm h Nat.cast_inj.1 (by rw [Int.ofNat_sub hl]; exact h) #align pell.pell_eq Pell.pell_eq instance dnsq : Zsqrtd.Nonsquare (d a1) := ⟨fun n h => have : n * n + 1 = a * a := by rw [← h]; exact Nat.succ_pred_eq_of_pos (asq_pos a1) have na : n < a := Nat.mul_self_lt_mul_self_iff.1 (by rw [← this]; exact Nat.lt_succ_self _) have : (n + 1) * (n + 1) ≀ n * n + 1 := by rw [this]; exact Nat.mul_self_le_mul_self na have : n + n ≀ 0 := @Nat.le_of_add_le_add_right _ (n * n + 1) _ (by ring_nf at this ⊒; assumption) Nat.ne_of_gt (d_pos a1) <| by rwa [Nat.eq_zero_of_le_zero ((Nat.le_add_left _ _).trans this)] at h⟩ #align pell.dnsq Pell.dnsq theorem xn_ge_a_pow : βˆ€ n : β„•, a ^ n ≀ xn a1 n | 0 => le_refl 1 | n + 1 => by simp only [_root_.pow_succ, xn_succ] exact le_trans (Nat.mul_le_mul_right _ (xn_ge_a_pow n)) (Nat.le_add_right _ _) #align pell.xn_ge_a_pow Pell.xn_ge_a_pow theorem n_lt_a_pow : βˆ€ n : β„•, n < a ^ n | 0 => Nat.le_refl 1 | n + 1 => by have IH := n_lt_a_pow n have : a ^ n + a ^ n ≀ a ^ n * a := by rw [← mul_two] exact Nat.mul_le_mul_left _ a1 simp only [_root_.pow_succ, gt_iff_lt] refine lt_of_lt_of_le ?_ this exact add_lt_add_of_lt_of_le IH (lt_of_le_of_lt (Nat.zero_le _) IH) #align pell.n_lt_a_pow Pell.n_lt_a_pow theorem n_lt_xn (n) : n < xn a1 n := lt_of_lt_of_le (n_lt_a_pow a1 n) (xn_ge_a_pow a1 n) #align pell.n_lt_xn Pell.n_lt_xn theorem x_pos (n) : 0 < xn a1 n := lt_of_le_of_lt (Nat.zero_le n) (n_lt_xn a1 n) #align pell.x_pos Pell.x_pos theorem eq_pell_lem : βˆ€ (n) (b : β„€βˆš(d a1)), 1 ≀ b β†’ IsPell b β†’ b ≀ pellZd a1 n β†’ βˆƒ n, b = pellZd a1 n | 0, b => fun h1 _ hl => ⟨0, @Zsqrtd.le_antisymm _ (dnsq a1) _ _ hl h1⟩ | n + 1, b => fun h1 hp h => have a1p : (0 : β„€βˆš(d a1)) ≀ ⟨a, 1⟩ := trivial have am1p : (0 : β„€βˆš(d a1)) ≀ ⟨a, -1⟩ := show (_ : Nat) ≀ _ by simp; exact Nat.pred_le _ have a1m : (⟨a, 1⟩ * ⟨a, -1⟩ : β„€βˆš(d a1)) = 1 := isPell_norm.1 (isPell_one a1) if ha : (βŸ¨β†‘a, 1⟩ : β„€βˆš(d a1)) ≀ b then let ⟨m, e⟩ := eq_pell_lem n (b * ⟨a, -1⟩) (by rw [← a1m]; exact mul_le_mul_of_nonneg_right ha am1p) (isPell_mul hp (isPell_star.1 (isPell_one a1))) (by have t := mul_le_mul_of_nonneg_right h am1p rwa [pellZd_succ, mul_assoc, a1m, mul_one] at t) ⟨m + 1, by rw [show b = b * ⟨a, -1⟩ * ⟨a, 1⟩ by rw [mul_assoc, Eq.trans (mul_comm _ _) a1m]; simp, pellZd_succ, e]⟩ else suffices Β¬1 < b from ⟨0, show b = 1 from (Or.resolve_left (lt_or_eq_of_le h1) this).symm⟩ fun h1l => by cases' b with x y exact by have bm : (_ * ⟨_, _⟩ : β„€βˆšd a1) = 1 := Pell.isPell_norm.1 hp have y0l : (0 : β„€βˆšd a1) < ⟨x - x, y - -y⟩ := sub_lt_sub h1l fun hn : (1 : β„€βˆšd a1) ≀ ⟨x, -y⟩ => by have t := mul_le_mul_of_nonneg_left hn (le_trans zero_le_one h1) erw [bm, mul_one] at t exact h1l t have yl2 : (⟨_, _⟩ : β„€βˆš_) < ⟨_, _⟩ := show (⟨x, y⟩ - ⟨x, -y⟩ : β„€βˆšd a1) < ⟨a, 1⟩ - ⟨a, -1⟩ from sub_lt_sub ha fun hn : (⟨x, -y⟩ : β„€βˆšd a1) ≀ ⟨a, -1⟩ => by have t := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hn (le_trans zero_le_one h1)) a1p erw [bm, one_mul, mul_assoc, Eq.trans (mul_comm _ _) a1m, mul_one] at t exact ha t simp only [sub_self, sub_neg_eq_add] at y0l; simp only [Zsqrtd.neg_re, add_right_neg, Zsqrtd.neg_im, neg_neg] at yl2 exact match y, y0l, (yl2 : (⟨_, _⟩ : β„€βˆš_) < ⟨_, _⟩) with | 0, y0l, _ => y0l (le_refl 0) | (y + 1 : β„•), _, yl2 => yl2 (Zsqrtd.le_of_le_le (by simp [sub_eq_add_neg]) (let t := Int.ofNat_le_ofNat_of_le (Nat.succ_pos y) add_le_add t t)) | Int.negSucc _, y0l, _ => y0l trivial #align pell.eq_pell_lem Pell.eq_pell_lem theorem eq_pellZd (b : β„€βˆš(d a1)) (b1 : 1 ≀ b) (hp : IsPell b) : βˆƒ n, b = pellZd a1 n := let ⟨n, h⟩ := @Zsqrtd.le_arch (d a1) b eq_pell_lem a1 n b b1 hp <| h.trans <| by rw [Zsqrtd.natCast_val] exact Zsqrtd.le_of_le_le (Int.ofNat_le_ofNat_of_le <| le_of_lt <| n_lt_xn _ _) (Int.ofNat_zero_le _) #align pell.eq_pell_zd Pell.eq_pellZd theorem eq_pell {x y : β„•} (hp : x * x - d a1 * y * y = 1) : βˆƒ n, x = xn a1 n ∧ y = yn a1 n := have : (1 : β„€βˆš(d a1)) ≀ ⟨x, y⟩ := match x, hp with | 0, (hp : 0 - _ = 1) => by rw [zero_tsub] at hp; contradiction | x + 1, _hp => Zsqrtd.le_of_le_le (Int.ofNat_le_ofNat_of_le <| Nat.succ_pos x) (Int.ofNat_zero_le _) let ⟨m, e⟩ := eq_pellZd a1 ⟨x, y⟩ this ((isPell_nat a1).2 hp) ⟨m, match x, y, e with | _, _, rfl => ⟨rfl, rfl⟩⟩ #align pell.eq_pell Pell.eq_pell theorem pellZd_add (m) : βˆ€ n, pellZd a1 (m + n) = pellZd a1 m * pellZd a1 n | 0 => (mul_one _).symm | n + 1 => by rw [← add_assoc, pellZd_succ, pellZd_succ, pellZd_add _ n, ← mul_assoc] #align pell.pell_zd_add Pell.pellZd_add theorem xn_add (m n) : xn a1 (m + n) = xn a1 m * xn a1 n + d a1 * yn a1 m * yn a1 n := by injection pellZd_add a1 m n with h _ zify rw [h] simp [pellZd] #align pell.xn_add Pell.xn_add theorem yn_add (m n) : yn a1 (m + n) = xn a1 m * yn a1 n + yn a1 m * xn a1 n := by injection pellZd_add a1 m n with _ h zify rw [h] simp [pellZd] #align pell.yn_add Pell.yn_add theorem pellZd_sub {m n} (h : n ≀ m) : pellZd a1 (m - n) = pellZd a1 m * star (pellZd a1 n) := by let t := pellZd_add a1 n (m - n) rw [add_tsub_cancel_of_le h] at t rw [t, mul_comm (pellZd _ n) _, mul_assoc, isPell_norm.1 (isPell_pellZd _ _), mul_one] #align pell.pell_zd_sub Pell.pellZd_sub theorem xz_sub {m n} (h : n ≀ m) : xz a1 (m - n) = xz a1 m * xz a1 n - d a1 * yz a1 m * yz a1 n := by rw [sub_eq_add_neg, ← mul_neg] exact congr_arg Zsqrtd.re (pellZd_sub a1 h) #align pell.xz_sub Pell.xz_sub theorem yz_sub {m n} (h : n ≀ m) : yz a1 (m - n) = xz a1 n * yz a1 m - xz a1 m * yz a1 n := by rw [sub_eq_add_neg, ← mul_neg, mul_comm, add_comm] exact congr_arg Zsqrtd.im (pellZd_sub a1 h) #align pell.yz_sub Pell.yz_sub theorem xy_coprime (n) : (xn a1 n).Coprime (yn a1 n) := Nat.coprime_of_dvd' fun k _ kx ky => by let p := pell_eq a1 n rw [← p] exact Nat.dvd_sub (le_of_lt <| Nat.lt_of_sub_eq_succ p) (kx.mul_left _) (ky.mul_left _) #align pell.xy_coprime Pell.xy_coprime theorem strictMono_y : StrictMono (yn a1) | m, 0, h => absurd h <| Nat.not_lt_zero _ | m, n + 1, h => by have : yn a1 m ≀ yn a1 n := Or.elim (lt_or_eq_of_le <| Nat.le_of_succ_le_succ h) (fun hl => le_of_lt <| strictMono_y hl) fun e => by rw [e] simp; refine lt_of_le_of_lt ?_ (Nat.lt_add_of_pos_left <| x_pos a1 n) rw [← mul_one (yn a1 m)] exact mul_le_mul this (le_of_lt a1) (Nat.zero_le _) (Nat.zero_le _) #align pell.strict_mono_y Pell.strictMono_y theorem strictMono_x : StrictMono (xn a1) | m, 0, h => absurd h <| Nat.not_lt_zero _ | m, n + 1, h => by have : xn a1 m ≀ xn a1 n := Or.elim (lt_or_eq_of_le <| Nat.le_of_succ_le_succ h) (fun hl => le_of_lt <| strictMono_x hl) fun e => by rw [e] simp; refine lt_of_lt_of_le (lt_of_le_of_lt this ?_) (Nat.le_add_right _ _) have t := Nat.mul_lt_mul_of_pos_left a1 (x_pos a1 n) rwa [mul_one] at t #align pell.strict_mono_x Pell.strictMono_x theorem yn_ge_n : βˆ€ n, n ≀ yn a1 n | 0 => Nat.zero_le _ | n + 1 => show n < yn a1 (n + 1) from lt_of_le_of_lt (yn_ge_n n) (strictMono_y a1 <| Nat.lt_succ_self n) #align pell.yn_ge_n Pell.yn_ge_n theorem y_mul_dvd (n) : βˆ€ k, yn a1 n ∣ yn a1 (n * k) | 0 => dvd_zero _ | k + 1 => by rw [Nat.mul_succ, yn_add]; exact dvd_add (dvd_mul_left _ _) ((y_mul_dvd _ k).mul_right _) #align pell.y_mul_dvd Pell.y_mul_dvd theorem y_dvd_iff (m n) : yn a1 m ∣ yn a1 n ↔ m ∣ n := ⟨fun h => Nat.dvd_of_mod_eq_zero <| (Nat.eq_zero_or_pos _).resolve_right fun hp => by have co : Nat.Coprime (yn a1 m) (xn a1 (m * (n / m))) := Nat.Coprime.symm <| (xy_coprime a1 _).coprime_dvd_right (y_mul_dvd a1 m (n / m)) have m0 : 0 < m := m.eq_zero_or_pos.resolve_left fun e => by rw [e, Nat.mod_zero] at hp;rw [e] at h exact _root_.ne_of_lt (strictMono_y a1 hp) (eq_zero_of_zero_dvd h).symm rw [← Nat.mod_add_div n m, yn_add] at h exact not_le_of_gt (strictMono_y _ <| Nat.mod_lt n m0) (Nat.le_of_dvd (strictMono_y _ hp) <| co.dvd_of_dvd_mul_right <| (Nat.dvd_add_iff_right <| (y_mul_dvd _ _ _).mul_left _).2 h), fun ⟨k, e⟩ => by rw [e]; apply y_mul_dvd⟩ #align pell.y_dvd_iff Pell.y_dvd_iff theorem xy_modEq_yn (n) : βˆ€ k, xn a1 (n * k) ≑ xn a1 n ^ k [MOD yn a1 n ^ 2] ∧ yn a1 (n * k) ≑ k * xn a1 n ^ (k - 1) * yn a1 n [MOD yn a1 n ^ 3] | 0 => by constructor <;> simp <;> exact Nat.ModEq.refl _ | k + 1 => by let ⟨hx, hy⟩ := xy_modEq_yn n k have L : xn a1 (n * k) * xn a1 n + d a1 * yn a1 (n * k) * yn a1 n ≑ xn a1 n ^ k * xn a1 n + 0 [MOD yn a1 n ^ 2] := (hx.mul_right _).add <| modEq_zero_iff_dvd.2 <| by rw [_root_.pow_succ] exact mul_dvd_mul_right (dvd_mul_of_dvd_right (modEq_zero_iff_dvd.1 <| (hy.of_dvd <| by simp [_root_.pow_succ]).trans <| modEq_zero_iff_dvd.2 <| by simp) _) _ have R : xn a1 (n * k) * yn a1 n + yn a1 (n * k) * xn a1 n ≑ xn a1 n ^ k * yn a1 n + k * xn a1 n ^ k * yn a1 n [MOD yn a1 n ^ 3] := ModEq.add (by rw [_root_.pow_succ] exact hx.mul_right' _) <| by have : k * xn a1 n ^ (k - 1) * yn a1 n * xn a1 n = k * xn a1 n ^ k * yn a1 n := by cases' k with k <;> simp [_root_.pow_succ]; ring_nf rw [← this] exact hy.mul_right _ rw [add_tsub_cancel_right, Nat.mul_succ, xn_add, yn_add, pow_succ (xn _ n), Nat.succ_mul, add_comm (k * xn _ n ^ k) (xn _ n ^ k), right_distrib] exact ⟨L, R⟩ #align pell.xy_modeq_yn Pell.xy_modEq_yn theorem ysq_dvd_yy (n) : yn a1 n * yn a1 n ∣ yn a1 (n * yn a1 n) := modEq_zero_iff_dvd.1 <| ((xy_modEq_yn a1 n (yn a1 n)).right.of_dvd <| by simp [_root_.pow_succ]).trans (modEq_zero_iff_dvd.2 <| by simp [mul_dvd_mul_left, mul_assoc]) #align pell.ysq_dvd_yy Pell.ysq_dvd_yy theorem dvd_of_ysq_dvd {n t} (h : yn a1 n * yn a1 n ∣ yn a1 t) : yn a1 n ∣ t := have nt : n ∣ t := (y_dvd_iff a1 n t).1 <| dvd_of_mul_left_dvd h n.eq_zero_or_pos.elim (fun n0 => by rwa [n0] at nt ⊒) fun n0l : 0 < n => by let ⟨k, ke⟩ := nt have : yn a1 n ∣ k * xn a1 n ^ (k - 1) := Nat.dvd_of_mul_dvd_mul_right (strictMono_y a1 n0l) <| modEq_zero_iff_dvd.1 <| by have xm := (xy_modEq_yn a1 n k).right; rw [← ke] at xm exact (xm.of_dvd <| by simp [_root_.pow_succ]).symm.trans h.modEq_zero_nat rw [ke] exact dvd_mul_of_dvd_right (((xy_coprime _ _).pow_left _).symm.dvd_of_dvd_mul_right this) _ #align pell.dvd_of_ysq_dvd Pell.dvd_of_ysq_dvd theorem pellZd_succ_succ (n) : pellZd a1 (n + 2) + pellZd a1 n = (2 * a : β„•) * pellZd a1 (n + 1) := by have : (1 : β„€βˆš(d a1)) + ⟨a, 1⟩ * ⟨a, 1⟩ = ⟨a, 1⟩ * (2 * a) := by rw [Zsqrtd.natCast_val] change (⟨_, _⟩ : β„€βˆš(d a1)) = ⟨_, _⟩ rw [dz_val] dsimp [az] ext <;> dsimp <;> ring_nf simpa [mul_add, mul_comm, mul_left_comm, add_comm] using congr_arg (Β· * pellZd a1 n) this #align pell.pell_zd_succ_succ Pell.pellZd_succ_succ theorem xy_succ_succ (n) : xn a1 (n + 2) + xn a1 n = 2 * a * xn a1 (n + 1) ∧ yn a1 (n + 2) + yn a1 n = 2 * a * yn a1 (n + 1) := by have := pellZd_succ_succ a1 n; unfold pellZd at this erw [Zsqrtd.smul_val (2 * a : β„•)] at this injection this with h₁ hβ‚‚ constructor <;> apply Int.ofNat.inj <;> [simpa using h₁; simpa using hβ‚‚] #align pell.xy_succ_succ Pell.xy_succ_succ theorem xn_succ_succ (n) : xn a1 (n + 2) + xn a1 n = 2 * a * xn a1 (n + 1) := (xy_succ_succ a1 n).1 #align pell.xn_succ_succ Pell.xn_succ_succ theorem yn_succ_succ (n) : yn a1 (n + 2) + yn a1 n = 2 * a * yn a1 (n + 1) := (xy_succ_succ a1 n).2 #align pell.yn_succ_succ Pell.yn_succ_succ theorem xz_succ_succ (n) : xz a1 (n + 2) = (2 * a : β„•) * xz a1 (n + 1) - xz a1 n := eq_sub_of_add_eq <| by delta xz; rw [← Int.ofNat_add, ← Int.ofNat_mul, xn_succ_succ] #align pell.xz_succ_succ Pell.xz_succ_succ theorem yz_succ_succ (n) : yz a1 (n + 2) = (2 * a : β„•) * yz a1 (n + 1) - yz a1 n := eq_sub_of_add_eq <| by delta yz; rw [← Int.ofNat_add, ← Int.ofNat_mul, yn_succ_succ] #align pell.yz_succ_succ Pell.yz_succ_succ theorem yn_modEq_a_sub_one : βˆ€ n, yn a1 n ≑ n [MOD a - 1] | 0 => by simp [Nat.ModEq.refl] | 1 => by simp [Nat.ModEq.refl] | n + 2 => (yn_modEq_a_sub_one n).add_right_cancel <| by rw [yn_succ_succ, (by ring : n + 2 + n = 2 * (n + 1))] exact ((modEq_sub a1.le).mul_left 2).mul (yn_modEq_a_sub_one (n + 1)) #align pell.yn_modeq_a_sub_one Pell.yn_modEq_a_sub_one theorem yn_modEq_two : βˆ€ n, yn a1 n ≑ n [MOD 2] | 0 => by rfl | 1 => by simp; rfl | n + 2 => (yn_modEq_two n).add_right_cancel <| by rw [yn_succ_succ, mul_assoc, (by ring : n + 2 + n = 2 * (n + 1))] exact (dvd_mul_right 2 _).modEq_zero_nat.trans (dvd_mul_right 2 _).zero_modEq_nat #align pell.yn_modeq_two Pell.yn_modEq_two section theorem x_sub_y_dvd_pow_lem (y2 y1 y0 yn1 yn0 xn1 xn0 ay a2 : β„€) : (a2 * yn1 - yn0) * ay + y2 - (a2 * xn1 - xn0) = y2 - a2 * y1 + y0 + a2 * (yn1 * ay + y1 - xn1) - (yn0 * ay + y0 - xn0) := by ring #align pell.x_sub_y_dvd_pow_lem Pell.x_sub_y_dvd_pow_lem end theorem x_sub_y_dvd_pow (y : β„•) : βˆ€ n, (2 * a * y - y * y - 1 : β„€) ∣ yz a1 n * (a - y) + ↑(y ^ n) - xz a1 n | 0 => by simp [xz, yz, Int.ofNat_zero, Int.ofNat_one] | 1 => by simp [xz, yz, Int.ofNat_zero, Int.ofNat_one] | n + 2 => by have : (2 * a * y - y * y - 1 : β„€) ∣ ↑(y ^ (n + 2)) - ↑(2 * a) * ↑(y ^ (n + 1)) + ↑(y ^ n) := ⟨-↑(y ^ n), by simp [_root_.pow_succ, mul_add, Int.ofNat_mul, show ((2 : β„•) : β„€) = 2 from rfl, mul_comm, mul_left_comm] ring⟩ rw [xz_succ_succ, yz_succ_succ, x_sub_y_dvd_pow_lem ↑(y ^ (n + 2)) ↑(y ^ (n + 1)) ↑(y ^ n)] exact _root_.dvd_sub (dvd_add this <| (x_sub_y_dvd_pow _ (n + 1)).mul_left _) (x_sub_y_dvd_pow _ n) #align pell.x_sub_y_dvd_pow Pell.x_sub_y_dvd_pow theorem xn_modEq_x2n_add_lem (n j) : xn a1 n ∣ d a1 * yn a1 n * (yn a1 n * xn a1 j) + xn a1 j := by have h1 : d a1 * yn a1 n * (yn a1 n * xn a1 j) + xn a1 j = (d a1 * yn a1 n * yn a1 n + 1) * xn a1 j := by simp [add_mul, mul_assoc] have h2 : d a1 * yn a1 n * yn a1 n + 1 = xn a1 n * xn a1 n := by zify at * apply add_eq_of_eq_sub' (Eq.symm (pell_eqz a1 n)) rw [h2] at h1; rw [h1, mul_assoc]; exact dvd_mul_right _ _ #align pell.xn_modeq_x2n_add_lem Pell.xn_modEq_x2n_add_lem theorem xn_modEq_x2n_add (n j) : xn a1 (2 * n + j) + xn a1 j ≑ 0 [MOD xn a1 n] := by rw [two_mul, add_assoc, xn_add, add_assoc, ← zero_add 0] refine (dvd_mul_right (xn a1 n) (xn a1 (n + j))).modEq_zero_nat.add ?_ rw [yn_add, left_distrib, add_assoc, ← zero_add 0] exact ((dvd_mul_right _ _).mul_left _).modEq_zero_nat.add (xn_modEq_x2n_add_lem _ _ _).modEq_zero_nat #align pell.xn_modeq_x2n_add Pell.xn_modEq_x2n_add
Mathlib/NumberTheory/PellMatiyasevic.lean
606
619
theorem xn_modEq_x2n_sub_lem {n j} (h : j ≀ n) : xn a1 (2 * n - j) + xn a1 j ≑ 0 [MOD xn a1 n] := by
have h1 : xz a1 n ∣ d a1 * yz a1 n * yz a1 (n - j) + xz a1 j := by rw [yz_sub _ h, mul_sub_left_distrib, sub_add_eq_add_sub] exact dvd_sub (by delta xz; delta yz rw [mul_comm (xn _ _ : β„€)] exact mod_cast (xn_modEq_x2n_add_lem _ n j)) ((dvd_mul_right _ _).mul_left _) rw [two_mul, add_tsub_assoc_of_le h, xn_add, add_assoc, ← zero_add 0] exact (dvd_mul_right _ _).modEq_zero_nat.add (Int.natCast_dvd_natCast.1 <| by simpa [xz, yz] using h1).modEq_zero_nat
import Mathlib.Algebra.Order.Module.Defs import Mathlib.Data.DFinsupp.Basic #align_import data.dfinsupp.order from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29" open Finset variable {ΞΉ : Type*} {Ξ± : ΞΉ β†’ Type*} namespace DFinsupp section Zero variable [βˆ€ i, Zero (Ξ± i)] instance [βˆ€ i, PartialOrder (Ξ± i)] : PartialOrder (Ξ β‚€ i, Ξ± i) := { (inferInstance : Preorder (DFinsupp Ξ±)) with le_antisymm := fun _ _ hfg hgf ↦ ext fun i ↦ (hfg i).antisymm (hgf i) } instance [βˆ€ i, SemilatticeInf (Ξ± i)] : SemilatticeInf (Ξ β‚€ i, Ξ± i) := { (inferInstance : PartialOrder (DFinsupp Ξ±)) with inf := zipWith (fun _ ↦ (Β· βŠ“ Β·)) fun _ ↦ inf_idem _ inf_le_left := fun _ _ _ ↦ inf_le_left inf_le_right := fun _ _ _ ↦ inf_le_right le_inf := fun _ _ _ hf hg i ↦ le_inf (hf i) (hg i) } @[simp, norm_cast] lemma coe_inf [βˆ€ i, SemilatticeInf (Ξ± i)] (f g : Ξ β‚€ i, Ξ± i) : f βŠ“ g = ⇑f βŠ“ g := rfl theorem inf_apply [βˆ€ i, SemilatticeInf (Ξ± i)] (f g : Ξ β‚€ i, Ξ± i) (i : ΞΉ) : (f βŠ“ g) i = f i βŠ“ g i := zipWith_apply _ _ _ _ _ #align dfinsupp.inf_apply DFinsupp.inf_apply instance [βˆ€ i, SemilatticeSup (Ξ± i)] : SemilatticeSup (Ξ β‚€ i, Ξ± i) := { (inferInstance : PartialOrder (DFinsupp Ξ±)) with sup := zipWith (fun _ ↦ (Β· βŠ” Β·)) fun _ ↦ sup_idem _ le_sup_left := fun _ _ _ ↦ le_sup_left le_sup_right := fun _ _ _ ↦ le_sup_right sup_le := fun _ _ _ hf hg i ↦ sup_le (hf i) (hg i) } @[simp, norm_cast] lemma coe_sup [βˆ€ i, SemilatticeSup (Ξ± i)] (f g : Ξ β‚€ i, Ξ± i) : f βŠ” g = ⇑f βŠ” g := rfl theorem sup_apply [βˆ€ i, SemilatticeSup (Ξ± i)] (f g : Ξ β‚€ i, Ξ± i) (i : ΞΉ) : (f βŠ” g) i = f i βŠ” g i := zipWith_apply _ _ _ _ _ #align dfinsupp.sup_apply DFinsupp.sup_apply instance (Ξ± : ΞΉ β†’ Type*) [βˆ€ i, OrderedAddCommMonoid (Ξ± i)] : OrderedAddCommMonoid (Ξ β‚€ i, Ξ± i) := { (inferInstance : AddCommMonoid (DFinsupp Ξ±)), (inferInstance : PartialOrder (DFinsupp Ξ±)) with add_le_add_left := fun _ _ h c i ↦ add_le_add_left (h i) (c i) } instance (Ξ± : ΞΉ β†’ Type*) [βˆ€ i, OrderedCancelAddCommMonoid (Ξ± i)] : OrderedCancelAddCommMonoid (Ξ β‚€ i, Ξ± i) := { (inferInstance : OrderedAddCommMonoid (DFinsupp Ξ±)) with le_of_add_le_add_left := fun _ _ _ H i ↦ le_of_add_le_add_left (H i) } instance [βˆ€ i, OrderedAddCommMonoid (Ξ± i)] [βˆ€ i, ContravariantClass (Ξ± i) (Ξ± i) (Β· + Β·) (Β· ≀ Β·)] : ContravariantClass (Ξ β‚€ i, Ξ± i) (Ξ β‚€ i, Ξ± i) (Β· + Β·) (Β· ≀ Β·) := ⟨fun _ _ _ H i ↦ le_of_add_le_add_left (H i)⟩ section CanonicallyLinearOrderedAddCommMonoid variable [βˆ€ i, CanonicallyLinearOrderedAddCommMonoid (Ξ± i)] [DecidableEq ΞΉ] {f g : Ξ β‚€ i, Ξ± i} @[simp] theorem support_inf : (f βŠ“ g).support = f.support ∩ g.support := by ext simp only [inf_apply, mem_support_iff, Ne, Finset.mem_inter] simp only [inf_eq_min, ← nonpos_iff_eq_zero, min_le_iff, not_or] #align dfinsupp.support_inf DFinsupp.support_inf @[simp]
Mathlib/Data/DFinsupp/Order.lean
320
323
theorem support_sup : (f βŠ” g).support = f.support βˆͺ g.support := by
ext simp only [Finset.mem_union, mem_support_iff, sup_apply, Ne, ← bot_eq_zero] rw [_root_.sup_eq_bot_iff, not_and_or]
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 AddCancelCommMonoid variable [AddCancelCommMonoid E] [OrderedAddCommMonoid Ξ²] [Module π•œ E] [SMul π•œ Ξ²] {s : Set E} {f : E β†’ Ξ²}
Mathlib/Analysis/Convex/Function.lean
940
946
theorem StrictConvexOn.translate_right (hf : StrictConvexOn π•œ s f) (c : E) : StrictConvexOn π•œ ((fun z => c + z) ⁻¹' s) (f ∘ fun z => c + z) := ⟨hf.1.translate_preimage_right _, fun x hx y hy hxy a b ha hb hab => calc f (c + (a β€’ x + b β€’ y)) = f (a β€’ (c + x) + b β€’ (c + y)) := by
rw [smul_add, smul_add, add_add_add_comm, Convex.combo_self hab] _ < a β€’ f (c + x) + b β€’ f (c + y) := hf.2 hx hy ((add_right_injective c).ne hxy) ha hb hab⟩
import Mathlib.CategoryTheory.Functor.Const import Mathlib.CategoryTheory.DiscreteCategory import Mathlib.CategoryTheory.Yoneda import Mathlib.CategoryTheory.Functor.ReflectsIso #align_import category_theory.limits.cones from "leanprover-community/mathlib"@"740acc0e6f9adf4423f92a485d0456fc271482da" -- morphism levels before object levels. See note [CategoryTheory universes]. universe v₁ vβ‚‚ v₃ vβ‚„ u₁ uβ‚‚ u₃ uβ‚„ open CategoryTheory variable {J : Type u₁} [Category.{v₁} J] variable {K : Type uβ‚‚} [Category.{vβ‚‚} K] variable {C : Type u₃} [Category.{v₃} C] variable {D : Type uβ‚„} [Category.{vβ‚„} D] open CategoryTheory open CategoryTheory.Category open CategoryTheory.Functor open Opposite namespace CategoryTheory section variable (J C) @[simps!] def cones : (J β₯€ C) β₯€ Cα΅’α΅– β₯€ Type max u₁ v₃ where obj := Functor.cones map f := whiskerLeft (const J).op (yoneda.map f) #align category_theory.cones CategoryTheory.cones @[simps!] def cocones : (J β₯€ C)α΅’α΅– β₯€ C β₯€ Type max u₁ v₃ where obj F := Functor.cocones (unop F) map f := whiskerLeft (const J) (coyoneda.map f) #align category_theory.cocones CategoryTheory.cocones end namespace Limits section structure Cone (F : J β₯€ C) where pt : C Ο€ : (const J).obj pt ⟢ F #align category_theory.limits.cone CategoryTheory.Limits.Cone set_option linter.uppercaseLean3 false in #align category_theory.limits.cone.X CategoryTheory.Limits.Cone.pt instance inhabitedCone (F : Discrete PUnit β₯€ C) : Inhabited (Cone F) := ⟨{ pt := F.obj ⟨⟨⟩⟩ Ο€ := { app := fun ⟨⟨⟩⟩ => πŸ™ _ naturality := by intro X Y f match X, Y, f with | .mk A, .mk B, .up g => aesop_cat } }⟩ #align category_theory.limits.inhabited_cone CategoryTheory.Limits.inhabitedCone @[reassoc (attr := simp)] theorem Cone.w {F : J β₯€ C} (c : Cone F) {j j' : J} (f : j ⟢ j') : c.Ο€.app j ≫ F.map f = c.Ο€.app j' := by rw [← c.Ο€.naturality f] apply id_comp #align category_theory.limits.cone.w CategoryTheory.Limits.Cone.w structure Cocone (F : J β₯€ C) where pt : C ΞΉ : F ⟢ (const J).obj pt #align category_theory.limits.cocone CategoryTheory.Limits.Cocone set_option linter.uppercaseLean3 false in #align category_theory.limits.cocone.X CategoryTheory.Limits.Cocone.pt instance inhabitedCocone (F : Discrete PUnit β₯€ C) : Inhabited (Cocone F) := ⟨{ pt := F.obj ⟨⟨⟩⟩ ΞΉ := { app := fun ⟨⟨⟩⟩ => πŸ™ _ naturality := by intro X Y f match X, Y, f with | .mk A, .mk B, .up g => aesop_cat } }⟩ #align category_theory.limits.inhabited_cocone CategoryTheory.Limits.inhabitedCocone @[reassoc] -- @[simp] -- Porting note (#10618): simp can prove this
Mathlib/CategoryTheory/Limits/Cones.lean
181
184
theorem Cocone.w {F : J β₯€ C} (c : Cocone F) {j j' : J} (f : j ⟢ j') : F.map f ≫ c.ΞΉ.app j' = c.ΞΉ.app j := by
rw [c.ΞΉ.naturality f] apply comp_id
import Mathlib.Topology.Algebra.InfiniteSum.Basic import Mathlib.Topology.Algebra.UniformGroup noncomputable section open Filter Finset Function open scoped Topology variable {Ξ± Ξ² Ξ³ Ξ΄ : Type*} section TopologicalGroup variable [CommGroup Ξ±] [TopologicalSpace Ξ±] [TopologicalGroup Ξ±] variable {f g : Ξ² β†’ Ξ±} {a a₁ aβ‚‚ : Ξ±} -- `by simpa using` speeds up elaboration. Why? @[to_additive] theorem HasProd.inv (h : HasProd f a) : HasProd (fun b ↦ (f b)⁻¹) a⁻¹ := by simpa only using h.map (MonoidHom.id Ξ±)⁻¹ continuous_inv #align has_sum.neg HasSum.neg @[to_additive] theorem Multipliable.inv (hf : Multipliable f) : Multipliable fun b ↦ (f b)⁻¹ := hf.hasProd.inv.multipliable #align summable.neg Summable.neg @[to_additive] theorem Multipliable.of_inv (hf : Multipliable fun b ↦ (f b)⁻¹) : Multipliable f := by simpa only [inv_inv] using hf.inv #align summable.of_neg Summable.of_neg @[to_additive] theorem multipliable_inv_iff : (Multipliable fun b ↦ (f b)⁻¹) ↔ Multipliable f := ⟨Multipliable.of_inv, Multipliable.inv⟩ #align summable_neg_iff summable_neg_iff @[to_additive] theorem HasProd.div (hf : HasProd f a₁) (hg : HasProd g aβ‚‚) : HasProd (fun b ↦ f b / g b) (a₁ / aβ‚‚) := by simp only [div_eq_mul_inv] exact hf.mul hg.inv #align has_sum.sub HasSum.sub @[to_additive] theorem Multipliable.div (hf : Multipliable f) (hg : Multipliable g) : Multipliable fun b ↦ f b / g b := (hf.hasProd.div hg.hasProd).multipliable #align summable.sub Summable.sub @[to_additive] theorem Multipliable.trans_div (hg : Multipliable g) (hfg : Multipliable fun b ↦ f b / g b) : Multipliable f := by simpa only [div_mul_cancel] using hfg.mul hg #align summable.trans_sub Summable.trans_sub @[to_additive] theorem multipliable_iff_of_multipliable_div (hfg : Multipliable fun b ↦ f b / g b) : Multipliable f ↔ Multipliable g := ⟨fun hf ↦ hf.trans_div <| by simpa only [inv_div] using hfg.inv, fun hg ↦ hg.trans_div hfg⟩ #align summable_iff_of_summable_sub summable_iff_of_summable_sub @[to_additive] theorem HasProd.update (hf : HasProd f a₁) (b : Ξ²) [DecidableEq Ξ²] (a : Ξ±) : HasProd (update f b a) (a / f b * a₁) := by convert (hasProd_ite_eq b (a / f b)).mul hf with b' by_cases h : b' = b Β· rw [h, update_same] simp [eq_self_iff_true, if_true, sub_add_cancel] Β· simp only [h, update_noteq, if_false, Ne, one_mul, not_false_iff] #align has_sum.update HasSum.update @[to_additive] theorem Multipliable.update (hf : Multipliable f) (b : Ξ²) [DecidableEq Ξ²] (a : Ξ±) : Multipliable (update f b a) := (hf.hasProd.update b a).multipliable #align summable.update Summable.update @[to_additive] theorem HasProd.hasProd_compl_iff {s : Set Ξ²} (hf : HasProd (f ∘ (↑) : s β†’ Ξ±) a₁) : HasProd (f ∘ (↑) : ↑sᢜ β†’ Ξ±) aβ‚‚ ↔ HasProd f (a₁ * aβ‚‚) := by refine ⟨fun h ↦ hf.mul_compl h, fun h ↦ ?_⟩ rw [hasProd_subtype_iff_mulIndicator] at hf ⊒ rw [Set.mulIndicator_compl] simpa only [div_eq_mul_inv, mul_inv_cancel_comm] using h.div hf #align has_sum.has_sum_compl_iff HasSum.hasSum_compl_iff @[to_additive] theorem HasProd.hasProd_iff_compl {s : Set Ξ²} (hf : HasProd (f ∘ (↑) : s β†’ Ξ±) a₁) : HasProd f aβ‚‚ ↔ HasProd (f ∘ (↑) : ↑sᢜ β†’ Ξ±) (aβ‚‚ / a₁) := Iff.symm <| hf.hasProd_compl_iff.trans <| by rw [mul_div_cancel] #align has_sum.has_sum_iff_compl HasSum.hasSum_iff_compl @[to_additive] theorem Multipliable.multipliable_compl_iff {s : Set Ξ²} (hf : Multipliable (f ∘ (↑) : s β†’ Ξ±)) : Multipliable (f ∘ (↑) : ↑sᢜ β†’ Ξ±) ↔ Multipliable f where mp := fun ⟨_, ha⟩ ↦ (hf.hasProd.hasProd_compl_iff.1 ha).multipliable mpr := fun ⟨_, ha⟩ ↦ (hf.hasProd.hasProd_iff_compl.1 ha).multipliable #align summable.summable_compl_iff Summable.summable_compl_iff @[to_additive] protected theorem Finset.hasProd_compl_iff (s : Finset Ξ²) : HasProd (fun x : { x // x βˆ‰ s } ↦ f x) a ↔ HasProd f (a * ∏ i ∈ s, f i) := (s.hasProd f).hasProd_compl_iff.trans <| by rw [mul_comm] #align finset.has_sum_compl_iff Finset.hasSum_compl_iff @[to_additive] protected theorem Finset.hasProd_iff_compl (s : Finset Ξ²) : HasProd f a ↔ HasProd (fun x : { x // x βˆ‰ s } ↦ f x) (a / ∏ i ∈ s, f i) := (s.hasProd f).hasProd_iff_compl #align finset.has_sum_iff_compl Finset.hasSum_iff_compl @[to_additive] protected theorem Finset.multipliable_compl_iff (s : Finset Ξ²) : (Multipliable fun x : { x // x βˆ‰ s } ↦ f x) ↔ Multipliable f := (s.multipliable f).multipliable_compl_iff #align finset.summable_compl_iff Finset.summable_compl_iff @[to_additive] theorem Set.Finite.multipliable_compl_iff {s : Set Ξ²} (hs : s.Finite) : Multipliable (f ∘ (↑) : ↑sᢜ β†’ Ξ±) ↔ Multipliable f := (hs.multipliable f).multipliable_compl_iff #align set.finite.summable_compl_iff Set.Finite.summable_compl_iff @[to_additive] theorem hasProd_ite_div_hasProd [DecidableEq Ξ²] (hf : HasProd f a) (b : Ξ²) : HasProd (fun n ↦ ite (n = b) 1 (f n)) (a / f b) := by convert hf.update b 1 using 1 Β· ext n rw [Function.update_apply] Β· rw [div_mul_eq_mul_div, one_mul] #align has_sum_ite_sub_has_sum hasSum_ite_sub_hasSum section tprod variable [T2Space Ξ±] @[to_additive]
Mathlib/Topology/Algebra/InfiniteSum/Group.lean
150
154
theorem tprod_inv : ∏' b, (f b)⁻¹ = (∏' b, f b)⁻¹ := by
by_cases hf : Multipliable f Β· exact hf.hasProd.inv.tprod_eq Β· simp [tprod_eq_one_of_not_multipliable hf, tprod_eq_one_of_not_multipliable (mt Multipliable.of_inv hf)]
import Mathlib.Analysis.Convex.Combination import Mathlib.Analysis.Convex.Strict import Mathlib.Topology.Connected.PathConnected import Mathlib.Topology.Algebra.Affine import Mathlib.Topology.Algebra.Module.Basic #align_import analysis.convex.topology from "leanprover-community/mathlib"@"0e3aacdc98d25e0afe035c452d876d28cbffaa7e" assert_not_exists Norm open Metric Bornology Set Pointwise Convex variable {ΞΉ π•œ E : Type*} theorem Real.convex_iff_isPreconnected {s : Set ℝ} : Convex ℝ s ↔ IsPreconnected s := convex_iff_ordConnected.trans isPreconnected_iff_ordConnected.symm #align real.convex_iff_is_preconnected Real.convex_iff_isPreconnected alias ⟨_, IsPreconnected.convex⟩ := Real.convex_iff_isPreconnected #align is_preconnected.convex IsPreconnected.convex section ContinuousConstSMul variable [LinearOrderedField π•œ] [AddCommGroup E] [Module π•œ E] [TopologicalSpace E] [TopologicalAddGroup E] [ContinuousConstSMul π•œ E] theorem Convex.combo_interior_closure_subset_interior {s : Set E} (hs : Convex π•œ s) {a b : π•œ} (ha : 0 < a) (hb : 0 ≀ b) (hab : a + b = 1) : a β€’ interior s + b β€’ closure s βŠ† interior s := interior_smulβ‚€ ha.ne' s β–Έ calc interior (a β€’ s) + b β€’ closure s βŠ† interior (a β€’ s) + closure (b β€’ s) := add_subset_add Subset.rfl (smul_closure_subset b s) _ = interior (a β€’ s) + b β€’ s := by rw [isOpen_interior.add_closure (b β€’ s)] _ βŠ† interior (a β€’ s + b β€’ s) := subset_interior_add_left _ βŠ† interior s := interior_mono <| hs.set_combo_subset ha.le hb hab #align convex.combo_interior_closure_subset_interior Convex.combo_interior_closure_subset_interior theorem Convex.combo_interior_self_subset_interior {s : Set E} (hs : Convex π•œ s) {a b : π•œ} (ha : 0 < a) (hb : 0 ≀ b) (hab : a + b = 1) : a β€’ interior s + b β€’ s βŠ† interior s := calc a β€’ interior s + b β€’ s βŠ† a β€’ interior s + b β€’ closure s := add_subset_add Subset.rfl <| image_subset _ subset_closure _ βŠ† interior s := hs.combo_interior_closure_subset_interior ha hb hab #align convex.combo_interior_self_subset_interior Convex.combo_interior_self_subset_interior theorem Convex.combo_closure_interior_subset_interior {s : Set E} (hs : Convex π•œ s) {a b : π•œ} (ha : 0 ≀ a) (hb : 0 < b) (hab : a + b = 1) : a β€’ closure s + b β€’ interior s βŠ† interior s := by rw [add_comm] exact hs.combo_interior_closure_subset_interior hb ha (add_comm a b β–Έ hab) #align convex.combo_closure_interior_subset_interior Convex.combo_closure_interior_subset_interior theorem Convex.combo_self_interior_subset_interior {s : Set E} (hs : Convex π•œ s) {a b : π•œ} (ha : 0 ≀ a) (hb : 0 < b) (hab : a + b = 1) : a β€’ s + b β€’ interior s βŠ† interior s := by rw [add_comm] exact hs.combo_interior_self_subset_interior hb ha (add_comm a b β–Έ hab) #align convex.combo_self_interior_subset_interior Convex.combo_self_interior_subset_interior theorem Convex.combo_interior_closure_mem_interior {s : Set E} (hs : Convex π•œ s) {x y : E} (hx : x ∈ interior s) (hy : y ∈ closure s) {a b : π•œ} (ha : 0 < a) (hb : 0 ≀ b) (hab : a + b = 1) : a β€’ x + b β€’ y ∈ interior s := hs.combo_interior_closure_subset_interior ha hb hab <| add_mem_add (smul_mem_smul_set hx) (smul_mem_smul_set hy) #align convex.combo_interior_closure_mem_interior Convex.combo_interior_closure_mem_interior theorem Convex.combo_interior_self_mem_interior {s : Set E} (hs : Convex π•œ s) {x y : E} (hx : x ∈ interior s) (hy : y ∈ s) {a b : π•œ} (ha : 0 < a) (hb : 0 ≀ b) (hab : a + b = 1) : a β€’ x + b β€’ y ∈ interior s := hs.combo_interior_closure_mem_interior hx (subset_closure hy) ha hb hab #align convex.combo_interior_self_mem_interior Convex.combo_interior_self_mem_interior theorem Convex.combo_closure_interior_mem_interior {s : Set E} (hs : Convex π•œ s) {x y : E} (hx : x ∈ closure s) (hy : y ∈ interior s) {a b : π•œ} (ha : 0 ≀ a) (hb : 0 < b) (hab : a + b = 1) : a β€’ x + b β€’ y ∈ interior s := hs.combo_closure_interior_subset_interior ha hb hab <| add_mem_add (smul_mem_smul_set hx) (smul_mem_smul_set hy) #align convex.combo_closure_interior_mem_interior Convex.combo_closure_interior_mem_interior theorem Convex.combo_self_interior_mem_interior {s : Set E} (hs : Convex π•œ s) {x y : E} (hx : x ∈ s) (hy : y ∈ interior s) {a b : π•œ} (ha : 0 ≀ a) (hb : 0 < b) (hab : a + b = 1) : a β€’ x + b β€’ y ∈ interior s := hs.combo_closure_interior_mem_interior (subset_closure hx) hy ha hb hab #align convex.combo_self_interior_mem_interior Convex.combo_self_interior_mem_interior theorem Convex.openSegment_interior_closure_subset_interior {s : Set E} (hs : Convex π•œ s) {x y : E} (hx : x ∈ interior s) (hy : y ∈ closure s) : openSegment π•œ x y βŠ† interior s := by rintro _ ⟨a, b, ha, hb, hab, rfl⟩ exact hs.combo_interior_closure_mem_interior hx hy ha hb.le hab #align convex.open_segment_interior_closure_subset_interior Convex.openSegment_interior_closure_subset_interior theorem Convex.openSegment_interior_self_subset_interior {s : Set E} (hs : Convex π•œ s) {x y : E} (hx : x ∈ interior s) (hy : y ∈ s) : openSegment π•œ x y βŠ† interior s := hs.openSegment_interior_closure_subset_interior hx (subset_closure hy) #align convex.open_segment_interior_self_subset_interior Convex.openSegment_interior_self_subset_interior theorem Convex.openSegment_closure_interior_subset_interior {s : Set E} (hs : Convex π•œ s) {x y : E} (hx : x ∈ closure s) (hy : y ∈ interior s) : openSegment π•œ x y βŠ† interior s := by rintro _ ⟨a, b, ha, hb, hab, rfl⟩ exact hs.combo_closure_interior_mem_interior hx hy ha.le hb hab #align convex.open_segment_closure_interior_subset_interior Convex.openSegment_closure_interior_subset_interior theorem Convex.openSegment_self_interior_subset_interior {s : Set E} (hs : Convex π•œ s) {x y : E} (hx : x ∈ s) (hy : y ∈ interior s) : openSegment π•œ x y βŠ† interior s := hs.openSegment_closure_interior_subset_interior (subset_closure hx) hy #align convex.open_segment_self_interior_subset_interior Convex.openSegment_self_interior_subset_interior
Mathlib/Analysis/Convex/Topology.lean
213
218
theorem Convex.add_smul_sub_mem_interior' {s : Set E} (hs : Convex π•œ s) {x y : E} (hx : x ∈ closure s) (hy : y ∈ interior s) {t : π•œ} (ht : t ∈ Ioc (0 : π•œ) 1) : x + t β€’ (y - x) ∈ interior s := by
simpa only [sub_smul, smul_sub, one_smul, add_sub, add_comm] using hs.combo_interior_closure_mem_interior hy hx ht.1 (sub_nonneg.mpr ht.2) (add_sub_cancel _ _)
import Mathlib.Algebra.Divisibility.Basic import Mathlib.Algebra.Group.Int import Mathlib.Algebra.Group.Nat import Mathlib.Algebra.Group.Opposite import Mathlib.Algebra.Group.Units import Mathlib.Data.List.Perm import Mathlib.Data.List.ProdSigma import Mathlib.Data.List.Range import Mathlib.Data.List.Rotate #align_import data.list.big_operators.basic from "leanprover-community/mathlib"@"6c5f73fd6f6cc83122788a80a27cdd54663609f4" -- Make sure we haven't imported `Data.Nat.Order.Basic` assert_not_exists OrderedSub assert_not_exists Ring variable {ΞΉ Ξ± Ξ² M N P G : Type*} namespace List section Monoid variable [Monoid M] [Monoid N] [Monoid P] {l l₁ lβ‚‚ : List M} {a : M} @[to_additive (attr := simp)] theorem prod_cons : (a :: l).prod = a * l.prod := calc (a :: l).prod = foldl (Β· * Β·) (a * 1) l := by simp only [List.prod, foldl_cons, one_mul, mul_one] _ = _ := foldl_assoc #align list.prod_cons List.prod_cons #align list.sum_cons List.sum_cons @[to_additive] lemma prod_induction (p : M β†’ Prop) (hom : βˆ€ a b, p a β†’ p b β†’ p (a * b)) (unit : p 1) (base : βˆ€ x ∈ l, p x) : p l.prod := by induction' l with a l ih Β· simpa rw [List.prod_cons] simp only [Bool.not_eq_true, List.mem_cons, forall_eq_or_imp] at base exact hom _ _ (base.1) (ih base.2) @[to_additive (attr := simp)] theorem prod_append : (l₁ ++ lβ‚‚).prod = l₁.prod * lβ‚‚.prod := calc (l₁ ++ lβ‚‚).prod = foldl (Β· * Β·) (foldl (Β· * Β·) 1 l₁ * 1) lβ‚‚ := by simp [List.prod] _ = l₁.prod * lβ‚‚.prod := foldl_assoc #align list.prod_append List.prod_append #align list.sum_append List.sum_append @[to_additive] theorem prod_concat : (l.concat a).prod = l.prod * a := by rw [concat_eq_append, prod_append, prod_singleton] #align list.prod_concat List.prod_concat #align list.sum_concat List.sum_concat @[to_additive (attr := simp)] theorem prod_join {l : List (List M)} : l.join.prod = (l.map List.prod).prod := by induction l <;> [rfl; simp only [*, List.join, map, prod_append, prod_cons]] #align list.prod_join List.prod_join #align list.sum_join List.sum_join @[to_additive] theorem prod_eq_foldr : βˆ€ {l : List M}, l.prod = foldr (Β· * Β·) 1 l | [] => rfl | cons a l => by rw [prod_cons, foldr_cons, prod_eq_foldr] #align list.prod_eq_foldr List.prod_eq_foldr #align list.sum_eq_foldr List.sum_eq_foldr @[to_additive (attr := simp)] theorem prod_replicate (n : β„•) (a : M) : (replicate n a).prod = a ^ n := by induction' n with n ih Β· rw [pow_zero] rfl Β· rw [replicate_succ, prod_cons, ih, pow_succ'] #align list.prod_replicate List.prod_replicate #align list.sum_replicate List.sum_replicate @[to_additive sum_eq_card_nsmul] theorem prod_eq_pow_card (l : List M) (m : M) (h : βˆ€ x ∈ l, x = m) : l.prod = m ^ l.length := by rw [← prod_replicate, ← List.eq_replicate.mpr ⟨rfl, h⟩] #align list.prod_eq_pow_card List.prod_eq_pow_card #align list.sum_eq_card_nsmul List.sum_eq_card_nsmul @[to_additive] theorem prod_hom_rel (l : List ΞΉ) {r : M β†’ N β†’ Prop} {f : ΞΉ β†’ M} {g : ΞΉ β†’ N} (h₁ : r 1 1) (hβ‚‚ : βˆ€ ⦃i a b⦄, r a b β†’ r (f i * a) (g i * b)) : r (l.map f).prod (l.map g).prod := List.recOn l h₁ fun a l hl => by simp only [map_cons, prod_cons, hβ‚‚ hl] #align list.prod_hom_rel List.prod_hom_rel #align list.sum_hom_rel List.sum_hom_rel @[to_additive] theorem rel_prod {R : M β†’ N β†’ Prop} (h : R 1 1) (hf : (R β‡’ R β‡’ R) (Β· * Β·) (Β· * Β·)) : (Forallβ‚‚ R β‡’ R) prod prod := rel_foldl hf h #align list.rel_prod List.rel_prod #align list.rel_sum List.rel_sum @[to_additive] theorem prod_hom (l : List M) {F : Type*} [FunLike F M N] [MonoidHomClass F M N] (f : F) : (l.map f).prod = f l.prod := by simp only [prod, foldl_map, ← map_one f] exact l.foldl_hom f (Β· * Β·) (Β· * f Β·) 1 (fun x y => (map_mul f x y).symm) #align list.prod_hom List.prod_hom #align list.sum_hom List.sum_hom @[to_additive] theorem prod_homβ‚‚ (l : List ΞΉ) (f : M β†’ N β†’ P) (hf : βˆ€ a b c d, f (a * b) (c * d) = f a c * f b d) (hf' : f 1 1 = 1) (f₁ : ΞΉ β†’ M) (fβ‚‚ : ΞΉ β†’ N) : (l.map fun i => f (f₁ i) (fβ‚‚ i)).prod = f (l.map f₁).prod (l.map fβ‚‚).prod := by simp only [prod, foldl_map] -- Porting note: next 3 lines used to be -- convert l.foldl_homβ‚‚ (fun a b => f a b) _ _ _ _ _ fun a b i => _ -- Β· exact hf'.symm -- Β· exact hf _ _ _ _ rw [← l.foldl_homβ‚‚ (fun a b => f a b), hf'] intros exact hf _ _ _ _ #align list.prod_homβ‚‚ List.prod_homβ‚‚ #align list.sum_homβ‚‚ List.sum_homβ‚‚ @[to_additive (attr := simp)] theorem prod_map_mul {Ξ± : Type*} [CommMonoid Ξ±] {l : List ΞΉ} {f g : ΞΉ β†’ Ξ±} : (l.map fun i => f i * g i).prod = (l.map f).prod * (l.map g).prod := l.prod_homβ‚‚ (Β· * Β·) mul_mul_mul_comm (mul_one _) _ _ #align list.prod_map_mul List.prod_map_mul #align list.sum_map_add List.sum_map_add @[to_additive] theorem prod_map_hom (L : List ΞΉ) (f : ΞΉ β†’ M) {G : Type*} [FunLike G M N] [MonoidHomClass G M N] (g : G) : (L.map (g ∘ f)).prod = g (L.map f).prod := by rw [← prod_hom, map_map] #align list.prod_map_hom List.prod_map_hom #align list.sum_map_hom List.sum_map_hom @[to_additive] theorem prod_isUnit : βˆ€ {L : List M}, (βˆ€ m ∈ L, IsUnit m) β†’ IsUnit L.prod | [], _ => by simp | h :: t, u => by simp only [List.prod_cons] exact IsUnit.mul (u h (mem_cons_self h t)) (prod_isUnit fun m mt => u m (mem_cons_of_mem h mt)) #align list.prod_is_unit List.prod_isUnit #align list.sum_is_add_unit List.sum_isAddUnit @[to_additive] theorem prod_isUnit_iff {Ξ± : Type*} [CommMonoid Ξ±] {L : List Ξ±} : IsUnit L.prod ↔ βˆ€ m ∈ L, IsUnit m := by refine ⟨fun h => ?_, prod_isUnit⟩ induction' L with m L ih Β· exact fun m' h' => False.elim (not_mem_nil m' h') rw [prod_cons, IsUnit.mul_iff] at h exact fun m' h' => Or.elim (eq_or_mem_of_mem_cons h') (fun H => H.substr h.1) fun H => ih h.2 _ H #align list.prod_is_unit_iff List.prod_isUnit_iff #align list.sum_is_add_unit_iff List.sum_isAddUnit_iff @[to_additive (attr := simp)] theorem prod_take_mul_prod_drop : βˆ€ (L : List M) (i : β„•), (L.take i).prod * (L.drop i).prod = L.prod | [], i => by simp [Nat.zero_le] | L, 0 => by simp | h :: t, n + 1 => by dsimp rw [prod_cons, prod_cons, mul_assoc, prod_take_mul_prod_drop t] #align list.prod_take_mul_prod_drop List.prod_take_mul_prod_drop #align list.sum_take_add_sum_drop List.sum_take_add_sum_drop @[to_additive (attr := simp)] theorem prod_take_succ : βˆ€ (L : List M) (i : β„•) (p), (L.take (i + 1)).prod = (L.take i).prod * L.get ⟨i, p⟩ | [], i, p => by cases p | h :: t, 0, _ => rfl | h :: t, n + 1, p => by dsimp rw [prod_cons, prod_cons, prod_take_succ t n (Nat.lt_of_succ_lt_succ p), mul_assoc] #align list.prod_take_succ List.prod_take_succ #align list.sum_take_succ List.sum_take_succ @[to_additive "A list with sum not zero must have positive length."] theorem length_pos_of_prod_ne_one (L : List M) (h : L.prod β‰  1) : 0 < L.length := by cases L Β· simp at h Β· simp #align list.length_pos_of_prod_ne_one List.length_pos_of_prod_ne_one #align list.length_pos_of_sum_ne_zero List.length_pos_of_sum_ne_zero @[to_additive length_pos_of_sum_pos "A list with positive sum must have positive length."] theorem length_pos_of_one_lt_prod [Preorder M] (L : List M) (h : 1 < L.prod) : 0 < L.length := length_pos_of_prod_ne_one L h.ne' #align list.length_pos_of_one_lt_prod List.length_pos_of_one_lt_prod #align list.length_pos_of_sum_pos List.length_pos_of_sum_pos @[to_additive "A list with negative sum must have positive length."] theorem length_pos_of_prod_lt_one [Preorder M] (L : List M) (h : L.prod < 1) : 0 < L.length := length_pos_of_prod_ne_one L h.ne #align list.length_pos_of_prod_lt_one List.length_pos_of_prod_lt_one #align list.length_pos_of_sum_neg List.length_pos_of_sum_neg @[to_additive] theorem prod_set : βˆ€ (L : List M) (n : β„•) (a : M), (L.set n a).prod = ((L.take n).prod * if n < L.length then a else 1) * (L.drop (n + 1)).prod | x :: xs, 0, a => by simp [set] | x :: xs, i + 1, a => by simp [set, prod_set xs i a, mul_assoc, Nat.succ_eq_add_one, Nat.add_lt_add_iff_right] | [], _, _ => by simp [set, (Nat.zero_le _).not_lt, Nat.zero_le] #align list.prod_update_nth List.prod_set #align list.sum_update_nth List.sum_set @[to_additive "We'd like to state this as `L.headI + L.tail.sum = L.sum`, but because `L.headI` relies on an inhabited instance to return a garbage value on the empty list, this is not possible. Instead, we write the statement in terms of `(L.get? 0).getD 0`."]
Mathlib/Algebra/BigOperators/Group/List.lean
289
290
theorem get?_zero_mul_tail_prod (l : List M) : (l.get? 0).getD 1 * l.tail.prod = l.prod := by
cases l <;> simp
import Mathlib.Topology.Compactness.SigmaCompact import Mathlib.Topology.Connected.TotallyDisconnected import Mathlib.Topology.Inseparable #align_import topology.separation from "leanprover-community/mathlib"@"d91e7f7a7f1c7e9f0e18fdb6bde4f652004c735d" open Function Set Filter Topology TopologicalSpace open scoped Classical universe u v variable {X : Type*} {Y : Type*} [TopologicalSpace X] section Separation def SeparatedNhds : Set X β†’ Set X β†’ Prop := fun s t : Set X => βˆƒ U V : Set X, IsOpen U ∧ IsOpen V ∧ s βŠ† U ∧ t βŠ† V ∧ Disjoint U V #align separated_nhds SeparatedNhds theorem separatedNhds_iff_disjoint {s t : Set X} : SeparatedNhds s t ↔ Disjoint (𝓝˒ s) (𝓝˒ t) := by simp only [(hasBasis_nhdsSet s).disjoint_iff (hasBasis_nhdsSet t), SeparatedNhds, exists_prop, ← exists_and_left, and_assoc, and_comm, and_left_comm] #align separated_nhds_iff_disjoint separatedNhds_iff_disjoint alias ⟨SeparatedNhds.disjoint_nhdsSet, _⟩ := separatedNhds_iff_disjoint class T0Space (X : Type u) [TopologicalSpace X] : Prop where t0 : βˆ€ ⦃x y : X⦄, Inseparable x y β†’ x = y #align t0_space T0Space theorem t0Space_iff_inseparable (X : Type u) [TopologicalSpace X] : T0Space X ↔ βˆ€ x y : X, Inseparable x y β†’ x = y := ⟨fun ⟨h⟩ => h, fun h => ⟨h⟩⟩ #align t0_space_iff_inseparable t0Space_iff_inseparable theorem t0Space_iff_not_inseparable (X : Type u) [TopologicalSpace X] : T0Space X ↔ Pairwise fun x y : X => Β¬Inseparable x y := by simp only [t0Space_iff_inseparable, Ne, not_imp_not, Pairwise] #align t0_space_iff_not_inseparable t0Space_iff_not_inseparable theorem Inseparable.eq [T0Space X] {x y : X} (h : Inseparable x y) : x = y := T0Space.t0 h #align inseparable.eq Inseparable.eq protected theorem Inducing.injective [TopologicalSpace Y] [T0Space X] {f : X β†’ Y} (hf : Inducing f) : Injective f := fun _ _ h => (hf.inseparable_iff.1 <| .of_eq h).eq #align inducing.injective Inducing.injective protected theorem Inducing.embedding [TopologicalSpace Y] [T0Space X] {f : X β†’ Y} (hf : Inducing f) : Embedding f := ⟨hf, hf.injective⟩ #align inducing.embedding Inducing.embedding lemma embedding_iff_inducing [TopologicalSpace Y] [T0Space X] {f : X β†’ Y} : Embedding f ↔ Inducing f := ⟨Embedding.toInducing, Inducing.embedding⟩ #align embedding_iff_inducing embedding_iff_inducing theorem t0Space_iff_nhds_injective (X : Type u) [TopologicalSpace X] : T0Space X ↔ Injective (𝓝 : X β†’ Filter X) := t0Space_iff_inseparable X #align t0_space_iff_nhds_injective t0Space_iff_nhds_injective theorem nhds_injective [T0Space X] : Injective (𝓝 : X β†’ Filter X) := (t0Space_iff_nhds_injective X).1 β€Ή_β€Ί #align nhds_injective nhds_injective theorem inseparable_iff_eq [T0Space X] {x y : X} : Inseparable x y ↔ x = y := nhds_injective.eq_iff #align inseparable_iff_eq inseparable_iff_eq @[simp] theorem nhds_eq_nhds_iff [T0Space X] {a b : X} : 𝓝 a = 𝓝 b ↔ a = b := nhds_injective.eq_iff #align nhds_eq_nhds_iff nhds_eq_nhds_iff @[simp] theorem inseparable_eq_eq [T0Space X] : Inseparable = @Eq X := funextβ‚‚ fun _ _ => propext inseparable_iff_eq #align inseparable_eq_eq inseparable_eq_eq theorem TopologicalSpace.IsTopologicalBasis.inseparable_iff {b : Set (Set X)} (hb : IsTopologicalBasis b) {x y : X} : Inseparable x y ↔ βˆ€ s ∈ b, (x ∈ s ↔ y ∈ s) := ⟨fun h s hs ↦ inseparable_iff_forall_open.1 h _ (hb.isOpen hs), fun h ↦ hb.nhds_hasBasis.eq_of_same_basis <| by convert hb.nhds_hasBasis using 2 exact and_congr_right (h _)⟩ theorem TopologicalSpace.IsTopologicalBasis.eq_iff [T0Space X] {b : Set (Set X)} (hb : IsTopologicalBasis b) {x y : X} : x = y ↔ βˆ€ s ∈ b, (x ∈ s ↔ y ∈ s) := inseparable_iff_eq.symm.trans hb.inseparable_iff theorem t0Space_iff_exists_isOpen_xor'_mem (X : Type u) [TopologicalSpace X] : T0Space X ↔ Pairwise fun x y => βˆƒ U : Set X, IsOpen U ∧ Xor' (x ∈ U) (y ∈ U) := by simp only [t0Space_iff_not_inseparable, xor_iff_not_iff, not_forall, exists_prop, inseparable_iff_forall_open, Pairwise] #align t0_space_iff_exists_is_open_xor_mem t0Space_iff_exists_isOpen_xor'_mem theorem exists_isOpen_xor'_mem [T0Space X] {x y : X} (h : x β‰  y) : βˆƒ U : Set X, IsOpen U ∧ Xor' (x ∈ U) (y ∈ U) := (t0Space_iff_exists_isOpen_xor'_mem X).1 β€Ή_β€Ί h #align exists_is_open_xor_mem exists_isOpen_xor'_mem def specializationOrder (X) [TopologicalSpace X] [T0Space X] : PartialOrder X := { specializationPreorder X, PartialOrder.lift (OrderDual.toDual ∘ 𝓝) nhds_injective with } #align specialization_order specializationOrder instance SeparationQuotient.instT0Space : T0Space (SeparationQuotient X) := ⟨fun x y => Quotient.inductionOnβ‚‚' x y fun _ _ h => SeparationQuotient.mk_eq_mk.2 <| SeparationQuotient.inducing_mk.inseparable_iff.1 h⟩ theorem minimal_nonempty_closed_subsingleton [T0Space X] {s : Set X} (hs : IsClosed s) (hmin : βˆ€ t, t βŠ† s β†’ t.Nonempty β†’ IsClosed t β†’ t = s) : s.Subsingleton := by clear Y -- Porting note: added refine fun x hx y hy => of_not_not fun hxy => ?_ rcases exists_isOpen_xor'_mem hxy with ⟨U, hUo, hU⟩ wlog h : x ∈ U ∧ y βˆ‰ U Β· refine this hs hmin y hy x hx (Ne.symm hxy) U hUo hU.symm (hU.resolve_left h) cases' h with hxU hyU have : s \ U = s := hmin (s \ U) diff_subset ⟨y, hy, hyU⟩ (hs.sdiff hUo) exact (this.symm.subset hx).2 hxU #align minimal_nonempty_closed_subsingleton minimal_nonempty_closed_subsingleton theorem minimal_nonempty_closed_eq_singleton [T0Space X] {s : Set X} (hs : IsClosed s) (hne : s.Nonempty) (hmin : βˆ€ t, t βŠ† s β†’ t.Nonempty β†’ IsClosed t β†’ t = s) : βˆƒ x, s = {x} := exists_eq_singleton_iff_nonempty_subsingleton.2 ⟨hne, minimal_nonempty_closed_subsingleton hs hmin⟩ #align minimal_nonempty_closed_eq_singleton minimal_nonempty_closed_eq_singleton theorem IsClosed.exists_closed_singleton [T0Space X] [CompactSpace X] {S : Set X} (hS : IsClosed S) (hne : S.Nonempty) : βˆƒ x : X, x ∈ S ∧ IsClosed ({x} : Set X) := by obtain ⟨V, Vsub, Vne, Vcls, hV⟩ := hS.exists_minimal_nonempty_closed_subset hne rcases minimal_nonempty_closed_eq_singleton Vcls Vne hV with ⟨x, rfl⟩ exact ⟨x, Vsub (mem_singleton x), Vcls⟩ #align is_closed.exists_closed_singleton IsClosed.exists_closed_singleton theorem minimal_nonempty_open_subsingleton [T0Space X] {s : Set X} (hs : IsOpen s) (hmin : βˆ€ t, t βŠ† s β†’ t.Nonempty β†’ IsOpen t β†’ t = s) : s.Subsingleton := by clear Y -- Porting note: added refine fun x hx y hy => of_not_not fun hxy => ?_ rcases exists_isOpen_xor'_mem hxy with ⟨U, hUo, hU⟩ wlog h : x ∈ U ∧ y βˆ‰ U Β· exact this hs hmin y hy x hx (Ne.symm hxy) U hUo hU.symm (hU.resolve_left h) cases' h with hxU hyU have : s ∩ U = s := hmin (s ∩ U) inter_subset_left ⟨x, hx, hxU⟩ (hs.inter hUo) exact hyU (this.symm.subset hy).2 #align minimal_nonempty_open_subsingleton minimal_nonempty_open_subsingleton theorem minimal_nonempty_open_eq_singleton [T0Space X] {s : Set X} (hs : IsOpen s) (hne : s.Nonempty) (hmin : βˆ€ t, t βŠ† s β†’ t.Nonempty β†’ IsOpen t β†’ t = s) : βˆƒ x, s = {x} := exists_eq_singleton_iff_nonempty_subsingleton.2 ⟨hne, minimal_nonempty_open_subsingleton hs hmin⟩ #align minimal_nonempty_open_eq_singleton minimal_nonempty_open_eq_singleton theorem exists_isOpen_singleton_of_isOpen_finite [T0Space X] {s : Set X} (hfin : s.Finite) (hne : s.Nonempty) (ho : IsOpen s) : βˆƒ x ∈ s, IsOpen ({x} : Set X) := by lift s to Finset X using hfin induction' s using Finset.strongInductionOn with s ihs rcases em (βˆƒ t, t βŠ‚ s ∧ t.Nonempty ∧ IsOpen (t : Set X)) with (⟨t, hts, htne, hto⟩ | ht) Β· rcases ihs t hts htne hto with ⟨x, hxt, hxo⟩ exact ⟨x, hts.1 hxt, hxo⟩ Β· -- Porting note: was `rcases minimal_nonempty_open_eq_singleton ho hne _ with ⟨x, hx⟩` -- https://github.com/leanprover/std4/issues/116 rsuffices ⟨x, hx⟩ : βˆƒ x, s.toSet = {x} Β· exact ⟨x, hx.symm β–Έ rfl, hx β–Έ ho⟩ refine minimal_nonempty_open_eq_singleton ho hne ?_ refine fun t hts htne hto => of_not_not fun hts' => ht ?_ lift t to Finset X using s.finite_toSet.subset hts exact ⟨t, ssubset_iff_subset_ne.2 ⟨hts, mt Finset.coe_inj.2 hts'⟩, htne, hto⟩ #align exists_open_singleton_of_open_finite exists_isOpen_singleton_of_isOpen_finite theorem exists_open_singleton_of_finite [T0Space X] [Finite X] [Nonempty X] : βˆƒ x : X, IsOpen ({x} : Set X) := let ⟨x, _, h⟩ := exists_isOpen_singleton_of_isOpen_finite (Set.toFinite _) univ_nonempty isOpen_univ ⟨x, h⟩ #align exists_open_singleton_of_fintype exists_open_singleton_of_finite theorem t0Space_of_injective_of_continuous [TopologicalSpace Y] {f : X β†’ Y} (hf : Function.Injective f) (hf' : Continuous f) [T0Space Y] : T0Space X := ⟨fun _ _ h => hf <| (h.map hf').eq⟩ #align t0_space_of_injective_of_continuous t0Space_of_injective_of_continuous protected theorem Embedding.t0Space [TopologicalSpace Y] [T0Space Y] {f : X β†’ Y} (hf : Embedding f) : T0Space X := t0Space_of_injective_of_continuous hf.inj hf.continuous #align embedding.t0_space Embedding.t0Space instance Subtype.t0Space [T0Space X] {p : X β†’ Prop} : T0Space (Subtype p) := embedding_subtype_val.t0Space #align subtype.t0_space Subtype.t0Space theorem t0Space_iff_or_not_mem_closure (X : Type u) [TopologicalSpace X] : T0Space X ↔ Pairwise fun a b : X => a βˆ‰ closure ({b} : Set X) ∨ b βˆ‰ closure ({a} : Set X) := by simp only [t0Space_iff_not_inseparable, inseparable_iff_mem_closure, not_and_or] #align t0_space_iff_or_not_mem_closure t0Space_iff_or_not_mem_closure instance Prod.instT0Space [TopologicalSpace Y] [T0Space X] [T0Space Y] : T0Space (X Γ— Y) := ⟨fun _ _ h => Prod.ext (h.map continuous_fst).eq (h.map continuous_snd).eq⟩ instance Pi.instT0Space {ΞΉ : Type*} {X : ΞΉ β†’ Type*} [βˆ€ i, TopologicalSpace (X i)] [βˆ€ i, T0Space (X i)] : T0Space (βˆ€ i, X i) := ⟨fun _ _ h => funext fun i => (h.map (continuous_apply i)).eq⟩ #align pi.t0_space Pi.instT0Space instance ULift.instT0Space [T0Space X] : T0Space (ULift X) := embedding_uLift_down.t0Space theorem T0Space.of_cover (h : βˆ€ x y, Inseparable x y β†’ βˆƒ s : Set X, x ∈ s ∧ y ∈ s ∧ T0Space s) : T0Space X := by refine ⟨fun x y hxy => ?_⟩ rcases h x y hxy with ⟨s, hxs, hys, hs⟩ lift x to s using hxs; lift y to s using hys rw [← subtype_inseparable_iff] at hxy exact congr_arg Subtype.val hxy.eq #align t0_space.of_cover T0Space.of_cover theorem T0Space.of_open_cover (h : βˆ€ x, βˆƒ s : Set X, x ∈ s ∧ IsOpen s ∧ T0Space s) : T0Space X := T0Space.of_cover fun x _ hxy => let ⟨s, hxs, hso, hs⟩ := h x ⟨s, hxs, (hxy.mem_open_iff hso).1 hxs, hs⟩ #align t0_space.of_open_cover T0Space.of_open_cover @[mk_iff] class R0Space (X : Type u) [TopologicalSpace X] : Prop where specializes_symmetric : Symmetric (Specializes : X β†’ X β†’ Prop) export R0Space (specializes_symmetric) class T1Space (X : Type u) [TopologicalSpace X] : Prop where t1 : βˆ€ x, IsClosed ({x} : Set X) #align t1_space T1Space theorem isClosed_singleton [T1Space X] {x : X} : IsClosed ({x} : Set X) := T1Space.t1 x #align is_closed_singleton isClosed_singleton theorem isOpen_compl_singleton [T1Space X] {x : X} : IsOpen ({x}ᢜ : Set X) := isClosed_singleton.isOpen_compl #align is_open_compl_singleton isOpen_compl_singleton theorem isOpen_ne [T1Space X] {x : X} : IsOpen { y | y β‰  x } := isOpen_compl_singleton #align is_open_ne isOpen_ne @[to_additive] theorem Continuous.isOpen_mulSupport [T1Space X] [One X] [TopologicalSpace Y] {f : Y β†’ X} (hf : Continuous f) : IsOpen (mulSupport f) := isOpen_ne.preimage hf #align continuous.is_open_mul_support Continuous.isOpen_mulSupport #align continuous.is_open_support Continuous.isOpen_support theorem Ne.nhdsWithin_compl_singleton [T1Space X] {x y : X} (h : x β‰  y) : 𝓝[{y}ᢜ] x = 𝓝 x := isOpen_ne.nhdsWithin_eq h #align ne.nhds_within_compl_singleton Ne.nhdsWithin_compl_singleton theorem Ne.nhdsWithin_diff_singleton [T1Space X] {x y : X} (h : x β‰  y) (s : Set X) : 𝓝[s \ {y}] x = 𝓝[s] x := by rw [diff_eq, inter_comm, nhdsWithin_inter_of_mem] exact mem_nhdsWithin_of_mem_nhds (isOpen_ne.mem_nhds h) #align ne.nhds_within_diff_singleton Ne.nhdsWithin_diff_singleton lemma nhdsWithin_compl_singleton_le [T1Space X] (x y : X) : 𝓝[{x}ᢜ] x ≀ 𝓝[{y}ᢜ] x := by rcases eq_or_ne x y with rfl|hy Β· exact Eq.le rfl Β· rw [Ne.nhdsWithin_compl_singleton hy] exact nhdsWithin_le_nhds theorem isOpen_setOf_eventually_nhdsWithin [T1Space X] {p : X β†’ Prop} : IsOpen { x | βˆ€αΆ  y in 𝓝[β‰ ] x, p y } := by refine isOpen_iff_mem_nhds.mpr fun a ha => ?_ filter_upwards [eventually_nhds_nhdsWithin.mpr ha] with b hb rcases eq_or_ne a b with rfl | h Β· exact hb Β· rw [h.symm.nhdsWithin_compl_singleton] at hb exact hb.filter_mono nhdsWithin_le_nhds #align is_open_set_of_eventually_nhds_within isOpen_setOf_eventually_nhdsWithin protected theorem Set.Finite.isClosed [T1Space X] {s : Set X} (hs : Set.Finite s) : IsClosed s := by rw [← biUnion_of_singleton s] exact hs.isClosed_biUnion fun i _ => isClosed_singleton #align set.finite.is_closed Set.Finite.isClosed theorem TopologicalSpace.IsTopologicalBasis.exists_mem_of_ne [T1Space X] {b : Set (Set X)} (hb : IsTopologicalBasis b) {x y : X} (h : x β‰  y) : βˆƒ a ∈ b, x ∈ a ∧ y βˆ‰ a := by rcases hb.isOpen_iff.1 isOpen_ne x h with ⟨a, ab, xa, ha⟩ exact ⟨a, ab, xa, fun h => ha h rfl⟩ #align topological_space.is_topological_basis.exists_mem_of_ne TopologicalSpace.IsTopologicalBasis.exists_mem_of_ne protected theorem Finset.isClosed [T1Space X] (s : Finset X) : IsClosed (s : Set X) := s.finite_toSet.isClosed #align finset.is_closed Finset.isClosed theorem t1Space_TFAE (X : Type u) [TopologicalSpace X] : List.TFAE [T1Space X, βˆ€ x, IsClosed ({ x } : Set X), βˆ€ x, IsOpen ({ x }ᢜ : Set X), Continuous (@CofiniteTopology.of X), βˆ€ ⦃x y : X⦄, x β‰  y β†’ {y}ᢜ ∈ 𝓝 x, βˆ€ ⦃x y : X⦄, x β‰  y β†’ βˆƒ s ∈ 𝓝 x, y βˆ‰ s, βˆ€ ⦃x y : X⦄, x β‰  y β†’ βˆƒ U : Set X, IsOpen U ∧ x ∈ U ∧ y βˆ‰ U, βˆ€ ⦃x y : X⦄, x β‰  y β†’ Disjoint (𝓝 x) (pure y), βˆ€ ⦃x y : X⦄, x β‰  y β†’ Disjoint (pure x) (𝓝 y), βˆ€ ⦃x y : X⦄, x β€³ y β†’ x = y] := by tfae_have 1 ↔ 2 Β· exact ⟨fun h => h.1, fun h => ⟨h⟩⟩ tfae_have 2 ↔ 3 Β· simp only [isOpen_compl_iff] tfae_have 5 ↔ 3 Β· refine forall_swap.trans ?_ simp only [isOpen_iff_mem_nhds, mem_compl_iff, mem_singleton_iff] tfae_have 5 ↔ 6 Β· simp only [← subset_compl_singleton_iff, exists_mem_subset_iff] tfae_have 5 ↔ 7 Β· simp only [(nhds_basis_opens _).mem_iff, subset_compl_singleton_iff, exists_prop, and_assoc, and_left_comm] tfae_have 5 ↔ 8 Β· simp only [← principal_singleton, disjoint_principal_right] tfae_have 8 ↔ 9 Β· exact forall_swap.trans (by simp only [disjoint_comm, ne_comm]) tfae_have 1 β†’ 4 Β· simp only [continuous_def, CofiniteTopology.isOpen_iff'] rintro H s (rfl | hs) exacts [isOpen_empty, compl_compl s β–Έ (@Set.Finite.isClosed _ _ H _ hs).isOpen_compl] tfae_have 4 β†’ 2 Β· exact fun h x => (CofiniteTopology.isClosed_iff.2 <| Or.inr (finite_singleton _)).preimage h tfae_have 2 ↔ 10 Β· simp only [← closure_subset_iff_isClosed, specializes_iff_mem_closure, subset_def, mem_singleton_iff, eq_comm] tfae_finish #align t1_space_tfae t1Space_TFAE theorem t1Space_iff_continuous_cofinite_of : T1Space X ↔ Continuous (@CofiniteTopology.of X) := (t1Space_TFAE X).out 0 3 #align t1_space_iff_continuous_cofinite_of t1Space_iff_continuous_cofinite_of theorem CofiniteTopology.continuous_of [T1Space X] : Continuous (@CofiniteTopology.of X) := t1Space_iff_continuous_cofinite_of.mp β€Ή_β€Ί #align cofinite_topology.continuous_of CofiniteTopology.continuous_of theorem t1Space_iff_exists_open : T1Space X ↔ Pairwise fun x y => βˆƒ U : Set X, IsOpen U ∧ x ∈ U ∧ y βˆ‰ U := (t1Space_TFAE X).out 0 6 #align t1_space_iff_exists_open t1Space_iff_exists_open theorem t1Space_iff_disjoint_pure_nhds : T1Space X ↔ βˆ€ ⦃x y : X⦄, x β‰  y β†’ Disjoint (pure x) (𝓝 y) := (t1Space_TFAE X).out 0 8 #align t1_space_iff_disjoint_pure_nhds t1Space_iff_disjoint_pure_nhds theorem t1Space_iff_disjoint_nhds_pure : T1Space X ↔ βˆ€ ⦃x y : X⦄, x β‰  y β†’ Disjoint (𝓝 x) (pure y) := (t1Space_TFAE X).out 0 7 #align t1_space_iff_disjoint_nhds_pure t1Space_iff_disjoint_nhds_pure theorem t1Space_iff_specializes_imp_eq : T1Space X ↔ βˆ€ ⦃x y : X⦄, x β€³ y β†’ x = y := (t1Space_TFAE X).out 0 9 #align t1_space_iff_specializes_imp_eq t1Space_iff_specializes_imp_eq theorem disjoint_pure_nhds [T1Space X] {x y : X} (h : x β‰  y) : Disjoint (pure x) (𝓝 y) := t1Space_iff_disjoint_pure_nhds.mp β€Ή_β€Ί h #align disjoint_pure_nhds disjoint_pure_nhds theorem disjoint_nhds_pure [T1Space X] {x y : X} (h : x β‰  y) : Disjoint (𝓝 x) (pure y) := t1Space_iff_disjoint_nhds_pure.mp β€Ή_β€Ί h #align disjoint_nhds_pure disjoint_nhds_pure theorem Specializes.eq [T1Space X] {x y : X} (h : x β€³ y) : x = y := t1Space_iff_specializes_imp_eq.1 β€Ή_β€Ί h #align specializes.eq Specializes.eq theorem specializes_iff_eq [T1Space X] {x y : X} : x β€³ y ↔ x = y := ⟨Specializes.eq, fun h => h β–Έ specializes_rfl⟩ #align specializes_iff_eq specializes_iff_eq @[simp] theorem specializes_eq_eq [T1Space X] : (Β· β€³ Β·) = @Eq X := funextβ‚‚ fun _ _ => propext specializes_iff_eq #align specializes_eq_eq specializes_eq_eq @[simp] theorem pure_le_nhds_iff [T1Space X] {a b : X} : pure a ≀ 𝓝 b ↔ a = b := specializes_iff_pure.symm.trans specializes_iff_eq #align pure_le_nhds_iff pure_le_nhds_iff @[simp] theorem nhds_le_nhds_iff [T1Space X] {a b : X} : 𝓝 a ≀ 𝓝 b ↔ a = b := specializes_iff_eq #align nhds_le_nhds_iff nhds_le_nhds_iff instance (priority := 100) [T1Space X] : R0Space X where specializes_symmetric _ _ := by rw [specializes_iff_eq, specializes_iff_eq]; exact Eq.symm instance : T1Space (CofiniteTopology X) := t1Space_iff_continuous_cofinite_of.mpr continuous_id theorem t1Space_antitone : Antitone (@T1Space X) := fun a _ h _ => @T1Space.mk _ a fun x => (T1Space.t1 x).mono h #align t1_space_antitone t1Space_antitone theorem continuousWithinAt_update_of_ne [T1Space X] [DecidableEq X] [TopologicalSpace Y] {f : X β†’ Y} {s : Set X} {x x' : X} {y : Y} (hne : x' β‰  x) : ContinuousWithinAt (Function.update f x y) s x' ↔ ContinuousWithinAt f s x' := EventuallyEq.congr_continuousWithinAt (mem_nhdsWithin_of_mem_nhds <| mem_of_superset (isOpen_ne.mem_nhds hne) fun _y' hy' => Function.update_noteq hy' _ _) (Function.update_noteq hne _ _) #align continuous_within_at_update_of_ne continuousWithinAt_update_of_ne theorem continuousAt_update_of_ne [T1Space X] [DecidableEq X] [TopologicalSpace Y] {f : X β†’ Y} {x x' : X} {y : Y} (hne : x' β‰  x) : ContinuousAt (Function.update f x y) x' ↔ ContinuousAt f x' := by simp only [← continuousWithinAt_univ, continuousWithinAt_update_of_ne hne] #align continuous_at_update_of_ne continuousAt_update_of_ne theorem continuousOn_update_iff [T1Space X] [DecidableEq X] [TopologicalSpace Y] {f : X β†’ Y} {s : Set X} {x : X} {y : Y} : ContinuousOn (Function.update f x y) s ↔ ContinuousOn f (s \ {x}) ∧ (x ∈ s β†’ Tendsto f (𝓝[s \ {x}] x) (𝓝 y)) := by rw [ContinuousOn, ← and_forall_ne x, and_comm] refine and_congr ⟨fun H z hz => ?_, fun H z hzx hzs => ?_⟩ (forall_congr' fun _ => ?_) Β· specialize H z hz.2 hz.1 rw [continuousWithinAt_update_of_ne hz.2] at H exact H.mono diff_subset Β· rw [continuousWithinAt_update_of_ne hzx] refine (H z ⟨hzs, hzx⟩).mono_of_mem (inter_mem_nhdsWithin _ ?_) exact isOpen_ne.mem_nhds hzx Β· exact continuousWithinAt_update_same #align continuous_on_update_iff continuousOn_update_iff theorem t1Space_of_injective_of_continuous [TopologicalSpace Y] {f : X β†’ Y} (hf : Function.Injective f) (hf' : Continuous f) [T1Space Y] : T1Space X := t1Space_iff_specializes_imp_eq.2 fun _ _ h => hf (h.map hf').eq #align t1_space_of_injective_of_continuous t1Space_of_injective_of_continuous protected theorem Embedding.t1Space [TopologicalSpace Y] [T1Space Y] {f : X β†’ Y} (hf : Embedding f) : T1Space X := t1Space_of_injective_of_continuous hf.inj hf.continuous #align embedding.t1_space Embedding.t1Space instance Subtype.t1Space {X : Type u} [TopologicalSpace X] [T1Space X] {p : X β†’ Prop} : T1Space (Subtype p) := embedding_subtype_val.t1Space #align subtype.t1_space Subtype.t1Space instance [TopologicalSpace Y] [T1Space X] [T1Space Y] : T1Space (X Γ— Y) := ⟨fun ⟨a, b⟩ => @singleton_prod_singleton _ _ a b β–Έ isClosed_singleton.prod isClosed_singleton⟩ instance {ΞΉ : Type*} {X : ΞΉ β†’ Type*} [βˆ€ i, TopologicalSpace (X i)] [βˆ€ i, T1Space (X i)] : T1Space (βˆ€ i, X i) := ⟨fun f => univ_pi_singleton f β–Έ isClosed_set_pi fun _ _ => isClosed_singleton⟩ instance ULift.instT1Space [T1Space X] : T1Space (ULift X) := embedding_uLift_down.t1Space -- see Note [lower instance priority] instance (priority := 100) TotallyDisconnectedSpace.t1Space [h: TotallyDisconnectedSpace X] : T1Space X := by rw [((t1Space_TFAE X).out 0 1 :)] intro x rw [← totallyDisconnectedSpace_iff_connectedComponent_singleton.mp h x] exact isClosed_connectedComponent -- see Note [lower instance priority] instance (priority := 100) T1Space.t0Space [T1Space X] : T0Space X := ⟨fun _ _ h => h.specializes.eq⟩ #align t1_space.t0_space T1Space.t0Space @[simp] theorem compl_singleton_mem_nhds_iff [T1Space X] {x y : X} : {x}ᢜ ∈ 𝓝 y ↔ y β‰  x := isOpen_compl_singleton.mem_nhds_iff #align compl_singleton_mem_nhds_iff compl_singleton_mem_nhds_iff theorem compl_singleton_mem_nhds [T1Space X] {x y : X} (h : y β‰  x) : {x}ᢜ ∈ 𝓝 y := compl_singleton_mem_nhds_iff.mpr h #align compl_singleton_mem_nhds compl_singleton_mem_nhds @[simp] theorem closure_singleton [T1Space X] {x : X} : closure ({x} : Set X) = {x} := isClosed_singleton.closure_eq #align closure_singleton closure_singleton -- Porting note (#11215): TODO: the proof was `hs.induction_on (by simp) fun x => by simp` theorem Set.Subsingleton.closure [T1Space X] {s : Set X} (hs : s.Subsingleton) : (closure s).Subsingleton := by rcases hs.eq_empty_or_singleton with (rfl | ⟨x, rfl⟩) <;> simp #align set.subsingleton.closure Set.Subsingleton.closure @[simp] theorem subsingleton_closure [T1Space X] {s : Set X} : (closure s).Subsingleton ↔ s.Subsingleton := ⟨fun h => h.anti subset_closure, fun h => h.closure⟩ #align subsingleton_closure subsingleton_closure theorem isClosedMap_const {X Y} [TopologicalSpace X] [TopologicalSpace Y] [T1Space Y] {y : Y} : IsClosedMap (Function.const X y) := IsClosedMap.of_nonempty fun s _ h2s => by simp_rw [const, h2s.image_const, isClosed_singleton] #align is_closed_map_const isClosedMap_const theorem nhdsWithin_insert_of_ne [T1Space X] {x y : X} {s : Set X} (hxy : x β‰  y) : 𝓝[insert y s] x = 𝓝[s] x := by refine le_antisymm (Filter.le_def.2 fun t ht => ?_) (nhdsWithin_mono x <| subset_insert y s) obtain ⟨o, ho, hxo, host⟩ := mem_nhdsWithin.mp ht refine mem_nhdsWithin.mpr ⟨o \ {y}, ho.sdiff isClosed_singleton, ⟨hxo, hxy⟩, ?_⟩ rw [inter_insert_of_not_mem <| not_mem_diff_of_mem (mem_singleton y)] exact (inter_subset_inter diff_subset Subset.rfl).trans host #align nhds_within_insert_of_ne nhdsWithin_insert_of_ne theorem insert_mem_nhdsWithin_of_subset_insert [T1Space X] {x y : X} {s t : Set X} (hu : t βŠ† insert y s) : insert x s ∈ 𝓝[t] x := by rcases eq_or_ne x y with (rfl | h) Β· exact mem_of_superset self_mem_nhdsWithin hu refine nhdsWithin_mono x hu ?_ rw [nhdsWithin_insert_of_ne h] exact mem_of_superset self_mem_nhdsWithin (subset_insert x s) #align insert_mem_nhds_within_of_subset_insert insert_mem_nhdsWithin_of_subset_insert @[simp] theorem ker_nhds [T1Space X] (x : X) : (𝓝 x).ker = {x} := by simp [ker_nhds_eq_specializes] theorem biInter_basis_nhds [T1Space X] {ΞΉ : Sort*} {p : ΞΉ β†’ Prop} {s : ΞΉ β†’ Set X} {x : X} (h : (𝓝 x).HasBasis p s) : β‹‚ (i) (_ : p i), s i = {x} := by rw [← h.ker, ker_nhds] #align bInter_basis_nhds biInter_basis_nhds @[simp] theorem compl_singleton_mem_nhdsSet_iff [T1Space X] {x : X} {s : Set X} : {x}ᢜ ∈ 𝓝˒ s ↔ x βˆ‰ s := by rw [isOpen_compl_singleton.mem_nhdsSet, subset_compl_singleton_iff] #align compl_singleton_mem_nhds_set_iff compl_singleton_mem_nhdsSet_iff @[simp] theorem nhdsSet_le_iff [T1Space X] {s t : Set X} : 𝓝˒ s ≀ 𝓝˒ t ↔ s βŠ† t := by refine ⟨?_, fun h => monotone_nhdsSet h⟩ simp_rw [Filter.le_def]; intro h x hx specialize h {x}ᢜ simp_rw [compl_singleton_mem_nhdsSet_iff] at h by_contra hxt exact h hxt hx #align nhds_set_le_iff nhdsSet_le_iff @[simp] theorem nhdsSet_inj_iff [T1Space X] {s t : Set X} : 𝓝˒ s = 𝓝˒ t ↔ s = t := by simp_rw [le_antisymm_iff] exact and_congr nhdsSet_le_iff nhdsSet_le_iff #align nhds_set_inj_iff nhdsSet_inj_iff theorem injective_nhdsSet [T1Space X] : Function.Injective (𝓝˒ : Set X β†’ Filter X) := fun _ _ hst => nhdsSet_inj_iff.mp hst #align injective_nhds_set injective_nhdsSet theorem strictMono_nhdsSet [T1Space X] : StrictMono (𝓝˒ : Set X β†’ Filter X) := monotone_nhdsSet.strictMono_of_injective injective_nhdsSet #align strict_mono_nhds_set strictMono_nhdsSet @[simp] theorem nhds_le_nhdsSet_iff [T1Space X] {s : Set X} {x : X} : 𝓝 x ≀ 𝓝˒ s ↔ x ∈ s := by rw [← nhdsSet_singleton, nhdsSet_le_iff, singleton_subset_iff] #align nhds_le_nhds_set_iff nhds_le_nhdsSet_iff theorem Dense.diff_singleton [T1Space X] {s : Set X} (hs : Dense s) (x : X) [NeBot (𝓝[β‰ ] x)] : Dense (s \ {x}) := hs.inter_of_isOpen_right (dense_compl_singleton x) isOpen_compl_singleton #align dense.diff_singleton Dense.diff_singleton theorem Dense.diff_finset [T1Space X] [βˆ€ x : X, NeBot (𝓝[β‰ ] x)] {s : Set X} (hs : Dense s) (t : Finset X) : Dense (s \ t) := by induction t using Finset.induction_on with | empty => simpa using hs | insert _ ih => rw [Finset.coe_insert, ← union_singleton, ← diff_diff] exact ih.diff_singleton _ #align dense.diff_finset Dense.diff_finset theorem Dense.diff_finite [T1Space X] [βˆ€ x : X, NeBot (𝓝[β‰ ] x)] {s : Set X} (hs : Dense s) {t : Set X} (ht : t.Finite) : Dense (s \ t) := by convert hs.diff_finset ht.toFinset exact (Finite.coe_toFinset _).symm #align dense.diff_finite Dense.diff_finite theorem eq_of_tendsto_nhds [TopologicalSpace Y] [T1Space Y] {f : X β†’ Y} {x : X} {y : Y} (h : Tendsto f (𝓝 x) (𝓝 y)) : f x = y := by_contra fun hfa : f x β‰  y => have fact₁ : {f x}ᢜ ∈ 𝓝 y := compl_singleton_mem_nhds hfa.symm have factβ‚‚ : Tendsto f (pure x) (𝓝 y) := h.comp (tendsto_id'.2 <| pure_le_nhds x) factβ‚‚ fact₁ (Eq.refl <| f x) #align eq_of_tendsto_nhds eq_of_tendsto_nhds theorem Filter.Tendsto.eventually_ne [TopologicalSpace Y] [T1Space Y] {g : X β†’ Y} {l : Filter X} {b₁ bβ‚‚ : Y} (hg : Tendsto g l (𝓝 b₁)) (hb : b₁ β‰  bβ‚‚) : βˆ€αΆ  z in l, g z β‰  bβ‚‚ := hg.eventually (isOpen_compl_singleton.eventually_mem hb) #align filter.tendsto.eventually_ne Filter.Tendsto.eventually_ne theorem ContinuousAt.eventually_ne [TopologicalSpace Y] [T1Space Y] {g : X β†’ Y} {x : X} {y : Y} (hg1 : ContinuousAt g x) (hg2 : g x β‰  y) : βˆ€αΆ  z in 𝓝 x, g z β‰  y := hg1.tendsto.eventually_ne hg2 #align continuous_at.eventually_ne ContinuousAt.eventually_ne theorem eventually_ne_nhds [T1Space X] {a b : X} (h : a β‰  b) : βˆ€αΆ  x in 𝓝 a, x β‰  b := IsOpen.eventually_mem isOpen_ne h theorem eventually_ne_nhdsWithin [T1Space X] {a b : X} {s : Set X} (h : a β‰  b) : βˆ€αΆ  x in 𝓝[s] a, x β‰  b := Filter.Eventually.filter_mono nhdsWithin_le_nhds <| eventually_ne_nhds h theorem continuousAt_of_tendsto_nhds [TopologicalSpace Y] [T1Space Y] {f : X β†’ Y} {x : X} {y : Y} (h : Tendsto f (𝓝 x) (𝓝 y)) : ContinuousAt f x := by rwa [ContinuousAt, eq_of_tendsto_nhds h] #align continuous_at_of_tendsto_nhds continuousAt_of_tendsto_nhds @[simp] theorem tendsto_const_nhds_iff [T1Space X] {l : Filter Y} [NeBot l] {c d : X} : Tendsto (fun _ => c) l (𝓝 d) ↔ c = d := by simp_rw [Tendsto, Filter.map_const, pure_le_nhds_iff] #align tendsto_const_nhds_iff tendsto_const_nhds_iff theorem isOpen_singleton_of_finite_mem_nhds [T1Space X] (x : X) {s : Set X} (hs : s ∈ 𝓝 x) (hsf : s.Finite) : IsOpen ({x} : Set X) := by have A : {x} βŠ† s := by simp only [singleton_subset_iff, mem_of_mem_nhds hs] have B : IsClosed (s \ {x}) := (hsf.subset diff_subset).isClosed have C : (s \ {x})ᢜ ∈ 𝓝 x := B.isOpen_compl.mem_nhds fun h => h.2 rfl have D : {x} ∈ 𝓝 x := by simpa only [← diff_eq, diff_diff_cancel_left A] using inter_mem hs C rwa [← mem_interior_iff_mem_nhds, ← singleton_subset_iff, subset_interior_iff_isOpen] at D #align is_open_singleton_of_finite_mem_nhds isOpen_singleton_of_finite_mem_nhds theorem infinite_of_mem_nhds {X} [TopologicalSpace X] [T1Space X] (x : X) [hx : NeBot (𝓝[β‰ ] x)] {s : Set X} (hs : s ∈ 𝓝 x) : Set.Infinite s := by refine fun hsf => hx.1 ?_ rw [← isOpen_singleton_iff_punctured_nhds] exact isOpen_singleton_of_finite_mem_nhds x hs hsf #align infinite_of_mem_nhds infinite_of_mem_nhds theorem discrete_of_t1_of_finite [T1Space X] [Finite X] : DiscreteTopology X := by apply singletons_open_iff_discrete.mp intro x rw [← isClosed_compl_iff] exact (Set.toFinite _).isClosed #align discrete_of_t1_of_finite discrete_of_t1_of_finite theorem PreconnectedSpace.trivial_of_discrete [PreconnectedSpace X] [DiscreteTopology X] : Subsingleton X := by rw [← not_nontrivial_iff_subsingleton] rintro ⟨x, y, hxy⟩ rw [Ne, ← mem_singleton_iff, (isClopen_discrete _).eq_univ <| singleton_nonempty y] at hxy exact hxy (mem_univ x) #align preconnected_space.trivial_of_discrete PreconnectedSpace.trivial_of_discrete theorem IsPreconnected.infinite_of_nontrivial [T1Space X] {s : Set X} (h : IsPreconnected s) (hs : s.Nontrivial) : s.Infinite := by refine mt (fun hf => (subsingleton_coe s).mp ?_) (not_subsingleton_iff.mpr hs) haveI := @discrete_of_t1_of_finite s _ _ hf.to_subtype exact @PreconnectedSpace.trivial_of_discrete _ _ (Subtype.preconnectedSpace h) _ #align is_preconnected.infinite_of_nontrivial IsPreconnected.infinite_of_nontrivial theorem ConnectedSpace.infinite [ConnectedSpace X] [Nontrivial X] [T1Space X] : Infinite X := infinite_univ_iff.mp <| isPreconnected_univ.infinite_of_nontrivial nontrivial_univ #align connected_space.infinite ConnectedSpace.infinite instance (priority := 100) ConnectedSpace.neBot_nhdsWithin_compl_of_nontrivial_of_t1space [ConnectedSpace X] [Nontrivial X] [T1Space X] (x : X) : NeBot (𝓝[β‰ ] x) := by by_contra contra rw [not_neBot, ← isOpen_singleton_iff_punctured_nhds] at contra replace contra := nonempty_inter isOpen_compl_singleton contra (compl_union_self _) (Set.nonempty_compl_of_nontrivial _) (singleton_nonempty _) simp [compl_inter_self {x}] at contra theorem SeparationQuotient.t1Space_iff : T1Space (SeparationQuotient X) ↔ R0Space X := by rw [r0Space_iff, ((t1Space_TFAE (SeparationQuotient X)).out 0 9 :)] constructor Β· intro h x y xspecy rw [← Inducing.specializes_iff inducing_mk, h xspecy] at * Β· rintro h ⟨x⟩ ⟨y⟩ sxspecsy have xspecy : x β€³ y := (Inducing.specializes_iff inducing_mk).mp sxspecsy have yspecx : y β€³ x := h xspecy erw [mk_eq_mk, inseparable_iff_specializes_and] exact ⟨xspecy, yspecx⟩ theorem singleton_mem_nhdsWithin_of_mem_discrete {s : Set X} [DiscreteTopology s] {x : X} (hx : x ∈ s) : {x} ∈ 𝓝[s] x := by have : ({⟨x, hx⟩} : Set s) ∈ 𝓝 (⟨x, hx⟩ : s) := by simp [nhds_discrete] simpa only [nhdsWithin_eq_map_subtype_coe hx, image_singleton] using @image_mem_map _ _ _ ((↑) : s β†’ X) _ this #align singleton_mem_nhds_within_of_mem_discrete singleton_mem_nhdsWithin_of_mem_discrete theorem nhdsWithin_of_mem_discrete {s : Set X} [DiscreteTopology s] {x : X} (hx : x ∈ s) : 𝓝[s] x = pure x := le_antisymm (le_pure_iff.2 <| singleton_mem_nhdsWithin_of_mem_discrete hx) (pure_le_nhdsWithin hx) #align nhds_within_of_mem_discrete nhdsWithin_of_mem_discrete theorem Filter.HasBasis.exists_inter_eq_singleton_of_mem_discrete {ΞΉ : Type*} {p : ΞΉ β†’ Prop} {t : ΞΉ β†’ Set X} {s : Set X} [DiscreteTopology s] {x : X} (hb : (𝓝 x).HasBasis p t) (hx : x ∈ s) : βˆƒ i, p i ∧ t i ∩ s = {x} := by rcases (nhdsWithin_hasBasis hb s).mem_iff.1 (singleton_mem_nhdsWithin_of_mem_discrete hx) with ⟨i, hi, hix⟩ exact ⟨i, hi, hix.antisymm <| singleton_subset_iff.2 ⟨mem_of_mem_nhds <| hb.mem_of_mem hi, hx⟩⟩ #align filter.has_basis.exists_inter_eq_singleton_of_mem_discrete Filter.HasBasis.exists_inter_eq_singleton_of_mem_discrete theorem nhds_inter_eq_singleton_of_mem_discrete {s : Set X} [DiscreteTopology s] {x : X} (hx : x ∈ s) : βˆƒ U ∈ 𝓝 x, U ∩ s = {x} := by simpa using (𝓝 x).basis_sets.exists_inter_eq_singleton_of_mem_discrete hx #align nhds_inter_eq_singleton_of_mem_discrete nhds_inter_eq_singleton_of_mem_discrete theorem isOpen_inter_eq_singleton_of_mem_discrete {s : Set X} [DiscreteTopology s] {x : X} (hx : x ∈ s) : βˆƒ U : Set X, IsOpen U ∧ U ∩ s = {x} := by obtain ⟨U, hU_nhds, hU_inter⟩ := nhds_inter_eq_singleton_of_mem_discrete hx obtain ⟨t, ht_sub, ht_open, ht_x⟩ := mem_nhds_iff.mp hU_nhds refine ⟨t, ht_open, Set.Subset.antisymm ?_ ?_⟩ Β· exact hU_inter β–Έ Set.inter_subset_inter_left s ht_sub Β· rw [Set.subset_inter_iff, Set.singleton_subset_iff, Set.singleton_subset_iff] exact ⟨ht_x, hx⟩ theorem disjoint_nhdsWithin_of_mem_discrete {s : Set X} [DiscreteTopology s] {x : X} (hx : x ∈ s) : βˆƒ U ∈ 𝓝[β‰ ] x, Disjoint U s := let ⟨V, h, h'⟩ := nhds_inter_eq_singleton_of_mem_discrete hx ⟨{x}ᢜ ∩ V, inter_mem_nhdsWithin _ h, disjoint_iff_inter_eq_empty.mpr (by rw [inter_assoc, h', compl_inter_self])⟩ #align disjoint_nhds_within_of_mem_discrete disjoint_nhdsWithin_of_mem_discrete @[deprecated embedding_inclusion (since := "2023-02-02")] theorem TopologicalSpace.subset_trans {s t : Set X} (ts : t βŠ† s) : (instTopologicalSpaceSubtype : TopologicalSpace t) = (instTopologicalSpaceSubtype : TopologicalSpace s).induced (Set.inclusion ts) := (embedding_inclusion ts).induced #align topological_space.subset_trans TopologicalSpace.subset_trans @[mk_iff] class T2Space (X : Type u) [TopologicalSpace X] : Prop where t2 : Pairwise fun x y => βˆƒ u v : Set X, IsOpen u ∧ IsOpen v ∧ x ∈ u ∧ y ∈ v ∧ Disjoint u v #align t2_space T2Space theorem t2_separation [T2Space X] {x y : X} (h : x β‰  y) : βˆƒ u v : Set X, IsOpen u ∧ IsOpen v ∧ x ∈ u ∧ y ∈ v ∧ Disjoint u v := T2Space.t2 h #align t2_separation t2_separation -- todo: use this as a definition? theorem t2Space_iff_disjoint_nhds : T2Space X ↔ Pairwise fun x y : X => Disjoint (𝓝 x) (𝓝 y) := by refine (t2Space_iff X).trans (forall₃_congr fun x y _ => ?_) simp only [(nhds_basis_opens x).disjoint_iff (nhds_basis_opens y), exists_prop, ← exists_and_left, and_assoc, and_comm, and_left_comm] #align t2_space_iff_disjoint_nhds t2Space_iff_disjoint_nhds @[simp] theorem disjoint_nhds_nhds [T2Space X] {x y : X} : Disjoint (𝓝 x) (𝓝 y) ↔ x β‰  y := ⟨fun hd he => by simp [he, nhds_neBot.ne] at hd, (t2Space_iff_disjoint_nhds.mp β€Ή_β€Ί Β·)⟩ #align disjoint_nhds_nhds disjoint_nhds_nhds theorem pairwise_disjoint_nhds [T2Space X] : Pairwise (Disjoint on (𝓝 : X β†’ Filter X)) := fun _ _ => disjoint_nhds_nhds.2 #align pairwise_disjoint_nhds pairwise_disjoint_nhds protected theorem Set.pairwiseDisjoint_nhds [T2Space X] (s : Set X) : s.PairwiseDisjoint 𝓝 := pairwise_disjoint_nhds.set_pairwise s #align set.pairwise_disjoint_nhds Set.pairwiseDisjoint_nhds theorem Set.Finite.t2_separation [T2Space X] {s : Set X} (hs : s.Finite) : βˆƒ U : X β†’ Set X, (βˆ€ x, x ∈ U x ∧ IsOpen (U x)) ∧ s.PairwiseDisjoint U := s.pairwiseDisjoint_nhds.exists_mem_filter_basis hs nhds_basis_opens #align set.finite.t2_separation Set.Finite.t2_separation -- see Note [lower instance priority] instance (priority := 100) T2Space.t1Space [T2Space X] : T1Space X := t1Space_iff_disjoint_pure_nhds.mpr fun _ _ hne => (disjoint_nhds_nhds.2 hne).mono_left <| pure_le_nhds _ #align t2_space.t1_space T2Space.t1Space -- see Note [lower instance priority] instance (priority := 100) T2Space.r1Space [T2Space X] : R1Space X := ⟨fun x y ↦ (eq_or_ne x y).imp specializes_of_eq disjoint_nhds_nhds.2⟩ theorem SeparationQuotient.t2Space_iff : T2Space (SeparationQuotient X) ↔ R1Space X := by simp only [t2Space_iff_disjoint_nhds, Pairwise, surjective_mk.forallβ‚‚, ne_eq, mk_eq_mk, r1Space_iff_inseparable_or_disjoint_nhds, ← disjoint_comap_iff surjective_mk, comap_mk_nhds_mk, ← or_iff_not_imp_left] instance SeparationQuotient.t2Space [R1Space X] : T2Space (SeparationQuotient X) := t2Space_iff.2 β€Ή_β€Ί instance (priority := 80) [R1Space X] [T0Space X] : T2Space X := t2Space_iff_disjoint_nhds.2 fun _x _y hne ↦ disjoint_nhds_nhds_iff_not_inseparable.2 fun hxy ↦ hne hxy.eq theorem R1Space.t2Space_iff_t0Space [R1Space X] : T2Space X ↔ T0Space X := by constructor <;> intro <;> infer_instance theorem t2_iff_nhds : T2Space X ↔ βˆ€ {x y : X}, NeBot (𝓝 x βŠ“ 𝓝 y) β†’ x = y := by simp only [t2Space_iff_disjoint_nhds, disjoint_iff, neBot_iff, Ne, not_imp_comm, Pairwise] #align t2_iff_nhds t2_iff_nhds theorem eq_of_nhds_neBot [T2Space X] {x y : X} (h : NeBot (𝓝 x βŠ“ 𝓝 y)) : x = y := t2_iff_nhds.mp β€Ή_β€Ί h #align eq_of_nhds_ne_bot eq_of_nhds_neBot theorem t2Space_iff_nhds : T2Space X ↔ Pairwise fun x y : X => βˆƒ U ∈ 𝓝 x, βˆƒ V ∈ 𝓝 y, Disjoint U V := by simp only [t2Space_iff_disjoint_nhds, Filter.disjoint_iff, Pairwise] #align t2_space_iff_nhds t2Space_iff_nhds theorem t2_separation_nhds [T2Space X] {x y : X} (h : x β‰  y) : βˆƒ u v, u ∈ 𝓝 x ∧ v ∈ 𝓝 y ∧ Disjoint u v := let ⟨u, v, open_u, open_v, x_in, y_in, huv⟩ := t2_separation h ⟨u, v, open_u.mem_nhds x_in, open_v.mem_nhds y_in, huv⟩ #align t2_separation_nhds t2_separation_nhds theorem t2_separation_compact_nhds [LocallyCompactSpace X] [T2Space X] {x y : X} (h : x β‰  y) : βˆƒ u v, u ∈ 𝓝 x ∧ v ∈ 𝓝 y ∧ IsCompact u ∧ IsCompact v ∧ Disjoint u v := by simpa only [exists_prop, ← exists_and_left, and_comm, and_assoc, and_left_comm] using ((compact_basis_nhds x).disjoint_iff (compact_basis_nhds y)).1 (disjoint_nhds_nhds.2 h) #align t2_separation_compact_nhds t2_separation_compact_nhds theorem t2_iff_ultrafilter : T2Space X ↔ βˆ€ {x y : X} (f : Ultrafilter X), ↑f ≀ 𝓝 x β†’ ↑f ≀ 𝓝 y β†’ x = y := t2_iff_nhds.trans <| by simp only [← exists_ultrafilter_iff, and_imp, le_inf_iff, exists_imp] #align t2_iff_ultrafilter t2_iff_ultrafilter theorem t2_iff_isClosed_diagonal : T2Space X ↔ IsClosed (diagonal X) := by simp only [t2Space_iff_disjoint_nhds, ← isOpen_compl_iff, isOpen_iff_mem_nhds, Prod.forall, nhds_prod_eq, compl_diagonal_mem_prod, mem_compl_iff, mem_diagonal_iff, Pairwise] #align t2_iff_is_closed_diagonal t2_iff_isClosed_diagonal theorem isClosed_diagonal [T2Space X] : IsClosed (diagonal X) := t2_iff_isClosed_diagonal.mp β€Ή_β€Ί #align is_closed_diagonal isClosed_diagonal -- Porting note: 2 lemmas moved below theorem tendsto_nhds_unique [T2Space X] {f : Y β†’ X} {l : Filter Y} {a b : X} [NeBot l] (ha : Tendsto f l (𝓝 a)) (hb : Tendsto f l (𝓝 b)) : a = b := eq_of_nhds_neBot <| neBot_of_le <| le_inf ha hb #align tendsto_nhds_unique tendsto_nhds_unique theorem tendsto_nhds_unique' [T2Space X] {f : Y β†’ X} {l : Filter Y} {a b : X} (_ : NeBot l) (ha : Tendsto f l (𝓝 a)) (hb : Tendsto f l (𝓝 b)) : a = b := eq_of_nhds_neBot <| neBot_of_le <| le_inf ha hb #align tendsto_nhds_unique' tendsto_nhds_unique' theorem tendsto_nhds_unique_of_eventuallyEq [T2Space X] {f g : Y β†’ X} {l : Filter Y} {a b : X} [NeBot l] (ha : Tendsto f l (𝓝 a)) (hb : Tendsto g l (𝓝 b)) (hfg : f =αΆ [l] g) : a = b := tendsto_nhds_unique (ha.congr' hfg) hb #align tendsto_nhds_unique_of_eventually_eq tendsto_nhds_unique_of_eventuallyEq theorem tendsto_nhds_unique_of_frequently_eq [T2Space X] {f g : Y β†’ X} {l : Filter Y} {a b : X} (ha : Tendsto f l (𝓝 a)) (hb : Tendsto g l (𝓝 b)) (hfg : βˆƒαΆ  x in l, f x = g x) : a = b := have : βˆƒαΆ  z : X Γ— X in 𝓝 (a, b), z.1 = z.2 := (ha.prod_mk_nhds hb).frequently hfg not_not.1 fun hne => this (isClosed_diagonal.isOpen_compl.mem_nhds hne) #align tendsto_nhds_unique_of_frequently_eq tendsto_nhds_unique_of_frequently_eq theorem IsCompact.nhdsSet_inter_eq [T2Space X] {s t : Set X} (hs : IsCompact s) (ht : IsCompact t) : 𝓝˒ (s ∩ t) = 𝓝˒ s βŠ“ 𝓝˒ t := by refine le_antisymm (nhdsSet_inter_le _ _) ?_ simp_rw [hs.nhdsSet_inf_eq_biSup, ht.inf_nhdsSet_eq_biSup, nhdsSet, sSup_image] refine iSupβ‚‚_le fun x hxs ↦ iSupβ‚‚_le fun y hyt ↦ ?_ rcases eq_or_ne x y with (rfl|hne) Β· exact le_iSupβ‚‚_of_le x ⟨hxs, hyt⟩ (inf_idem _).le Β· exact (disjoint_nhds_nhds.mpr hne).eq_bot β–Έ bot_le theorem Set.InjOn.exists_mem_nhdsSet {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [T2Space Y] {f : X β†’ Y} {s : Set X} (inj : InjOn f s) (sc : IsCompact s) (fc : βˆ€ x ∈ s, ContinuousAt f x) (loc : βˆ€ x ∈ s, βˆƒ u ∈ 𝓝 x, InjOn f u) : βˆƒ t ∈ 𝓝˒ s, InjOn f t := by have : βˆ€ x ∈ s Γ—Λ’ s, βˆ€αΆ  y in 𝓝 x, f y.1 = f y.2 β†’ y.1 = y.2 := fun (x, y) ⟨hx, hy⟩ ↦ by rcases eq_or_ne x y with rfl | hne Β· rcases loc x hx with ⟨u, hu, hf⟩ exact Filter.mem_of_superset (prod_mem_nhds hu hu) <| forall_prod_set.2 hf Β· suffices βˆ€αΆ  z in 𝓝 (x, y), f z.1 β‰  f z.2 from this.mono fun _ hne h ↦ absurd h hne refine (fc x hx).prod_map' (fc y hy) <| isClosed_diagonal.isOpen_compl.mem_nhds ?_ exact inj.ne hx hy hne rw [← eventually_nhdsSet_iff_forall, sc.nhdsSet_prod_eq sc] at this exact eventually_prod_self_iff.1 this theorem Set.InjOn.exists_isOpen_superset {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [T2Space Y] {f : X β†’ Y} {s : Set X} (inj : InjOn f s) (sc : IsCompact s) (fc : βˆ€ x ∈ s, ContinuousAt f x) (loc : βˆ€ x ∈ s, βˆƒ u ∈ 𝓝 x, InjOn f u) : βˆƒ t, IsOpen t ∧ s βŠ† t ∧ InjOn f t := let ⟨_t, hst, ht⟩ := inj.exists_mem_nhdsSet sc fc loc let ⟨u, huo, hsu, hut⟩ := mem_nhdsSet_iff_exists.1 hst ⟨u, huo, hsu, ht.mono hut⟩ section limUnder variable [T2Space X] {f : Filter X} theorem lim_eq {x : X} [NeBot f] (h : f ≀ 𝓝 x) : @lim _ _ ⟨x⟩ f = x := tendsto_nhds_unique (le_nhds_lim ⟨x, h⟩) h set_option linter.uppercaseLean3 false in #align Lim_eq lim_eq theorem lim_eq_iff [NeBot f] (h : βˆƒ x : X, f ≀ 𝓝 x) {x} : @lim _ _ ⟨x⟩ f = x ↔ f ≀ 𝓝 x := ⟨fun c => c β–Έ le_nhds_lim h, lim_eq⟩ set_option linter.uppercaseLean3 false in #align Lim_eq_iff lim_eq_iff theorem Ultrafilter.lim_eq_iff_le_nhds [CompactSpace X] {x : X} {F : Ultrafilter X} : F.lim = x ↔ ↑F ≀ 𝓝 x := ⟨fun h => h β–Έ F.le_nhds_lim, lim_eq⟩ set_option linter.uppercaseLean3 false in #align ultrafilter.Lim_eq_iff_le_nhds Ultrafilter.lim_eq_iff_le_nhds
Mathlib/Topology/Separation.lean
1,495
1,501
theorem isOpen_iff_ultrafilter' [CompactSpace X] (U : Set X) : IsOpen U ↔ βˆ€ F : Ultrafilter X, F.lim ∈ U β†’ U ∈ F.1 := by
rw [isOpen_iff_ultrafilter] refine ⟨fun h F hF => h F.lim hF F F.le_nhds_lim, ?_⟩ intro cond x hx f h rw [← Ultrafilter.lim_eq_iff_le_nhds.2 h] at hx exact cond _ hx
import Mathlib.Data.Nat.Factorization.Basic import Mathlib.Data.SetLike.Fintype import Mathlib.GroupTheory.GroupAction.ConjAct import Mathlib.GroupTheory.PGroup import Mathlib.GroupTheory.NoncommPiCoprod import Mathlib.Order.Atoms.Finite import Mathlib.Data.Set.Lattice #align_import group_theory.sylow from "leanprover-community/mathlib"@"4be589053caf347b899a494da75410deb55fb3ef" open Fintype MulAction Subgroup section InfiniteSylow variable (p : β„•) (G : Type*) [Group G] structure Sylow extends Subgroup G where isPGroup' : IsPGroup p toSubgroup is_maximal' : βˆ€ {Q : Subgroup G}, IsPGroup p Q β†’ toSubgroup ≀ Q β†’ Q = toSubgroup #align sylow Sylow variable {p} {G} open Equiv Equiv.Perm Finset Function List QuotientGroup universe u v w variable {G : Type u} {Ξ± : Type v} {Ξ² : Type w} [Group G] attribute [local instance 10] Subtype.fintype setFintype Classical.propDecidable theorem QuotientGroup.card_preimage_mk [Fintype G] (s : Subgroup G) (t : Set (G β§Έ s)) : Fintype.card (QuotientGroup.mk ⁻¹' t) = Fintype.card s * Fintype.card t := by rw [← Fintype.card_prod, Fintype.card_congr (preimageMkEquivSubgroupProdSet _ _)] #align quotient_group.card_preimage_mk QuotientGroup.card_preimage_mk namespace Sylow theorem mem_fixedPoints_mul_left_cosets_iff_mem_normalizer {H : Subgroup G} [Finite (H : Set G)] {x : G} : (x : G β§Έ H) ∈ MulAction.fixedPoints H (G β§Έ H) ↔ x ∈ normalizer H := ⟨fun hx => have ha : βˆ€ {y : G β§Έ H}, y ∈ orbit H (x : G β§Έ H) β†’ y = x := mem_fixedPoints'.1 hx _ (inv_mem_iff (G := G)).1 (mem_normalizer_fintype fun n (hn : n ∈ H) => have : (n⁻¹ * x)⁻¹ * x ∈ H := QuotientGroup.eq.1 (ha ⟨⟨n⁻¹, inv_mem hn⟩, rfl⟩) show _ ∈ H by rw [mul_inv_rev, inv_inv] at this convert this rw [inv_inv]), fun hx : βˆ€ n : G, n ∈ H ↔ x * n * x⁻¹ ∈ H => mem_fixedPoints'.2 fun y => Quotient.inductionOn' y fun y hy => QuotientGroup.eq.2 (let ⟨⟨b, hbβ‚βŸ©, hbβ‚‚βŸ© := hy have hbβ‚‚ : (b * x)⁻¹ * y ∈ H := QuotientGroup.eq.1 hbβ‚‚ (inv_mem_iff (G := G)).1 <| (hx _).2 <| (mul_mem_cancel_left (inv_mem hb₁)).1 <| by rw [hx] at hbβ‚‚; simpa [mul_inv_rev, mul_assoc] using hbβ‚‚)⟩ #align sylow.mem_fixed_points_mul_left_cosets_iff_mem_normalizer Sylow.mem_fixedPoints_mul_left_cosets_iff_mem_normalizer def fixedPointsMulLeftCosetsEquivQuotient (H : Subgroup G) [Finite (H : Set G)] : MulAction.fixedPoints H (G β§Έ H) ≃ normalizer H β§Έ Subgroup.comap ((normalizer H).subtype : normalizer H β†’* G) H := @subtypeQuotientEquivQuotientSubtype G (normalizer H : Set G) (_) (_) (MulAction.fixedPoints H (G β§Έ H)) (fun a => (@mem_fixedPoints_mul_left_cosets_iff_mem_normalizer _ _ _ β€Ή_β€Ί _).symm) (by intros unfold_projs rw [leftRel_apply (Ξ± := normalizer H), leftRel_apply] rfl) #align sylow.fixed_points_mul_left_cosets_equiv_quotient Sylow.fixedPointsMulLeftCosetsEquivQuotient theorem card_quotient_normalizer_modEq_card_quotient [Fintype G] {p : β„•} {n : β„•} [hp : Fact p.Prime] {H : Subgroup G} (hH : Fintype.card H = p ^ n) : Fintype.card (normalizer H β§Έ Subgroup.comap ((normalizer H).subtype : normalizer H β†’* G) H) ≑ card (G β§Έ H) [MOD p] := by rw [← Fintype.card_congr (fixedPointsMulLeftCosetsEquivQuotient H)] exact ((IsPGroup.of_card hH).card_modEq_card_fixedPoints _).symm #align sylow.card_quotient_normalizer_modeq_card_quotient Sylow.card_quotient_normalizer_modEq_card_quotient
Mathlib/GroupTheory/Sylow.lean
548
556
theorem card_normalizer_modEq_card [Fintype G] {p : β„•} {n : β„•} [hp : Fact p.Prime] {H : Subgroup G} (hH : Fintype.card H = p ^ n) : card (normalizer H) ≑ card G [MOD p ^ (n + 1)] := by
have : H.subgroupOf (normalizer H) ≃ H := (subgroupOfEquivOfLe le_normalizer).toEquiv simp only [← Nat.card_eq_fintype_card] at hH ⊒ rw [card_eq_card_quotient_mul_card_subgroup H, card_eq_card_quotient_mul_card_subgroup (H.subgroupOf (normalizer H)), Nat.card_congr this, hH, pow_succ'] simp only [Nat.card_eq_fintype_card] at hH ⊒ exact (card_quotient_normalizer_modEq_card_quotient hH).mul_right' _
import Mathlib.Algebra.Associated import Mathlib.Algebra.Order.Monoid.Unbundled.Pow import Mathlib.Algebra.Ring.Int import Mathlib.Data.Nat.Factorial.Basic import Mathlib.Data.Nat.GCD.Basic import Mathlib.Order.Bounds.Basic #align_import data.nat.prime from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" open Bool Subtype open Nat namespace Nat variable {n : β„•} -- Porting note (#11180): removed @[pp_nodot] def Prime (p : β„•) := Irreducible p #align nat.prime Nat.Prime theorem irreducible_iff_nat_prime (a : β„•) : Irreducible a ↔ Nat.Prime a := Iff.rfl #align irreducible_iff_nat_prime Nat.irreducible_iff_nat_prime @[aesop safe destruct] theorem not_prime_zero : Β¬Prime 0 | h => h.ne_zero rfl #align nat.not_prime_zero Nat.not_prime_zero @[aesop safe destruct] theorem not_prime_one : Β¬Prime 1 | h => h.ne_one rfl #align nat.not_prime_one Nat.not_prime_one theorem Prime.ne_zero {n : β„•} (h : Prime n) : n β‰  0 := Irreducible.ne_zero h #align nat.prime.ne_zero Nat.Prime.ne_zero theorem Prime.pos {p : β„•} (pp : Prime p) : 0 < p := Nat.pos_of_ne_zero pp.ne_zero #align nat.prime.pos Nat.Prime.pos theorem Prime.two_le : βˆ€ {p : β„•}, Prime p β†’ 2 ≀ p | 0, h => (not_prime_zero h).elim | 1, h => (not_prime_one h).elim | _ + 2, _ => le_add_self #align nat.prime.two_le Nat.Prime.two_le theorem Prime.one_lt {p : β„•} : Prime p β†’ 1 < p := Prime.two_le #align nat.prime.one_lt Nat.Prime.one_lt lemma Prime.one_le {p : β„•} (hp : p.Prime) : 1 ≀ p := hp.one_lt.le instance Prime.one_lt' (p : β„•) [hp : Fact p.Prime] : Fact (1 < p) := ⟨hp.1.one_lt⟩ #align nat.prime.one_lt' Nat.Prime.one_lt' theorem Prime.ne_one {p : β„•} (hp : p.Prime) : p β‰  1 := hp.one_lt.ne' #align nat.prime.ne_one Nat.Prime.ne_one theorem Prime.eq_one_or_self_of_dvd {p : β„•} (pp : p.Prime) (m : β„•) (hm : m ∣ p) : m = 1 ∨ m = p := by obtain ⟨n, hn⟩ := hm have := pp.isUnit_or_isUnit hn rw [Nat.isUnit_iff, Nat.isUnit_iff] at this apply Or.imp_right _ this rintro rfl rw [hn, mul_one] #align nat.prime.eq_one_or_self_of_dvd Nat.Prime.eq_one_or_self_of_dvd theorem prime_def_lt'' {p : β„•} : Prime p ↔ 2 ≀ p ∧ βˆ€ m, m ∣ p β†’ m = 1 ∨ m = p := by refine ⟨fun h => ⟨h.two_le, h.eq_one_or_self_of_dvd⟩, fun h => ?_⟩ -- Porting note: needed to make β„• explicit have h1 := (@one_lt_two β„• ..).trans_le h.1 refine ⟨mt Nat.isUnit_iff.mp h1.ne', fun a b hab => ?_⟩ simp only [Nat.isUnit_iff] apply Or.imp_right _ (h.2 a _) Β· rintro rfl rw [← mul_right_inj' (pos_of_gt h1).ne', ← hab, mul_one] Β· rw [hab] exact dvd_mul_right _ _ #align nat.prime_def_lt'' Nat.prime_def_lt'' theorem prime_def_lt {p : β„•} : Prime p ↔ 2 ≀ p ∧ βˆ€ m < p, m ∣ p β†’ m = 1 := prime_def_lt''.trans <| and_congr_right fun p2 => forall_congr' fun _ => ⟨fun h l d => (h d).resolve_right (ne_of_lt l), fun h d => (le_of_dvd (le_of_succ_le p2) d).lt_or_eq_dec.imp_left fun l => h l d⟩ #align nat.prime_def_lt Nat.prime_def_lt theorem prime_def_lt' {p : β„•} : Prime p ↔ 2 ≀ p ∧ βˆ€ m, 2 ≀ m β†’ m < p β†’ Β¬m ∣ p := prime_def_lt.trans <| and_congr_right fun p2 => forall_congr' fun m => ⟨fun h m2 l d => not_lt_of_ge m2 ((h l d).symm β–Έ by decide), fun h l d => by rcases m with (_ | _ | m) Β· rw [eq_zero_of_zero_dvd d] at p2 revert p2 decide Β· rfl Β· exact (h le_add_self l).elim d⟩ #align nat.prime_def_lt' Nat.prime_def_lt' theorem prime_def_le_sqrt {p : β„•} : Prime p ↔ 2 ≀ p ∧ βˆ€ m, 2 ≀ m β†’ m ≀ sqrt p β†’ Β¬m ∣ p := prime_def_lt'.trans <| and_congr_right fun p2 => ⟨fun a m m2 l => a m m2 <| lt_of_le_of_lt l <| sqrt_lt_self p2, fun a => have : βˆ€ {m k : β„•}, m ≀ k β†’ 1 < m β†’ p β‰  m * k := fun {m k} mk m1 e => a m m1 (le_sqrt.2 (e.symm β–Έ Nat.mul_le_mul_left m mk)) ⟨k, e⟩ fun m m2 l ⟨k, e⟩ => by rcases le_total m k with mk | km Β· exact this mk m2 e Β· rw [mul_comm] at e refine this km (lt_of_mul_lt_mul_right ?_ (zero_le m)) e rwa [one_mul, ← e]⟩ #align nat.prime_def_le_sqrt Nat.prime_def_le_sqrt theorem prime_of_coprime (n : β„•) (h1 : 1 < n) (h : βˆ€ m < n, m β‰  0 β†’ n.Coprime m) : Prime n := by refine prime_def_lt.mpr ⟨h1, fun m mlt mdvd => ?_⟩ have hm : m β‰  0 := by rintro rfl rw [zero_dvd_iff] at mdvd exact mlt.ne' mdvd exact (h m mlt hm).symm.eq_one_of_dvd mdvd #align nat.prime_of_coprime Nat.prime_of_coprime section @[local instance] def decidablePrime1 (p : β„•) : Decidable (Prime p) := decidable_of_iff' _ prime_def_lt' #align nat.decidable_prime_1 Nat.decidablePrime1 theorem prime_two : Prime 2 := by decide #align nat.prime_two Nat.prime_two theorem prime_three : Prime 3 := by decide #align nat.prime_three Nat.prime_three theorem prime_five : Prime 5 := by decide theorem Prime.five_le_of_ne_two_of_ne_three {p : β„•} (hp : p.Prime) (h_two : p β‰  2) (h_three : p β‰  3) : 5 ≀ p := by by_contra! h revert h_two h_three hp -- Porting note (#11043): was `decide!` match p with | 0 => decide | 1 => decide | 2 => decide | 3 => decide | 4 => decide | n + 5 => exact (h.not_le le_add_self).elim #align nat.prime.five_le_of_ne_two_of_ne_three Nat.Prime.five_le_of_ne_two_of_ne_three end theorem Prime.pred_pos {p : β„•} (pp : Prime p) : 0 < pred p := lt_pred_iff.2 pp.one_lt #align nat.prime.pred_pos Nat.Prime.pred_pos theorem succ_pred_prime {p : β„•} (pp : Prime p) : succ (pred p) = p := succ_pred_eq_of_pos pp.pos #align nat.succ_pred_prime Nat.succ_pred_prime theorem dvd_prime {p m : β„•} (pp : Prime p) : m ∣ p ↔ m = 1 ∨ m = p := ⟨fun d => pp.eq_one_or_self_of_dvd m d, fun h => h.elim (fun e => e.symm β–Έ one_dvd _) fun e => e.symm β–Έ dvd_rfl⟩ #align nat.dvd_prime Nat.dvd_prime theorem dvd_prime_two_le {p m : β„•} (pp : Prime p) (H : 2 ≀ m) : m ∣ p ↔ m = p := (dvd_prime pp).trans <| or_iff_right_of_imp <| Not.elim <| ne_of_gt H #align nat.dvd_prime_two_le Nat.dvd_prime_two_le theorem prime_dvd_prime_iff_eq {p q : β„•} (pp : p.Prime) (qp : q.Prime) : p ∣ q ↔ p = q := dvd_prime_two_le qp (Prime.two_le pp) #align nat.prime_dvd_prime_iff_eq Nat.prime_dvd_prime_iff_eq theorem Prime.not_dvd_one {p : β„•} (pp : Prime p) : Β¬p ∣ 1 := Irreducible.not_dvd_one pp #align nat.prime.not_dvd_one Nat.Prime.not_dvd_one theorem prime_mul_iff {a b : β„•} : Nat.Prime (a * b) ↔ a.Prime ∧ b = 1 ∨ b.Prime ∧ a = 1 := by simp only [iff_self_iff, irreducible_mul_iff, ← irreducible_iff_nat_prime, Nat.isUnit_iff] #align nat.prime_mul_iff Nat.prime_mul_iff theorem not_prime_mul {a b : β„•} (a1 : a β‰  1) (b1 : b β‰  1) : Β¬Prime (a * b) := by simp [prime_mul_iff, _root_.not_or, *] #align nat.not_prime_mul Nat.not_prime_mul theorem not_prime_mul' {a b n : β„•} (h : a * b = n) (h₁ : a β‰  1) (hβ‚‚ : b β‰  1) : Β¬Prime n := h β–Έ not_prime_mul h₁ hβ‚‚ #align nat.not_prime_mul' Nat.not_prime_mul' theorem Prime.dvd_iff_eq {p a : β„•} (hp : p.Prime) (a1 : a β‰  1) : a ∣ p ↔ p = a := by refine ⟨?_, by rintro rfl; rfl⟩ rintro ⟨j, rfl⟩ rcases prime_mul_iff.mp hp with (⟨_, rfl⟩ | ⟨_, rfl⟩) Β· exact mul_one _ Β· exact (a1 rfl).elim #align nat.prime.dvd_iff_eq Nat.Prime.dvd_iff_eq section MinFac theorem minFac_lemma (n k : β„•) (h : Β¬n < k * k) : sqrt n - k < sqrt n + 2 - k := (tsub_lt_tsub_iff_right <| le_sqrt.2 <| le_of_not_gt h).2 <| Nat.lt_add_of_pos_right (by decide) #align nat.min_fac_lemma Nat.minFac_lemma @[semireducible] def minFacAux (n : β„•) : β„• β†’ β„• | k => if n < k * k then n else if k ∣ n then k else minFacAux n (k + 2) termination_by k => sqrt n + 2 - k decreasing_by simp_wf; apply minFac_lemma n k; assumption #align nat.min_fac_aux Nat.minFacAux def minFac (n : β„•) : β„• := if 2 ∣ n then 2 else minFacAux n 3 #align nat.min_fac Nat.minFac @[simp] theorem minFac_zero : minFac 0 = 2 := rfl #align nat.min_fac_zero Nat.minFac_zero @[simp] theorem minFac_one : minFac 1 = 1 := by simp [minFac, minFacAux] #align nat.min_fac_one Nat.minFac_one @[simp] theorem minFac_two : minFac 2 = 2 := by simp [minFac, minFacAux] theorem minFac_eq (n : β„•) : minFac n = if 2 ∣ n then 2 else minFacAux n 3 := rfl #align nat.min_fac_eq Nat.minFac_eq private def minFacProp (n k : β„•) := 2 ≀ k ∧ k ∣ n ∧ βˆ€ m, 2 ≀ m β†’ m ∣ n β†’ k ≀ m theorem minFacAux_has_prop {n : β„•} (n2 : 2 ≀ n) : βˆ€ k i, k = 2 * i + 3 β†’ (βˆ€ m, 2 ≀ m β†’ m ∣ n β†’ k ≀ m) β†’ minFacProp n (minFacAux n k) | k => fun i e a => by rw [minFacAux] by_cases h : n < k * k <;> simp [h] Β· have pp : Prime n := prime_def_le_sqrt.2 ⟨n2, fun m m2 l d => not_lt_of_ge l <| lt_of_lt_of_le (sqrt_lt.2 h) (a m m2 d)⟩ exact ⟨n2, dvd_rfl, fun m m2 d => le_of_eq ((dvd_prime_two_le pp m2).1 d).symm⟩ have k2 : 2 ≀ k := by subst e apply Nat.le_add_left by_cases dk : k ∣ n <;> simp [dk] Β· exact ⟨k2, dk, a⟩ Β· refine have := minFac_lemma n k h minFacAux_has_prop n2 (k + 2) (i + 1) (by simp [k, e, left_distrib, add_right_comm]) fun m m2 d => ?_ rcases Nat.eq_or_lt_of_le (a m m2 d) with me | ml Β· subst me contradiction apply (Nat.eq_or_lt_of_le ml).resolve_left intro me rw [← me, e] at d have d' : 2 * (i + 2) ∣ n := d have := a _ le_rfl (dvd_of_mul_right_dvd d') rw [e] at this exact absurd this (by contradiction) termination_by k => sqrt n + 2 - k #align nat.min_fac_aux_has_prop Nat.minFacAux_has_prop
Mathlib/Data/Nat/Prime.lean
324
335
theorem minFac_has_prop {n : β„•} (n1 : n β‰  1) : minFacProp n (minFac n) := by
by_cases n0 : n = 0 Β· simp [n0, minFacProp, GE.ge] have n2 : 2 ≀ n := by revert n0 n1 rcases n with (_ | _ | _) <;> simp [succ_le_succ] simp only [minFac_eq, Nat.isUnit_iff] by_cases d2 : 2 ∣ n <;> simp [d2] Β· exact ⟨le_rfl, d2, fun k k2 _ => k2⟩ Β· refine minFacAux_has_prop n2 3 0 rfl fun m m2 d => (Nat.eq_or_lt_of_le m2).resolve_left (mt ?_ d2) exact fun e => e.symm β–Έ d
import Mathlib.Data.Nat.Cast.WithTop import Mathlib.RingTheory.Prime import Mathlib.RingTheory.Polynomial.Content import Mathlib.RingTheory.Ideal.Quotient #align_import ring_theory.eisenstein_criterion from "leanprover-community/mathlib"@"da420a8c6dd5bdfb85c4ced85c34388f633bc6ff" open Polynomial Ideal.Quotient variable {R : Type*} [CommRing R] namespace Polynomial open Polynomial namespace EisensteinCriterionAux -- Section for auxiliary lemmas used in the proof of `irreducible_of_eisenstein_criterion` theorem map_eq_C_mul_X_pow_of_forall_coeff_mem {f : R[X]} {P : Ideal R} (hfP : βˆ€ n : β„•, ↑n < f.degree β†’ f.coeff n ∈ P) : map (mk P) f = C ((mk P) f.leadingCoeff) * X ^ f.natDegree := Polynomial.ext fun n => by by_cases hf0 : f = 0 Β· simp [hf0] rcases lt_trichotomy (n : WithBot β„•) (degree f) with (h | h | h) Β· erw [coeff_map, eq_zero_iff_mem.2 (hfP n h), coeff_C_mul, coeff_X_pow, if_neg, mul_zero] rintro rfl exact not_lt_of_ge degree_le_natDegree h Β· have : natDegree f = n := natDegree_eq_of_degree_eq_some h.symm rw [coeff_C_mul, coeff_X_pow, if_pos this.symm, mul_one, leadingCoeff, this, coeff_map] Β· rw [coeff_eq_zero_of_degree_lt, coeff_eq_zero_of_degree_lt] Β· refine lt_of_le_of_lt (degree_C_mul_X_pow_le _ _) ?_ rwa [← degree_eq_natDegree hf0] Β· exact lt_of_le_of_lt (degree_map_le _ _) h set_option linter.uppercaseLean3 false in #align polynomial.eisenstein_criterion_aux.map_eq_C_mul_X_pow_of_forall_coeff_mem Polynomial.EisensteinCriterionAux.map_eq_C_mul_X_pow_of_forall_coeff_mem theorem le_natDegree_of_map_eq_mul_X_pow {n : β„•} {P : Ideal R} (hP : P.IsPrime) {q : R[X]} {c : Polynomial (R β§Έ P)} (hq : map (mk P) q = c * X ^ n) (hc0 : c.degree = 0) : n ≀ q.natDegree := Nat.cast_le.1 (calc ↑n = degree (q.map (mk P)) := by rw [hq, degree_mul, hc0, zero_add, degree_pow, degree_X, nsmul_one] _ ≀ degree q := degree_map_le _ _ _ ≀ natDegree q := degree_le_natDegree ) set_option linter.uppercaseLean3 false in #align polynomial.eisenstein_criterion_aux.le_nat_degree_of_map_eq_mul_X_pow Polynomial.EisensteinCriterionAux.le_natDegree_of_map_eq_mul_X_pow theorem eval_zero_mem_ideal_of_eq_mul_X_pow {n : β„•} {P : Ideal R} {q : R[X]} {c : Polynomial (R β§Έ P)} (hq : map (mk P) q = c * X ^ n) (hn0 : n β‰  0) : eval 0 q ∈ P := by rw [← coeff_zero_eq_eval_zero, ← eq_zero_iff_mem, ← coeff_map, hq, coeff_zero_eq_eval_zero, eval_mul, eval_pow, eval_X, zero_pow hn0, mul_zero] set_option linter.uppercaseLean3 false in #align polynomial.eisenstein_criterion_aux.eval_zero_mem_ideal_of_eq_mul_X_pow Polynomial.EisensteinCriterionAux.eval_zero_mem_ideal_of_eq_mul_X_pow
Mathlib/RingTheory/EisensteinCriterion.lean
72
78
theorem isUnit_of_natDegree_eq_zero_of_isPrimitive {p q : R[X]} -- Porting note: stated using `IsPrimitive` which is defeq to old statement. (hu : IsPrimitive (p * q)) (hpm : p.natDegree = 0) : IsUnit p := by
rw [eq_C_of_degree_le_zero (natDegree_eq_zero_iff_degree_le_zero.1 hpm), isUnit_C] refine hu _ ?_ rw [← eq_C_of_degree_le_zero (natDegree_eq_zero_iff_degree_le_zero.1 hpm)] exact dvd_mul_right _ _
import Mathlib.Order.Filter.Interval import Mathlib.Order.Interval.Set.Pi import Mathlib.Tactic.TFAE import Mathlib.Tactic.NormNum import Mathlib.Topology.Order.LeftRight import Mathlib.Topology.Order.OrderClosed #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {Ξ± : Type u} {Ξ² : Type v} {Ξ³ : Type w} -- Porting note (#11215): TODO: define `Preorder.topology` before `OrderTopology` and reuse the def class OrderTopology (Ξ± : Type*) [t : TopologicalSpace Ξ±] [Preorder Ξ±] : Prop where topology_eq_generate_intervals : t = generateFrom { s | βˆƒ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology def Preorder.topology (Ξ± : Type*) [Preorder Ξ±] : TopologicalSpace Ξ± := generateFrom { s : Set Ξ± | βˆƒ a : Ξ±, s = { b : Ξ± | a < b } ∨ s = { b : Ξ± | b < a } } #align preorder.topology Preorder.topology section OrderTopology instance tendstoIxxNhdsWithin {Ξ± : Type*} [TopologicalSpace Ξ±] (a : Ξ±) {s t : Set Ξ±} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (π“Ÿ s) (π“Ÿ t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ΞΉ : Type*} {Ξ± : ΞΉ β†’ Type*} [βˆ€ i, Preorder (Ξ± i)] [βˆ€ i, TopologicalSpace (Ξ± i)] [βˆ€ i, OrderTopology (Ξ± i)] (f : βˆ€ i, Ξ± i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap_eq_comap_image, tendsto_iInf, tendsto_comap_iff] intro i have : Tendsto (fun g : βˆ€ i, Ξ± i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine (this.comp tendsto_fst).Icc (this.comp tendsto_snd) |>.smallSets_mono ?_ filter_upwards [] using fun ⟨f, g⟩ ↦ image_subset_iff.mpr fun p hp ↦ ⟨hp.1 i, hp.2 i⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- Porting note (#10756): new lemma theorem induced_topology_le_preorder [Preorder Ξ±] [Preorder Ξ²] [TopologicalSpace Ξ²] [OrderTopology Ξ²] {f : Ξ± β†’ Ξ²} (hf : βˆ€ {x y}, f x < f y ↔ x < y) : induced f β€ΉTopologicalSpace Ξ²β€Ί ≀ Preorder.topology Ξ± := by let _ := Preorder.topology Ξ±; have : OrderTopology Ξ± := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInfβ‚‚ fun a ha => ?_) (le_iInfβ‚‚ fun a ha => ?_) exacts [iInfβ‚‚_le (f a) ha, iInfβ‚‚_le (f a) ha] -- Porting note (#10756): new lemma theorem induced_topology_eq_preorder [Preorder Ξ±] [Preorder Ξ²] [TopologicalSpace Ξ²] [OrderTopology Ξ²] {f : Ξ± β†’ Ξ²} (hf : βˆ€ {x y}, f x < f y ↔ x < y) (H₁ : βˆ€ {a b x}, b < f a β†’ Β¬(b < f x) β†’ βˆƒ y, y < a ∧ b ≀ f y) (Hβ‚‚ : βˆ€ {a b x}, f a < b β†’ Β¬(f x < b) β†’ βˆƒ y, a < y ∧ f y ≀ b) : induced f β€ΉTopologicalSpace Ξ²β€Ί = Preorder.topology Ξ± := by let _ := Preorder.topology Ξ±; have : OrderTopology Ξ± := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInfβ‚‚ fun b hb => ?_) (le_iInfβ‚‚ fun b hb => ?_) Β· rcases em (βˆƒ x, Β¬(b < f x)) with (⟨x, hx⟩ | hb) Β· rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInfβ‚‚_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) Β· push_neg at hb exact le_principal_iff.2 (univ_mem' hb) Β· rcases em (βˆƒ x, Β¬(f x < b)) with (⟨x, hx⟩ | hb) Β· rcases Hβ‚‚ hb hx with ⟨y, hya, hyb⟩ exact iInfβ‚‚_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) Β· push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {Ξ± : Type u} {Ξ² : Type v} [Preorder Ξ±] [ta : TopologicalSpace Ξ²] [Preorder Ξ²] [OrderTopology Ξ²] (f : Ξ± β†’ Ξ²) (hf : βˆ€ {x y}, f x < f y ↔ x < y) (H₁ : βˆ€ {a x}, x < f a β†’ βˆƒ b < a, x ≀ f b) (Hβ‚‚ : βˆ€ {a x}, f a < x β†’ βˆƒ b > a, f b ≀ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => Hβ‚‚ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {Ξ± : Type u} {Ξ² : Type v} [Preorder Ξ±] [ta : TopologicalSpace Ξ²] [Preorder Ξ²] [OrderTopology Ξ²] (f : Ξ± β†’ Ξ²) (hf : βˆ€ {x y}, f x < f y ↔ x < y) (H : βˆ€ {x y}, x < y β†’ βˆƒ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology nonrec theorem StrictMono.induced_topology_eq_preorder {Ξ± Ξ² : Type*} [LinearOrder Ξ±] [LinearOrder Ξ²] [t : TopologicalSpace Ξ²] [OrderTopology Ξ²] {f : Ξ± β†’ Ξ²} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology Ξ± := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ hβ‚‚ => ?_) fun h₁ hβ‚‚ => ?_ Β· rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 hβ‚‚, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ Β· rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 hβ‚‚βŸ© with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ theorem StrictMono.embedding_of_ordConnected {Ξ± Ξ² : Type*} [LinearOrder Ξ±] [LinearOrder Ξ²] [TopologicalSpace Ξ±] [h : OrderTopology Ξ±] [TopologicalSpace Ξ²] [OrderTopology Ξ²] {f : Ξ± β†’ Ξ²} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ instance orderTopology_of_ordConnected {Ξ± : Type u} [TopologicalSpace Ξ±] [LinearOrder Ξ±] [OrderTopology Ξ±] {t : Set Ξ±} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder <| by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace Ξ±] [Preorder Ξ±] [OrderTopology Ξ±] (a : Ξ±) : 𝓝[β‰₯] a = (β¨… (u) (_ : a < u), π“Ÿ (Iio u)) βŠ“ π“Ÿ (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf ?_ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInfβ‚‚ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace Ξ±] [Preorder Ξ±] [OrderTopology Ξ±] (a : Ξ±) : 𝓝[≀] a = (β¨… l < a, π“Ÿ (Ioi l)) βŠ“ π“Ÿ (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace Ξ±] [Preorder Ξ±] [OrderTopology Ξ±] {a : Ξ±} (ha : βˆƒ u, a < u) : 𝓝[β‰₯] a = β¨… (u) (_ : a < u), π“Ÿ (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace Ξ±] [Preorder Ξ±] [OrderTopology Ξ±] {a : Ξ±} (ha : βˆƒ l, l < a) : 𝓝[≀] a = β¨… l < a, π“Ÿ (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace Ξ±] [LinearOrder Ξ±] [OrderTopology Ξ±] {a : Ξ±} (ha : βˆƒ u, a < u) : (𝓝[β‰₯] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm β–Έ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace Ξ±] [LinearOrder Ξ±] [OrderTopology Ξ±] {a : Ξ±} (ha : βˆƒ l, l < a) : (𝓝[≀] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (Ξ± := Ξ±α΅’α΅ˆ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace Ξ±] [LinearOrder Ξ±] [OrderTopology Ξ±] [NoMaxOrder Ξ±] (a : Ξ±) : (𝓝[β‰₯] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace Ξ±] [LinearOrder Ξ±] [OrderTopology Ξ±] [NoMinOrder Ξ±] (a : Ξ±) : (𝓝[≀] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace Ξ±] [Preorder Ξ±] [OrderTop Ξ±] [OrderTopology Ξ±] : 𝓝 (⊀ : Ξ±) = β¨… (l) (hβ‚‚ : l < ⊀), π“Ÿ (Ioi l) := by simp [nhds_eq_order (⊀ : Ξ±)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace Ξ±] [Preorder Ξ±] [OrderBot Ξ±] [OrderTopology Ξ±] : 𝓝 (βŠ₯ : Ξ±) = β¨… (l) (hβ‚‚ : βŠ₯ < l), π“Ÿ (Iio l) := by simp [nhds_eq_order (βŠ₯ : Ξ±)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace Ξ±] [LinearOrder Ξ±] [OrderTop Ξ±] [OrderTopology Ξ±] [Nontrivial Ξ±] : (𝓝 ⊀).HasBasis (fun a : Ξ± => a < ⊀) fun a : Ξ± => Ioi a := by have : βˆƒ x : Ξ±, x < ⊀ := (exists_ne ⊀).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace Ξ±] [LinearOrder Ξ±] [OrderBot Ξ±] [OrderTopology Ξ±] [Nontrivial Ξ±] : (𝓝 βŠ₯).HasBasis (fun a : Ξ± => βŠ₯ < a) fun a : Ξ± => Iio a := nhds_top_basis (Ξ± := Ξ±α΅’α΅ˆ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace Ξ±] [LinearOrder Ξ±] [OrderTop Ξ±] [OrderTopology Ξ±] [Nontrivial Ξ±] [DenselyOrdered Ξ±] : (𝓝 ⊀).HasBasis (fun a : Ξ± => a < ⊀) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace Ξ±] [LinearOrder Ξ±] [OrderBot Ξ±] [OrderTopology Ξ±] [Nontrivial Ξ±] [DenselyOrdered Ξ±] : (𝓝 βŠ₯).HasBasis (fun a : Ξ± => βŠ₯ < a) Iic := nhds_top_basis_Ici (Ξ± := Ξ±α΅’α΅ˆ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace Ξ²] [Preorder Ξ²] [OrderTop Ξ²] [OrderTopology Ξ²] {l : Filter Ξ±} {f g : Ξ± β†’ Ξ²} (hf : Tendsto f l (𝓝 ⊀)) (hg : f ≀ᢠ[l] g) : Tendsto g l (𝓝 ⊀) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊒ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace Ξ²] [Preorder Ξ²] [OrderBot Ξ²] [OrderTopology Ξ²] {l : Filter Ξ±} {f g : Ξ± β†’ Ξ²} (hf : Tendsto f l (𝓝 βŠ₯)) (hg : g ≀ᢠ[l] f) : Tendsto g l (𝓝 βŠ₯) := tendsto_nhds_top_mono (Ξ² := Ξ²α΅’α΅ˆ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace Ξ²] [Preorder Ξ²] [OrderTop Ξ²] [OrderTopology Ξ²] {l : Filter Ξ±} {f g : Ξ± β†’ Ξ²} (hf : Tendsto f l (𝓝 ⊀)) (hg : f ≀ g) : Tendsto g l (𝓝 ⊀) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace Ξ²] [Preorder Ξ²] [OrderBot Ξ²] [OrderTopology Ξ²] {l : Filter Ξ±} {f g : Ξ± β†’ Ξ²} (hf : Tendsto f l (𝓝 βŠ₯)) (hg : g ≀ f) : Tendsto g l (𝓝 βŠ₯) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace Ξ±] [LinearOrder Ξ±] section OrderTopology variable [OrderTopology Ξ±] theorem order_separated {a₁ aβ‚‚ : Ξ±} (h : a₁ < aβ‚‚) : βˆƒ u v : Set Ξ±, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ aβ‚‚ ∈ v ∧ βˆ€ b₁ ∈ u, βˆ€ bβ‚‚ ∈ v, b₁ < bβ‚‚ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology Ξ± where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ aβ‚‚ (h : Β¬a₁ ≀ aβ‚‚) => have h : aβ‚‚ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, haβ‚‚, h⟩ := order_separated h ⟨v, u, hv, hu, haβ‚‚, ha₁, fun ⟨b₁, bβ‚‚βŸ© ⟨h₁, hβ‚‚βŸ© => not_le_of_gt <| h bβ‚‚ hβ‚‚ b₁ hβ‚βŸ© #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : Ξ±} {s : Set Ξ±} (hs : s ∈ 𝓝 a) (h : βˆƒ l, l < a) : βˆƒ l < a, Ioc l a βŠ† s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : Ξ±} {s : Set Ξ±} (hs : s ∈ 𝓝 a) {l : Ξ±} (hl : l < a) : βˆƒ l' ∈ Ico l a, Ioc l' a βŠ† s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : Ξ±} {s : Set Ξ±} (hs : s ∈ 𝓝 a) {u : Ξ±} (hu : a < u) : βˆƒ u' ∈ Ioc a u, Ico a u' βŠ† s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : Ξ±} {s : Set Ξ±} (hs : s ∈ 𝓝 a) (h : βˆƒ u, a < u) : βˆƒ u, a < u ∧ Ico a u βŠ† s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : Ξ±} {s : Set Ξ±} (hs : s ∈ 𝓝[β‰₯] a) : βˆƒ b, a ≀ b ∧ Icc a b ∈ 𝓝[β‰₯] a ∧ Icc a b βŠ† s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) Β· use a simpa [ha.Ici_eq] using hs Β· rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) Β· have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this β–Έ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ Β· refine ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, ?_⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : Ξ±} {s : Set Ξ±} (hs : s ∈ 𝓝[≀] a) : βˆƒ b ≀ a, Icc b a ∈ 𝓝[≀] a ∧ Icc b a βŠ† s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (Ξ± := Ξ±α΅’α΅ˆ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : Ξ±} {s : Set Ξ±} (hs : s ∈ 𝓝 a) : βˆƒ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c βŠ† s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine ⟨b, c, ⟨hba, hac⟩, ?_⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial Ξ±] {s : Set Ξ±} (hs : IsOpen s) (h : s.Nonempty) : βˆƒ a b, a < b ∧ Ioo a b βŠ† s := by obtain ⟨x, hx⟩ : βˆƒ x, x ∈ s := h obtain ⟨y, hy⟩ : βˆƒ y, y β‰  x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) Β· obtain ⟨u, xu, hu⟩ : βˆƒ u, x < u ∧ Ico x u βŠ† s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ Β· exact (hy rfl).elim Β· obtain ⟨l, lx, hl⟩ : βˆƒ l, l < x ∧ Ioc l x βŠ† s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset
Mathlib/Topology/Order/Basic.lean
466
471
theorem dense_of_exists_between [Nontrivial Ξ±] {s : Set Ξ±} (h : βˆ€ ⦃a b⦄, a < b β†’ βˆƒ c ∈ s, a < c ∧ c < b) : Dense s := by
refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : βˆƒ a b : Ξ±, a < b ∧ Ioo a b βŠ† U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : βˆƒ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩
import Mathlib.Algebra.Homology.ComplexShape import Mathlib.CategoryTheory.Subobject.Limits import Mathlib.CategoryTheory.GradedObject import Mathlib.Algebra.Homology.ShortComplex.Basic #align_import algebra.homology.homological_complex from "leanprover-community/mathlib"@"88bca0ce5d22ebfd9e73e682e51d60ea13b48347" universe v u open CategoryTheory CategoryTheory.Category CategoryTheory.Limits variable {ΞΉ : Type*} variable (V : Type u) [Category.{v} V] [HasZeroMorphisms V] structure HomologicalComplex (c : ComplexShape ΞΉ) where X : ΞΉ β†’ V d : βˆ€ i j, X i ⟢ X j shape : βˆ€ i j, Β¬c.Rel i j β†’ d i j = 0 := by aesop_cat d_comp_d' : βˆ€ i j k, c.Rel i j β†’ c.Rel j k β†’ d i j ≫ d j k = 0 := by aesop_cat #align homological_complex HomologicalComplex abbrev ChainComplex (Ξ± : Type*) [AddRightCancelSemigroup Ξ±] [One Ξ±] : Type _ := HomologicalComplex V (ComplexShape.down Ξ±) #align chain_complex ChainComplex abbrev CochainComplex (Ξ± : Type*) [AddRightCancelSemigroup Ξ±] [One Ξ±] : Type _ := HomologicalComplex V (ComplexShape.up Ξ±) #align cochain_complex CochainComplex namespace ChainComplex section MkHom variable {V} variable (P Q : CochainComplex V β„•) (zero : P.X 0 ⟢ Q.X 0) (one : P.X 1 ⟢ Q.X 1) (one_zero_comm : zero ≫ Q.d 0 1 = P.d 0 1 ≫ one) (succ : βˆ€ (n : β„•) (p : Ξ£' (f : P.X n ⟢ Q.X n) (f' : P.X (n + 1) ⟢ Q.X (n + 1)), f ≫ Q.d n (n + 1) = P.d n (n + 1) ≫ f'), Ξ£' f'' : P.X (n + 2) ⟢ Q.X (n + 2), p.2.1 ≫ Q.d (n + 1) (n + 2) = P.d (n + 1) (n + 2) ≫ f'') def mkHomAux : βˆ€ n, Ξ£' (f : P.X n ⟢ Q.X n) (f' : P.X (n + 1) ⟢ Q.X (n + 1)), f ≫ Q.d n (n + 1) = P.d n (n + 1) ≫ f' | 0 => ⟨zero, one, one_zero_comm⟩ | n + 1 => ⟨(mkHomAux n).2.1, (succ n (mkHomAux n)).1, (succ n (mkHomAux n)).2⟩ #align cochain_complex.mk_hom_aux CochainComplex.mkHomAux def mkHom : P ⟢ Q where f n := (mkHomAux P Q zero one one_zero_comm succ n).1 comm' n m := by rintro (rfl : n + 1 = m) exact (mkHomAux P Q zero one one_zero_comm succ n).2.2 #align cochain_complex.mk_hom CochainComplex.mkHom @[simp] theorem mkHom_f_0 : (mkHom P Q zero one one_zero_comm succ).f 0 = zero := rfl #align cochain_complex.mk_hom_f_0 CochainComplex.mkHom_f_0 @[simp] theorem mkHom_f_1 : (mkHom P Q zero one one_zero_comm succ).f 1 = one := rfl #align cochain_complex.mk_hom_f_1 CochainComplex.mkHom_f_1 @[simp]
Mathlib/Algebra/Homology/HomologicalComplex.lean
1,144
1,150
theorem mkHom_f_succ_succ (n : β„•) : (mkHom P Q zero one one_zero_comm succ).f (n + 2) = (succ n ⟨(mkHom P Q zero one one_zero_comm succ).f n, (mkHom P Q zero one one_zero_comm succ).f (n + 1), (mkHom P Q zero one one_zero_comm succ).comm n (n + 1)⟩).1 := by
dsimp [mkHom, mkHomAux]
import Mathlib.Topology.Constructions #align_import topology.continuous_on from "leanprover-community/mathlib"@"d4f691b9e5f94cfc64639973f3544c95f8d5d494" open Set Filter Function Topology Filter variable {Ξ± : Type*} {Ξ² : Type*} {Ξ³ : Type*} {Ξ΄ : Type*} variable [TopologicalSpace Ξ±] @[simp] theorem nhds_bind_nhdsWithin {a : Ξ±} {s : Set Ξ±} : ((𝓝 a).bind fun x => 𝓝[s] x) = 𝓝[s] a := bind_inf_principal.trans <| congr_argβ‚‚ _ nhds_bind_nhds rfl #align nhds_bind_nhds_within nhds_bind_nhdsWithin @[simp] theorem eventually_nhds_nhdsWithin {a : Ξ±} {s : Set Ξ±} {p : Ξ± β†’ Prop} : (βˆ€αΆ  y in 𝓝 a, βˆ€αΆ  x in 𝓝[s] y, p x) ↔ βˆ€αΆ  x in 𝓝[s] a, p x := Filter.ext_iff.1 nhds_bind_nhdsWithin { x | p x } #align eventually_nhds_nhds_within eventually_nhds_nhdsWithin theorem eventually_nhdsWithin_iff {a : Ξ±} {s : Set Ξ±} {p : Ξ± β†’ Prop} : (βˆ€αΆ  x in 𝓝[s] a, p x) ↔ βˆ€αΆ  x in 𝓝 a, x ∈ s β†’ p x := eventually_inf_principal #align eventually_nhds_within_iff eventually_nhdsWithin_iff theorem frequently_nhdsWithin_iff {z : Ξ±} {s : Set Ξ±} {p : Ξ± β†’ Prop} : (βˆƒαΆ  x in 𝓝[s] z, p x) ↔ βˆƒαΆ  x in 𝓝 z, p x ∧ x ∈ s := frequently_inf_principal.trans <| by simp only [and_comm] #align frequently_nhds_within_iff frequently_nhdsWithin_iff theorem mem_closure_ne_iff_frequently_within {z : Ξ±} {s : Set Ξ±} : z ∈ closure (s \ {z}) ↔ βˆƒαΆ  x in 𝓝[β‰ ] z, x ∈ s := by simp [mem_closure_iff_frequently, frequently_nhdsWithin_iff] #align mem_closure_ne_iff_frequently_within mem_closure_ne_iff_frequently_within @[simp] theorem eventually_nhdsWithin_nhdsWithin {a : Ξ±} {s : Set Ξ±} {p : Ξ± β†’ Prop} : (βˆ€αΆ  y in 𝓝[s] a, βˆ€αΆ  x in 𝓝[s] y, p x) ↔ βˆ€αΆ  x in 𝓝[s] a, p x := by refine ⟨fun h => ?_, fun h => (eventually_nhds_nhdsWithin.2 h).filter_mono inf_le_left⟩ simp only [eventually_nhdsWithin_iff] at h ⊒ exact h.mono fun x hx hxs => (hx hxs).self_of_nhds hxs #align eventually_nhds_within_nhds_within eventually_nhdsWithin_nhdsWithin theorem nhdsWithin_eq (a : Ξ±) (s : Set Ξ±) : 𝓝[s] a = β¨… t ∈ { t : Set Ξ± | a ∈ t ∧ IsOpen t }, π“Ÿ (t ∩ s) := ((nhds_basis_opens a).inf_principal s).eq_biInf #align nhds_within_eq nhdsWithin_eq theorem nhdsWithin_univ (a : Ξ±) : 𝓝[Set.univ] a = 𝓝 a := by rw [nhdsWithin, principal_univ, inf_top_eq] #align nhds_within_univ nhdsWithin_univ theorem nhdsWithin_hasBasis {p : Ξ² β†’ Prop} {s : Ξ² β†’ Set Ξ±} {a : Ξ±} (h : (𝓝 a).HasBasis p s) (t : Set Ξ±) : (𝓝[t] a).HasBasis p fun i => s i ∩ t := h.inf_principal t #align nhds_within_has_basis nhdsWithin_hasBasis theorem nhdsWithin_basis_open (a : Ξ±) (t : Set Ξ±) : (𝓝[t] a).HasBasis (fun u => a ∈ u ∧ IsOpen u) fun u => u ∩ t := nhdsWithin_hasBasis (nhds_basis_opens a) t #align nhds_within_basis_open nhdsWithin_basis_open theorem mem_nhdsWithin {t : Set Ξ±} {a : Ξ±} {s : Set Ξ±} : t ∈ 𝓝[s] a ↔ βˆƒ u, IsOpen u ∧ a ∈ u ∧ u ∩ s βŠ† t := by simpa only [and_assoc, and_left_comm] using (nhdsWithin_basis_open a s).mem_iff #align mem_nhds_within mem_nhdsWithin theorem mem_nhdsWithin_iff_exists_mem_nhds_inter {t : Set Ξ±} {a : Ξ±} {s : Set Ξ±} : t ∈ 𝓝[s] a ↔ βˆƒ u ∈ 𝓝 a, u ∩ s βŠ† t := (nhdsWithin_hasBasis (𝓝 a).basis_sets s).mem_iff #align mem_nhds_within_iff_exists_mem_nhds_inter mem_nhdsWithin_iff_exists_mem_nhds_inter theorem diff_mem_nhdsWithin_compl {x : Ξ±} {s : Set Ξ±} (hs : s ∈ 𝓝 x) (t : Set Ξ±) : s \ t ∈ 𝓝[tᢜ] x := diff_mem_inf_principal_compl hs t #align diff_mem_nhds_within_compl diff_mem_nhdsWithin_compl theorem diff_mem_nhdsWithin_diff {x : Ξ±} {s t : Set Ξ±} (hs : s ∈ 𝓝[t] x) (t' : Set Ξ±) : s \ t' ∈ 𝓝[t \ t'] x := by rw [nhdsWithin, diff_eq, diff_eq, ← inf_principal, ← inf_assoc] exact inter_mem_inf hs (mem_principal_self _) #align diff_mem_nhds_within_diff diff_mem_nhdsWithin_diff theorem nhds_of_nhdsWithin_of_nhds {s t : Set Ξ±} {a : Ξ±} (h1 : s ∈ 𝓝 a) (h2 : t ∈ 𝓝[s] a) : t ∈ 𝓝 a := by rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.mp h2 with ⟨_, Hw, hw⟩ exact (𝓝 a).sets_of_superset ((𝓝 a).inter_sets Hw h1) hw #align nhds_of_nhds_within_of_nhds nhds_of_nhdsWithin_of_nhds theorem mem_nhdsWithin_iff_eventually {s t : Set Ξ±} {x : Ξ±} : t ∈ 𝓝[s] x ↔ βˆ€αΆ  y in 𝓝 x, y ∈ s β†’ y ∈ t := eventually_inf_principal #align mem_nhds_within_iff_eventually mem_nhdsWithin_iff_eventually theorem mem_nhdsWithin_iff_eventuallyEq {s t : Set Ξ±} {x : Ξ±} : t ∈ 𝓝[s] x ↔ s =αΆ [𝓝 x] (s ∩ t : Set Ξ±) := by simp_rw [mem_nhdsWithin_iff_eventually, eventuallyEq_set, mem_inter_iff, iff_self_and] #align mem_nhds_within_iff_eventually_eq mem_nhdsWithin_iff_eventuallyEq theorem nhdsWithin_eq_iff_eventuallyEq {s t : Set Ξ±} {x : Ξ±} : 𝓝[s] x = 𝓝[t] x ↔ s =αΆ [𝓝 x] t := set_eventuallyEq_iff_inf_principal.symm #align nhds_within_eq_iff_eventually_eq nhdsWithin_eq_iff_eventuallyEq theorem nhdsWithin_le_iff {s t : Set Ξ±} {x : Ξ±} : 𝓝[s] x ≀ 𝓝[t] x ↔ t ∈ 𝓝[s] x := set_eventuallyLE_iff_inf_principal_le.symm.trans set_eventuallyLE_iff_mem_inf_principal #align nhds_within_le_iff nhdsWithin_le_iff -- Porting note: golfed, dropped an unneeded assumption theorem preimage_nhdsWithin_coinduced' {Ο€ : Ξ± β†’ Ξ²} {s : Set Ξ²} {t : Set Ξ±} {a : Ξ±} (h : a ∈ t) (hs : s ∈ @nhds Ξ² (.coinduced (fun x : t => Ο€ x) inferInstance) (Ο€ a)) : Ο€ ⁻¹' s ∈ 𝓝[t] a := by lift a to t using h replace hs : (fun x : t => Ο€ x) ⁻¹' s ∈ 𝓝 a := preimage_nhds_coinduced hs rwa [← map_nhds_subtype_val, mem_map] #align preimage_nhds_within_coinduced' preimage_nhdsWithin_coinduced'β‚“ theorem mem_nhdsWithin_of_mem_nhds {s t : Set Ξ±} {a : Ξ±} (h : s ∈ 𝓝 a) : s ∈ 𝓝[t] a := mem_inf_of_left h #align mem_nhds_within_of_mem_nhds mem_nhdsWithin_of_mem_nhds theorem self_mem_nhdsWithin {a : Ξ±} {s : Set Ξ±} : s ∈ 𝓝[s] a := mem_inf_of_right (mem_principal_self s) #align self_mem_nhds_within self_mem_nhdsWithin theorem eventually_mem_nhdsWithin {a : Ξ±} {s : Set Ξ±} : βˆ€αΆ  x in 𝓝[s] a, x ∈ s := self_mem_nhdsWithin #align eventually_mem_nhds_within eventually_mem_nhdsWithin theorem inter_mem_nhdsWithin (s : Set Ξ±) {t : Set Ξ±} {a : Ξ±} (h : t ∈ 𝓝 a) : s ∩ t ∈ 𝓝[s] a := inter_mem self_mem_nhdsWithin (mem_inf_of_left h) #align inter_mem_nhds_within inter_mem_nhdsWithin theorem nhdsWithin_mono (a : Ξ±) {s t : Set Ξ±} (h : s βŠ† t) : 𝓝[s] a ≀ 𝓝[t] a := inf_le_inf_left _ (principal_mono.mpr h) #align nhds_within_mono nhdsWithin_mono theorem pure_le_nhdsWithin {a : Ξ±} {s : Set Ξ±} (ha : a ∈ s) : pure a ≀ 𝓝[s] a := le_inf (pure_le_nhds a) (le_principal_iff.2 ha) #align pure_le_nhds_within pure_le_nhdsWithin theorem mem_of_mem_nhdsWithin {a : Ξ±} {s t : Set Ξ±} (ha : a ∈ s) (ht : t ∈ 𝓝[s] a) : a ∈ t := pure_le_nhdsWithin ha ht #align mem_of_mem_nhds_within mem_of_mem_nhdsWithin theorem Filter.Eventually.self_of_nhdsWithin {p : Ξ± β†’ Prop} {s : Set Ξ±} {x : Ξ±} (h : βˆ€αΆ  y in 𝓝[s] x, p y) (hx : x ∈ s) : p x := mem_of_mem_nhdsWithin hx h #align filter.eventually.self_of_nhds_within Filter.Eventually.self_of_nhdsWithin theorem tendsto_const_nhdsWithin {l : Filter Ξ²} {s : Set Ξ±} {a : Ξ±} (ha : a ∈ s) : Tendsto (fun _ : Ξ² => a) l (𝓝[s] a) := tendsto_const_pure.mono_right <| pure_le_nhdsWithin ha #align tendsto_const_nhds_within tendsto_const_nhdsWithin theorem nhdsWithin_restrict'' {a : Ξ±} (s : Set Ξ±) {t : Set Ξ±} (h : t ∈ 𝓝[s] a) : 𝓝[s] a = 𝓝[s ∩ t] a := le_antisymm (le_inf inf_le_left (le_principal_iff.mpr (inter_mem self_mem_nhdsWithin h))) (inf_le_inf_left _ (principal_mono.mpr Set.inter_subset_left)) #align nhds_within_restrict'' nhdsWithin_restrict'' theorem nhdsWithin_restrict' {a : Ξ±} (s : Set Ξ±) {t : Set Ξ±} (h : t ∈ 𝓝 a) : 𝓝[s] a = 𝓝[s ∩ t] a := nhdsWithin_restrict'' s <| mem_inf_of_left h #align nhds_within_restrict' nhdsWithin_restrict' theorem nhdsWithin_restrict {a : Ξ±} (s : Set Ξ±) {t : Set Ξ±} (hβ‚€ : a ∈ t) (h₁ : IsOpen t) : 𝓝[s] a = 𝓝[s ∩ t] a := nhdsWithin_restrict' s (IsOpen.mem_nhds h₁ hβ‚€) #align nhds_within_restrict nhdsWithin_restrict theorem nhdsWithin_le_of_mem {a : Ξ±} {s t : Set Ξ±} (h : s ∈ 𝓝[t] a) : 𝓝[t] a ≀ 𝓝[s] a := nhdsWithin_le_iff.mpr h #align nhds_within_le_of_mem nhdsWithin_le_of_mem theorem nhdsWithin_le_nhds {a : Ξ±} {s : Set Ξ±} : 𝓝[s] a ≀ 𝓝 a := by rw [← nhdsWithin_univ] apply nhdsWithin_le_of_mem exact univ_mem #align nhds_within_le_nhds nhdsWithin_le_nhds theorem nhdsWithin_eq_nhdsWithin' {a : Ξ±} {s t u : Set Ξ±} (hs : s ∈ 𝓝 a) (hβ‚‚ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict' t hs, nhdsWithin_restrict' u hs, hβ‚‚] #align nhds_within_eq_nhds_within' nhdsWithin_eq_nhdsWithin' theorem nhdsWithin_eq_nhdsWithin {a : Ξ±} {s t u : Set Ξ±} (hβ‚€ : a ∈ s) (h₁ : IsOpen s) (hβ‚‚ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict t hβ‚€ h₁, nhdsWithin_restrict u hβ‚€ h₁, hβ‚‚] #align nhds_within_eq_nhds_within nhdsWithin_eq_nhdsWithin @[simp] theorem nhdsWithin_eq_nhds {a : Ξ±} {s : Set Ξ±} : 𝓝[s] a = 𝓝 a ↔ s ∈ 𝓝 a := inf_eq_left.trans le_principal_iff #align nhds_within_eq_nhds nhdsWithin_eq_nhds theorem IsOpen.nhdsWithin_eq {a : Ξ±} {s : Set Ξ±} (h : IsOpen s) (ha : a ∈ s) : 𝓝[s] a = 𝓝 a := nhdsWithin_eq_nhds.2 <| h.mem_nhds ha #align is_open.nhds_within_eq IsOpen.nhdsWithin_eq theorem preimage_nhds_within_coinduced {Ο€ : Ξ± β†’ Ξ²} {s : Set Ξ²} {t : Set Ξ±} {a : Ξ±} (h : a ∈ t) (ht : IsOpen t) (hs : s ∈ @nhds Ξ² (.coinduced (fun x : t => Ο€ x) inferInstance) (Ο€ a)) : Ο€ ⁻¹' s ∈ 𝓝 a := by rw [← ht.nhdsWithin_eq h] exact preimage_nhdsWithin_coinduced' h hs #align preimage_nhds_within_coinduced preimage_nhds_within_coinduced @[simp] theorem nhdsWithin_empty (a : Ξ±) : 𝓝[βˆ…] a = βŠ₯ := by rw [nhdsWithin, principal_empty, inf_bot_eq] #align nhds_within_empty nhdsWithin_empty theorem nhdsWithin_union (a : Ξ±) (s t : Set Ξ±) : 𝓝[s βˆͺ t] a = 𝓝[s] a βŠ” 𝓝[t] a := by delta nhdsWithin rw [← inf_sup_left, sup_principal] #align nhds_within_union nhdsWithin_union theorem nhdsWithin_biUnion {ΞΉ} {I : Set ΞΉ} (hI : I.Finite) (s : ΞΉ β†’ Set Ξ±) (a : Ξ±) : 𝓝[⋃ i ∈ I, s i] a = ⨆ i ∈ I, 𝓝[s i] a := Set.Finite.induction_on hI (by simp) fun _ _ hT ↦ by simp only [hT, nhdsWithin_union, iSup_insert, biUnion_insert] #align nhds_within_bUnion nhdsWithin_biUnion theorem nhdsWithin_sUnion {S : Set (Set Ξ±)} (hS : S.Finite) (a : Ξ±) : 𝓝[⋃₀ S] a = ⨆ s ∈ S, 𝓝[s] a := by rw [sUnion_eq_biUnion, nhdsWithin_biUnion hS] #align nhds_within_sUnion nhdsWithin_sUnion theorem nhdsWithin_iUnion {ΞΉ} [Finite ΞΉ] (s : ΞΉ β†’ Set Ξ±) (a : Ξ±) : 𝓝[⋃ i, s i] a = ⨆ i, 𝓝[s i] a := by rw [← sUnion_range, nhdsWithin_sUnion (finite_range s), iSup_range] #align nhds_within_Union nhdsWithin_iUnion theorem nhdsWithin_inter (a : Ξ±) (s t : Set Ξ±) : 𝓝[s ∩ t] a = 𝓝[s] a βŠ“ 𝓝[t] a := by delta nhdsWithin rw [inf_left_comm, inf_assoc, inf_principal, ← inf_assoc, inf_idem] #align nhds_within_inter nhdsWithin_inter theorem nhdsWithin_inter' (a : Ξ±) (s t : Set Ξ±) : 𝓝[s ∩ t] a = 𝓝[s] a βŠ“ π“Ÿ t := by delta nhdsWithin rw [← inf_principal, inf_assoc] #align nhds_within_inter' nhdsWithin_inter' theorem nhdsWithin_inter_of_mem {a : Ξ±} {s t : Set Ξ±} (h : s ∈ 𝓝[t] a) : 𝓝[s ∩ t] a = 𝓝[t] a := by rw [nhdsWithin_inter, inf_eq_right] exact nhdsWithin_le_of_mem h #align nhds_within_inter_of_mem nhdsWithin_inter_of_mem theorem nhdsWithin_inter_of_mem' {a : Ξ±} {s t : Set Ξ±} (h : t ∈ 𝓝[s] a) : 𝓝[s ∩ t] a = 𝓝[s] a := by rw [inter_comm, nhdsWithin_inter_of_mem h] #align nhds_within_inter_of_mem' nhdsWithin_inter_of_mem' @[simp] theorem nhdsWithin_singleton (a : Ξ±) : 𝓝[{a}] a = pure a := by rw [nhdsWithin, principal_singleton, inf_eq_right.2 (pure_le_nhds a)] #align nhds_within_singleton nhdsWithin_singleton @[simp] theorem nhdsWithin_insert (a : Ξ±) (s : Set Ξ±) : 𝓝[insert a s] a = pure a βŠ” 𝓝[s] a := by rw [← singleton_union, nhdsWithin_union, nhdsWithin_singleton] #align nhds_within_insert nhdsWithin_insert theorem mem_nhdsWithin_insert {a : Ξ±} {s t : Set Ξ±} : t ∈ 𝓝[insert a s] a ↔ a ∈ t ∧ t ∈ 𝓝[s] a := by simp #align mem_nhds_within_insert mem_nhdsWithin_insert theorem insert_mem_nhdsWithin_insert {a : Ξ±} {s t : Set Ξ±} (h : t ∈ 𝓝[s] a) : insert a t ∈ 𝓝[insert a s] a := by simp [mem_of_superset h] #align insert_mem_nhds_within_insert insert_mem_nhdsWithin_insert theorem insert_mem_nhds_iff {a : Ξ±} {s : Set Ξ±} : insert a s ∈ 𝓝 a ↔ s ∈ 𝓝[β‰ ] a := by simp only [nhdsWithin, mem_inf_principal, mem_compl_iff, mem_singleton_iff, or_iff_not_imp_left, insert_def] #align insert_mem_nhds_iff insert_mem_nhds_iff @[simp] theorem nhdsWithin_compl_singleton_sup_pure (a : Ξ±) : 𝓝[β‰ ] a βŠ” pure a = 𝓝 a := by rw [← nhdsWithin_singleton, ← nhdsWithin_union, compl_union_self, nhdsWithin_univ] #align nhds_within_compl_singleton_sup_pure nhdsWithin_compl_singleton_sup_pure theorem nhdsWithin_prod {Ξ± : Type*} [TopologicalSpace Ξ±] {Ξ² : Type*} [TopologicalSpace Ξ²] {s u : Set Ξ±} {t v : Set Ξ²} {a : Ξ±} {b : Ξ²} (hu : u ∈ 𝓝[s] a) (hv : v ∈ 𝓝[t] b) : u Γ—Λ’ v ∈ 𝓝[s Γ—Λ’ t] (a, b) := by rw [nhdsWithin_prod_eq] exact prod_mem_prod hu hv #align nhds_within_prod nhdsWithin_prod theorem nhdsWithin_pi_eq' {ΞΉ : Type*} {Ξ± : ΞΉ β†’ Type*} [βˆ€ i, TopologicalSpace (Ξ± i)] {I : Set ΞΉ} (hI : I.Finite) (s : βˆ€ i, Set (Ξ± i)) (x : βˆ€ i, Ξ± i) : 𝓝[pi I s] x = β¨… i, comap (fun x => x i) (𝓝 (x i) βŠ“ β¨… (_ : i ∈ I), π“Ÿ (s i)) := by simp only [nhdsWithin, nhds_pi, Filter.pi, comap_inf, comap_iInf, pi_def, comap_principal, ← iInf_principal_finite hI, ← iInf_inf_eq] #align nhds_within_pi_eq' nhdsWithin_pi_eq' theorem nhdsWithin_pi_eq {ΞΉ : Type*} {Ξ± : ΞΉ β†’ Type*} [βˆ€ i, TopologicalSpace (Ξ± i)] {I : Set ΞΉ} (hI : I.Finite) (s : βˆ€ i, Set (Ξ± i)) (x : βˆ€ i, Ξ± i) : 𝓝[pi I s] x = (β¨… i ∈ I, comap (fun x => x i) (𝓝[s i] x i)) βŠ“ β¨… (i) (_ : i βˆ‰ I), comap (fun x => x i) (𝓝 (x i)) := by simp only [nhdsWithin, nhds_pi, Filter.pi, pi_def, ← iInf_principal_finite hI, comap_inf, comap_principal, eval] rw [iInf_split _ fun i => i ∈ I, inf_right_comm] simp only [iInf_inf_eq] #align nhds_within_pi_eq nhdsWithin_pi_eq theorem nhdsWithin_pi_univ_eq {ΞΉ : Type*} {Ξ± : ΞΉ β†’ Type*} [Finite ΞΉ] [βˆ€ i, TopologicalSpace (Ξ± i)] (s : βˆ€ i, Set (Ξ± i)) (x : βˆ€ i, Ξ± i) : 𝓝[pi univ s] x = β¨… i, comap (fun x => x i) (𝓝[s i] x i) := by simpa [nhdsWithin] using nhdsWithin_pi_eq finite_univ s x #align nhds_within_pi_univ_eq nhdsWithin_pi_univ_eq theorem nhdsWithin_pi_eq_bot {ΞΉ : Type*} {Ξ± : ΞΉ β†’ Type*} [βˆ€ i, TopologicalSpace (Ξ± i)] {I : Set ΞΉ} {s : βˆ€ i, Set (Ξ± i)} {x : βˆ€ i, Ξ± i} : 𝓝[pi I s] x = βŠ₯ ↔ βˆƒ i ∈ I, 𝓝[s i] x i = βŠ₯ := by simp only [nhdsWithin, nhds_pi, pi_inf_principal_pi_eq_bot] #align nhds_within_pi_eq_bot nhdsWithin_pi_eq_bot theorem nhdsWithin_pi_neBot {ΞΉ : Type*} {Ξ± : ΞΉ β†’ Type*} [βˆ€ i, TopologicalSpace (Ξ± i)] {I : Set ΞΉ} {s : βˆ€ i, Set (Ξ± i)} {x : βˆ€ i, Ξ± i} : (𝓝[pi I s] x).NeBot ↔ βˆ€ i ∈ I, (𝓝[s i] x i).NeBot := by simp [neBot_iff, nhdsWithin_pi_eq_bot] #align nhds_within_pi_ne_bot nhdsWithin_pi_neBot theorem Filter.Tendsto.piecewise_nhdsWithin {f g : Ξ± β†’ Ξ²} {t : Set Ξ±} [βˆ€ x, Decidable (x ∈ t)] {a : Ξ±} {s : Set Ξ±} {l : Filter Ξ²} (hβ‚€ : Tendsto f (𝓝[s ∩ t] a) l) (h₁ : Tendsto g (𝓝[s ∩ tᢜ] a) l) : Tendsto (piecewise t f g) (𝓝[s] a) l := by apply Tendsto.piecewise <;> rwa [← nhdsWithin_inter'] #align filter.tendsto.piecewise_nhds_within Filter.Tendsto.piecewise_nhdsWithin theorem Filter.Tendsto.if_nhdsWithin {f g : Ξ± β†’ Ξ²} {p : Ξ± β†’ Prop} [DecidablePred p] {a : Ξ±} {s : Set Ξ±} {l : Filter Ξ²} (hβ‚€ : Tendsto f (𝓝[s ∩ { x | p x }] a) l) (h₁ : Tendsto g (𝓝[s ∩ { x | Β¬p x }] a) l) : Tendsto (fun x => if p x then f x else g x) (𝓝[s] a) l := hβ‚€.piecewise_nhdsWithin h₁ #align filter.tendsto.if_nhds_within Filter.Tendsto.if_nhdsWithin theorem map_nhdsWithin (f : Ξ± β†’ Ξ²) (a : Ξ±) (s : Set Ξ±) : map f (𝓝[s] a) = β¨… t ∈ { t : Set Ξ± | a ∈ t ∧ IsOpen t }, π“Ÿ (f '' (t ∩ s)) := ((nhdsWithin_basis_open a s).map f).eq_biInf #align map_nhds_within map_nhdsWithin theorem tendsto_nhdsWithin_mono_left {f : Ξ± β†’ Ξ²} {a : Ξ±} {s t : Set Ξ±} {l : Filter Ξ²} (hst : s βŠ† t) (h : Tendsto f (𝓝[t] a) l) : Tendsto f (𝓝[s] a) l := h.mono_left <| nhdsWithin_mono a hst #align tendsto_nhds_within_mono_left tendsto_nhdsWithin_mono_left theorem tendsto_nhdsWithin_mono_right {f : Ξ² β†’ Ξ±} {l : Filter Ξ²} {a : Ξ±} {s t : Set Ξ±} (hst : s βŠ† t) (h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝[t] a) := h.mono_right (nhdsWithin_mono a hst) #align tendsto_nhds_within_mono_right tendsto_nhdsWithin_mono_right theorem tendsto_nhdsWithin_of_tendsto_nhds {f : Ξ± β†’ Ξ²} {a : Ξ±} {s : Set Ξ±} {l : Filter Ξ²} (h : Tendsto f (𝓝 a) l) : Tendsto f (𝓝[s] a) l := h.mono_left inf_le_left #align tendsto_nhds_within_of_tendsto_nhds tendsto_nhdsWithin_of_tendsto_nhds theorem eventually_mem_of_tendsto_nhdsWithin {f : Ξ² β†’ Ξ±} {a : Ξ±} {s : Set Ξ±} {l : Filter Ξ²} (h : Tendsto f l (𝓝[s] a)) : βˆ€αΆ  i in l, f i ∈ s := by simp_rw [nhdsWithin_eq, tendsto_iInf, mem_setOf_eq, tendsto_principal, mem_inter_iff, eventually_and] at h exact (h univ ⟨mem_univ a, isOpen_univ⟩).2 #align eventually_mem_of_tendsto_nhds_within eventually_mem_of_tendsto_nhdsWithin theorem tendsto_nhds_of_tendsto_nhdsWithin {f : Ξ² β†’ Ξ±} {a : Ξ±} {s : Set Ξ±} {l : Filter Ξ²} (h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝 a) := h.mono_right nhdsWithin_le_nhds #align tendsto_nhds_of_tendsto_nhds_within tendsto_nhds_of_tendsto_nhdsWithin theorem nhdsWithin_neBot_of_mem {s : Set Ξ±} {x : Ξ±} (hx : x ∈ s) : NeBot (𝓝[s] x) := mem_closure_iff_nhdsWithin_neBot.1 <| subset_closure hx #align nhds_within_ne_bot_of_mem nhdsWithin_neBot_of_mem theorem IsClosed.mem_of_nhdsWithin_neBot {s : Set Ξ±} (hs : IsClosed s) {x : Ξ±} (hx : NeBot <| 𝓝[s] x) : x ∈ s := hs.closure_eq β–Έ mem_closure_iff_nhdsWithin_neBot.2 hx #align is_closed.mem_of_nhds_within_ne_bot IsClosed.mem_of_nhdsWithin_neBot theorem DenseRange.nhdsWithin_neBot {ΞΉ : Type*} {f : ΞΉ β†’ Ξ±} (h : DenseRange f) (x : Ξ±) : NeBot (𝓝[range f] x) := mem_closure_iff_clusterPt.1 (h x) #align dense_range.nhds_within_ne_bot DenseRange.nhdsWithin_neBot theorem mem_closure_pi {ΞΉ : Type*} {Ξ± : ΞΉ β†’ Type*} [βˆ€ i, TopologicalSpace (Ξ± i)] {I : Set ΞΉ} {s : βˆ€ i, Set (Ξ± i)} {x : βˆ€ i, Ξ± i} : x ∈ closure (pi I s) ↔ βˆ€ i ∈ I, x i ∈ closure (s i) := by simp only [mem_closure_iff_nhdsWithin_neBot, nhdsWithin_pi_neBot] #align mem_closure_pi mem_closure_pi theorem closure_pi_set {ΞΉ : Type*} {Ξ± : ΞΉ β†’ Type*} [βˆ€ i, TopologicalSpace (Ξ± i)] (I : Set ΞΉ) (s : βˆ€ i, Set (Ξ± i)) : closure (pi I s) = pi I fun i => closure (s i) := Set.ext fun _ => mem_closure_pi #align closure_pi_set closure_pi_set theorem dense_pi {ΞΉ : Type*} {Ξ± : ΞΉ β†’ Type*} [βˆ€ i, TopologicalSpace (Ξ± i)] {s : βˆ€ i, Set (Ξ± i)} (I : Set ΞΉ) (hs : βˆ€ i ∈ I, Dense (s i)) : Dense (pi I s) := by simp only [dense_iff_closure_eq, closure_pi_set, pi_congr rfl fun i hi => (hs i hi).closure_eq, pi_univ] #align dense_pi dense_pi theorem eventuallyEq_nhdsWithin_iff {f g : Ξ± β†’ Ξ²} {s : Set Ξ±} {a : Ξ±} : f =αΆ [𝓝[s] a] g ↔ βˆ€αΆ  x in 𝓝 a, x ∈ s β†’ f x = g x := mem_inf_principal #align eventually_eq_nhds_within_iff eventuallyEq_nhdsWithin_iff theorem eventuallyEq_nhdsWithin_of_eqOn {f g : Ξ± β†’ Ξ²} {s : Set Ξ±} {a : Ξ±} (h : EqOn f g s) : f =αΆ [𝓝[s] a] g := mem_inf_of_right h #align eventually_eq_nhds_within_of_eq_on eventuallyEq_nhdsWithin_of_eqOn theorem Set.EqOn.eventuallyEq_nhdsWithin {f g : Ξ± β†’ Ξ²} {s : Set Ξ±} {a : Ξ±} (h : EqOn f g s) : f =αΆ [𝓝[s] a] g := eventuallyEq_nhdsWithin_of_eqOn h #align set.eq_on.eventually_eq_nhds_within Set.EqOn.eventuallyEq_nhdsWithin theorem tendsto_nhdsWithin_congr {f g : Ξ± β†’ Ξ²} {s : Set Ξ±} {a : Ξ±} {l : Filter Ξ²} (hfg : βˆ€ x ∈ s, f x = g x) (hf : Tendsto f (𝓝[s] a) l) : Tendsto g (𝓝[s] a) l := (tendsto_congr' <| eventuallyEq_nhdsWithin_of_eqOn hfg).1 hf #align tendsto_nhds_within_congr tendsto_nhdsWithin_congr theorem eventually_nhdsWithin_of_forall {s : Set Ξ±} {a : Ξ±} {p : Ξ± β†’ Prop} (h : βˆ€ x ∈ s, p x) : βˆ€αΆ  x in 𝓝[s] a, p x := mem_inf_of_right h #align eventually_nhds_within_of_forall eventually_nhdsWithin_of_forall theorem tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within {a : Ξ±} {l : Filter Ξ²} {s : Set Ξ±} (f : Ξ² β†’ Ξ±) (h1 : Tendsto f l (𝓝 a)) (h2 : βˆ€αΆ  x in l, f x ∈ s) : Tendsto f l (𝓝[s] a) := tendsto_inf.2 ⟨h1, tendsto_principal.2 h2⟩ #align tendsto_nhds_within_of_tendsto_nhds_of_eventually_within tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within theorem tendsto_nhdsWithin_iff {a : Ξ±} {l : Filter Ξ²} {s : Set Ξ±} {f : Ξ² β†’ Ξ±} : Tendsto f l (𝓝[s] a) ↔ Tendsto f l (𝓝 a) ∧ βˆ€αΆ  n in l, f n ∈ s := ⟨fun h => ⟨tendsto_nhds_of_tendsto_nhdsWithin h, eventually_mem_of_tendsto_nhdsWithin h⟩, fun h => tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ h.1 h.2⟩ #align tendsto_nhds_within_iff tendsto_nhdsWithin_iff @[simp] theorem tendsto_nhdsWithin_range {a : Ξ±} {l : Filter Ξ²} {f : Ξ² β†’ Ξ±} : Tendsto f l (𝓝[range f] a) ↔ Tendsto f l (𝓝 a) := ⟨fun h => h.mono_right inf_le_left, fun h => tendsto_inf.2 ⟨h, tendsto_principal.2 <| eventually_of_forall mem_range_self⟩⟩ #align tendsto_nhds_within_range tendsto_nhdsWithin_range theorem Filter.EventuallyEq.eq_of_nhdsWithin {s : Set Ξ±} {f g : Ξ± β†’ Ξ²} {a : Ξ±} (h : f =αΆ [𝓝[s] a] g) (hmem : a ∈ s) : f a = g a := h.self_of_nhdsWithin hmem #align filter.eventually_eq.eq_of_nhds_within Filter.EventuallyEq.eq_of_nhdsWithin theorem eventually_nhdsWithin_of_eventually_nhds {Ξ± : Type*} [TopologicalSpace Ξ±] {s : Set Ξ±} {a : Ξ±} {p : Ξ± β†’ Prop} (h : βˆ€αΆ  x in 𝓝 a, p x) : βˆ€αΆ  x in 𝓝[s] a, p x := mem_nhdsWithin_of_mem_nhds h #align eventually_nhds_within_of_eventually_nhds eventually_nhdsWithin_of_eventually_nhds theorem mem_nhdsWithin_subtype {s : Set Ξ±} {a : { x // x ∈ s }} {t u : Set { x // x ∈ s }} : t ∈ 𝓝[u] a ↔ t ∈ comap ((↑) : s β†’ Ξ±) (𝓝[(↑) '' u] a) := by rw [nhdsWithin, nhds_subtype, principal_subtype, ← comap_inf, ← nhdsWithin] #align mem_nhds_within_subtype mem_nhdsWithin_subtype theorem nhdsWithin_subtype (s : Set Ξ±) (a : { x // x ∈ s }) (t : Set { x // x ∈ s }) : 𝓝[t] a = comap ((↑) : s β†’ Ξ±) (𝓝[(↑) '' t] a) := Filter.ext fun _ => mem_nhdsWithin_subtype #align nhds_within_subtype nhdsWithin_subtype theorem nhdsWithin_eq_map_subtype_coe {s : Set Ξ±} {a : Ξ±} (h : a ∈ s) : 𝓝[s] a = map ((↑) : s β†’ Ξ±) (𝓝 ⟨a, h⟩) := (map_nhds_subtype_val ⟨a, h⟩).symm #align nhds_within_eq_map_subtype_coe nhdsWithin_eq_map_subtype_coe theorem mem_nhds_subtype_iff_nhdsWithin {s : Set Ξ±} {a : s} {t : Set s} : t ∈ 𝓝 a ↔ (↑) '' t ∈ 𝓝[s] (a : Ξ±) := by rw [← map_nhds_subtype_val, image_mem_map_iff Subtype.val_injective] #align mem_nhds_subtype_iff_nhds_within mem_nhds_subtype_iff_nhdsWithin theorem preimage_coe_mem_nhds_subtype {s t : Set Ξ±} {a : s} : (↑) ⁻¹' t ∈ 𝓝 a ↔ t ∈ 𝓝[s] ↑a := by rw [← map_nhds_subtype_val, mem_map] #align preimage_coe_mem_nhds_subtype preimage_coe_mem_nhds_subtype theorem eventually_nhds_subtype_iff (s : Set Ξ±) (a : s) (P : Ξ± β†’ Prop) : (βˆ€αΆ  x : s in 𝓝 a, P x) ↔ βˆ€αΆ  x in 𝓝[s] a, P x := preimage_coe_mem_nhds_subtype theorem frequently_nhds_subtype_iff (s : Set Ξ±) (a : s) (P : Ξ± β†’ Prop) : (βˆƒαΆ  x : s in 𝓝 a, P x) ↔ βˆƒαΆ  x in 𝓝[s] a, P x := eventually_nhds_subtype_iff s a (Β¬ P Β·) |>.not theorem tendsto_nhdsWithin_iff_subtype {s : Set Ξ±} {a : Ξ±} (h : a ∈ s) (f : Ξ± β†’ Ξ²) (l : Filter Ξ²) : Tendsto f (𝓝[s] a) l ↔ Tendsto (s.restrict f) (𝓝 ⟨a, h⟩) l := by rw [nhdsWithin_eq_map_subtype_coe h, tendsto_map'_iff]; rfl #align tendsto_nhds_within_iff_subtype tendsto_nhdsWithin_iff_subtype variable [TopologicalSpace Ξ²] [TopologicalSpace Ξ³] [TopologicalSpace Ξ΄] theorem ContinuousWithinAt.tendsto {f : Ξ± β†’ Ξ²} {s : Set Ξ±} {x : Ξ±} (h : ContinuousWithinAt f s x) : Tendsto f (𝓝[s] x) (𝓝 (f x)) := h #align continuous_within_at.tendsto ContinuousWithinAt.tendsto theorem ContinuousOn.continuousWithinAt {f : Ξ± β†’ Ξ²} {s : Set Ξ±} {x : Ξ±} (hf : ContinuousOn f s) (hx : x ∈ s) : ContinuousWithinAt f s x := hf x hx #align continuous_on.continuous_within_at ContinuousOn.continuousWithinAt theorem continuousWithinAt_univ (f : Ξ± β†’ Ξ²) (x : Ξ±) : ContinuousWithinAt f Set.univ x ↔ ContinuousAt f x := by rw [ContinuousAt, ContinuousWithinAt, nhdsWithin_univ] #align continuous_within_at_univ continuousWithinAt_univ theorem continuous_iff_continuousOn_univ {f : Ξ± β†’ Ξ²} : Continuous f ↔ ContinuousOn f univ := by simp [continuous_iff_continuousAt, ContinuousOn, ContinuousAt, ContinuousWithinAt, nhdsWithin_univ] #align continuous_iff_continuous_on_univ continuous_iff_continuousOn_univ theorem continuousWithinAt_iff_continuousAt_restrict (f : Ξ± β†’ Ξ²) {x : Ξ±} {s : Set Ξ±} (h : x ∈ s) : ContinuousWithinAt f s x ↔ ContinuousAt (s.restrict f) ⟨x, h⟩ := tendsto_nhdsWithin_iff_subtype h f _ #align continuous_within_at_iff_continuous_at_restrict continuousWithinAt_iff_continuousAt_restrict theorem ContinuousWithinAt.tendsto_nhdsWithin {f : Ξ± β†’ Ξ²} {x : Ξ±} {s : Set Ξ±} {t : Set Ξ²} (h : ContinuousWithinAt f s x) (ht : MapsTo f s t) : Tendsto f (𝓝[s] x) (𝓝[t] f x) := tendsto_inf.2 ⟨h, tendsto_principal.2 <| mem_inf_of_right <| mem_principal.2 <| ht⟩ #align continuous_within_at.tendsto_nhds_within ContinuousWithinAt.tendsto_nhdsWithin theorem ContinuousWithinAt.tendsto_nhdsWithin_image {f : Ξ± β†’ Ξ²} {x : Ξ±} {s : Set Ξ±} (h : ContinuousWithinAt f s x) : Tendsto f (𝓝[s] x) (𝓝[f '' s] f x) := h.tendsto_nhdsWithin (mapsTo_image _ _) #align continuous_within_at.tendsto_nhds_within_image ContinuousWithinAt.tendsto_nhdsWithin_image theorem ContinuousWithinAt.prod_map {f : Ξ± β†’ Ξ³} {g : Ξ² β†’ Ξ΄} {s : Set Ξ±} {t : Set Ξ²} {x : Ξ±} {y : Ξ²} (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g t y) : ContinuousWithinAt (Prod.map f g) (s Γ—Λ’ t) (x, y) := by unfold ContinuousWithinAt at * rw [nhdsWithin_prod_eq, Prod.map, nhds_prod_eq] exact hf.prod_map hg #align continuous_within_at.prod_map ContinuousWithinAt.prod_map theorem continuousWithinAt_prod_of_discrete_left [DiscreteTopology Ξ±] {f : Ξ± Γ— Ξ² β†’ Ξ³} {s : Set (Ξ± Γ— Ξ²)} {x : Ξ± Γ— Ξ²} : ContinuousWithinAt f s x ↔ ContinuousWithinAt (f ⟨x.1, ·⟩) {b | (x.1, b) ∈ s} x.2 := by rw [← x.eta]; simp_rw [ContinuousWithinAt, nhdsWithin, nhds_prod_eq, nhds_discrete, pure_prod, ← map_inf_principal_preimage]; rfl theorem continuousWithinAt_prod_of_discrete_right [DiscreteTopology Ξ²] {f : Ξ± Γ— Ξ² β†’ Ξ³} {s : Set (Ξ± Γ— Ξ²)} {x : Ξ± Γ— Ξ²} : ContinuousWithinAt f s x ↔ ContinuousWithinAt (f ⟨·, x.2⟩) {a | (a, x.2) ∈ s} x.1 := by rw [← x.eta]; simp_rw [ContinuousWithinAt, nhdsWithin, nhds_prod_eq, nhds_discrete, prod_pure, ← map_inf_principal_preimage]; rfl theorem continuousAt_prod_of_discrete_left [DiscreteTopology Ξ±] {f : Ξ± Γ— Ξ² β†’ Ξ³} {x : Ξ± Γ— Ξ²} : ContinuousAt f x ↔ ContinuousAt (f ⟨x.1, ·⟩) x.2 := by simp_rw [← continuousWithinAt_univ]; exact continuousWithinAt_prod_of_discrete_left theorem continuousAt_prod_of_discrete_right [DiscreteTopology Ξ²] {f : Ξ± Γ— Ξ² β†’ Ξ³} {x : Ξ± Γ— Ξ²} : ContinuousAt f x ↔ ContinuousAt (f ⟨·, x.2⟩) x.1 := by simp_rw [← continuousWithinAt_univ]; exact continuousWithinAt_prod_of_discrete_right theorem continuousOn_prod_of_discrete_left [DiscreteTopology Ξ±] {f : Ξ± Γ— Ξ² β†’ Ξ³} {s : Set (Ξ± Γ— Ξ²)} : ContinuousOn f s ↔ βˆ€ a, ContinuousOn (f ⟨a, ·⟩) {b | (a, b) ∈ s} := by simp_rw [ContinuousOn, Prod.forall, continuousWithinAt_prod_of_discrete_left]; rfl theorem continuousOn_prod_of_discrete_right [DiscreteTopology Ξ²] {f : Ξ± Γ— Ξ² β†’ Ξ³} {s : Set (Ξ± Γ— Ξ²)} : ContinuousOn f s ↔ βˆ€ b, ContinuousOn (f ⟨·, b⟩) {a | (a, b) ∈ s} := by simp_rw [ContinuousOn, Prod.forall, continuousWithinAt_prod_of_discrete_right]; apply forall_swap theorem continuous_prod_of_discrete_left [DiscreteTopology Ξ±] {f : Ξ± Γ— Ξ² β†’ Ξ³} : Continuous f ↔ βˆ€ a, Continuous (f ⟨a, ·⟩) := by simp_rw [continuous_iff_continuousOn_univ]; exact continuousOn_prod_of_discrete_left theorem continuous_prod_of_discrete_right [DiscreteTopology Ξ²] {f : Ξ± Γ— Ξ² β†’ Ξ³} : Continuous f ↔ βˆ€ b, Continuous (f ⟨·, b⟩) := by simp_rw [continuous_iff_continuousOn_univ]; exact continuousOn_prod_of_discrete_right theorem isOpenMap_prod_of_discrete_left [DiscreteTopology Ξ±] {f : Ξ± Γ— Ξ² β†’ Ξ³} : IsOpenMap f ↔ βˆ€ a, IsOpenMap (f ⟨a, ·⟩) := by simp_rw [isOpenMap_iff_nhds_le, Prod.forall, nhds_prod_eq, nhds_discrete, pure_prod, map_map] rfl theorem isOpenMap_prod_of_discrete_right [DiscreteTopology Ξ²] {f : Ξ± Γ— Ξ² β†’ Ξ³} : IsOpenMap f ↔ βˆ€ b, IsOpenMap (f ⟨·, b⟩) := by simp_rw [isOpenMap_iff_nhds_le, Prod.forall, forall_swap (Ξ± := Ξ±) (Ξ² := Ξ²), nhds_prod_eq, nhds_discrete, prod_pure, map_map]; rfl theorem continuousWithinAt_pi {ΞΉ : Type*} {Ο€ : ΞΉ β†’ Type*} [βˆ€ i, TopologicalSpace (Ο€ i)] {f : Ξ± β†’ βˆ€ i, Ο€ i} {s : Set Ξ±} {x : Ξ±} : ContinuousWithinAt f s x ↔ βˆ€ i, ContinuousWithinAt (fun y => f y i) s x := tendsto_pi_nhds #align continuous_within_at_pi continuousWithinAt_pi theorem continuousOn_pi {ΞΉ : Type*} {Ο€ : ΞΉ β†’ Type*} [βˆ€ i, TopologicalSpace (Ο€ i)] {f : Ξ± β†’ βˆ€ i, Ο€ i} {s : Set Ξ±} : ContinuousOn f s ↔ βˆ€ i, ContinuousOn (fun y => f y i) s := ⟨fun h i x hx => tendsto_pi_nhds.1 (h x hx) i, fun h x hx => tendsto_pi_nhds.2 fun i => h i x hx⟩ #align continuous_on_pi continuousOn_pi @[fun_prop] theorem continuousOn_pi' {ΞΉ : Type*} {Ο€ : ΞΉ β†’ Type*} [βˆ€ i, TopologicalSpace (Ο€ i)] {f : Ξ± β†’ βˆ€ i, Ο€ i} {s : Set Ξ±} (hf : βˆ€ i, ContinuousOn (fun y => f y i) s) : ContinuousOn f s := continuousOn_pi.2 hf theorem ContinuousWithinAt.fin_insertNth {n} {Ο€ : Fin (n + 1) β†’ Type*} [βˆ€ i, TopologicalSpace (Ο€ i)] (i : Fin (n + 1)) {f : Ξ± β†’ Ο€ i} {a : Ξ±} {s : Set Ξ±} (hf : ContinuousWithinAt f s a) {g : Ξ± β†’ βˆ€ j : Fin n, Ο€ (i.succAbove j)} (hg : ContinuousWithinAt g s a) : ContinuousWithinAt (fun a => i.insertNth (f a) (g a)) s a := hf.tendsto.fin_insertNth i hg #align continuous_within_at.fin_insert_nth ContinuousWithinAt.fin_insertNth nonrec theorem ContinuousOn.fin_insertNth {n} {Ο€ : Fin (n + 1) β†’ Type*} [βˆ€ i, TopologicalSpace (Ο€ i)] (i : Fin (n + 1)) {f : Ξ± β†’ Ο€ i} {s : Set Ξ±} (hf : ContinuousOn f s) {g : Ξ± β†’ βˆ€ j : Fin n, Ο€ (i.succAbove j)} (hg : ContinuousOn g s) : ContinuousOn (fun a => i.insertNth (f a) (g a)) s := fun a ha => (hf a ha).fin_insertNth i (hg a ha) #align continuous_on.fin_insert_nth ContinuousOn.fin_insertNth theorem continuousOn_iff {f : Ξ± β†’ Ξ²} {s : Set Ξ±} : ContinuousOn f s ↔ βˆ€ x ∈ s, βˆ€ t : Set Ξ², IsOpen t β†’ f x ∈ t β†’ βˆƒ u, IsOpen u ∧ x ∈ u ∧ u ∩ s βŠ† f ⁻¹' t := by simp only [ContinuousOn, ContinuousWithinAt, tendsto_nhds, mem_nhdsWithin] #align continuous_on_iff continuousOn_iff theorem continuousOn_iff_continuous_restrict {f : Ξ± β†’ Ξ²} {s : Set Ξ±} : ContinuousOn f s ↔ Continuous (s.restrict f) := by rw [ContinuousOn, continuous_iff_continuousAt]; constructor Β· rintro h ⟨x, xs⟩ exact (continuousWithinAt_iff_continuousAt_restrict f xs).mp (h x xs) intro h x xs exact (continuousWithinAt_iff_continuousAt_restrict f xs).mpr (h ⟨x, xs⟩) #align continuous_on_iff_continuous_restrict continuousOn_iff_continuous_restrict -- Porting note: 2 new lemmas alias ⟨ContinuousOn.restrict, _⟩ := continuousOn_iff_continuous_restrict theorem ContinuousOn.restrict_mapsTo {f : Ξ± β†’ Ξ²} {s : Set Ξ±} {t : Set Ξ²} (hf : ContinuousOn f s) (ht : MapsTo f s t) : Continuous (ht.restrict f s t) := hf.restrict.codRestrict _ theorem continuousOn_iff' {f : Ξ± β†’ Ξ²} {s : Set Ξ±} : ContinuousOn f s ↔ βˆ€ t : Set Ξ², IsOpen t β†’ βˆƒ u, IsOpen u ∧ f ⁻¹' t ∩ s = u ∩ s := by have : βˆ€ t, IsOpen (s.restrict f ⁻¹' t) ↔ βˆƒ u : Set Ξ±, IsOpen u ∧ f ⁻¹' t ∩ s = u ∩ s := by intro t rw [isOpen_induced_iff, Set.restrict_eq, Set.preimage_comp] simp only [Subtype.preimage_coe_eq_preimage_coe_iff] constructor <;> Β· rintro ⟨u, ou, useq⟩ exact ⟨u, ou, by simpa only [Set.inter_comm, eq_comm] using useq⟩ rw [continuousOn_iff_continuous_restrict, continuous_def]; simp only [this] #align continuous_on_iff' continuousOn_iff' theorem ContinuousOn.mono_dom {Ξ± Ξ² : Type*} {t₁ tβ‚‚ : TopologicalSpace Ξ±} {t₃ : TopologicalSpace Ξ²} (h₁ : tβ‚‚ ≀ t₁) {s : Set Ξ±} {f : Ξ± β†’ Ξ²} (hβ‚‚ : @ContinuousOn Ξ± Ξ² t₁ t₃ f s) : @ContinuousOn Ξ± Ξ² tβ‚‚ t₃ f s := fun x hx _u hu => map_mono (inf_le_inf_right _ <| nhds_mono h₁) (hβ‚‚ x hx hu) #align continuous_on.mono_dom ContinuousOn.mono_dom theorem ContinuousOn.mono_rng {Ξ± Ξ² : Type*} {t₁ : TopologicalSpace Ξ±} {tβ‚‚ t₃ : TopologicalSpace Ξ²} (h₁ : tβ‚‚ ≀ t₃) {s : Set Ξ±} {f : Ξ± β†’ Ξ²} (hβ‚‚ : @ContinuousOn Ξ± Ξ² t₁ tβ‚‚ f s) : @ContinuousOn Ξ± Ξ² t₁ t₃ f s := fun x hx _u hu => hβ‚‚ x hx <| nhds_mono h₁ hu #align continuous_on.mono_rng ContinuousOn.mono_rng theorem continuousOn_iff_isClosed {f : Ξ± β†’ Ξ²} {s : Set Ξ±} : ContinuousOn f s ↔ βˆ€ t : Set Ξ², IsClosed t β†’ βˆƒ u, IsClosed u ∧ f ⁻¹' t ∩ s = u ∩ s := by have : βˆ€ t, IsClosed (s.restrict f ⁻¹' t) ↔ βˆƒ u : Set Ξ±, IsClosed u ∧ f ⁻¹' t ∩ s = u ∩ s := by intro t rw [isClosed_induced_iff, Set.restrict_eq, Set.preimage_comp] simp only [Subtype.preimage_coe_eq_preimage_coe_iff, eq_comm, Set.inter_comm s] rw [continuousOn_iff_continuous_restrict, continuous_iff_isClosed]; simp only [this] #align continuous_on_iff_is_closed continuousOn_iff_isClosed theorem ContinuousOn.prod_map {f : Ξ± β†’ Ξ³} {g : Ξ² β†’ Ξ΄} {s : Set Ξ±} {t : Set Ξ²} (hf : ContinuousOn f s) (hg : ContinuousOn g t) : ContinuousOn (Prod.map f g) (s Γ—Λ’ t) := fun ⟨x, y⟩ ⟨hx, hy⟩ => ContinuousWithinAt.prod_map (hf x hx) (hg y hy) #align continuous_on.prod_map ContinuousOn.prod_map theorem continuous_of_cover_nhds {ΞΉ : Sort*} {f : Ξ± β†’ Ξ²} {s : ΞΉ β†’ Set Ξ±} (hs : βˆ€ x : Ξ±, βˆƒ i, s i ∈ 𝓝 x) (hf : βˆ€ i, ContinuousOn f (s i)) : Continuous f := continuous_iff_continuousAt.mpr fun x ↦ let ⟨i, hi⟩ := hs x; by rw [ContinuousAt, ← nhdsWithin_eq_nhds.2 hi] exact hf _ _ (mem_of_mem_nhds hi) #align continuous_of_cover_nhds continuous_of_cover_nhds theorem continuousOn_empty (f : Ξ± β†’ Ξ²) : ContinuousOn f βˆ… := fun _ => False.elim #align continuous_on_empty continuousOn_empty @[simp] theorem continuousOn_singleton (f : Ξ± β†’ Ξ²) (a : Ξ±) : ContinuousOn f {a} := forall_eq.2 <| by simpa only [ContinuousWithinAt, nhdsWithin_singleton, tendsto_pure_left] using fun s => mem_of_mem_nhds #align continuous_on_singleton continuousOn_singleton theorem Set.Subsingleton.continuousOn {s : Set Ξ±} (hs : s.Subsingleton) (f : Ξ± β†’ Ξ²) : ContinuousOn f s := hs.induction_on (continuousOn_empty f) (continuousOn_singleton f) #align set.subsingleton.continuous_on Set.Subsingleton.continuousOn theorem nhdsWithin_le_comap {x : Ξ±} {s : Set Ξ±} {f : Ξ± β†’ Ξ²} (ctsf : ContinuousWithinAt f s x) : 𝓝[s] x ≀ comap f (𝓝[f '' s] f x) := ctsf.tendsto_nhdsWithin_image.le_comap #align nhds_within_le_comap nhdsWithin_le_comap @[simp] theorem comap_nhdsWithin_range {Ξ±} (f : Ξ± β†’ Ξ²) (y : Ξ²) : comap f (𝓝[range f] y) = comap f (𝓝 y) := comap_inf_principal_range #align comap_nhds_within_range comap_nhdsWithin_range theorem ContinuousWithinAt.mono {f : Ξ± β†’ Ξ²} {s t : Set Ξ±} {x : Ξ±} (h : ContinuousWithinAt f t x) (hs : s βŠ† t) : ContinuousWithinAt f s x := h.mono_left (nhdsWithin_mono x hs) #align continuous_within_at.mono ContinuousWithinAt.mono theorem ContinuousWithinAt.mono_of_mem {f : Ξ± β†’ Ξ²} {s t : Set Ξ±} {x : Ξ±} (h : ContinuousWithinAt f t x) (hs : t ∈ 𝓝[s] x) : ContinuousWithinAt f s x := h.mono_left (nhdsWithin_le_of_mem hs) #align continuous_within_at.mono_of_mem ContinuousWithinAt.mono_of_mem theorem continuousWithinAt_congr_nhds {f : Ξ± β†’ Ξ²} {s t : Set Ξ±} {x : Ξ±} (h : 𝓝[s] x = 𝓝[t] x) : ContinuousWithinAt f s x ↔ ContinuousWithinAt f t x := by simp only [ContinuousWithinAt, h] theorem continuousWithinAt_inter' {f : Ξ± β†’ Ξ²} {s t : Set Ξ±} {x : Ξ±} (h : t ∈ 𝓝[s] x) : ContinuousWithinAt f (s ∩ t) x ↔ ContinuousWithinAt f s x := by simp [ContinuousWithinAt, nhdsWithin_restrict'' s h] #align continuous_within_at_inter' continuousWithinAt_inter' theorem continuousWithinAt_inter {f : Ξ± β†’ Ξ²} {s t : Set Ξ±} {x : Ξ±} (h : t ∈ 𝓝 x) : ContinuousWithinAt f (s ∩ t) x ↔ ContinuousWithinAt f s x := by simp [ContinuousWithinAt, nhdsWithin_restrict' s h] #align continuous_within_at_inter continuousWithinAt_inter theorem continuousWithinAt_union {f : Ξ± β†’ Ξ²} {s t : Set Ξ±} {x : Ξ±} : ContinuousWithinAt f (s βˆͺ t) x ↔ ContinuousWithinAt f s x ∧ ContinuousWithinAt f t x := by simp only [ContinuousWithinAt, nhdsWithin_union, tendsto_sup] #align continuous_within_at_union continuousWithinAt_union theorem ContinuousWithinAt.union {f : Ξ± β†’ Ξ²} {s t : Set Ξ±} {x : Ξ±} (hs : ContinuousWithinAt f s x) (ht : ContinuousWithinAt f t x) : ContinuousWithinAt f (s βˆͺ t) x := continuousWithinAt_union.2 ⟨hs, ht⟩ #align continuous_within_at.union ContinuousWithinAt.union theorem ContinuousWithinAt.mem_closure_image {f : Ξ± β†’ Ξ²} {s : Set Ξ±} {x : Ξ±} (h : ContinuousWithinAt f s x) (hx : x ∈ closure s) : f x ∈ closure (f '' s) := haveI := mem_closure_iff_nhdsWithin_neBot.1 hx mem_closure_of_tendsto h <| mem_of_superset self_mem_nhdsWithin (subset_preimage_image f s) #align continuous_within_at.mem_closure_image ContinuousWithinAt.mem_closure_image theorem ContinuousWithinAt.mem_closure {f : Ξ± β†’ Ξ²} {s : Set Ξ±} {x : Ξ±} {A : Set Ξ²} (h : ContinuousWithinAt f s x) (hx : x ∈ closure s) (hA : MapsTo f s A) : f x ∈ closure A := closure_mono (image_subset_iff.2 hA) (h.mem_closure_image hx) #align continuous_within_at.mem_closure ContinuousWithinAt.mem_closure theorem Set.MapsTo.closure_of_continuousWithinAt {f : Ξ± β†’ Ξ²} {s : Set Ξ±} {t : Set Ξ²} (h : MapsTo f s t) (hc : βˆ€ x ∈ closure s, ContinuousWithinAt f s x) : MapsTo f (closure s) (closure t) := fun x hx => (hc x hx).mem_closure hx h #align set.maps_to.closure_of_continuous_within_at Set.MapsTo.closure_of_continuousWithinAt theorem Set.MapsTo.closure_of_continuousOn {f : Ξ± β†’ Ξ²} {s : Set Ξ±} {t : Set Ξ²} (h : MapsTo f s t) (hc : ContinuousOn f (closure s)) : MapsTo f (closure s) (closure t) := h.closure_of_continuousWithinAt fun x hx => (hc x hx).mono subset_closure #align set.maps_to.closure_of_continuous_on Set.MapsTo.closure_of_continuousOn theorem ContinuousWithinAt.image_closure {f : Ξ± β†’ Ξ²} {s : Set Ξ±} (hf : βˆ€ x ∈ closure s, ContinuousWithinAt f s x) : f '' closure s βŠ† closure (f '' s) := ((mapsTo_image f s).closure_of_continuousWithinAt hf).image_subset #align continuous_within_at.image_closure ContinuousWithinAt.image_closure theorem ContinuousOn.image_closure {f : Ξ± β†’ Ξ²} {s : Set Ξ±} (hf : ContinuousOn f (closure s)) : f '' closure s βŠ† closure (f '' s) := ContinuousWithinAt.image_closure fun x hx => (hf x hx).mono subset_closure #align continuous_on.image_closure ContinuousOn.image_closure @[simp] theorem continuousWithinAt_singleton {f : Ξ± β†’ Ξ²} {x : Ξ±} : ContinuousWithinAt f {x} x := by simp only [ContinuousWithinAt, nhdsWithin_singleton, tendsto_pure_nhds] #align continuous_within_at_singleton continuousWithinAt_singleton @[simp] theorem continuousWithinAt_insert_self {f : Ξ± β†’ Ξ²} {x : Ξ±} {s : Set Ξ±} : ContinuousWithinAt f (insert x s) x ↔ ContinuousWithinAt f s x := by simp only [← singleton_union, continuousWithinAt_union, continuousWithinAt_singleton, true_and_iff] #align continuous_within_at_insert_self continuousWithinAt_insert_self alias ⟨_, ContinuousWithinAt.insert_self⟩ := continuousWithinAt_insert_self #align continuous_within_at.insert_self ContinuousWithinAt.insert_self theorem ContinuousWithinAt.diff_iff {f : Ξ± β†’ Ξ²} {s t : Set Ξ±} {x : Ξ±} (ht : ContinuousWithinAt f t x) : ContinuousWithinAt f (s \ t) x ↔ ContinuousWithinAt f s x := ⟨fun h => (h.union ht).mono <| by simp only [diff_union_self, subset_union_left], fun h => h.mono diff_subset⟩ #align continuous_within_at.diff_iff ContinuousWithinAt.diff_iff @[simp] theorem continuousWithinAt_diff_self {f : Ξ± β†’ Ξ²} {s : Set Ξ±} {x : Ξ±} : ContinuousWithinAt f (s \ {x}) x ↔ ContinuousWithinAt f s x := continuousWithinAt_singleton.diff_iff #align continuous_within_at_diff_self continuousWithinAt_diff_self @[simp]
Mathlib/Topology/ContinuousOn.lean
830
832
theorem continuousWithinAt_compl_self {f : Ξ± β†’ Ξ²} {a : Ξ±} : ContinuousWithinAt f {a}ᢜ a ↔ ContinuousAt f a := by
rw [compl_eq_univ_diff, continuousWithinAt_diff_self, continuousWithinAt_univ]
import Mathlib.Algebra.CharZero.Lemmas import Mathlib.Algebra.Order.Interval.Set.Group import Mathlib.Algebra.Group.Int import Mathlib.Data.Int.Lemmas import Mathlib.Data.Set.Subsingleton import Mathlib.Init.Data.Nat.Lemmas import Mathlib.Order.GaloisConnection import Mathlib.Tactic.Abel import Mathlib.Tactic.Linarith import Mathlib.Tactic.Positivity #align_import algebra.order.floor from "leanprover-community/mathlib"@"afdb43429311b885a7988ea15d0bac2aac80f69c" open Set variable {F Ξ± Ξ² : Type*} class FloorSemiring (Ξ±) [OrderedSemiring Ξ±] where floor : Ξ± β†’ β„• ceil : Ξ± β†’ β„• floor_of_neg {a : Ξ±} (ha : a < 0) : floor a = 0 gc_floor {a : Ξ±} {n : β„•} (ha : 0 ≀ a) : n ≀ floor a ↔ (n : Ξ±) ≀ a gc_ceil : GaloisConnection ceil (↑) #align floor_semiring FloorSemiring instance : FloorSemiring β„• where floor := id ceil := id floor_of_neg ha := (Nat.not_lt_zero _ ha).elim gc_floor _ := by rw [Nat.cast_id] rfl gc_ceil n a := by rw [Nat.cast_id] rfl namespace Nat theorem subsingleton_floorSemiring {Ξ±} [LinearOrderedSemiring Ξ±] : Subsingleton (FloorSemiring Ξ±) := by refine ⟨fun H₁ Hβ‚‚ => ?_⟩ have : H₁.ceil = Hβ‚‚.ceil := funext fun a => (H₁.gc_ceil.l_unique Hβ‚‚.gc_ceil) fun n => rfl have : H₁.floor = Hβ‚‚.floor := by ext a cases' lt_or_le a 0 with h h Β· rw [H₁.floor_of_neg, Hβ‚‚.floor_of_neg] <;> exact h Β· refine eq_of_forall_le_iff fun n => ?_ rw [H₁.gc_floor, Hβ‚‚.gc_floor] <;> exact h cases H₁ cases Hβ‚‚ congr #align subsingleton_floor_semiring subsingleton_floorSemiring class FloorRing (Ξ±) [LinearOrderedRing Ξ±] where floor : Ξ± β†’ β„€ ceil : Ξ± β†’ β„€ gc_coe_floor : GaloisConnection (↑) floor gc_ceil_coe : GaloisConnection ceil (↑) #align floor_ring FloorRing instance : FloorRing β„€ where floor := id ceil := id gc_coe_floor a b := by rw [Int.cast_id] rfl gc_ceil_coe a b := by rw [Int.cast_id] rfl def FloorRing.ofFloor (Ξ±) [LinearOrderedRing Ξ±] (floor : Ξ± β†’ β„€) (gc_coe_floor : GaloisConnection (↑) floor) : FloorRing Ξ± := { floor ceil := fun a => -floor (-a) gc_coe_floor gc_ceil_coe := fun a z => by rw [neg_le, ← gc_coe_floor, Int.cast_neg, neg_le_neg_iff] } #align floor_ring.of_floor FloorRing.ofFloor def FloorRing.ofCeil (Ξ±) [LinearOrderedRing Ξ±] (ceil : Ξ± β†’ β„€) (gc_ceil_coe : GaloisConnection ceil (↑)) : FloorRing Ξ± := { floor := fun a => -ceil (-a) ceil gc_coe_floor := fun a z => by rw [le_neg, gc_ceil_coe, Int.cast_neg, neg_le_neg_iff] gc_ceil_coe } #align floor_ring.of_ceil FloorRing.ofCeil namespace Int variable [LinearOrderedRing Ξ±] [FloorRing Ξ±] {z : β„€} {a : Ξ±} def floor : Ξ± β†’ β„€ := FloorRing.floor #align int.floor Int.floor def ceil : Ξ± β†’ β„€ := FloorRing.ceil #align int.ceil Int.ceil def fract (a : Ξ±) : Ξ± := a - floor a #align int.fract Int.fract @[simp] theorem floor_int : (Int.floor : β„€ β†’ β„€) = id := rfl #align int.floor_int Int.floor_int @[simp] theorem ceil_int : (Int.ceil : β„€ β†’ β„€) = id := rfl #align int.ceil_int Int.ceil_int @[simp] theorem fract_int : (Int.fract : β„€ β†’ β„€) = 0 := funext fun x => by simp [fract] #align int.fract_int Int.fract_int @[inherit_doc] notation "⌊" a "βŒ‹" => Int.floor a @[inherit_doc] notation "⌈" a "βŒ‰" => Int.ceil a -- Mathematical notation for `fract a` is usually `{a}`. Let's not even go there. @[simp] theorem floorRing_floor_eq : @FloorRing.floor = @Int.floor := rfl #align int.floor_ring_floor_eq Int.floorRing_floor_eq @[simp] theorem floorRing_ceil_eq : @FloorRing.ceil = @Int.ceil := rfl #align int.floor_ring_ceil_eq Int.floorRing_ceil_eq theorem gc_coe_floor : GaloisConnection ((↑) : β„€ β†’ Ξ±) floor := FloorRing.gc_coe_floor #align int.gc_coe_floor Int.gc_coe_floor theorem le_floor : z ≀ ⌊aβŒ‹ ↔ (z : Ξ±) ≀ a := (gc_coe_floor z a).symm #align int.le_floor Int.le_floor theorem floor_lt : ⌊aβŒ‹ < z ↔ a < z := lt_iff_lt_of_le_iff_le le_floor #align int.floor_lt Int.floor_lt theorem floor_le (a : Ξ±) : (⌊aβŒ‹ : Ξ±) ≀ a := gc_coe_floor.l_u_le a #align int.floor_le Int.floor_le theorem floor_nonneg : 0 ≀ ⌊aβŒ‹ ↔ 0 ≀ a := by rw [le_floor, Int.cast_zero] #align int.floor_nonneg Int.floor_nonneg @[simp] theorem floor_le_sub_one_iff : ⌊aβŒ‹ ≀ z - 1 ↔ a < z := by rw [← floor_lt, le_sub_one_iff] #align int.floor_le_sub_one_iff Int.floor_le_sub_one_iff @[simp] theorem floor_le_neg_one_iff : ⌊aβŒ‹ ≀ -1 ↔ a < 0 := by rw [← zero_sub (1 : β„€), floor_le_sub_one_iff, cast_zero] #align int.floor_le_neg_one_iff Int.floor_le_neg_one_iff theorem floor_nonpos (ha : a ≀ 0) : ⌊aβŒ‹ ≀ 0 := by rw [← @cast_le Ξ±, Int.cast_zero] exact (floor_le a).trans ha #align int.floor_nonpos Int.floor_nonpos theorem lt_succ_floor (a : Ξ±) : a < ⌊aβŒ‹.succ := floor_lt.1 <| Int.lt_succ_self _ #align int.lt_succ_floor Int.lt_succ_floor @[simp] theorem lt_floor_add_one (a : Ξ±) : a < ⌊aβŒ‹ + 1 := by simpa only [Int.succ, Int.cast_add, Int.cast_one] using lt_succ_floor a #align int.lt_floor_add_one Int.lt_floor_add_one @[simp] theorem sub_one_lt_floor (a : Ξ±) : a - 1 < ⌊aβŒ‹ := sub_lt_iff_lt_add.2 (lt_floor_add_one a) #align int.sub_one_lt_floor Int.sub_one_lt_floor @[simp] theorem floor_intCast (z : β„€) : ⌊(z : Ξ±)βŒ‹ = z := eq_of_forall_le_iff fun a => by rw [le_floor, Int.cast_le] #align int.floor_int_cast Int.floor_intCast @[simp] theorem floor_natCast (n : β„•) : ⌊(n : Ξ±)βŒ‹ = n := eq_of_forall_le_iff fun a => by rw [le_floor, ← cast_natCast, cast_le] #align int.floor_nat_cast Int.floor_natCast @[simp] theorem floor_zero : ⌊(0 : Ξ±)βŒ‹ = 0 := by rw [← cast_zero, floor_intCast] #align int.floor_zero Int.floor_zero @[simp] theorem floor_one : ⌊(1 : Ξ±)βŒ‹ = 1 := by rw [← cast_one, floor_intCast] #align int.floor_one Int.floor_one -- See note [no_index around OfNat.ofNat] @[simp] theorem floor_ofNat (n : β„•) [n.AtLeastTwo] : ⌊(no_index (OfNat.ofNat n : Ξ±))βŒ‹ = n := floor_natCast n @[mono] theorem floor_mono : Monotone (floor : Ξ± β†’ β„€) := gc_coe_floor.monotone_u #align int.floor_mono Int.floor_mono @[gcongr] theorem floor_le_floor : βˆ€ x y : Ξ±, x ≀ y β†’ ⌊xβŒ‹ ≀ ⌊yβŒ‹ := floor_mono theorem floor_pos : 0 < ⌊aβŒ‹ ↔ 1 ≀ a := by -- Porting note: broken `convert le_floor` rw [Int.lt_iff_add_one_le, zero_add, le_floor, cast_one] #align int.floor_pos Int.floor_pos @[simp] theorem floor_add_int (a : Ξ±) (z : β„€) : ⌊a + zβŒ‹ = ⌊aβŒ‹ + z := eq_of_forall_le_iff fun a => by rw [le_floor, ← sub_le_iff_le_add, ← sub_le_iff_le_add, le_floor, Int.cast_sub] #align int.floor_add_int Int.floor_add_int @[simp] theorem floor_add_one (a : Ξ±) : ⌊a + 1βŒ‹ = ⌊aβŒ‹ + 1 := by -- Porting note: broken `convert floor_add_int a 1` rw [← cast_one, floor_add_int] #align int.floor_add_one Int.floor_add_one theorem le_floor_add (a b : Ξ±) : ⌊aβŒ‹ + ⌊bβŒ‹ ≀ ⌊a + bβŒ‹ := by rw [le_floor, Int.cast_add] exact add_le_add (floor_le _) (floor_le _) #align int.le_floor_add Int.le_floor_add theorem le_floor_add_floor (a b : Ξ±) : ⌊a + bβŒ‹ - 1 ≀ ⌊aβŒ‹ + ⌊bβŒ‹ := by rw [← sub_le_iff_le_add, le_floor, Int.cast_sub, sub_le_comm, Int.cast_sub, Int.cast_one] refine le_trans ?_ (sub_one_lt_floor _).le rw [sub_le_iff_le_add', ← add_sub_assoc, sub_le_sub_iff_right] exact floor_le _ #align int.le_floor_add_floor Int.le_floor_add_floor @[simp] theorem floor_int_add (z : β„€) (a : Ξ±) : βŒŠβ†‘z + aβŒ‹ = z + ⌊aβŒ‹ := by simpa only [add_comm] using floor_add_int a z #align int.floor_int_add Int.floor_int_add @[simp]
Mathlib/Algebra/Order/Floor.lean
802
803
theorem floor_add_nat (a : Ξ±) (n : β„•) : ⌊a + nβŒ‹ = ⌊aβŒ‹ + n := by
rw [← Int.cast_natCast, floor_add_int]
import Mathlib.MeasureTheory.Measure.Doubling import Mathlib.MeasureTheory.Covering.Vitali import Mathlib.MeasureTheory.Covering.Differentiation #align_import measure_theory.covering.density_theorem from "leanprover-community/mathlib"@"5f6e827d81dfbeb6151d7016586ceeb0099b9655" noncomputable section open Set Filter Metric MeasureTheory TopologicalSpace open scoped NNReal Topology namespace IsUnifLocDoublingMeasure variable {Ξ± : Type*} [MetricSpace Ξ±] [MeasurableSpace Ξ±] (ΞΌ : Measure Ξ±) [IsUnifLocDoublingMeasure ΞΌ] section variable [SecondCountableTopology Ξ±] [BorelSpace Ξ±] [IsLocallyFiniteMeasure ΞΌ] open scoped Topology irreducible_def vitaliFamily (K : ℝ) : VitaliFamily ΞΌ := by let R := scalingScaleOf ΞΌ (max (4 * K + 3) 3) have Rpos : 0 < R := scalingScaleOf_pos _ _ have A : βˆ€ x : Ξ±, βˆƒαΆ  r in 𝓝[>] (0 : ℝ), ΞΌ (closedBall x (3 * r)) ≀ scalingConstantOf ΞΌ (max (4 * K + 3) 3) * ΞΌ (closedBall x r) := by intro x apply frequently_iff.2 fun {U} hU => ?_ obtain ⟨Ρ, Ξ΅pos, hΡ⟩ := mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 hU refine ⟨min Ξ΅ R, hΞ΅ ⟨lt_min Ξ΅pos Rpos, min_le_left _ _⟩, ?_⟩ exact measure_mul_le_scalingConstantOf_mul ΞΌ ⟨zero_lt_three, le_max_right _ _⟩ (min_le_right _ _) exact (Vitali.vitaliFamily ΞΌ (scalingConstantOf ΞΌ (max (4 * K + 3) 3)) A).enlarge (R / 4) (by linarith) #align is_unif_loc_doubling_measure.vitali_family IsUnifLocDoublingMeasure.vitaliFamily theorem closedBall_mem_vitaliFamily_of_dist_le_mul {K : ℝ} {x y : Ξ±} {r : ℝ} (h : dist x y ≀ K * r) (rpos : 0 < r) : closedBall y r ∈ (vitaliFamily ΞΌ K).setsAt x := by let R := scalingScaleOf ΞΌ (max (4 * K + 3) 3) simp only [vitaliFamily, VitaliFamily.enlarge, Vitali.vitaliFamily, mem_union, mem_setOf_eq, isClosed_ball, true_and_iff, (nonempty_ball.2 rpos).mono ball_subset_interior_closedBall, measurableSet_closedBall] by_cases H : closedBall y r βŠ† closedBall x (R / 4) swap; Β· exact Or.inr H left rcases le_or_lt r R with (hr | hr) Β· refine ⟨(K + 1) * r, ?_⟩ constructor Β· apply closedBall_subset_closedBall' rw [dist_comm] linarith Β· have I1 : closedBall x (3 * ((K + 1) * r)) βŠ† closedBall y ((4 * K + 3) * r) := by apply closedBall_subset_closedBall' linarith have I2 : closedBall y ((4 * K + 3) * r) βŠ† closedBall y (max (4 * K + 3) 3 * r) := by apply closedBall_subset_closedBall exact mul_le_mul_of_nonneg_right (le_max_left _ _) rpos.le apply (measure_mono (I1.trans I2)).trans exact measure_mul_le_scalingConstantOf_mul _ ⟨zero_lt_three.trans_le (le_max_right _ _), le_rfl⟩ hr Β· refine ⟨R / 4, H, ?_⟩ have : closedBall x (3 * (R / 4)) βŠ† closedBall y r := by apply closedBall_subset_closedBall' have A : y ∈ closedBall y r := mem_closedBall_self rpos.le have B := mem_closedBall'.1 (H A) linarith apply (measure_mono this).trans _ refine le_mul_of_one_le_left (zero_le _) ?_ exact ENNReal.one_le_coe_iff.2 (le_max_right _ _) #align is_unif_loc_doubling_measure.closed_ball_mem_vitali_family_of_dist_le_mul IsUnifLocDoublingMeasure.closedBall_mem_vitaliFamily_of_dist_le_mul theorem tendsto_closedBall_filterAt {K : ℝ} {x : Ξ±} {ΞΉ : Type*} {l : Filter ΞΉ} (w : ΞΉ β†’ Ξ±) (Ξ΄ : ΞΉ β†’ ℝ) (Ξ΄lim : Tendsto Ξ΄ l (𝓝[>] 0)) (xmem : βˆ€αΆ  j in l, x ∈ closedBall (w j) (K * Ξ΄ j)) : Tendsto (fun j => closedBall (w j) (Ξ΄ j)) l ((vitaliFamily ΞΌ K).filterAt x) := by refine (vitaliFamily ΞΌ K).tendsto_filterAt_iff.mpr ⟨?_, fun Ξ΅ hΞ΅ => ?_⟩ Β· filter_upwards [xmem, Ξ΄lim self_mem_nhdsWithin] with j hj h'j exact closedBall_mem_vitaliFamily_of_dist_le_mul ΞΌ hj h'j Β· rcases l.eq_or_neBot with rfl | h Β· simp have hK : 0 ≀ K := by rcases (xmem.and (Ξ΄lim self_mem_nhdsWithin)).exists with ⟨j, hj, h'j⟩ have : 0 ≀ K * Ξ΄ j := nonempty_closedBall.1 ⟨x, hj⟩ exact (mul_nonneg_iff_left_nonneg_of_pos (mem_Ioi.1 h'j)).1 this have Ξ΄pos := eventually_mem_of_tendsto_nhdsWithin Ξ΄lim replace Ξ΄lim := tendsto_nhds_of_tendsto_nhdsWithin Ξ΄lim replace hK : 0 < K + 1 := by linarith apply (((Metric.tendsto_nhds.mp Ξ΄lim _ (div_pos hΞ΅ hK)).and Ξ΄pos).and xmem).mono rintro j ⟨⟨hjΞ΅, hjβ‚€ : 0 < Ξ΄ j⟩, hx⟩ y hy replace hjΞ΅ : (K + 1) * Ξ΄ j < Ξ΅ := by simpa [abs_eq_self.mpr hjβ‚€.le] using (lt_div_iff' hK).mp hjΞ΅ simp only [mem_closedBall] at hx hy ⊒ linarith [dist_triangle_right y x (w j)] #align is_unif_loc_doubling_measure.tendsto_closed_ball_filter_at IsUnifLocDoublingMeasure.tendsto_closedBall_filterAt end section Applications variable [SecondCountableTopology Ξ±] [BorelSpace Ξ±] [IsLocallyFiniteMeasure ΞΌ] {E : Type*} [NormedAddCommGroup E]
Mathlib/MeasureTheory/Covering/DensityTheorem.lean
146
151
theorem ae_tendsto_measure_inter_div (S : Set Ξ±) (K : ℝ) : βˆ€α΅ x βˆ‚ΞΌ.restrict S, βˆ€ {ΞΉ : Type*} {l : Filter ΞΉ} (w : ΞΉ β†’ Ξ±) (Ξ΄ : ΞΉ β†’ ℝ) (Ξ΄lim : Tendsto Ξ΄ l (𝓝[>] 0)) (xmem : βˆ€αΆ  j in l, x ∈ closedBall (w j) (K * Ξ΄ j)), Tendsto (fun j => ΞΌ (S ∩ closedBall (w j) (Ξ΄ j)) / ΞΌ (closedBall (w j) (Ξ΄ j))) l (𝓝 1) := by
filter_upwards [(vitaliFamily ΞΌ K).ae_tendsto_measure_inter_div S] with x hx ΞΉ l w Ξ΄ Ξ΄lim xmem using hx.comp (tendsto_closedBall_filterAt ΞΌ _ _ Ξ΄lim xmem)
import Mathlib.Data.Nat.Prime import Mathlib.Data.PNat.Basic #align_import data.pnat.prime from "leanprover-community/mathlib"@"09597669f02422ed388036273d8848119699c22f" namespace PNat open Nat def gcd (n m : β„•+) : β„•+ := ⟨Nat.gcd (n : β„•) (m : β„•), Nat.gcd_pos_of_pos_left (m : β„•) n.pos⟩ #align pnat.gcd PNat.gcd def lcm (n m : β„•+) : β„•+ := ⟨Nat.lcm (n : β„•) (m : β„•), by let h := mul_pos n.pos m.pos rw [← gcd_mul_lcm (n : β„•) (m : β„•), mul_comm] at h exact pos_of_dvd_of_pos (Dvd.intro (Nat.gcd (n : β„•) (m : β„•)) rfl) h⟩ #align pnat.lcm PNat.lcm @[simp, norm_cast] theorem gcd_coe (n m : β„•+) : (gcd n m : β„•) = Nat.gcd n m := rfl #align pnat.gcd_coe PNat.gcd_coe @[simp, norm_cast] theorem lcm_coe (n m : β„•+) : (lcm n m : β„•) = Nat.lcm n m := rfl #align pnat.lcm_coe PNat.lcm_coe theorem gcd_dvd_left (n m : β„•+) : gcd n m ∣ n := dvd_iff.2 (Nat.gcd_dvd_left (n : β„•) (m : β„•)) #align pnat.gcd_dvd_left PNat.gcd_dvd_left theorem gcd_dvd_right (n m : β„•+) : gcd n m ∣ m := dvd_iff.2 (Nat.gcd_dvd_right (n : β„•) (m : β„•)) #align pnat.gcd_dvd_right PNat.gcd_dvd_right theorem dvd_gcd {m n k : β„•+} (hm : k ∣ m) (hn : k ∣ n) : k ∣ gcd m n := dvd_iff.2 (Nat.dvd_gcd (dvd_iff.1 hm) (dvd_iff.1 hn)) #align pnat.dvd_gcd PNat.dvd_gcd theorem dvd_lcm_left (n m : β„•+) : n ∣ lcm n m := dvd_iff.2 (Nat.dvd_lcm_left (n : β„•) (m : β„•)) #align pnat.dvd_lcm_left PNat.dvd_lcm_left theorem dvd_lcm_right (n m : β„•+) : m ∣ lcm n m := dvd_iff.2 (Nat.dvd_lcm_right (n : β„•) (m : β„•)) #align pnat.dvd_lcm_right PNat.dvd_lcm_right theorem lcm_dvd {m n k : β„•+} (hm : m ∣ k) (hn : n ∣ k) : lcm m n ∣ k := dvd_iff.2 (@Nat.lcm_dvd (m : β„•) (n : β„•) (k : β„•) (dvd_iff.1 hm) (dvd_iff.1 hn)) #align pnat.lcm_dvd PNat.lcm_dvd theorem gcd_mul_lcm (n m : β„•+) : gcd n m * lcm n m = n * m := Subtype.eq (Nat.gcd_mul_lcm (n : β„•) (m : β„•)) #align pnat.gcd_mul_lcm PNat.gcd_mul_lcm theorem eq_one_of_lt_two {n : β„•+} : n < 2 β†’ n = 1 := by intro h; apply le_antisymm; swap Β· apply PNat.one_le Β· exact PNat.lt_add_one_iff.1 h #align pnat.eq_one_of_lt_two PNat.eq_one_of_lt_two section Coprime def Coprime (m n : β„•+) : Prop := m.gcd n = 1 #align pnat.coprime PNat.Coprime @[simp, norm_cast] theorem coprime_coe {m n : β„•+} : Nat.Coprime ↑m ↑n ↔ m.Coprime n := by unfold Nat.Coprime Coprime rw [← coe_inj] simp #align pnat.coprime_coe PNat.coprime_coe theorem Coprime.mul {k m n : β„•+} : m.Coprime k β†’ n.Coprime k β†’ (m * n).Coprime k := by repeat rw [← coprime_coe] rw [mul_coe] apply Nat.Coprime.mul #align pnat.coprime.mul PNat.Coprime.mul theorem Coprime.mul_right {k m n : β„•+} : k.Coprime m β†’ k.Coprime n β†’ k.Coprime (m * n) := by repeat rw [← coprime_coe] rw [mul_coe] apply Nat.Coprime.mul_right #align pnat.coprime.mul_right PNat.Coprime.mul_right theorem gcd_comm {m n : β„•+} : m.gcd n = n.gcd m := by apply eq simp only [gcd_coe] apply Nat.gcd_comm #align pnat.gcd_comm PNat.gcd_comm theorem gcd_eq_left_iff_dvd {m n : β„•+} : m ∣ n ↔ m.gcd n = m := by rw [dvd_iff] rw [Nat.gcd_eq_left_iff_dvd] rw [← coe_inj] simp #align pnat.gcd_eq_left_iff_dvd PNat.gcd_eq_left_iff_dvd theorem gcd_eq_right_iff_dvd {m n : β„•+} : m ∣ n ↔ n.gcd m = m := by rw [gcd_comm] apply gcd_eq_left_iff_dvd #align pnat.gcd_eq_right_iff_dvd PNat.gcd_eq_right_iff_dvd theorem Coprime.gcd_mul_left_cancel (m : β„•+) {n k : β„•+} : k.Coprime n β†’ (k * m).gcd n = m.gcd n := by intro h; apply eq; simp only [gcd_coe, mul_coe] apply Nat.Coprime.gcd_mul_left_cancel; simpa #align pnat.coprime.gcd_mul_left_cancel PNat.Coprime.gcd_mul_left_cancel theorem Coprime.gcd_mul_right_cancel (m : β„•+) {n k : β„•+} : k.Coprime n β†’ (m * k).gcd n = m.gcd n := by rw [mul_comm]; apply Coprime.gcd_mul_left_cancel #align pnat.coprime.gcd_mul_right_cancel PNat.Coprime.gcd_mul_right_cancel theorem Coprime.gcd_mul_left_cancel_right (m : β„•+) {n k : β„•+} : k.Coprime m β†’ m.gcd (k * n) = m.gcd n := by intro h; iterate 2 rw [gcd_comm]; symm; apply Coprime.gcd_mul_left_cancel _ h #align pnat.coprime.gcd_mul_left_cancel_right PNat.Coprime.gcd_mul_left_cancel_right theorem Coprime.gcd_mul_right_cancel_right (m : β„•+) {n k : β„•+} : k.Coprime m β†’ m.gcd (n * k) = m.gcd n := by rw [mul_comm]; apply Coprime.gcd_mul_left_cancel_right #align pnat.coprime.gcd_mul_right_cancel_right PNat.Coprime.gcd_mul_right_cancel_right @[simp] theorem one_gcd {n : β„•+} : gcd 1 n = 1 := by rw [← gcd_eq_left_iff_dvd] apply one_dvd #align pnat.one_gcd PNat.one_gcd @[simp] theorem gcd_one {n : β„•+} : gcd n 1 = 1 := by rw [gcd_comm] apply one_gcd #align pnat.gcd_one PNat.gcd_one @[symm]
Mathlib/Data/PNat/Prime.lean
257
260
theorem Coprime.symm {m n : β„•+} : m.Coprime n β†’ n.Coprime m := by
unfold Coprime rw [gcd_comm] simp
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]
Mathlib/RingTheory/RootsOfUnity/Basic.lean
488
491
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]
import Mathlib.MeasureTheory.Function.LpOrder #align_import measure_theory.function.l1_space from "leanprover-community/mathlib"@"ccdbfb6e5614667af5aa3ab2d50885e0ef44a46f" noncomputable section open scoped Classical open Topology ENNReal MeasureTheory NNReal open Set Filter TopologicalSpace ENNReal EMetric MeasureTheory variable {Ξ± Ξ² Ξ³ Ξ΄ : Type*} {m : MeasurableSpace Ξ±} {ΞΌ Ξ½ : Measure Ξ±} [MeasurableSpace Ξ΄] variable [NormedAddCommGroup Ξ²] variable [NormedAddCommGroup Ξ³] namespace MeasureTheory theorem lintegral_nnnorm_eq_lintegral_edist (f : Ξ± β†’ Ξ²) : ∫⁻ a, β€–f aβ€–β‚Š βˆ‚ΞΌ = ∫⁻ a, edist (f a) 0 βˆ‚ΞΌ := by simp only [edist_eq_coe_nnnorm] #align measure_theory.lintegral_nnnorm_eq_lintegral_edist MeasureTheory.lintegral_nnnorm_eq_lintegral_edist theorem lintegral_norm_eq_lintegral_edist (f : Ξ± β†’ Ξ²) : ∫⁻ a, ENNReal.ofReal β€–f aβ€– βˆ‚ΞΌ = ∫⁻ a, edist (f a) 0 βˆ‚ΞΌ := by simp only [ofReal_norm_eq_coe_nnnorm, edist_eq_coe_nnnorm] #align measure_theory.lintegral_norm_eq_lintegral_edist MeasureTheory.lintegral_norm_eq_lintegral_edist theorem lintegral_edist_triangle {f g h : Ξ± β†’ Ξ²} (hf : AEStronglyMeasurable f ΞΌ) (hh : AEStronglyMeasurable h ΞΌ) : (∫⁻ a, edist (f a) (g a) βˆ‚ΞΌ) ≀ (∫⁻ a, edist (f a) (h a) βˆ‚ΞΌ) + ∫⁻ a, edist (g a) (h a) βˆ‚ΞΌ := by rw [← lintegral_add_left' (hf.edist hh)] refine lintegral_mono fun a => ?_ apply edist_triangle_right #align measure_theory.lintegral_edist_triangle MeasureTheory.lintegral_edist_triangle theorem lintegral_nnnorm_zero : (∫⁻ _ : Ξ±, β€–(0 : Ξ²)β€–β‚Š βˆ‚ΞΌ) = 0 := by simp #align measure_theory.lintegral_nnnorm_zero MeasureTheory.lintegral_nnnorm_zero theorem lintegral_nnnorm_add_left {f : Ξ± β†’ Ξ²} (hf : AEStronglyMeasurable f ΞΌ) (g : Ξ± β†’ Ξ³) : ∫⁻ a, β€–f aβ€–β‚Š + β€–g aβ€–β‚Š βˆ‚ΞΌ = (∫⁻ a, β€–f aβ€–β‚Š βˆ‚ΞΌ) + ∫⁻ a, β€–g aβ€–β‚Š βˆ‚ΞΌ := lintegral_add_left' hf.ennnorm _ #align measure_theory.lintegral_nnnorm_add_left MeasureTheory.lintegral_nnnorm_add_left theorem lintegral_nnnorm_add_right (f : Ξ± β†’ Ξ²) {g : Ξ± β†’ Ξ³} (hg : AEStronglyMeasurable g ΞΌ) : ∫⁻ a, β€–f aβ€–β‚Š + β€–g aβ€–β‚Š βˆ‚ΞΌ = (∫⁻ a, β€–f aβ€–β‚Š βˆ‚ΞΌ) + ∫⁻ a, β€–g aβ€–β‚Š βˆ‚ΞΌ := lintegral_add_right' _ hg.ennnorm #align measure_theory.lintegral_nnnorm_add_right MeasureTheory.lintegral_nnnorm_add_right theorem lintegral_nnnorm_neg {f : Ξ± β†’ Ξ²} : (∫⁻ a, β€–(-f) aβ€–β‚Š βˆ‚ΞΌ) = ∫⁻ a, β€–f aβ€–β‚Š βˆ‚ΞΌ := by simp only [Pi.neg_apply, nnnorm_neg] #align measure_theory.lintegral_nnnorm_neg MeasureTheory.lintegral_nnnorm_neg def HasFiniteIntegral {_ : MeasurableSpace Ξ±} (f : Ξ± β†’ Ξ²) (ΞΌ : Measure Ξ± := by volume_tac) : Prop := (∫⁻ a, β€–f aβ€–β‚Š βˆ‚ΞΌ) < ∞ #align measure_theory.has_finite_integral MeasureTheory.HasFiniteIntegral theorem hasFiniteIntegral_def {_ : MeasurableSpace Ξ±} (f : Ξ± β†’ Ξ²) (ΞΌ : Measure Ξ±) : HasFiniteIntegral f ΞΌ ↔ ((∫⁻ a, β€–f aβ€–β‚Š βˆ‚ΞΌ) < ∞) := Iff.rfl theorem hasFiniteIntegral_iff_norm (f : Ξ± β†’ Ξ²) : HasFiniteIntegral f ΞΌ ↔ (∫⁻ a, ENNReal.ofReal β€–f aβ€– βˆ‚ΞΌ) < ∞ := by simp only [HasFiniteIntegral, ofReal_norm_eq_coe_nnnorm] #align measure_theory.has_finite_integral_iff_norm MeasureTheory.hasFiniteIntegral_iff_norm theorem hasFiniteIntegral_iff_edist (f : Ξ± β†’ Ξ²) : HasFiniteIntegral f ΞΌ ↔ (∫⁻ a, edist (f a) 0 βˆ‚ΞΌ) < ∞ := by simp only [hasFiniteIntegral_iff_norm, edist_dist, dist_zero_right] #align measure_theory.has_finite_integral_iff_edist MeasureTheory.hasFiniteIntegral_iff_edist theorem hasFiniteIntegral_iff_ofReal {f : Ξ± β†’ ℝ} (h : 0 ≀ᡐ[ΞΌ] f) : HasFiniteIntegral f ΞΌ ↔ (∫⁻ a, ENNReal.ofReal (f a) βˆ‚ΞΌ) < ∞ := by rw [HasFiniteIntegral, lintegral_nnnorm_eq_of_ae_nonneg h] #align measure_theory.has_finite_integral_iff_of_real MeasureTheory.hasFiniteIntegral_iff_ofReal theorem hasFiniteIntegral_iff_ofNNReal {f : Ξ± β†’ ℝβ‰₯0} : HasFiniteIntegral (fun x => (f x : ℝ)) ΞΌ ↔ (∫⁻ a, f a βˆ‚ΞΌ) < ∞ := by simp [hasFiniteIntegral_iff_norm] #align measure_theory.has_finite_integral_iff_of_nnreal MeasureTheory.hasFiniteIntegral_iff_ofNNReal theorem HasFiniteIntegral.mono {f : Ξ± β†’ Ξ²} {g : Ξ± β†’ Ξ³} (hg : HasFiniteIntegral g ΞΌ) (h : βˆ€α΅ a βˆ‚ΞΌ, β€–f aβ€– ≀ β€–g aβ€–) : HasFiniteIntegral f ΞΌ := by simp only [hasFiniteIntegral_iff_norm] at * calc (∫⁻ a, ENNReal.ofReal β€–f aβ€– βˆ‚ΞΌ) ≀ ∫⁻ a : Ξ±, ENNReal.ofReal β€–g aβ€– βˆ‚ΞΌ := lintegral_mono_ae (h.mono fun a h => ofReal_le_ofReal h) _ < ∞ := hg #align measure_theory.has_finite_integral.mono MeasureTheory.HasFiniteIntegral.mono theorem HasFiniteIntegral.mono' {f : Ξ± β†’ Ξ²} {g : Ξ± β†’ ℝ} (hg : HasFiniteIntegral g ΞΌ) (h : βˆ€α΅ a βˆ‚ΞΌ, β€–f aβ€– ≀ g a) : HasFiniteIntegral f ΞΌ := hg.mono <| h.mono fun _x hx => le_trans hx (le_abs_self _) #align measure_theory.has_finite_integral.mono' MeasureTheory.HasFiniteIntegral.mono' theorem HasFiniteIntegral.congr' {f : Ξ± β†’ Ξ²} {g : Ξ± β†’ Ξ³} (hf : HasFiniteIntegral f ΞΌ) (h : βˆ€α΅ a βˆ‚ΞΌ, β€–f aβ€– = β€–g aβ€–) : HasFiniteIntegral g ΞΌ := hf.mono <| EventuallyEq.le <| EventuallyEq.symm h #align measure_theory.has_finite_integral.congr' MeasureTheory.HasFiniteIntegral.congr' theorem hasFiniteIntegral_congr' {f : Ξ± β†’ Ξ²} {g : Ξ± β†’ Ξ³} (h : βˆ€α΅ a βˆ‚ΞΌ, β€–f aβ€– = β€–g aβ€–) : HasFiniteIntegral f ΞΌ ↔ HasFiniteIntegral g ΞΌ := ⟨fun hf => hf.congr' h, fun hg => hg.congr' <| EventuallyEq.symm h⟩ #align measure_theory.has_finite_integral_congr' MeasureTheory.hasFiniteIntegral_congr' theorem HasFiniteIntegral.congr {f g : Ξ± β†’ Ξ²} (hf : HasFiniteIntegral f ΞΌ) (h : f =ᡐ[ΞΌ] g) : HasFiniteIntegral g ΞΌ := hf.congr' <| h.fun_comp norm #align measure_theory.has_finite_integral.congr MeasureTheory.HasFiniteIntegral.congr theorem hasFiniteIntegral_congr {f g : Ξ± β†’ Ξ²} (h : f =ᡐ[ΞΌ] g) : HasFiniteIntegral f ΞΌ ↔ HasFiniteIntegral g ΞΌ := hasFiniteIntegral_congr' <| h.fun_comp norm #align measure_theory.has_finite_integral_congr MeasureTheory.hasFiniteIntegral_congr theorem hasFiniteIntegral_const_iff {c : Ξ²} : HasFiniteIntegral (fun _ : Ξ± => c) ΞΌ ↔ c = 0 ∨ ΞΌ univ < ∞ := by simp [HasFiniteIntegral, lintegral_const, lt_top_iff_ne_top, ENNReal.mul_eq_top, or_iff_not_imp_left] #align measure_theory.has_finite_integral_const_iff MeasureTheory.hasFiniteIntegral_const_iff theorem hasFiniteIntegral_const [IsFiniteMeasure ΞΌ] (c : Ξ²) : HasFiniteIntegral (fun _ : Ξ± => c) ΞΌ := hasFiniteIntegral_const_iff.2 (Or.inr <| measure_lt_top _ _) #align measure_theory.has_finite_integral_const MeasureTheory.hasFiniteIntegral_const theorem hasFiniteIntegral_of_bounded [IsFiniteMeasure ΞΌ] {f : Ξ± β†’ Ξ²} {C : ℝ} (hC : βˆ€α΅ a βˆ‚ΞΌ, β€–f aβ€– ≀ C) : HasFiniteIntegral f ΞΌ := (hasFiniteIntegral_const C).mono' hC #align measure_theory.has_finite_integral_of_bounded MeasureTheory.hasFiniteIntegral_of_bounded theorem HasFiniteIntegral.of_finite [Finite Ξ±] [IsFiniteMeasure ΞΌ] {f : Ξ± β†’ Ξ²} : HasFiniteIntegral f ΞΌ := let ⟨_⟩ := nonempty_fintype Ξ± hasFiniteIntegral_of_bounded <| ae_of_all ΞΌ <| norm_le_pi_norm f @[deprecated (since := "2024-02-05")] alias hasFiniteIntegral_of_fintype := HasFiniteIntegral.of_finite theorem HasFiniteIntegral.mono_measure {f : Ξ± β†’ Ξ²} (h : HasFiniteIntegral f Ξ½) (hΞΌ : ΞΌ ≀ Ξ½) : HasFiniteIntegral f ΞΌ := lt_of_le_of_lt (lintegral_mono' hΞΌ le_rfl) h #align measure_theory.has_finite_integral.mono_measure MeasureTheory.HasFiniteIntegral.mono_measure
Mathlib/MeasureTheory/Function/L1Space.lean
196
199
theorem HasFiniteIntegral.add_measure {f : Ξ± β†’ Ξ²} (hΞΌ : HasFiniteIntegral f ΞΌ) (hΞ½ : HasFiniteIntegral f Ξ½) : HasFiniteIntegral f (ΞΌ + Ξ½) := by
simp only [HasFiniteIntegral, lintegral_add_measure] at * exact add_lt_top.2 ⟨hμ, hν⟩
import Mathlib.LinearAlgebra.CliffordAlgebra.Grading import Mathlib.Algebra.Module.Opposites #align_import linear_algebra.clifford_algebra.conjugation from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0" variable {R : Type*} [CommRing R] variable {M : Type*} [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} namespace CliffordAlgebra section Reverse theorem submodule_map_reverse_eq_comap (p : Submodule R (CliffordAlgebra Q)) : p.map (reverse : CliffordAlgebra Q β†’β‚—[R] CliffordAlgebra Q) = p.comap (reverse : CliffordAlgebra Q β†’β‚—[R] CliffordAlgebra Q) := Submodule.map_equiv_eq_comap_symm (reverseEquiv : _ ≃ₗ[R] _) _ #align clifford_algebra.submodule_map_reverse_eq_comap CliffordAlgebra.submodule_map_reverse_eq_comap @[simp] theorem ΞΉ_range_map_reverse : (ΞΉ Q).range.map (reverse : CliffordAlgebra Q β†’β‚—[R] CliffordAlgebra Q) = LinearMap.range (ΞΉ Q) := by rw [reverse, reverseOp, Submodule.map_comp, ΞΉ_range_map_lift, LinearMap.range_comp, ← Submodule.map_comp] exact Submodule.map_id _ #align clifford_algebra.ΞΉ_range_map_reverse CliffordAlgebra.ΞΉ_range_map_reverse @[simp] theorem ΞΉ_range_comap_reverse : (ΞΉ Q).range.comap (reverse : CliffordAlgebra Q β†’β‚—[R] CliffordAlgebra Q) = LinearMap.range (ΞΉ Q) := by rw [← submodule_map_reverse_eq_comap, ΞΉ_range_map_reverse] #align clifford_algebra.ΞΉ_range_comap_reverse CliffordAlgebra.ΞΉ_range_comap_reverse theorem submodule_map_mul_reverse (p q : Submodule R (CliffordAlgebra Q)) : (p * q).map (reverse : CliffordAlgebra Q β†’β‚—[R] CliffordAlgebra Q) = q.map (reverse : CliffordAlgebra Q β†’β‚—[R] CliffordAlgebra Q) * p.map (reverse : CliffordAlgebra Q β†’β‚—[R] CliffordAlgebra Q) := by simp_rw [reverse, Submodule.map_comp, Submodule.map_mul, Submodule.map_unop_mul] #align clifford_algebra.submodule_map_mul_reverse CliffordAlgebra.submodule_map_mul_reverse theorem submodule_comap_mul_reverse (p q : Submodule R (CliffordAlgebra Q)) : (p * q).comap (reverse : CliffordAlgebra Q β†’β‚—[R] CliffordAlgebra Q) = q.comap (reverse : CliffordAlgebra Q β†’β‚—[R] CliffordAlgebra Q) * p.comap (reverse : CliffordAlgebra Q β†’β‚—[R] CliffordAlgebra Q) := by simp_rw [← submodule_map_reverse_eq_comap, submodule_map_mul_reverse] #align clifford_algebra.submodule_comap_mul_reverse CliffordAlgebra.submodule_comap_mul_reverse theorem submodule_map_pow_reverse (p : Submodule R (CliffordAlgebra Q)) (n : β„•) : (p ^ n).map (reverse : CliffordAlgebra Q β†’β‚—[R] CliffordAlgebra Q) = p.map (reverse : CliffordAlgebra Q β†’β‚—[R] CliffordAlgebra Q) ^ n := by simp_rw [reverse, Submodule.map_comp, Submodule.map_pow, Submodule.map_unop_pow] #align clifford_algebra.submodule_map_pow_reverse CliffordAlgebra.submodule_map_pow_reverse
Mathlib/LinearAlgebra/CliffordAlgebra/Conjugation.lean
295
298
theorem submodule_comap_pow_reverse (p : Submodule R (CliffordAlgebra Q)) (n : β„•) : (p ^ n).comap (reverse : CliffordAlgebra Q β†’β‚—[R] CliffordAlgebra Q) = p.comap (reverse : CliffordAlgebra Q β†’β‚—[R] CliffordAlgebra Q) ^ n := by
simp_rw [← submodule_map_reverse_eq_comap, submodule_map_pow_reverse]
import Mathlib.NumberTheory.Zsqrtd.Basic import Mathlib.RingTheory.PrincipalIdealDomain import Mathlib.Data.Complex.Basic import Mathlib.Data.Real.Archimedean #align_import number_theory.zsqrtd.gaussian_int from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" open Zsqrtd Complex open scoped ComplexConjugate abbrev GaussianInt : Type := Zsqrtd (-1) #align gaussian_int GaussianInt local notation "β„€[i]" => GaussianInt namespace GaussianInt instance : Repr β„€[i] := ⟨fun x _ => "⟨" ++ repr x.re ++ ", " ++ repr x.im ++ "⟩"⟩ instance instCommRing : CommRing β„€[i] := Zsqrtd.commRing #align gaussian_int.comm_ring GaussianInt.instCommRing section attribute [-instance] Complex.instField -- Avoid making things noncomputable unnecessarily. def toComplex : β„€[i] β†’+* β„‚ := Zsqrtd.lift ⟨I, by simp⟩ #align gaussian_int.to_complex GaussianInt.toComplex end instance : Coe β„€[i] β„‚ := ⟨toComplex⟩ theorem toComplex_def (x : β„€[i]) : (x : β„‚) = x.re + x.im * I := rfl #align gaussian_int.to_complex_def GaussianInt.toComplex_def theorem toComplex_def' (x y : β„€) : ((⟨x, y⟩ : β„€[i]) : β„‚) = x + y * I := by simp [toComplex_def] #align gaussian_int.to_complex_def' GaussianInt.toComplex_def' theorem toComplex_defβ‚‚ (x : β„€[i]) : (x : β„‚) = ⟨x.re, x.im⟩ := by apply Complex.ext <;> simp [toComplex_def] #align gaussian_int.to_complex_defβ‚‚ GaussianInt.toComplex_defβ‚‚ @[simp] theorem to_real_re (x : β„€[i]) : ((x.re : β„€) : ℝ) = (x : β„‚).re := by simp [toComplex_def] #align gaussian_int.to_real_re GaussianInt.to_real_re @[simp] theorem to_real_im (x : β„€[i]) : ((x.im : β„€) : ℝ) = (x : β„‚).im := by simp [toComplex_def] #align gaussian_int.to_real_im GaussianInt.to_real_im @[simp] theorem toComplex_re (x y : β„€) : ((⟨x, y⟩ : β„€[i]) : β„‚).re = x := by simp [toComplex_def] #align gaussian_int.to_complex_re GaussianInt.toComplex_re @[simp] theorem toComplex_im (x y : β„€) : ((⟨x, y⟩ : β„€[i]) : β„‚).im = y := by simp [toComplex_def] #align gaussian_int.to_complex_im GaussianInt.toComplex_im -- Porting note (#10618): @[simp] can prove this theorem toComplex_add (x y : β„€[i]) : ((x + y : β„€[i]) : β„‚) = x + y := toComplex.map_add _ _ #align gaussian_int.to_complex_add GaussianInt.toComplex_add -- Porting note (#10618): @[simp] can prove this theorem toComplex_mul (x y : β„€[i]) : ((x * y : β„€[i]) : β„‚) = x * y := toComplex.map_mul _ _ #align gaussian_int.to_complex_mul GaussianInt.toComplex_mul -- Porting note (#10618): @[simp] can prove this theorem toComplex_one : ((1 : β„€[i]) : β„‚) = 1 := toComplex.map_one #align gaussian_int.to_complex_one GaussianInt.toComplex_one -- Porting note (#10618): @[simp] can prove this theorem toComplex_zero : ((0 : β„€[i]) : β„‚) = 0 := toComplex.map_zero #align gaussian_int.to_complex_zero GaussianInt.toComplex_zero -- Porting note (#10618): @[simp] can prove this theorem toComplex_neg (x : β„€[i]) : ((-x : β„€[i]) : β„‚) = -x := toComplex.map_neg _ #align gaussian_int.to_complex_neg GaussianInt.toComplex_neg -- Porting note (#10618): @[simp] can prove this theorem toComplex_sub (x y : β„€[i]) : ((x - y : β„€[i]) : β„‚) = x - y := toComplex.map_sub _ _ #align gaussian_int.to_complex_sub GaussianInt.toComplex_sub @[simp] theorem toComplex_star (x : β„€[i]) : ((star x : β„€[i]) : β„‚) = conj (x : β„‚) := by rw [toComplex_defβ‚‚, toComplex_defβ‚‚] exact congr_argβ‚‚ _ rfl (Int.cast_neg _) #align gaussian_int.to_complex_star GaussianInt.toComplex_star @[simp] theorem toComplex_inj {x y : β„€[i]} : (x : β„‚) = y ↔ x = y := by cases x; cases y; simp [toComplex_defβ‚‚] #align gaussian_int.to_complex_inj GaussianInt.toComplex_inj lemma toComplex_injective : Function.Injective GaussianInt.toComplex := fun ⦃_ _⦄ ↦ toComplex_inj.mp @[simp] theorem toComplex_eq_zero {x : β„€[i]} : (x : β„‚) = 0 ↔ x = 0 := by rw [← toComplex_zero, toComplex_inj] #align gaussian_int.to_complex_eq_zero GaussianInt.toComplex_eq_zero @[simp] theorem intCast_real_norm (x : β„€[i]) : (x.norm : ℝ) = Complex.normSq (x : β„‚) := by rw [Zsqrtd.norm, normSq]; simp #align gaussian_int.nat_cast_real_norm GaussianInt.intCast_real_norm @[deprecated (since := "2024-04-17")] alias int_cast_real_norm := intCast_real_norm @[simp] theorem intCast_complex_norm (x : β„€[i]) : (x.norm : β„‚) = Complex.normSq (x : β„‚) := by cases x; rw [Zsqrtd.norm, normSq]; simp #align gaussian_int.nat_cast_complex_norm GaussianInt.intCast_complex_norm @[deprecated (since := "2024-04-17")] alias int_cast_complex_norm := intCast_complex_norm theorem norm_nonneg (x : β„€[i]) : 0 ≀ norm x := Zsqrtd.norm_nonneg (by norm_num) _ #align gaussian_int.norm_nonneg GaussianInt.norm_nonneg @[simp] theorem norm_eq_zero {x : β„€[i]} : norm x = 0 ↔ x = 0 := by rw [← @Int.cast_inj ℝ _ _ _]; simp #align gaussian_int.norm_eq_zero GaussianInt.norm_eq_zero theorem norm_pos {x : β„€[i]} : 0 < norm x ↔ x β‰  0 := by rw [lt_iff_le_and_ne, Ne, eq_comm, norm_eq_zero]; simp [norm_nonneg] #align gaussian_int.norm_pos GaussianInt.norm_pos theorem abs_natCast_norm (x : β„€[i]) : (x.norm.natAbs : β„€) = x.norm := Int.natAbs_of_nonneg (norm_nonneg _) #align gaussian_int.abs_coe_nat_norm GaussianInt.abs_natCast_norm -- 2024-04-05 @[deprecated] alias abs_coe_nat_norm := abs_natCast_norm @[simp] theorem natCast_natAbs_norm {Ξ± : Type*} [Ring Ξ±] (x : β„€[i]) : (x.norm.natAbs : Ξ±) = x.norm := by rw [← Int.cast_natCast, abs_natCast_norm] #align gaussian_int.nat_cast_nat_abs_norm GaussianInt.natCast_natAbs_norm @[deprecated (since := "2024-04-17")] alias nat_cast_natAbs_norm := natCast_natAbs_norm theorem natAbs_norm_eq (x : β„€[i]) : x.norm.natAbs = x.re.natAbs * x.re.natAbs + x.im.natAbs * x.im.natAbs := Int.ofNat.inj <| by simp; simp [Zsqrtd.norm] #align gaussian_int.nat_abs_norm_eq GaussianInt.natAbs_norm_eq instance : Div β„€[i] := ⟨fun x y => let n := (norm y : β„š)⁻¹ let c := star y ⟨round ((x * c).re * n : β„š), round ((x * c).im * n : β„š)⟩⟩ theorem div_def (x y : β„€[i]) : x / y = ⟨round ((x * star y).re / norm y : β„š), round ((x * star y).im / norm y : β„š)⟩ := show Zsqrtd.mk _ _ = _ by simp [div_eq_mul_inv] #align gaussian_int.div_def GaussianInt.div_def theorem toComplex_div_re (x y : β„€[i]) : ((x / y : β„€[i]) : β„‚).re = round (x / y : β„‚).re := by rw [div_def, ← @Rat.round_cast ℝ _ _] simp [-Rat.round_cast, mul_assoc, div_eq_mul_inv, mul_add, add_mul] #align gaussian_int.to_complex_div_re GaussianInt.toComplex_div_re
Mathlib/NumberTheory/Zsqrtd/GaussianInt.lean
217
219
theorem toComplex_div_im (x y : β„€[i]) : ((x / y : β„€[i]) : β„‚).im = round (x / y : β„‚).im := by
rw [div_def, ← @Rat.round_cast ℝ _ _, ← @Rat.round_cast ℝ _ _] simp [-Rat.round_cast, mul_assoc, div_eq_mul_inv, mul_add, add_mul]
import Mathlib.Data.Finset.Pointwise #align_import combinatorics.additive.e_transform from "leanprover-community/mathlib"@"207c92594599a06e7c134f8d00a030a83e6c7259" open MulOpposite open Pointwise variable {Ξ± : Type*} [DecidableEq Ξ±] namespace Finset section CommGroup variable [CommGroup Ξ±] (e : Ξ±) (x : Finset Ξ± Γ— Finset Ξ±) @[to_additive (attr := simps) "The **Dyson e-transform**. Turns `(s, t)` into `(s βˆͺ e +α΅₯ t, t ∩ -e +α΅₯ s)`. This reduces the sum of the two sets."] def mulDysonETransform : Finset Ξ± Γ— Finset Ξ± := (x.1 βˆͺ e β€’ x.2, x.2 ∩ e⁻¹ β€’ x.1) #align finset.mul_dyson_e_transform Finset.mulDysonETransform #align finset.add_dyson_e_transform Finset.addDysonETransform @[to_additive] theorem mulDysonETransform.subset : (mulDysonETransform e x).1 * (mulDysonETransform e x).2 βŠ† x.1 * x.2 := by refine union_mul_inter_subset_union.trans (union_subset Subset.rfl ?_) rw [mul_smul_comm, smul_mul_assoc, inv_smul_smul, mul_comm] #align finset.mul_dyson_e_transform.subset Finset.mulDysonETransform.subset #align finset.add_dyson_e_transform.subset Finset.addDysonETransform.subset @[to_additive] theorem mulDysonETransform.card : (mulDysonETransform e x).1.card + (mulDysonETransform e x).2.card = x.1.card + x.2.card := by dsimp rw [← card_smul_finset e (_ ∩ _), smul_finset_inter, smul_inv_smul, inter_comm, card_union_add_card_inter, card_smul_finset] #align finset.mul_dyson_e_transform.card Finset.mulDysonETransform.card #align finset.add_dyson_e_transform.card Finset.addDysonETransform.card @[to_additive (attr := simp)] theorem mulDysonETransform_idem : mulDysonETransform e (mulDysonETransform e x) = mulDysonETransform e x := by ext : 1 <;> dsimp Β· rw [smul_finset_inter, smul_inv_smul, inter_comm, union_eq_left] exact inter_subset_union Β· rw [smul_finset_union, inv_smul_smul, union_comm, inter_eq_left] exact inter_subset_union #align finset.mul_dyson_e_transform_idem Finset.mulDysonETransform_idem #align finset.add_dyson_e_transform_idem Finset.addDysonETransform_idem variable {e x} @[to_additive]
Mathlib/Combinatorics/Additive/ETransform.lean
88
92
theorem mulDysonETransform.smul_finset_snd_subset_fst : e β€’ (mulDysonETransform e x).2 βŠ† (mulDysonETransform e x).1 := by
dsimp rw [smul_finset_inter, smul_inv_smul, inter_comm] exact inter_subset_union
import Mathlib.Algebra.Category.ModuleCat.Free import Mathlib.Topology.Category.Profinite.CofilteredLimit import Mathlib.Topology.Category.Profinite.Product import Mathlib.Topology.LocallyConstant.Algebra import Mathlib.Init.Data.Bool.Lemmas universe u namespace Profinite namespace NobelingProof variable {I : Type u} [LinearOrder I] [IsWellOrder I (Β·<Β·)] (C : Set (I β†’ Bool)) open Profinite ContinuousMap CategoryTheory Limits Opposite Submodule section Projections variable (J K L : I β†’ Prop) [βˆ€ i, Decidable (J i)] [βˆ€ i, Decidable (K i)] [βˆ€ i, Decidable (L i)] def Proj : (I β†’ Bool) β†’ (I β†’ Bool) := fun c i ↦ if J i then c i else false @[simp] theorem continuous_proj : Continuous (Proj J : (I β†’ Bool) β†’ (I β†’ Bool)) := by dsimp (config := { unfoldPartialApp := true }) [Proj] apply continuous_pi intro i split Β· apply continuous_apply Β· apply continuous_const def Ο€ : Set (I β†’ Bool) := (Proj J) '' C @[simps!] def ProjRestrict : C β†’ Ο€ C J := Set.MapsTo.restrict (Proj J) _ _ (Set.mapsTo_image _ _) @[simp] theorem continuous_projRestrict : Continuous (ProjRestrict C J) := Continuous.restrict _ (continuous_proj _) theorem proj_eq_self {x : I β†’ Bool} (h : βˆ€ i, x i β‰  false β†’ J i) : Proj J x = x := by ext i simp only [Proj, ite_eq_left_iff] contrapose! simpa only [ne_comm] using h i theorem proj_prop_eq_self (hh : βˆ€ i x, x ∈ C β†’ x i β‰  false β†’ J i) : Ο€ C J = C := by ext x refine ⟨fun ⟨y, hy, h⟩ ↦ ?_, fun h ↦ ⟨x, h, ?_⟩⟩ Β· rwa [← h, proj_eq_self]; exact (hh Β· y hy) Β· rw [proj_eq_self]; exact (hh Β· x h) theorem proj_comp_of_subset (h : βˆ€ i, J i β†’ K i) : (Proj J ∘ Proj K) = (Proj J : (I β†’ Bool) β†’ (I β†’ Bool)) := by ext x i; dsimp [Proj]; aesop
Mathlib/Topology/Category/Profinite/Nobeling.lean
129
139
theorem proj_eq_of_subset (h : βˆ€ i, J i β†’ K i) : Ο€ (Ο€ C K) J = Ο€ C J := by
ext x refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ Β· obtain ⟨y, ⟨z, hz, rfl⟩, rfl⟩ := h refine ⟨z, hz, (?_ : _ = (Proj J ∘ Proj K) z)⟩ rw [proj_comp_of_subset J K h] Β· obtain ⟨y, hy, rfl⟩ := h dsimp [Ο€] rw [← Set.image_comp] refine ⟨y, hy, ?_⟩ rw [proj_comp_of_subset J K h]
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 section StarRing variable [NonUnitalSemiring Ξ±] [StarRing Ξ±] (v w : m β†’ Ξ±) theorem star_dotProduct_star : star v ⬝α΅₯ star w = star (w ⬝α΅₯ v) := by simp [dotProduct] #align matrix.star_dot_product_star Matrix.star_dotProduct_star
Mathlib/Data/Matrix/Basic.lean
939
939
theorem star_dotProduct : star v ⬝α΅₯ w = star (star w ⬝α΅₯ v) := by
simp [dotProduct]
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 section UniformSpace variable [UniformSpace Ξ±] theorem nhds_eq_comap_uniformity {x : Ξ±} : 𝓝 x = (𝓀 Ξ±).comap (Prod.mk x) := UniformSpace.nhds_eq_comap_uniformity x #align nhds_eq_comap_uniformity nhds_eq_comap_uniformity theorem isOpen_uniformity {s : Set Ξ±} : IsOpen s ↔ βˆ€ x ∈ s, { p : Ξ± Γ— Ξ± | p.1 = x β†’ p.2 ∈ s } ∈ 𝓀 Ξ± := by simp only [isOpen_iff_mem_nhds, nhds_eq_comap_uniformity, mem_comap_prod_mk] #align is_open_uniformity isOpen_uniformity theorem refl_le_uniformity : π“Ÿ idRel ≀ 𝓀 Ξ± := (@UniformSpace.toCore Ξ± _).refl #align refl_le_uniformity refl_le_uniformity instance uniformity.neBot [Nonempty Ξ±] : NeBot (𝓀 Ξ±) := diagonal_nonempty.principal_neBot.mono refl_le_uniformity #align uniformity.ne_bot uniformity.neBot theorem refl_mem_uniformity {x : Ξ±} {s : Set (Ξ± Γ— Ξ±)} (h : s ∈ 𝓀 Ξ±) : (x, x) ∈ s := refl_le_uniformity h rfl #align refl_mem_uniformity refl_mem_uniformity theorem mem_uniformity_of_eq {x y : Ξ±} {s : Set (Ξ± Γ— Ξ±)} (h : s ∈ 𝓀 Ξ±) (hx : x = y) : (x, y) ∈ s := refl_le_uniformity h hx #align mem_uniformity_of_eq mem_uniformity_of_eq theorem symm_le_uniformity : map (@Prod.swap Ξ± Ξ±) (𝓀 _) ≀ 𝓀 _ := UniformSpace.symm #align symm_le_uniformity symm_le_uniformity theorem comp_le_uniformity : ((𝓀 Ξ±).lift' fun s : Set (Ξ± Γ— Ξ±) => s β—‹ s) ≀ 𝓀 Ξ± := UniformSpace.comp #align comp_le_uniformity comp_le_uniformity theorem lift'_comp_uniformity : ((𝓀 Ξ±).lift' fun s : Set (Ξ± Γ— Ξ±) => s β—‹ s) = 𝓀 Ξ± := comp_le_uniformity.antisymm <| le_lift'.2 fun _s hs ↦ mem_of_superset hs <| subset_comp_self <| idRel_subset.2 fun _ ↦ refl_mem_uniformity hs theorem tendsto_swap_uniformity : Tendsto (@Prod.swap Ξ± Ξ±) (𝓀 Ξ±) (𝓀 Ξ±) := symm_le_uniformity #align tendsto_swap_uniformity tendsto_swap_uniformity theorem comp_mem_uniformity_sets {s : Set (Ξ± Γ— Ξ±)} (hs : s ∈ 𝓀 Ξ±) : βˆƒ t ∈ 𝓀 Ξ±, t β—‹ t βŠ† s := (mem_lift'_sets <| monotone_id.compRel monotone_id).mp <| comp_le_uniformity hs #align comp_mem_uniformity_sets comp_mem_uniformity_sets theorem eventually_uniformity_iterate_comp_subset {s : Set (Ξ± Γ— Ξ±)} (hs : s ∈ 𝓀 Ξ±) (n : β„•) : βˆ€αΆ  t in (𝓀 Ξ±).smallSets, (t β—‹ Β·)^[n] t βŠ† s := by suffices βˆ€αΆ  t in (𝓀 Ξ±).smallSets, t βŠ† s ∧ (t β—‹ Β·)^[n] t βŠ† s from (eventually_and.1 this).2 induction' n with n ihn generalizing s Β· simpa rcases comp_mem_uniformity_sets hs with ⟨t, htU, hts⟩ refine (ihn htU).mono fun U hU => ?_ rw [Function.iterate_succ_apply'] exact ⟨hU.1.trans <| (subset_comp_self <| refl_le_uniformity htU).trans hts, (compRel_mono hU.1 hU.2).trans hts⟩ #align eventually_uniformity_iterate_comp_subset eventually_uniformity_iterate_comp_subset theorem eventually_uniformity_comp_subset {s : Set (Ξ± Γ— Ξ±)} (hs : s ∈ 𝓀 Ξ±) : βˆ€αΆ  t in (𝓀 Ξ±).smallSets, t β—‹ t βŠ† s := eventually_uniformity_iterate_comp_subset hs 1 #align eventually_uniformity_comp_subset eventually_uniformity_comp_subset theorem Filter.Tendsto.uniformity_trans {l : Filter Ξ²} {f₁ fβ‚‚ f₃ : Ξ² β†’ Ξ±} (h₁₂ : Tendsto (fun x => (f₁ x, fβ‚‚ x)) l (𝓀 Ξ±)) (h₂₃ : Tendsto (fun x => (fβ‚‚ x, f₃ x)) l (𝓀 Ξ±)) : Tendsto (fun x => (f₁ x, f₃ x)) l (𝓀 Ξ±) := by refine le_trans (le_lift'.2 fun s hs => mem_map.2 ?_) comp_le_uniformity filter_upwards [mem_map.1 (h₁₂ hs), mem_map.1 (h₂₃ hs)] with x hx₁₂ hx₂₃ using ⟨_, hx₁₂, hxβ‚‚β‚ƒβŸ© #align filter.tendsto.uniformity_trans Filter.Tendsto.uniformity_trans theorem Filter.Tendsto.uniformity_symm {l : Filter Ξ²} {f : Ξ² β†’ Ξ± Γ— Ξ±} (h : Tendsto f l (𝓀 Ξ±)) : Tendsto (fun x => ((f x).2, (f x).1)) l (𝓀 Ξ±) := tendsto_swap_uniformity.comp h #align filter.tendsto.uniformity_symm Filter.Tendsto.uniformity_symm theorem tendsto_diag_uniformity (f : Ξ² β†’ Ξ±) (l : Filter Ξ²) : Tendsto (fun x => (f x, f x)) l (𝓀 Ξ±) := fun _s hs => mem_map.2 <| univ_mem' fun _ => refl_mem_uniformity hs #align tendsto_diag_uniformity tendsto_diag_uniformity theorem tendsto_const_uniformity {a : Ξ±} {f : Filter Ξ²} : Tendsto (fun _ => (a, a)) f (𝓀 Ξ±) := tendsto_diag_uniformity (fun _ => a) f #align tendsto_const_uniformity tendsto_const_uniformity theorem symm_of_uniformity {s : Set (Ξ± Γ— Ξ±)} (hs : s ∈ 𝓀 Ξ±) : βˆƒ t ∈ 𝓀 Ξ±, (βˆ€ a b, (a, b) ∈ t β†’ (b, a) ∈ t) ∧ t βŠ† s := have : preimage Prod.swap s ∈ 𝓀 Ξ± := symm_le_uniformity hs ⟨s ∩ preimage Prod.swap s, inter_mem hs this, fun _ _ ⟨h₁, hβ‚‚βŸ© => ⟨hβ‚‚, hβ‚βŸ©, inter_subset_left⟩ #align symm_of_uniformity symm_of_uniformity theorem comp_symm_of_uniformity {s : Set (Ξ± Γ— Ξ±)} (hs : s ∈ 𝓀 Ξ±) : βˆƒ t ∈ 𝓀 Ξ±, (βˆ€ {a b}, (a, b) ∈ t β†’ (b, a) ∈ t) ∧ t β—‹ t βŠ† s := let ⟨_t, ht₁, htβ‚‚βŸ© := comp_mem_uniformity_sets hs let ⟨t', ht', ht'₁, ht'β‚‚βŸ© := symm_of_uniformity ht₁ ⟨t', ht', ht'₁ _ _, Subset.trans (monotone_id.compRel monotone_id ht'β‚‚) htβ‚‚βŸ© #align comp_symm_of_uniformity comp_symm_of_uniformity theorem uniformity_le_symm : 𝓀 Ξ± ≀ @Prod.swap Ξ± Ξ± <$> 𝓀 Ξ± := by rw [map_swap_eq_comap_swap]; exact tendsto_swap_uniformity.le_comap #align uniformity_le_symm uniformity_le_symm theorem uniformity_eq_symm : 𝓀 Ξ± = @Prod.swap Ξ± Ξ± <$> 𝓀 Ξ± := le_antisymm uniformity_le_symm symm_le_uniformity #align uniformity_eq_symm uniformity_eq_symm @[simp] theorem comap_swap_uniformity : comap (@Prod.swap Ξ± Ξ±) (𝓀 Ξ±) = 𝓀 Ξ± := (congr_arg _ uniformity_eq_symm).trans <| comap_map Prod.swap_injective #align comap_swap_uniformity comap_swap_uniformity theorem symmetrize_mem_uniformity {V : Set (Ξ± Γ— Ξ±)} (h : V ∈ 𝓀 Ξ±) : symmetrizeRel V ∈ 𝓀 Ξ± := by apply (𝓀 Ξ±).inter_sets h rw [← image_swap_eq_preimage_swap, uniformity_eq_symm] exact image_mem_map h #align symmetrize_mem_uniformity symmetrize_mem_uniformity theorem UniformSpace.hasBasis_symmetric : (𝓀 Ξ±).HasBasis (fun s : Set (Ξ± Γ— Ξ±) => s ∈ 𝓀 Ξ± ∧ SymmetricRel s) id := hasBasis_self.2 fun t t_in => ⟨symmetrizeRel t, symmetrize_mem_uniformity t_in, symmetric_symmetrizeRel t, symmetrizeRel_subset_self t⟩ #align uniform_space.has_basis_symmetric UniformSpace.hasBasis_symmetric theorem uniformity_lift_le_swap {g : Set (Ξ± Γ— Ξ±) β†’ Filter Ξ²} {f : Filter Ξ²} (hg : Monotone g) (h : ((𝓀 Ξ±).lift fun s => g (preimage Prod.swap s)) ≀ f) : (𝓀 Ξ±).lift g ≀ f := calc (𝓀 Ξ±).lift g ≀ (Filter.map (@Prod.swap Ξ± Ξ±) <| 𝓀 Ξ±).lift g := lift_mono uniformity_le_symm le_rfl _ ≀ _ := by rw [map_lift_eq2 hg, image_swap_eq_preimage_swap]; exact h #align uniformity_lift_le_swap uniformity_lift_le_swap theorem uniformity_lift_le_comp {f : Set (Ξ± Γ— Ξ±) β†’ Filter Ξ²} (h : Monotone f) : ((𝓀 Ξ±).lift fun s => f (s β—‹ s)) ≀ (𝓀 Ξ±).lift f := calc ((𝓀 Ξ±).lift fun s => f (s β—‹ s)) = ((𝓀 Ξ±).lift' fun s : Set (Ξ± Γ— Ξ±) => s β—‹ s).lift f := by rw [lift_lift'_assoc] Β· exact monotone_id.compRel monotone_id Β· exact h _ ≀ (𝓀 Ξ±).lift f := lift_mono comp_le_uniformity le_rfl #align uniformity_lift_le_comp uniformity_lift_le_comp -- Porting note (#10756): new lemma theorem comp3_mem_uniformity {s : Set (Ξ± Γ— Ξ±)} (hs : s ∈ 𝓀 Ξ±) : βˆƒ t ∈ 𝓀 Ξ±, t β—‹ (t β—‹ t) βŠ† s := let ⟨_t', ht', ht's⟩ := comp_mem_uniformity_sets hs let ⟨t, ht, htt'⟩ := comp_mem_uniformity_sets ht' ⟨t, ht, (compRel_mono ((subset_comp_self (refl_le_uniformity ht)).trans htt') htt').trans ht's⟩ theorem comp_le_uniformity3 : ((𝓀 Ξ±).lift' fun s : Set (Ξ± Γ— Ξ±) => s β—‹ (s β—‹ s)) ≀ 𝓀 Ξ± := fun _ h => let ⟨_t, htU, ht⟩ := comp3_mem_uniformity h mem_of_superset (mem_lift' htU) ht #align comp_le_uniformity3 comp_le_uniformity3 theorem comp_symm_mem_uniformity_sets {s : Set (Ξ± Γ— Ξ±)} (hs : s ∈ 𝓀 Ξ±) : βˆƒ t ∈ 𝓀 Ξ±, SymmetricRel t ∧ t β—‹ t βŠ† s := by obtain ⟨w, w_in, w_sub⟩ : βˆƒ w ∈ 𝓀 Ξ±, w β—‹ w βŠ† s := comp_mem_uniformity_sets hs use symmetrizeRel w, symmetrize_mem_uniformity w_in, symmetric_symmetrizeRel w have : symmetrizeRel w βŠ† w := symmetrizeRel_subset_self w calc symmetrizeRel w β—‹ symmetrizeRel w _ βŠ† w β—‹ w := by mono _ βŠ† s := w_sub #align comp_symm_mem_uniformity_sets comp_symm_mem_uniformity_sets theorem subset_comp_self_of_mem_uniformity {s : Set (Ξ± Γ— Ξ±)} (h : s ∈ 𝓀 Ξ±) : s βŠ† s β—‹ s := subset_comp_self (refl_le_uniformity h) #align subset_comp_self_of_mem_uniformity subset_comp_self_of_mem_uniformity theorem comp_comp_symm_mem_uniformity_sets {s : Set (Ξ± Γ— Ξ±)} (hs : s ∈ 𝓀 Ξ±) : βˆƒ t ∈ 𝓀 Ξ±, SymmetricRel t ∧ t β—‹ t β—‹ t βŠ† s := by rcases comp_symm_mem_uniformity_sets hs with ⟨w, w_in, _, w_sub⟩ rcases comp_symm_mem_uniformity_sets w_in with ⟨t, t_in, t_symm, t_sub⟩ use t, t_in, t_symm have : t βŠ† t β—‹ t := subset_comp_self_of_mem_uniformity t_in -- Porting note: Needed the following `have`s to make `mono` work have ht := Subset.refl t have hw := Subset.refl w calc t β—‹ t β—‹ t βŠ† w β—‹ t := by mono _ βŠ† w β—‹ (t β—‹ t) := by mono _ βŠ† w β—‹ w := by mono _ βŠ† s := w_sub #align comp_comp_symm_mem_uniformity_sets comp_comp_symm_mem_uniformity_sets def UniformSpace.ball (x : Ξ²) (V : Set (Ξ² Γ— Ξ²)) : Set Ξ² := Prod.mk x ⁻¹' V #align uniform_space.ball UniformSpace.ball open UniformSpace (ball) theorem UniformSpace.mem_ball_self (x : Ξ±) {V : Set (Ξ± Γ— Ξ±)} (hV : V ∈ 𝓀 Ξ±) : x ∈ ball x V := refl_mem_uniformity hV #align uniform_space.mem_ball_self UniformSpace.mem_ball_self theorem mem_ball_comp {V W : Set (Ξ² Γ— Ξ²)} {x y z} (h : y ∈ ball x V) (h' : z ∈ ball y W) : z ∈ ball x (V β—‹ W) := prod_mk_mem_compRel h h' #align mem_ball_comp mem_ball_comp theorem ball_subset_of_comp_subset {V W : Set (Ξ² Γ— Ξ²)} {x y} (h : x ∈ ball y W) (h' : W β—‹ W βŠ† V) : ball x W βŠ† ball y V := fun _z z_in => h' (mem_ball_comp h z_in) #align ball_subset_of_comp_subset ball_subset_of_comp_subset theorem ball_mono {V W : Set (Ξ² Γ— Ξ²)} (h : V βŠ† W) (x : Ξ²) : ball x V βŠ† ball x W := preimage_mono h #align ball_mono ball_mono theorem ball_inter (x : Ξ²) (V W : Set (Ξ² Γ— Ξ²)) : ball x (V ∩ W) = ball x V ∩ ball x W := preimage_inter #align ball_inter ball_inter theorem ball_inter_left (x : Ξ²) (V W : Set (Ξ² Γ— Ξ²)) : ball x (V ∩ W) βŠ† ball x V := ball_mono inter_subset_left x #align ball_inter_left ball_inter_left theorem ball_inter_right (x : Ξ²) (V W : Set (Ξ² Γ— Ξ²)) : ball x (V ∩ W) βŠ† ball x W := ball_mono inter_subset_right x #align ball_inter_right ball_inter_right theorem mem_ball_symmetry {V : Set (Ξ² Γ— Ξ²)} (hV : SymmetricRel V) {x y} : x ∈ ball y V ↔ y ∈ ball x V := show (x, y) ∈ Prod.swap ⁻¹' V ↔ (x, y) ∈ V by unfold SymmetricRel at hV rw [hV] #align mem_ball_symmetry mem_ball_symmetry theorem ball_eq_of_symmetry {V : Set (Ξ² Γ— Ξ²)} (hV : SymmetricRel V) {x} : ball x V = { y | (y, x) ∈ V } := by ext y rw [mem_ball_symmetry hV] exact Iff.rfl #align ball_eq_of_symmetry ball_eq_of_symmetry theorem mem_comp_of_mem_ball {V W : Set (Ξ² Γ— Ξ²)} {x y z : Ξ²} (hV : SymmetricRel V) (hx : x ∈ ball z V) (hy : y ∈ ball z W) : (x, y) ∈ V β—‹ W := by rw [mem_ball_symmetry hV] at hx exact ⟨z, hx, hy⟩ #align mem_comp_of_mem_ball mem_comp_of_mem_ball theorem UniformSpace.isOpen_ball (x : Ξ±) {V : Set (Ξ± Γ— Ξ±)} (hV : IsOpen V) : IsOpen (ball x V) := hV.preimage <| continuous_const.prod_mk continuous_id #align uniform_space.is_open_ball UniformSpace.isOpen_ball theorem UniformSpace.isClosed_ball (x : Ξ±) {V : Set (Ξ± Γ— Ξ±)} (hV : IsClosed V) : IsClosed (ball x V) := hV.preimage <| continuous_const.prod_mk continuous_id theorem mem_comp_comp {V W M : Set (Ξ² Γ— Ξ²)} (hW' : SymmetricRel W) {p : Ξ² Γ— Ξ²} : p ∈ V β—‹ M β—‹ W ↔ (ball p.1 V Γ—Λ’ ball p.2 W ∩ M).Nonempty := by cases' p with x y constructor Β· rintro ⟨z, ⟨w, hpw, hwz⟩, hzy⟩ exact ⟨(w, z), ⟨hpw, by rwa [mem_ball_symmetry hW']⟩, hwz⟩ Β· rintro ⟨⟨w, z⟩, ⟨w_in, z_in⟩, hwz⟩ rw [mem_ball_symmetry hW'] at z_in exact ⟨z, ⟨w, w_in, hwz⟩, z_in⟩ #align mem_comp_comp mem_comp_comp theorem mem_nhds_uniformity_iff_right {x : Ξ±} {s : Set Ξ±} : s ∈ 𝓝 x ↔ { p : Ξ± Γ— Ξ± | p.1 = x β†’ p.2 ∈ s } ∈ 𝓀 Ξ± := by simp only [nhds_eq_comap_uniformity, mem_comap_prod_mk] #align mem_nhds_uniformity_iff_right mem_nhds_uniformity_iff_right theorem mem_nhds_uniformity_iff_left {x : Ξ±} {s : Set Ξ±} : s ∈ 𝓝 x ↔ { p : Ξ± Γ— Ξ± | p.2 = x β†’ p.1 ∈ s } ∈ 𝓀 Ξ± := by rw [uniformity_eq_symm, mem_nhds_uniformity_iff_right] simp only [map_def, mem_map, preimage_setOf_eq, Prod.snd_swap, Prod.fst_swap] #align mem_nhds_uniformity_iff_left mem_nhds_uniformity_iff_left theorem nhdsWithin_eq_comap_uniformity_of_mem {x : Ξ±} {T : Set Ξ±} (hx : x ∈ T) (S : Set Ξ±) : 𝓝[S] x = (𝓀 Ξ± βŠ“ π“Ÿ (T Γ—Λ’ S)).comap (Prod.mk x) := by simp [nhdsWithin, nhds_eq_comap_uniformity, hx] theorem nhdsWithin_eq_comap_uniformity {x : Ξ±} (S : Set Ξ±) : 𝓝[S] x = (𝓀 Ξ± βŠ“ π“Ÿ (univ Γ—Λ’ S)).comap (Prod.mk x) := nhdsWithin_eq_comap_uniformity_of_mem (mem_univ _) S theorem isOpen_iff_ball_subset {s : Set Ξ±} : IsOpen s ↔ βˆ€ x ∈ s, βˆƒ V ∈ 𝓀 Ξ±, ball x V βŠ† s := by simp_rw [isOpen_iff_mem_nhds, nhds_eq_comap_uniformity, mem_comap, ball] #align is_open_iff_ball_subset isOpen_iff_ball_subset theorem nhds_basis_uniformity' {p : ΞΉ β†’ Prop} {s : ΞΉ β†’ Set (Ξ± Γ— Ξ±)} (h : (𝓀 Ξ±).HasBasis p s) {x : Ξ±} : (𝓝 x).HasBasis p fun i => ball x (s i) := by rw [nhds_eq_comap_uniformity] exact h.comap (Prod.mk x) #align nhds_basis_uniformity' nhds_basis_uniformity' theorem nhds_basis_uniformity {p : ΞΉ β†’ Prop} {s : ΞΉ β†’ Set (Ξ± Γ— Ξ±)} (h : (𝓀 Ξ±).HasBasis p s) {x : Ξ±} : (𝓝 x).HasBasis p fun i => { y | (y, x) ∈ s i } := by replace h := h.comap Prod.swap rw [comap_swap_uniformity] at h exact nhds_basis_uniformity' h #align nhds_basis_uniformity nhds_basis_uniformity theorem nhds_eq_comap_uniformity' {x : Ξ±} : 𝓝 x = (𝓀 Ξ±).comap fun y => (y, x) := (nhds_basis_uniformity (𝓀 Ξ±).basis_sets).eq_of_same_basis <| (𝓀 Ξ±).basis_sets.comap _ #align nhds_eq_comap_uniformity' nhds_eq_comap_uniformity'
Mathlib/Topology/UniformSpace/Basic.lean
763
765
theorem UniformSpace.mem_nhds_iff {x : Ξ±} {s : Set Ξ±} : s ∈ 𝓝 x ↔ βˆƒ V ∈ 𝓀 Ξ±, ball x V βŠ† s := by
rw [nhds_eq_comap_uniformity, mem_comap] simp_rw [ball]
import Mathlib.Logic.Relation import Mathlib.Data.List.Forall2 import Mathlib.Data.List.Lex import Mathlib.Data.List.Infix #align_import data.list.chain from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734" -- Make sure we haven't imported `Data.Nat.Order.Basic` assert_not_exists OrderedSub universe u v open Nat namespace List variable {Ξ± : Type u} {Ξ² : Type v} {R r : Ξ± β†’ Ξ± β†’ Prop} {l l₁ lβ‚‚ : List Ξ±} {a b : Ξ±} mk_iff_of_inductive_prop List.Chain List.chain_iff #align list.chain_iff List.chain_iff #align list.chain.nil List.Chain.nil #align list.chain.cons List.Chain.cons #align list.rel_of_chain_cons List.rel_of_chain_cons #align list.chain_of_chain_cons List.chain_of_chain_cons #align list.chain.imp' List.Chain.imp' #align list.chain.imp List.Chain.imp theorem Chain.iff {S : Ξ± β†’ Ξ± β†’ Prop} (H : βˆ€ a b, R a b ↔ S a b) {a : Ξ±} {l : List Ξ±} : Chain R a l ↔ Chain S a l := ⟨Chain.imp fun a b => (H a b).1, Chain.imp fun a b => (H a b).2⟩ #align list.chain.iff List.Chain.iff theorem Chain.iff_mem {a : Ξ±} {l : List Ξ±} : Chain R a l ↔ Chain (fun x y => x ∈ a :: l ∧ y ∈ l ∧ R x y) a l := ⟨fun p => by induction' p with _ a b l r _ IH <;> constructor <;> [exact ⟨mem_cons_self _ _, mem_cons_self _ _, r⟩; exact IH.imp fun a b ⟨am, bm, h⟩ => ⟨mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h⟩], Chain.imp fun a b h => h.2.2⟩ #align list.chain.iff_mem List.Chain.iff_mem theorem chain_singleton {a b : Ξ±} : Chain R a [b] ↔ R a b := by simp only [chain_cons, Chain.nil, and_true_iff] #align list.chain_singleton List.chain_singleton theorem chain_split {a b : Ξ±} {l₁ lβ‚‚ : List Ξ±} : Chain R a (l₁ ++ b :: lβ‚‚) ↔ Chain R a (l₁ ++ [b]) ∧ Chain R b lβ‚‚ := by induction' l₁ with x l₁ IH generalizing a <;> simp only [*, nil_append, cons_append, Chain.nil, chain_cons, and_true_iff, and_assoc] #align list.chain_split List.chain_split @[simp] theorem chain_append_cons_cons {a b c : Ξ±} {l₁ lβ‚‚ : List Ξ±} : Chain R a (l₁ ++ b :: c :: lβ‚‚) ↔ Chain R a (l₁ ++ [b]) ∧ R b c ∧ Chain R c lβ‚‚ := by rw [chain_split, chain_cons] #align list.chain_append_cons_cons List.chain_append_cons_cons theorem chain_iff_forallβ‚‚ : βˆ€ {a : Ξ±} {l : List Ξ±}, Chain R a l ↔ l = [] ∨ Forallβ‚‚ R (a :: dropLast l) l | a, [] => by simp | a, b :: l => by by_cases h : l = [] <;> simp [@chain_iff_forallβ‚‚ b l, dropLast, *] #align list.chain_iff_forallβ‚‚ List.chain_iff_forallβ‚‚
Mathlib/Data/List/Chain.lean
82
83
theorem chain_append_singleton_iff_forallβ‚‚ : Chain R a (l ++ [b]) ↔ Forallβ‚‚ R (a :: l) (l ++ [b]) := by
simp [chain_iff_forallβ‚‚]
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
Mathlib/Data/Matroid/Basic.lean
739
742
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)]
import Mathlib.CategoryTheory.Monoidal.Braided.Basic import Mathlib.CategoryTheory.Monoidal.Discrete import Mathlib.CategoryTheory.Monoidal.CoherenceLemmas import Mathlib.CategoryTheory.Limits.Shapes.Terminal import Mathlib.Algebra.PUnitInstances #align_import category_theory.monoidal.Mon_ from "leanprover-community/mathlib"@"a836c6dba9bd1ee2a0cdc9af0006a596f243031c" set_option linter.uppercaseLean3 false universe v₁ vβ‚‚ u₁ uβ‚‚ u open CategoryTheory MonoidalCategory variable (C : Type u₁) [Category.{v₁} C] [MonoidalCategory.{v₁} C] structure Mon_ where X : C one : πŸ™_ C ⟢ X mul : X βŠ— X ⟢ X one_mul : (one β–· X) ≫ mul = (Ξ»_ X).hom := by aesop_cat mul_one : (X ◁ one) ≫ mul = (ρ_ X).hom := by aesop_cat -- Obviously there is some flexibility stating this axiom. -- This one has left- and right-hand sides matching the statement of `Monoid.mul_assoc`, -- and chooses to place the associator on the right-hand side. -- The heuristic is that unitors and associators "don't have much weight". mul_assoc : (mul β–· X) ≫ mul = (Ξ±_ X X X).hom ≫ (X ◁ mul) ≫ mul := by aesop_cat #align Mon_ Mon_ attribute [reassoc] Mon_.one_mul Mon_.mul_one attribute [simp] Mon_.one_mul Mon_.mul_one -- We prove a more general `@[simp]` lemma below. attribute [reassoc (attr := simp)] Mon_.mul_assoc namespace Mon_ @[simps] def trivial : Mon_ C where X := πŸ™_ C one := πŸ™ _ mul := (Ξ»_ _).hom mul_assoc := by coherence mul_one := by coherence #align Mon_.trivial Mon_.trivial instance : Inhabited (Mon_ C) := ⟨trivial C⟩ variable {C} variable {M : Mon_ C} @[simp] theorem one_mul_hom {Z : C} (f : Z ⟢ M.X) : (M.one βŠ— f) ≫ M.mul = (Ξ»_ Z).hom ≫ f := by rw [tensorHom_def'_assoc, M.one_mul, leftUnitor_naturality] #align Mon_.one_mul_hom Mon_.one_mul_hom @[simp] theorem mul_one_hom {Z : C} (f : Z ⟢ M.X) : (f βŠ— M.one) ≫ M.mul = (ρ_ Z).hom ≫ f := by rw [tensorHom_def_assoc, M.mul_one, rightUnitor_naturality] #align Mon_.mul_one_hom Mon_.mul_one_hom
Mathlib/CategoryTheory/Monoidal/Mon_.lean
84
85
theorem assoc_flip : (M.X ◁ M.mul) ≫ M.mul = (Ξ±_ M.X M.X M.X).inv ≫ (M.mul β–· M.X) ≫ M.mul := by
simp
import Mathlib.Algebra.Order.Ring.Cast import Mathlib.Data.Int.Cast.Lemmas import Mathlib.Data.Nat.Bitwise import Mathlib.Data.Nat.PSub import Mathlib.Data.Nat.Size import Mathlib.Data.Num.Bitwise #align_import data.num.lemmas from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" set_option linter.deprecated false -- Porting note: Required for the notation `-[n+1]`. open Int Function attribute [local simp] add_assoc namespace Num variable {Ξ± : Type*} open PosNum theorem pred_to_nat : βˆ€ n : Num, (pred n : β„•) = Nat.pred n | 0 => rfl | pos p => by rw [pred, PosNum.pred'_to_nat]; rfl #align num.pred_to_nat Num.pred_to_nat theorem ppred_to_nat : βˆ€ n : Num, (↑) <$> ppred n = Nat.ppred n | 0 => rfl | pos p => by rw [ppred, Option.map_some, Nat.ppred_eq_some.2] rw [PosNum.pred'_to_nat, Nat.succ_pred_eq_of_pos (PosNum.to_nat_pos _)] rfl #align num.ppred_to_nat Num.ppred_to_nat theorem cmp_swap (m n) : (cmp m n).swap = cmp n m := by cases m <;> cases n <;> try { rfl }; apply PosNum.cmp_swap #align num.cmp_swap Num.cmp_swap theorem cmp_eq (m n) : cmp m n = Ordering.eq ↔ m = n := by have := cmp_to_nat m n -- Porting note: `cases` didn't rewrite at `this`, so `revert` & `intro` are required. revert this; cases cmp m n <;> intro this <;> simp at this ⊒ <;> try { exact this } <;> simp [show m β‰  n from fun e => by rw [e] at this; exact lt_irrefl _ this] #align num.cmp_eq Num.cmp_eq @[simp, norm_cast] theorem cast_lt [LinearOrderedSemiring Ξ±] {m n : Num} : (m : Ξ±) < n ↔ m < n := by rw [← cast_to_nat m, ← cast_to_nat n, Nat.cast_lt (Ξ± := Ξ±), lt_to_nat] #align num.cast_lt Num.cast_lt @[simp, norm_cast] theorem cast_le [LinearOrderedSemiring Ξ±] {m n : Num} : (m : Ξ±) ≀ n ↔ m ≀ n := by rw [← not_lt]; exact not_congr cast_lt #align num.cast_le Num.cast_le @[simp, norm_cast]
Mathlib/Data/Num/Lemmas.lean
870
871
theorem cast_inj [LinearOrderedSemiring Ξ±] {m n : Num} : (m : Ξ±) = n ↔ m = n := by
rw [← cast_to_nat m, ← cast_to_nat n, Nat.cast_inj, to_nat_inj]
import Mathlib.Algebra.BigOperators.Fin import Mathlib.LinearAlgebra.Finsupp import Mathlib.LinearAlgebra.Prod import Mathlib.SetTheory.Cardinal.Basic import Mathlib.Tactic.FinCases import Mathlib.Tactic.LinearCombination import Mathlib.Lean.Expr.ExtraRecognizers import Mathlib.Data.Set.Subsingleton #align_import linear_algebra.linear_independent from "leanprover-community/mathlib"@"9d684a893c52e1d6692a504a118bfccbae04feeb" noncomputable section open Function Set Submodule open Cardinal universe u' u variable {ΞΉ : Type u'} {ΞΉ' : Type*} {R : Type*} {K : Type*} variable {M : Type*} {M' M'' : Type*} {V : Type u} {V' : Type*} section Module variable {v : ΞΉ β†’ M} variable [Semiring R] [AddCommMonoid M] [AddCommMonoid M'] [AddCommMonoid M''] variable [Module R M] [Module R M'] [Module R M''] variable {a b : R} {x y : M} variable (R) (v) def LinearIndependent : Prop := LinearMap.ker (Finsupp.total ΞΉ M R v) = βŠ₯ #align linear_independent LinearIndependent open Lean PrettyPrinter.Delaborator SubExpr in @[delab app.LinearIndependent] def delabLinearIndependent : Delab := whenPPOption getPPNotation <| whenNotPPOption getPPAnalysisSkip <| withOptionAtCurrPos `pp.analysis.skip true do let e ← getExpr guard <| e.isAppOfArity ``LinearIndependent 7 let some _ := (e.getArg! 0).coeTypeSet? | failure let optionsPerPos ← if (e.getArg! 3).isLambda then withNaryArg 3 do return (← read).optionsPerPos.setBool (← getPos) pp.funBinderTypes.name true else withNaryArg 0 do return (← read).optionsPerPos.setBool (← getPos) `pp.analysis.namedArg true withTheReader Context ({Β· with optionsPerPos}) delab variable {R} {v} theorem linearIndependent_iff : LinearIndependent R v ↔ βˆ€ l, Finsupp.total ΞΉ M R v l = 0 β†’ l = 0 := by simp [LinearIndependent, LinearMap.ker_eq_bot'] #align linear_independent_iff linearIndependent_iff theorem linearIndependent_iff' : LinearIndependent R v ↔ βˆ€ s : Finset ΞΉ, βˆ€ g : ΞΉ β†’ R, βˆ‘ i ∈ s, g i β€’ v i = 0 β†’ βˆ€ i ∈ s, g i = 0 := linearIndependent_iff.trans ⟨fun hf s g hg i his => have h := hf (βˆ‘ i ∈ s, Finsupp.single i (g i)) <| by simpa only [map_sum, Finsupp.total_single] using hg calc g i = (Finsupp.lapply i : (ΞΉ β†’β‚€ R) β†’β‚—[R] R) (Finsupp.single i (g i)) := by { rw [Finsupp.lapply_apply, Finsupp.single_eq_same] } _ = βˆ‘ j ∈ s, (Finsupp.lapply i : (ΞΉ β†’β‚€ R) β†’β‚—[R] R) (Finsupp.single j (g j)) := Eq.symm <| Finset.sum_eq_single i (fun j _hjs hji => by rw [Finsupp.lapply_apply, Finsupp.single_eq_of_ne hji]) fun hnis => hnis.elim his _ = (βˆ‘ j ∈ s, Finsupp.single j (g j)) i := (map_sum ..).symm _ = 0 := DFunLike.ext_iff.1 h i, fun hf l hl => Finsupp.ext fun i => _root_.by_contradiction fun hni => hni <| hf _ _ hl _ <| Finsupp.mem_support_iff.2 hni⟩ #align linear_independent_iff' linearIndependent_iff' theorem linearIndependent_iff'' : LinearIndependent R v ↔ βˆ€ (s : Finset ΞΉ) (g : ΞΉ β†’ R), (βˆ€ i βˆ‰ s, g i = 0) β†’ βˆ‘ i ∈ s, g i β€’ v i = 0 β†’ βˆ€ i, g i = 0 := by classical exact linearIndependent_iff'.trans ⟨fun H s g hg hv i => if his : i ∈ s then H s g hv i his else hg i his, fun H s g hg i hi => by convert H s (fun j => if j ∈ s then g j else 0) (fun j hj => if_neg hj) (by simp_rw [ite_smul, zero_smul, Finset.sum_extend_by_zero, hg]) i exact (if_pos hi).symm⟩ #align linear_independent_iff'' linearIndependent_iff'' theorem not_linearIndependent_iff : Β¬LinearIndependent R v ↔ βˆƒ s : Finset ΞΉ, βˆƒ g : ΞΉ β†’ R, βˆ‘ i ∈ s, g i β€’ v i = 0 ∧ βˆƒ i ∈ s, g i β‰  0 := by rw [linearIndependent_iff'] simp only [exists_prop, not_forall] #align not_linear_independent_iff not_linearIndependent_iff theorem Fintype.linearIndependent_iff [Fintype ΞΉ] : LinearIndependent R v ↔ βˆ€ g : ΞΉ β†’ R, βˆ‘ i, g i β€’ v i = 0 β†’ βˆ€ i, g i = 0 := by refine ⟨fun H g => by simpa using linearIndependent_iff'.1 H Finset.univ g, fun H => linearIndependent_iff''.2 fun s g hg hs i => H _ ?_ _⟩ rw [← hs] refine (Finset.sum_subset (Finset.subset_univ _) fun i _ hi => ?_).symm rw [hg i hi, zero_smul] #align fintype.linear_independent_iff Fintype.linearIndependent_iff theorem Fintype.linearIndependent_iff' [Fintype ΞΉ] [DecidableEq ΞΉ] : LinearIndependent R v ↔ LinearMap.ker (LinearMap.lsum R (fun _ ↦ R) β„• fun i ↦ LinearMap.id.smulRight (v i)) = βŠ₯ := by simp [Fintype.linearIndependent_iff, LinearMap.ker_eq_bot', funext_iff] #align fintype.linear_independent_iff' Fintype.linearIndependent_iff' theorem Fintype.not_linearIndependent_iff [Fintype ΞΉ] : Β¬LinearIndependent R v ↔ βˆƒ g : ΞΉ β†’ R, βˆ‘ i, g i β€’ v i = 0 ∧ βˆƒ i, g i β‰  0 := by simpa using not_iff_not.2 Fintype.linearIndependent_iff #align fintype.not_linear_independent_iff Fintype.not_linearIndependent_iff theorem linearIndependent_empty_type [IsEmpty ΞΉ] : LinearIndependent R v := linearIndependent_iff.mpr fun v _hv => Subsingleton.elim v 0 #align linear_independent_empty_type linearIndependent_empty_type theorem LinearIndependent.ne_zero [Nontrivial R] (i : ΞΉ) (hv : LinearIndependent R v) : v i β‰  0 := fun h => zero_ne_one' R <| Eq.symm (by suffices (Finsupp.single i 1 : ΞΉ β†’β‚€ R) i = 0 by simpa rw [linearIndependent_iff.1 hv (Finsupp.single i 1)] Β· simp Β· simp [h]) #align linear_independent.ne_zero LinearIndependent.ne_zero lemma LinearIndependent.eq_zero_of_pair {x y : M} (h : LinearIndependent R ![x, y]) {s t : R} (h' : s β€’ x + t β€’ y = 0) : s = 0 ∧ t = 0 := by have := linearIndependent_iff'.1 h Finset.univ ![s, t] simp only [Fin.sum_univ_two, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.head_cons, h', Finset.mem_univ, forall_true_left] at this exact ⟨this 0, this 1⟩ lemma LinearIndependent.pair_iff {x y : M} : LinearIndependent R ![x, y] ↔ βˆ€ (s t : R), s β€’ x + t β€’ y = 0 β†’ s = 0 ∧ t = 0 := by refine ⟨fun h s t hst ↦ h.eq_zero_of_pair hst, fun h ↦ ?_⟩ apply Fintype.linearIndependent_iff.2 intro g hg simp only [Fin.sum_univ_two, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.head_cons] at hg intro i fin_cases i exacts [(h _ _ hg).1, (h _ _ hg).2] theorem LinearIndependent.comp (h : LinearIndependent R v) (f : ΞΉ' β†’ ΞΉ) (hf : Injective f) : LinearIndependent R (v ∘ f) := by rw [linearIndependent_iff, Finsupp.total_comp] intro l hl have h_map_domain : βˆ€ x, (Finsupp.mapDomain f l) (f x) = 0 := by rw [linearIndependent_iff.1 h (Finsupp.mapDomain f l) hl]; simp ext x convert h_map_domain x rw [Finsupp.mapDomain_apply hf] #align linear_independent.comp LinearIndependent.comp theorem linearIndependent_iff_finset_linearIndependent : LinearIndependent R v ↔ βˆ€ (s : Finset ΞΉ), LinearIndependent R (v ∘ (Subtype.val : s β†’ ΞΉ)) := ⟨fun H _ ↦ H.comp _ Subtype.val_injective, fun H ↦ linearIndependent_iff'.2 fun s g hg i hi ↦ Fintype.linearIndependent_iff.1 (H s) (g ∘ Subtype.val) (hg β–Έ Finset.sum_attach s fun j ↦ g j β€’ v j) ⟨i, hi⟩⟩ theorem LinearIndependent.coe_range (i : LinearIndependent R v) : LinearIndependent R ((↑) : range v β†’ M) := by simpa using i.comp _ (rangeSplitting_injective v) #align linear_independent.coe_range LinearIndependent.coe_range theorem LinearIndependent.map (hv : LinearIndependent R v) {f : M β†’β‚—[R] M'} (hf_inj : Disjoint (span R (range v)) (LinearMap.ker f)) : LinearIndependent R (f ∘ v) := by rw [disjoint_iff_inf_le, ← Set.image_univ, Finsupp.span_image_eq_map_total, map_inf_eq_map_inf_comap, map_le_iff_le_comap, comap_bot, Finsupp.supported_univ, top_inf_eq] at hf_inj unfold LinearIndependent at hv ⊒ rw [hv, le_bot_iff] at hf_inj haveI : Inhabited M := ⟨0⟩ rw [Finsupp.total_comp, Finsupp.lmapDomain_total _ _ f, LinearMap.ker_comp, hf_inj] exact fun _ => rfl #align linear_independent.map LinearIndependent.map theorem Submodule.range_ker_disjoint {f : M β†’β‚—[R] M'} (hv : LinearIndependent R (f ∘ v)) : Disjoint (span R (range v)) (LinearMap.ker f) := by rw [LinearIndependent, Finsupp.total_comp, Finsupp.lmapDomain_total R _ f (fun _ ↦ rfl), LinearMap.ker_comp] at hv rw [disjoint_iff_inf_le, ← Set.image_univ, Finsupp.span_image_eq_map_total, map_inf_eq_map_inf_comap, hv, inf_bot_eq, map_bot] theorem LinearIndependent.map' (hv : LinearIndependent R v) (f : M β†’β‚—[R] M') (hf_inj : LinearMap.ker f = βŠ₯) : LinearIndependent R (f ∘ v) := hv.map <| by simp [hf_inj] #align linear_independent.map' LinearIndependent.map' theorem LinearIndependent.map_of_injective_injective {R' : Type*} {M' : Type*} [Semiring R'] [AddCommMonoid M'] [Module R' M'] (hv : LinearIndependent R v) (i : R' β†’ R) (j : M β†’+ M') (hi : βˆ€ r, i r = 0 β†’ r = 0) (hj : βˆ€ m, j m = 0 β†’ m = 0) (hc : βˆ€ (r : R') (m : M), j (i r β€’ m) = r β€’ j m) : LinearIndependent R' (j ∘ v) := by rw [linearIndependent_iff'] at hv ⊒ intro S r' H s hs simp_rw [comp_apply, ← hc, ← map_sum] at H exact hi _ <| hv _ _ (hj _ H) s hs theorem LinearIndependent.map_of_surjective_injective {R' : Type*} {M' : Type*} [Semiring R'] [AddCommMonoid M'] [Module R' M'] (hv : LinearIndependent R v) (i : ZeroHom R R') (j : M β†’+ M') (hi : Surjective i) (hj : βˆ€ m, j m = 0 β†’ m = 0) (hc : βˆ€ (r : R) (m : M), j (r β€’ m) = i r β€’ j m) : LinearIndependent R' (j ∘ v) := by obtain ⟨i', hi'⟩ := hi.hasRightInverse refine hv.map_of_injective_injective i' j (fun _ h ↦ ?_) hj fun r m ↦ ?_ Β· apply_fun i at h rwa [hi', i.map_zero] at h rw [hc (i' r) m, hi'] theorem LinearIndependent.of_comp (f : M β†’β‚—[R] M') (hfv : LinearIndependent R (f ∘ v)) : LinearIndependent R v := linearIndependent_iff'.2 fun s g hg i his => have : (βˆ‘ i ∈ s, g i β€’ f (v i)) = 0 := by simp_rw [← map_smul, ← map_sum, hg, f.map_zero] linearIndependent_iff'.1 hfv s g this i his #align linear_independent.of_comp LinearIndependent.of_comp protected theorem LinearMap.linearIndependent_iff (f : M β†’β‚—[R] M') (hf_inj : LinearMap.ker f = βŠ₯) : LinearIndependent R (f ∘ v) ↔ LinearIndependent R v := ⟨fun h => h.of_comp f, fun h => h.map <| by simp only [hf_inj, disjoint_bot_right]⟩ #align linear_map.linear_independent_iff LinearMap.linearIndependent_iff @[nontriviality] theorem linearIndependent_of_subsingleton [Subsingleton R] : LinearIndependent R v := linearIndependent_iff.2 fun _l _hl => Subsingleton.elim _ _ #align linear_independent_of_subsingleton linearIndependent_of_subsingleton theorem linearIndependent_equiv (e : ΞΉ ≃ ΞΉ') {f : ΞΉ' β†’ M} : LinearIndependent R (f ∘ e) ↔ LinearIndependent R f := ⟨fun h => Function.comp_id f β–Έ e.self_comp_symm β–Έ h.comp _ e.symm.injective, fun h => h.comp _ e.injective⟩ #align linear_independent_equiv linearIndependent_equiv theorem linearIndependent_equiv' (e : ΞΉ ≃ ΞΉ') {f : ΞΉ' β†’ M} {g : ΞΉ β†’ M} (h : f ∘ e = g) : LinearIndependent R g ↔ LinearIndependent R f := h β–Έ linearIndependent_equiv e #align linear_independent_equiv' linearIndependent_equiv' theorem linearIndependent_subtype_range {ΞΉ} {f : ΞΉ β†’ M} (hf : Injective f) : LinearIndependent R ((↑) : range f β†’ M) ↔ LinearIndependent R f := Iff.symm <| linearIndependent_equiv' (Equiv.ofInjective f hf) rfl #align linear_independent_subtype_range linearIndependent_subtype_range alias ⟨LinearIndependent.of_subtype_range, _⟩ := linearIndependent_subtype_range #align linear_independent.of_subtype_range LinearIndependent.of_subtype_range theorem linearIndependent_image {ΞΉ} {s : Set ΞΉ} {f : ΞΉ β†’ M} (hf : Set.InjOn f s) : (LinearIndependent R fun x : s => f x) ↔ LinearIndependent R fun x : f '' s => (x : M) := linearIndependent_equiv' (Equiv.Set.imageOfInjOn _ _ hf) rfl #align linear_independent_image linearIndependent_image theorem linearIndependent_span (hs : LinearIndependent R v) : LinearIndependent R (M := span R (range v)) (fun i : ΞΉ => ⟨v i, subset_span (mem_range_self i)⟩) := LinearIndependent.of_comp (span R (range v)).subtype hs #align linear_independent_span linearIndependent_span theorem LinearIndependent.fin_cons' {m : β„•} (x : M) (v : Fin m β†’ M) (hli : LinearIndependent R v) (x_ortho : βˆ€ (c : R) (y : Submodule.span R (Set.range v)), c β€’ x + y = (0 : M) β†’ c = 0) : LinearIndependent R (Fin.cons x v : Fin m.succ β†’ M) := by rw [Fintype.linearIndependent_iff] at hli ⊒ rintro g total_eq j simp_rw [Fin.sum_univ_succ, Fin.cons_zero, Fin.cons_succ] at total_eq have : g 0 = 0 := by refine x_ortho (g 0) βŸ¨βˆ‘ i : Fin m, g i.succ β€’ v i, ?_⟩ total_eq exact sum_mem fun i _ => smul_mem _ _ (subset_span ⟨i, rfl⟩) rw [this, zero_smul, zero_add] at total_eq exact Fin.cases this (hli _ total_eq) j #align linear_independent.fin_cons' LinearIndependent.fin_cons' theorem LinearIndependent.restrict_scalars [Semiring K] [SMulWithZero R K] [Module K M] [IsScalarTower R K M] (hinj : Function.Injective fun r : R => r β€’ (1 : K)) (li : LinearIndependent K v) : LinearIndependent R v := by refine linearIndependent_iff'.mpr fun s g hg i hi => hinj ?_ dsimp only; rw [zero_smul] refine (linearIndependent_iff'.mp li : _) _ (g Β· β€’ (1:K)) ?_ i hi simp_rw [smul_assoc, one_smul] exact hg #align linear_independent.restrict_scalars LinearIndependent.restrict_scalars theorem linearIndependent_finset_map_embedding_subtype (s : Set M) (li : LinearIndependent R ((↑) : s β†’ M)) (t : Finset s) : LinearIndependent R ((↑) : Finset.map (Embedding.subtype s) t β†’ M) := by let f : t.map (Embedding.subtype s) β†’ s := fun x => ⟨x.1, by obtain ⟨x, h⟩ := x rw [Finset.mem_map] at h obtain ⟨a, _ha, rfl⟩ := h simp only [Subtype.coe_prop, Embedding.coe_subtype]⟩ convert LinearIndependent.comp li f ?_ rintro ⟨x, hx⟩ ⟨y, hy⟩ rw [Finset.mem_map] at hx hy obtain ⟨a, _ha, rfl⟩ := hx obtain ⟨b, _hb, rfl⟩ := hy simp only [f, imp_self, Subtype.mk_eq_mk] #align linear_independent_finset_map_embedding_subtype linearIndependent_finset_map_embedding_subtype theorem linearIndependent_bounded_of_finset_linearIndependent_bounded {n : β„•} (H : βˆ€ s : Finset M, (LinearIndependent R fun i : s => (i : M)) β†’ s.card ≀ n) : βˆ€ s : Set M, LinearIndependent R ((↑) : s β†’ M) β†’ #s ≀ n := by intro s li apply Cardinal.card_le_of intro t rw [← Finset.card_map (Embedding.subtype s)] apply H apply linearIndependent_finset_map_embedding_subtype _ li #align linear_independent_bounded_of_finset_linear_independent_bounded linearIndependent_bounded_of_finset_linearIndependent_bounded section Module variable {v : ΞΉ β†’ M} variable [Ring R] [AddCommGroup M] [AddCommGroup M'] [AddCommGroup M''] variable [Module R M] [Module R M'] [Module R M''] variable {a b : R} {x y : M} theorem linearIndependent_iff_injective_total : LinearIndependent R v ↔ Function.Injective (Finsupp.total ΞΉ M R v) := linearIndependent_iff.trans (injective_iff_map_eq_zero (Finsupp.total ΞΉ M R v).toAddMonoidHom).symm #align linear_independent_iff_injective_total linearIndependent_iff_injective_total alias ⟨LinearIndependent.injective_total, _⟩ := linearIndependent_iff_injective_total #align linear_independent.injective_total LinearIndependent.injective_total theorem LinearIndependent.injective [Nontrivial R] (hv : LinearIndependent R v) : Injective v := by intro i j hij let l : ΞΉ β†’β‚€ R := Finsupp.single i (1 : R) - Finsupp.single j 1 have h_total : Finsupp.total ΞΉ M R v l = 0 := by simp_rw [l, LinearMap.map_sub, Finsupp.total_apply] simp [hij] have h_single_eq : Finsupp.single i (1 : R) = Finsupp.single j 1 := by rw [linearIndependent_iff] at hv simp [eq_add_of_sub_eq' (hv l h_total)] simpa [Finsupp.single_eq_single_iff] using h_single_eq #align linear_independent.injective LinearIndependent.injective theorem LinearIndependent.to_subtype_range {ΞΉ} {f : ΞΉ β†’ M} (hf : LinearIndependent R f) : LinearIndependent R ((↑) : range f β†’ M) := by nontriviality R exact (linearIndependent_subtype_range hf.injective).2 hf #align linear_independent.to_subtype_range LinearIndependent.to_subtype_range theorem LinearIndependent.to_subtype_range' {ΞΉ} {f : ΞΉ β†’ M} (hf : LinearIndependent R f) {t} (ht : range f = t) : LinearIndependent R ((↑) : t β†’ M) := ht β–Έ hf.to_subtype_range #align linear_independent.to_subtype_range' LinearIndependent.to_subtype_range' theorem LinearIndependent.image_of_comp {ΞΉ ΞΉ'} (s : Set ΞΉ) (f : ΞΉ β†’ ΞΉ') (g : ΞΉ' β†’ M) (hs : LinearIndependent R fun x : s => g (f x)) : LinearIndependent R fun x : f '' s => g x := by nontriviality R have : InjOn f s := injOn_iff_injective.2 hs.injective.of_comp exact (linearIndependent_equiv' (Equiv.Set.imageOfInjOn f s this) rfl).1 hs #align linear_independent.image_of_comp LinearIndependent.image_of_comp theorem LinearIndependent.image {ΞΉ} {s : Set ΞΉ} {f : ΞΉ β†’ M} (hs : LinearIndependent R fun x : s => f x) : LinearIndependent R fun x : f '' s => (x : M) := by convert LinearIndependent.image_of_comp s f id hs #align linear_independent.image LinearIndependent.image theorem LinearIndependent.group_smul {G : Type*} [hG : Group G] [DistribMulAction G R] [DistribMulAction G M] [IsScalarTower G R M] [SMulCommClass G R M] {v : ΞΉ β†’ M} (hv : LinearIndependent R v) (w : ΞΉ β†’ G) : LinearIndependent R (w β€’ v) := by rw [linearIndependent_iff''] at hv ⊒ intro s g hgs hsum i refine (smul_eq_zero_iff_eq (w i)).1 ?_ refine hv s (fun i => w i β€’ g i) (fun i hi => ?_) ?_ i Β· dsimp only exact (hgs i hi).symm β–Έ smul_zero _ Β· rw [← hsum, Finset.sum_congr rfl _] intros dsimp rw [smul_assoc, smul_comm] #align linear_independent.group_smul LinearIndependent.group_smul -- This lemma cannot be proved with `LinearIndependent.group_smul` since the action of -- `RΛ£` on `R` is not commutative. theorem LinearIndependent.units_smul {v : ΞΉ β†’ M} (hv : LinearIndependent R v) (w : ΞΉ β†’ RΛ£) : LinearIndependent R (w β€’ v) := by rw [linearIndependent_iff''] at hv ⊒ intro s g hgs hsum i rw [← (w i).mul_left_eq_zero] refine hv s (fun i => g i β€’ (w i : R)) (fun i hi => ?_) ?_ i Β· dsimp only exact (hgs i hi).symm β–Έ zero_smul _ _ Β· rw [← hsum, Finset.sum_congr rfl _] intros erw [Pi.smul_apply, smul_assoc] rfl #align linear_independent.units_smul LinearIndependent.units_smul lemma LinearIndependent.eq_of_pair {x y : M} (h : LinearIndependent R ![x, y]) {s t s' t' : R} (h' : s β€’ x + t β€’ y = s' β€’ x + t' β€’ y) : s = s' ∧ t = t' := by have : (s - s') β€’ x + (t - t') β€’ y = 0 := by rw [← sub_eq_zero_of_eq h', ← sub_eq_zero] simp only [sub_smul] abel simpa [sub_eq_zero] using h.eq_zero_of_pair this lemma LinearIndependent.eq_zero_of_pair' {x y : M} (h : LinearIndependent R ![x, y]) {s t : R} (h' : s β€’ x = t β€’ y) : s = 0 ∧ t = 0 := by suffices H : s = 0 ∧ 0 = t from ⟨H.1, H.2.symm⟩ exact h.eq_of_pair (by simpa using h') lemma LinearIndependent.linear_combination_pair_of_det_ne_zero {R M : Type*} [CommRing R] [NoZeroDivisors R] [AddCommGroup M] [Module R M] {x y : M} (h : LinearIndependent R ![x, y]) {a b c d : R} (h' : a * d - b * c β‰  0) : LinearIndependent R ![a β€’ x + b β€’ y, c β€’ x + d β€’ y] := by apply LinearIndependent.pair_iff.2 (fun s t hst ↦ ?_) have H : (s * a + t * c) β€’ x + (s * b + t * d) β€’ y = 0 := by convert hst using 1 simp only [_root_.add_smul, smul_add, smul_smul] abel have I1 : s * a + t * c = 0 := (h.eq_zero_of_pair H).1 have I2 : s * b + t * d = 0 := (h.eq_zero_of_pair H).2 have J1 : (a * d - b * c) * s = 0 := by linear_combination d * I1 - c * I2 have J2 : (a * d - b * c) * t = 0 := by linear_combination -b * I1 + a * I2 exact ⟨by simpa [h'] using mul_eq_zero.1 J1, by simpa [h'] using mul_eq_zero.1 J2⟩ theorem surjective_of_linearIndependent_of_span [Nontrivial R] (hv : LinearIndependent R v) (f : ΞΉ' β†ͺ ΞΉ) (hss : range v βŠ† span R (range (v ∘ f))) : Surjective f := by intro i let repr : (span R (range (v ∘ f)) : Type _) β†’ ΞΉ' β†’β‚€ R := (hv.comp f f.injective).repr let l := (repr ⟨v i, hss (mem_range_self i)⟩).mapDomain f have h_total_l : Finsupp.total ΞΉ M R v l = v i := by dsimp only [l] rw [Finsupp.total_mapDomain] rw [(hv.comp f f.injective).total_repr] -- Porting note: `rfl` isn't necessary. have h_total_eq : (Finsupp.total ΞΉ M R v) l = (Finsupp.total ΞΉ M R v) (Finsupp.single i 1) := by rw [h_total_l, Finsupp.total_single, one_smul] have l_eq : l = _ := LinearMap.ker_eq_bot.1 hv h_total_eq dsimp only [l] at l_eq rw [← Finsupp.embDomain_eq_mapDomain] at l_eq rcases Finsupp.single_of_embDomain_single (repr ⟨v i, _⟩) f i (1 : R) zero_ne_one.symm l_eq with ⟨i', hi'⟩ use i' exact hi'.2 #align surjective_of_linear_independent_of_span surjective_of_linearIndependent_of_span
Mathlib/LinearAlgebra/LinearIndependent.lean
1,075
1,087
theorem eq_of_linearIndependent_of_span_subtype [Nontrivial R] {s t : Set M} (hs : LinearIndependent R (fun x => x : s β†’ M)) (h : t βŠ† s) (hst : s βŠ† span R t) : s = t := by
let f : t β†ͺ s := ⟨fun x => ⟨x.1, h x.2⟩, fun a b hab => Subtype.coe_injective (Subtype.mk.inj hab)⟩ have h_surj : Surjective f := by apply surjective_of_linearIndependent_of_span hs f _ convert hst <;> simp [f, comp] show s = t apply Subset.antisymm _ h intro x hx rcases h_surj ⟨x, hx⟩ with ⟨y, hy⟩ convert y.mem rw [← Subtype.mk.inj hy]
import Mathlib.Algebra.NeZero import Mathlib.Data.Nat.Defs import Mathlib.Logic.Embedding.Basic import Mathlib.Logic.Equiv.Set import Mathlib.Tactic.Common #align_import data.fin.basic from "leanprover-community/mathlib"@"3a2b5524a138b5d0b818b858b516d4ac8a484b03" assert_not_exists Monoid universe u v open Fin Nat Function def finZeroElim {Ξ± : Fin 0 β†’ Sort*} (x : Fin 0) : Ξ± x := x.elim0 #align fin_zero_elim finZeroElim namespace Fin instance {n : β„•} : CanLift β„• (Fin n) Fin.val (Β· < n) where prf k hk := ⟨⟨k, hk⟩, rfl⟩ def rec0 {Ξ± : Fin 0 β†’ Sort*} (i : Fin 0) : Ξ± i := absurd i.2 (Nat.not_lt_zero _) #align fin.elim0' Fin.elim0 variable {n m : β„•} --variable {a b : Fin n} -- this *really* breaks stuff #align fin.fin_to_nat Fin.coeToNat theorem val_injective : Function.Injective (@Fin.val n) := @Fin.eq_of_val_eq n #align fin.val_injective Fin.val_injective lemma size_positive : Fin n β†’ 0 < n := Fin.pos lemma size_positive' [Nonempty (Fin n)] : 0 < n := β€ΉNonempty (Fin n)β€Ί.elim Fin.pos protected theorem prop (a : Fin n) : a.val < n := a.2 #align fin.prop Fin.prop #align fin.is_lt Fin.is_lt #align fin.pos Fin.pos #align fin.pos_iff_nonempty Fin.pos_iff_nonempty lemma lt_last_iff_ne_last {a : Fin (n + 1)} : a < last n ↔ a β‰  last n := by simp [Fin.lt_iff_le_and_ne, le_last] lemma ne_zero_of_lt {a b : Fin (n + 1)} (hab : a < b) : b β‰  0 := Fin.ne_of_gt $ Fin.lt_of_le_of_lt a.zero_le hab lemma ne_last_of_lt {a b : Fin (n + 1)} (hab : a < b) : a β‰  last n := Fin.ne_of_lt $ Fin.lt_of_lt_of_le hab b.le_last @[simps apply symm_apply] def equivSubtype : Fin n ≃ { i // i < n } where toFun a := ⟨a.1, a.2⟩ invFun a := ⟨a.1, a.2⟩ left_inv := fun ⟨_, _⟩ => rfl right_inv := fun ⟨_, _⟩ => rfl #align fin.equiv_subtype Fin.equivSubtype #align fin.equiv_subtype_symm_apply Fin.equivSubtype_symm_apply #align fin.equiv_subtype_apply Fin.equivSubtype_apply section Add #align fin.val_one Fin.val_one #align fin.coe_one Fin.val_one @[simp] theorem val_one' (n : β„•) [NeZero n] : ((1 : Fin n) : β„•) = 1 % n := rfl #align fin.coe_one' Fin.val_one' -- Porting note: Delete this lemma after porting theorem val_one'' {n : β„•} : ((1 : Fin (n + 1)) : β„•) = 1 % (n + 1) := rfl #align fin.one_val Fin.val_one'' #align fin.mk_one Fin.mk_one instance nontrivial {n : β„•} : Nontrivial (Fin (n + 2)) where exists_pair_ne := ⟨0, 1, (ne_iff_vne 0 1).mpr (by simp [val_one, val_zero])⟩ theorem nontrivial_iff_two_le : Nontrivial (Fin n) ↔ 2 ≀ n := by rcases n with (_ | _ | n) <;> simp [← Nat.one_eq_succ_zero, Fin.nontrivial, not_nontrivial, Nat.succ_le_iff] -- Porting note: here and in the next lemma, had to use `← Nat.one_eq_succ_zero`. #align fin.nontrivial_iff_two_le Fin.nontrivial_iff_two_le #align fin.subsingleton_iff_le_one Fin.subsingleton_iff_le_one section Monoid -- Porting note (#10618): removing `simp`, `simp` can prove it with AddCommMonoid instance protected theorem add_zero [NeZero n] (k : Fin n) : k + 0 = k := by simp only [add_def, val_zero', Nat.add_zero, mod_eq_of_lt (is_lt k)] #align fin.add_zero Fin.add_zero -- Porting note (#10618): removing `simp`, `simp` can prove it with AddCommMonoid instance protected theorem zero_add [NeZero n] (k : Fin n) : 0 + k = k := by simp [ext_iff, add_def, mod_eq_of_lt (is_lt k)] #align fin.zero_add Fin.zero_add instance {a : β„•} [NeZero n] : OfNat (Fin n) a where ofNat := Fin.ofNat' a n.pos_of_neZero instance inhabited (n : β„•) [NeZero n] : Inhabited (Fin n) := ⟨0⟩ instance inhabitedFinOneAdd (n : β„•) : Inhabited (Fin (1 + n)) := haveI : NeZero (1 + n) := by rw [Nat.add_comm]; infer_instance inferInstance @[simp] theorem default_eq_zero (n : β„•) [NeZero n] : (default : Fin n) = 0 := rfl #align fin.default_eq_zero Fin.default_eq_zero #align fin.val_add Fin.val_add #align fin.coe_add Fin.val_add theorem val_add_eq_ite {n : β„•} (a b : Fin n) : (↑(a + b) : β„•) = if n ≀ a + b then a + b - n else a + b := by rw [Fin.val_add, Nat.add_mod_eq_ite, Nat.mod_eq_of_lt (show ↑a < n from a.2), Nat.mod_eq_of_lt (show ↑b < n from b.2)] #align fin.coe_add_eq_ite Fin.val_add_eq_ite #align fin.coe_add_one_of_lt Fin.val_add_one_of_lt #align fin.last_add_one Fin.last_add_one #align fin.coe_add_one Fin.val_add_one #align fin.val_two Fin.val_two --- Porting note: syntactically the same as the above #align fin.coe_two Fin.val_two section DivMod def divNat (i : Fin (m * n)) : Fin m := ⟨i / n, Nat.div_lt_of_lt_mul <| Nat.mul_comm m n β–Έ i.prop⟩ #align fin.div_nat Fin.divNat @[simp] theorem coe_divNat (i : Fin (m * n)) : (i.divNat : β„•) = i / n := rfl #align fin.coe_div_nat Fin.coe_divNat def modNat (i : Fin (m * n)) : Fin n := ⟨i % n, Nat.mod_lt _ <| Nat.pos_of_mul_pos_left i.pos⟩ #align fin.mod_nat Fin.modNat @[simp] theorem coe_modNat (i : Fin (m * n)) : (i.modNat : β„•) = i % n := rfl #align fin.coe_mod_nat Fin.coe_modNat
Mathlib/Data/Fin/Basic.lean
1,774
1,786
theorem modNat_rev (i : Fin (m * n)) : i.rev.modNat = i.modNat.rev := by
ext have H₁ : i % n + 1 ≀ n := i.modNat.is_lt have Hβ‚‚ : i / n < m := i.divNat.is_lt simp only [coe_modNat, val_rev] calc (m * n - (i + 1)) % n = (m * n - ((i / n) * n + i % n + 1)) % n := by rw [Nat.div_add_mod'] _ = ((m - i / n - 1) * n + (n - (i % n + 1))) % n := by rw [Nat.mul_sub_right_distrib, Nat.one_mul, Nat.sub_add_sub_cancel _ H₁, Nat.mul_sub_right_distrib, Nat.sub_sub, Nat.add_assoc] exact Nat.le_mul_of_pos_left _ <| Nat.le_sub_of_add_le' Hβ‚‚ _ = n - (i % n + 1) := by rw [Nat.mul_comm, Nat.mul_add_mod, Nat.mod_eq_of_lt]; exact i.modNat.rev.is_lt
import Mathlib.Topology.Defs.Induced import Mathlib.Topology.Basic #align_import topology.order from "leanprover-community/mathlib"@"bcfa726826abd57587355b4b5b7e78ad6527b7e4" open Function Set Filter Topology universe u v w namespace TopologicalSpace variable {Ξ± : Type u} inductive GenerateOpen (g : Set (Set Ξ±)) : Set Ξ± β†’ Prop | basic : βˆ€ s ∈ g, GenerateOpen g s | univ : GenerateOpen g univ | inter : βˆ€ s t, GenerateOpen g s β†’ GenerateOpen g t β†’ GenerateOpen g (s ∩ t) | sUnion : βˆ€ S : Set (Set Ξ±), (βˆ€ s ∈ S, GenerateOpen g s) β†’ GenerateOpen g (⋃₀ S) #align topological_space.generate_open TopologicalSpace.GenerateOpen def generateFrom (g : Set (Set Ξ±)) : TopologicalSpace Ξ± where IsOpen := GenerateOpen g isOpen_univ := GenerateOpen.univ isOpen_inter := GenerateOpen.inter isOpen_sUnion := GenerateOpen.sUnion #align topological_space.generate_from TopologicalSpace.generateFrom theorem isOpen_generateFrom_of_mem {g : Set (Set Ξ±)} {s : Set Ξ±} (hs : s ∈ g) : IsOpen[generateFrom g] s := GenerateOpen.basic s hs #align topological_space.is_open_generate_from_of_mem TopologicalSpace.isOpen_generateFrom_of_mem theorem nhds_generateFrom {g : Set (Set Ξ±)} {a : Ξ±} : @nhds Ξ± (generateFrom g) a = β¨… s ∈ { s | a ∈ s ∧ s ∈ g }, π“Ÿ s := by letI := generateFrom g rw [nhds_def] refine le_antisymm (biInf_mono fun s ⟨as, sg⟩ => ⟨as, .basic _ sg⟩) <| le_iInfβ‚‚ ?_ rintro s ⟨ha, hs⟩ induction hs with | basic _ hs => exact iInfβ‚‚_le _ ⟨ha, hs⟩ | univ => exact le_top.trans_eq principal_univ.symm | inter _ _ _ _ hs ht => exact (le_inf (hs ha.1) (ht ha.2)).trans_eq inf_principal | sUnion _ _ hS => let ⟨t, htS, hat⟩ := ha exact (hS t htS hat).trans (principal_mono.2 <| subset_sUnion_of_mem htS) #align topological_space.nhds_generate_from TopologicalSpace.nhds_generateFrom lemma tendsto_nhds_generateFrom_iff {Ξ² : Type*} {m : Ξ± β†’ Ξ²} {f : Filter Ξ±} {g : Set (Set Ξ²)} {b : Ξ²} : Tendsto m f (@nhds Ξ² (generateFrom g) b) ↔ βˆ€ s ∈ g, b ∈ s β†’ m ⁻¹' s ∈ f := by simp only [nhds_generateFrom, @forall_swap (b ∈ _), tendsto_iInf, mem_setOf_eq, and_imp, tendsto_principal]; rfl @[deprecated] alias ⟨_, tendsto_nhds_generateFrom⟩ := tendsto_nhds_generateFrom_iff #align topological_space.tendsto_nhds_generate_from TopologicalSpace.tendsto_nhds_generateFrom protected def mkOfNhds (n : Ξ± β†’ Filter Ξ±) : TopologicalSpace Ξ± where IsOpen s := βˆ€ a ∈ s, s ∈ n a isOpen_univ _ _ := univ_mem isOpen_inter := fun _s _t hs ht x ⟨hxs, hxt⟩ => inter_mem (hs x hxs) (ht x hxt) isOpen_sUnion := fun _s hs _a ⟨x, hx, hxa⟩ => mem_of_superset (hs x hx _ hxa) (subset_sUnion_of_mem hx) #align topological_space.mk_of_nhds TopologicalSpace.mkOfNhds theorem nhds_mkOfNhds_of_hasBasis {n : Ξ± β†’ Filter Ξ±} {ΞΉ : Ξ± β†’ Sort*} {p : βˆ€ a, ΞΉ a β†’ Prop} {s : βˆ€ a, ΞΉ a β†’ Set Ξ±} (hb : βˆ€ a, (n a).HasBasis (p a) (s a)) (hpure : βˆ€ a i, p a i β†’ a ∈ s a i) (hopen : βˆ€ a i, p a i β†’ βˆ€αΆ  x in n a, s a i ∈ n x) (a : Ξ±) : @nhds Ξ± (.mkOfNhds n) a = n a := by let t : TopologicalSpace Ξ± := .mkOfNhds n apply le_antisymm Β· intro U hU replace hpure : pure ≀ n := fun x ↦ (hb x).ge_iff.2 (hpure x) refine mem_nhds_iff.2 ⟨{x | U ∈ n x}, fun x hx ↦ hpure x hx, fun x hx ↦ ?_, hU⟩ rcases (hb x).mem_iff.1 hx with ⟨i, hpi, hi⟩ exact (hopen x i hpi).mono fun y hy ↦ mem_of_superset hy hi Β· exact (nhds_basis_opens a).ge_iff.2 fun U ⟨haU, hUo⟩ ↦ hUo a haU theorem nhds_mkOfNhds (n : Ξ± β†’ Filter Ξ±) (a : Ξ±) (hβ‚€ : pure ≀ n) (h₁ : βˆ€ a, βˆ€ s ∈ n a, βˆ€αΆ  y in n a, s ∈ n y) : @nhds Ξ± (TopologicalSpace.mkOfNhds n) a = n a := nhds_mkOfNhds_of_hasBasis (fun a ↦ (n a).basis_sets) hβ‚€ h₁ _ #align topological_space.nhds_mk_of_nhds TopologicalSpace.nhds_mkOfNhds theorem nhds_mkOfNhds_single [DecidableEq Ξ±] {aβ‚€ : Ξ±} {l : Filter Ξ±} (h : pure aβ‚€ ≀ l) (b : Ξ±) : @nhds Ξ± (TopologicalSpace.mkOfNhds (update pure aβ‚€ l)) b = (update pure aβ‚€ l : Ξ± β†’ Filter Ξ±) b := by refine nhds_mkOfNhds _ _ (le_update_iff.mpr ⟨h, fun _ _ => le_rfl⟩) fun a s hs => ?_ rcases eq_or_ne a aβ‚€ with (rfl | ha) Β· filter_upwards [hs] with b hb rcases eq_or_ne b a with (rfl | hb) Β· exact hs Β· rwa [update_noteq hb] Β· simpa only [update_noteq ha, mem_pure, eventually_pure] using hs #align topological_space.nhds_mk_of_nhds_single TopologicalSpace.nhds_mkOfNhds_single theorem nhds_mkOfNhds_filterBasis (B : Ξ± β†’ FilterBasis Ξ±) (a : Ξ±) (hβ‚€ : βˆ€ x, βˆ€ n ∈ B x, x ∈ n) (h₁ : βˆ€ x, βˆ€ n ∈ B x, βˆƒ n₁ ∈ B x, βˆ€ x' ∈ n₁, βˆƒ nβ‚‚ ∈ B x', nβ‚‚ βŠ† n) : @nhds Ξ± (TopologicalSpace.mkOfNhds fun x => (B x).filter) a = (B a).filter := nhds_mkOfNhds_of_hasBasis (fun a ↦ (B a).hasBasis) hβ‚€ h₁ a #align topological_space.nhds_mk_of_nhds_filter_basis TopologicalSpace.nhds_mkOfNhds_filterBasis section Lattice variable {Ξ± : Type*} {t t₁ tβ‚‚ : TopologicalSpace Ξ±} {s : Set Ξ±} theorem IsOpen.mono (hs : IsOpen[tβ‚‚] s) (h : t₁ ≀ tβ‚‚) : IsOpen[t₁] s := h s hs #align is_open.mono IsOpen.mono theorem IsClosed.mono (hs : IsClosed[tβ‚‚] s) (h : t₁ ≀ tβ‚‚) : IsClosed[t₁] s := (@isOpen_compl_iff Ξ± s t₁).mp <| hs.isOpen_compl.mono h #align is_closed.mono IsClosed.mono theorem closure.mono (h : t₁ ≀ tβ‚‚) : closure[t₁] s βŠ† closure[tβ‚‚] s := @closure_minimal _ s (@closure _ tβ‚‚ s) t₁ subset_closure (IsClosed.mono isClosed_closure h) theorem isOpen_implies_isOpen_iff : (βˆ€ s, IsOpen[t₁] s β†’ IsOpen[tβ‚‚] s) ↔ tβ‚‚ ≀ t₁ := Iff.rfl #align is_open_implies_is_open_iff isOpen_implies_isOpen_iff theorem TopologicalSpace.isOpen_top_iff {Ξ±} (U : Set Ξ±) : IsOpen[⊀] U ↔ U = βˆ… ∨ U = univ := ⟨fun h => by induction h with | basic _ h => exact False.elim h | univ => exact .inr rfl | inter _ _ _ _ h₁ hβ‚‚ => rcases h₁ with (rfl | rfl) <;> rcases hβ‚‚ with (rfl | rfl) <;> simp | sUnion _ _ ih => exact sUnion_mem_empty_univ ih, by rintro (rfl | rfl) exacts [@isOpen_empty _ ⊀, @isOpen_univ _ ⊀]⟩ #align topological_space.is_open_top_iff TopologicalSpace.isOpen_top_iff class DiscreteTopology (Ξ± : Type*) [t : TopologicalSpace Ξ±] : Prop where eq_bot : t = βŠ₯ #align discrete_topology DiscreteTopology theorem discreteTopology_bot (Ξ± : Type*) : @DiscreteTopology Ξ± βŠ₯ := @DiscreteTopology.mk Ξ± βŠ₯ rfl #align discrete_topology_bot discreteTopology_bot -- constructions using the complete lattice structure section iInf open TopologicalSpace variable {Ξ± : Type u} {ΞΉ : Sort v} theorem generateFrom_union (a₁ aβ‚‚ : Set (Set Ξ±)) : generateFrom (a₁ βˆͺ aβ‚‚) = generateFrom a₁ βŠ“ generateFrom aβ‚‚ := (gc_generateFrom Ξ±).u_inf #align generate_from_union generateFrom_union theorem setOf_isOpen_sup (t₁ tβ‚‚ : TopologicalSpace Ξ±) : { s | IsOpen[t₁ βŠ” tβ‚‚] s } = { s | IsOpen[t₁] s } ∩ { s | IsOpen[tβ‚‚] s } := rfl #align set_of_is_open_sup setOf_isOpen_sup theorem generateFrom_iUnion {f : ΞΉ β†’ Set (Set Ξ±)} : generateFrom (⋃ i, f i) = β¨… i, generateFrom (f i) := (gc_generateFrom Ξ±).u_iInf #align generate_from_Union generateFrom_iUnion theorem setOf_isOpen_iSup {t : ΞΉ β†’ TopologicalSpace Ξ±} : { s | IsOpen[⨆ i, t i] s } = β‹‚ i, { s | IsOpen[t i] s } := (gc_generateFrom Ξ±).l_iSup #align set_of_is_open_supr setOf_isOpen_iSup theorem generateFrom_sUnion {S : Set (Set (Set Ξ±))} : generateFrom (⋃₀ S) = β¨… s ∈ S, generateFrom s := (gc_generateFrom Ξ±).u_sInf #align generate_from_sUnion generateFrom_sUnion theorem setOf_isOpen_sSup {T : Set (TopologicalSpace Ξ±)} : { s | IsOpen[sSup T] s } = β‹‚ t ∈ T, { s | IsOpen[t] s } := (gc_generateFrom Ξ±).l_sSup #align set_of_is_open_Sup setOf_isOpen_sSup theorem generateFrom_union_isOpen (a b : TopologicalSpace Ξ±) : generateFrom ({ s | IsOpen[a] s } βˆͺ { s | IsOpen[b] s }) = a βŠ“ b := (gciGenerateFrom Ξ±).u_inf_l _ _ #align generate_from_union_is_open generateFrom_union_isOpen theorem generateFrom_iUnion_isOpen (f : ΞΉ β†’ TopologicalSpace Ξ±) : generateFrom (⋃ i, { s | IsOpen[f i] s }) = β¨… i, f i := (gciGenerateFrom Ξ±).u_iInf_l _ #align generate_from_Union_is_open generateFrom_iUnion_isOpen theorem generateFrom_inter (a b : TopologicalSpace Ξ±) : generateFrom ({ s | IsOpen[a] s } ∩ { s | IsOpen[b] s }) = a βŠ” b := (gciGenerateFrom Ξ±).u_sup_l _ _ #align generate_from_inter generateFrom_inter theorem generateFrom_iInter (f : ΞΉ β†’ TopologicalSpace Ξ±) : generateFrom (β‹‚ i, { s | IsOpen[f i] s }) = ⨆ i, f i := (gciGenerateFrom Ξ±).u_iSup_l _ #align generate_from_Inter generateFrom_iInter theorem generateFrom_iInter_of_generateFrom_eq_self (f : ΞΉ β†’ Set (Set Ξ±)) (hf : βˆ€ i, { s | IsOpen[generateFrom (f i)] s } = f i) : generateFrom (β‹‚ i, f i) = ⨆ i, generateFrom (f i) := (gciGenerateFrom Ξ±).u_iSup_of_lu_eq_self f hf #align generate_from_Inter_of_generate_from_eq_self generateFrom_iInter_of_generateFrom_eq_self variable {t : ΞΉ β†’ TopologicalSpace Ξ±} theorem isOpen_iSup_iff {s : Set Ξ±} : IsOpen[⨆ i, t i] s ↔ βˆ€ i, IsOpen[t i] s := show s ∈ {s | IsOpen[iSup t] s} ↔ s ∈ { x : Set Ξ± | βˆ€ i : ΞΉ, IsOpen[t i] x } by simp [setOf_isOpen_iSup] #align is_open_supr_iff isOpen_iSup_iff set_option tactic.skipAssignedInstances false in
Mathlib/Topology/Order.lean
987
988
theorem isClosed_iSup_iff {s : Set Ξ±} : IsClosed[⨆ i, t i] s ↔ βˆ€ i, IsClosed[t i] s := by
simp [← @isOpen_compl_iff _ _ (⨆ i, t i), ← @isOpen_compl_iff _ _ (t _), isOpen_iSup_iff]
import Mathlib.Data.Set.Function import Mathlib.Logic.Equiv.Defs import Mathlib.Tactic.Core import Mathlib.Tactic.Attr.Core #align_import logic.equiv.local_equiv from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" open Lean Meta Elab Tactic def mfld_cfg : Simps.Config where attrs := [`mfld_simps] fullyApplied := false #align mfld_cfg mfld_cfg open Function Set variable {Ξ± : Type*} {Ξ² : Type*} {Ξ³ : Type*} {Ξ΄ : Type*} structure PartialEquiv (Ξ± : Type*) (Ξ² : Type*) where toFun : Ξ± β†’ Ξ² invFun : Ξ² β†’ Ξ± source : Set Ξ± target : Set Ξ² map_source' : βˆ€ ⦃x⦄, x ∈ source β†’ toFun x ∈ target map_target' : βˆ€ ⦃x⦄, x ∈ target β†’ invFun x ∈ source left_inv' : βˆ€ ⦃x⦄, x ∈ source β†’ invFun (toFun x) = x right_inv' : βˆ€ ⦃x⦄, x ∈ target β†’ toFun (invFun x) = x #align local_equiv PartialEquiv attribute [coe] PartialEquiv.toFun namespace PartialEquiv variable (e : PartialEquiv Ξ± Ξ²) (e' : PartialEquiv Ξ² Ξ³) instance [Inhabited Ξ±] [Inhabited Ξ²] : Inhabited (PartialEquiv Ξ± Ξ²) := ⟨⟨const Ξ± default, const Ξ² default, βˆ…, βˆ…, mapsTo_empty _ _, mapsTo_empty _ _, eqOn_empty _ _, eqOn_empty _ _⟩⟩ @[symm] protected def symm : PartialEquiv Ξ² Ξ± where toFun := e.invFun invFun := e.toFun source := e.target target := e.source map_source' := e.map_target' map_target' := e.map_source' left_inv' := e.right_inv' right_inv' := e.left_inv' #align local_equiv.symm PartialEquiv.symm instance : CoeFun (PartialEquiv Ξ± Ξ²) fun _ => Ξ± β†’ Ξ² := ⟨PartialEquiv.toFun⟩ def Simps.symm_apply (e : PartialEquiv Ξ± Ξ²) : Ξ² β†’ Ξ± := e.symm #align local_equiv.simps.symm_apply PartialEquiv.Simps.symm_apply initialize_simps_projections PartialEquiv (toFun β†’ apply, invFun β†’ symm_apply) -- Porting note: this can be proven with `dsimp only` -- @[simp, mfld_simps] -- theorem coe_mk (f : Ξ± β†’ Ξ²) (g s t ml mr il ir) : -- (PartialEquiv.mk f g s t ml mr il ir : Ξ± β†’ Ξ²) = f := by dsimp only -- #align local_equiv.coe_mk PartialEquiv.coe_mk #noalign local_equiv.coe_mk @[simp, mfld_simps] theorem coe_symm_mk (f : Ξ± β†’ Ξ²) (g s t ml mr il ir) : ((PartialEquiv.mk f g s t ml mr il ir).symm : Ξ² β†’ Ξ±) = g := rfl #align local_equiv.coe_symm_mk PartialEquiv.coe_symm_mk -- Porting note: this is now a syntactic tautology -- @[simp, mfld_simps] -- theorem toFun_as_coe : e.toFun = e := rfl -- #align local_equiv.to_fun_as_coe PartialEquiv.toFun_as_coe #noalign local_equiv.to_fun_as_coe @[simp, mfld_simps] theorem invFun_as_coe : e.invFun = e.symm := rfl #align local_equiv.inv_fun_as_coe PartialEquiv.invFun_as_coe @[simp, mfld_simps] theorem map_source {x : Ξ±} (h : x ∈ e.source) : e x ∈ e.target := e.map_source' h #align local_equiv.map_source PartialEquiv.map_source lemma map_source'' : e '' e.source βŠ† e.target := fun _ ⟨_, hx, hex⟩ ↦ mem_of_eq_of_mem (id hex.symm) (e.map_source' hx) @[simp, mfld_simps] theorem map_target {x : Ξ²} (h : x ∈ e.target) : e.symm x ∈ e.source := e.map_target' h #align local_equiv.map_target PartialEquiv.map_target @[simp, mfld_simps] theorem left_inv {x : Ξ±} (h : x ∈ e.source) : e.symm (e x) = x := e.left_inv' h #align local_equiv.left_inv PartialEquiv.left_inv @[simp, mfld_simps] theorem right_inv {x : Ξ²} (h : x ∈ e.target) : e (e.symm x) = x := e.right_inv' h #align local_equiv.right_inv PartialEquiv.right_inv theorem eq_symm_apply {x : Ξ±} {y : Ξ²} (hx : x ∈ e.source) (hy : y ∈ e.target) : x = e.symm y ↔ e x = y := ⟨fun h => by rw [← e.right_inv hy, h], fun h => by rw [← e.left_inv hx, h]⟩ #align local_equiv.eq_symm_apply PartialEquiv.eq_symm_apply protected theorem mapsTo : MapsTo e e.source e.target := fun _ => e.map_source #align local_equiv.maps_to PartialEquiv.mapsTo theorem symm_mapsTo : MapsTo e.symm e.target e.source := e.symm.mapsTo #align local_equiv.symm_maps_to PartialEquiv.symm_mapsTo protected theorem leftInvOn : LeftInvOn e.symm e e.source := fun _ => e.left_inv #align local_equiv.left_inv_on PartialEquiv.leftInvOn protected theorem rightInvOn : RightInvOn e.symm e e.target := fun _ => e.right_inv #align local_equiv.right_inv_on PartialEquiv.rightInvOn protected theorem invOn : InvOn e.symm e e.source e.target := ⟨e.leftInvOn, e.rightInvOn⟩ #align local_equiv.inv_on PartialEquiv.invOn protected theorem injOn : InjOn e e.source := e.leftInvOn.injOn #align local_equiv.inj_on PartialEquiv.injOn protected theorem bijOn : BijOn e e.source e.target := e.invOn.bijOn e.mapsTo e.symm_mapsTo #align local_equiv.bij_on PartialEquiv.bijOn protected theorem surjOn : SurjOn e e.source e.target := e.bijOn.surjOn #align local_equiv.surj_on PartialEquiv.surjOn @[simps (config := .asFn)] def _root_.Equiv.toPartialEquivOfImageEq (e : Ξ± ≃ Ξ²) (s : Set Ξ±) (t : Set Ξ²) (h : e '' s = t) : PartialEquiv Ξ± Ξ² where toFun := e invFun := e.symm source := s target := t map_source' x hx := h β–Έ mem_image_of_mem _ hx map_target' x hx := by subst t rcases hx with ⟨x, hx, rfl⟩ rwa [e.symm_apply_apply] left_inv' x _ := e.symm_apply_apply x right_inv' x _ := e.apply_symm_apply x @[simps! (config := mfld_cfg)] def _root_.Equiv.toPartialEquiv (e : Ξ± ≃ Ξ²) : PartialEquiv Ξ± Ξ² := e.toPartialEquivOfImageEq univ univ <| by rw [image_univ, e.surjective.range_eq] #align equiv.to_local_equiv Equiv.toPartialEquiv #align equiv.to_local_equiv_symm_apply Equiv.toPartialEquiv_symm_apply #align equiv.to_local_equiv_target Equiv.toPartialEquiv_target #align equiv.to_local_equiv_apply Equiv.toPartialEquiv_apply #align equiv.to_local_equiv_source Equiv.toPartialEquiv_source instance inhabitedOfEmpty [IsEmpty Ξ±] [IsEmpty Ξ²] : Inhabited (PartialEquiv Ξ± Ξ²) := ⟨((Equiv.equivEmpty Ξ±).trans (Equiv.equivEmpty Ξ²).symm).toPartialEquiv⟩ #align local_equiv.inhabited_of_empty PartialEquiv.inhabitedOfEmpty @[simps (config := .asFn)] def copy (e : PartialEquiv Ξ± Ξ²) (f : Ξ± β†’ Ξ²) (hf : ⇑e = f) (g : Ξ² β†’ Ξ±) (hg : ⇑e.symm = g) (s : Set Ξ±) (hs : e.source = s) (t : Set Ξ²) (ht : e.target = t) : PartialEquiv Ξ± Ξ² where toFun := f invFun := g source := s target := t map_source' _ := ht β–Έ hs β–Έ hf β–Έ e.map_source map_target' _ := hs β–Έ ht β–Έ hg β–Έ e.map_target left_inv' _ := hs β–Έ hf β–Έ hg β–Έ e.left_inv right_inv' _ := ht β–Έ hf β–Έ hg β–Έ e.right_inv #align local_equiv.copy PartialEquiv.copy #align local_equiv.copy_source PartialEquiv.copy_source #align local_equiv.copy_apply PartialEquiv.copy_apply #align local_equiv.copy_symm_apply PartialEquiv.copy_symm_apply #align local_equiv.copy_target PartialEquiv.copy_target theorem copy_eq (e : PartialEquiv Ξ± Ξ²) (f : Ξ± β†’ Ξ²) (hf : ⇑e = f) (g : Ξ² β†’ Ξ±) (hg : ⇑e.symm = g) (s : Set Ξ±) (hs : e.source = s) (t : Set Ξ²) (ht : e.target = t) : e.copy f hf g hg s hs t ht = e := by substs f g s t cases e rfl #align local_equiv.copy_eq PartialEquiv.copy_eq protected def toEquiv : e.source ≃ e.target where toFun x := ⟨e x, e.map_source x.mem⟩ invFun y := ⟨e.symm y, e.map_target y.mem⟩ left_inv := fun ⟨_, hx⟩ => Subtype.eq <| e.left_inv hx right_inv := fun ⟨_, hy⟩ => Subtype.eq <| e.right_inv hy #align local_equiv.to_equiv PartialEquiv.toEquiv @[simp, mfld_simps] theorem symm_source : e.symm.source = e.target := rfl #align local_equiv.symm_source PartialEquiv.symm_source @[simp, mfld_simps] theorem symm_target : e.symm.target = e.source := rfl #align local_equiv.symm_target PartialEquiv.symm_target @[simp, mfld_simps] theorem symm_symm : e.symm.symm = e := by cases e rfl #align local_equiv.symm_symm PartialEquiv.symm_symm theorem symm_bijective : Function.Bijective (PartialEquiv.symm : PartialEquiv Ξ± Ξ² β†’ PartialEquiv Ξ² Ξ±) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ theorem image_source_eq_target : e '' e.source = e.target := e.bijOn.image_eq #align local_equiv.image_source_eq_target PartialEquiv.image_source_eq_target theorem forall_mem_target {p : Ξ² β†’ Prop} : (βˆ€ y ∈ e.target, p y) ↔ βˆ€ x ∈ e.source, p (e x) := by rw [← image_source_eq_target, forall_mem_image] #align local_equiv.forall_mem_target PartialEquiv.forall_mem_target theorem exists_mem_target {p : Ξ² β†’ Prop} : (βˆƒ y ∈ e.target, p y) ↔ βˆƒ x ∈ e.source, p (e x) := by rw [← image_source_eq_target, exists_mem_image] #align local_equiv.exists_mem_target PartialEquiv.exists_mem_target def IsImage (s : Set Ξ±) (t : Set Ξ²) : Prop := βˆ€ ⦃x⦄, x ∈ e.source β†’ (e x ∈ t ↔ x ∈ s) #align local_equiv.is_image PartialEquiv.IsImage theorem isImage_source_target : e.IsImage e.source e.target := fun x hx => by simp [hx] #align local_equiv.is_image_source_target PartialEquiv.isImage_source_target theorem isImage_source_target_of_disjoint (e' : PartialEquiv Ξ± Ξ²) (hs : Disjoint e.source e'.source) (ht : Disjoint e.target e'.target) : e.IsImage e'.source e'.target := IsImage.of_image_eq <| by rw [hs.inter_eq, ht.inter_eq, image_empty] #align local_equiv.is_image_source_target_of_disjoint PartialEquiv.isImage_source_target_of_disjoint theorem image_source_inter_eq' (s : Set Ξ±) : e '' (e.source ∩ s) = e.target ∩ e.symm ⁻¹' s := by rw [inter_comm, e.leftInvOn.image_inter', image_source_eq_target, inter_comm] #align local_equiv.image_source_inter_eq' PartialEquiv.image_source_inter_eq' theorem image_source_inter_eq (s : Set Ξ±) : e '' (e.source ∩ s) = e.target ∩ e.symm ⁻¹' (e.source ∩ s) := by rw [inter_comm, e.leftInvOn.image_inter, image_source_eq_target, inter_comm] #align local_equiv.image_source_inter_eq PartialEquiv.image_source_inter_eq theorem image_eq_target_inter_inv_preimage {s : Set Ξ±} (h : s βŠ† e.source) : e '' s = e.target ∩ e.symm ⁻¹' s := by rw [← e.image_source_inter_eq', inter_eq_self_of_subset_right h] #align local_equiv.image_eq_target_inter_inv_preimage PartialEquiv.image_eq_target_inter_inv_preimage theorem symm_image_eq_source_inter_preimage {s : Set Ξ²} (h : s βŠ† e.target) : e.symm '' s = e.source ∩ e ⁻¹' s := e.symm.image_eq_target_inter_inv_preimage h #align local_equiv.symm_image_eq_source_inter_preimage PartialEquiv.symm_image_eq_source_inter_preimage theorem symm_image_target_inter_eq (s : Set Ξ²) : e.symm '' (e.target ∩ s) = e.source ∩ e ⁻¹' (e.target ∩ s) := e.symm.image_source_inter_eq _ #align local_equiv.symm_image_target_inter_eq PartialEquiv.symm_image_target_inter_eq theorem symm_image_target_inter_eq' (s : Set Ξ²) : e.symm '' (e.target ∩ s) = e.source ∩ e ⁻¹' s := e.symm.image_source_inter_eq' _ #align local_equiv.symm_image_target_inter_eq' PartialEquiv.symm_image_target_inter_eq' theorem source_inter_preimage_inv_preimage (s : Set Ξ±) : e.source ∩ e ⁻¹' (e.symm ⁻¹' s) = e.source ∩ s := Set.ext fun x => and_congr_right_iff.2 fun hx => by simp only [mem_preimage, e.left_inv hx] #align local_equiv.source_inter_preimage_inv_preimage PartialEquiv.source_inter_preimage_inv_preimage theorem source_inter_preimage_target_inter (s : Set Ξ²) : e.source ∩ e ⁻¹' (e.target ∩ s) = e.source ∩ e ⁻¹' s := ext fun _ => ⟨fun hx => ⟨hx.1, hx.2.2⟩, fun hx => ⟨hx.1, e.map_source hx.1, hx.2⟩⟩ #align local_equiv.source_inter_preimage_target_inter PartialEquiv.source_inter_preimage_target_inter theorem target_inter_inv_preimage_preimage (s : Set Ξ²) : e.target ∩ e.symm ⁻¹' (e ⁻¹' s) = e.target ∩ s := e.symm.source_inter_preimage_inv_preimage _ #align local_equiv.target_inter_inv_preimage_preimage PartialEquiv.target_inter_inv_preimage_preimage theorem symm_image_image_of_subset_source {s : Set Ξ±} (h : s βŠ† e.source) : e.symm '' (e '' s) = s := (e.leftInvOn.mono h).image_image #align local_equiv.symm_image_image_of_subset_source PartialEquiv.symm_image_image_of_subset_source theorem image_symm_image_of_subset_target {s : Set Ξ²} (h : s βŠ† e.target) : e '' (e.symm '' s) = s := e.symm.symm_image_image_of_subset_source h #align local_equiv.image_symm_image_of_subset_target PartialEquiv.image_symm_image_of_subset_target theorem source_subset_preimage_target : e.source βŠ† e ⁻¹' e.target := e.mapsTo #align local_equiv.source_subset_preimage_target PartialEquiv.source_subset_preimage_target theorem symm_image_target_eq_source : e.symm '' e.target = e.source := e.symm.image_source_eq_target #align local_equiv.symm_image_target_eq_source PartialEquiv.symm_image_target_eq_source theorem target_subset_preimage_source : e.target βŠ† e.symm ⁻¹' e.source := e.symm_mapsTo #align local_equiv.target_subset_preimage_source PartialEquiv.target_subset_preimage_source @[ext] protected theorem ext {e e' : PartialEquiv Ξ± Ξ²} (h : βˆ€ x, e x = e' x) (hsymm : βˆ€ x, e.symm x = e'.symm x) (hs : e.source = e'.source) : e = e' := by have A : (e : Ξ± β†’ Ξ²) = e' := by ext x exact h x have B : (e.symm : Ξ² β†’ Ξ±) = e'.symm := by ext x exact hsymm x have I : e '' e.source = e.target := e.image_source_eq_target have I' : e' '' e'.source = e'.target := e'.image_source_eq_target rw [A, hs, I'] at I cases e; cases e' simp_all #align local_equiv.ext PartialEquiv.ext protected def restr (s : Set Ξ±) : PartialEquiv Ξ± Ξ² := (@IsImage.of_symm_preimage_eq Ξ± Ξ² e s (e.symm ⁻¹' s) rfl).restr #align local_equiv.restr PartialEquiv.restr @[simp, mfld_simps] theorem restr_coe (s : Set Ξ±) : (e.restr s : Ξ± β†’ Ξ²) = e := rfl #align local_equiv.restr_coe PartialEquiv.restr_coe @[simp, mfld_simps] theorem restr_coe_symm (s : Set Ξ±) : ((e.restr s).symm : Ξ² β†’ Ξ±) = e.symm := rfl #align local_equiv.restr_coe_symm PartialEquiv.restr_coe_symm @[simp, mfld_simps] theorem restr_source (s : Set Ξ±) : (e.restr s).source = e.source ∩ s := rfl #align local_equiv.restr_source PartialEquiv.restr_source @[simp, mfld_simps] theorem restr_target (s : Set Ξ±) : (e.restr s).target = e.target ∩ e.symm ⁻¹' s := rfl #align local_equiv.restr_target PartialEquiv.restr_target theorem restr_eq_of_source_subset {e : PartialEquiv Ξ± Ξ²} {s : Set Ξ±} (h : e.source βŠ† s) : e.restr s = e := PartialEquiv.ext (fun _ => rfl) (fun _ => rfl) (by simp [inter_eq_self_of_subset_left h]) #align local_equiv.restr_eq_of_source_subset PartialEquiv.restr_eq_of_source_subset @[simp, mfld_simps] theorem restr_univ {e : PartialEquiv Ξ± Ξ²} : e.restr univ = e := restr_eq_of_source_subset (subset_univ _) #align local_equiv.restr_univ PartialEquiv.restr_univ protected def refl (Ξ± : Type*) : PartialEquiv Ξ± Ξ± := (Equiv.refl Ξ±).toPartialEquiv #align local_equiv.refl PartialEquiv.refl @[simp, mfld_simps] theorem refl_source : (PartialEquiv.refl Ξ±).source = univ := rfl #align local_equiv.refl_source PartialEquiv.refl_source @[simp, mfld_simps] theorem refl_target : (PartialEquiv.refl Ξ±).target = univ := rfl #align local_equiv.refl_target PartialEquiv.refl_target @[simp, mfld_simps] theorem refl_coe : (PartialEquiv.refl Ξ± : Ξ± β†’ Ξ±) = id := rfl #align local_equiv.refl_coe PartialEquiv.refl_coe @[simp, mfld_simps] theorem refl_symm : (PartialEquiv.refl Ξ±).symm = PartialEquiv.refl Ξ± := rfl #align local_equiv.refl_symm PartialEquiv.refl_symm -- Porting note: removed `simp` because `simp` can prove this @[mfld_simps] theorem refl_restr_source (s : Set Ξ±) : ((PartialEquiv.refl Ξ±).restr s).source = s := by simp #align local_equiv.refl_restr_source PartialEquiv.refl_restr_source -- Porting note: removed `simp` because `simp` can prove this @[mfld_simps] theorem refl_restr_target (s : Set Ξ±) : ((PartialEquiv.refl Ξ±).restr s).target = s := by change univ ∩ id ⁻¹' s = s simp #align local_equiv.refl_restr_target PartialEquiv.refl_restr_target def ofSet (s : Set Ξ±) : PartialEquiv Ξ± Ξ± where toFun := id invFun := id source := s target := s map_source' _ hx := hx map_target' _ hx := hx left_inv' _ _ := rfl right_inv' _ _ := rfl #align local_equiv.of_set PartialEquiv.ofSet @[simp, mfld_simps] theorem ofSet_source (s : Set Ξ±) : (PartialEquiv.ofSet s).source = s := rfl #align local_equiv.of_set_source PartialEquiv.ofSet_source @[simp, mfld_simps] theorem ofSet_target (s : Set Ξ±) : (PartialEquiv.ofSet s).target = s := rfl #align local_equiv.of_set_target PartialEquiv.ofSet_target @[simp, mfld_simps] theorem ofSet_coe (s : Set Ξ±) : (PartialEquiv.ofSet s : Ξ± β†’ Ξ±) = id := rfl #align local_equiv.of_set_coe PartialEquiv.ofSet_coe @[simp, mfld_simps] theorem ofSet_symm (s : Set Ξ±) : (PartialEquiv.ofSet s).symm = PartialEquiv.ofSet s := rfl #align local_equiv.of_set_symm PartialEquiv.ofSet_symm @[simps] protected def trans' (e' : PartialEquiv Ξ² Ξ³) (h : e.target = e'.source) : PartialEquiv Ξ± Ξ³ where toFun := e' ∘ e invFun := e.symm ∘ e'.symm source := e.source target := e'.target map_source' x hx := by simp [← h, hx] map_target' y hy := by simp [h, hy] left_inv' x hx := by simp [hx, ← h] right_inv' y hy := by simp [hy, h] #align local_equiv.trans' PartialEquiv.trans' @[trans] protected def trans : PartialEquiv Ξ± Ξ³ := PartialEquiv.trans' (e.symm.restr e'.source).symm (e'.restr e.target) (inter_comm _ _) #align local_equiv.trans PartialEquiv.trans @[simp, mfld_simps] theorem coe_trans : (e.trans e' : Ξ± β†’ Ξ³) = e' ∘ e := rfl #align local_equiv.coe_trans PartialEquiv.coe_trans @[simp, mfld_simps] theorem coe_trans_symm : ((e.trans e').symm : Ξ³ β†’ Ξ±) = e.symm ∘ e'.symm := rfl #align local_equiv.coe_trans_symm PartialEquiv.coe_trans_symm theorem trans_apply {x : Ξ±} : (e.trans e') x = e' (e x) := rfl #align local_equiv.trans_apply PartialEquiv.trans_apply theorem trans_symm_eq_symm_trans_symm : (e.trans e').symm = e'.symm.trans e.symm := by cases e; cases e'; rfl #align local_equiv.trans_symm_eq_symm_trans_symm PartialEquiv.trans_symm_eq_symm_trans_symm @[simp, mfld_simps] theorem trans_source : (e.trans e').source = e.source ∩ e ⁻¹' e'.source := rfl #align local_equiv.trans_source PartialEquiv.trans_source
Mathlib/Logic/Equiv/PartialEquiv.lean
720
721
theorem trans_source' : (e.trans e').source = e.source ∩ e ⁻¹' (e.target ∩ e'.source) := by
mfld_set_tac
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]
Mathlib/Algebra/BigOperators/Group/Finset.lean
464
468
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]
import Mathlib.Algebra.Polynomial.Splits #align_import algebra.cubic_discriminant from "leanprover-community/mathlib"@"930133160e24036d5242039fe4972407cd4f1222" noncomputable section @[ext] structure Cubic (R : Type*) where (a b c d : R) #align cubic Cubic namespace Cubic open Cubic Polynomial open Polynomial variable {R S F K : Type*} instance [Inhabited R] : Inhabited (Cubic R) := ⟨⟨default, default, default, default⟩⟩ instance [Zero R] : Zero (Cubic R) := ⟨⟨0, 0, 0, 0⟩⟩ section Basic variable {P Q : Cubic R} {a b c d a' b' c' d' : R} [Semiring R] def toPoly (P : Cubic R) : R[X] := C P.a * X ^ 3 + C P.b * X ^ 2 + C P.c * X + C P.d #align cubic.to_poly Cubic.toPoly theorem C_mul_prod_X_sub_C_eq [CommRing S] {w x y z : S} : C w * (X - C x) * (X - C y) * (X - C z) = toPoly ⟨w, w * -(x + y + z), w * (x * y + x * z + y * z), w * -(x * y * z)⟩ := by simp only [toPoly, C_neg, C_add, C_mul] ring1 set_option linter.uppercaseLean3 false in #align cubic.C_mul_prod_X_sub_C_eq Cubic.C_mul_prod_X_sub_C_eq theorem prod_X_sub_C_eq [CommRing S] {x y z : S} : (X - C x) * (X - C y) * (X - C z) = toPoly ⟨1, -(x + y + z), x * y + x * z + y * z, -(x * y * z)⟩ := by rw [← one_mul <| X - C x, ← C_1, C_mul_prod_X_sub_C_eq, one_mul, one_mul, one_mul] set_option linter.uppercaseLean3 false in #align cubic.prod_X_sub_C_eq Cubic.prod_X_sub_C_eq section Coeff private theorem coeffs : (βˆ€ n > 3, P.toPoly.coeff n = 0) ∧ P.toPoly.coeff 3 = P.a ∧ P.toPoly.coeff 2 = P.b ∧ P.toPoly.coeff 1 = P.c ∧ P.toPoly.coeff 0 = P.d := by simp only [toPoly, coeff_add, coeff_C, coeff_C_mul_X, coeff_C_mul_X_pow] set_option tactic.skipAssignedInstances false in norm_num intro n hn repeat' rw [if_neg] any_goals linarith only [hn] repeat' rw [zero_add] @[simp] theorem coeff_eq_zero {n : β„•} (hn : 3 < n) : P.toPoly.coeff n = 0 := coeffs.1 n hn #align cubic.coeff_eq_zero Cubic.coeff_eq_zero @[simp] theorem coeff_eq_a : P.toPoly.coeff 3 = P.a := coeffs.2.1 #align cubic.coeff_eq_a Cubic.coeff_eq_a @[simp] theorem coeff_eq_b : P.toPoly.coeff 2 = P.b := coeffs.2.2.1 #align cubic.coeff_eq_b Cubic.coeff_eq_b @[simp] theorem coeff_eq_c : P.toPoly.coeff 1 = P.c := coeffs.2.2.2.1 #align cubic.coeff_eq_c Cubic.coeff_eq_c @[simp] theorem coeff_eq_d : P.toPoly.coeff 0 = P.d := coeffs.2.2.2.2 #align cubic.coeff_eq_d Cubic.coeff_eq_d theorem a_of_eq (h : P.toPoly = Q.toPoly) : P.a = Q.a := by rw [← coeff_eq_a, h, coeff_eq_a] #align cubic.a_of_eq Cubic.a_of_eq theorem b_of_eq (h : P.toPoly = Q.toPoly) : P.b = Q.b := by rw [← coeff_eq_b, h, coeff_eq_b] #align cubic.b_of_eq Cubic.b_of_eq theorem c_of_eq (h : P.toPoly = Q.toPoly) : P.c = Q.c := by rw [← coeff_eq_c, h, coeff_eq_c] #align cubic.c_of_eq Cubic.c_of_eq theorem d_of_eq (h : P.toPoly = Q.toPoly) : P.d = Q.d := by rw [← coeff_eq_d, h, coeff_eq_d] #align cubic.d_of_eq Cubic.d_of_eq theorem toPoly_injective (P Q : Cubic R) : P.toPoly = Q.toPoly ↔ P = Q := ⟨fun h ↦ Cubic.ext P Q (a_of_eq h) (b_of_eq h) (c_of_eq h) (d_of_eq h), congr_arg toPoly⟩ #align cubic.to_poly_injective Cubic.toPoly_injective theorem of_a_eq_zero (ha : P.a = 0) : P.toPoly = C P.b * X ^ 2 + C P.c * X + C P.d := by rw [toPoly, ha, C_0, zero_mul, zero_add] #align cubic.of_a_eq_zero Cubic.of_a_eq_zero theorem of_a_eq_zero' : toPoly ⟨0, b, c, d⟩ = C b * X ^ 2 + C c * X + C d := of_a_eq_zero rfl #align cubic.of_a_eq_zero' Cubic.of_a_eq_zero' theorem of_b_eq_zero (ha : P.a = 0) (hb : P.b = 0) : P.toPoly = C P.c * X + C P.d := by rw [of_a_eq_zero ha, hb, C_0, zero_mul, zero_add] #align cubic.of_b_eq_zero Cubic.of_b_eq_zero theorem of_b_eq_zero' : toPoly ⟨0, 0, c, d⟩ = C c * X + C d := of_b_eq_zero rfl rfl #align cubic.of_b_eq_zero' Cubic.of_b_eq_zero' theorem of_c_eq_zero (ha : P.a = 0) (hb : P.b = 0) (hc : P.c = 0) : P.toPoly = C P.d := by rw [of_b_eq_zero ha hb, hc, C_0, zero_mul, zero_add] #align cubic.of_c_eq_zero Cubic.of_c_eq_zero theorem of_c_eq_zero' : toPoly ⟨0, 0, 0, d⟩ = C d := of_c_eq_zero rfl rfl rfl #align cubic.of_c_eq_zero' Cubic.of_c_eq_zero' theorem of_d_eq_zero (ha : P.a = 0) (hb : P.b = 0) (hc : P.c = 0) (hd : P.d = 0) : P.toPoly = 0 := by rw [of_c_eq_zero ha hb hc, hd, C_0] #align cubic.of_d_eq_zero Cubic.of_d_eq_zero theorem of_d_eq_zero' : (⟨0, 0, 0, 0⟩ : Cubic R).toPoly = 0 := of_d_eq_zero rfl rfl rfl rfl #align cubic.of_d_eq_zero' Cubic.of_d_eq_zero' theorem zero : (0 : Cubic R).toPoly = 0 := of_d_eq_zero' #align cubic.zero Cubic.zero theorem toPoly_eq_zero_iff (P : Cubic R) : P.toPoly = 0 ↔ P = 0 := by rw [← zero, toPoly_injective] #align cubic.to_poly_eq_zero_iff Cubic.toPoly_eq_zero_iff private theorem ne_zero (h0 : P.a β‰  0 ∨ P.b β‰  0 ∨ P.c β‰  0 ∨ P.d β‰  0) : P.toPoly β‰  0 := by contrapose! h0 rw [(toPoly_eq_zero_iff P).mp h0] exact ⟨rfl, rfl, rfl, rfl⟩ theorem ne_zero_of_a_ne_zero (ha : P.a β‰  0) : P.toPoly β‰  0 := (or_imp.mp ne_zero).1 ha #align cubic.ne_zero_of_a_ne_zero Cubic.ne_zero_of_a_ne_zero theorem ne_zero_of_b_ne_zero (hb : P.b β‰  0) : P.toPoly β‰  0 := (or_imp.mp (or_imp.mp ne_zero).2).1 hb #align cubic.ne_zero_of_b_ne_zero Cubic.ne_zero_of_b_ne_zero theorem ne_zero_of_c_ne_zero (hc : P.c β‰  0) : P.toPoly β‰  0 := (or_imp.mp (or_imp.mp (or_imp.mp ne_zero).2).2).1 hc #align cubic.ne_zero_of_c_ne_zero Cubic.ne_zero_of_c_ne_zero theorem ne_zero_of_d_ne_zero (hd : P.d β‰  0) : P.toPoly β‰  0 := (or_imp.mp (or_imp.mp (or_imp.mp ne_zero).2).2).2 hd #align cubic.ne_zero_of_d_ne_zero Cubic.ne_zero_of_d_ne_zero @[simp] theorem leadingCoeff_of_a_ne_zero (ha : P.a β‰  0) : P.toPoly.leadingCoeff = P.a := leadingCoeff_cubic ha #align cubic.leading_coeff_of_a_ne_zero Cubic.leadingCoeff_of_a_ne_zero @[simp] theorem leadingCoeff_of_a_ne_zero' (ha : a β‰  0) : (toPoly ⟨a, b, c, d⟩).leadingCoeff = a := leadingCoeff_of_a_ne_zero ha #align cubic.leading_coeff_of_a_ne_zero' Cubic.leadingCoeff_of_a_ne_zero' @[simp] theorem leadingCoeff_of_b_ne_zero (ha : P.a = 0) (hb : P.b β‰  0) : P.toPoly.leadingCoeff = P.b := by rw [of_a_eq_zero ha, leadingCoeff_quadratic hb] #align cubic.leading_coeff_of_b_ne_zero Cubic.leadingCoeff_of_b_ne_zero @[simp] theorem leadingCoeff_of_b_ne_zero' (hb : b β‰  0) : (toPoly ⟨0, b, c, d⟩).leadingCoeff = b := leadingCoeff_of_b_ne_zero rfl hb #align cubic.leading_coeff_of_b_ne_zero' Cubic.leadingCoeff_of_b_ne_zero' @[simp] theorem leadingCoeff_of_c_ne_zero (ha : P.a = 0) (hb : P.b = 0) (hc : P.c β‰  0) : P.toPoly.leadingCoeff = P.c := by rw [of_b_eq_zero ha hb, leadingCoeff_linear hc] #align cubic.leading_coeff_of_c_ne_zero Cubic.leadingCoeff_of_c_ne_zero @[simp] theorem leadingCoeff_of_c_ne_zero' (hc : c β‰  0) : (toPoly ⟨0, 0, c, d⟩).leadingCoeff = c := leadingCoeff_of_c_ne_zero rfl rfl hc #align cubic.leading_coeff_of_c_ne_zero' Cubic.leadingCoeff_of_c_ne_zero' @[simp]
Mathlib/Algebra/CubicDiscriminant.lean
231
233
theorem leadingCoeff_of_c_eq_zero (ha : P.a = 0) (hb : P.b = 0) (hc : P.c = 0) : P.toPoly.leadingCoeff = P.d := by
rw [of_c_eq_zero ha hb hc, leadingCoeff_C]
import Mathlib.CategoryTheory.Subobject.Limits #align_import algebra.homology.image_to_kernel from "leanprover-community/mathlib"@"618ea3d5c99240cd7000d8376924906a148bf9ff" universe v u w open CategoryTheory CategoryTheory.Limits variable {ΞΉ : Type*} variable {V : Type u} [Category.{v} V] [HasZeroMorphisms V] open scoped Classical noncomputable section section variable {A B C : V} (f : A ⟢ B) [HasImage f] (g : B ⟢ C) [HasKernel g] theorem image_le_kernel (w : f ≫ g = 0) : imageSubobject f ≀ kernelSubobject g := imageSubobject_le_mk _ _ (kernel.lift _ _ w) (by simp) #align image_le_kernel image_le_kernel def imageToKernel (w : f ≫ g = 0) : (imageSubobject f : V) ⟢ (kernelSubobject g : V) := Subobject.ofLE _ _ (image_le_kernel _ _ w) #align image_to_kernel imageToKernel instance (w : f ≫ g = 0) : Mono (imageToKernel f g w) := by dsimp only [imageToKernel] infer_instance @[simp] theorem subobject_ofLE_as_imageToKernel (w : f ≫ g = 0) (h) : Subobject.ofLE (imageSubobject f) (kernelSubobject g) h = imageToKernel f g w := rfl #align subobject_of_le_as_image_to_kernel subobject_ofLE_as_imageToKernel attribute [local instance] ConcreteCategory.instFunLike -- Porting note: removed elementwise attribute which does not seem to be helpful here -- a more suitable lemma is added below @[reassoc (attr := simp)] theorem imageToKernel_arrow (w : f ≫ g = 0) : imageToKernel f g w ≫ (kernelSubobject g).arrow = (imageSubobject f).arrow := by simp [imageToKernel] #align image_to_kernel_arrow imageToKernel_arrow @[simp] lemma imageToKernel_arrow_apply [ConcreteCategory V] (w : f ≫ g = 0) (x : (forget V).obj (Subobject.underlying.obj (imageSubobject f))) : (kernelSubobject g).arrow (imageToKernel f g w x) = (imageSubobject f).arrow x := by rw [← comp_apply, imageToKernel_arrow] -- This is less useful as a `simp` lemma than it initially appears, -- as it "loses" the information the morphism factors through the image. theorem factorThruImageSubobject_comp_imageToKernel (w : f ≫ g = 0) : factorThruImageSubobject f ≫ imageToKernel f g w = factorThruKernelSubobject g f w := by ext simp #align factor_thru_image_subobject_comp_image_to_kernel factorThruImageSubobject_comp_imageToKernel end section variable {A B C : V} (f : A ⟢ B) (g : B ⟢ C) @[simp] theorem imageToKernel_zero_left [HasKernels V] [HasZeroObject V] {w} : imageToKernel (0 : A ⟢ B) g w = 0 := by ext simp #align image_to_kernel_zero_left imageToKernel_zero_left theorem imageToKernel_zero_right [HasImages V] {w} : imageToKernel f (0 : B ⟢ C) w = (imageSubobject f).arrow ≫ inv (kernelSubobject (0 : B ⟢ C)).arrow := by ext simp #align image_to_kernel_zero_right imageToKernel_zero_right section variable [HasKernels V] [HasImages V] theorem imageToKernel_comp_right {D : V} (h : C ⟢ D) (w : f ≫ g = 0) : imageToKernel f (g ≫ h) (by simp [reassoc_of% w]) = imageToKernel f g w ≫ Subobject.ofLE _ _ (kernelSubobject_comp_le g h) := by ext simp #align image_to_kernel_comp_right imageToKernel_comp_right theorem imageToKernel_comp_left {Z : V} (h : Z ⟢ A) (w : f ≫ g = 0) : imageToKernel (h ≫ f) g (by simp [w]) = Subobject.ofLE _ _ (imageSubobject_comp_le h f) ≫ imageToKernel f g w := by ext simp #align image_to_kernel_comp_left imageToKernel_comp_left @[simp]
Mathlib/Algebra/Homology/ImageToKernel.lean
127
132
theorem imageToKernel_comp_mono {D : V} (h : C ⟢ D) [Mono h] (w) : imageToKernel f (g ≫ h) w = imageToKernel f g ((cancel_mono h).mp (by simpa using w : (f ≫ g) ≫ h = 0 ≫ h)) ≫ (Subobject.isoOfEq _ _ (kernelSubobject_comp_mono g h)).inv := by
ext simp
import Mathlib.Init.Core import Mathlib.LinearAlgebra.AffineSpace.Basis import Mathlib.LinearAlgebra.FiniteDimensional #align_import linear_algebra.affine_space.finite_dimensional from "leanprover-community/mathlib"@"67e606eaea14c7854bdc556bd53d98aefdf76ec0" noncomputable section open Affine section AffineSpace' variable (k : Type*) {V : Type*} {P : Type*} variable {ΞΉ : Type*} open AffineSubspace FiniteDimensional Module variable [DivisionRing k] [AddCommGroup V] [Module k V] [AffineSpace V P] theorem finiteDimensional_vectorSpan_of_finite {s : Set P} (h : Set.Finite s) : FiniteDimensional k (vectorSpan k s) := span_of_finite k <| h.vsub h #align finite_dimensional_vector_span_of_finite finiteDimensional_vectorSpan_of_finite instance finiteDimensional_vectorSpan_range [Finite ΞΉ] (p : ΞΉ β†’ P) : FiniteDimensional k (vectorSpan k (Set.range p)) := finiteDimensional_vectorSpan_of_finite k (Set.finite_range _) #align finite_dimensional_vector_span_range finiteDimensional_vectorSpan_range instance finiteDimensional_vectorSpan_image_of_finite [Finite ΞΉ] (p : ΞΉ β†’ P) (s : Set ΞΉ) : FiniteDimensional k (vectorSpan k (p '' s)) := finiteDimensional_vectorSpan_of_finite k (Set.toFinite _) #align finite_dimensional_vector_span_image_of_finite finiteDimensional_vectorSpan_image_of_finite theorem finiteDimensional_direction_affineSpan_of_finite {s : Set P} (h : Set.Finite s) : FiniteDimensional k (affineSpan k s).direction := (direction_affineSpan k s).symm β–Έ finiteDimensional_vectorSpan_of_finite k h #align finite_dimensional_direction_affine_span_of_finite finiteDimensional_direction_affineSpan_of_finite instance finiteDimensional_direction_affineSpan_range [Finite ΞΉ] (p : ΞΉ β†’ P) : FiniteDimensional k (affineSpan k (Set.range p)).direction := finiteDimensional_direction_affineSpan_of_finite k (Set.finite_range _) #align finite_dimensional_direction_affine_span_range finiteDimensional_direction_affineSpan_range instance finiteDimensional_direction_affineSpan_image_of_finite [Finite ΞΉ] (p : ΞΉ β†’ P) (s : Set ΞΉ) : FiniteDimensional k (affineSpan k (p '' s)).direction := finiteDimensional_direction_affineSpan_of_finite k (Set.toFinite _) #align finite_dimensional_direction_affine_span_image_of_finite finiteDimensional_direction_affineSpan_image_of_finite theorem finite_of_fin_dim_affineIndependent [FiniteDimensional k V] {p : ΞΉ β†’ P} (hi : AffineIndependent k p) : Finite ΞΉ := by nontriviality ΞΉ; inhabit ΞΉ rw [affineIndependent_iff_linearIndependent_vsub k p default] at hi letI : IsNoetherian k V := IsNoetherian.iff_fg.2 inferInstance exact (Set.finite_singleton default).finite_of_compl (Set.finite_coe_iff.1 hi.finite_of_isNoetherian) #align finite_of_fin_dim_affine_independent finite_of_fin_dim_affineIndependent theorem finite_set_of_fin_dim_affineIndependent [FiniteDimensional k V] {s : Set ΞΉ} {f : s β†’ P} (hi : AffineIndependent k f) : s.Finite := @Set.toFinite _ s (finite_of_fin_dim_affineIndependent k hi) #align finite_set_of_fin_dim_affine_independent finite_set_of_fin_dim_affineIndependent variable {k} theorem AffineIndependent.finrank_vectorSpan_image_finset [DecidableEq P] {p : ΞΉ β†’ P} (hi : AffineIndependent k p) {s : Finset ΞΉ} {n : β„•} (hc : Finset.card s = n + 1) : finrank k (vectorSpan k (s.image p : Set P)) = n := by classical have hi' := hi.range.mono (Set.image_subset_range p ↑s) have hc' : (s.image p).card = n + 1 := by rwa [s.card_image_of_injective hi.injective] have hn : (s.image p).Nonempty := by simp [hc', ← Finset.card_pos] rcases hn with ⟨p₁, hpβ‚βŸ© have hp₁' : p₁ ∈ p '' s := by simpa using hp₁ rw [affineIndependent_set_iff_linearIndependent_vsub k hp₁', ← Finset.coe_singleton, ← Finset.coe_image, ← Finset.coe_sdiff, Finset.sdiff_singleton_eq_erase, ← Finset.coe_image] at hi' have hc : (Finset.image (fun p : P => p -α΅₯ p₁) ((Finset.image p s).erase p₁)).card = n := by rw [Finset.card_image_of_injective _ (vsub_left_injective _), Finset.card_erase_of_mem hp₁] exact Nat.pred_eq_of_eq_succ hc' rwa [vectorSpan_eq_span_vsub_finset_right_ne k hp₁, finrank_span_finset_eq_card, hc] #align affine_independent.finrank_vector_span_image_finset AffineIndependent.finrank_vectorSpan_image_finset theorem AffineIndependent.finrank_vectorSpan [Fintype ΞΉ] {p : ΞΉ β†’ P} (hi : AffineIndependent k p) {n : β„•} (hc : Fintype.card ΞΉ = n + 1) : finrank k (vectorSpan k (Set.range p)) = n := by classical rw [← Finset.card_univ] at hc rw [← Set.image_univ, ← Finset.coe_univ, ← Finset.coe_image] exact hi.finrank_vectorSpan_image_finset hc #align affine_independent.finrank_vector_span AffineIndependent.finrank_vectorSpan lemma AffineIndependent.finrank_vectorSpan_add_one [Fintype ΞΉ] [Nonempty ΞΉ] {p : ΞΉ β†’ P} (hi : AffineIndependent k p) : finrank k (vectorSpan k (Set.range p)) + 1 = Fintype.card ΞΉ := by rw [hi.finrank_vectorSpan (tsub_add_cancel_of_le _).symm, tsub_add_cancel_of_le] <;> exact Fintype.card_pos theorem AffineIndependent.vectorSpan_eq_top_of_card_eq_finrank_add_one [FiniteDimensional k V] [Fintype ΞΉ] {p : ΞΉ β†’ P} (hi : AffineIndependent k p) (hc : Fintype.card ΞΉ = finrank k V + 1) : vectorSpan k (Set.range p) = ⊀ := Submodule.eq_top_of_finrank_eq <| hi.finrank_vectorSpan hc #align affine_independent.vector_span_eq_top_of_card_eq_finrank_add_one AffineIndependent.vectorSpan_eq_top_of_card_eq_finrank_add_one variable (k) theorem finrank_vectorSpan_image_finset_le [DecidableEq P] (p : ΞΉ β†’ P) (s : Finset ΞΉ) {n : β„•} (hc : Finset.card s = n + 1) : finrank k (vectorSpan k (s.image p : Set P)) ≀ n := by classical have hn : (s.image p).Nonempty := by rw [Finset.image_nonempty, ← Finset.card_pos, hc] apply Nat.succ_pos rcases hn with ⟨p₁, hpβ‚βŸ© rw [vectorSpan_eq_span_vsub_finset_right_ne k hp₁] refine le_trans (finrank_span_finset_le_card (((s.image p).erase p₁).image fun p => p -α΅₯ p₁)) ?_ rw [Finset.card_image_of_injective _ (vsub_left_injective p₁), Finset.card_erase_of_mem hp₁, tsub_le_iff_right, ← hc] apply Finset.card_image_le #align finrank_vector_span_image_finset_le finrank_vectorSpan_image_finset_le theorem finrank_vectorSpan_range_le [Fintype ΞΉ] (p : ΞΉ β†’ P) {n : β„•} (hc : Fintype.card ΞΉ = n + 1) : finrank k (vectorSpan k (Set.range p)) ≀ n := by classical rw [← Set.image_univ, ← Finset.coe_univ, ← Finset.coe_image] rw [← Finset.card_univ] at hc exact finrank_vectorSpan_image_finset_le _ _ _ hc #align finrank_vector_span_range_le finrank_vectorSpan_range_le lemma finrank_vectorSpan_range_add_one_le [Fintype ΞΉ] [Nonempty ΞΉ] (p : ΞΉ β†’ P) : finrank k (vectorSpan k (Set.range p)) + 1 ≀ Fintype.card ΞΉ := (le_tsub_iff_right $ Nat.succ_le_iff.2 Fintype.card_pos).1 $ finrank_vectorSpan_range_le _ _ (tsub_add_cancel_of_le $ Nat.succ_le_iff.2 Fintype.card_pos).symm theorem affineIndependent_iff_finrank_vectorSpan_eq [Fintype ΞΉ] (p : ΞΉ β†’ P) {n : β„•} (hc : Fintype.card ΞΉ = n + 1) : AffineIndependent k p ↔ finrank k (vectorSpan k (Set.range p)) = n := by classical have hn : Nonempty ΞΉ := by simp [← Fintype.card_pos_iff, hc] cases' hn with i₁ rw [affineIndependent_iff_linearIndependent_vsub _ _ i₁, linearIndependent_iff_card_eq_finrank_span, eq_comm, vectorSpan_range_eq_span_range_vsub_right_ne k p i₁, Set.finrank] rw [← Finset.card_univ] at hc rw [Fintype.subtype_card] simp [Finset.filter_ne', Finset.card_erase_of_mem, hc] #align affine_independent_iff_finrank_vector_span_eq affineIndependent_iff_finrank_vectorSpan_eq theorem affineIndependent_iff_le_finrank_vectorSpan [Fintype ΞΉ] (p : ΞΉ β†’ P) {n : β„•} (hc : Fintype.card ΞΉ = n + 1) : AffineIndependent k p ↔ n ≀ finrank k (vectorSpan k (Set.range p)) := by rw [affineIndependent_iff_finrank_vectorSpan_eq k p hc] constructor Β· rintro rfl rfl Β· exact fun hle => le_antisymm (finrank_vectorSpan_range_le k p hc) hle #align affine_independent_iff_le_finrank_vector_span affineIndependent_iff_le_finrank_vectorSpan theorem affineIndependent_iff_not_finrank_vectorSpan_le [Fintype ΞΉ] (p : ΞΉ β†’ P) {n : β„•} (hc : Fintype.card ΞΉ = n + 2) : AffineIndependent k p ↔ Β¬finrank k (vectorSpan k (Set.range p)) ≀ n := by rw [affineIndependent_iff_le_finrank_vectorSpan k p hc, ← Nat.lt_iff_add_one_le, lt_iff_not_ge] #align affine_independent_iff_not_finrank_vector_span_le affineIndependent_iff_not_finrank_vectorSpan_le theorem finrank_vectorSpan_le_iff_not_affineIndependent [Fintype ΞΉ] (p : ΞΉ β†’ P) {n : β„•} (hc : Fintype.card ΞΉ = n + 2) : finrank k (vectorSpan k (Set.range p)) ≀ n ↔ Β¬AffineIndependent k p := (not_iff_comm.1 (affineIndependent_iff_not_finrank_vectorSpan_le k p hc).symm).symm #align finrank_vector_span_le_iff_not_affine_independent finrank_vectorSpan_le_iff_not_affineIndependent variable {k} lemma AffineIndependent.card_le_finrank_succ [Fintype ΞΉ] {p : ΞΉ β†’ P} (hp : AffineIndependent k p) : Fintype.card ΞΉ ≀ FiniteDimensional.finrank k (vectorSpan k (Set.range p)) + 1 := by cases isEmpty_or_nonempty ΞΉ Β· simp [Fintype.card_eq_zero] rw [← tsub_le_iff_right] exact (affineIndependent_iff_le_finrank_vectorSpan _ _ (tsub_add_cancel_of_le <| Nat.one_le_iff_ne_zero.2 Fintype.card_ne_zero).symm).1 hp open Finset in lemma AffineIndependent.card_le_card_of_subset_affineSpan {s t : Finset V} (hs : AffineIndependent k ((↑) : s β†’ V)) (hst : (s : Set V) βŠ† affineSpan k (t : Set V)) : s.card ≀ t.card := by obtain rfl | hs' := s.eq_empty_or_nonempty Β· simp obtain rfl | ht' := t.eq_empty_or_nonempty Β· simpa [Set.subset_empty_iff] using hst have := hs'.to_subtype have := ht'.to_set.to_subtype have direction_le := AffineSubspace.direction_le (affineSpan_mono k hst) rw [AffineSubspace.affineSpan_coe, direction_affineSpan, direction_affineSpan, ← @Subtype.range_coe _ (s : Set V), ← @Subtype.range_coe _ (t : Set V)] at direction_le have finrank_le := add_le_add_right (Submodule.finrank_le_finrank_of_le direction_le) 1 -- We use `erw` to elide the difference between `β†₯s` and `β†₯(s : Set V)}` erw [hs.finrank_vectorSpan_add_one] at finrank_le simpa using finrank_le.trans <| finrank_vectorSpan_range_add_one_le _ _ open Finset in lemma AffineIndependent.card_lt_card_of_affineSpan_lt_affineSpan {s t : Finset V} (hs : AffineIndependent k ((↑) : s β†’ V)) (hst : affineSpan k (s : Set V) < affineSpan k (t : Set V)) : s.card < t.card := by obtain rfl | hs' := s.eq_empty_or_nonempty Β· simpa [card_pos] using hst obtain rfl | ht' := t.eq_empty_or_nonempty Β· simp [Set.subset_empty_iff] at hst have := hs'.to_subtype have := ht'.to_set.to_subtype have dir_lt := AffineSubspace.direction_lt_of_nonempty (k := k) hst $ hs'.to_set.affineSpan k rw [direction_affineSpan, direction_affineSpan, ← @Subtype.range_coe _ (s : Set V), ← @Subtype.range_coe _ (t : Set V)] at dir_lt have finrank_lt := add_lt_add_right (Submodule.finrank_lt_finrank_of_lt dir_lt) 1 -- We use `erw` to elide the difference between `β†₯s` and `β†₯(s : Set V)}` erw [hs.finrank_vectorSpan_add_one] at finrank_lt simpa using finrank_lt.trans_le <| finrank_vectorSpan_range_add_one_le _ _ theorem AffineIndependent.vectorSpan_image_finset_eq_of_le_of_card_eq_finrank_add_one [DecidableEq P] {p : ΞΉ β†’ P} (hi : AffineIndependent k p) {s : Finset ΞΉ} {sm : Submodule k V} [FiniteDimensional k sm] (hle : vectorSpan k (s.image p : Set P) ≀ sm) (hc : Finset.card s = finrank k sm + 1) : vectorSpan k (s.image p : Set P) = sm := eq_of_le_of_finrank_eq hle <| hi.finrank_vectorSpan_image_finset hc #align affine_independent.vector_span_image_finset_eq_of_le_of_card_eq_finrank_add_one AffineIndependent.vectorSpan_image_finset_eq_of_le_of_card_eq_finrank_add_one theorem AffineIndependent.vectorSpan_eq_of_le_of_card_eq_finrank_add_one [Fintype ΞΉ] {p : ΞΉ β†’ P} (hi : AffineIndependent k p) {sm : Submodule k V} [FiniteDimensional k sm] (hle : vectorSpan k (Set.range p) ≀ sm) (hc : Fintype.card ΞΉ = finrank k sm + 1) : vectorSpan k (Set.range p) = sm := eq_of_le_of_finrank_eq hle <| hi.finrank_vectorSpan hc #align affine_independent.vector_span_eq_of_le_of_card_eq_finrank_add_one AffineIndependent.vectorSpan_eq_of_le_of_card_eq_finrank_add_one theorem AffineIndependent.affineSpan_image_finset_eq_of_le_of_card_eq_finrank_add_one [DecidableEq P] {p : ΞΉ β†’ P} (hi : AffineIndependent k p) {s : Finset ΞΉ} {sp : AffineSubspace k P} [FiniteDimensional k sp.direction] (hle : affineSpan k (s.image p : Set P) ≀ sp) (hc : Finset.card s = finrank k sp.direction + 1) : affineSpan k (s.image p : Set P) = sp := by have hn : s.Nonempty := by rw [← Finset.card_pos, hc] apply Nat.succ_pos refine eq_of_direction_eq_of_nonempty_of_le ?_ ((hn.image p).to_set.affineSpan k) hle have hd := direction_le hle rw [direction_affineSpan] at hd ⊒ exact hi.vectorSpan_image_finset_eq_of_le_of_card_eq_finrank_add_one hd hc #align affine_independent.affine_span_image_finset_eq_of_le_of_card_eq_finrank_add_one AffineIndependent.affineSpan_image_finset_eq_of_le_of_card_eq_finrank_add_one theorem AffineIndependent.affineSpan_eq_of_le_of_card_eq_finrank_add_one [Fintype ΞΉ] {p : ΞΉ β†’ P} (hi : AffineIndependent k p) {sp : AffineSubspace k P} [FiniteDimensional k sp.direction] (hle : affineSpan k (Set.range p) ≀ sp) (hc : Fintype.card ΞΉ = finrank k sp.direction + 1) : affineSpan k (Set.range p) = sp := by classical rw [← Finset.card_univ] at hc rw [← Set.image_univ, ← Finset.coe_univ, ← Finset.coe_image] at hle ⊒ exact hi.affineSpan_image_finset_eq_of_le_of_card_eq_finrank_add_one hle hc #align affine_independent.affine_span_eq_of_le_of_card_eq_finrank_add_one AffineIndependent.affineSpan_eq_of_le_of_card_eq_finrank_add_one theorem AffineIndependent.affineSpan_eq_top_iff_card_eq_finrank_add_one [FiniteDimensional k V] [Fintype ΞΉ] {p : ΞΉ β†’ P} (hi : AffineIndependent k p) : affineSpan k (Set.range p) = ⊀ ↔ Fintype.card ΞΉ = finrank k V + 1 := by constructor Β· intro h_tot let n := Fintype.card ΞΉ - 1 have hn : Fintype.card ΞΉ = n + 1 := (Nat.succ_pred_eq_of_pos (card_pos_of_affineSpan_eq_top k V P h_tot)).symm rw [hn, ← finrank_top, ← (vectorSpan_eq_top_of_affineSpan_eq_top k V P) h_tot, ← hi.finrank_vectorSpan hn] Β· intro hc rw [← finrank_top, ← direction_top k V P] at hc exact hi.affineSpan_eq_of_le_of_card_eq_finrank_add_one le_top hc #align affine_independent.affine_span_eq_top_iff_card_eq_finrank_add_one AffineIndependent.affineSpan_eq_top_iff_card_eq_finrank_add_one theorem Affine.Simplex.span_eq_top [FiniteDimensional k V] {n : β„•} (T : Affine.Simplex k V n) (hrank : finrank k V = n) : affineSpan k (Set.range T.points) = ⊀ := by rw [AffineIndependent.affineSpan_eq_top_iff_card_eq_finrank_add_one T.independent, Fintype.card_fin, hrank] #align affine.simplex.span_eq_top Affine.Simplex.span_eq_top instance finiteDimensional_vectorSpan_insert (s : AffineSubspace k P) [FiniteDimensional k s.direction] (p : P) : FiniteDimensional k (vectorSpan k (insert p (s : Set P))) := by rw [← direction_affineSpan, ← affineSpan_insert_affineSpan] rcases (s : Set P).eq_empty_or_nonempty with (hs | ⟨pβ‚€, hpβ‚€βŸ©) Β· rw [coe_eq_bot_iff] at hs rw [hs, bot_coe, span_empty, bot_coe, direction_affineSpan] convert finiteDimensional_bot k V <;> simp Β· rw [affineSpan_coe, direction_affineSpan_insert hpβ‚€] infer_instance #align finite_dimensional_vector_span_insert finiteDimensional_vectorSpan_insert instance finiteDimensional_direction_affineSpan_insert (s : AffineSubspace k P) [FiniteDimensional k s.direction] (p : P) : FiniteDimensional k (affineSpan k (insert p (s : Set P))).direction := (direction_affineSpan k (insert p (s : Set P))).symm β–Έ finiteDimensional_vectorSpan_insert s p #align finite_dimensional_direction_affine_span_insert finiteDimensional_direction_affineSpan_insert variable (k) instance finiteDimensional_vectorSpan_insert_set (s : Set P) [FiniteDimensional k (vectorSpan k s)] (p : P) : FiniteDimensional k (vectorSpan k (insert p s)) := by haveI : FiniteDimensional k (affineSpan k s).direction := (direction_affineSpan k s).symm β–Έ inferInstance rw [← direction_affineSpan, ← affineSpan_insert_affineSpan, direction_affineSpan] exact finiteDimensional_vectorSpan_insert (affineSpan k s) p #align finite_dimensional_vector_span_insert_set finiteDimensional_vectorSpan_insert_set def Collinear (s : Set P) : Prop := Module.rank k (vectorSpan k s) ≀ 1 #align collinear Collinear theorem collinear_iff_rank_le_one (s : Set P) : Collinear k s ↔ Module.rank k (vectorSpan k s) ≀ 1 := Iff.rfl #align collinear_iff_rank_le_one collinear_iff_rank_le_one variable {k} theorem collinear_iff_finrank_le_one {s : Set P} [FiniteDimensional k (vectorSpan k s)] : Collinear k s ↔ finrank k (vectorSpan k s) ≀ 1 := by have h := collinear_iff_rank_le_one k s rw [← finrank_eq_rank] at h exact mod_cast h #align collinear_iff_finrank_le_one collinear_iff_finrank_le_one alias ⟨Collinear.finrank_le_one, _⟩ := collinear_iff_finrank_le_one #align collinear.finrank_le_one Collinear.finrank_le_one theorem Collinear.subset {s₁ sβ‚‚ : Set P} (hs : s₁ βŠ† sβ‚‚) (h : Collinear k sβ‚‚) : Collinear k s₁ := (rank_le_of_submodule (vectorSpan k s₁) (vectorSpan k sβ‚‚) (vectorSpan_mono k hs)).trans h #align collinear.subset Collinear.subset theorem Collinear.finiteDimensional_vectorSpan {s : Set P} (h : Collinear k s) : FiniteDimensional k (vectorSpan k s) := IsNoetherian.iff_fg.1 (IsNoetherian.iff_rank_lt_aleph0.2 (lt_of_le_of_lt h Cardinal.one_lt_aleph0)) #align collinear.finite_dimensional_vector_span Collinear.finiteDimensional_vectorSpan theorem Collinear.finiteDimensional_direction_affineSpan {s : Set P} (h : Collinear k s) : FiniteDimensional k (affineSpan k s).direction := (direction_affineSpan k s).symm β–Έ h.finiteDimensional_vectorSpan #align collinear.finite_dimensional_direction_affine_span Collinear.finiteDimensional_direction_affineSpan variable (k P) theorem collinear_empty : Collinear k (βˆ… : Set P) := by rw [collinear_iff_rank_le_one, vectorSpan_empty] simp #align collinear_empty collinear_empty variable {P} theorem collinear_singleton (p : P) : Collinear k ({p} : Set P) := by rw [collinear_iff_rank_le_one, vectorSpan_singleton] simp #align collinear_singleton collinear_singleton variable {k} theorem collinear_iff_of_mem {s : Set P} {pβ‚€ : P} (h : pβ‚€ ∈ s) : Collinear k s ↔ βˆƒ v : V, βˆ€ p ∈ s, βˆƒ r : k, p = r β€’ v +α΅₯ pβ‚€ := by simp_rw [collinear_iff_rank_le_one, rank_submodule_le_one_iff', Submodule.le_span_singleton_iff] constructor Β· rintro ⟨vβ‚€, hv⟩ use vβ‚€ intro p hp obtain ⟨r, hr⟩ := hv (p -α΅₯ pβ‚€) (vsub_mem_vectorSpan k hp h) use r rw [eq_vadd_iff_vsub_eq] exact hr.symm Β· rintro ⟨v, hpβ‚€v⟩ use v intro w hw have hs : vectorSpan k s ≀ k βˆ™ v := by rw [vectorSpan_eq_span_vsub_set_right k h, Submodule.span_le, Set.subset_def] intro x hx rw [SetLike.mem_coe, Submodule.mem_span_singleton] rw [Set.mem_image] at hx rcases hx with ⟨p, hp, rfl⟩ rcases hpβ‚€v p hp with ⟨r, rfl⟩ use r simp have hw' := SetLike.le_def.1 hs hw rwa [Submodule.mem_span_singleton] at hw' #align collinear_iff_of_mem collinear_iff_of_mem theorem collinear_iff_exists_forall_eq_smul_vadd (s : Set P) : Collinear k s ↔ βˆƒ (pβ‚€ : P) (v : V), βˆ€ p ∈ s, βˆƒ r : k, p = r β€’ v +α΅₯ pβ‚€ := by rcases Set.eq_empty_or_nonempty s with (rfl | ⟨⟨p₁, hpβ‚βŸ©βŸ©) Β· simp [collinear_empty] Β· rw [collinear_iff_of_mem hp₁] constructor Β· exact fun h => ⟨p₁, h⟩ Β· rintro ⟨p, v, hv⟩ use v intro pβ‚‚ hpβ‚‚ rcases hv pβ‚‚ hpβ‚‚ with ⟨r, rfl⟩ rcases hv p₁ hp₁ with ⟨r₁, rfl⟩ use r - r₁ simp [vadd_vadd, ← add_smul] #align collinear_iff_exists_forall_eq_smul_vadd collinear_iff_exists_forall_eq_smul_vadd variable (k) theorem collinear_pair (p₁ pβ‚‚ : P) : Collinear k ({p₁, pβ‚‚} : Set P) := by rw [collinear_iff_exists_forall_eq_smul_vadd] use p₁, pβ‚‚ -α΅₯ p₁ intro p hp rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hp cases' hp with hp hp Β· use 0 simp [hp] Β· use 1 simp [hp] #align collinear_pair collinear_pair variable {k} theorem affineIndependent_iff_not_collinear {p : Fin 3 β†’ P} : AffineIndependent k p ↔ Β¬Collinear k (Set.range p) := by rw [collinear_iff_finrank_le_one, affineIndependent_iff_not_finrank_vectorSpan_le k p (Fintype.card_fin 3)] #align affine_independent_iff_not_collinear affineIndependent_iff_not_collinear theorem collinear_iff_not_affineIndependent {p : Fin 3 β†’ P} : Collinear k (Set.range p) ↔ Β¬AffineIndependent k p := by rw [collinear_iff_finrank_le_one, finrank_vectorSpan_le_iff_not_affineIndependent k p (Fintype.card_fin 3)] #align collinear_iff_not_affine_independent collinear_iff_not_affineIndependent theorem affineIndependent_iff_not_collinear_set {p₁ pβ‚‚ p₃ : P} : AffineIndependent k ![p₁, pβ‚‚, p₃] ↔ Β¬Collinear k ({p₁, pβ‚‚, p₃} : Set P) := by rw [affineIndependent_iff_not_collinear] simp_rw [Matrix.range_cons, Matrix.range_empty, Set.singleton_union, insert_emptyc_eq] #align affine_independent_iff_not_collinear_set affineIndependent_iff_not_collinear_set theorem collinear_iff_not_affineIndependent_set {p₁ pβ‚‚ p₃ : P} : Collinear k ({p₁, pβ‚‚, p₃} : Set P) ↔ Β¬AffineIndependent k ![p₁, pβ‚‚, p₃] := affineIndependent_iff_not_collinear_set.not_left.symm #align collinear_iff_not_affine_independent_set collinear_iff_not_affineIndependent_set theorem affineIndependent_iff_not_collinear_of_ne {p : Fin 3 β†’ P} {i₁ iβ‚‚ i₃ : Fin 3} (h₁₂ : i₁ β‰  iβ‚‚) (h₁₃ : i₁ β‰  i₃) (h₂₃ : iβ‚‚ β‰  i₃) : AffineIndependent k p ↔ Β¬Collinear k ({p i₁, p iβ‚‚, p i₃} : Set P) := by have hu : (Finset.univ : Finset (Fin 3)) = {i₁, iβ‚‚, i₃} := by -- Porting note: Originally `by decide!` fin_cases i₁ <;> fin_cases iβ‚‚ <;> fin_cases i₃ <;> simp (config := {decide := true}) only at h₁₂ h₁₃ h₂₃ ⊒ rw [affineIndependent_iff_not_collinear, ← Set.image_univ, ← Finset.coe_univ, hu, Finset.coe_insert, Finset.coe_insert, Finset.coe_singleton, Set.image_insert_eq, Set.image_pair] #align affine_independent_iff_not_collinear_of_ne affineIndependent_iff_not_collinear_of_ne theorem collinear_iff_not_affineIndependent_of_ne {p : Fin 3 β†’ P} {i₁ iβ‚‚ i₃ : Fin 3} (h₁₂ : i₁ β‰  iβ‚‚) (h₁₃ : i₁ β‰  i₃) (h₂₃ : iβ‚‚ β‰  i₃) : Collinear k ({p i₁, p iβ‚‚, p i₃} : Set P) ↔ Β¬AffineIndependent k p := (affineIndependent_iff_not_collinear_of_ne h₁₂ h₁₃ h₂₃).not_left.symm #align collinear_iff_not_affine_independent_of_ne collinear_iff_not_affineIndependent_of_ne theorem ne₁₂_of_not_collinear {p₁ pβ‚‚ p₃ : P} (h : Β¬Collinear k ({p₁, pβ‚‚, p₃} : Set P)) : p₁ β‰  pβ‚‚ := by rintro rfl simp [collinear_pair] at h #align ne₁₂_of_not_collinear ne₁₂_of_not_collinear theorem ne₁₃_of_not_collinear {p₁ pβ‚‚ p₃ : P} (h : Β¬Collinear k ({p₁, pβ‚‚, p₃} : Set P)) : p₁ β‰  p₃ := by rintro rfl simp [collinear_pair] at h #align ne₁₃_of_not_collinear ne₁₃_of_not_collinear theorem ne₂₃_of_not_collinear {p₁ pβ‚‚ p₃ : P} (h : Β¬Collinear k ({p₁, pβ‚‚, p₃} : Set P)) : pβ‚‚ β‰  p₃ := by rintro rfl simp [collinear_pair] at h #align ne₂₃_of_not_collinear ne₂₃_of_not_collinear theorem Collinear.mem_affineSpan_of_mem_of_ne {s : Set P} (h : Collinear k s) {p₁ pβ‚‚ p₃ : P} (hp₁ : p₁ ∈ s) (hpβ‚‚ : pβ‚‚ ∈ s) (hp₃ : p₃ ∈ s) (hp₁pβ‚‚ : p₁ β‰  pβ‚‚) : p₃ ∈ line[k, p₁, pβ‚‚] := by rw [collinear_iff_of_mem hp₁] at h rcases h with ⟨v, h⟩ rcases h pβ‚‚ hpβ‚‚ with ⟨rβ‚‚, rfl⟩ rcases h p₃ hp₃ with ⟨r₃, rfl⟩ rw [vadd_left_mem_affineSpan_pair] refine ⟨r₃ / rβ‚‚, ?_⟩ have hβ‚‚ : rβ‚‚ β‰  0 := by rintro rfl simp at hp₁pβ‚‚ simp [smul_smul, hβ‚‚] #align collinear.mem_affine_span_of_mem_of_ne Collinear.mem_affineSpan_of_mem_of_ne theorem Collinear.affineSpan_eq_of_ne {s : Set P} (h : Collinear k s) {p₁ pβ‚‚ : P} (hp₁ : p₁ ∈ s) (hpβ‚‚ : pβ‚‚ ∈ s) (hp₁pβ‚‚ : p₁ β‰  pβ‚‚) : line[k, p₁, pβ‚‚] = affineSpan k s := le_antisymm (affineSpan_mono _ (Set.insert_subset_iff.2 ⟨hp₁, Set.singleton_subset_iff.2 hpβ‚‚βŸ©)) (affineSpan_le.2 fun _ hp => h.mem_affineSpan_of_mem_of_ne hp₁ hpβ‚‚ hp hp₁pβ‚‚) #align collinear.affine_span_eq_of_ne Collinear.affineSpan_eq_of_ne theorem Collinear.collinear_insert_iff_of_ne {s : Set P} (h : Collinear k s) {p₁ pβ‚‚ p₃ : P} (hpβ‚‚ : pβ‚‚ ∈ s) (hp₃ : p₃ ∈ s) (hpβ‚‚p₃ : pβ‚‚ β‰  p₃) : Collinear k (insert p₁ s) ↔ Collinear k ({p₁, pβ‚‚, p₃} : Set P) := by have hv : vectorSpan k (insert p₁ s) = vectorSpan k ({p₁, pβ‚‚, p₃} : Set P) := by -- Porting note: Original proof used `conv_lhs` and `conv_rhs`, but these tactics timed out. rw [← direction_affineSpan, ← affineSpan_insert_affineSpan] symm rw [← direction_affineSpan, ← affineSpan_insert_affineSpan, h.affineSpan_eq_of_ne hpβ‚‚ hp₃ hpβ‚‚p₃] rw [Collinear, Collinear, hv] #align collinear.collinear_insert_iff_of_ne Collinear.collinear_insert_iff_of_ne theorem collinear_insert_iff_of_mem_affineSpan {s : Set P} {p : P} (h : p ∈ affineSpan k s) : Collinear k (insert p s) ↔ Collinear k s := by rw [Collinear, Collinear, vectorSpan_insert_eq_vectorSpan h] #align collinear_insert_iff_of_mem_affine_span collinear_insert_iff_of_mem_affineSpan
Mathlib/LinearAlgebra/AffineSpace/FiniteDimensional.lean
620
623
theorem collinear_insert_of_mem_affineSpan_pair {p₁ pβ‚‚ p₃ : P} (h : p₁ ∈ line[k, pβ‚‚, p₃]) : Collinear k ({p₁, pβ‚‚, p₃} : Set P) := by
rw [collinear_insert_iff_of_mem_affineSpan h] exact collinear_pair _ _ _
import Mathlib.Algebra.Order.Invertible import Mathlib.Algebra.Order.Module.OrderedSMul import Mathlib.LinearAlgebra.AffineSpace.Midpoint import Mathlib.LinearAlgebra.Ray import Mathlib.Tactic.GCongr #align_import analysis.convex.segment from "leanprover-community/mathlib"@"c5773405394e073885e2a144c9ca14637e8eb963" variable {π•œ E F G ΞΉ : Type*} {Ο€ : ΞΉ β†’ Type*} open Function Set open Pointwise Convex section OrderedSemiring variable [OrderedSemiring π•œ] [AddCommMonoid E] open Convex open Convex section OrderedRing variable (π•œ) [OrderedRing π•œ] [AddCommGroup E] [AddCommGroup F] [AddCommGroup G] [Module π•œ E] [Module π•œ F]
Mathlib/Analysis/Convex/Segment.lean
308
313
theorem sameRay_of_mem_segment [StrictOrderedCommRing π•œ] [AddCommGroup E] [Module π•œ E] {x y z : E} (h : x ∈ [y -[π•œ] z]) : SameRay π•œ (x - y) (z - x) := by
rw [segment_eq_image'] at h rcases h with ⟨θ, ⟨hΞΈβ‚€, hΞΈβ‚βŸ©, rfl⟩ simpa only [add_sub_cancel_left, ← sub_sub, sub_smul, one_smul] using (SameRay.sameRay_nonneg_smul_left (z - y) hΞΈβ‚€).nonneg_smul_right (sub_nonneg.2 hθ₁)
import Mathlib.MeasureTheory.Decomposition.RadonNikodym import Mathlib.MeasureTheory.Measure.Haar.OfBasis import Mathlib.Probability.Independence.Basic #align_import probability.density from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" open scoped Classical MeasureTheory NNReal ENNReal open TopologicalSpace MeasureTheory.Measure noncomputable section namespace MeasureTheory variable {Ξ© E : Type*} [MeasurableSpace E] class HasPDF {m : MeasurableSpace Ξ©} (X : Ξ© β†’ E) (β„™ : Measure Ξ©) (ΞΌ : Measure E := by volume_tac) : Prop where pdf' : AEMeasurable X β„™ ∧ (map X β„™).HaveLebesgueDecomposition ΞΌ ∧ map X β„™ β‰ͺ ΞΌ #align measure_theory.has_pdf MeasureTheory.HasPDF section HasPDF variable {_ : MeasurableSpace Ξ©} theorem hasPDF_iff {X : Ξ© β†’ E} {β„™ : Measure Ξ©} {ΞΌ : Measure E} : HasPDF X β„™ ΞΌ ↔ AEMeasurable X β„™ ∧ (map X β„™).HaveLebesgueDecomposition ΞΌ ∧ map X β„™ β‰ͺ ΞΌ := ⟨@HasPDF.pdf' _ _ _ _ _ _ _, HasPDF.mk⟩ #align measure_theory.pdf.has_pdf_iff MeasureTheory.hasPDF_iff theorem hasPDF_iff_of_aemeasurable {X : Ξ© β†’ E} {β„™ : Measure Ξ©} {ΞΌ : Measure E} (hX : AEMeasurable X β„™) : HasPDF X β„™ ΞΌ ↔ (map X β„™).HaveLebesgueDecomposition ΞΌ ∧ map X β„™ β‰ͺ ΞΌ := by rw [hasPDF_iff] simp only [hX, true_and] #align measure_theory.pdf.has_pdf_iff_of_measurable MeasureTheory.hasPDF_iff_of_aemeasurable @[measurability] theorem HasPDF.aemeasurable (X : Ξ© β†’ E) (β„™ : Measure Ξ©) (ΞΌ : Measure E) [hX : HasPDF X β„™ ΞΌ] : AEMeasurable X β„™ := hX.pdf'.1 #align measure_theory.has_pdf.measurable MeasureTheory.HasPDF.aemeasurable instance HasPDF.haveLebesgueDecomposition {X : Ξ© β†’ E} {β„™ : Measure Ξ©} {ΞΌ : Measure E} [hX : HasPDF X β„™ ΞΌ] : (map X β„™).HaveLebesgueDecomposition ΞΌ := hX.pdf'.2.1 #align measure_theory.pdf.have_lebesgue_decomposition_of_has_pdf MeasureTheory.HasPDF.haveLebesgueDecomposition theorem HasPDF.absolutelyContinuous {X : Ξ© β†’ E} {β„™ : Measure Ξ©} {ΞΌ : Measure E} [hX : HasPDF X β„™ ΞΌ] : map X β„™ β‰ͺ ΞΌ := hX.pdf'.2.2 #align measure_theory.pdf.map_absolutely_continuous MeasureTheory.HasPDF.absolutelyContinuous theorem HasPDF.quasiMeasurePreserving_of_measurable (X : Ξ© β†’ E) (β„™ : Measure Ξ©) (ΞΌ : Measure E) [HasPDF X β„™ ΞΌ] (h : Measurable X) : QuasiMeasurePreserving X β„™ ΞΌ := { measurable := h absolutelyContinuous := HasPDF.absolutelyContinuous } #align measure_theory.pdf.to_quasi_measure_preserving MeasureTheory.HasPDF.quasiMeasurePreserving_of_measurable theorem HasPDF.congr {X Y : Ξ© β†’ E} {β„™ : Measure Ξ©} {ΞΌ : Measure E} (hXY : X =ᡐ[β„™] Y) [hX : HasPDF X β„™ ΞΌ] : HasPDF Y β„™ ΞΌ := ⟨(HasPDF.aemeasurable X β„™ ΞΌ).congr hXY, β„™.map_congr hXY β–Έ hX.haveLebesgueDecomposition, β„™.map_congr hXY β–Έ hX.absolutelyContinuous⟩ theorem HasPDF.congr' {X Y : Ξ© β†’ E} {β„™ : Measure Ξ©} {ΞΌ : Measure E} (hXY : X =ᡐ[β„™] Y) : HasPDF X β„™ ΞΌ ↔ HasPDF Y β„™ ΞΌ := ⟨fun _ ↦ HasPDF.congr hXY, fun _ ↦ HasPDF.congr hXY.symm⟩
Mathlib/Probability/Density.lean
122
128
theorem hasPDF_of_map_eq_withDensity {X : Ξ© β†’ E} {β„™ : Measure Ξ©} {ΞΌ : Measure E} (hX : AEMeasurable X β„™) (f : E β†’ ℝβ‰₯0∞) (hf : AEMeasurable f ΞΌ) (h : map X β„™ = ΞΌ.withDensity f) : HasPDF X β„™ ΞΌ := by
refine ⟨hX, ?_, ?_⟩ <;> rw [h] · rw [withDensity_congr_ae hf.ae_eq_mk] exact haveLebesgueDecomposition_withDensity μ hf.measurable_mk · exact withDensity_absolutelyContinuous μ f
import Batteries.Classes.Order import Batteries.Control.ForInStep.Basic namespace Batteries namespace BinomialHeap namespace Imp inductive HeapNode (Ξ± : Type u) where | nil : HeapNode Ξ± | node (a : Ξ±) (child sibling : HeapNode Ξ±) : HeapNode Ξ± deriving Repr @[simp] def HeapNode.realSize : HeapNode Ξ± β†’ Nat | .nil => 0 | .node _ c s => c.realSize + 1 + s.realSize def HeapNode.singleton (a : Ξ±) : HeapNode Ξ± := .node a .nil .nil def HeapNode.rank : HeapNode Ξ± β†’ Nat | .nil => 0 | .node _ _ s => s.rank + 1 @[inline] private def HeapNode.rankTR (s : HeapNode Ξ±) : Nat := go s 0 where go : HeapNode Ξ± β†’ Nat β†’ Nat | .nil, r => r | .node _ _ s, r => go s (r + 1) @[csimp] private theorem HeapNode.rankTR_eq : @rankTR = @rank := by funext Ξ± s; exact go s 0 where go {Ξ±} : βˆ€ s n, @rankTR.go Ξ± s n = rank s + n | .nil, _ => (Nat.zero_add ..).symm | .node .., _ => by simp_arith only [rankTR.go, go, rank] inductive Heap (Ξ± : Type u) where | nil : Heap Ξ± | cons (rank : Nat) (val : Ξ±) (node : HeapNode Ξ±) (next : Heap Ξ±) : Heap Ξ± deriving Repr @[simp] def Heap.realSize : Heap Ξ± β†’ Nat | .nil => 0 | .cons _ _ c s => c.realSize + 1 + s.realSize def Heap.size : Heap Ξ± β†’ Nat | .nil => 0 | .cons r _ _ s => 1 <<< r + s.size @[inline] def Heap.isEmpty : Heap Ξ± β†’ Bool | .nil => true | _ => false @[inline] def Heap.singleton (a : Ξ±) : Heap Ξ± := .cons 0 a .nil .nil def Heap.rankGT : Heap Ξ± β†’ Nat β†’ Prop | .nil, _ => True | .cons r .., n => n < r instance : Decidable (Heap.rankGT s n) := match s with | .nil => inferInstanceAs (Decidable True) | .cons .. => inferInstanceAs (Decidable (_ < _)) @[simp] def Heap.length : Heap Ξ± β†’ Nat | .nil => 0 | .cons _ _ _ r => r.length + 1 @[inline] def combine (le : Ξ± β†’ Ξ± β†’ Bool) (a₁ aβ‚‚ : Ξ±) (n₁ nβ‚‚ : HeapNode Ξ±) : Ξ± Γ— HeapNode Ξ± := if le a₁ aβ‚‚ then (a₁, .node aβ‚‚ nβ‚‚ n₁) else (aβ‚‚, .node a₁ n₁ nβ‚‚) @[specialize] def Heap.merge (le : Ξ± β†’ Ξ± β†’ Bool) : Heap Ξ± β†’ Heap Ξ± β†’ Heap Ξ± | .nil, h => h | h, .nil => h | s₁@(.cons r₁ a₁ n₁ t₁), sβ‚‚@(.cons rβ‚‚ aβ‚‚ nβ‚‚ tβ‚‚) => if r₁ < rβ‚‚ then .cons r₁ a₁ n₁ (merge le t₁ sβ‚‚) else if rβ‚‚ < r₁ then .cons rβ‚‚ aβ‚‚ nβ‚‚ (merge le s₁ tβ‚‚) else let (a, n) := combine le a₁ aβ‚‚ n₁ nβ‚‚ let r := r₁ + 1 if t₁.rankGT r then if tβ‚‚.rankGT r then .cons r a n (merge le t₁ tβ‚‚) else merge le (.cons r a n t₁) tβ‚‚ else if tβ‚‚.rankGT r then merge le t₁ (.cons r a n tβ‚‚) else .cons r a n (merge le t₁ tβ‚‚) termination_by s₁ sβ‚‚ => s₁.length + sβ‚‚.length def HeapNode.toHeap (s : HeapNode Ξ±) : Heap Ξ± := go s s.rank .nil where go : HeapNode Ξ± β†’ Nat β†’ Heap Ξ± β†’ Heap Ξ± | .nil, _, res => res | .node a c s, n, res => go s (n - 1) (.cons (n - 1) a c res) @[specialize] def Heap.headD (le : Ξ± β†’ Ξ± β†’ Bool) (a : Ξ±) : Heap Ξ± β†’ Ξ± | .nil => a | .cons _ b _ hs => headD le (if le a b then a else b) hs @[inline] def Heap.head? (le : Ξ± β†’ Ξ± β†’ Bool) : Heap Ξ± β†’ Option Ξ± | .nil => none | .cons _ h _ hs => some <| headD le h hs structure FindMin (Ξ±) where before : Heap Ξ± β†’ Heap Ξ± := id val : Ξ± node : HeapNode Ξ± next : Heap Ξ± @[specialize] def Heap.findMin (le : Ξ± β†’ Ξ± β†’ Bool) (k : Heap Ξ± β†’ Heap Ξ±) : Heap Ξ± β†’ FindMin Ξ± β†’ FindMin Ξ± | .nil, res => res | .cons r a c s, res => -- It is important that we check `le res.val a` here, not the other way -- around. This ensures that head? and findMin find the same element even -- when we have `le res.val a` and `le a res.val` (i.e. le is not antisymmetric). findMin le (k ∘ .cons r a c) s <| if le res.val a then res else ⟨k, a, c, s⟩ def Heap.deleteMin (le : Ξ± β†’ Ξ± β†’ Bool) : Heap Ξ± β†’ Option (Ξ± Γ— Heap Ξ±) | .nil => none | .cons r a c s => let { before, val, node, next } := findMin le (.cons r a c) s ⟨id, a, c, s⟩ some (val, node.toHeap.merge le (before next)) @[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 theorem Heap.realSize_merge (le) (s₁ sβ‚‚ : Heap Ξ±) : (s₁.merge le sβ‚‚).realSize = s₁.realSize + sβ‚‚.realSize := by unfold merge; split Β· simp Β· simp Β· next r₁ a₁ n₁ t₁ rβ‚‚ aβ‚‚ nβ‚‚ tβ‚‚ => have IH₁ r a n := realSize_merge le t₁ (cons r a n tβ‚‚) have IHβ‚‚ r a n := realSize_merge le (cons r a n t₁) tβ‚‚ have IH₃ := realSize_merge le t₁ tβ‚‚ split; Β· simp [IH₁, Nat.add_assoc] split; Β· simp [IHβ‚‚, Nat.add_assoc, Nat.add_left_comm] split; simp only; rename_i a n eq have : n.realSize = n₁.realSize + 1 + nβ‚‚.realSize := by rw [combine] at eq; split at eq <;> cases eq <;> simp [Nat.add_assoc, Nat.add_left_comm, Nat.add_comm] split <;> split <;> simp [IH₁, IHβ‚‚, IH₃, this, Nat.add_assoc, Nat.add_left_comm] termination_by s₁.length + sβ‚‚.length private def FindMin.HasSize (res : FindMin Ξ±) (n : Nat) : Prop := βˆƒ m, (βˆ€ s, (res.before s).realSize = m + s.realSize) ∧ n = m + res.node.realSize + res.next.realSize + 1 private theorem Heap.realSize_findMin {s : Heap Ξ±} (m) (hk : βˆ€ s, (k s).realSize = m + s.realSize) (eq : n = m + s.realSize) (hres : res.HasSize n) : (s.findMin le k res).HasSize n := match s with | .nil => hres | .cons r a c s => by simp [findMin] refine realSize_findMin (m + c.realSize + 1) (by simp [hk, Nat.add_assoc]) (by simp [eq, Nat.add_assoc]) ?_ split Β· exact hres Β· exact ⟨m, hk, by simp [eq, Nat.add_assoc, Nat.add_comm, Nat.add_left_comm]⟩ theorem HeapNode.realSize_toHeap (s : HeapNode Ξ±) : s.toHeap.realSize = s.realSize := go s where go {n res} : βˆ€ s : HeapNode Ξ±, (toHeap.go s n res).realSize = s.realSize + res.realSize | .nil => (Nat.zero_add _).symm | .node a c s => by simp [toHeap.go, go, Nat.add_assoc, Nat.add_left_comm] theorem Heap.realSize_deleteMin {s : Heap Ξ±} (eq : s.deleteMin le = some (a, s')) : s.realSize = s'.realSize + 1 := by cases s with cases eq | cons r a c s => ?_ have : (s.findMin le (cons r a c) ⟨id, a, c, s⟩).HasSize (c.realSize + s.realSize + 1) := Heap.realSize_findMin (c.realSize + 1) (by simp) (Nat.add_right_comm ..) ⟨0, by simp⟩ revert this match s.findMin le (cons r a c) ⟨id, a, c, s⟩ with | { before, val, node, next } => intro ⟨m, ih₁, ihβ‚‚βŸ©; dsimp only at ih₁ ihβ‚‚ rw [realSize, Nat.add_right_comm, ihβ‚‚] simp only [realSize_merge, HeapNode.realSize_toHeap, ih₁, Nat.add_assoc, Nat.add_left_comm]
.lake/packages/batteries/Batteries/Data/BinomialHeap/Basic.lean
259
263
theorem Heap.realSize_tail? {s : Heap Ξ±} : s.tail? le = some s' β†’ s.realSize = s'.realSize + 1 := by
simp only [Heap.tail?]; intro eq match eqβ‚‚ : s.deleteMin le, eq with | some (a, tl), rfl => exact realSize_deleteMin eqβ‚‚
import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Data.Nat.Factorial.DoubleFactorial #align_import ring_theory.polynomial.hermite.basic from "leanprover-community/mathlib"@"938d3db9c278f8a52c0f964a405806f0f2b09b74" noncomputable section open Polynomial namespace Polynomial noncomputable def hermite : β„• β†’ Polynomial β„€ | 0 => 1 | n + 1 => X * hermite n - derivative (hermite n) #align polynomial.hermite Polynomial.hermite @[simp] theorem hermite_succ (n : β„•) : hermite (n + 1) = X * hermite n - derivative (hermite n) := by rw [hermite] #align polynomial.hermite_succ Polynomial.hermite_succ theorem hermite_eq_iterate (n : β„•) : hermite n = (fun p => X * p - derivative p)^[n] 1 := by induction' n with n ih Β· rfl Β· rw [Function.iterate_succ_apply', ← ih, hermite_succ] #align polynomial.hermite_eq_iterate Polynomial.hermite_eq_iterate @[simp] theorem hermite_zero : hermite 0 = C 1 := rfl #align polynomial.hermite_zero Polynomial.hermite_zero -- Porting note (#10618): There was initially @[simp] on this line but it was removed -- because simp can prove this theorem theorem hermite_one : hermite 1 = X := by rw [hermite_succ, hermite_zero] simp only [map_one, mul_one, derivative_one, sub_zero] #align polynomial.hermite_one Polynomial.hermite_one section coeff theorem coeff_hermite_succ_zero (n : β„•) : coeff (hermite (n + 1)) 0 = -coeff (hermite n) 1 := by simp [coeff_derivative] #align polynomial.coeff_hermite_succ_zero Polynomial.coeff_hermite_succ_zero theorem coeff_hermite_succ_succ (n k : β„•) : coeff (hermite (n + 1)) (k + 1) = coeff (hermite n) k - (k + 2) * coeff (hermite n) (k + 2) := by rw [hermite_succ, coeff_sub, coeff_X_mul, coeff_derivative, mul_comm] norm_cast #align polynomial.coeff_hermite_succ_succ Polynomial.coeff_hermite_succ_succ theorem coeff_hermite_of_lt {n k : β„•} (hnk : n < k) : coeff (hermite n) k = 0 := by obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_lt hnk clear hnk induction' n with n ih generalizing k Β· apply coeff_C Β· have : n + k + 1 + 2 = n + (k + 2) + 1 := by ring rw [coeff_hermite_succ_succ, add_right_comm, this, ih k, ih (k + 2), mul_zero, sub_zero] #align polynomial.coeff_hermite_of_lt Polynomial.coeff_hermite_of_lt @[simp]
Mathlib/RingTheory/Polynomial/Hermite/Basic.lean
103
107
theorem coeff_hermite_self (n : β„•) : coeff (hermite n) n = 1 := by
induction' n with n ih Β· apply coeff_C Β· rw [coeff_hermite_succ_succ, ih, coeff_hermite_of_lt, mul_zero, sub_zero] simp
import Mathlib.Tactic.Linarith import Mathlib.CategoryTheory.Skeletal import Mathlib.Data.Fintype.Sort import Mathlib.Order.Category.NonemptyFinLinOrd import Mathlib.CategoryTheory.Functor.ReflectsIso #align_import algebraic_topology.simplex_category from "leanprover-community/mathlib"@"e8ac6315bcfcbaf2d19a046719c3b553206dac75" universe v open CategoryTheory CategoryTheory.Limits def SimplexCategory := β„• #align simplex_category SimplexCategory namespace SimplexCategory section -- Porting note: the definition of `SimplexCategory` is made irreducible below def mk (n : β„•) : SimplexCategory := n #align simplex_category.mk SimplexCategory.mk scoped[Simplicial] notation "[" n "]" => SimplexCategory.mk n -- TODO: Make `len` irreducible. def len (n : SimplexCategory) : β„• := n #align simplex_category.len SimplexCategory.len @[ext] theorem ext (a b : SimplexCategory) : a.len = b.len β†’ a = b := id #align simplex_category.ext SimplexCategory.ext attribute [irreducible] SimplexCategory open Simplicial @[simp] theorem len_mk (n : β„•) : [n].len = n := rfl #align simplex_category.len_mk SimplexCategory.len_mk @[simp] theorem mk_len (n : SimplexCategory) : ([n.len] : SimplexCategory) = n := rfl #align simplex_category.mk_len SimplexCategory.mk_len protected def rec {F : SimplexCategory β†’ Sort*} (h : βˆ€ n : β„•, F [n]) : βˆ€ X, F X := fun n => h n.len #align simplex_category.rec SimplexCategory.rec -- porting note (#5171): removed @[nolint has_nonempty_instance] protected def Hom (a b : SimplexCategory) := Fin (a.len + 1) β†’o Fin (b.len + 1) #align simplex_category.hom SimplexCategory.Hom instance smallCategory : SmallCategory.{0} SimplexCategory where Hom n m := SimplexCategory.Hom n m id m := SimplexCategory.Hom.id _ comp f g := SimplexCategory.Hom.comp g f #align simplex_category.small_category SimplexCategory.smallCategory @[simp] lemma id_toOrderHom (a : SimplexCategory) : Hom.toOrderHom (πŸ™ a) = OrderHom.id := rfl @[simp] lemma comp_toOrderHom {a b c: SimplexCategory} (f : a ⟢ b) (g : b ⟢ c) : (f ≫ g).toOrderHom = g.toOrderHom.comp f.toOrderHom := rfl -- Porting note: added because `Hom.ext'` is not triggered automatically @[ext] theorem Hom.ext {a b : SimplexCategory} (f g : a ⟢ b) : f.toOrderHom = g.toOrderHom β†’ f = g := Hom.ext' _ _ def const (x y : SimplexCategory) (i : Fin (y.len + 1)) : x ⟢ y := Hom.mk <| ⟨fun _ => i, by tauto⟩ #align simplex_category.const SimplexCategory.const @[simp] lemma const_eq_id : const [0] [0] 0 = πŸ™ _ := by aesop @[simp] lemma const_apply (x y : SimplexCategory) (i : Fin (y.len + 1)) (a : Fin (x.len + 1)) : (const x y i).toOrderHom a = i := rfl @[simp] theorem const_comp (x : SimplexCategory) {y z : SimplexCategory} (f : y ⟢ z) (i : Fin (y.len + 1)) : const x y i ≫ f = const x z (f.toOrderHom i) := rfl #align simplex_category.const_comp SimplexCategory.const_comp @[simp] def mkHom {n m : β„•} (f : Fin (n + 1) β†’o Fin (m + 1)) : ([n] : SimplexCategory) ⟢ [m] := SimplexCategory.Hom.mk f #align simplex_category.mk_hom SimplexCategory.mkHom theorem hom_zero_zero (f : ([0] : SimplexCategory) ⟢ [0]) : f = πŸ™ _ := by ext : 3 apply @Subsingleton.elim (Fin 1) #align simplex_category.hom_zero_zero SimplexCategory.hom_zero_zero end open Simplicial section Skeleton @[simps obj map] def skeletalFunctor : SimplexCategory β₯€ NonemptyFinLinOrd where obj a := NonemptyFinLinOrd.of (Fin (a.len + 1)) map f := f.toOrderHom #align simplex_category.skeletal_functor SimplexCategory.skeletalFunctor theorem skeletalFunctor.coe_map {Δ₁ Ξ”β‚‚ : SimplexCategory} (f : Δ₁ ⟢ Ξ”β‚‚) : ↑(skeletalFunctor.map f) = f.toOrderHom := rfl #align simplex_category.skeletal_functor.coe_map SimplexCategory.skeletalFunctor.coe_map theorem skeletal : Skeletal SimplexCategory := fun X Y ⟨I⟩ => by suffices Fintype.card (Fin (X.len + 1)) = Fintype.card (Fin (Y.len + 1)) by ext simpa apply Fintype.card_congr exact ((skeletalFunctor β‹™ forget NonemptyFinLinOrd).mapIso I).toEquiv #align simplex_category.skeletal SimplexCategory.skeletal lemma isSkeletonOf : IsSkeletonOf NonemptyFinLinOrd SimplexCategory skeletalFunctor where skel := skeletal eqv := SkeletalFunctor.isEquivalence #align simplex_category.is_skeleton_of SimplexCategory.isSkeletonOf def Truncated (n : β„•) := FullSubcategory fun a : SimplexCategory => a.len ≀ n #align simplex_category.truncated SimplexCategory.Truncated instance (n : β„•) : SmallCategory.{0} (Truncated n) := FullSubcategory.category _ section EpiMono theorem mono_iff_injective {n m : SimplexCategory} {f : n ⟢ m} : Mono f ↔ Function.Injective f.toOrderHom := by rw [← Functor.mono_map_iff_mono skeletalEquivalence.functor] dsimp only [skeletalEquivalence, Functor.asEquivalence_functor] simp only [skeletalFunctor_obj, skeletalFunctor_map, NonemptyFinLinOrd.mono_iff_injective, NonemptyFinLinOrd.coe_of] #align simplex_category.mono_iff_injective SimplexCategory.mono_iff_injective theorem epi_iff_surjective {n m : SimplexCategory} {f : n ⟢ m} : Epi f ↔ Function.Surjective f.toOrderHom := by rw [← Functor.epi_map_iff_epi skeletalEquivalence.functor] dsimp only [skeletalEquivalence, Functor.asEquivalence_functor] simp only [skeletalFunctor_obj, skeletalFunctor_map, NonemptyFinLinOrd.epi_iff_surjective, NonemptyFinLinOrd.coe_of] #align simplex_category.epi_iff_surjective SimplexCategory.epi_iff_surjective theorem len_le_of_mono {x y : SimplexCategory} {f : x ⟢ y} : Mono f β†’ x.len ≀ y.len := by intro hyp_f_mono have f_inj : Function.Injective f.toOrderHom.toFun := mono_iff_injective.1 hyp_f_mono simpa using Fintype.card_le_of_injective f.toOrderHom.toFun f_inj #align simplex_category.len_le_of_mono SimplexCategory.len_le_of_mono theorem le_of_mono {n m : β„•} {f : ([n] : SimplexCategory) ⟢ [m]} : CategoryTheory.Mono f β†’ n ≀ m := len_le_of_mono #align simplex_category.le_of_mono SimplexCategory.le_of_mono theorem len_le_of_epi {x y : SimplexCategory} {f : x ⟢ y} : Epi f β†’ y.len ≀ x.len := by intro hyp_f_epi have f_surj : Function.Surjective f.toOrderHom.toFun := epi_iff_surjective.1 hyp_f_epi simpa using Fintype.card_le_of_surjective f.toOrderHom.toFun f_surj #align simplex_category.len_le_of_epi SimplexCategory.len_le_of_epi theorem le_of_epi {n m : β„•} {f : ([n] : SimplexCategory) ⟢ [m]} : Epi f β†’ m ≀ n := len_le_of_epi #align simplex_category.le_of_epi SimplexCategory.le_of_epi instance {n : β„•} {i : Fin (n + 2)} : Mono (Ξ΄ i) := by rw [mono_iff_injective] exact Fin.succAbove_right_injective instance {n : β„•} {i : Fin (n + 1)} : Epi (Οƒ i) := by rw [epi_iff_surjective] intro b simp only [Οƒ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk] by_cases h : b ≀ i Β· use b -- This was not needed before leanprover/lean4#2644 dsimp rw [Fin.predAbove_of_le_castSucc i b (by simpa only [Fin.coe_eq_castSucc] using h)] simp only [len_mk, Fin.coe_eq_castSucc, Fin.castPred_castSucc] Β· use b.succ -- This was not needed before leanprover/lean4#2644 dsimp rw [Fin.predAbove_of_castSucc_lt i b.succ _, Fin.pred_succ] rw [not_le] at h rw [Fin.lt_iff_val_lt_val] at h ⊒ simpa only [Fin.val_succ, Fin.coe_castSucc] using Nat.lt.step h instance : (forget SimplexCategory).ReflectsIsomorphisms := ⟨fun f hf => Iso.isIso_hom { hom := f inv := Hom.mk { toFun := inv ((forget SimplexCategory).map f) monotone' := fun y₁ yβ‚‚ h => by by_cases h' : y₁ < yβ‚‚ Β· by_contra h'' apply not_le.mpr h' convert f.toOrderHom.monotone (le_of_not_ge h'') all_goals exact (congr_hom (Iso.inv_hom_id (asIso ((forget SimplexCategory).map f))) _).symm Β· rw [eq_of_le_of_not_lt h h'] } hom_inv_id := by ext1 ext1 exact Iso.hom_inv_id (asIso ((forget _).map f)) inv_hom_id := by ext1 ext1 exact Iso.inv_hom_id (asIso ((forget _).map f)) }⟩ theorem isIso_of_bijective {x y : SimplexCategory} {f : x ⟢ y} (hf : Function.Bijective f.toOrderHom.toFun) : IsIso f := haveI : IsIso ((forget SimplexCategory).map f) := (isIso_iff_bijective _).mpr hf isIso_of_reflects_iso f (forget SimplexCategory) #align simplex_category.is_iso_of_bijective SimplexCategory.isIso_of_bijective @[simp] def orderIsoOfIso {x y : SimplexCategory} (e : x β‰… y) : Fin (x.len + 1) ≃o Fin (y.len + 1) := Equiv.toOrderIso { toFun := e.hom.toOrderHom invFun := e.inv.toOrderHom left_inv := fun i => by simpa only using congr_arg (fun Ο† => (Hom.toOrderHom Ο†) i) e.hom_inv_id right_inv := fun i => by simpa only using congr_arg (fun Ο† => (Hom.toOrderHom Ο†) i) e.inv_hom_id } e.hom.toOrderHom.monotone e.inv.toOrderHom.monotone #align simplex_category.order_iso_of_iso SimplexCategory.orderIsoOfIso
Mathlib/AlgebraicTopology/SimplexCategory.lean
658
668
theorem iso_eq_iso_refl {x : SimplexCategory} (e : x β‰… x) : e = Iso.refl x := by
have h : (Finset.univ : Finset (Fin (x.len + 1))).card = x.len + 1 := Finset.card_fin (x.len + 1) have eq₁ := Finset.orderEmbOfFin_unique' h fun i => Finset.mem_univ ((orderIsoOfIso e) i) have eqβ‚‚ := Finset.orderEmbOfFin_unique' h fun i => Finset.mem_univ ((orderIsoOfIso (Iso.refl x)) i) -- Porting note: the proof was rewritten from this point in #3414 (reenableeta) -- It could be investigated again to see if the original can be restored. ext x replace eq₁ := congr_arg (Β· x) eq₁ replace eqβ‚‚ := congr_arg (Β· x) eqβ‚‚.symm simp_all
import Mathlib.Algebra.ModEq import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.Archimedean import Mathlib.Algebra.Periodic import Mathlib.Data.Int.SuccPred import Mathlib.GroupTheory.QuotientGroup import Mathlib.Order.Circular import Mathlib.Data.List.TFAE import Mathlib.Data.Set.Lattice #align_import algebra.order.to_interval_mod from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec" noncomputable section section LinearOrderedAddCommGroup variable {Ξ± : Type*} [LinearOrderedAddCommGroup Ξ±] [hΞ± : Archimedean Ξ±] {p : Ξ±} (hp : 0 < p) {a b c : Ξ±} {n : β„€} def toIcoDiv (a b : Ξ±) : β„€ := (existsUnique_sub_zsmul_mem_Ico hp b a).choose #align to_Ico_div toIcoDiv theorem sub_toIcoDiv_zsmul_mem_Ico (a b : Ξ±) : b - toIcoDiv hp a b β€’ p ∈ Set.Ico a (a + p) := (existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.1 #align sub_to_Ico_div_zsmul_mem_Ico sub_toIcoDiv_zsmul_mem_Ico theorem toIcoDiv_eq_of_sub_zsmul_mem_Ico (h : b - n β€’ p ∈ Set.Ico a (a + p)) : toIcoDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.2 _ h).symm #align to_Ico_div_eq_of_sub_zsmul_mem_Ico toIcoDiv_eq_of_sub_zsmul_mem_Ico def toIocDiv (a b : Ξ±) : β„€ := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose #align to_Ioc_div toIocDiv theorem sub_toIocDiv_zsmul_mem_Ioc (a b : Ξ±) : b - toIocDiv hp a b β€’ p ∈ Set.Ioc a (a + p) := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.1 #align sub_to_Ioc_div_zsmul_mem_Ioc sub_toIocDiv_zsmul_mem_Ioc theorem toIocDiv_eq_of_sub_zsmul_mem_Ioc (h : b - n β€’ p ∈ Set.Ioc a (a + p)) : toIocDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.2 _ h).symm #align to_Ioc_div_eq_of_sub_zsmul_mem_Ioc toIocDiv_eq_of_sub_zsmul_mem_Ioc def toIcoMod (a b : Ξ±) : Ξ± := b - toIcoDiv hp a b β€’ p #align to_Ico_mod toIcoMod def toIocMod (a b : Ξ±) : Ξ± := b - toIocDiv hp a b β€’ p #align to_Ioc_mod toIocMod theorem toIcoMod_mem_Ico (a b : Ξ±) : toIcoMod hp a b ∈ Set.Ico a (a + p) := sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_mod_mem_Ico toIcoMod_mem_Ico theorem toIcoMod_mem_Ico' (b : Ξ±) : toIcoMod hp 0 b ∈ Set.Ico 0 p := by convert toIcoMod_mem_Ico hp 0 b exact (zero_add p).symm #align to_Ico_mod_mem_Ico' toIcoMod_mem_Ico' theorem toIocMod_mem_Ioc (a b : Ξ±) : toIocMod hp a b ∈ Set.Ioc a (a + p) := sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_mod_mem_Ioc toIocMod_mem_Ioc theorem left_le_toIcoMod (a b : Ξ±) : a ≀ toIcoMod hp a b := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).1 #align left_le_to_Ico_mod left_le_toIcoMod theorem left_lt_toIocMod (a b : Ξ±) : a < toIocMod hp a b := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).1 #align left_lt_to_Ioc_mod left_lt_toIocMod theorem toIcoMod_lt_right (a b : Ξ±) : toIcoMod hp a b < a + p := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).2 #align to_Ico_mod_lt_right toIcoMod_lt_right theorem toIocMod_le_right (a b : Ξ±) : toIocMod hp a b ≀ a + p := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).2 #align to_Ioc_mod_le_right toIocMod_le_right @[simp] theorem self_sub_toIcoDiv_zsmul (a b : Ξ±) : b - toIcoDiv hp a b β€’ p = toIcoMod hp a b := rfl #align self_sub_to_Ico_div_zsmul self_sub_toIcoDiv_zsmul @[simp] theorem self_sub_toIocDiv_zsmul (a b : Ξ±) : b - toIocDiv hp a b β€’ p = toIocMod hp a b := rfl #align self_sub_to_Ioc_div_zsmul self_sub_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_self (a b : Ξ±) : toIcoDiv hp a b β€’ p - b = -toIcoMod hp a b := by rw [toIcoMod, neg_sub] #align to_Ico_div_zsmul_sub_self toIcoDiv_zsmul_sub_self @[simp] theorem toIocDiv_zsmul_sub_self (a b : Ξ±) : toIocDiv hp a b β€’ p - b = -toIocMod hp a b := by rw [toIocMod, neg_sub] #align to_Ioc_div_zsmul_sub_self toIocDiv_zsmul_sub_self @[simp] theorem toIcoMod_sub_self (a b : Ξ±) : toIcoMod hp a b - b = -toIcoDiv hp a b β€’ p := by rw [toIcoMod, sub_sub_cancel_left, neg_smul] #align to_Ico_mod_sub_self toIcoMod_sub_self @[simp] theorem toIocMod_sub_self (a b : Ξ±) : toIocMod hp a b - b = -toIocDiv hp a b β€’ p := by rw [toIocMod, sub_sub_cancel_left, neg_smul] #align to_Ioc_mod_sub_self toIocMod_sub_self @[simp] theorem self_sub_toIcoMod (a b : Ξ±) : b - toIcoMod hp a b = toIcoDiv hp a b β€’ p := by rw [toIcoMod, sub_sub_cancel] #align self_sub_to_Ico_mod self_sub_toIcoMod @[simp] theorem self_sub_toIocMod (a b : Ξ±) : b - toIocMod hp a b = toIocDiv hp a b β€’ p := by rw [toIocMod, sub_sub_cancel] #align self_sub_to_Ioc_mod self_sub_toIocMod @[simp] theorem toIcoMod_add_toIcoDiv_zsmul (a b : Ξ±) : toIcoMod hp a b + toIcoDiv hp a b β€’ p = b := by rw [toIcoMod, sub_add_cancel] #align to_Ico_mod_add_to_Ico_div_zsmul toIcoMod_add_toIcoDiv_zsmul @[simp] theorem toIocMod_add_toIocDiv_zsmul (a b : Ξ±) : toIocMod hp a b + toIocDiv hp a b β€’ p = b := by rw [toIocMod, sub_add_cancel] #align to_Ioc_mod_add_to_Ioc_div_zsmul toIocMod_add_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_toIcoMod (a b : Ξ±) : toIcoDiv hp a b β€’ p + toIcoMod hp a b = b := by rw [add_comm, toIcoMod_add_toIcoDiv_zsmul] #align to_Ico_div_zsmul_sub_to_Ico_mod toIcoDiv_zsmul_sub_toIcoMod @[simp] theorem toIocDiv_zsmul_sub_toIocMod (a b : Ξ±) : toIocDiv hp a b β€’ p + toIocMod hp a b = b := by rw [add_comm, toIocMod_add_toIocDiv_zsmul] #align to_Ioc_div_zsmul_sub_to_Ioc_mod toIocDiv_zsmul_sub_toIocMod theorem toIcoMod_eq_iff : toIcoMod hp a b = c ↔ c ∈ Set.Ico a (a + p) ∧ βˆƒ z : β„€, b = c + z β€’ p := by refine ⟨fun h => ⟨h β–Έ toIcoMod_mem_Ico hp a b, toIcoDiv hp a b, h β–Έ (toIcoMod_add_toIcoDiv_zsmul _ _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIcoDiv_eq_of_sub_zsmul_mem_Ico hp hc, toIcoMod] #align to_Ico_mod_eq_iff toIcoMod_eq_iff theorem toIocMod_eq_iff : toIocMod hp a b = c ↔ c ∈ Set.Ioc a (a + p) ∧ βˆƒ z : β„€, b = c + z β€’ p := by refine ⟨fun h => ⟨h β–Έ toIocMod_mem_Ioc hp a b, toIocDiv hp a b, h β–Έ (toIocMod_add_toIocDiv_zsmul hp _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIocDiv_eq_of_sub_zsmul_mem_Ioc hp hc, toIocMod] #align to_Ioc_mod_eq_iff toIocMod_eq_iff @[simp] theorem toIcoDiv_apply_left (a : Ξ±) : toIcoDiv hp a a = 0 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_left toIcoDiv_apply_left @[simp] theorem toIocDiv_apply_left (a : Ξ±) : toIocDiv hp a a = -1 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_left toIocDiv_apply_left @[simp] theorem toIcoMod_apply_left (a : Ξ±) : toIcoMod hp a a = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ico_mod_apply_left toIcoMod_apply_left @[simp] theorem toIocMod_apply_left (a : Ξ±) : toIocMod hp a a = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, -1, by simp⟩ #align to_Ioc_mod_apply_left toIocMod_apply_left theorem toIcoDiv_apply_right (a : Ξ±) : toIcoDiv hp a (a + p) = 1 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_right toIcoDiv_apply_right theorem toIocDiv_apply_right (a : Ξ±) : toIocDiv hp a (a + p) = 0 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_right toIocDiv_apply_right theorem toIcoMod_apply_right (a : Ξ±) : toIcoMod hp a (a + p) = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 1, by simp⟩ #align to_Ico_mod_apply_right toIcoMod_apply_right theorem toIocMod_apply_right (a : Ξ±) : toIocMod hp a (a + p) = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ioc_mod_apply_right toIocMod_apply_right @[simp] theorem toIcoDiv_add_zsmul (a b : Ξ±) (m : β„€) : toIcoDiv hp a (b + m β€’ p) = toIcoDiv hp a b + m := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul toIcoDiv_add_zsmul @[simp] theorem toIcoDiv_add_zsmul' (a b : Ξ±) (m : β„€) : toIcoDiv hp (a + m β€’ p) b = toIcoDiv hp a b - m := by refine toIcoDiv_eq_of_sub_zsmul_mem_Ico _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul' toIcoDiv_add_zsmul' @[simp] theorem toIocDiv_add_zsmul (a b : Ξ±) (m : β„€) : toIocDiv hp a (b + m β€’ p) = toIocDiv hp a b + m := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul toIocDiv_add_zsmul @[simp] theorem toIocDiv_add_zsmul' (a b : Ξ±) (m : β„€) : toIocDiv hp (a + m β€’ p) b = toIocDiv hp a b - m := by refine toIocDiv_eq_of_sub_zsmul_mem_Ioc _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul' toIocDiv_add_zsmul' @[simp] theorem toIcoDiv_zsmul_add (a b : Ξ±) (m : β„€) : toIcoDiv hp a (m β€’ p + b) = m + toIcoDiv hp a b := by rw [add_comm, toIcoDiv_add_zsmul, add_comm] #align to_Ico_div_zsmul_add toIcoDiv_zsmul_add @[simp] theorem toIocDiv_zsmul_add (a b : Ξ±) (m : β„€) : toIocDiv hp a (m β€’ p + b) = m + toIocDiv hp a b := by rw [add_comm, toIocDiv_add_zsmul, add_comm] #align to_Ioc_div_zsmul_add toIocDiv_zsmul_add @[simp] theorem toIcoDiv_sub_zsmul (a b : Ξ±) (m : β„€) : toIcoDiv hp a (b - m β€’ p) = toIcoDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul, sub_eq_add_neg] #align to_Ico_div_sub_zsmul toIcoDiv_sub_zsmul @[simp] theorem toIcoDiv_sub_zsmul' (a b : Ξ±) (m : β„€) : toIcoDiv hp (a - m β€’ p) b = toIcoDiv hp a b + m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul', sub_neg_eq_add] #align to_Ico_div_sub_zsmul' toIcoDiv_sub_zsmul' @[simp] theorem toIocDiv_sub_zsmul (a b : Ξ±) (m : β„€) : toIocDiv hp a (b - m β€’ p) = toIocDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul, sub_eq_add_neg] #align to_Ioc_div_sub_zsmul toIocDiv_sub_zsmul @[simp] theorem toIocDiv_sub_zsmul' (a b : Ξ±) (m : β„€) : toIocDiv hp (a - m β€’ p) b = toIocDiv hp a b + m := by rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul', sub_neg_eq_add] #align to_Ioc_div_sub_zsmul' toIocDiv_sub_zsmul' @[simp] theorem toIcoDiv_add_right (a b : Ξ±) : toIcoDiv hp a (b + p) = toIcoDiv hp a b + 1 := by simpa only [one_zsmul] using toIcoDiv_add_zsmul hp a b 1 #align to_Ico_div_add_right toIcoDiv_add_right @[simp] theorem toIcoDiv_add_right' (a b : Ξ±) : toIcoDiv hp (a + p) b = toIcoDiv hp a b - 1 := by simpa only [one_zsmul] using toIcoDiv_add_zsmul' hp a b 1 #align to_Ico_div_add_right' toIcoDiv_add_right' @[simp] theorem toIocDiv_add_right (a b : Ξ±) : toIocDiv hp a (b + p) = toIocDiv hp a b + 1 := by simpa only [one_zsmul] using toIocDiv_add_zsmul hp a b 1 #align to_Ioc_div_add_right toIocDiv_add_right @[simp] theorem toIocDiv_add_right' (a b : Ξ±) : toIocDiv hp (a + p) b = toIocDiv hp a b - 1 := by simpa only [one_zsmul] using toIocDiv_add_zsmul' hp a b 1 #align to_Ioc_div_add_right' toIocDiv_add_right' @[simp] theorem toIcoDiv_add_left (a b : Ξ±) : toIcoDiv hp a (p + b) = toIcoDiv hp a b + 1 := by rw [add_comm, toIcoDiv_add_right] #align to_Ico_div_add_left toIcoDiv_add_left @[simp] theorem toIcoDiv_add_left' (a b : Ξ±) : toIcoDiv hp (p + a) b = toIcoDiv hp a b - 1 := by rw [add_comm, toIcoDiv_add_right'] #align to_Ico_div_add_left' toIcoDiv_add_left' @[simp] theorem toIocDiv_add_left (a b : Ξ±) : toIocDiv hp a (p + b) = toIocDiv hp a b + 1 := by rw [add_comm, toIocDiv_add_right] #align to_Ioc_div_add_left toIocDiv_add_left @[simp] theorem toIocDiv_add_left' (a b : Ξ±) : toIocDiv hp (p + a) b = toIocDiv hp a b - 1 := by rw [add_comm, toIocDiv_add_right'] #align to_Ioc_div_add_left' toIocDiv_add_left' @[simp] theorem toIcoDiv_sub (a b : Ξ±) : toIcoDiv hp a (b - p) = toIcoDiv hp a b - 1 := by simpa only [one_zsmul] using toIcoDiv_sub_zsmul hp a b 1 #align to_Ico_div_sub toIcoDiv_sub @[simp] theorem toIcoDiv_sub' (a b : Ξ±) : toIcoDiv hp (a - p) b = toIcoDiv hp a b + 1 := by simpa only [one_zsmul] using toIcoDiv_sub_zsmul' hp a b 1 #align to_Ico_div_sub' toIcoDiv_sub' @[simp] theorem toIocDiv_sub (a b : Ξ±) : toIocDiv hp a (b - p) = toIocDiv hp a b - 1 := by simpa only [one_zsmul] using toIocDiv_sub_zsmul hp a b 1 #align to_Ioc_div_sub toIocDiv_sub @[simp] theorem toIocDiv_sub' (a b : Ξ±) : toIocDiv hp (a - p) b = toIocDiv hp a b + 1 := by simpa only [one_zsmul] using toIocDiv_sub_zsmul' hp a b 1 #align to_Ioc_div_sub' toIocDiv_sub' theorem toIcoDiv_sub_eq_toIcoDiv_add (a b c : Ξ±) : toIcoDiv hp a (b - c) = toIcoDiv hp (a + c) b := by apply toIcoDiv_eq_of_sub_zsmul_mem_Ico rw [← sub_right_comm, Set.sub_mem_Ico_iff_left, add_right_comm] exact sub_toIcoDiv_zsmul_mem_Ico hp (a + c) b #align to_Ico_div_sub_eq_to_Ico_div_add toIcoDiv_sub_eq_toIcoDiv_add theorem toIocDiv_sub_eq_toIocDiv_add (a b c : Ξ±) : toIocDiv hp a (b - c) = toIocDiv hp (a + c) b := by apply toIocDiv_eq_of_sub_zsmul_mem_Ioc rw [← sub_right_comm, Set.sub_mem_Ioc_iff_left, add_right_comm] exact sub_toIocDiv_zsmul_mem_Ioc hp (a + c) b #align to_Ioc_div_sub_eq_to_Ioc_div_add toIocDiv_sub_eq_toIocDiv_add theorem toIcoDiv_sub_eq_toIcoDiv_add' (a b c : Ξ±) : toIcoDiv hp (a - c) b = toIcoDiv hp a (b + c) := by rw [← sub_neg_eq_add, toIcoDiv_sub_eq_toIcoDiv_add, sub_eq_add_neg] #align to_Ico_div_sub_eq_to_Ico_div_add' toIcoDiv_sub_eq_toIcoDiv_add' theorem toIocDiv_sub_eq_toIocDiv_add' (a b c : Ξ±) : toIocDiv hp (a - c) b = toIocDiv hp a (b + c) := by rw [← sub_neg_eq_add, toIocDiv_sub_eq_toIocDiv_add, sub_eq_add_neg] #align to_Ioc_div_sub_eq_to_Ioc_div_add' toIocDiv_sub_eq_toIocDiv_add' theorem toIcoDiv_neg (a b : Ξ±) : toIcoDiv hp a (-b) = -(toIocDiv hp (-a) b + 1) := by suffices toIcoDiv hp a (-b) = -toIocDiv hp (-(a + p)) b by rwa [neg_add, ← sub_eq_add_neg, toIocDiv_sub_eq_toIocDiv_add', toIocDiv_add_right] at this rw [← neg_eq_iff_eq_neg, eq_comm] apply toIocDiv_eq_of_sub_zsmul_mem_Ioc obtain ⟨hc, ho⟩ := sub_toIcoDiv_zsmul_mem_Ico hp a (-b) rw [← neg_lt_neg_iff, neg_sub' (-b), neg_neg, ← neg_smul] at ho rw [← neg_le_neg_iff, neg_sub' (-b), neg_neg, ← neg_smul] at hc refine ⟨ho, hc.trans_eq ?_⟩ rw [neg_add, neg_add_cancel_right] #align to_Ico_div_neg toIcoDiv_neg theorem toIcoDiv_neg' (a b : Ξ±) : toIcoDiv hp (-a) b = -(toIocDiv hp a (-b) + 1) := by simpa only [neg_neg] using toIcoDiv_neg hp (-a) (-b) #align to_Ico_div_neg' toIcoDiv_neg' theorem toIocDiv_neg (a b : Ξ±) : toIocDiv hp a (-b) = -(toIcoDiv hp (-a) b + 1) := by rw [← neg_neg b, toIcoDiv_neg, neg_neg, neg_neg, neg_add', neg_neg, add_sub_cancel_right] #align to_Ioc_div_neg toIocDiv_neg theorem toIocDiv_neg' (a b : Ξ±) : toIocDiv hp (-a) b = -(toIcoDiv hp a (-b) + 1) := by simpa only [neg_neg] using toIocDiv_neg hp (-a) (-b) #align to_Ioc_div_neg' toIocDiv_neg' @[simp] theorem toIcoMod_add_zsmul (a b : Ξ±) (m : β„€) : toIcoMod hp a (b + m β€’ p) = toIcoMod hp a b := by rw [toIcoMod, toIcoDiv_add_zsmul, toIcoMod, add_smul] abel #align to_Ico_mod_add_zsmul toIcoMod_add_zsmul @[simp] theorem toIcoMod_add_zsmul' (a b : Ξ±) (m : β„€) : toIcoMod hp (a + m β€’ p) b = toIcoMod hp a b + m β€’ p := by simp only [toIcoMod, toIcoDiv_add_zsmul', sub_smul, sub_add] #align to_Ico_mod_add_zsmul' toIcoMod_add_zsmul' @[simp] theorem toIocMod_add_zsmul (a b : Ξ±) (m : β„€) : toIocMod hp a (b + m β€’ p) = toIocMod hp a b := by rw [toIocMod, toIocDiv_add_zsmul, toIocMod, add_smul] abel #align to_Ioc_mod_add_zsmul toIocMod_add_zsmul @[simp] theorem toIocMod_add_zsmul' (a b : Ξ±) (m : β„€) : toIocMod hp (a + m β€’ p) b = toIocMod hp a b + m β€’ p := by simp only [toIocMod, toIocDiv_add_zsmul', sub_smul, sub_add] #align to_Ioc_mod_add_zsmul' toIocMod_add_zsmul' @[simp] theorem toIcoMod_zsmul_add (a b : Ξ±) (m : β„€) : toIcoMod hp a (m β€’ p + b) = toIcoMod hp a b := by rw [add_comm, toIcoMod_add_zsmul] #align to_Ico_mod_zsmul_add toIcoMod_zsmul_add @[simp] theorem toIcoMod_zsmul_add' (a b : Ξ±) (m : β„€) : toIcoMod hp (m β€’ p + a) b = m β€’ p + toIcoMod hp a b := by rw [add_comm, toIcoMod_add_zsmul', add_comm] #align to_Ico_mod_zsmul_add' toIcoMod_zsmul_add' @[simp] theorem toIocMod_zsmul_add (a b : Ξ±) (m : β„€) : toIocMod hp a (m β€’ p + b) = toIocMod hp a b := by rw [add_comm, toIocMod_add_zsmul] #align to_Ioc_mod_zsmul_add toIocMod_zsmul_add @[simp] theorem toIocMod_zsmul_add' (a b : Ξ±) (m : β„€) : toIocMod hp (m β€’ p + a) b = m β€’ p + toIocMod hp a b := by rw [add_comm, toIocMod_add_zsmul', add_comm] #align to_Ioc_mod_zsmul_add' toIocMod_zsmul_add' @[simp] theorem toIcoMod_sub_zsmul (a b : Ξ±) (m : β„€) : toIcoMod hp a (b - m β€’ p) = toIcoMod hp a b := by rw [sub_eq_add_neg, ← neg_smul, toIcoMod_add_zsmul] #align to_Ico_mod_sub_zsmul toIcoMod_sub_zsmul @[simp] theorem toIcoMod_sub_zsmul' (a b : Ξ±) (m : β„€) : toIcoMod hp (a - m β€’ p) b = toIcoMod hp a b - m β€’ p := by simp_rw [sub_eq_add_neg, ← neg_smul, toIcoMod_add_zsmul'] #align to_Ico_mod_sub_zsmul' toIcoMod_sub_zsmul' @[simp] theorem toIocMod_sub_zsmul (a b : Ξ±) (m : β„€) : toIocMod hp a (b - m β€’ p) = toIocMod hp a b := by rw [sub_eq_add_neg, ← neg_smul, toIocMod_add_zsmul] #align to_Ioc_mod_sub_zsmul toIocMod_sub_zsmul @[simp] theorem toIocMod_sub_zsmul' (a b : Ξ±) (m : β„€) : toIocMod hp (a - m β€’ p) b = toIocMod hp a b - m β€’ p := by simp_rw [sub_eq_add_neg, ← neg_smul, toIocMod_add_zsmul'] #align to_Ioc_mod_sub_zsmul' toIocMod_sub_zsmul' @[simp] theorem toIcoMod_add_right (a b : Ξ±) : toIcoMod hp a (b + p) = toIcoMod hp a b := by simpa only [one_zsmul] using toIcoMod_add_zsmul hp a b 1 #align to_Ico_mod_add_right toIcoMod_add_right @[simp]
Mathlib/Algebra/Order/ToIntervalMod.lean
480
481
theorem toIcoMod_add_right' (a b : Ξ±) : toIcoMod hp (a + p) b = toIcoMod hp a b + p := by
simpa only [one_zsmul] using toIcoMod_add_zsmul' hp a b 1
import Mathlib.Algebra.BigOperators.Finsupp import Mathlib.Algebra.BigOperators.Finprod import Mathlib.Data.Fintype.BigOperators import Mathlib.LinearAlgebra.Finsupp import Mathlib.LinearAlgebra.LinearIndependent import Mathlib.SetTheory.Cardinal.Cofinality #align_import linear_algebra.basis from "leanprover-community/mathlib"@"13bce9a6b6c44f6b4c91ac1c1d2a816e2533d395" noncomputable section universe u open Function Set Submodule variable {ΞΉ : Type*} {ΞΉ' : Type*} {R : Type*} {Rβ‚‚ : Type*} {K : Type*} variable {M : Type*} {M' M'' : Type*} {V : Type u} {V' : Type*} section Module variable [Semiring R] variable [AddCommMonoid M] [Module R M] [AddCommMonoid M'] [Module R M'] section variable (ΞΉ R M) structure Basis where ofRepr :: repr : M ≃ₗ[R] ΞΉ β†’β‚€ R #align basis Basis #align basis.repr Basis.repr #align basis.of_repr Basis.ofRepr end instance uniqueBasis [Subsingleton R] : Unique (Basis ΞΉ R M) := ⟨⟨⟨default⟩⟩, fun ⟨b⟩ => by rw [Subsingleton.elim b]⟩ #align unique_basis uniqueBasis namespace Basis instance : Inhabited (Basis ΞΉ R (ΞΉ β†’β‚€ R)) := ⟨.ofRepr (LinearEquiv.refl _ _)⟩ variable (b b₁ : Basis ΞΉ R M) (i : ΞΉ) (c : R) (x : M) section Coord @[simps!] def coord : M β†’β‚—[R] R := Finsupp.lapply i βˆ˜β‚— ↑b.repr #align basis.coord Basis.coord theorem forall_coord_eq_zero_iff {x : M} : (βˆ€ i, b.coord i x = 0) ↔ x = 0 := Iff.trans (by simp only [b.coord_apply, DFunLike.ext_iff, Finsupp.zero_apply]) b.repr.map_eq_zero_iff #align basis.forall_coord_eq_zero_iff Basis.forall_coord_eq_zero_iff noncomputable def sumCoords : M β†’β‚—[R] R := (Finsupp.lsum β„• fun _ => LinearMap.id) βˆ˜β‚— (b.repr : M β†’β‚—[R] ΞΉ β†’β‚€ R) #align basis.sum_coords Basis.sumCoords @[simp] theorem coe_sumCoords : (b.sumCoords : M β†’ R) = fun m => (b.repr m).sum fun _ => id := rfl #align basis.coe_sum_coords Basis.coe_sumCoords theorem coe_sumCoords_eq_finsum : (b.sumCoords : M β†’ R) = fun m => βˆ‘αΆ  i, b.coord i m := by ext m simp only [Basis.sumCoords, Basis.coord, Finsupp.lapply_apply, LinearMap.id_coe, LinearEquiv.coe_coe, Function.comp_apply, Finsupp.coe_lsum, LinearMap.coe_comp, finsum_eq_sum _ (b.repr m).finite_support, Finsupp.sum, Finset.finite_toSet_toFinset, id, Finsupp.fun_support_eq] #align basis.coe_sum_coords_eq_finsum Basis.coe_sumCoords_eq_finsum @[simp high] theorem coe_sumCoords_of_fintype [Fintype ΞΉ] : (b.sumCoords : M β†’ R) = βˆ‘ i, b.coord i := by ext m -- Porting note: - `eq_self_iff_true` -- + `comp_apply` `LinearMap.coeFn_sum` simp only [sumCoords, Finsupp.sum_fintype, LinearMap.id_coe, LinearEquiv.coe_coe, coord_apply, id, Fintype.sum_apply, imp_true_iff, Finsupp.coe_lsum, LinearMap.coe_comp, comp_apply, LinearMap.coeFn_sum] #align basis.coe_sum_coords_of_fintype Basis.coe_sumCoords_of_fintype @[simp]
Mathlib/LinearAlgebra/Basis.lean
250
252
theorem sumCoords_self_apply : b.sumCoords (b i) = 1 := by
simp only [Basis.sumCoords, LinearMap.id_coe, LinearEquiv.coe_coe, id, Basis.repr_self, Function.comp_apply, Finsupp.coe_lsum, LinearMap.coe_comp, Finsupp.sum_single_index]
import Mathlib.Data.Nat.Factorization.Basic import Mathlib.Data.SetLike.Fintype import Mathlib.GroupTheory.GroupAction.ConjAct import Mathlib.GroupTheory.PGroup import Mathlib.GroupTheory.NoncommPiCoprod import Mathlib.Order.Atoms.Finite import Mathlib.Data.Set.Lattice #align_import group_theory.sylow from "leanprover-community/mathlib"@"4be589053caf347b899a494da75410deb55fb3ef" open Fintype MulAction Subgroup section InfiniteSylow variable (p : β„•) (G : Type*) [Group G] structure Sylow extends Subgroup G where isPGroup' : IsPGroup p toSubgroup is_maximal' : βˆ€ {Q : Subgroup G}, IsPGroup p Q β†’ toSubgroup ≀ Q β†’ Q = toSubgroup #align sylow Sylow variable {p} {G} open Equiv Equiv.Perm Finset Function List QuotientGroup universe u v w variable {G : Type u} {Ξ± : Type v} {Ξ² : Type w} [Group G] attribute [local instance 10] Subtype.fintype setFintype Classical.propDecidable theorem QuotientGroup.card_preimage_mk [Fintype G] (s : Subgroup G) (t : Set (G β§Έ s)) : Fintype.card (QuotientGroup.mk ⁻¹' t) = Fintype.card s * Fintype.card t := by rw [← Fintype.card_prod, Fintype.card_congr (preimageMkEquivSubgroupProdSet _ _)] #align quotient_group.card_preimage_mk QuotientGroup.card_preimage_mk namespace Sylow theorem mem_fixedPoints_mul_left_cosets_iff_mem_normalizer {H : Subgroup G} [Finite (H : Set G)] {x : G} : (x : G β§Έ H) ∈ MulAction.fixedPoints H (G β§Έ H) ↔ x ∈ normalizer H := ⟨fun hx => have ha : βˆ€ {y : G β§Έ H}, y ∈ orbit H (x : G β§Έ H) β†’ y = x := mem_fixedPoints'.1 hx _ (inv_mem_iff (G := G)).1 (mem_normalizer_fintype fun n (hn : n ∈ H) => have : (n⁻¹ * x)⁻¹ * x ∈ H := QuotientGroup.eq.1 (ha ⟨⟨n⁻¹, inv_mem hn⟩, rfl⟩) show _ ∈ H by rw [mul_inv_rev, inv_inv] at this convert this rw [inv_inv]), fun hx : βˆ€ n : G, n ∈ H ↔ x * n * x⁻¹ ∈ H => mem_fixedPoints'.2 fun y => Quotient.inductionOn' y fun y hy => QuotientGroup.eq.2 (let ⟨⟨b, hbβ‚βŸ©, hbβ‚‚βŸ© := hy have hbβ‚‚ : (b * x)⁻¹ * y ∈ H := QuotientGroup.eq.1 hbβ‚‚ (inv_mem_iff (G := G)).1 <| (hx _).2 <| (mul_mem_cancel_left (inv_mem hb₁)).1 <| by rw [hx] at hbβ‚‚; simpa [mul_inv_rev, mul_assoc] using hbβ‚‚)⟩ #align sylow.mem_fixed_points_mul_left_cosets_iff_mem_normalizer Sylow.mem_fixedPoints_mul_left_cosets_iff_mem_normalizer def fixedPointsMulLeftCosetsEquivQuotient (H : Subgroup G) [Finite (H : Set G)] : MulAction.fixedPoints H (G β§Έ H) ≃ normalizer H β§Έ Subgroup.comap ((normalizer H).subtype : normalizer H β†’* G) H := @subtypeQuotientEquivQuotientSubtype G (normalizer H : Set G) (_) (_) (MulAction.fixedPoints H (G β§Έ H)) (fun a => (@mem_fixedPoints_mul_left_cosets_iff_mem_normalizer _ _ _ β€Ή_β€Ί _).symm) (by intros unfold_projs rw [leftRel_apply (Ξ± := normalizer H), leftRel_apply] rfl) #align sylow.fixed_points_mul_left_cosets_equiv_quotient Sylow.fixedPointsMulLeftCosetsEquivQuotient theorem card_quotient_normalizer_modEq_card_quotient [Fintype G] {p : β„•} {n : β„•} [hp : Fact p.Prime] {H : Subgroup G} (hH : Fintype.card H = p ^ n) : Fintype.card (normalizer H β§Έ Subgroup.comap ((normalizer H).subtype : normalizer H β†’* G) H) ≑ card (G β§Έ H) [MOD p] := by rw [← Fintype.card_congr (fixedPointsMulLeftCosetsEquivQuotient H)] exact ((IsPGroup.of_card hH).card_modEq_card_fixedPoints _).symm #align sylow.card_quotient_normalizer_modeq_card_quotient Sylow.card_quotient_normalizer_modEq_card_quotient theorem card_normalizer_modEq_card [Fintype G] {p : β„•} {n : β„•} [hp : Fact p.Prime] {H : Subgroup G} (hH : Fintype.card H = p ^ n) : card (normalizer H) ≑ card G [MOD p ^ (n + 1)] := by have : H.subgroupOf (normalizer H) ≃ H := (subgroupOfEquivOfLe le_normalizer).toEquiv simp only [← Nat.card_eq_fintype_card] at hH ⊒ rw [card_eq_card_quotient_mul_card_subgroup H, card_eq_card_quotient_mul_card_subgroup (H.subgroupOf (normalizer H)), Nat.card_congr this, hH, pow_succ'] simp only [Nat.card_eq_fintype_card] at hH ⊒ exact (card_quotient_normalizer_modEq_card_quotient hH).mul_right' _ #align sylow.card_normalizer_modeq_card Sylow.card_normalizer_modEq_card theorem prime_dvd_card_quotient_normalizer [Fintype G] {p : β„•} {n : β„•} [hp : Fact p.Prime] (hdvd : p ^ (n + 1) ∣ card G) {H : Subgroup G} (hH : Fintype.card H = p ^ n) : p ∣ card (normalizer H β§Έ Subgroup.comap ((normalizer H).subtype : normalizer H β†’* G) H) := let ⟨s, hs⟩ := exists_eq_mul_left_of_dvd hdvd have hcard : card (G β§Έ H) = s * p := (mul_left_inj' (show card H β‰  0 from Fintype.card_ne_zero)).1 (by simp only [← Nat.card_eq_fintype_card] at hs hH ⊒ rw [← card_eq_card_quotient_mul_card_subgroup H, hH, hs, pow_succ', mul_assoc, mul_comm p]) have hm : s * p % p = card (normalizer H β§Έ Subgroup.comap ((normalizer H).subtype : normalizer H β†’* G) H) % p := hcard β–Έ (card_quotient_normalizer_modEq_card_quotient hH).symm Nat.dvd_of_mod_eq_zero (by rwa [Nat.mod_eq_zero_of_dvd (dvd_mul_left _ _), eq_comm] at hm) #align sylow.prime_dvd_card_quotient_normalizer Sylow.prime_dvd_card_quotient_normalizer theorem prime_pow_dvd_card_normalizer [Fintype G] {p : β„•} {n : β„•} [_hp : Fact p.Prime] (hdvd : p ^ (n + 1) ∣ card G) {H : Subgroup G} (hH : Fintype.card H = p ^ n) : p ^ (n + 1) ∣ card (normalizer H) := Nat.modEq_zero_iff_dvd.1 ((card_normalizer_modEq_card hH).trans hdvd.modEq_zero_nat) #align sylow.prime_pow_dvd_card_normalizer Sylow.prime_pow_dvd_card_normalizer theorem exists_subgroup_card_pow_succ [Fintype G] {p : β„•} {n : β„•} [hp : Fact p.Prime] (hdvd : p ^ (n + 1) ∣ card G) {H : Subgroup G} (hH : Fintype.card H = p ^ n) : βˆƒ K : Subgroup G, Fintype.card K = p ^ (n + 1) ∧ H ≀ K := let ⟨s, hs⟩ := exists_eq_mul_left_of_dvd hdvd have hcard : card (G β§Έ H) = s * p := (mul_left_inj' (show card H β‰  0 from Fintype.card_ne_zero)).1 (by simp only [← Nat.card_eq_fintype_card] at hs hH ⊒ rw [← card_eq_card_quotient_mul_card_subgroup H, hH, hs, pow_succ', mul_assoc, mul_comm p]) have hm : s * p % p = card (normalizer H β§Έ H.subgroupOf H.normalizer) % p := Fintype.card_congr (fixedPointsMulLeftCosetsEquivQuotient H) β–Έ hcard β–Έ (IsPGroup.of_card hH).card_modEq_card_fixedPoints _ have hm' : p ∣ card (normalizer H β§Έ H.subgroupOf H.normalizer) := Nat.dvd_of_mod_eq_zero (by rwa [Nat.mod_eq_zero_of_dvd (dvd_mul_left _ _), eq_comm] at hm) let ⟨x, hx⟩ := @exists_prime_orderOf_dvd_card _ (QuotientGroup.Quotient.group _) _ _ hp hm' have hequiv : H ≃ H.subgroupOf H.normalizer := (subgroupOfEquivOfLe le_normalizer).symm.toEquiv ⟨Subgroup.map (normalizer H).subtype (Subgroup.comap (mk' (H.subgroupOf H.normalizer)) (zpowers x)), by show Fintype.card (Subgroup.map H.normalizer.subtype (comap (mk' (H.subgroupOf H.normalizer)) (Subgroup.zpowers x))) = p ^ (n + 1) suffices Fintype.card (Subtype.val '' (Subgroup.comap (mk' (H.subgroupOf H.normalizer)) (zpowers x) : Set H.normalizer)) = p ^ (n + 1) by convert this using 2 rw [Set.card_image_of_injective (Subgroup.comap (mk' (H.subgroupOf H.normalizer)) (zpowers x) : Set H.normalizer) Subtype.val_injective, pow_succ, ← hH, Fintype.card_congr hequiv, ← hx, ← Fintype.card_zpowers, ← Fintype.card_prod] exact @Fintype.card_congr _ _ (_) (_) (preimageMkEquivSubgroupProdSet (H.subgroupOf H.normalizer) (zpowers x)), by intro y hy simp only [exists_prop, Subgroup.coeSubtype, mk'_apply, Subgroup.mem_map, Subgroup.mem_comap] refine ⟨⟨y, le_normalizer hy⟩, ⟨0, ?_⟩, rfl⟩ dsimp only rw [zpow_zero, eq_comm, QuotientGroup.eq_one_iff] simpa using hy⟩ #align sylow.exists_subgroup_card_pow_succ Sylow.exists_subgroup_card_pow_succ theorem exists_subgroup_card_pow_prime_le [Fintype G] (p : β„•) : βˆ€ {n m : β„•} [_hp : Fact p.Prime] (_hdvd : p ^ m ∣ card G) (H : Subgroup G) (_hH : card H = p ^ n) (_hnm : n ≀ m), βˆƒ K : Subgroup G, card K = p ^ m ∧ H ≀ K | n, m => fun {hdvd H hH hnm} => (lt_or_eq_of_le hnm).elim (fun hnm : n < m => have h0m : 0 < m := lt_of_le_of_lt n.zero_le hnm have _wf : m - 1 < m := Nat.sub_lt h0m zero_lt_one have hnm1 : n ≀ m - 1 := le_tsub_of_add_le_right hnm let ⟨K, hK⟩ := @exists_subgroup_card_pow_prime_le _ _ n (m - 1) _ (Nat.pow_dvd_of_le_of_pow_dvd tsub_le_self hdvd) H hH hnm1 have hdvd' : p ^ (m - 1 + 1) ∣ card G := by rwa [tsub_add_cancel_of_le h0m.nat_succ_le] let ⟨K', hK'⟩ := @exists_subgroup_card_pow_succ _ _ _ _ _ _ hdvd' K hK.1 ⟨K', by rw [hK'.1, tsub_add_cancel_of_le h0m.nat_succ_le], le_trans hK.2 hK'.2⟩) fun hnm : n = m => ⟨H, by simp [hH, hnm]⟩ #align sylow.exists_subgroup_card_pow_prime_le Sylow.exists_subgroup_card_pow_prime_le theorem exists_subgroup_card_pow_prime [Fintype G] (p : β„•) {n : β„•} [Fact p.Prime] (hdvd : p ^ n ∣ card G) : βˆƒ K : Subgroup G, Fintype.card K = p ^ n := let ⟨K, hK⟩ := exists_subgroup_card_pow_prime_le p hdvd βŠ₯ -- The @ is due to a Fintype βŠ₯ mismatch, but this will be fixed once we convert to Nat.card (by rw [← @Nat.card_eq_fintype_card, card_bot, pow_zero]) n.zero_le ⟨K, hK.1⟩ #align sylow.exists_subgroup_card_pow_prime Sylow.exists_subgroup_card_pow_prime lemma exists_subgroup_card_pow_prime_of_le_card {n p : β„•} (hp : p.Prime) (h : IsPGroup p G) (hn : p ^ n ≀ Nat.card G) : βˆƒ H : Subgroup G, Nat.card H = p ^ n := by have : Fact p.Prime := ⟨hp⟩ have : Finite G := Nat.finite_of_card_ne_zero <| by linarith [Nat.one_le_pow n p hp.pos] cases nonempty_fintype G obtain ⟨m, hm⟩ := h.exists_card_eq simp_rw [Nat.card_eq_fintype_card] at hm hn ⊒ refine exists_subgroup_card_pow_prime _ ?_ rw [hm] at hn ⊒ exact pow_dvd_pow _ <| (pow_le_pow_iff_right hp.one_lt).1 hn lemma exists_subgroup_le_card_pow_prime_of_le_card {n p : β„•} (hp : p.Prime) (h : IsPGroup p G) {H : Subgroup G} (hn : p ^ n ≀ Nat.card H) : βˆƒ H' ≀ H, Nat.card H' = p ^ n := by obtain ⟨H', H'card⟩ := exists_subgroup_card_pow_prime_of_le_card hp (h.to_subgroup H) hn refine ⟨H'.map H.subtype, map_subtype_le _, ?_⟩ rw [← H'card] let e : H' ≃* H'.map H.subtype := H'.equivMapOfInjective (Subgroup.subtype H) H.subtype_injective exact Nat.card_congr e.symm.toEquiv lemma exists_subgroup_le_card_le {k p : β„•} (hp : p.Prime) (h : IsPGroup p G) {H : Subgroup G} (hk : k ≀ Nat.card H) (hkβ‚€ : k β‰  0) : βˆƒ H' ≀ H, Nat.card H' ≀ k ∧ k < p * Nat.card H' := by obtain ⟨m, hmk, hkm⟩ : βˆƒ s, p ^ s ≀ k ∧ k < p ^ (s + 1) := exists_nat_pow_near (Nat.one_le_iff_ne_zero.2 hkβ‚€) hp.one_lt obtain ⟨H', H'H, H'card⟩ := exists_subgroup_le_card_pow_prime_of_le_card hp h (hmk.trans hk) refine ⟨H', H'H, ?_⟩ simpa only [pow_succ', H'card] using And.intro hmk hkm theorem pow_dvd_card_of_pow_dvd_card [Fintype G] {p n : β„•} [hp : Fact p.Prime] (P : Sylow p G) (hdvd : p ^ n ∣ card G) : p ^ n ∣ card P := (hp.1.coprime_pow_of_not_dvd (not_dvd_index_sylow P index_ne_zero_of_finite)).symm.dvd_of_dvd_mul_left ((index_mul_card P.1).symm β–Έ hdvd) #align sylow.pow_dvd_card_of_pow_dvd_card Sylow.pow_dvd_card_of_pow_dvd_card theorem dvd_card_of_dvd_card [Fintype G] {p : β„•} [Fact p.Prime] (P : Sylow p G) (hdvd : p ∣ card G) : p ∣ card P := by rw [← pow_one p] at hdvd have key := P.pow_dvd_card_of_pow_dvd_card hdvd rwa [pow_one] at key #align sylow.dvd_card_of_dvd_card Sylow.dvd_card_of_dvd_card theorem card_coprime_index [Fintype G] {p : β„•} [hp : Fact p.Prime] (P : Sylow p G) : (card P).Coprime (index (P : Subgroup G)) := let ⟨_n, hn⟩ := IsPGroup.iff_card.mp P.2 hn.symm β–Έ (hp.1.coprime_pow_of_not_dvd (not_dvd_index_sylow P index_ne_zero_of_finite)).symm #align sylow.card_coprime_index Sylow.card_coprime_index theorem ne_bot_of_dvd_card [Fintype G] {p : β„•} [hp : Fact p.Prime] (P : Sylow p G) (hdvd : p ∣ card G) : (P : Subgroup G) β‰  βŠ₯ := by refine fun h => hp.out.not_dvd_one ?_ have key : p ∣ card (P : Subgroup G) := P.dvd_card_of_dvd_card hdvd -- The @ is due to a Fintype βŠ₯ mismatch, but this will be fixed once we convert to Nat.card rwa [h, ← @Nat.card_eq_fintype_card, card_bot] at key #align sylow.ne_bot_of_dvd_card Sylow.ne_bot_of_dvd_card theorem card_eq_multiplicity [Fintype G] {p : β„•} [hp : Fact p.Prime] (P : Sylow p G) : card P = p ^ Nat.factorization (card G) p := by obtain ⟨n, heq : card P = _⟩ := IsPGroup.iff_card.mp P.isPGroup' refine Nat.dvd_antisymm ?_ (P.pow_dvd_card_of_pow_dvd_card (Nat.ord_proj_dvd _ p)) rw [heq, ← hp.out.pow_dvd_iff_dvd_ord_proj (show card G β‰  0 from card_ne_zero), ← heq] simp only [← Nat.card_eq_fintype_card] exact P.1.card_subgroup_dvd_card #align sylow.card_eq_multiplicity Sylow.card_eq_multiplicity def ofCard [Fintype G] {p : β„•} [Fact p.Prime] (H : Subgroup G) [Fintype H] (card_eq : card H = p ^ (card G).factorization p) : Sylow p G where toSubgroup := H isPGroup' := IsPGroup.of_card card_eq is_maximal' := by obtain ⟨P, hHP⟩ := (IsPGroup.of_card card_eq).exists_le_sylow exact SetLike.ext' (Set.eq_of_subset_of_card_le hHP (P.card_eq_multiplicity.trans card_eq.symm).le).symm β–Έ P.3 #align sylow.of_card Sylow.ofCard @[simp, norm_cast] theorem coe_ofCard [Fintype G] {p : β„•} [Fact p.Prime] (H : Subgroup G) [Fintype H] (card_eq : card H = p ^ (card G).factorization p) : ↑(ofCard H card_eq) = H := rfl #align sylow.coe_of_card Sylow.coe_ofCard noncomputable def unique_of_normal {p : β„•} [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G) (h : (P : Subgroup G).Normal) : Unique (Sylow p G) := by refine { uniq := fun Q ↦ ?_ } obtain ⟨x, h1⟩ := exists_smul_eq G P Q obtain ⟨x, h2⟩ := exists_smul_eq G P default rw [Sylow.smul_eq_of_normal] at h1 h2 rw [← h1, ← h2] #align sylow.subsingleton_of_normal Sylow.unique_of_normal section Pointwise open Pointwise
Mathlib/GroupTheory/Sylow.lean
763
770
theorem characteristic_of_normal {p : β„•} [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G) (h : (P : Subgroup G).Normal) : (P : Subgroup G).Characteristic := by
haveI := Sylow.unique_of_normal P h rw [characteristic_iff_map_eq] intro Ξ¦ show (Ξ¦ β€’ P).toSubgroup = P.toSubgroup congr simp [eq_iff_true_of_subsingleton]
import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Data.Set.Finite #align_import order.filter.basic from "leanprover-community/mathlib"@"d4f691b9e5f94cfc64639973f3544c95f8d5d494" set_option autoImplicit true open Function Set Order open scoped Classical universe u v w x y structure Filter (Ξ± : Type*) where sets : Set (Set Ξ±) univ_sets : Set.univ ∈ sets sets_of_superset {x y} : x ∈ sets β†’ x βŠ† y β†’ y ∈ sets inter_sets {x y} : x ∈ sets β†’ y ∈ sets β†’ x ∩ y ∈ sets #align filter Filter instance {Ξ± : Type*} : Membership (Set Ξ±) (Filter Ξ±) := ⟨fun U F => U ∈ F.sets⟩ namespace Filter variable {Ξ± : Type u} {Ξ² : Type v} {Ξ³ : Type w} {Ξ΄ : Type*} {ΞΉ : Sort x} open Filter section Lattice variable {f g : Filter Ξ±} {s t : Set Ξ±} instance : PartialOrder (Filter Ξ±) where le f g := βˆ€ ⦃U : Set α⦄, U ∈ g β†’ U ∈ f le_antisymm a b h₁ hβ‚‚ := filter_eq <| Subset.antisymm hβ‚‚ h₁ le_refl a := Subset.rfl le_trans a b c h₁ hβ‚‚ := Subset.trans hβ‚‚ h₁ theorem le_def : f ≀ g ↔ βˆ€ x ∈ g, x ∈ f := Iff.rfl #align filter.le_def Filter.le_def protected theorem not_le : Β¬f ≀ g ↔ βˆƒ s ∈ g, s βˆ‰ f := by simp_rw [le_def, not_forall, exists_prop] #align filter.not_le Filter.not_le inductive GenerateSets (g : Set (Set Ξ±)) : Set Ξ± β†’ Prop | basic {s : Set Ξ±} : s ∈ g β†’ GenerateSets g s | univ : GenerateSets g univ | superset {s t : Set Ξ±} : GenerateSets g s β†’ s βŠ† t β†’ GenerateSets g t | inter {s t : Set Ξ±} : GenerateSets g s β†’ GenerateSets g t β†’ GenerateSets g (s ∩ t) #align filter.generate_sets Filter.GenerateSets def generate (g : Set (Set Ξ±)) : Filter Ξ± where sets := {s | GenerateSets g s} univ_sets := GenerateSets.univ sets_of_superset := GenerateSets.superset inter_sets := GenerateSets.inter #align filter.generate Filter.generate lemma mem_generate_of_mem {s : Set <| Set Ξ±} {U : Set Ξ±} (h : U ∈ s) : U ∈ generate s := GenerateSets.basic h theorem le_generate_iff {s : Set (Set Ξ±)} {f : Filter Ξ±} : f ≀ generate s ↔ s βŠ† f.sets := Iff.intro (fun h _ hu => h <| GenerateSets.basic <| hu) fun h _ hu => hu.recOn (fun h' => h h') univ_mem (fun _ hxy hx => mem_of_superset hx hxy) fun _ _ hx hy => inter_mem hx hy #align filter.sets_iff_generate Filter.le_generate_iff theorem mem_generate_iff {s : Set <| Set Ξ±} {U : Set Ξ±} : U ∈ generate s ↔ βˆƒ t βŠ† s, Set.Finite t ∧ β‹‚β‚€ t βŠ† U := by constructor <;> intro h Β· induction h with | @basic V V_in => exact ⟨{V}, singleton_subset_iff.2 V_in, finite_singleton _, (sInter_singleton _).subset⟩ | univ => exact βŸ¨βˆ…, empty_subset _, finite_empty, subset_univ _⟩ | superset _ hVW hV => rcases hV with ⟨t, hts, ht, htV⟩ exact ⟨t, hts, ht, htV.trans hVW⟩ | inter _ _ hV hW => rcases hV, hW with ⟨⟨t, hts, ht, htV⟩, u, hus, hu, huW⟩ exact ⟨t βˆͺ u, union_subset hts hus, ht.union hu, (sInter_union _ _).subset.trans <| inter_subset_inter htV huW⟩ Β· rcases h with ⟨t, hts, tfin, h⟩ exact mem_of_superset ((sInter_mem tfin).2 fun V hV => GenerateSets.basic <| hts hV) h #align filter.mem_generate_iff Filter.mem_generate_iff @[simp] lemma generate_singleton (s : Set Ξ±) : generate {s} = π“Ÿ s := le_antisymm (fun _t ht ↦ mem_of_superset (mem_generate_of_mem <| mem_singleton _) ht) <| le_generate_iff.2 <| singleton_subset_iff.2 Subset.rfl protected def mkOfClosure (s : Set (Set Ξ±)) (hs : (generate s).sets = s) : Filter Ξ± where sets := s univ_sets := hs β–Έ univ_mem sets_of_superset := hs β–Έ mem_of_superset inter_sets := hs β–Έ inter_mem #align filter.mk_of_closure Filter.mkOfClosure theorem mkOfClosure_sets {s : Set (Set Ξ±)} {hs : (generate s).sets = s} : Filter.mkOfClosure s hs = generate s := Filter.ext fun u => show u ∈ (Filter.mkOfClosure s hs).sets ↔ u ∈ (generate s).sets from hs.symm β–Έ Iff.rfl #align filter.mk_of_closure_sets Filter.mkOfClosure_sets def giGenerate (Ξ± : Type*) : @GaloisInsertion (Set (Set Ξ±)) (Filter Ξ±)α΅’α΅ˆ _ _ Filter.generate Filter.sets where gc _ _ := le_generate_iff le_l_u _ _ h := GenerateSets.basic h choice s hs := Filter.mkOfClosure s (le_antisymm hs <| le_generate_iff.1 <| le_rfl) choice_eq _ _ := mkOfClosure_sets #align filter.gi_generate Filter.giGenerate instance : Inf (Filter Ξ±) := ⟨fun f g : Filter Ξ± => { sets := { s | βˆƒ a ∈ f, βˆƒ b ∈ g, s = a ∩ b } univ_sets := ⟨_, univ_mem, _, univ_mem, by simp⟩ sets_of_superset := by rintro x y ⟨a, ha, b, hb, rfl⟩ xy refine ⟨a βˆͺ y, mem_of_superset ha subset_union_left, b βˆͺ y, mem_of_superset hb subset_union_left, ?_⟩ rw [← inter_union_distrib_right, union_eq_self_of_subset_left xy] inter_sets := by rintro x y ⟨a, ha, b, hb, rfl⟩ ⟨c, hc, d, hd, rfl⟩ refine ⟨a ∩ c, inter_mem ha hc, b ∩ d, inter_mem hb hd, ?_⟩ ac_rfl }⟩ theorem mem_inf_iff {f g : Filter Ξ±} {s : Set Ξ±} : s ∈ f βŠ“ g ↔ βˆƒ t₁ ∈ f, βˆƒ tβ‚‚ ∈ g, s = t₁ ∩ tβ‚‚ := Iff.rfl #align filter.mem_inf_iff Filter.mem_inf_iff theorem mem_inf_of_left {f g : Filter Ξ±} {s : Set Ξ±} (h : s ∈ f) : s ∈ f βŠ“ g := ⟨s, h, univ, univ_mem, (inter_univ s).symm⟩ #align filter.mem_inf_of_left Filter.mem_inf_of_left theorem mem_inf_of_right {f g : Filter Ξ±} {s : Set Ξ±} (h : s ∈ g) : s ∈ f βŠ“ g := ⟨univ, univ_mem, s, h, (univ_inter s).symm⟩ #align filter.mem_inf_of_right Filter.mem_inf_of_right theorem inter_mem_inf {Ξ± : Type u} {f g : Filter Ξ±} {s t : Set Ξ±} (hs : s ∈ f) (ht : t ∈ g) : s ∩ t ∈ f βŠ“ g := ⟨s, hs, t, ht, rfl⟩ #align filter.inter_mem_inf Filter.inter_mem_inf theorem mem_inf_of_inter {f g : Filter Ξ±} {s t u : Set Ξ±} (hs : s ∈ f) (ht : t ∈ g) (h : s ∩ t βŠ† u) : u ∈ f βŠ“ g := mem_of_superset (inter_mem_inf hs ht) h #align filter.mem_inf_of_inter Filter.mem_inf_of_inter theorem mem_inf_iff_superset {f g : Filter Ξ±} {s : Set Ξ±} : s ∈ f βŠ“ g ↔ βˆƒ t₁ ∈ f, βˆƒ tβ‚‚ ∈ g, t₁ ∩ tβ‚‚ βŠ† s := ⟨fun ⟨t₁, h₁, tβ‚‚, hβ‚‚, Eq⟩ => ⟨t₁, h₁, tβ‚‚, hβ‚‚, Eq β–Έ Subset.rfl⟩, fun ⟨_, h₁, _, hβ‚‚, sub⟩ => mem_inf_of_inter h₁ hβ‚‚ sub⟩ #align filter.mem_inf_iff_superset Filter.mem_inf_iff_superset instance : Top (Filter Ξ±) := ⟨{ sets := { s | βˆ€ x, x ∈ s } univ_sets := fun x => mem_univ x sets_of_superset := fun hx hxy a => hxy (hx a) inter_sets := fun hx hy _ => mem_inter (hx _) (hy _) }⟩ theorem mem_top_iff_forall {s : Set Ξ±} : s ∈ (⊀ : Filter Ξ±) ↔ βˆ€ x, x ∈ s := Iff.rfl #align filter.mem_top_iff_forall Filter.mem_top_iff_forall @[simp] theorem mem_top {s : Set Ξ±} : s ∈ (⊀ : Filter Ξ±) ↔ s = univ := by rw [mem_top_iff_forall, eq_univ_iff_forall] #align filter.mem_top Filter.mem_top @[mono, gcongr] theorem join_mono {f₁ fβ‚‚ : Filter (Filter Ξ±)} (h : f₁ ≀ fβ‚‚) : join f₁ ≀ join fβ‚‚ := fun _ hs => h hs #align filter.join_mono Filter.join_mono protected def Eventually (p : Ξ± β†’ Prop) (f : Filter Ξ±) : Prop := { x | p x } ∈ f #align filter.eventually Filter.Eventually @[inherit_doc Filter.Eventually] notation3 "βˆ€αΆ  "(...)" in "f", "r:(scoped p => Filter.Eventually p f) => r theorem eventually_iff {f : Filter Ξ±} {P : Ξ± β†’ Prop} : (βˆ€αΆ  x in f, P x) ↔ { x | P x } ∈ f := Iff.rfl #align filter.eventually_iff Filter.eventually_iff @[simp] theorem eventually_mem_set {s : Set Ξ±} {l : Filter Ξ±} : (βˆ€αΆ  x in l, x ∈ s) ↔ s ∈ l := Iff.rfl #align filter.eventually_mem_set Filter.eventually_mem_set protected theorem ext' {f₁ fβ‚‚ : Filter Ξ±} (h : βˆ€ p : Ξ± β†’ Prop, (βˆ€αΆ  x in f₁, p x) ↔ βˆ€αΆ  x in fβ‚‚, p x) : f₁ = fβ‚‚ := Filter.ext h #align filter.ext' Filter.ext' theorem Eventually.filter_mono {f₁ fβ‚‚ : Filter Ξ±} (h : f₁ ≀ fβ‚‚) {p : Ξ± β†’ Prop} (hp : βˆ€αΆ  x in fβ‚‚, p x) : βˆ€αΆ  x in f₁, p x := h hp #align filter.eventually.filter_mono Filter.Eventually.filter_mono theorem eventually_of_mem {f : Filter Ξ±} {P : Ξ± β†’ Prop} {U : Set Ξ±} (hU : U ∈ f) (h : βˆ€ x ∈ U, P x) : βˆ€αΆ  x in f, P x := mem_of_superset hU h #align filter.eventually_of_mem Filter.eventually_of_mem protected theorem Eventually.and {p q : Ξ± β†’ Prop} {f : Filter Ξ±} : f.Eventually p β†’ f.Eventually q β†’ βˆ€αΆ  x in f, p x ∧ q x := inter_mem #align filter.eventually.and Filter.Eventually.and @[simp] theorem eventually_true (f : Filter Ξ±) : βˆ€αΆ  _ in f, True := univ_mem #align filter.eventually_true Filter.eventually_true theorem eventually_of_forall {p : Ξ± β†’ Prop} {f : Filter Ξ±} (hp : βˆ€ x, p x) : βˆ€αΆ  x in f, p x := univ_mem' hp #align filter.eventually_of_forall Filter.eventually_of_forall @[simp] theorem eventually_false_iff_eq_bot {f : Filter Ξ±} : (βˆ€αΆ  _ in f, False) ↔ f = βŠ₯ := empty_mem_iff_bot #align filter.eventually_false_iff_eq_bot Filter.eventually_false_iff_eq_bot @[simp] theorem eventually_const {f : Filter Ξ±} [t : NeBot f] {p : Prop} : (βˆ€αΆ  _ in f, p) ↔ p := by by_cases h : p <;> simp [h, t.ne] #align filter.eventually_const Filter.eventually_const theorem eventually_iff_exists_mem {p : Ξ± β†’ Prop} {f : Filter Ξ±} : (βˆ€αΆ  x in f, p x) ↔ βˆƒ v ∈ f, βˆ€ y ∈ v, p y := exists_mem_subset_iff.symm #align filter.eventually_iff_exists_mem Filter.eventually_iff_exists_mem theorem Eventually.exists_mem {p : Ξ± β†’ Prop} {f : Filter Ξ±} (hp : βˆ€αΆ  x in f, p x) : βˆƒ v ∈ f, βˆ€ y ∈ v, p y := eventually_iff_exists_mem.1 hp #align filter.eventually.exists_mem Filter.Eventually.exists_mem theorem Eventually.mp {p q : Ξ± β†’ Prop} {f : Filter Ξ±} (hp : βˆ€αΆ  x in f, p x) (hq : βˆ€αΆ  x in f, p x β†’ q x) : βˆ€αΆ  x in f, q x := mp_mem hp hq #align filter.eventually.mp Filter.Eventually.mp theorem Eventually.mono {p q : Ξ± β†’ Prop} {f : Filter Ξ±} (hp : βˆ€αΆ  x in f, p x) (hq : βˆ€ x, p x β†’ q x) : βˆ€αΆ  x in f, q x := hp.mp (eventually_of_forall hq) #align filter.eventually.mono Filter.Eventually.mono theorem forall_eventually_of_eventually_forall {f : Filter Ξ±} {p : Ξ± β†’ Ξ² β†’ Prop} (h : βˆ€αΆ  x in f, βˆ€ y, p x y) : βˆ€ y, βˆ€αΆ  x in f, p x y := fun y => h.mono fun _ h => h y #align filter.forall_eventually_of_eventually_forall Filter.forall_eventually_of_eventually_forall @[simp] theorem eventually_and {p q : Ξ± β†’ Prop} {f : Filter Ξ±} : (βˆ€αΆ  x in f, p x ∧ q x) ↔ (βˆ€αΆ  x in f, p x) ∧ βˆ€αΆ  x in f, q x := inter_mem_iff #align filter.eventually_and Filter.eventually_and theorem Eventually.congr {f : Filter Ξ±} {p q : Ξ± β†’ Prop} (h' : βˆ€αΆ  x in f, p x) (h : βˆ€αΆ  x in f, p x ↔ q x) : βˆ€αΆ  x in f, q x := h'.mp (h.mono fun _ hx => hx.mp) #align filter.eventually.congr Filter.Eventually.congr theorem eventually_congr {f : Filter Ξ±} {p q : Ξ± β†’ Prop} (h : βˆ€αΆ  x in f, p x ↔ q x) : (βˆ€αΆ  x in f, p x) ↔ βˆ€αΆ  x in f, q x := ⟨fun hp => hp.congr h, fun hq => hq.congr <| by simpa only [Iff.comm] using h⟩ #align filter.eventually_congr Filter.eventually_congr @[simp] theorem eventually_all {ΞΉ : Sort*} [Finite ΞΉ] {l} {p : ΞΉ β†’ Ξ± β†’ Prop} : (βˆ€αΆ  x in l, βˆ€ i, p i x) ↔ βˆ€ i, βˆ€αΆ  x in l, p i x := by simpa only [Filter.Eventually, setOf_forall] using iInter_mem #align filter.eventually_all Filter.eventually_all @[simp] theorem eventually_all_finite {ΞΉ} {I : Set ΞΉ} (hI : I.Finite) {l} {p : ΞΉ β†’ Ξ± β†’ Prop} : (βˆ€αΆ  x in l, βˆ€ i ∈ I, p i x) ↔ βˆ€ i ∈ I, βˆ€αΆ  x in l, p i x := by simpa only [Filter.Eventually, setOf_forall] using biInter_mem hI #align filter.eventually_all_finite Filter.eventually_all_finite alias _root_.Set.Finite.eventually_all := eventually_all_finite #align set.finite.eventually_all Set.Finite.eventually_all -- attribute [protected] Set.Finite.eventually_all @[simp] theorem eventually_all_finset {ΞΉ} (I : Finset ΞΉ) {l} {p : ΞΉ β†’ Ξ± β†’ Prop} : (βˆ€αΆ  x in l, βˆ€ i ∈ I, p i x) ↔ βˆ€ i ∈ I, βˆ€αΆ  x in l, p i x := I.finite_toSet.eventually_all #align filter.eventually_all_finset Filter.eventually_all_finset alias _root_.Finset.eventually_all := eventually_all_finset #align finset.eventually_all Finset.eventually_all -- attribute [protected] Finset.eventually_all @[simp] theorem eventually_or_distrib_left {f : Filter Ξ±} {p : Prop} {q : Ξ± β†’ Prop} : (βˆ€αΆ  x in f, p ∨ q x) ↔ p ∨ βˆ€αΆ  x in f, q x := by_cases (fun h : p => by simp [h]) fun h => by simp [h] #align filter.eventually_or_distrib_left Filter.eventually_or_distrib_left @[simp] theorem eventually_or_distrib_right {f : Filter Ξ±} {p : Ξ± β†’ Prop} {q : Prop} : (βˆ€αΆ  x in f, p x ∨ q) ↔ (βˆ€αΆ  x in f, p x) ∨ q := by simp only [@or_comm _ q, eventually_or_distrib_left] #align filter.eventually_or_distrib_right Filter.eventually_or_distrib_right theorem eventually_imp_distrib_left {f : Filter Ξ±} {p : Prop} {q : Ξ± β†’ Prop} : (βˆ€αΆ  x in f, p β†’ q x) ↔ p β†’ βˆ€αΆ  x in f, q x := eventually_all #align filter.eventually_imp_distrib_left Filter.eventually_imp_distrib_left @[simp] theorem eventually_bot {p : Ξ± β†’ Prop} : βˆ€αΆ  x in βŠ₯, p x := ⟨⟩ #align filter.eventually_bot Filter.eventually_bot @[simp] theorem eventually_top {p : Ξ± β†’ Prop} : (βˆ€αΆ  x in ⊀, p x) ↔ βˆ€ x, p x := Iff.rfl #align filter.eventually_top Filter.eventually_top @[simp] theorem eventually_sup {p : Ξ± β†’ Prop} {f g : Filter Ξ±} : (βˆ€αΆ  x in f βŠ” g, p x) ↔ (βˆ€αΆ  x in f, p x) ∧ βˆ€αΆ  x in g, p x := Iff.rfl #align filter.eventually_sup Filter.eventually_sup @[simp] theorem eventually_sSup {p : Ξ± β†’ Prop} {fs : Set (Filter Ξ±)} : (βˆ€αΆ  x in sSup fs, p x) ↔ βˆ€ f ∈ fs, βˆ€αΆ  x in f, p x := Iff.rfl #align filter.eventually_Sup Filter.eventually_sSup @[simp] theorem eventually_iSup {p : Ξ± β†’ Prop} {fs : ΞΉ β†’ Filter Ξ±} : (βˆ€αΆ  x in ⨆ b, fs b, p x) ↔ βˆ€ b, βˆ€αΆ  x in fs b, p x := mem_iSup #align filter.eventually_supr Filter.eventually_iSup @[simp] theorem eventually_principal {a : Set Ξ±} {p : Ξ± β†’ Prop} : (βˆ€αΆ  x in π“Ÿ a, p x) ↔ βˆ€ x ∈ a, p x := Iff.rfl #align filter.eventually_principal Filter.eventually_principal theorem Eventually.forall_mem {Ξ± : Type*} {f : Filter Ξ±} {s : Set Ξ±} {P : Ξ± β†’ Prop} (hP : βˆ€αΆ  x in f, P x) (hf : π“Ÿ s ≀ f) : βˆ€ x ∈ s, P x := Filter.eventually_principal.mp (hP.filter_mono hf) theorem eventually_inf {f g : Filter Ξ±} {p : Ξ± β†’ Prop} : (βˆ€αΆ  x in f βŠ“ g, p x) ↔ βˆƒ s ∈ f, βˆƒ t ∈ g, βˆ€ x ∈ s ∩ t, p x := mem_inf_iff_superset #align filter.eventually_inf Filter.eventually_inf theorem eventually_inf_principal {f : Filter Ξ±} {p : Ξ± β†’ Prop} {s : Set Ξ±} : (βˆ€αΆ  x in f βŠ“ π“Ÿ s, p x) ↔ βˆ€αΆ  x in f, x ∈ s β†’ p x := mem_inf_principal #align filter.eventually_inf_principal Filter.eventually_inf_principal protected def Frequently (p : Ξ± β†’ Prop) (f : Filter Ξ±) : Prop := Β¬βˆ€αΆ  x in f, Β¬p x #align filter.frequently Filter.Frequently @[inherit_doc Filter.Frequently] notation3 "βˆƒαΆ  "(...)" in "f", "r:(scoped p => Filter.Frequently p f) => r theorem Eventually.frequently {f : Filter Ξ±} [NeBot f] {p : Ξ± β†’ Prop} (h : βˆ€αΆ  x in f, p x) : βˆƒαΆ  x in f, p x := compl_not_mem h #align filter.eventually.frequently Filter.Eventually.frequently theorem frequently_of_forall {f : Filter Ξ±} [NeBot f] {p : Ξ± β†’ Prop} (h : βˆ€ x, p x) : βˆƒαΆ  x in f, p x := Eventually.frequently (eventually_of_forall h) #align filter.frequently_of_forall Filter.frequently_of_forall theorem Frequently.mp {p q : Ξ± β†’ Prop} {f : Filter Ξ±} (h : βˆƒαΆ  x in f, p x) (hpq : βˆ€αΆ  x in f, p x β†’ q x) : βˆƒαΆ  x in f, q x := mt (fun hq => hq.mp <| hpq.mono fun _ => mt) h #align filter.frequently.mp Filter.Frequently.mp theorem Frequently.filter_mono {p : Ξ± β†’ Prop} {f g : Filter Ξ±} (h : βˆƒαΆ  x in f, p x) (hle : f ≀ g) : βˆƒαΆ  x in g, p x := mt (fun h' => h'.filter_mono hle) h #align filter.frequently.filter_mono Filter.Frequently.filter_mono theorem Frequently.mono {p q : Ξ± β†’ Prop} {f : Filter Ξ±} (h : βˆƒαΆ  x in f, p x) (hpq : βˆ€ x, p x β†’ q x) : βˆƒαΆ  x in f, q x := h.mp (eventually_of_forall hpq) #align filter.frequently.mono Filter.Frequently.mono theorem Frequently.and_eventually {p q : Ξ± β†’ Prop} {f : Filter Ξ±} (hp : βˆƒαΆ  x in f, p x) (hq : βˆ€αΆ  x in f, q x) : βˆƒαΆ  x in f, p x ∧ q x := by refine mt (fun h => hq.mp <| h.mono ?_) hp exact fun x hpq hq hp => hpq ⟨hp, hq⟩ #align filter.frequently.and_eventually Filter.Frequently.and_eventually
Mathlib/Order/Filter/Basic.lean
1,319
1,321
theorem Eventually.and_frequently {p q : Ξ± β†’ Prop} {f : Filter Ξ±} (hp : βˆ€αΆ  x in f, p x) (hq : βˆƒαΆ  x in f, q x) : βˆƒαΆ  x in f, p x ∧ q x := by
simpa only [and_comm] using hq.and_eventually hp
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] 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] section #align euclidean_space.finite_dimensional WithLp.instModuleFinite variable [Fintype ΞΉ] #align euclidean_space.inner_product_space PiLp.innerProductSpace @[simp] theorem finrank_euclideanSpace : FiniteDimensional.finrank π•œ (EuclideanSpace π•œ ΞΉ) = Fintype.card ΞΉ := by simp [EuclideanSpace, PiLp, WithLp] #align finrank_euclidean_space finrank_euclideanSpace theorem finrank_euclideanSpace_fin {n : β„•} : FiniteDimensional.finrank π•œ (EuclideanSpace π•œ (Fin n)) = n := by simp #align finrank_euclidean_space_fin finrank_euclideanSpace_fin theorem EuclideanSpace.inner_eq_star_dotProduct (x y : EuclideanSpace π•œ ΞΉ) : βŸͺx, y⟫ = Matrix.dotProduct (star <| WithLp.equiv _ _ x) (WithLp.equiv _ _ y) := rfl #align euclidean_space.inner_eq_star_dot_product EuclideanSpace.inner_eq_star_dotProduct theorem EuclideanSpace.inner_piLp_equiv_symm (x y : ΞΉ β†’ π•œ) : βŸͺ(WithLp.equiv 2 _).symm x, (WithLp.equiv 2 _).symm y⟫ = Matrix.dotProduct (star x) y := rfl #align euclidean_space.inner_pi_Lp_equiv_symm EuclideanSpace.inner_piLp_equiv_symm def DirectSum.IsInternal.isometryL2OfOrthogonalFamily [DecidableEq ΞΉ] {V : ΞΉ β†’ Submodule π•œ E} (hV : DirectSum.IsInternal V) (hV' : OrthogonalFamily π•œ (fun i => V i) fun i => (V i).subtypeβ‚—α΅’) : E ≃ₗᡒ[π•œ] PiLp 2 fun i => V i := by let e₁ := DirectSum.linearEquivFunOnFintype π•œ ΞΉ fun i => V i let eβ‚‚ := LinearEquiv.ofBijective (DirectSum.coeLinearMap V) hV refine LinearEquiv.isometryOfInner (eβ‚‚.symm.trans e₁) ?_ suffices βˆ€ (v w : PiLp 2 fun i => V i), βŸͺv, w⟫ = βŸͺeβ‚‚ (e₁.symm v), eβ‚‚ (e₁.symm w)⟫ by intro vβ‚€ wβ‚€ convert this (e₁ (eβ‚‚.symm vβ‚€)) (e₁ (eβ‚‚.symm wβ‚€)) <;> simp only [LinearEquiv.symm_apply_apply, LinearEquiv.apply_symm_apply] intro v w trans βŸͺβˆ‘ i, (V i).subtypeβ‚—α΅’ (v i), βˆ‘ i, (V i).subtypeβ‚—α΅’ (w i)⟫ Β· simp only [sum_inner, hV'.inner_right_fintype, PiLp.inner_apply] Β· congr <;> simp #align direct_sum.is_internal.isometry_L2_of_orthogonal_family DirectSum.IsInternal.isometryL2OfOrthogonalFamily @[simp] theorem DirectSum.IsInternal.isometryL2OfOrthogonalFamily_symm_apply [DecidableEq ΞΉ] {V : ΞΉ β†’ Submodule π•œ E} (hV : DirectSum.IsInternal V) (hV' : OrthogonalFamily π•œ (fun i => V i) fun i => (V i).subtypeβ‚—α΅’) (w : PiLp 2 fun i => V i) : (hV.isometryL2OfOrthogonalFamily hV').symm w = βˆ‘ i, (w i : E) := by classical let e₁ := DirectSum.linearEquivFunOnFintype π•œ ΞΉ fun i => V i let eβ‚‚ := LinearEquiv.ofBijective (DirectSum.coeLinearMap V) hV suffices βˆ€ v : ⨁ i, V i, eβ‚‚ v = βˆ‘ i, e₁ v i by exact this (e₁.symm w) intro v -- Porting note: added `DFinsupp.lsum` simp [e₁, eβ‚‚, DirectSum.coeLinearMap, DirectSum.toModule, DFinsupp.lsum, DFinsupp.sumAddHom_apply] #align direct_sum.is_internal.isometry_L2_of_orthogonal_family_symm_apply DirectSum.IsInternal.isometryL2OfOrthogonalFamily_symm_apply end variable (ΞΉ π•œ) abbrev EuclideanSpace.equiv : EuclideanSpace π•œ ΞΉ ≃L[π•œ] ΞΉ β†’ π•œ := PiLp.continuousLinearEquiv 2 π•œ _ #align euclidean_space.equiv EuclideanSpace.equiv #noalign euclidean_space.equiv_to_linear_equiv_apply #noalign euclidean_space.equiv_apply #noalign euclidean_space.equiv_to_linear_equiv_symm_apply #noalign euclidean_space.equiv_symm_apply variable {ΞΉ π•œ} -- TODO : This should be generalized to `PiLp`. @[simps!] def EuclideanSpace.projβ‚— (i : ΞΉ) : EuclideanSpace π•œ ΞΉ β†’β‚—[π•œ] π•œ := (LinearMap.proj i).comp (WithLp.linearEquiv 2 π•œ (ΞΉ β†’ π•œ) : EuclideanSpace π•œ ΞΉ β†’β‚—[π•œ] ΞΉ β†’ π•œ) #align euclidean_space.projβ‚— EuclideanSpace.projβ‚— #align euclidean_space.projβ‚—_apply EuclideanSpace.projβ‚—_apply -- TODO : This should be generalized to `PiLp`. @[simps! apply coe] def EuclideanSpace.proj (i : ΞΉ) : EuclideanSpace π•œ ΞΉ β†’L[π•œ] π•œ := ⟨EuclideanSpace.projβ‚— i, continuous_apply i⟩ #align euclidean_space.proj EuclideanSpace.proj #align euclidean_space.proj_coe EuclideanSpace.proj_coe #align euclidean_space.proj_apply EuclideanSpace.proj_apply variable (ΞΉ π•œ E) variable [Fintype ΞΉ] structure OrthonormalBasis where ofRepr :: repr : E ≃ₗᡒ[π•œ] EuclideanSpace π•œ ΞΉ #align orthonormal_basis OrthonormalBasis #align orthonormal_basis.of_repr OrthonormalBasis.ofRepr #align orthonormal_basis.repr OrthonormalBasis.repr variable {ΞΉ π•œ E} instance OrthonormalBasis.instInhabited : Inhabited (OrthonormalBasis ΞΉ π•œ (EuclideanSpace π•œ ΞΉ)) := ⟨EuclideanSpace.basisFun ΞΉ π•œβŸ© #align orthonormal_basis.inhabited OrthonormalBasis.instInhabited open FiniteDimensional section ToMatrix variable [DecidableEq ΞΉ] section variable (a b : OrthonormalBasis ΞΉ π•œ E) theorem OrthonormalBasis.toMatrix_orthonormalBasis_mem_unitary : a.toBasis.toMatrix b ∈ Matrix.unitaryGroup ΞΉ π•œ := by rw [Matrix.mem_unitaryGroup_iff'] ext i j convert a.repr.inner_map_map (b i) (b j) rw [orthonormal_iff_ite.mp b.orthonormal i j] rfl #align orthonormal_basis.to_matrix_orthonormal_basis_mem_unitary OrthonormalBasis.toMatrix_orthonormalBasis_mem_unitary @[simp] theorem OrthonormalBasis.det_to_matrix_orthonormalBasis : β€–a.toBasis.det bβ€– = 1 := by have := (Matrix.det_of_mem_unitary (a.toMatrix_orthonormalBasis_mem_unitary b)).2 rw [star_def, RCLike.mul_conj] at this norm_cast at this rwa [pow_eq_one_iff_of_nonneg (norm_nonneg _) two_ne_zero] at this #align orthonormal_basis.det_to_matrix_orthonormal_basis OrthonormalBasis.det_to_matrix_orthonormalBasis end section FiniteDimensional variable {v : Set E} variable {A : ΞΉ β†’ Submodule π•œ E} noncomputable def DirectSum.IsInternal.collectedOrthonormalBasis (hV : OrthogonalFamily π•œ (fun i => A i) fun i => (A i).subtypeβ‚—α΅’) [DecidableEq ΞΉ] (hV_sum : DirectSum.IsInternal fun i => A i) {Ξ± : ΞΉ β†’ Type*} [βˆ€ i, Fintype (Ξ± i)] (v_family : βˆ€ i, OrthonormalBasis (Ξ± i) π•œ (A i)) : OrthonormalBasis (Ξ£i, Ξ± i) π•œ E := (hV_sum.collectedBasis fun i => (v_family i).toBasis).toOrthonormalBasis <| by simpa using hV.orthonormal_sigma_orthonormal (show βˆ€ i, Orthonormal π•œ (v_family i).toBasis by simp) #align direct_sum.is_internal.collected_orthonormal_basis DirectSum.IsInternal.collectedOrthonormalBasis
Mathlib/Analysis/InnerProductSpace/PiL2.lean
787
792
theorem DirectSum.IsInternal.collectedOrthonormalBasis_mem [DecidableEq ΞΉ] (h : DirectSum.IsInternal A) {Ξ± : ΞΉ β†’ Type*} [βˆ€ i, Fintype (Ξ± i)] (hV : OrthogonalFamily π•œ (fun i => A i) fun i => (A i).subtypeβ‚—α΅’) (v : βˆ€ i, OrthonormalBasis (Ξ± i) π•œ (A i)) (a : Ξ£i, Ξ± i) : h.collectedOrthonormalBasis hV v a ∈ A a.1 := by
simp [DirectSum.IsInternal.collectedOrthonormalBasis]
import Mathlib.Analysis.Convex.Gauge import Mathlib.Analysis.Convex.Normed open Metric Bornology Filter Set open scoped NNReal Topology Pointwise noncomputable section section Module variable {E : Type*} [AddCommGroup E] [Module ℝ E] def gaugeRescale (s t : Set E) (x : E) : E := (gauge s x / gauge t x) β€’ x theorem gaugeRescale_def (s t : Set E) (x : E) : gaugeRescale s t x = (gauge s x / gauge t x) β€’ x := rfl @[simp] theorem gaugeRescale_zero (s t : Set E) : gaugeRescale s t 0 = 0 := smul_zero _ theorem gaugeRescale_smul (s t : Set E) {c : ℝ} (hc : 0 ≀ c) (x : E) : gaugeRescale s t (c β€’ x) = c β€’ gaugeRescale s t x := by simp only [gaugeRescale, gauge_smul_of_nonneg hc, smul_smul, smul_eq_mul] rw [mul_div_mul_comm, mul_right_comm, div_self_mul_self] variable [TopologicalSpace E] [T1Space E]
Mathlib/Analysis/Convex/GaugeRescale.lean
48
52
theorem gaugeRescale_self_apply {s : Set E} (hsa : Absorbent ℝ s) (hsb : IsVonNBounded ℝ s) (x : E) : gaugeRescale s s x = x := by
rcases eq_or_ne x 0 with rfl | hx; Β· simp rw [gaugeRescale, div_self, one_smul] exact ((gauge_pos hsa hsb).2 hx).ne'
import Mathlib.CategoryTheory.Sites.Sieves #align_import category_theory.sites.sheaf_of_types from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe w v₁ vβ‚‚ u₁ uβ‚‚ namespace CategoryTheory open Opposite CategoryTheory Category Limits Sieve namespace Presieve variable {C : Type u₁} [Category.{v₁} C] variable {P Q U : Cα΅’α΅– β₯€ Type w} variable {X Y : C} {S : Sieve X} {R : Presieve X} def FamilyOfElements (P : Cα΅’α΅– β₯€ Type w) (R : Presieve X) := βˆ€ ⦃Y : C⦄ (f : Y ⟢ X), R f β†’ P.obj (op Y) #align category_theory.presieve.family_of_elements CategoryTheory.Presieve.FamilyOfElements instance : Inhabited (FamilyOfElements P (βŠ₯ : Presieve X)) := ⟨fun _ _ => False.elim⟩ def FamilyOfElements.restrict {R₁ Rβ‚‚ : Presieve X} (h : R₁ ≀ Rβ‚‚) : FamilyOfElements P Rβ‚‚ β†’ FamilyOfElements P R₁ := fun x _ f hf => x f (h _ hf) #align category_theory.presieve.family_of_elements.restrict CategoryTheory.Presieve.FamilyOfElements.restrict def FamilyOfElements.map (p : FamilyOfElements P R) (Ο† : P ⟢ Q) : FamilyOfElements Q R := fun _ f hf => Ο†.app _ (p f hf) @[simp] lemma FamilyOfElements.map_apply (p : FamilyOfElements P R) (Ο† : P ⟢ Q) {Y : C} (f : Y ⟢ X) (hf : R f) : p.map Ο† f hf = Ο†.app _ (p f hf) := rfl lemma FamilyOfElements.restrict_map (p : FamilyOfElements P R) (Ο† : P ⟢ Q) {R' : Presieve X} (h : R' ≀ R) : (p.restrict h).map Ο† = (p.map Ο†).restrict h := rfl def FamilyOfElements.Compatible (x : FamilyOfElements P R) : Prop := βˆ€ ⦃Y₁ Yβ‚‚ Z⦄ (g₁ : Z ⟢ Y₁) (gβ‚‚ : Z ⟢ Yβ‚‚) ⦃f₁ : Y₁ ⟢ X⦄ ⦃fβ‚‚ : Yβ‚‚ ⟢ X⦄ (h₁ : R f₁) (hβ‚‚ : R fβ‚‚), g₁ ≫ f₁ = gβ‚‚ ≫ fβ‚‚ β†’ P.map g₁.op (x f₁ h₁) = P.map gβ‚‚.op (x fβ‚‚ hβ‚‚) #align category_theory.presieve.family_of_elements.compatible CategoryTheory.Presieve.FamilyOfElements.Compatible def FamilyOfElements.PullbackCompatible (x : FamilyOfElements P R) [R.hasPullbacks] : Prop := βˆ€ ⦃Y₁ Y₂⦄ ⦃f₁ : Y₁ ⟢ X⦄ ⦃fβ‚‚ : Yβ‚‚ ⟢ X⦄ (h₁ : R f₁) (hβ‚‚ : R fβ‚‚), haveI := hasPullbacks.has_pullbacks h₁ hβ‚‚ P.map (pullback.fst : Limits.pullback f₁ fβ‚‚ ⟢ _).op (x f₁ h₁) = P.map pullback.snd.op (x fβ‚‚ hβ‚‚) #align category_theory.presieve.family_of_elements.pullback_compatible CategoryTheory.Presieve.FamilyOfElements.PullbackCompatible theorem pullbackCompatible_iff (x : FamilyOfElements P R) [R.hasPullbacks] : x.Compatible ↔ x.PullbackCompatible := by constructor Β· intro t Y₁ Yβ‚‚ f₁ fβ‚‚ hf₁ hfβ‚‚ apply t haveI := hasPullbacks.has_pullbacks hf₁ hfβ‚‚ apply pullback.condition Β· intro t Y₁ Yβ‚‚ Z g₁ gβ‚‚ f₁ fβ‚‚ hf₁ hfβ‚‚ comm haveI := hasPullbacks.has_pullbacks hf₁ hfβ‚‚ rw [← pullback.lift_fst _ _ comm, op_comp, FunctorToTypes.map_comp_apply, t hf₁ hfβ‚‚, ← FunctorToTypes.map_comp_apply, ← op_comp, pullback.lift_snd] #align category_theory.presieve.pullback_compatible_iff CategoryTheory.Presieve.pullbackCompatible_iff theorem FamilyOfElements.Compatible.restrict {R₁ Rβ‚‚ : Presieve X} (h : R₁ ≀ Rβ‚‚) {x : FamilyOfElements P Rβ‚‚} : x.Compatible β†’ (x.restrict h).Compatible := fun q _ _ _ g₁ gβ‚‚ _ _ h₁ hβ‚‚ comm => q g₁ gβ‚‚ (h _ h₁) (h _ hβ‚‚) comm #align category_theory.presieve.family_of_elements.compatible.restrict CategoryTheory.Presieve.FamilyOfElements.Compatible.restrict noncomputable def FamilyOfElements.sieveExtend (x : FamilyOfElements P R) : FamilyOfElements P (generate R : Presieve X) := fun _ _ hf => P.map hf.choose_spec.choose.op (x _ hf.choose_spec.choose_spec.choose_spec.1) #align category_theory.presieve.family_of_elements.sieve_extend CategoryTheory.Presieve.FamilyOfElements.sieveExtend theorem FamilyOfElements.Compatible.sieveExtend {x : FamilyOfElements P R} (hx : x.Compatible) : x.sieveExtend.Compatible := by intro _ _ _ _ _ _ _ h₁ hβ‚‚ comm iterate 2 erw [← FunctorToTypes.map_comp_apply]; rw [← op_comp] apply hx simp [comm, h₁.choose_spec.choose_spec.choose_spec.2, hβ‚‚.choose_spec.choose_spec.choose_spec.2] #align category_theory.presieve.family_of_elements.compatible.sieve_extend CategoryTheory.Presieve.FamilyOfElements.Compatible.sieveExtend
Mathlib/CategoryTheory/Sites/IsSheafFor.lean
195
202
theorem extend_agrees {x : FamilyOfElements P R} (t : x.Compatible) {f : Y ⟢ X} (hf : R f) : x.sieveExtend f (le_generate R Y hf) = x f hf := by
have h := (le_generate R Y hf).choose_spec unfold FamilyOfElements.sieveExtend rw [t h.choose (πŸ™ _) _ hf _] Β· simp Β· rw [id_comp] exact h.choose_spec.choose_spec.2
import Mathlib.Algebra.Group.Subgroup.Basic import Mathlib.Algebra.Ring.Subsemiring.Basic #align_import ring_theory.subring.basic from "leanprover-community/mathlib"@"b915e9392ecb2a861e1e766f0e1df6ac481188ca" universe u v w variable {R : Type u} {S : Type v} {T : Type w} [Ring R] namespace Subring instance : Bot (Subring R) := ⟨(Int.castRingHom R).range⟩ instance : Inhabited (Subring R) := ⟨βŠ₯⟩ theorem coe_bot : ((βŠ₯ : Subring R) : Set R) = Set.range ((↑) : β„€ β†’ R) := RingHom.coe_range (Int.castRingHom R) #align subring.coe_bot Subring.coe_bot theorem mem_bot {x : R} : x ∈ (βŠ₯ : Subring R) ↔ βˆƒ n : β„€, ↑n = x := RingHom.mem_range #align subring.mem_bot Subring.mem_bot instance : Inf (Subring R) := ⟨fun s t => { s.toSubmonoid βŠ“ t.toSubmonoid, s.toAddSubgroup βŠ“ t.toAddSubgroup with carrier := s ∩ t }⟩ @[simp] theorem coe_inf (p p' : Subring R) : ((p βŠ“ p' : Subring R) : Set R) = (p : Set R) ∩ p' := rfl #align subring.coe_inf Subring.coe_inf @[simp] theorem mem_inf {p p' : Subring R} {x : R} : x ∈ p βŠ“ p' ↔ x ∈ p ∧ x ∈ p' := Iff.rfl #align subring.mem_inf Subring.mem_inf instance : InfSet (Subring R) := ⟨fun s => Subring.mk' (β‹‚ t ∈ s, ↑t) (β¨… t ∈ s, t.toSubmonoid) (β¨… t ∈ s, Subring.toAddSubgroup t) (by simp) (by simp)⟩ @[simp, norm_cast] theorem coe_sInf (S : Set (Subring R)) : ((sInf S : Subring R) : Set R) = β‹‚ s ∈ S, ↑s := rfl #align subring.coe_Inf Subring.coe_sInf theorem mem_sInf {S : Set (Subring R)} {x : R} : x ∈ sInf S ↔ βˆ€ p ∈ S, x ∈ p := Set.mem_iInterβ‚‚ #align subring.mem_Inf Subring.mem_sInf @[simp, norm_cast] theorem coe_iInf {ΞΉ : Sort*} {S : ΞΉ β†’ Subring R} : (↑(β¨… i, S i) : Set R) = β‹‚ i, S i := by simp only [iInf, coe_sInf, Set.biInter_range] #align subring.coe_infi Subring.coe_iInf theorem mem_iInf {ΞΉ : Sort*} {S : ΞΉ β†’ Subring R} {x : R} : (x ∈ β¨… i, S i) ↔ βˆ€ i, x ∈ S i := by simp only [iInf, mem_sInf, Set.forall_mem_range] #align subring.mem_infi Subring.mem_iInf @[simp] theorem sInf_toSubmonoid (s : Set (Subring R)) : (sInf s).toSubmonoid = β¨… t ∈ s, t.toSubmonoid := mk'_toSubmonoid _ _ #align subring.Inf_to_submonoid Subring.sInf_toSubmonoid @[simp] theorem sInf_toAddSubgroup (s : Set (Subring R)) : (sInf s).toAddSubgroup = β¨… t ∈ s, Subring.toAddSubgroup t := mk'_toAddSubgroup _ _ #align subring.Inf_to_add_subgroup Subring.sInf_toAddSubgroup instance : CompleteLattice (Subring R) := { completeLatticeOfInf (Subring R) fun _ => IsGLB.of_image SetLike.coe_subset_coe isGLB_biInf with bot := βŠ₯ bot_le := fun s _x hx => let ⟨n, hn⟩ := mem_bot.1 hx hn β–Έ intCast_mem s n top := ⊀ le_top := fun _s _x _hx => trivial inf := (Β· βŠ“ Β·) inf_le_left := fun _s _t _x => And.left inf_le_right := fun _s _t _x => And.right le_inf := fun _s _t₁ _tβ‚‚ h₁ hβ‚‚ _x hx => ⟨h₁ hx, hβ‚‚ hx⟩ } theorem eq_top_iff' (A : Subring R) : A = ⊀ ↔ βˆ€ x : R, x ∈ A := eq_top_iff.trans ⟨fun h m => h <| mem_top m, fun h m _ => h m⟩ #align subring.eq_top_iff' Subring.eq_top_iff' section variable (R) def center : Subring R := { Subsemiring.center R with carrier := Set.center R neg_mem' := Set.neg_mem_center } #align subring.center Subring.center theorem coe_center : ↑(center R) = Set.center R := rfl #align subring.coe_center Subring.coe_center @[simp] theorem center_toSubsemiring : (center R).toSubsemiring = Subsemiring.center R := rfl #align subring.center_to_subsemiring Subring.center_toSubsemiring variable {R} theorem mem_center_iff {z : R} : z ∈ center R ↔ βˆ€ g, g * z = z * g := Subsemigroup.mem_center_iff #align subring.mem_center_iff Subring.mem_center_iff instance decidableMemCenter [DecidableEq R] [Fintype R] : DecidablePred (Β· ∈ center R) := fun _ => decidable_of_iff' _ mem_center_iff #align subring.decidable_mem_center Subring.decidableMemCenter @[simp] theorem center_eq_top (R) [CommRing R] : center R = ⊀ := SetLike.coe_injective (Set.center_eq_univ R) #align subring.center_eq_top Subring.center_eq_top instance : CommRing (center R) := { inferInstanceAs (CommSemiring (Subsemiring.center R)), (center R).toRing with } end def closure (s : Set R) : Subring R := sInf { S | s βŠ† S } #align subring.closure Subring.closure theorem mem_closure {x : R} {s : Set R} : x ∈ closure s ↔ βˆ€ S : Subring R, s βŠ† S β†’ x ∈ S := mem_sInf #align subring.mem_closure Subring.mem_closure @[simp, aesop safe 20 apply (rule_sets := [SetLike])] theorem subset_closure {s : Set R} : s βŠ† closure s := fun _ hx => mem_closure.2 fun _ hS => hS hx #align subring.subset_closure Subring.subset_closure theorem not_mem_of_not_mem_closure {s : Set R} {P : R} (hP : P βˆ‰ closure s) : P βˆ‰ s := fun h => hP (subset_closure h) #align subring.not_mem_of_not_mem_closure Subring.not_mem_of_not_mem_closure @[simp] theorem closure_le {s : Set R} {t : Subring R} : closure s ≀ t ↔ s βŠ† t := ⟨Set.Subset.trans subset_closure, fun h => sInf_le h⟩ #align subring.closure_le Subring.closure_le theorem closure_mono ⦃s t : Set R⦄ (h : s βŠ† t) : closure s ≀ closure t := closure_le.2 <| Set.Subset.trans h subset_closure #align subring.closure_mono Subring.closure_mono theorem closure_eq_of_le {s : Set R} {t : Subring R} (h₁ : s βŠ† t) (hβ‚‚ : t ≀ closure s) : closure s = t := le_antisymm (closure_le.2 h₁) hβ‚‚ #align subring.closure_eq_of_le Subring.closure_eq_of_le @[elab_as_elim] theorem closure_induction {s : Set R} {p : R β†’ Prop} {x} (h : x ∈ closure s) (Hs : βˆ€ x ∈ s, p x) (zero : p 0) (one : p 1) (add : βˆ€ x y, p x β†’ p y β†’ p (x + y)) (neg : βˆ€ x : R, p x β†’ p (-x)) (mul : βˆ€ x y, p x β†’ p y β†’ p (x * y)) : p x := (@closure_le _ _ _ ⟨⟨⟨⟨p, @mul⟩, one⟩, @add, zero⟩, @neg⟩).2 Hs h #align subring.closure_induction Subring.closure_induction @[elab_as_elim] theorem closure_induction' {s : Set R} {p : βˆ€ x, x ∈ closure s β†’ Prop} (mem : βˆ€ (x) (h : x ∈ s), p x (subset_closure h)) (zero : p 0 (zero_mem _)) (one : p 1 (one_mem _)) (add : βˆ€ x hx y hy, p x hx β†’ p y hy β†’ p (x + y) (add_mem hx hy)) (neg : βˆ€ x hx, p x hx β†’ p (-x) (neg_mem hx)) (mul : βˆ€ x hx y hy, p x hx β†’ p y hy β†’ p (x * y) (mul_mem hx hy)) {a : R} (ha : a ∈ closure s) : p a ha := by refine Exists.elim ?_ fun (ha : a ∈ closure s) (hc : p a ha) => hc refine closure_induction ha (fun m hm => ⟨subset_closure hm, mem m hm⟩) ⟨zero_mem _, zero⟩ ⟨one_mem _, one⟩ ?_ (fun x hx => hx.elim fun hx' hx => ⟨neg_mem hx', neg _ _ hx⟩) ?_ Β· exact (fun x y hx hy => hx.elim fun hx' hx => hy.elim fun hy' hy => ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩) Β· exact (fun x y hx hy => hx.elim fun hx' hx => hy.elim fun hy' hy => ⟨mul_mem hx' hy', mul _ _ _ _ hx hy⟩) @[elab_as_elim] theorem closure_inductionβ‚‚ {s : Set R} {p : R β†’ R β†’ Prop} {a b : R} (ha : a ∈ closure s) (hb : b ∈ closure s) (Hs : βˆ€ x ∈ s, βˆ€ y ∈ s, p x y) (H0_left : βˆ€ x, p 0 x) (H0_right : βˆ€ x, p x 0) (H1_left : βˆ€ x, p 1 x) (H1_right : βˆ€ x, p x 1) (Hneg_left : βˆ€ x y, p x y β†’ p (-x) y) (Hneg_right : βˆ€ x y, p x y β†’ p x (-y)) (Hadd_left : βˆ€ x₁ xβ‚‚ y, p x₁ y β†’ p xβ‚‚ y β†’ p (x₁ + xβ‚‚) y) (Hadd_right : βˆ€ x y₁ yβ‚‚, p x y₁ β†’ p x yβ‚‚ β†’ p x (y₁ + yβ‚‚)) (Hmul_left : βˆ€ x₁ xβ‚‚ y, p x₁ y β†’ p xβ‚‚ y β†’ p (x₁ * xβ‚‚) y) (Hmul_right : βˆ€ x y₁ yβ‚‚, p x y₁ β†’ p x yβ‚‚ β†’ p x (y₁ * yβ‚‚)) : p a b := by refine closure_induction hb ?_ (H0_right _) (H1_right _) (Hadd_right a) (Hneg_right a) (Hmul_right a) refine closure_induction ha Hs (fun x _ => H0_left x) (fun x _ => H1_left x) ?_ ?_ ?_ Β· exact fun x y H₁ Hβ‚‚ z zs => Hadd_left x y z (H₁ z zs) (Hβ‚‚ z zs) Β· exact fun x hx z zs => Hneg_left x z (hx z zs) Β· exact fun x y H₁ Hβ‚‚ z zs => Hmul_left x y z (H₁ z zs) (Hβ‚‚ z zs) #align subring.closure_inductionβ‚‚ Subring.closure_inductionβ‚‚
Mathlib/Algebra/Ring/Subring/Basic.lean
919
946
theorem mem_closure_iff {s : Set R} {x} : x ∈ closure s ↔ x ∈ AddSubgroup.closure (Submonoid.closure s : Set R) := ⟨fun h => closure_induction h (fun x hx => AddSubgroup.subset_closure <| Submonoid.subset_closure hx) (AddSubgroup.zero_mem _) (AddSubgroup.subset_closure (Submonoid.one_mem (Submonoid.closure s))) (fun x y hx hy => AddSubgroup.add_mem _ hx hy) (fun x hx => AddSubgroup.neg_mem _ hx) fun x y hx hy => AddSubgroup.closure_induction hy (fun q hq => AddSubgroup.closure_induction hx (fun p hp => AddSubgroup.subset_closure ((Submonoid.closure s).mul_mem hp hq)) (by rw [zero_mul q]; apply AddSubgroup.zero_mem _) (fun p₁ pβ‚‚ ihp₁ ihpβ‚‚ => by rw [add_mul p₁ pβ‚‚ q]; apply AddSubgroup.add_mem _ ihp₁ ihpβ‚‚) fun x hx => by have f : -x * q = -(x * q) := by
simp rw [f]; apply AddSubgroup.neg_mem _ hx) (by rw [mul_zero x]; apply AddSubgroup.zero_mem _) (fun q₁ qβ‚‚ ihq₁ ihqβ‚‚ => by rw [mul_add x q₁ qβ‚‚]; apply AddSubgroup.add_mem _ ihq₁ ihqβ‚‚) fun z hz => by have f : x * -z = -(x * z) := by simp rw [f]; apply AddSubgroup.neg_mem _ hz, fun h => AddSubgroup.closure_induction (p := (Β· ∈ closure s)) h (fun x hx => Submonoid.closure_induction hx (fun x hx => subset_closure hx) (one_mem _) fun x y hx hy => mul_mem hx hy) (zero_mem _) (fun x y hx hy => add_mem hx hy) fun x hx => neg_mem hx⟩
import Mathlib.Init.Data.Prod import Mathlib.Data.Seq.WSeq #align_import data.seq.parallel from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" universe u v namespace Computation open Stream' variable {Ξ± : Type u} {Ξ² : Type v} def parallel.aux2 : List (Computation Ξ±) β†’ Sum Ξ± (List (Computation Ξ±)) := List.foldr (fun c o => match o with | Sum.inl a => Sum.inl a | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) (Sum.inr []) #align computation.parallel.aux2 Computation.parallel.aux2 def parallel.aux1 : List (Computation Ξ±) Γ— WSeq (Computation Ξ±) β†’ Sum Ξ± (List (Computation Ξ±) Γ— WSeq (Computation Ξ±)) | (l, S) => rmap (fun l' => match Seq.destruct S with | none => (l', Seq.nil) | some (none, S') => (l', S') | some (some c, S') => (c :: l', S')) (parallel.aux2 l) #align computation.parallel.aux1 Computation.parallel.aux1 def parallel (S : WSeq (Computation Ξ±)) : Computation Ξ± := corec parallel.aux1 ([], S) #align computation.parallel Computation.parallel theorem terminates_parallel.aux : βˆ€ {l : List (Computation Ξ±)} {S c}, c ∈ l β†’ Terminates c β†’ Terminates (corec parallel.aux1 (l, S)) := by have lem1 : βˆ€ l S, (βˆƒ a : Ξ±, parallel.aux2 l = Sum.inl a) β†’ Terminates (corec parallel.aux1 (l, S)) := by intro l S e cases' e with a e have : corec parallel.aux1 (l, S) = return a := by apply destruct_eq_pure simp only [parallel.aux1, rmap, corec_eq] rw [e] rw [this] -- Porting note: This line is required. exact ret_terminates a intro l S c m T revert l S apply @terminatesRecOn _ _ c T _ _ Β· intro a l S m apply lem1 induction' l with c l IH <;> simp at m cases' m with e m Β· rw [← e] simp only [parallel.aux2, rmap, List.foldr_cons, destruct_pure] split <;> simp Β· cases' IH m with a' e simp only [parallel.aux2, rmap, List.foldr_cons] simp? [parallel.aux2] at e says simp only [parallel.aux2, rmap] at e rw [e] exact ⟨a', rfl⟩ Β· intro s IH l S m have H1 : βˆ€ l', parallel.aux2 l = Sum.inr l' β†’ s ∈ l' := by induction' l with c l IH' <;> intro l' e' <;> simp at m cases' m with e m <;> simp [parallel.aux2] at e' Β· rw [← e] at e' -- Porting note: `revert e'` & `intro e'` are required. revert e' split Β· simp Β· simp only [destruct_think, Sum.inr.injEq] rintro rfl simp Β· induction' e : List.foldr (fun c o => match o with | Sum.inl a => Sum.inl a | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) (Sum.inr List.nil) l with a' ls <;> erw [e] at e' Β· contradiction have := IH' m _ e -- Porting note: `revert e'` & `intro e'` are required. revert e' cases destruct c <;> intro e' <;> [injection e'; injection e' with h'] rw [← h'] simp [this] induction' h : parallel.aux2 l with a l' Β· exact lem1 _ _ ⟨a, h⟩ Β· have H2 : corec parallel.aux1 (l, S) = think _ := destruct_eq_think (by simp only [parallel.aux1, rmap, corec_eq] rw [h]) rw [H2] refine @Computation.think_terminates _ _ ?_ have := H1 _ h rcases Seq.destruct S with (_ | ⟨_ | c, S'⟩) <;> simp [parallel.aux1] <;> apply IH <;> simp [this] #align computation.terminates_parallel.aux Computation.terminates_parallel.aux theorem terminates_parallel {S : WSeq (Computation Ξ±)} {c} (h : c ∈ S) [T : Terminates c] : Terminates (parallel S) := by suffices βˆ€ (n) (l : List (Computation Ξ±)) (S c), c ∈ l ∨ some (some c) = Seq.get? S n β†’ Terminates c β†’ Terminates (corec parallel.aux1 (l, S)) from let ⟨n, h⟩ := h this n [] S c (Or.inr h) T intro n; induction' n with n IH <;> intro l S c o T Β· cases' o with a a Β· exact terminates_parallel.aux a T have H : Seq.destruct S = some (some c, Seq.tail S) := by simp [Seq.destruct, (Β· <$> Β·), ← a] induction' h : parallel.aux2 l with a l' Β· have C : corec parallel.aux1 (l, S) = pure a := by apply destruct_eq_pure rw [corec_eq, parallel.aux1] dsimp only [] rw [h] simp only [rmap] rw [C] infer_instance Β· have C : corec parallel.aux1 (l, S) = _ := destruct_eq_think (by simp only [corec_eq, rmap, parallel.aux1.eq_1] rw [h, H]) rw [C] refine @Computation.think_terminates _ _ ?_ apply terminates_parallel.aux _ T simp Β· cases' o with a a Β· exact terminates_parallel.aux a T induction' h : parallel.aux2 l with a l' Β· have C : corec parallel.aux1 (l, S) = pure a := by apply destruct_eq_pure rw [corec_eq, parallel.aux1] dsimp only [] rw [h] simp only [rmap] rw [C] infer_instance Β· have C : corec parallel.aux1 (l, S) = _ := destruct_eq_think (by simp only [corec_eq, rmap, parallel.aux1.eq_1] rw [h]) rw [C] refine @Computation.think_terminates _ _ ?_ have TT : βˆ€ l', Terminates (corec parallel.aux1 (l', S.tail)) := by intro apply IH _ _ _ (Or.inr _) T rw [a] cases' S with f al rfl induction' e : Seq.get? S 0 with o Β· have D : Seq.destruct S = none := by dsimp [Seq.destruct] rw [e] rfl rw [D] simp only have TT := TT l' rwa [Seq.destruct_eq_nil D, Seq.tail_nil] at TT Β· have D : Seq.destruct S = some (o, S.tail) := by dsimp [Seq.destruct] rw [e] rfl rw [D] cases' o with c <;> simp [parallel.aux1, TT] #align computation.terminates_parallel Computation.terminates_parallel
Mathlib/Data/Seq/Parallel.lean
189
266
theorem exists_of_mem_parallel {S : WSeq (Computation Ξ±)} {a} (h : a ∈ parallel S) : βˆƒ c ∈ S, a ∈ c := by
suffices βˆ€ C, a ∈ C β†’ βˆ€ (l : List (Computation Ξ±)) (S), corec parallel.aux1 (l, S) = C β†’ βˆƒ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c from let ⟨c, h1, h2⟩ := this _ h [] S rfl ⟨c, h1.resolve_left <| List.not_mem_nil _, h2⟩ let F : List (Computation Ξ±) β†’ Sum Ξ± (List (Computation Ξ±)) β†’ Prop := by intro l a cases' a with a l' Β· exact βˆƒ c ∈ l, a ∈ c Β· exact βˆ€ a', (βˆƒ c ∈ l', a' ∈ c) β†’ βˆƒ c ∈ l, a' ∈ c have lem1 : βˆ€ l : List (Computation Ξ±), F l (parallel.aux2 l) := by intro l induction' l with c l IH <;> simp only [parallel.aux2, List.foldr] Β· intro a h rcases h with ⟨c, hn, _⟩ exact False.elim <| List.not_mem_nil _ hn Β· simp only [parallel.aux2] at IH -- Porting note: `revert IH` & `intro IH` are required. revert IH cases' List.foldr (fun c o => match o with | Sum.inl a => Sum.inl a | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) (Sum.inr List.nil) l with a ls <;> intro IH <;> simp only [parallel.aux2] Β· rcases IH with ⟨c', cl, ac⟩ exact ⟨c', List.Mem.tail _ cl, ac⟩ Β· induction' h : destruct c with a c' <;> simp only [rmap] Β· refine ⟨c, List.mem_cons_self _ _, ?_⟩ rw [destruct_eq_pure h] apply ret_mem Β· intro a' h rcases h with ⟨d, dm, ad⟩ simp? at dm says simp only [List.mem_cons] at dm cases' dm with e dl Β· rw [e] at ad refine ⟨c, List.mem_cons_self _ _, ?_⟩ rw [destruct_eq_think h] exact think_mem ad Β· cases' IH a' ⟨d, dl, ad⟩ with d dm cases' dm with dm ad exact ⟨d, List.Mem.tail _ dm, ad⟩ intro C aC -- Porting note: `revert e'` & `intro e'` are required. apply memRecOn aC <;> [skip; intro C' IH] <;> intro l S e <;> have e' := congr_arg destruct e <;> have := lem1 l <;> simp only [parallel.aux1, corec_eq, destruct_pure, destruct_think] at e' <;> revert this e' <;> cases' parallel.aux2 l with a' l' <;> intro this e' <;> [injection e' with h'; injection e'; injection e'; injection e' with h'] Β· rw [h'] at this rcases this with ⟨c, cl, ac⟩ exact ⟨c, Or.inl cl, ac⟩ Β· induction' e : Seq.destruct S with a <;> rw [e] at h' Β· exact let ⟨d, o, ad⟩ := IH _ _ h' let ⟨c, cl, ac⟩ := this a ⟨d, o.resolve_right (WSeq.not_mem_nil _), ad⟩ ⟨c, Or.inl cl, ac⟩ Β· cases' a with o S' cases' o with c <;> simp [parallel.aux1] at h' <;> rcases IH _ _ h' with ⟨d, dl | dS', ad⟩ Β· exact let ⟨c, cl, ac⟩ := this a ⟨d, dl, ad⟩ ⟨c, Or.inl cl, ac⟩ Β· refine ⟨d, Or.inr ?_, ad⟩ rw [Seq.destruct_eq_cons e] exact Seq.mem_cons_of_mem _ dS' Β· simp at dl cases' dl with dc dl Β· rw [dc] at ad refine ⟨c, Or.inr ?_, ad⟩ rw [Seq.destruct_eq_cons e] apply Seq.mem_cons Β· exact let ⟨c, cl, ac⟩ := this a ⟨d, dl, ad⟩ ⟨c, Or.inl cl, ac⟩ Β· refine ⟨d, Or.inr ?_, ad⟩ rw [Seq.destruct_eq_cons e] exact Seq.mem_cons_of_mem _ dS'
import Mathlib.Analysis.SpecialFunctions.Exp import Mathlib.Tactic.Positivity.Core import Mathlib.Algebra.Ring.NegOnePow #align_import analysis.special_functions.trigonometric.basic from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" noncomputable section open scoped Classical open Topology Filter Set namespace Real open Real @[simp] theorem sin_pi : sin Ο€ = 0 := by rw [← mul_div_cancel_leftβ‚€ Ο€ (two_ne_zero' ℝ), two_mul, add_div, sin_add, cos_pi_div_two]; simp #align real.sin_pi Real.sin_pi @[simp] theorem cos_pi : cos Ο€ = -1 := by rw [← mul_div_cancel_leftβ‚€ Ο€ (two_ne_zero' ℝ), mul_div_assoc, cos_two_mul, cos_pi_div_two] norm_num #align real.cos_pi Real.cos_pi @[simp] theorem sin_two_pi : sin (2 * Ο€) = 0 := by simp [two_mul, sin_add] #align real.sin_two_pi Real.sin_two_pi @[simp] theorem cos_two_pi : cos (2 * Ο€) = 1 := by simp [two_mul, cos_add] #align real.cos_two_pi Real.cos_two_pi theorem sin_antiperiodic : Function.Antiperiodic sin Ο€ := by simp [sin_add] #align real.sin_antiperiodic Real.sin_antiperiodic theorem sin_periodic : Function.Periodic sin (2 * Ο€) := sin_antiperiodic.periodic_two_mul #align real.sin_periodic Real.sin_periodic @[simp] theorem sin_add_pi (x : ℝ) : sin (x + Ο€) = -sin x := sin_antiperiodic x #align real.sin_add_pi Real.sin_add_pi @[simp] theorem sin_add_two_pi (x : ℝ) : sin (x + 2 * Ο€) = sin x := sin_periodic x #align real.sin_add_two_pi Real.sin_add_two_pi @[simp] theorem sin_sub_pi (x : ℝ) : sin (x - Ο€) = -sin x := sin_antiperiodic.sub_eq x #align real.sin_sub_pi Real.sin_sub_pi @[simp] theorem sin_sub_two_pi (x : ℝ) : sin (x - 2 * Ο€) = sin x := sin_periodic.sub_eq x #align real.sin_sub_two_pi Real.sin_sub_two_pi @[simp] theorem sin_pi_sub (x : ℝ) : sin (Ο€ - x) = sin x := neg_neg (sin x) β–Έ sin_neg x β–Έ sin_antiperiodic.sub_eq' #align real.sin_pi_sub Real.sin_pi_sub @[simp] theorem sin_two_pi_sub (x : ℝ) : sin (2 * Ο€ - x) = -sin x := sin_neg x β–Έ sin_periodic.sub_eq' #align real.sin_two_pi_sub Real.sin_two_pi_sub @[simp] theorem sin_nat_mul_pi (n : β„•) : sin (n * Ο€) = 0 := sin_antiperiodic.nat_mul_eq_of_eq_zero sin_zero n #align real.sin_nat_mul_pi Real.sin_nat_mul_pi @[simp] theorem sin_int_mul_pi (n : β„€) : sin (n * Ο€) = 0 := sin_antiperiodic.int_mul_eq_of_eq_zero sin_zero n #align real.sin_int_mul_pi Real.sin_int_mul_pi @[simp] theorem sin_add_nat_mul_two_pi (x : ℝ) (n : β„•) : sin (x + n * (2 * Ο€)) = sin x := sin_periodic.nat_mul n x #align real.sin_add_nat_mul_two_pi Real.sin_add_nat_mul_two_pi @[simp] theorem sin_add_int_mul_two_pi (x : ℝ) (n : β„€) : sin (x + n * (2 * Ο€)) = sin x := sin_periodic.int_mul n x #align real.sin_add_int_mul_two_pi Real.sin_add_int_mul_two_pi @[simp] theorem sin_sub_nat_mul_two_pi (x : ℝ) (n : β„•) : sin (x - n * (2 * Ο€)) = sin x := sin_periodic.sub_nat_mul_eq n #align real.sin_sub_nat_mul_two_pi Real.sin_sub_nat_mul_two_pi @[simp] theorem sin_sub_int_mul_two_pi (x : ℝ) (n : β„€) : sin (x - n * (2 * Ο€)) = sin x := sin_periodic.sub_int_mul_eq n #align real.sin_sub_int_mul_two_pi Real.sin_sub_int_mul_two_pi @[simp] theorem sin_nat_mul_two_pi_sub (x : ℝ) (n : β„•) : sin (n * (2 * Ο€) - x) = -sin x := sin_neg x β–Έ sin_periodic.nat_mul_sub_eq n #align real.sin_nat_mul_two_pi_sub Real.sin_nat_mul_two_pi_sub @[simp] theorem sin_int_mul_two_pi_sub (x : ℝ) (n : β„€) : sin (n * (2 * Ο€) - x) = -sin x := sin_neg x β–Έ sin_periodic.int_mul_sub_eq n #align real.sin_int_mul_two_pi_sub Real.sin_int_mul_two_pi_sub theorem sin_add_int_mul_pi (x : ℝ) (n : β„€) : sin (x + n * Ο€) = (-1) ^ n * sin x := n.coe_negOnePow ℝ β–Έ sin_antiperiodic.add_int_mul_eq n theorem sin_add_nat_mul_pi (x : ℝ) (n : β„•) : sin (x + n * Ο€) = (-1) ^ n * sin x := sin_antiperiodic.add_nat_mul_eq n theorem sin_sub_int_mul_pi (x : ℝ) (n : β„€) : sin (x - n * Ο€) = (-1) ^ n * sin x := n.coe_negOnePow ℝ β–Έ sin_antiperiodic.sub_int_mul_eq n theorem sin_sub_nat_mul_pi (x : ℝ) (n : β„•) : sin (x - n * Ο€) = (-1) ^ n * sin x := sin_antiperiodic.sub_nat_mul_eq n theorem sin_int_mul_pi_sub (x : ℝ) (n : β„€) : sin (n * Ο€ - x) = -((-1) ^ n * sin x) := by simpa only [sin_neg, mul_neg, Int.coe_negOnePow] using sin_antiperiodic.int_mul_sub_eq n theorem sin_nat_mul_pi_sub (x : ℝ) (n : β„•) : sin (n * Ο€ - x) = -((-1) ^ n * sin x) := by simpa only [sin_neg, mul_neg] using sin_antiperiodic.nat_mul_sub_eq n theorem cos_antiperiodic : Function.Antiperiodic cos Ο€ := by simp [cos_add] #align real.cos_antiperiodic Real.cos_antiperiodic theorem cos_periodic : Function.Periodic cos (2 * Ο€) := cos_antiperiodic.periodic_two_mul #align real.cos_periodic Real.cos_periodic @[simp] theorem cos_add_pi (x : ℝ) : cos (x + Ο€) = -cos x := cos_antiperiodic x #align real.cos_add_pi Real.cos_add_pi @[simp] theorem cos_add_two_pi (x : ℝ) : cos (x + 2 * Ο€) = cos x := cos_periodic x #align real.cos_add_two_pi Real.cos_add_two_pi @[simp] theorem cos_sub_pi (x : ℝ) : cos (x - Ο€) = -cos x := cos_antiperiodic.sub_eq x #align real.cos_sub_pi Real.cos_sub_pi @[simp] theorem cos_sub_two_pi (x : ℝ) : cos (x - 2 * Ο€) = cos x := cos_periodic.sub_eq x #align real.cos_sub_two_pi Real.cos_sub_two_pi @[simp] theorem cos_pi_sub (x : ℝ) : cos (Ο€ - x) = -cos x := cos_neg x β–Έ cos_antiperiodic.sub_eq' #align real.cos_pi_sub Real.cos_pi_sub @[simp] theorem cos_two_pi_sub (x : ℝ) : cos (2 * Ο€ - x) = cos x := cos_neg x β–Έ cos_periodic.sub_eq' #align real.cos_two_pi_sub Real.cos_two_pi_sub @[simp] theorem cos_nat_mul_two_pi (n : β„•) : cos (n * (2 * Ο€)) = 1 := (cos_periodic.nat_mul_eq n).trans cos_zero #align real.cos_nat_mul_two_pi Real.cos_nat_mul_two_pi @[simp] theorem cos_int_mul_two_pi (n : β„€) : cos (n * (2 * Ο€)) = 1 := (cos_periodic.int_mul_eq n).trans cos_zero #align real.cos_int_mul_two_pi Real.cos_int_mul_two_pi @[simp] theorem cos_add_nat_mul_two_pi (x : ℝ) (n : β„•) : cos (x + n * (2 * Ο€)) = cos x := cos_periodic.nat_mul n x #align real.cos_add_nat_mul_two_pi Real.cos_add_nat_mul_two_pi @[simp] theorem cos_add_int_mul_two_pi (x : ℝ) (n : β„€) : cos (x + n * (2 * Ο€)) = cos x := cos_periodic.int_mul n x #align real.cos_add_int_mul_two_pi Real.cos_add_int_mul_two_pi @[simp] theorem cos_sub_nat_mul_two_pi (x : ℝ) (n : β„•) : cos (x - n * (2 * Ο€)) = cos x := cos_periodic.sub_nat_mul_eq n #align real.cos_sub_nat_mul_two_pi Real.cos_sub_nat_mul_two_pi @[simp] theorem cos_sub_int_mul_two_pi (x : ℝ) (n : β„€) : cos (x - n * (2 * Ο€)) = cos x := cos_periodic.sub_int_mul_eq n #align real.cos_sub_int_mul_two_pi Real.cos_sub_int_mul_two_pi @[simp] theorem cos_nat_mul_two_pi_sub (x : ℝ) (n : β„•) : cos (n * (2 * Ο€) - x) = cos x := cos_neg x β–Έ cos_periodic.nat_mul_sub_eq n #align real.cos_nat_mul_two_pi_sub Real.cos_nat_mul_two_pi_sub @[simp] theorem cos_int_mul_two_pi_sub (x : ℝ) (n : β„€) : cos (n * (2 * Ο€) - x) = cos x := cos_neg x β–Έ cos_periodic.int_mul_sub_eq n #align real.cos_int_mul_two_pi_sub Real.cos_int_mul_two_pi_sub theorem cos_add_int_mul_pi (x : ℝ) (n : β„€) : cos (x + n * Ο€) = (-1) ^ n * cos x := n.coe_negOnePow ℝ β–Έ cos_antiperiodic.add_int_mul_eq n theorem cos_add_nat_mul_pi (x : ℝ) (n : β„•) : cos (x + n * Ο€) = (-1) ^ n * cos x := cos_antiperiodic.add_nat_mul_eq n theorem cos_sub_int_mul_pi (x : ℝ) (n : β„€) : cos (x - n * Ο€) = (-1) ^ n * cos x := n.coe_negOnePow ℝ β–Έ cos_antiperiodic.sub_int_mul_eq n theorem cos_sub_nat_mul_pi (x : ℝ) (n : β„•) : cos (x - n * Ο€) = (-1) ^ n * cos x := cos_antiperiodic.sub_nat_mul_eq n theorem cos_int_mul_pi_sub (x : ℝ) (n : β„€) : cos (n * Ο€ - x) = (-1) ^ n * cos x := n.coe_negOnePow ℝ β–Έ cos_neg x β–Έ cos_antiperiodic.int_mul_sub_eq n theorem cos_nat_mul_pi_sub (x : ℝ) (n : β„•) : cos (n * Ο€ - x) = (-1) ^ n * cos x := cos_neg x β–Έ cos_antiperiodic.nat_mul_sub_eq n -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_nat_mul_two_pi_add_pi (n : β„•) : cos (n * (2 * Ο€) + Ο€) = -1 := by simpa only [cos_zero] using (cos_periodic.nat_mul n).add_antiperiod_eq cos_antiperiodic #align real.cos_nat_mul_two_pi_add_pi Real.cos_nat_mul_two_pi_add_pi -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_int_mul_two_pi_add_pi (n : β„€) : cos (n * (2 * Ο€) + Ο€) = -1 := by simpa only [cos_zero] using (cos_periodic.int_mul n).add_antiperiod_eq cos_antiperiodic #align real.cos_int_mul_two_pi_add_pi Real.cos_int_mul_two_pi_add_pi -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_nat_mul_two_pi_sub_pi (n : β„•) : cos (n * (2 * Ο€) - Ο€) = -1 := by simpa only [cos_zero] using (cos_periodic.nat_mul n).sub_antiperiod_eq cos_antiperiodic #align real.cos_nat_mul_two_pi_sub_pi Real.cos_nat_mul_two_pi_sub_pi -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_int_mul_two_pi_sub_pi (n : β„€) : cos (n * (2 * Ο€) - Ο€) = -1 := by simpa only [cos_zero] using (cos_periodic.int_mul n).sub_antiperiod_eq cos_antiperiodic #align real.cos_int_mul_two_pi_sub_pi Real.cos_int_mul_two_pi_sub_pi theorem sin_pos_of_pos_of_lt_pi {x : ℝ} (h0x : 0 < x) (hxp : x < Ο€) : 0 < sin x := if hx2 : x ≀ 2 then sin_pos_of_pos_of_le_two h0x hx2 else have : (2 : ℝ) + 2 = 4 := by norm_num have : Ο€ - x ≀ 2 := sub_le_iff_le_add.2 (le_trans pi_le_four (this β–Έ add_le_add_left (le_of_not_ge hx2) _)) sin_pi_sub x β–Έ sin_pos_of_pos_of_le_two (sub_pos.2 hxp) this #align real.sin_pos_of_pos_of_lt_pi Real.sin_pos_of_pos_of_lt_pi theorem sin_pos_of_mem_Ioo {x : ℝ} (hx : x ∈ Ioo 0 Ο€) : 0 < sin x := sin_pos_of_pos_of_lt_pi hx.1 hx.2 #align real.sin_pos_of_mem_Ioo Real.sin_pos_of_mem_Ioo theorem sin_nonneg_of_mem_Icc {x : ℝ} (hx : x ∈ Icc 0 Ο€) : 0 ≀ sin x := by rw [← closure_Ioo pi_ne_zero.symm] at hx exact closure_lt_subset_le continuous_const continuous_sin (closure_mono (fun y => sin_pos_of_mem_Ioo) hx) #align real.sin_nonneg_of_mem_Icc Real.sin_nonneg_of_mem_Icc theorem sin_nonneg_of_nonneg_of_le_pi {x : ℝ} (h0x : 0 ≀ x) (hxp : x ≀ Ο€) : 0 ≀ sin x := sin_nonneg_of_mem_Icc ⟨h0x, hxp⟩ #align real.sin_nonneg_of_nonneg_of_le_pi Real.sin_nonneg_of_nonneg_of_le_pi theorem sin_neg_of_neg_of_neg_pi_lt {x : ℝ} (hx0 : x < 0) (hpx : -Ο€ < x) : sin x < 0 := neg_pos.1 <| sin_neg x β–Έ sin_pos_of_pos_of_lt_pi (neg_pos.2 hx0) (neg_lt.1 hpx) #align real.sin_neg_of_neg_of_neg_pi_lt Real.sin_neg_of_neg_of_neg_pi_lt theorem sin_nonpos_of_nonnpos_of_neg_pi_le {x : ℝ} (hx0 : x ≀ 0) (hpx : -Ο€ ≀ x) : sin x ≀ 0 := neg_nonneg.1 <| sin_neg x β–Έ sin_nonneg_of_nonneg_of_le_pi (neg_nonneg.2 hx0) (neg_le.1 hpx) #align real.sin_nonpos_of_nonnpos_of_neg_pi_le Real.sin_nonpos_of_nonnpos_of_neg_pi_le @[simp] theorem sin_pi_div_two : sin (Ο€ / 2) = 1 := have : sin (Ο€ / 2) = 1 ∨ sin (Ο€ / 2) = -1 := by simpa [sq, mul_self_eq_one_iff] using sin_sq_add_cos_sq (Ο€ / 2) this.resolve_right fun h => show Β¬(0 : ℝ) < -1 by norm_num <| h β–Έ sin_pos_of_pos_of_lt_pi pi_div_two_pos (half_lt_self pi_pos) #align real.sin_pi_div_two Real.sin_pi_div_two theorem sin_add_pi_div_two (x : ℝ) : sin (x + Ο€ / 2) = cos x := by simp [sin_add] #align real.sin_add_pi_div_two Real.sin_add_pi_div_two theorem sin_sub_pi_div_two (x : ℝ) : sin (x - Ο€ / 2) = -cos x := by simp [sub_eq_add_neg, sin_add] #align real.sin_sub_pi_div_two Real.sin_sub_pi_div_two theorem sin_pi_div_two_sub (x : ℝ) : sin (Ο€ / 2 - x) = cos x := by simp [sub_eq_add_neg, sin_add] #align real.sin_pi_div_two_sub Real.sin_pi_div_two_sub theorem cos_add_pi_div_two (x : ℝ) : cos (x + Ο€ / 2) = -sin x := by simp [cos_add] #align real.cos_add_pi_div_two Real.cos_add_pi_div_two theorem cos_sub_pi_div_two (x : ℝ) : cos (x - Ο€ / 2) = sin x := by simp [sub_eq_add_neg, cos_add] #align real.cos_sub_pi_div_two Real.cos_sub_pi_div_two theorem cos_pi_div_two_sub (x : ℝ) : cos (Ο€ / 2 - x) = sin x := by rw [← cos_neg, neg_sub, cos_sub_pi_div_two] #align real.cos_pi_div_two_sub Real.cos_pi_div_two_sub theorem cos_pos_of_mem_Ioo {x : ℝ} (hx : x ∈ Ioo (-(Ο€ / 2)) (Ο€ / 2)) : 0 < cos x := sin_add_pi_div_two x β–Έ sin_pos_of_mem_Ioo ⟨by linarith [hx.1], by linarith [hx.2]⟩ #align real.cos_pos_of_mem_Ioo Real.cos_pos_of_mem_Ioo theorem cos_nonneg_of_mem_Icc {x : ℝ} (hx : x ∈ Icc (-(Ο€ / 2)) (Ο€ / 2)) : 0 ≀ cos x := sin_add_pi_div_two x β–Έ sin_nonneg_of_mem_Icc ⟨by linarith [hx.1], by linarith [hx.2]⟩ #align real.cos_nonneg_of_mem_Icc Real.cos_nonneg_of_mem_Icc theorem cos_nonneg_of_neg_pi_div_two_le_of_le {x : ℝ} (hl : -(Ο€ / 2) ≀ x) (hu : x ≀ Ο€ / 2) : 0 ≀ cos x := cos_nonneg_of_mem_Icc ⟨hl, hu⟩ #align real.cos_nonneg_of_neg_pi_div_two_le_of_le Real.cos_nonneg_of_neg_pi_div_two_le_of_le theorem cos_neg_of_pi_div_two_lt_of_lt {x : ℝ} (hx₁ : Ο€ / 2 < x) (hxβ‚‚ : x < Ο€ + Ο€ / 2) : cos x < 0 := neg_pos.1 <| cos_pi_sub x β–Έ cos_pos_of_mem_Ioo ⟨by linarith, by linarith⟩ #align real.cos_neg_of_pi_div_two_lt_of_lt Real.cos_neg_of_pi_div_two_lt_of_lt theorem cos_nonpos_of_pi_div_two_le_of_le {x : ℝ} (hx₁ : Ο€ / 2 ≀ x) (hxβ‚‚ : x ≀ Ο€ + Ο€ / 2) : cos x ≀ 0 := neg_nonneg.1 <| cos_pi_sub x β–Έ cos_nonneg_of_mem_Icc ⟨by linarith, by linarith⟩ #align real.cos_nonpos_of_pi_div_two_le_of_le Real.cos_nonpos_of_pi_div_two_le_of_le theorem sin_eq_sqrt_one_sub_cos_sq {x : ℝ} (hl : 0 ≀ x) (hu : x ≀ Ο€) : sin x = √(1 - cos x ^ 2) := by rw [← abs_sin_eq_sqrt_one_sub_cos_sq, abs_of_nonneg (sin_nonneg_of_nonneg_of_le_pi hl hu)] #align real.sin_eq_sqrt_one_sub_cos_sq Real.sin_eq_sqrt_one_sub_cos_sq theorem cos_eq_sqrt_one_sub_sin_sq {x : ℝ} (hl : -(Ο€ / 2) ≀ x) (hu : x ≀ Ο€ / 2) : cos x = √(1 - sin x ^ 2) := by rw [← abs_cos_eq_sqrt_one_sub_sin_sq, abs_of_nonneg (cos_nonneg_of_mem_Icc ⟨hl, hu⟩)] #align real.cos_eq_sqrt_one_sub_sin_sq Real.cos_eq_sqrt_one_sub_sin_sq lemma cos_half {x : ℝ} (hl : -Ο€ ≀ x) (hr : x ≀ Ο€) : cos (x / 2) = sqrt ((1 + cos x) / 2) := by have : 0 ≀ cos (x / 2) := cos_nonneg_of_mem_Icc <| by constructor <;> linarith rw [← sqrt_sq this, cos_sq, add_div, two_mul, add_halves] lemma abs_sin_half (x : ℝ) : |sin (x / 2)| = sqrt ((1 - cos x) / 2) := by rw [← sqrt_sq_eq_abs, sin_sq_eq_half_sub, two_mul, add_halves, sub_div] lemma sin_half_eq_sqrt {x : ℝ} (hl : 0 ≀ x) (hr : x ≀ 2 * Ο€) : sin (x / 2) = sqrt ((1 - cos x) / 2) := by rw [← abs_sin_half, abs_of_nonneg] apply sin_nonneg_of_nonneg_of_le_pi <;> linarith lemma sin_half_eq_neg_sqrt {x : ℝ} (hl : -(2 * Ο€) ≀ x) (hr : x ≀ 0) : sin (x / 2) = -sqrt ((1 - cos x) / 2) := by rw [← abs_sin_half, abs_of_nonpos, neg_neg] apply sin_nonpos_of_nonnpos_of_neg_pi_le <;> linarith theorem sin_eq_zero_iff_of_lt_of_lt {x : ℝ} (hx₁ : -Ο€ < x) (hxβ‚‚ : x < Ο€) : sin x = 0 ↔ x = 0 := ⟨fun h => by contrapose! h cases h.lt_or_lt with | inl h0 => exact (sin_neg_of_neg_of_neg_pi_lt h0 hx₁).ne | inr h0 => exact (sin_pos_of_pos_of_lt_pi h0 hxβ‚‚).ne', fun h => by simp [h]⟩ #align real.sin_eq_zero_iff_of_lt_of_lt Real.sin_eq_zero_iff_of_lt_of_lt theorem sin_eq_zero_iff {x : ℝ} : sin x = 0 ↔ βˆƒ n : β„€, (n : ℝ) * Ο€ = x := ⟨fun h => ⟨⌊x / Ο€βŒ‹, le_antisymm (sub_nonneg.1 (Int.sub_floor_div_mul_nonneg _ pi_pos)) (sub_nonpos.1 <| le_of_not_gt fun h₃ => (sin_pos_of_pos_of_lt_pi h₃ (Int.sub_floor_div_mul_lt _ pi_pos)).ne (by simp [sub_eq_add_neg, sin_add, h, sin_int_mul_pi]))⟩, fun ⟨n, hn⟩ => hn β–Έ sin_int_mul_pi _⟩ #align real.sin_eq_zero_iff Real.sin_eq_zero_iff theorem sin_ne_zero_iff {x : ℝ} : sin x β‰  0 ↔ βˆ€ n : β„€, (n : ℝ) * Ο€ β‰  x := by rw [← not_exists, not_iff_not, sin_eq_zero_iff] #align real.sin_ne_zero_iff Real.sin_ne_zero_iff theorem sin_eq_zero_iff_cos_eq {x : ℝ} : sin x = 0 ↔ cos x = 1 ∨ cos x = -1 := by rw [← mul_self_eq_one_iff, ← sin_sq_add_cos_sq x, sq, sq, ← sub_eq_iff_eq_add, sub_self] exact ⟨fun h => by rw [h, mul_zero], eq_zero_of_mul_self_eq_zero ∘ Eq.symm⟩ #align real.sin_eq_zero_iff_cos_eq Real.sin_eq_zero_iff_cos_eq theorem cos_eq_one_iff (x : ℝ) : cos x = 1 ↔ βˆƒ n : β„€, (n : ℝ) * (2 * Ο€) = x := ⟨fun h => let ⟨n, hn⟩ := sin_eq_zero_iff.1 (sin_eq_zero_iff_cos_eq.2 (Or.inl h)) ⟨n / 2, (Int.emod_two_eq_zero_or_one n).elim (fun hn0 => by rwa [← mul_assoc, ← @Int.cast_two ℝ, ← Int.cast_mul, Int.ediv_mul_cancel ((Int.dvd_iff_emod_eq_zero _ _).2 hn0)]) fun hn1 => by rw [← Int.emod_add_ediv n 2, hn1, Int.cast_add, Int.cast_one, add_mul, one_mul, add_comm, mul_comm (2 : β„€), Int.cast_mul, mul_assoc, Int.cast_two] at hn rw [← hn, cos_int_mul_two_pi_add_pi] at h exact absurd h (by norm_num)⟩, fun ⟨n, hn⟩ => hn β–Έ cos_int_mul_two_pi _⟩ #align real.cos_eq_one_iff Real.cos_eq_one_iff theorem cos_eq_one_iff_of_lt_of_lt {x : ℝ} (hx₁ : -(2 * Ο€) < x) (hxβ‚‚ : x < 2 * Ο€) : cos x = 1 ↔ x = 0 := ⟨fun h => by rcases (cos_eq_one_iff _).1 h with ⟨n, rfl⟩ rw [mul_lt_iff_lt_one_left two_pi_pos] at hxβ‚‚ rw [neg_lt, neg_mul_eq_neg_mul, mul_lt_iff_lt_one_left two_pi_pos] at hx₁ norm_cast at hx₁ hxβ‚‚ obtain rfl : n = 0 := le_antisymm (by omega) (by omega) simp, fun h => by simp [h]⟩ #align real.cos_eq_one_iff_of_lt_of_lt Real.cos_eq_one_iff_of_lt_of_lt theorem sin_lt_sin_of_lt_of_le_pi_div_two {x y : ℝ} (hx₁ : -(Ο€ / 2) ≀ x) (hyβ‚‚ : y ≀ Ο€ / 2) (hxy : x < y) : sin x < sin y := by rw [← sub_pos, sin_sub_sin] have : 0 < sin ((y - x) / 2) := by apply sin_pos_of_pos_of_lt_pi <;> linarith have : 0 < cos ((y + x) / 2) := by refine cos_pos_of_mem_Ioo ⟨?_, ?_⟩ <;> linarith positivity #align real.sin_lt_sin_of_lt_of_le_pi_div_two Real.sin_lt_sin_of_lt_of_le_pi_div_two theorem strictMonoOn_sin : StrictMonoOn sin (Icc (-(Ο€ / 2)) (Ο€ / 2)) := fun _ hx _ hy hxy => sin_lt_sin_of_lt_of_le_pi_div_two hx.1 hy.2 hxy #align real.strict_mono_on_sin Real.strictMonoOn_sin theorem cos_lt_cos_of_nonneg_of_le_pi {x y : ℝ} (hx₁ : 0 ≀ x) (hyβ‚‚ : y ≀ Ο€) (hxy : x < y) : cos y < cos x := by rw [← sin_pi_div_two_sub, ← sin_pi_div_two_sub] apply sin_lt_sin_of_lt_of_le_pi_div_two <;> linarith #align real.cos_lt_cos_of_nonneg_of_le_pi Real.cos_lt_cos_of_nonneg_of_le_pi theorem cos_lt_cos_of_nonneg_of_le_pi_div_two {x y : ℝ} (hx₁ : 0 ≀ x) (hyβ‚‚ : y ≀ Ο€ / 2) (hxy : x < y) : cos y < cos x := cos_lt_cos_of_nonneg_of_le_pi hx₁ (hyβ‚‚.trans (by linarith)) hxy #align real.cos_lt_cos_of_nonneg_of_le_pi_div_two Real.cos_lt_cos_of_nonneg_of_le_pi_div_two theorem strictAntiOn_cos : StrictAntiOn cos (Icc 0 Ο€) := fun _ hx _ hy hxy => cos_lt_cos_of_nonneg_of_le_pi hx.1 hy.2 hxy #align real.strict_anti_on_cos Real.strictAntiOn_cos theorem cos_le_cos_of_nonneg_of_le_pi {x y : ℝ} (hx₁ : 0 ≀ x) (hyβ‚‚ : y ≀ Ο€) (hxy : x ≀ y) : cos y ≀ cos x := (strictAntiOn_cos.le_iff_le ⟨hx₁.trans hxy, hyβ‚‚βŸ© ⟨hx₁, hxy.trans hyβ‚‚βŸ©).2 hxy #align real.cos_le_cos_of_nonneg_of_le_pi Real.cos_le_cos_of_nonneg_of_le_pi theorem sin_le_sin_of_le_of_le_pi_div_two {x y : ℝ} (hx₁ : -(Ο€ / 2) ≀ x) (hyβ‚‚ : y ≀ Ο€ / 2) (hxy : x ≀ y) : sin x ≀ sin y := (strictMonoOn_sin.le_iff_le ⟨hx₁, hxy.trans hyβ‚‚βŸ© ⟨hx₁.trans hxy, hyβ‚‚βŸ©).2 hxy #align real.sin_le_sin_of_le_of_le_pi_div_two Real.sin_le_sin_of_le_of_le_pi_div_two theorem injOn_sin : InjOn sin (Icc (-(Ο€ / 2)) (Ο€ / 2)) := strictMonoOn_sin.injOn #align real.inj_on_sin Real.injOn_sin theorem injOn_cos : InjOn cos (Icc 0 Ο€) := strictAntiOn_cos.injOn #align real.inj_on_cos Real.injOn_cos theorem surjOn_sin : SurjOn sin (Icc (-(Ο€ / 2)) (Ο€ / 2)) (Icc (-1) 1) := by simpa only [sin_neg, sin_pi_div_two] using intermediate_value_Icc (neg_le_self pi_div_two_pos.le) continuous_sin.continuousOn #align real.surj_on_sin Real.surjOn_sin theorem surjOn_cos : SurjOn cos (Icc 0 Ο€) (Icc (-1) 1) := by simpa only [cos_zero, cos_pi] using intermediate_value_Icc' pi_pos.le continuous_cos.continuousOn #align real.surj_on_cos Real.surjOn_cos theorem sin_mem_Icc (x : ℝ) : sin x ∈ Icc (-1 : ℝ) 1 := ⟨neg_one_le_sin x, sin_le_one x⟩ #align real.sin_mem_Icc Real.sin_mem_Icc theorem cos_mem_Icc (x : ℝ) : cos x ∈ Icc (-1 : ℝ) 1 := ⟨neg_one_le_cos x, cos_le_one x⟩ #align real.cos_mem_Icc Real.cos_mem_Icc theorem mapsTo_sin (s : Set ℝ) : MapsTo sin s (Icc (-1 : ℝ) 1) := fun x _ => sin_mem_Icc x #align real.maps_to_sin Real.mapsTo_sin theorem mapsTo_cos (s : Set ℝ) : MapsTo cos s (Icc (-1 : ℝ) 1) := fun x _ => cos_mem_Icc x #align real.maps_to_cos Real.mapsTo_cos theorem bijOn_sin : BijOn sin (Icc (-(Ο€ / 2)) (Ο€ / 2)) (Icc (-1) 1) := ⟨mapsTo_sin _, injOn_sin, surjOn_sin⟩ #align real.bij_on_sin Real.bijOn_sin theorem bijOn_cos : BijOn cos (Icc 0 Ο€) (Icc (-1) 1) := ⟨mapsTo_cos _, injOn_cos, surjOn_cos⟩ #align real.bij_on_cos Real.bijOn_cos @[simp] theorem range_cos : range cos = (Icc (-1) 1 : Set ℝ) := Subset.antisymm (range_subset_iff.2 cos_mem_Icc) surjOn_cos.subset_range #align real.range_cos Real.range_cos @[simp] theorem range_sin : range sin = (Icc (-1) 1 : Set ℝ) := Subset.antisymm (range_subset_iff.2 sin_mem_Icc) surjOn_sin.subset_range #align real.range_sin Real.range_sin theorem range_cos_infinite : (range Real.cos).Infinite := by rw [Real.range_cos] exact Icc_infinite (by norm_num) #align real.range_cos_infinite Real.range_cos_infinite theorem range_sin_infinite : (range Real.sin).Infinite := by rw [Real.range_sin] exact Icc_infinite (by norm_num) #align real.range_sin_infinite Real.range_sin_infinite section CosDivSq variable (x : ℝ) @[simp] noncomputable def sqrtTwoAddSeries (x : ℝ) : β„• β†’ ℝ | 0 => x | n + 1 => √(2 + sqrtTwoAddSeries x n) #align real.sqrt_two_add_series Real.sqrtTwoAddSeries theorem sqrtTwoAddSeries_zero : sqrtTwoAddSeries x 0 = x := by simp #align real.sqrt_two_add_series_zero Real.sqrtTwoAddSeries_zero theorem sqrtTwoAddSeries_one : sqrtTwoAddSeries 0 1 = √2 := by simp #align real.sqrt_two_add_series_one Real.sqrtTwoAddSeries_one theorem sqrtTwoAddSeries_two : sqrtTwoAddSeries 0 2 = √(2 + √2) := by simp #align real.sqrt_two_add_series_two Real.sqrtTwoAddSeries_two theorem sqrtTwoAddSeries_zero_nonneg : βˆ€ n : β„•, 0 ≀ sqrtTwoAddSeries 0 n | 0 => le_refl 0 | _ + 1 => sqrt_nonneg _ #align real.sqrt_two_add_series_zero_nonneg Real.sqrtTwoAddSeries_zero_nonneg theorem sqrtTwoAddSeries_nonneg {x : ℝ} (h : 0 ≀ x) : βˆ€ n : β„•, 0 ≀ sqrtTwoAddSeries x n | 0 => h | _ + 1 => sqrt_nonneg _ #align real.sqrt_two_add_series_nonneg Real.sqrtTwoAddSeries_nonneg theorem sqrtTwoAddSeries_lt_two : βˆ€ n : β„•, sqrtTwoAddSeries 0 n < 2 | 0 => by norm_num | n + 1 => by refine lt_of_lt_of_le ?_ (sqrt_sq zero_lt_two.le).le rw [sqrtTwoAddSeries, sqrt_lt_sqrt_iff, ← lt_sub_iff_add_lt'] Β· refine (sqrtTwoAddSeries_lt_two n).trans_le ?_ norm_num Β· exact add_nonneg zero_le_two (sqrtTwoAddSeries_zero_nonneg n) #align real.sqrt_two_add_series_lt_two Real.sqrtTwoAddSeries_lt_two theorem sqrtTwoAddSeries_succ (x : ℝ) : βˆ€ n : β„•, sqrtTwoAddSeries x (n + 1) = sqrtTwoAddSeries (√(2 + x)) n | 0 => rfl | n + 1 => by rw [sqrtTwoAddSeries, sqrtTwoAddSeries_succ _ _, sqrtTwoAddSeries] #align real.sqrt_two_add_series_succ Real.sqrtTwoAddSeries_succ theorem sqrtTwoAddSeries_monotone_left {x y : ℝ} (h : x ≀ y) : βˆ€ n : β„•, sqrtTwoAddSeries x n ≀ sqrtTwoAddSeries y n | 0 => h | n + 1 => by rw [sqrtTwoAddSeries, sqrtTwoAddSeries] exact sqrt_le_sqrt (add_le_add_left (sqrtTwoAddSeries_monotone_left h _) _) #align real.sqrt_two_add_series_monotone_left Real.sqrtTwoAddSeries_monotone_left @[simp] theorem cos_pi_over_two_pow : βˆ€ n : β„•, cos (Ο€ / 2 ^ (n + 1)) = sqrtTwoAddSeries 0 n / 2 | 0 => by simp | n + 1 => by have A : (1 : ℝ) < 2 ^ (n + 1) := one_lt_pow one_lt_two n.succ_ne_zero have B : Ο€ / 2 ^ (n + 1) < Ο€ := div_lt_self pi_pos A have C : 0 < Ο€ / 2 ^ (n + 1) := by positivity rw [pow_succ, div_mul_eq_div_div, cos_half, cos_pi_over_two_pow n, sqrtTwoAddSeries, add_div_eq_mul_add_div, one_mul, ← div_mul_eq_div_div, sqrt_div, sqrt_mul_self] <;> linarith [sqrtTwoAddSeries_nonneg le_rfl n] #align real.cos_pi_over_two_pow Real.cos_pi_over_two_pow theorem sin_sq_pi_over_two_pow (n : β„•) : sin (Ο€ / 2 ^ (n + 1)) ^ 2 = 1 - (sqrtTwoAddSeries 0 n / 2) ^ 2 := by rw [sin_sq, cos_pi_over_two_pow] #align real.sin_sq_pi_over_two_pow Real.sin_sq_pi_over_two_pow theorem sin_sq_pi_over_two_pow_succ (n : β„•) : sin (Ο€ / 2 ^ (n + 2)) ^ 2 = 1 / 2 - sqrtTwoAddSeries 0 n / 4 := by rw [sin_sq_pi_over_two_pow, sqrtTwoAddSeries, div_pow, sq_sqrt, add_div, ← sub_sub] Β· congr Β· norm_num Β· norm_num Β· exact add_nonneg two_pos.le (sqrtTwoAddSeries_zero_nonneg _) #align real.sin_sq_pi_over_two_pow_succ Real.sin_sq_pi_over_two_pow_succ @[simp] theorem sin_pi_over_two_pow_succ (n : β„•) : sin (Ο€ / 2 ^ (n + 2)) = √(2 - sqrtTwoAddSeries 0 n) / 2 := by rw [eq_div_iff_mul_eq two_ne_zero, eq_comm, sqrt_eq_iff_sq_eq, mul_pow, sin_sq_pi_over_two_pow_succ, sub_mul] Β· congr <;> norm_num Β· rw [sub_nonneg] exact (sqrtTwoAddSeries_lt_two _).le refine mul_nonneg (sin_nonneg_of_nonneg_of_le_pi ?_ ?_) zero_le_two Β· positivity Β· exact div_le_self pi_pos.le <| one_le_pow_of_one_le one_le_two _ #align real.sin_pi_over_two_pow_succ Real.sin_pi_over_two_pow_succ @[simp] theorem cos_pi_div_four : cos (Ο€ / 4) = √2 / 2 := by trans cos (Ο€ / 2 ^ 2) Β· congr norm_num Β· simp #align real.cos_pi_div_four Real.cos_pi_div_four @[simp] theorem sin_pi_div_four : sin (Ο€ / 4) = √2 / 2 := by trans sin (Ο€ / 2 ^ 2) Β· congr norm_num Β· simp #align real.sin_pi_div_four Real.sin_pi_div_four @[simp] theorem cos_pi_div_eight : cos (Ο€ / 8) = √(2 + √2) / 2 := by trans cos (Ο€ / 2 ^ 3) Β· congr norm_num Β· simp #align real.cos_pi_div_eight Real.cos_pi_div_eight @[simp] theorem sin_pi_div_eight : sin (Ο€ / 8) = √(2 - √2) / 2 := by trans sin (Ο€ / 2 ^ 3) Β· congr norm_num Β· simp #align real.sin_pi_div_eight Real.sin_pi_div_eight @[simp] theorem cos_pi_div_sixteen : cos (Ο€ / 16) = √(2 + √(2 + √2)) / 2 := by trans cos (Ο€ / 2 ^ 4) Β· congr norm_num Β· simp #align real.cos_pi_div_sixteen Real.cos_pi_div_sixteen @[simp] theorem sin_pi_div_sixteen : sin (Ο€ / 16) = √(2 - √(2 + √2)) / 2 := by trans sin (Ο€ / 2 ^ 4) Β· congr norm_num Β· simp #align real.sin_pi_div_sixteen Real.sin_pi_div_sixteen @[simp]
Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean
867
871
theorem cos_pi_div_thirty_two : cos (Ο€ / 32) = √(2 + √(2 + √(2 + √2))) / 2 := by
trans cos (Ο€ / 2 ^ 5) Β· congr norm_num Β· simp
import Mathlib.Algebra.Group.Equiv.Basic import Mathlib.Algebra.Group.Aut import Mathlib.Data.ZMod.Defs import Mathlib.Tactic.Ring #align_import algebra.quandle from "leanprover-community/mathlib"@"28aa996fc6fb4317f0083c4e6daf79878d81be33" open MulOpposite universe u v class Shelf (Ξ± : Type u) where act : Ξ± β†’ Ξ± β†’ Ξ± self_distrib : βˆ€ {x y z : Ξ±}, act x (act y z) = act (act x y) (act x z) #align shelf Shelf class UnitalShelf (Ξ± : Type u) extends Shelf Ξ±, One Ξ± := (one_act : βˆ€ a : Ξ±, act 1 a = a) (act_one : βˆ€ a : Ξ±, act a 1 = a) #align unital_shelf UnitalShelf @[ext] structure ShelfHom (S₁ : Type*) (Sβ‚‚ : Type*) [Shelf S₁] [Shelf Sβ‚‚] where toFun : S₁ β†’ Sβ‚‚ map_act' : βˆ€ {x y : S₁}, toFun (Shelf.act x y) = Shelf.act (toFun x) (toFun y) #align shelf_hom ShelfHom #align shelf_hom.ext_iff ShelfHom.ext_iff #align shelf_hom.ext ShelfHom.ext class Rack (Ξ± : Type u) extends Shelf Ξ± where invAct : Ξ± β†’ Ξ± β†’ Ξ± left_inv : βˆ€ x, Function.LeftInverse (invAct x) (act x) right_inv : βˆ€ x, Function.RightInverse (invAct x) (act x) #align rack Rack scoped[Quandles] infixr:65 " β—ƒ " => Shelf.act scoped[Quandles] infixr:65 " ◃⁻¹ " => Rack.invAct scoped[Quandles] infixr:25 " β†’β—ƒ " => ShelfHom open Quandles namespace Rack variable {R : Type*} [Rack R] -- Porting note: No longer a need for `Rack.self_distrib` export Shelf (self_distrib) -- porting note, changed name to `act'` to not conflict with `Shelf.act` def act' (x : R) : R ≃ R where toFun := Shelf.act x invFun := invAct x left_inv := left_inv x right_inv := right_inv x #align rack.act Rack.act' @[simp] theorem act'_apply (x y : R) : act' x y = x β—ƒ y := rfl #align rack.act_apply Rack.act'_apply @[simp] theorem act'_symm_apply (x y : R) : (act' x).symm y = x ◃⁻¹ y := rfl #align rack.act_symm_apply Rack.act'_symm_apply @[simp] theorem invAct_apply (x y : R) : (act' x)⁻¹ y = x ◃⁻¹ y := rfl #align rack.inv_act_apply Rack.invAct_apply @[simp] theorem invAct_act_eq (x y : R) : x ◃⁻¹ x β—ƒ y = y := left_inv x y #align rack.inv_act_act_eq Rack.invAct_act_eq @[simp] theorem act_invAct_eq (x y : R) : x β—ƒ x ◃⁻¹ y = y := right_inv x y #align rack.act_inv_act_eq Rack.act_invAct_eq theorem left_cancel (x : R) {y y' : R} : x β—ƒ y = x β—ƒ y' ↔ y = y' := by constructor Β· apply (act' x).injective rintro rfl rfl #align rack.left_cancel Rack.left_cancel
Mathlib/Algebra/Quandle.lean
232
236
theorem left_cancel_inv (x : R) {y y' : R} : x ◃⁻¹ y = x ◃⁻¹ y' ↔ y = y' := by
constructor Β· apply (act' x).symm.injective rintro rfl rfl
import Mathlib.Analysis.SpecialFunctions.Exp import Mathlib.Tactic.Positivity.Core import Mathlib.Algebra.Ring.NegOnePow #align_import analysis.special_functions.trigonometric.basic from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" noncomputable section open scoped Classical open Topology Filter Set namespace Real open Real @[simp] theorem sin_pi : sin Ο€ = 0 := by rw [← mul_div_cancel_leftβ‚€ Ο€ (two_ne_zero' ℝ), two_mul, add_div, sin_add, cos_pi_div_two]; simp #align real.sin_pi Real.sin_pi @[simp] theorem cos_pi : cos Ο€ = -1 := by rw [← mul_div_cancel_leftβ‚€ Ο€ (two_ne_zero' ℝ), mul_div_assoc, cos_two_mul, cos_pi_div_two] norm_num #align real.cos_pi Real.cos_pi @[simp] theorem sin_two_pi : sin (2 * Ο€) = 0 := by simp [two_mul, sin_add] #align real.sin_two_pi Real.sin_two_pi @[simp] theorem cos_two_pi : cos (2 * Ο€) = 1 := by simp [two_mul, cos_add] #align real.cos_two_pi Real.cos_two_pi theorem sin_antiperiodic : Function.Antiperiodic sin Ο€ := by simp [sin_add] #align real.sin_antiperiodic Real.sin_antiperiodic theorem sin_periodic : Function.Periodic sin (2 * Ο€) := sin_antiperiodic.periodic_two_mul #align real.sin_periodic Real.sin_periodic @[simp] theorem sin_add_pi (x : ℝ) : sin (x + Ο€) = -sin x := sin_antiperiodic x #align real.sin_add_pi Real.sin_add_pi @[simp] theorem sin_add_two_pi (x : ℝ) : sin (x + 2 * Ο€) = sin x := sin_periodic x #align real.sin_add_two_pi Real.sin_add_two_pi @[simp] theorem sin_sub_pi (x : ℝ) : sin (x - Ο€) = -sin x := sin_antiperiodic.sub_eq x #align real.sin_sub_pi Real.sin_sub_pi @[simp] theorem sin_sub_two_pi (x : ℝ) : sin (x - 2 * Ο€) = sin x := sin_periodic.sub_eq x #align real.sin_sub_two_pi Real.sin_sub_two_pi @[simp] theorem sin_pi_sub (x : ℝ) : sin (Ο€ - x) = sin x := neg_neg (sin x) β–Έ sin_neg x β–Έ sin_antiperiodic.sub_eq' #align real.sin_pi_sub Real.sin_pi_sub @[simp] theorem sin_two_pi_sub (x : ℝ) : sin (2 * Ο€ - x) = -sin x := sin_neg x β–Έ sin_periodic.sub_eq' #align real.sin_two_pi_sub Real.sin_two_pi_sub @[simp] theorem sin_nat_mul_pi (n : β„•) : sin (n * Ο€) = 0 := sin_antiperiodic.nat_mul_eq_of_eq_zero sin_zero n #align real.sin_nat_mul_pi Real.sin_nat_mul_pi @[simp] theorem sin_int_mul_pi (n : β„€) : sin (n * Ο€) = 0 := sin_antiperiodic.int_mul_eq_of_eq_zero sin_zero n #align real.sin_int_mul_pi Real.sin_int_mul_pi @[simp] theorem sin_add_nat_mul_two_pi (x : ℝ) (n : β„•) : sin (x + n * (2 * Ο€)) = sin x := sin_periodic.nat_mul n x #align real.sin_add_nat_mul_two_pi Real.sin_add_nat_mul_two_pi @[simp] theorem sin_add_int_mul_two_pi (x : ℝ) (n : β„€) : sin (x + n * (2 * Ο€)) = sin x := sin_periodic.int_mul n x #align real.sin_add_int_mul_two_pi Real.sin_add_int_mul_two_pi @[simp] theorem sin_sub_nat_mul_two_pi (x : ℝ) (n : β„•) : sin (x - n * (2 * Ο€)) = sin x := sin_periodic.sub_nat_mul_eq n #align real.sin_sub_nat_mul_two_pi Real.sin_sub_nat_mul_two_pi @[simp] theorem sin_sub_int_mul_two_pi (x : ℝ) (n : β„€) : sin (x - n * (2 * Ο€)) = sin x := sin_periodic.sub_int_mul_eq n #align real.sin_sub_int_mul_two_pi Real.sin_sub_int_mul_two_pi @[simp] theorem sin_nat_mul_two_pi_sub (x : ℝ) (n : β„•) : sin (n * (2 * Ο€) - x) = -sin x := sin_neg x β–Έ sin_periodic.nat_mul_sub_eq n #align real.sin_nat_mul_two_pi_sub Real.sin_nat_mul_two_pi_sub @[simp] theorem sin_int_mul_two_pi_sub (x : ℝ) (n : β„€) : sin (n * (2 * Ο€) - x) = -sin x := sin_neg x β–Έ sin_periodic.int_mul_sub_eq n #align real.sin_int_mul_two_pi_sub Real.sin_int_mul_two_pi_sub theorem sin_add_int_mul_pi (x : ℝ) (n : β„€) : sin (x + n * Ο€) = (-1) ^ n * sin x := n.coe_negOnePow ℝ β–Έ sin_antiperiodic.add_int_mul_eq n theorem sin_add_nat_mul_pi (x : ℝ) (n : β„•) : sin (x + n * Ο€) = (-1) ^ n * sin x := sin_antiperiodic.add_nat_mul_eq n theorem sin_sub_int_mul_pi (x : ℝ) (n : β„€) : sin (x - n * Ο€) = (-1) ^ n * sin x := n.coe_negOnePow ℝ β–Έ sin_antiperiodic.sub_int_mul_eq n theorem sin_sub_nat_mul_pi (x : ℝ) (n : β„•) : sin (x - n * Ο€) = (-1) ^ n * sin x := sin_antiperiodic.sub_nat_mul_eq n theorem sin_int_mul_pi_sub (x : ℝ) (n : β„€) : sin (n * Ο€ - x) = -((-1) ^ n * sin x) := by simpa only [sin_neg, mul_neg, Int.coe_negOnePow] using sin_antiperiodic.int_mul_sub_eq n theorem sin_nat_mul_pi_sub (x : ℝ) (n : β„•) : sin (n * Ο€ - x) = -((-1) ^ n * sin x) := by simpa only [sin_neg, mul_neg] using sin_antiperiodic.nat_mul_sub_eq n theorem cos_antiperiodic : Function.Antiperiodic cos Ο€ := by simp [cos_add] #align real.cos_antiperiodic Real.cos_antiperiodic theorem cos_periodic : Function.Periodic cos (2 * Ο€) := cos_antiperiodic.periodic_two_mul #align real.cos_periodic Real.cos_periodic @[simp] theorem cos_add_pi (x : ℝ) : cos (x + Ο€) = -cos x := cos_antiperiodic x #align real.cos_add_pi Real.cos_add_pi @[simp] theorem cos_add_two_pi (x : ℝ) : cos (x + 2 * Ο€) = cos x := cos_periodic x #align real.cos_add_two_pi Real.cos_add_two_pi @[simp] theorem cos_sub_pi (x : ℝ) : cos (x - Ο€) = -cos x := cos_antiperiodic.sub_eq x #align real.cos_sub_pi Real.cos_sub_pi @[simp] theorem cos_sub_two_pi (x : ℝ) : cos (x - 2 * Ο€) = cos x := cos_periodic.sub_eq x #align real.cos_sub_two_pi Real.cos_sub_two_pi @[simp] theorem cos_pi_sub (x : ℝ) : cos (Ο€ - x) = -cos x := cos_neg x β–Έ cos_antiperiodic.sub_eq' #align real.cos_pi_sub Real.cos_pi_sub @[simp] theorem cos_two_pi_sub (x : ℝ) : cos (2 * Ο€ - x) = cos x := cos_neg x β–Έ cos_periodic.sub_eq' #align real.cos_two_pi_sub Real.cos_two_pi_sub @[simp] theorem cos_nat_mul_two_pi (n : β„•) : cos (n * (2 * Ο€)) = 1 := (cos_periodic.nat_mul_eq n).trans cos_zero #align real.cos_nat_mul_two_pi Real.cos_nat_mul_two_pi @[simp] theorem cos_int_mul_two_pi (n : β„€) : cos (n * (2 * Ο€)) = 1 := (cos_periodic.int_mul_eq n).trans cos_zero #align real.cos_int_mul_two_pi Real.cos_int_mul_two_pi @[simp] theorem cos_add_nat_mul_two_pi (x : ℝ) (n : β„•) : cos (x + n * (2 * Ο€)) = cos x := cos_periodic.nat_mul n x #align real.cos_add_nat_mul_two_pi Real.cos_add_nat_mul_two_pi @[simp] theorem cos_add_int_mul_two_pi (x : ℝ) (n : β„€) : cos (x + n * (2 * Ο€)) = cos x := cos_periodic.int_mul n x #align real.cos_add_int_mul_two_pi Real.cos_add_int_mul_two_pi @[simp] theorem cos_sub_nat_mul_two_pi (x : ℝ) (n : β„•) : cos (x - n * (2 * Ο€)) = cos x := cos_periodic.sub_nat_mul_eq n #align real.cos_sub_nat_mul_two_pi Real.cos_sub_nat_mul_two_pi @[simp] theorem cos_sub_int_mul_two_pi (x : ℝ) (n : β„€) : cos (x - n * (2 * Ο€)) = cos x := cos_periodic.sub_int_mul_eq n #align real.cos_sub_int_mul_two_pi Real.cos_sub_int_mul_two_pi @[simp] theorem cos_nat_mul_two_pi_sub (x : ℝ) (n : β„•) : cos (n * (2 * Ο€) - x) = cos x := cos_neg x β–Έ cos_periodic.nat_mul_sub_eq n #align real.cos_nat_mul_two_pi_sub Real.cos_nat_mul_two_pi_sub @[simp] theorem cos_int_mul_two_pi_sub (x : ℝ) (n : β„€) : cos (n * (2 * Ο€) - x) = cos x := cos_neg x β–Έ cos_periodic.int_mul_sub_eq n #align real.cos_int_mul_two_pi_sub Real.cos_int_mul_two_pi_sub theorem cos_add_int_mul_pi (x : ℝ) (n : β„€) : cos (x + n * Ο€) = (-1) ^ n * cos x := n.coe_negOnePow ℝ β–Έ cos_antiperiodic.add_int_mul_eq n theorem cos_add_nat_mul_pi (x : ℝ) (n : β„•) : cos (x + n * Ο€) = (-1) ^ n * cos x := cos_antiperiodic.add_nat_mul_eq n theorem cos_sub_int_mul_pi (x : ℝ) (n : β„€) : cos (x - n * Ο€) = (-1) ^ n * cos x := n.coe_negOnePow ℝ β–Έ cos_antiperiodic.sub_int_mul_eq n theorem cos_sub_nat_mul_pi (x : ℝ) (n : β„•) : cos (x - n * Ο€) = (-1) ^ n * cos x := cos_antiperiodic.sub_nat_mul_eq n theorem cos_int_mul_pi_sub (x : ℝ) (n : β„€) : cos (n * Ο€ - x) = (-1) ^ n * cos x := n.coe_negOnePow ℝ β–Έ cos_neg x β–Έ cos_antiperiodic.int_mul_sub_eq n theorem cos_nat_mul_pi_sub (x : ℝ) (n : β„•) : cos (n * Ο€ - x) = (-1) ^ n * cos x := cos_neg x β–Έ cos_antiperiodic.nat_mul_sub_eq n -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_nat_mul_two_pi_add_pi (n : β„•) : cos (n * (2 * Ο€) + Ο€) = -1 := by simpa only [cos_zero] using (cos_periodic.nat_mul n).add_antiperiod_eq cos_antiperiodic #align real.cos_nat_mul_two_pi_add_pi Real.cos_nat_mul_two_pi_add_pi -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_int_mul_two_pi_add_pi (n : β„€) : cos (n * (2 * Ο€) + Ο€) = -1 := by simpa only [cos_zero] using (cos_periodic.int_mul n).add_antiperiod_eq cos_antiperiodic #align real.cos_int_mul_two_pi_add_pi Real.cos_int_mul_two_pi_add_pi -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_nat_mul_two_pi_sub_pi (n : β„•) : cos (n * (2 * Ο€) - Ο€) = -1 := by simpa only [cos_zero] using (cos_periodic.nat_mul n).sub_antiperiod_eq cos_antiperiodic #align real.cos_nat_mul_two_pi_sub_pi Real.cos_nat_mul_two_pi_sub_pi -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_int_mul_two_pi_sub_pi (n : β„€) : cos (n * (2 * Ο€) - Ο€) = -1 := by simpa only [cos_zero] using (cos_periodic.int_mul n).sub_antiperiod_eq cos_antiperiodic #align real.cos_int_mul_two_pi_sub_pi Real.cos_int_mul_two_pi_sub_pi theorem sin_pos_of_pos_of_lt_pi {x : ℝ} (h0x : 0 < x) (hxp : x < Ο€) : 0 < sin x := if hx2 : x ≀ 2 then sin_pos_of_pos_of_le_two h0x hx2 else have : (2 : ℝ) + 2 = 4 := by norm_num have : Ο€ - x ≀ 2 := sub_le_iff_le_add.2 (le_trans pi_le_four (this β–Έ add_le_add_left (le_of_not_ge hx2) _)) sin_pi_sub x β–Έ sin_pos_of_pos_of_le_two (sub_pos.2 hxp) this #align real.sin_pos_of_pos_of_lt_pi Real.sin_pos_of_pos_of_lt_pi theorem sin_pos_of_mem_Ioo {x : ℝ} (hx : x ∈ Ioo 0 Ο€) : 0 < sin x := sin_pos_of_pos_of_lt_pi hx.1 hx.2 #align real.sin_pos_of_mem_Ioo Real.sin_pos_of_mem_Ioo theorem sin_nonneg_of_mem_Icc {x : ℝ} (hx : x ∈ Icc 0 Ο€) : 0 ≀ sin x := by rw [← closure_Ioo pi_ne_zero.symm] at hx exact closure_lt_subset_le continuous_const continuous_sin (closure_mono (fun y => sin_pos_of_mem_Ioo) hx) #align real.sin_nonneg_of_mem_Icc Real.sin_nonneg_of_mem_Icc theorem sin_nonneg_of_nonneg_of_le_pi {x : ℝ} (h0x : 0 ≀ x) (hxp : x ≀ Ο€) : 0 ≀ sin x := sin_nonneg_of_mem_Icc ⟨h0x, hxp⟩ #align real.sin_nonneg_of_nonneg_of_le_pi Real.sin_nonneg_of_nonneg_of_le_pi theorem sin_neg_of_neg_of_neg_pi_lt {x : ℝ} (hx0 : x < 0) (hpx : -Ο€ < x) : sin x < 0 := neg_pos.1 <| sin_neg x β–Έ sin_pos_of_pos_of_lt_pi (neg_pos.2 hx0) (neg_lt.1 hpx) #align real.sin_neg_of_neg_of_neg_pi_lt Real.sin_neg_of_neg_of_neg_pi_lt theorem sin_nonpos_of_nonnpos_of_neg_pi_le {x : ℝ} (hx0 : x ≀ 0) (hpx : -Ο€ ≀ x) : sin x ≀ 0 := neg_nonneg.1 <| sin_neg x β–Έ sin_nonneg_of_nonneg_of_le_pi (neg_nonneg.2 hx0) (neg_le.1 hpx) #align real.sin_nonpos_of_nonnpos_of_neg_pi_le Real.sin_nonpos_of_nonnpos_of_neg_pi_le @[simp] theorem sin_pi_div_two : sin (Ο€ / 2) = 1 := have : sin (Ο€ / 2) = 1 ∨ sin (Ο€ / 2) = -1 := by simpa [sq, mul_self_eq_one_iff] using sin_sq_add_cos_sq (Ο€ / 2) this.resolve_right fun h => show Β¬(0 : ℝ) < -1 by norm_num <| h β–Έ sin_pos_of_pos_of_lt_pi pi_div_two_pos (half_lt_self pi_pos) #align real.sin_pi_div_two Real.sin_pi_div_two
Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean
502
502
theorem sin_add_pi_div_two (x : ℝ) : sin (x + Ο€ / 2) = cos x := by
simp [sin_add]
import Mathlib.Order.ConditionallyCompleteLattice.Basic import Mathlib.Data.Set.Finite #align_import order.conditionally_complete_lattice.finset from "leanprover-community/mathlib"@"2445c98ae4b87eabebdde552593519b9b6dc350c" open Set variable {ΞΉ Ξ± Ξ² Ξ³ : Type*} section ConditionallyCompleteLinearOrder variable [ConditionallyCompleteLinearOrder Ξ±] {s t : Set Ξ±} {a b : Ξ±} theorem Finset.Nonempty.csSup_eq_max' {s : Finset Ξ±} (h : s.Nonempty) : sSup ↑s = s.max' h := eq_of_forall_ge_iff fun _ => (csSup_le_iff s.bddAbove h.to_set).trans (s.max'_le_iff h).symm #align finset.nonempty.cSup_eq_max' Finset.Nonempty.csSup_eq_max' theorem Finset.Nonempty.csInf_eq_min' {s : Finset Ξ±} (h : s.Nonempty) : sInf ↑s = s.min' h := @Finset.Nonempty.csSup_eq_max' Ξ±α΅’α΅ˆ _ s h #align finset.nonempty.cInf_eq_min' Finset.Nonempty.csInf_eq_min'
Mathlib/Order/ConditionallyCompleteLattice/Finset.lean
33
35
theorem Finset.Nonempty.csSup_mem {s : Finset α} (h : s.Nonempty) : sSup (s : Set α) ∈ s := by
rw [h.csSup_eq_max'] exact s.max'_mem _
import Mathlib.Data.Nat.Lattice import Mathlib.Logic.Denumerable import Mathlib.Logic.Function.Iterate import Mathlib.Order.Hom.Basic import Mathlib.Data.Set.Subsingleton #align_import order.order_iso_nat from "leanprover-community/mathlib"@"210657c4ea4a4a7b234392f70a3a2a83346dfa90" variable {Ξ± : Type*} namespace RelEmbedding variable {r : Ξ± β†’ Ξ± β†’ Prop} [IsStrictOrder Ξ± r] def natLT (f : β„• β†’ Ξ±) (H : βˆ€ n : β„•, r (f n) (f (n + 1))) : ((Β· < Β·) : β„• β†’ β„• β†’ Prop) β†ͺr r := ofMonotone f <| Nat.rel_of_forall_rel_succ_of_lt r H #align rel_embedding.nat_lt RelEmbedding.natLT @[simp] theorem coe_natLT {f : β„• β†’ Ξ±} {H : βˆ€ n : β„•, r (f n) (f (n + 1))} : ⇑(natLT f H) = f := rfl #align rel_embedding.coe_nat_lt RelEmbedding.coe_natLT def natGT (f : β„• β†’ Ξ±) (H : βˆ€ n : β„•, r (f (n + 1)) (f n)) : ((Β· > Β·) : β„• β†’ β„• β†’ Prop) β†ͺr r := haveI := IsStrictOrder.swap r RelEmbedding.swap (natLT f H) #align rel_embedding.nat_gt RelEmbedding.natGT @[simp] theorem coe_natGT {f : β„• β†’ Ξ±} {H : βˆ€ n : β„•, r (f (n + 1)) (f n)} : ⇑(natGT f H) = f := rfl #align rel_embedding.coe_nat_gt RelEmbedding.coe_natGT
Mathlib/Order/OrderIsoNat.lean
58
62
theorem exists_not_acc_lt_of_not_acc {a : Ξ±} {r} (h : Β¬Acc r a) : βˆƒ b, Β¬Acc r b ∧ r b a := by
contrapose! h refine ⟨_, fun b hr => ?_⟩ by_contra hb exact h b hb hr
import Mathlib.Order.Interval.Set.Basic import Mathlib.Data.Set.NAry import Mathlib.Order.Directed #align_import order.bounds.basic from "leanprover-community/mathlib"@"b1abe23ae96fef89ad30d9f4362c307f72a55010" open Function Set open OrderDual (toDual ofDual) universe u v w x variable {Ξ± : Type u} {Ξ² : Type v} {Ξ³ : Type w} {ΞΉ : Sort x} section variable [Preorder Ξ±] [Preorder Ξ²] {s t : Set Ξ±} {a b : Ξ±} def upperBounds (s : Set Ξ±) : Set Ξ± := { x | βˆ€ ⦃a⦄, a ∈ s β†’ a ≀ x } #align upper_bounds upperBounds def lowerBounds (s : Set Ξ±) : Set Ξ± := { x | βˆ€ ⦃a⦄, a ∈ s β†’ x ≀ a } #align lower_bounds lowerBounds def BddAbove (s : Set Ξ±) := (upperBounds s).Nonempty #align bdd_above BddAbove def BddBelow (s : Set Ξ±) := (lowerBounds s).Nonempty #align bdd_below BddBelow def IsLeast (s : Set Ξ±) (a : Ξ±) : Prop := a ∈ s ∧ a ∈ lowerBounds s #align is_least IsLeast def IsGreatest (s : Set Ξ±) (a : Ξ±) : Prop := a ∈ s ∧ a ∈ upperBounds s #align is_greatest IsGreatest def IsLUB (s : Set Ξ±) : Ξ± β†’ Prop := IsLeast (upperBounds s) #align is_lub IsLUB def IsGLB (s : Set Ξ±) : Ξ± β†’ Prop := IsGreatest (lowerBounds s) #align is_glb IsGLB theorem mem_upperBounds : a ∈ upperBounds s ↔ βˆ€ x ∈ s, x ≀ a := Iff.rfl #align mem_upper_bounds mem_upperBounds theorem mem_lowerBounds : a ∈ lowerBounds s ↔ βˆ€ x ∈ s, a ≀ x := Iff.rfl #align mem_lower_bounds mem_lowerBounds lemma mem_upperBounds_iff_subset_Iic : a ∈ upperBounds s ↔ s βŠ† Iic a := Iff.rfl #align mem_upper_bounds_iff_subset_Iic mem_upperBounds_iff_subset_Iic lemma mem_lowerBounds_iff_subset_Ici : a ∈ lowerBounds s ↔ s βŠ† Ici a := Iff.rfl #align mem_lower_bounds_iff_subset_Ici mem_lowerBounds_iff_subset_Ici theorem bddAbove_def : BddAbove s ↔ βˆƒ x, βˆ€ y ∈ s, y ≀ x := Iff.rfl #align bdd_above_def bddAbove_def theorem bddBelow_def : BddBelow s ↔ βˆƒ x, βˆ€ y ∈ s, x ≀ y := Iff.rfl #align bdd_below_def bddBelow_def theorem bot_mem_lowerBounds [OrderBot Ξ±] (s : Set Ξ±) : βŠ₯ ∈ lowerBounds s := fun _ _ => bot_le #align bot_mem_lower_bounds bot_mem_lowerBounds theorem top_mem_upperBounds [OrderTop Ξ±] (s : Set Ξ±) : ⊀ ∈ upperBounds s := fun _ _ => le_top #align top_mem_upper_bounds top_mem_upperBounds @[simp] theorem isLeast_bot_iff [OrderBot Ξ±] : IsLeast s βŠ₯ ↔ βŠ₯ ∈ s := and_iff_left <| bot_mem_lowerBounds _ #align is_least_bot_iff isLeast_bot_iff @[simp] theorem isGreatest_top_iff [OrderTop Ξ±] : IsGreatest s ⊀ ↔ ⊀ ∈ s := and_iff_left <| top_mem_upperBounds _ #align is_greatest_top_iff isGreatest_top_iff theorem not_bddAbove_iff' : Β¬BddAbove s ↔ βˆ€ x, βˆƒ y ∈ s, Β¬y ≀ x := by simp [BddAbove, upperBounds, Set.Nonempty] #align not_bdd_above_iff' not_bddAbove_iff' theorem not_bddBelow_iff' : Β¬BddBelow s ↔ βˆ€ x, βˆƒ y ∈ s, Β¬x ≀ y := @not_bddAbove_iff' Ξ±α΅’α΅ˆ _ _ #align not_bdd_below_iff' not_bddBelow_iff' theorem not_bddAbove_iff {Ξ± : Type*} [LinearOrder Ξ±] {s : Set Ξ±} : Β¬BddAbove s ↔ βˆ€ x, βˆƒ y ∈ s, x < y := by simp only [not_bddAbove_iff', not_le] #align not_bdd_above_iff not_bddAbove_iff theorem not_bddBelow_iff {Ξ± : Type*} [LinearOrder Ξ±] {s : Set Ξ±} : Β¬BddBelow s ↔ βˆ€ x, βˆƒ y ∈ s, y < x := @not_bddAbove_iff Ξ±α΅’α΅ˆ _ _ #align not_bdd_below_iff not_bddBelow_iff @[simp] lemma bddBelow_preimage_ofDual {s : Set Ξ±} : BddBelow (ofDual ⁻¹' s) ↔ BddAbove s := Iff.rfl @[simp] lemma bddAbove_preimage_ofDual {s : Set Ξ±} : BddAbove (ofDual ⁻¹' s) ↔ BddBelow s := Iff.rfl @[simp] lemma bddBelow_preimage_toDual {s : Set Ξ±α΅’α΅ˆ} : BddBelow (toDual ⁻¹' s) ↔ BddAbove s := Iff.rfl @[simp] lemma bddAbove_preimage_toDual {s : Set Ξ±α΅’α΅ˆ} : BddAbove (toDual ⁻¹' s) ↔ BddBelow s := Iff.rfl theorem BddAbove.dual (h : BddAbove s) : BddBelow (ofDual ⁻¹' s) := h #align bdd_above.dual BddAbove.dual theorem BddBelow.dual (h : BddBelow s) : BddAbove (ofDual ⁻¹' s) := h #align bdd_below.dual BddBelow.dual theorem IsLeast.dual (h : IsLeast s a) : IsGreatest (ofDual ⁻¹' s) (toDual a) := h #align is_least.dual IsLeast.dual theorem IsGreatest.dual (h : IsGreatest s a) : IsLeast (ofDual ⁻¹' s) (toDual a) := h #align is_greatest.dual IsGreatest.dual theorem IsLUB.dual (h : IsLUB s a) : IsGLB (ofDual ⁻¹' s) (toDual a) := h #align is_lub.dual IsLUB.dual theorem IsGLB.dual (h : IsGLB s a) : IsLUB (ofDual ⁻¹' s) (toDual a) := h #align is_glb.dual IsGLB.dual abbrev IsLeast.orderBot (h : IsLeast s a) : OrderBot s where bot := ⟨a, h.1⟩ bot_le := Subtype.forall.2 h.2 #align is_least.order_bot IsLeast.orderBot abbrev IsGreatest.orderTop (h : IsGreatest s a) : OrderTop s where top := ⟨a, h.1⟩ le_top := Subtype.forall.2 h.2 #align is_greatest.order_top IsGreatest.orderTop theorem upperBounds_mono_set ⦃s t : Set α⦄ (hst : s βŠ† t) : upperBounds t βŠ† upperBounds s := fun _ hb _ h => hb <| hst h #align upper_bounds_mono_set upperBounds_mono_set theorem lowerBounds_mono_set ⦃s t : Set α⦄ (hst : s βŠ† t) : lowerBounds t βŠ† lowerBounds s := fun _ hb _ h => hb <| hst h #align lower_bounds_mono_set lowerBounds_mono_set theorem upperBounds_mono_mem ⦃a b⦄ (hab : a ≀ b) : a ∈ upperBounds s β†’ b ∈ upperBounds s := fun ha _ h => le_trans (ha h) hab #align upper_bounds_mono_mem upperBounds_mono_mem theorem lowerBounds_mono_mem ⦃a b⦄ (hab : a ≀ b) : b ∈ lowerBounds s β†’ a ∈ lowerBounds s := fun hb _ h => le_trans hab (hb h) #align lower_bounds_mono_mem lowerBounds_mono_mem theorem upperBounds_mono ⦃s t : Set α⦄ (hst : s βŠ† t) ⦃a b⦄ (hab : a ≀ b) : a ∈ upperBounds t β†’ b ∈ upperBounds s := fun ha => upperBounds_mono_set hst <| upperBounds_mono_mem hab ha #align upper_bounds_mono upperBounds_mono theorem lowerBounds_mono ⦃s t : Set α⦄ (hst : s βŠ† t) ⦃a b⦄ (hab : a ≀ b) : b ∈ lowerBounds t β†’ a ∈ lowerBounds s := fun hb => lowerBounds_mono_set hst <| lowerBounds_mono_mem hab hb #align lower_bounds_mono lowerBounds_mono theorem BddAbove.mono ⦃s t : Set α⦄ (h : s βŠ† t) : BddAbove t β†’ BddAbove s := Nonempty.mono <| upperBounds_mono_set h #align bdd_above.mono BddAbove.mono theorem BddBelow.mono ⦃s t : Set α⦄ (h : s βŠ† t) : BddBelow t β†’ BddBelow s := Nonempty.mono <| lowerBounds_mono_set h #align bdd_below.mono BddBelow.mono theorem IsLUB.of_subset_of_superset {s t p : Set Ξ±} (hs : IsLUB s a) (hp : IsLUB p a) (hst : s βŠ† t) (htp : t βŠ† p) : IsLUB t a := ⟨upperBounds_mono_set htp hp.1, lowerBounds_mono_set (upperBounds_mono_set hst) hs.2⟩ #align is_lub.of_subset_of_superset IsLUB.of_subset_of_superset theorem IsGLB.of_subset_of_superset {s t p : Set Ξ±} (hs : IsGLB s a) (hp : IsGLB p a) (hst : s βŠ† t) (htp : t βŠ† p) : IsGLB t a := hs.dual.of_subset_of_superset hp hst htp #align is_glb.of_subset_of_superset IsGLB.of_subset_of_superset theorem IsLeast.mono (ha : IsLeast s a) (hb : IsLeast t b) (hst : s βŠ† t) : b ≀ a := hb.2 (hst ha.1) #align is_least.mono IsLeast.mono theorem IsGreatest.mono (ha : IsGreatest s a) (hb : IsGreatest t b) (hst : s βŠ† t) : a ≀ b := hb.2 (hst ha.1) #align is_greatest.mono IsGreatest.mono theorem IsLUB.mono (ha : IsLUB s a) (hb : IsLUB t b) (hst : s βŠ† t) : a ≀ b := IsLeast.mono hb ha <| upperBounds_mono_set hst #align is_lub.mono IsLUB.mono theorem IsGLB.mono (ha : IsGLB s a) (hb : IsGLB t b) (hst : s βŠ† t) : b ≀ a := IsGreatest.mono hb ha <| lowerBounds_mono_set hst #align is_glb.mono IsGLB.mono theorem subset_lowerBounds_upperBounds (s : Set Ξ±) : s βŠ† lowerBounds (upperBounds s) := fun _ hx _ hy => hy hx #align subset_lower_bounds_upper_bounds subset_lowerBounds_upperBounds theorem subset_upperBounds_lowerBounds (s : Set Ξ±) : s βŠ† upperBounds (lowerBounds s) := fun _ hx _ hy => hy hx #align subset_upper_bounds_lower_bounds subset_upperBounds_lowerBounds theorem Set.Nonempty.bddAbove_lowerBounds (hs : s.Nonempty) : BddAbove (lowerBounds s) := hs.mono (subset_upperBounds_lowerBounds s) #align set.nonempty.bdd_above_lower_bounds Set.Nonempty.bddAbove_lowerBounds theorem Set.Nonempty.bddBelow_upperBounds (hs : s.Nonempty) : BddBelow (upperBounds s) := hs.mono (subset_lowerBounds_upperBounds s) #align set.nonempty.bdd_below_upper_bounds Set.Nonempty.bddBelow_upperBounds theorem IsLeast.isGLB (h : IsLeast s a) : IsGLB s a := ⟨h.2, fun _ hb => hb h.1⟩ #align is_least.is_glb IsLeast.isGLB theorem IsGreatest.isLUB (h : IsGreatest s a) : IsLUB s a := ⟨h.2, fun _ hb => hb h.1⟩ #align is_greatest.is_lub IsGreatest.isLUB theorem IsLUB.upperBounds_eq (h : IsLUB s a) : upperBounds s = Ici a := Set.ext fun _ => ⟨fun hb => h.2 hb, fun hb => upperBounds_mono_mem hb h.1⟩ #align is_lub.upper_bounds_eq IsLUB.upperBounds_eq theorem IsGLB.lowerBounds_eq (h : IsGLB s a) : lowerBounds s = Iic a := h.dual.upperBounds_eq #align is_glb.lower_bounds_eq IsGLB.lowerBounds_eq theorem IsLeast.lowerBounds_eq (h : IsLeast s a) : lowerBounds s = Iic a := h.isGLB.lowerBounds_eq #align is_least.lower_bounds_eq IsLeast.lowerBounds_eq theorem IsGreatest.upperBounds_eq (h : IsGreatest s a) : upperBounds s = Ici a := h.isLUB.upperBounds_eq #align is_greatest.upper_bounds_eq IsGreatest.upperBounds_eq -- Porting note (#10756): new lemma theorem IsGreatest.lt_iff (h : IsGreatest s a) : a < b ↔ βˆ€ x ∈ s, x < b := ⟨fun hlt _x hx => (h.2 hx).trans_lt hlt, fun h' => h' _ h.1⟩ -- Porting note (#10756): new lemma theorem IsLeast.lt_iff (h : IsLeast s a) : b < a ↔ βˆ€ x ∈ s, b < x := h.dual.lt_iff theorem isLUB_le_iff (h : IsLUB s a) : a ≀ b ↔ b ∈ upperBounds s := by rw [h.upperBounds_eq] rfl #align is_lub_le_iff isLUB_le_iff theorem le_isGLB_iff (h : IsGLB s a) : b ≀ a ↔ b ∈ lowerBounds s := by rw [h.lowerBounds_eq] rfl #align le_is_glb_iff le_isGLB_iff theorem isLUB_iff_le_iff : IsLUB s a ↔ βˆ€ b, a ≀ b ↔ b ∈ upperBounds s := ⟨fun h _ => isLUB_le_iff h, fun H => ⟨(H _).1 le_rfl, fun b hb => (H b).2 hb⟩⟩ #align is_lub_iff_le_iff isLUB_iff_le_iff theorem isGLB_iff_le_iff : IsGLB s a ↔ βˆ€ b, b ≀ a ↔ b ∈ lowerBounds s := @isLUB_iff_le_iff Ξ±α΅’α΅ˆ _ _ _ #align is_glb_iff_le_iff isGLB_iff_le_iff theorem IsLUB.bddAbove (h : IsLUB s a) : BddAbove s := ⟨a, h.1⟩ #align is_lub.bdd_above IsLUB.bddAbove theorem IsGLB.bddBelow (h : IsGLB s a) : BddBelow s := ⟨a, h.1⟩ #align is_glb.bdd_below IsGLB.bddBelow theorem IsGreatest.bddAbove (h : IsGreatest s a) : BddAbove s := ⟨a, h.2⟩ #align is_greatest.bdd_above IsGreatest.bddAbove theorem IsLeast.bddBelow (h : IsLeast s a) : BddBelow s := ⟨a, h.2⟩ #align is_least.bdd_below IsLeast.bddBelow theorem IsLeast.nonempty (h : IsLeast s a) : s.Nonempty := ⟨a, h.1⟩ #align is_least.nonempty IsLeast.nonempty theorem IsGreatest.nonempty (h : IsGreatest s a) : s.Nonempty := ⟨a, h.1⟩ #align is_greatest.nonempty IsGreatest.nonempty @[simp] theorem upperBounds_union : upperBounds (s βˆͺ t) = upperBounds s ∩ upperBounds t := Subset.antisymm (fun _ hb => ⟨fun _ hx => hb (Or.inl hx), fun _ hx => hb (Or.inr hx)⟩) fun _ hb _ hx => hx.elim (fun hs => hb.1 hs) fun ht => hb.2 ht #align upper_bounds_union upperBounds_union @[simp] theorem lowerBounds_union : lowerBounds (s βˆͺ t) = lowerBounds s ∩ lowerBounds t := @upperBounds_union Ξ±α΅’α΅ˆ _ s t #align lower_bounds_union lowerBounds_union theorem union_upperBounds_subset_upperBounds_inter : upperBounds s βˆͺ upperBounds t βŠ† upperBounds (s ∩ t) := union_subset (upperBounds_mono_set inter_subset_left) (upperBounds_mono_set inter_subset_right) #align union_upper_bounds_subset_upper_bounds_inter union_upperBounds_subset_upperBounds_inter theorem union_lowerBounds_subset_lowerBounds_inter : lowerBounds s βˆͺ lowerBounds t βŠ† lowerBounds (s ∩ t) := @union_upperBounds_subset_upperBounds_inter Ξ±α΅’α΅ˆ _ s t #align union_lower_bounds_subset_lower_bounds_inter union_lowerBounds_subset_lowerBounds_inter theorem isLeast_union_iff {a : Ξ±} {s t : Set Ξ±} : IsLeast (s βˆͺ t) a ↔ IsLeast s a ∧ a ∈ lowerBounds t ∨ a ∈ lowerBounds s ∧ IsLeast t a := by simp [IsLeast, lowerBounds_union, or_and_right, and_comm (a := a ∈ t), and_assoc] #align is_least_union_iff isLeast_union_iff theorem isGreatest_union_iff : IsGreatest (s βˆͺ t) a ↔ IsGreatest s a ∧ a ∈ upperBounds t ∨ a ∈ upperBounds s ∧ IsGreatest t a := @isLeast_union_iff Ξ±α΅’α΅ˆ _ a s t #align is_greatest_union_iff isGreatest_union_iff theorem BddAbove.inter_of_left (h : BddAbove s) : BddAbove (s ∩ t) := h.mono inter_subset_left #align bdd_above.inter_of_left BddAbove.inter_of_left theorem BddAbove.inter_of_right (h : BddAbove t) : BddAbove (s ∩ t) := h.mono inter_subset_right #align bdd_above.inter_of_right BddAbove.inter_of_right theorem BddBelow.inter_of_left (h : BddBelow s) : BddBelow (s ∩ t) := h.mono inter_subset_left #align bdd_below.inter_of_left BddBelow.inter_of_left theorem BddBelow.inter_of_right (h : BddBelow t) : BddBelow (s ∩ t) := h.mono inter_subset_right #align bdd_below.inter_of_right BddBelow.inter_of_right theorem BddAbove.union [IsDirected Ξ± (Β· ≀ Β·)] {s t : Set Ξ±} : BddAbove s β†’ BddAbove t β†’ BddAbove (s βˆͺ t) := by rintro ⟨a, ha⟩ ⟨b, hb⟩ obtain ⟨c, hca, hcb⟩ := exists_ge_ge a b rw [BddAbove, upperBounds_union] exact ⟨c, upperBounds_mono_mem hca ha, upperBounds_mono_mem hcb hb⟩ #align bdd_above.union BddAbove.union theorem bddAbove_union [IsDirected Ξ± (Β· ≀ Β·)] {s t : Set Ξ±} : BddAbove (s βˆͺ t) ↔ BddAbove s ∧ BddAbove t := ⟨fun h => ⟨h.mono subset_union_left, h.mono subset_union_right⟩, fun h => h.1.union h.2⟩ #align bdd_above_union bddAbove_union theorem BddBelow.union [IsDirected Ξ± (Β· β‰₯ Β·)] {s t : Set Ξ±} : BddBelow s β†’ BddBelow t β†’ BddBelow (s βˆͺ t) := @BddAbove.union Ξ±α΅’α΅ˆ _ _ _ _ #align bdd_below.union BddBelow.union theorem bddBelow_union [IsDirected Ξ± (Β· β‰₯ Β·)] {s t : Set Ξ±} : BddBelow (s βˆͺ t) ↔ BddBelow s ∧ BddBelow t := @bddAbove_union Ξ±α΅’α΅ˆ _ _ _ _ #align bdd_below_union bddBelow_union theorem IsLUB.union [SemilatticeSup Ξ³] {a b : Ξ³} {s t : Set Ξ³} (hs : IsLUB s a) (ht : IsLUB t b) : IsLUB (s βˆͺ t) (a βŠ” b) := ⟨fun _ h => h.casesOn (fun h => le_sup_of_le_left <| hs.left h) fun h => le_sup_of_le_right <| ht.left h, fun _ hc => sup_le (hs.right fun _ hd => hc <| Or.inl hd) (ht.right fun _ hd => hc <| Or.inr hd)⟩ #align is_lub.union IsLUB.union theorem IsGLB.union [SemilatticeInf Ξ³] {a₁ aβ‚‚ : Ξ³} {s t : Set Ξ³} (hs : IsGLB s a₁) (ht : IsGLB t aβ‚‚) : IsGLB (s βˆͺ t) (a₁ βŠ“ aβ‚‚) := hs.dual.union ht #align is_glb.union IsGLB.union theorem IsLeast.union [LinearOrder Ξ³] {a b : Ξ³} {s t : Set Ξ³} (ha : IsLeast s a) (hb : IsLeast t b) : IsLeast (s βˆͺ t) (min a b) := ⟨by rcases le_total a b with h | h <;> simp [h, ha.1, hb.1], (ha.isGLB.union hb.isGLB).1⟩ #align is_least.union IsLeast.union theorem IsGreatest.union [LinearOrder Ξ³] {a b : Ξ³} {s t : Set Ξ³} (ha : IsGreatest s a) (hb : IsGreatest t b) : IsGreatest (s βˆͺ t) (max a b) := ⟨by rcases le_total a b with h | h <;> simp [h, ha.1, hb.1], (ha.isLUB.union hb.isLUB).1⟩ #align is_greatest.union IsGreatest.union theorem IsLUB.inter_Ici_of_mem [LinearOrder Ξ³] {s : Set Ξ³} {a b : Ξ³} (ha : IsLUB s a) (hb : b ∈ s) : IsLUB (s ∩ Ici b) a := ⟨fun _ hx => ha.1 hx.1, fun c hc => have hbc : b ≀ c := hc ⟨hb, le_rfl⟩ ha.2 fun x hx => ((le_total x b).elim fun hxb => hxb.trans hbc) fun hbx => hc ⟨hx, hbx⟩⟩ #align is_lub.inter_Ici_of_mem IsLUB.inter_Ici_of_mem theorem IsGLB.inter_Iic_of_mem [LinearOrder Ξ³] {s : Set Ξ³} {a b : Ξ³} (ha : IsGLB s a) (hb : b ∈ s) : IsGLB (s ∩ Iic b) a := ha.dual.inter_Ici_of_mem hb #align is_glb.inter_Iic_of_mem IsGLB.inter_Iic_of_mem
Mathlib/Order/Bounds/Basic.lean
496
499
theorem bddAbove_iff_exists_ge [SemilatticeSup Ξ³] {s : Set Ξ³} (xβ‚€ : Ξ³) : BddAbove s ↔ βˆƒ x, xβ‚€ ≀ x ∧ βˆ€ y ∈ s, y ≀ x := by
rw [bddAbove_def, exists_ge_and_iff_exists] exact Monotone.ball fun x _ => monotone_le
import Mathlib.Algebra.Algebra.Defs import Mathlib.Algebra.Order.BigOperators.Ring.Finset import Mathlib.Algebra.Order.Field.Canonical.Basic import Mathlib.Algebra.Order.Nonneg.Field import Mathlib.Algebra.Order.Nonneg.Floor import Mathlib.Data.Real.Pointwise import Mathlib.Order.ConditionallyCompleteLattice.Group import Mathlib.Tactic.GCongr.Core #align_import data.real.nnreal from "leanprover-community/mathlib"@"b1abe23ae96fef89ad30d9f4362c307f72a55010" open Function -- to ensure these instances are computable def NNReal := { r : ℝ // 0 ≀ r } deriving Zero, One, Semiring, StrictOrderedSemiring, CommMonoidWithZero, CommSemiring, SemilatticeInf, SemilatticeSup, DistribLattice, OrderedCommSemiring, CanonicallyOrderedCommSemiring, Inhabited #align nnreal NNReal namespace NNReal scoped notation "ℝβ‰₯0" => NNReal noncomputable instance : FloorSemiring ℝβ‰₯0 := Nonneg.floorSemiring instance instDenselyOrdered : DenselyOrdered ℝβ‰₯0 := Nonneg.instDenselyOrdered instance : OrderBot ℝβ‰₯0 := inferInstance instance : Archimedean ℝβ‰₯0 := Nonneg.archimedean noncomputable instance : Sub ℝβ‰₯0 := Nonneg.sub noncomputable instance : OrderedSub ℝβ‰₯0 := Nonneg.orderedSub noncomputable instance : CanonicallyLinearOrderedSemifield ℝβ‰₯0 := Nonneg.canonicallyLinearOrderedSemifield @[coe] def toReal : ℝβ‰₯0 β†’ ℝ := Subtype.val instance : Coe ℝβ‰₯0 ℝ := ⟨toReal⟩ -- Simp lemma to put back `n.val` into the normal form given by the coercion. @[simp] theorem val_eq_coe (n : ℝβ‰₯0) : n.val = n := rfl #align nnreal.val_eq_coe NNReal.val_eq_coe instance canLift : CanLift ℝ ℝβ‰₯0 toReal fun r => 0 ≀ r := Subtype.canLift _ #align nnreal.can_lift NNReal.canLift @[ext] protected theorem eq {n m : ℝβ‰₯0} : (n : ℝ) = (m : ℝ) β†’ n = m := Subtype.eq #align nnreal.eq NNReal.eq protected theorem eq_iff {n m : ℝβ‰₯0} : (n : ℝ) = (m : ℝ) ↔ n = m := Subtype.ext_iff.symm #align nnreal.eq_iff NNReal.eq_iff theorem ne_iff {x y : ℝβ‰₯0} : (x : ℝ) β‰  (y : ℝ) ↔ x β‰  y := not_congr <| NNReal.eq_iff #align nnreal.ne_iff NNReal.ne_iff protected theorem Β«forallΒ» {p : ℝβ‰₯0 β†’ Prop} : (βˆ€ x : ℝβ‰₯0, p x) ↔ βˆ€ (x : ℝ) (hx : 0 ≀ x), p ⟨x, hx⟩ := Subtype.forall #align nnreal.forall NNReal.forall protected theorem Β«existsΒ» {p : ℝβ‰₯0 β†’ Prop} : (βˆƒ x : ℝβ‰₯0, p x) ↔ βˆƒ (x : ℝ) (hx : 0 ≀ x), p ⟨x, hx⟩ := Subtype.exists #align nnreal.exists NNReal.exists noncomputable def _root_.Real.toNNReal (r : ℝ) : ℝβ‰₯0 := ⟨max r 0, le_max_right _ _⟩ #align real.to_nnreal Real.toNNReal theorem _root_.Real.coe_toNNReal (r : ℝ) (hr : 0 ≀ r) : (Real.toNNReal r : ℝ) = r := max_eq_left hr #align real.coe_to_nnreal Real.coe_toNNReal theorem _root_.Real.toNNReal_of_nonneg {r : ℝ} (hr : 0 ≀ r) : r.toNNReal = ⟨r, hr⟩ := by simp_rw [Real.toNNReal, max_eq_left hr] #align real.to_nnreal_of_nonneg Real.toNNReal_of_nonneg theorem _root_.Real.le_coe_toNNReal (r : ℝ) : r ≀ Real.toNNReal r := le_max_left r 0 #align real.le_coe_to_nnreal Real.le_coe_toNNReal theorem coe_nonneg (r : ℝβ‰₯0) : (0 : ℝ) ≀ r := r.2 #align nnreal.coe_nonneg NNReal.coe_nonneg @[simp, norm_cast] theorem coe_mk (a : ℝ) (ha) : toReal ⟨a, ha⟩ = a := rfl #align nnreal.coe_mk NNReal.coe_mk example : Zero ℝβ‰₯0 := by infer_instance example : One ℝβ‰₯0 := by infer_instance example : Add ℝβ‰₯0 := by infer_instance noncomputable example : Sub ℝβ‰₯0 := by infer_instance example : Mul ℝβ‰₯0 := by infer_instance noncomputable example : Inv ℝβ‰₯0 := by infer_instance noncomputable example : Div ℝβ‰₯0 := by infer_instance example : LE ℝβ‰₯0 := by infer_instance example : Bot ℝβ‰₯0 := by infer_instance example : Inhabited ℝβ‰₯0 := by infer_instance example : Nontrivial ℝβ‰₯0 := by infer_instance protected theorem coe_injective : Injective ((↑) : ℝβ‰₯0 β†’ ℝ) := Subtype.coe_injective #align nnreal.coe_injective NNReal.coe_injective @[simp, norm_cast] lemma coe_inj {r₁ rβ‚‚ : ℝβ‰₯0} : (r₁ : ℝ) = rβ‚‚ ↔ r₁ = rβ‚‚ := NNReal.coe_injective.eq_iff #align nnreal.coe_eq NNReal.coe_inj @[deprecated (since := "2024-02-03")] protected alias coe_eq := coe_inj @[simp, norm_cast] lemma coe_zero : ((0 : ℝβ‰₯0) : ℝ) = 0 := rfl #align nnreal.coe_zero NNReal.coe_zero @[simp, norm_cast] lemma coe_one : ((1 : ℝβ‰₯0) : ℝ) = 1 := rfl #align nnreal.coe_one NNReal.coe_one @[simp, norm_cast] protected theorem coe_add (r₁ rβ‚‚ : ℝβ‰₯0) : ((r₁ + rβ‚‚ : ℝβ‰₯0) : ℝ) = r₁ + rβ‚‚ := rfl #align nnreal.coe_add NNReal.coe_add @[simp, norm_cast] protected theorem coe_mul (r₁ rβ‚‚ : ℝβ‰₯0) : ((r₁ * rβ‚‚ : ℝβ‰₯0) : ℝ) = r₁ * rβ‚‚ := rfl #align nnreal.coe_mul NNReal.coe_mul @[simp, norm_cast] protected theorem coe_inv (r : ℝβ‰₯0) : ((r⁻¹ : ℝβ‰₯0) : ℝ) = (r : ℝ)⁻¹ := rfl #align nnreal.coe_inv NNReal.coe_inv @[simp, norm_cast] protected theorem coe_div (r₁ rβ‚‚ : ℝβ‰₯0) : ((r₁ / rβ‚‚ : ℝβ‰₯0) : ℝ) = (r₁ : ℝ) / rβ‚‚ := rfl #align nnreal.coe_div NNReal.coe_div #noalign nnreal.coe_bit0 #noalign nnreal.coe_bit1 protected theorem coe_two : ((2 : ℝβ‰₯0) : ℝ) = 2 := rfl #align nnreal.coe_two NNReal.coe_two @[simp, norm_cast] protected theorem coe_sub {r₁ rβ‚‚ : ℝβ‰₯0} (h : rβ‚‚ ≀ r₁) : ((r₁ - rβ‚‚ : ℝβ‰₯0) : ℝ) = ↑r₁ - ↑rβ‚‚ := max_eq_left <| le_sub_comm.2 <| by simp [show (rβ‚‚ : ℝ) ≀ r₁ from h] #align nnreal.coe_sub NNReal.coe_sub variable {r r₁ rβ‚‚ : ℝβ‰₯0} {x y : ℝ} @[simp, norm_cast] lemma coe_eq_zero : (r : ℝ) = 0 ↔ r = 0 := by rw [← coe_zero, coe_inj] #align coe_eq_zero NNReal.coe_eq_zero @[simp, norm_cast] lemma coe_eq_one : (r : ℝ) = 1 ↔ r = 1 := by rw [← coe_one, coe_inj] #align coe_inj_one NNReal.coe_eq_one @[norm_cast] lemma coe_ne_zero : (r : ℝ) β‰  0 ↔ r β‰  0 := coe_eq_zero.not #align nnreal.coe_ne_zero NNReal.coe_ne_zero @[norm_cast] lemma coe_ne_one : (r : ℝ) β‰  1 ↔ r β‰  1 := coe_eq_one.not example : CommSemiring ℝβ‰₯0 := by infer_instance def toRealHom : ℝβ‰₯0 β†’+* ℝ where toFun := (↑) map_one' := NNReal.coe_one map_mul' := NNReal.coe_mul map_zero' := NNReal.coe_zero map_add' := NNReal.coe_add #align nnreal.to_real_hom NNReal.toRealHom @[simp] theorem coe_toRealHom : ⇑toRealHom = toReal := rfl #align nnreal.coe_to_real_hom NNReal.coe_toRealHom example : MonoidWithZero ℝβ‰₯0 := by infer_instance example : CommMonoidWithZero ℝβ‰₯0 := by infer_instance noncomputable example : CommGroupWithZero ℝβ‰₯0 := by infer_instance @[simp, norm_cast] theorem coe_indicator {Ξ±} (s : Set Ξ±) (f : Ξ± β†’ ℝβ‰₯0) (a : Ξ±) : ((s.indicator f a : ℝβ‰₯0) : ℝ) = s.indicator (fun x => ↑(f x)) a := (toRealHom : ℝβ‰₯0 β†’+ ℝ).map_indicator _ _ _ #align nnreal.coe_indicator NNReal.coe_indicator @[simp, norm_cast] theorem coe_pow (r : ℝβ‰₯0) (n : β„•) : ((r ^ n : ℝβ‰₯0) : ℝ) = (r : ℝ) ^ n := rfl #align nnreal.coe_pow NNReal.coe_pow @[simp, norm_cast] theorem coe_zpow (r : ℝβ‰₯0) (n : β„€) : ((r ^ n : ℝβ‰₯0) : ℝ) = (r : ℝ) ^ n := rfl #align nnreal.coe_zpow NNReal.coe_zpow @[norm_cast] theorem coe_list_sum (l : List ℝβ‰₯0) : ((l.sum : ℝβ‰₯0) : ℝ) = (l.map (↑)).sum := map_list_sum toRealHom l #align nnreal.coe_list_sum NNReal.coe_list_sum @[norm_cast] theorem coe_list_prod (l : List ℝβ‰₯0) : ((l.prod : ℝβ‰₯0) : ℝ) = (l.map (↑)).prod := map_list_prod toRealHom l #align nnreal.coe_list_prod NNReal.coe_list_prod @[norm_cast] theorem coe_multiset_sum (s : Multiset ℝβ‰₯0) : ((s.sum : ℝβ‰₯0) : ℝ) = (s.map (↑)).sum := map_multiset_sum toRealHom s #align nnreal.coe_multiset_sum NNReal.coe_multiset_sum @[norm_cast] theorem coe_multiset_prod (s : Multiset ℝβ‰₯0) : ((s.prod : ℝβ‰₯0) : ℝ) = (s.map (↑)).prod := map_multiset_prod toRealHom s #align nnreal.coe_multiset_prod NNReal.coe_multiset_prod @[norm_cast] theorem coe_sum {Ξ±} {s : Finset Ξ±} {f : Ξ± β†’ ℝβ‰₯0} : ↑(βˆ‘ a ∈ s, f a) = βˆ‘ a ∈ s, (f a : ℝ) := map_sum toRealHom _ _ #align nnreal.coe_sum NNReal.coe_sum theorem _root_.Real.toNNReal_sum_of_nonneg {Ξ±} {s : Finset Ξ±} {f : Ξ± β†’ ℝ} (hf : βˆ€ a, a ∈ s β†’ 0 ≀ f a) : Real.toNNReal (βˆ‘ a ∈ s, f a) = βˆ‘ a ∈ s, Real.toNNReal (f a) := by rw [← coe_inj, NNReal.coe_sum, Real.coe_toNNReal _ (Finset.sum_nonneg hf)] exact Finset.sum_congr rfl fun x hxs => by rw [Real.coe_toNNReal _ (hf x hxs)] #align real.to_nnreal_sum_of_nonneg Real.toNNReal_sum_of_nonneg @[norm_cast] theorem coe_prod {Ξ±} {s : Finset Ξ±} {f : Ξ± β†’ ℝβ‰₯0} : ↑(∏ a ∈ s, f a) = ∏ a ∈ s, (f a : ℝ) := map_prod toRealHom _ _ #align nnreal.coe_prod NNReal.coe_prod theorem _root_.Real.toNNReal_prod_of_nonneg {Ξ±} {s : Finset Ξ±} {f : Ξ± β†’ ℝ} (hf : βˆ€ a, a ∈ s β†’ 0 ≀ f a) : Real.toNNReal (∏ a ∈ s, f a) = ∏ a ∈ s, Real.toNNReal (f a) := by rw [← coe_inj, NNReal.coe_prod, Real.coe_toNNReal _ (Finset.prod_nonneg hf)] exact Finset.prod_congr rfl fun x hxs => by rw [Real.coe_toNNReal _ (hf x hxs)] #align real.to_nnreal_prod_of_nonneg Real.toNNReal_prod_of_nonneg -- Porting note (#11215): TODO: `simp`? `norm_cast`? theorem coe_nsmul (r : ℝβ‰₯0) (n : β„•) : ↑(n β€’ r) = n β€’ (r : ℝ) := rfl #align nnreal.nsmul_coe NNReal.coe_nsmul @[simp, norm_cast] protected theorem coe_natCast (n : β„•) : (↑(↑n : ℝβ‰₯0) : ℝ) = n := map_natCast toRealHom n #align nnreal.coe_nat_cast NNReal.coe_natCast @[deprecated (since := "2024-04-17")] alias coe_nat_cast := NNReal.coe_natCast -- See note [no_index around OfNat.ofNat] @[simp, norm_cast] protected theorem coe_ofNat (n : β„•) [n.AtLeastTwo] : (no_index (OfNat.ofNat n : ℝβ‰₯0) : ℝ) = OfNat.ofNat n := rfl @[simp, norm_cast] protected theorem coe_ofScientific (m : β„•) (s : Bool) (e : β„•) : ↑(OfScientific.ofScientific m s e : ℝβ‰₯0) = (OfScientific.ofScientific m s e : ℝ) := rfl noncomputable example : LinearOrder ℝβ‰₯0 := by infer_instance @[simp, norm_cast] lemma coe_le_coe : (r₁ : ℝ) ≀ rβ‚‚ ↔ r₁ ≀ rβ‚‚ := Iff.rfl #align nnreal.coe_le_coe NNReal.coe_le_coe @[simp, norm_cast] lemma coe_lt_coe : (r₁ : ℝ) < rβ‚‚ ↔ r₁ < rβ‚‚ := Iff.rfl #align nnreal.coe_lt_coe NNReal.coe_lt_coe @[simp, norm_cast] lemma coe_pos : (0 : ℝ) < r ↔ 0 < r := Iff.rfl #align nnreal.coe_pos NNReal.coe_pos @[simp, norm_cast] lemma one_le_coe : 1 ≀ (r : ℝ) ↔ 1 ≀ r := by rw [← coe_le_coe, coe_one] @[simp, norm_cast] lemma one_lt_coe : 1 < (r : ℝ) ↔ 1 < r := by rw [← coe_lt_coe, coe_one] @[simp, norm_cast] lemma coe_le_one : (r : ℝ) ≀ 1 ↔ r ≀ 1 := by rw [← coe_le_coe, coe_one] @[simp, norm_cast] lemma coe_lt_one : (r : ℝ) < 1 ↔ r < 1 := by rw [← coe_lt_coe, coe_one] @[mono] lemma coe_mono : Monotone ((↑) : ℝβ‰₯0 β†’ ℝ) := fun _ _ => NNReal.coe_le_coe.2 #align nnreal.coe_mono NNReal.coe_mono @[gcongr] alias ⟨_, GCongr.toReal_le_toReal⟩ := coe_le_coe protected theorem _root_.Real.toNNReal_mono : Monotone Real.toNNReal := fun _ _ h => max_le_max h (le_refl 0) #align real.to_nnreal_mono Real.toNNReal_mono @[simp] theorem _root_.Real.toNNReal_coe {r : ℝβ‰₯0} : Real.toNNReal r = r := NNReal.eq <| max_eq_left r.2 #align real.to_nnreal_coe Real.toNNReal_coe @[simp] theorem mk_natCast (n : β„•) : @Eq ℝβ‰₯0 (⟨(n : ℝ), n.cast_nonneg⟩ : ℝβ‰₯0) n := NNReal.eq (NNReal.coe_natCast n).symm #align nnreal.mk_coe_nat NNReal.mk_natCast @[deprecated (since := "2024-04-05")] alias mk_coe_nat := mk_natCast -- Porting note: place this in the `Real` namespace @[simp] theorem toNNReal_coe_nat (n : β„•) : Real.toNNReal n = n := NNReal.eq <| by simp [Real.coe_toNNReal] #align nnreal.to_nnreal_coe_nat NNReal.toNNReal_coe_nat -- See note [no_index around OfNat.ofNat] @[simp] theorem _root_.Real.toNNReal_ofNat (n : β„•) [n.AtLeastTwo] : Real.toNNReal (no_index (OfNat.ofNat n)) = OfNat.ofNat n := toNNReal_coe_nat n noncomputable def gi : GaloisInsertion Real.toNNReal (↑) := GaloisInsertion.monotoneIntro NNReal.coe_mono Real.toNNReal_mono Real.le_coe_toNNReal fun _ => Real.toNNReal_coe #align nnreal.gi NNReal.gi -- note that anything involving the (decidability of the) linear order, -- will be noncomputable, everything else should not be. example : OrderBot ℝβ‰₯0 := by infer_instance example : PartialOrder ℝβ‰₯0 := by infer_instance noncomputable example : CanonicallyLinearOrderedAddCommMonoid ℝβ‰₯0 := by infer_instance noncomputable example : LinearOrderedAddCommMonoid ℝβ‰₯0 := by infer_instance example : DistribLattice ℝβ‰₯0 := by infer_instance example : SemilatticeInf ℝβ‰₯0 := by infer_instance example : SemilatticeSup ℝβ‰₯0 := by infer_instance noncomputable example : LinearOrderedSemiring ℝβ‰₯0 := by infer_instance example : OrderedCommSemiring ℝβ‰₯0 := by infer_instance noncomputable example : LinearOrderedCommMonoid ℝβ‰₯0 := by infer_instance noncomputable example : LinearOrderedCommMonoidWithZero ℝβ‰₯0 := by infer_instance noncomputable example : LinearOrderedCommGroupWithZero ℝβ‰₯0 := by infer_instance example : CanonicallyOrderedCommSemiring ℝβ‰₯0 := by infer_instance example : DenselyOrdered ℝβ‰₯0 := by infer_instance example : NoMaxOrder ℝβ‰₯0 := by infer_instance instance instPosSMulStrictMono {Ξ±} [Preorder Ξ±] [MulAction ℝ Ξ±] [PosSMulStrictMono ℝ Ξ±] : PosSMulStrictMono ℝβ‰₯0 Ξ± where elim _r hr _a₁ _aβ‚‚ ha := (smul_lt_smul_of_pos_left ha (coe_pos.2 hr):) instance instSMulPosStrictMono {Ξ±} [Zero Ξ±] [Preorder Ξ±] [MulAction ℝ Ξ±] [SMulPosStrictMono ℝ Ξ±] : SMulPosStrictMono ℝβ‰₯0 Ξ± where elim _a ha _r₁ _rβ‚‚ hr := (smul_lt_smul_of_pos_right (coe_lt_coe.2 hr) ha:) -- Porting note (#11215): TODO: restore once `simps` supports `ℝβ‰₯0` @[simps!? apply_coe_coe] def orderIsoIccZeroCoe (a : ℝβ‰₯0) : Set.Icc (0 : ℝ) a ≃o Set.Iic a where toEquiv := Equiv.Set.sep (Set.Ici 0) fun x : ℝ => x ≀ a map_rel_iff' := Iff.rfl #align nnreal.order_iso_Icc_zero_coe NNReal.orderIsoIccZeroCoe @[simp] theorem orderIsoIccZeroCoe_apply_coe_coe (a : ℝβ‰₯0) (b : Set.Icc (0 : ℝ) a) : (orderIsoIccZeroCoe a b : ℝ) = b := rfl @[simp] theorem orderIsoIccZeroCoe_symm_apply_coe (a : ℝβ‰₯0) (b : Set.Iic a) : ((orderIsoIccZeroCoe a).symm b : ℝ) = b := rfl #align nnreal.order_iso_Icc_zero_coe_symm_apply_coe NNReal.orderIsoIccZeroCoe_symm_apply_coe -- note we need the `@` to make the `Membership.mem` have a sensible type theorem coe_image {s : Set ℝβ‰₯0} : (↑) '' s = { x : ℝ | βˆƒ h : 0 ≀ x, @Membership.mem ℝβ‰₯0 _ _ ⟨x, h⟩ s } := Subtype.coe_image #align nnreal.coe_image NNReal.coe_image theorem bddAbove_coe {s : Set ℝβ‰₯0} : BddAbove (((↑) : ℝβ‰₯0 β†’ ℝ) '' s) ↔ BddAbove s := Iff.intro (fun ⟨b, hb⟩ => ⟨Real.toNNReal b, fun ⟨y, _⟩ hys => show y ≀ max b 0 from le_max_of_le_left <| hb <| Set.mem_image_of_mem _ hys⟩) fun ⟨b, hb⟩ => ⟨b, fun _ ⟨_, hx, eq⟩ => eq β–Έ hb hx⟩ #align nnreal.bdd_above_coe NNReal.bddAbove_coe theorem bddBelow_coe (s : Set ℝβ‰₯0) : BddBelow (((↑) : ℝβ‰₯0 β†’ ℝ) '' s) := ⟨0, fun _ ⟨q, _, eq⟩ => eq β–Έ q.2⟩ #align nnreal.bdd_below_coe NNReal.bddBelow_coe noncomputable instance : ConditionallyCompleteLinearOrderBot ℝβ‰₯0 := Nonneg.conditionallyCompleteLinearOrderBot 0 @[norm_cast] theorem coe_sSup (s : Set ℝβ‰₯0) : (↑(sSup s) : ℝ) = sSup (((↑) : ℝβ‰₯0 β†’ ℝ) '' s) := by rcases Set.eq_empty_or_nonempty s with rfl|hs Β· simp by_cases H : BddAbove s Β· have A : sSup (Subtype.val '' s) ∈ Set.Ici 0 := by apply Real.sSup_nonneg rintro - ⟨y, -, rfl⟩ exact y.2 exact (@subset_sSup_of_within ℝ (Set.Ici (0 : ℝ)) _ _ (_) s hs H A).symm Β· simp only [csSup_of_not_bddAbove H, csSup_empty, bot_eq_zero', NNReal.coe_zero] apply (Real.sSup_of_not_bddAbove ?_).symm contrapose! H exact bddAbove_coe.1 H #align nnreal.coe_Sup NNReal.coe_sSup @[simp, norm_cast] -- Porting note: add `simp` theorem coe_iSup {ΞΉ : Sort*} (s : ΞΉ β†’ ℝβ‰₯0) : (↑(⨆ i, s i) : ℝ) = ⨆ i, ↑(s i) := by rw [iSup, iSup, coe_sSup, ← Set.range_comp]; rfl #align nnreal.coe_supr NNReal.coe_iSup @[norm_cast] theorem coe_sInf (s : Set ℝβ‰₯0) : (↑(sInf s) : ℝ) = sInf (((↑) : ℝβ‰₯0 β†’ ℝ) '' s) := by rcases Set.eq_empty_or_nonempty s with rfl|hs Β· simp only [Set.image_empty, Real.sInf_empty, coe_eq_zero] exact @subset_sInf_emptyset ℝ (Set.Ici (0 : ℝ)) _ _ (_) have A : sInf (Subtype.val '' s) ∈ Set.Ici 0 := by apply Real.sInf_nonneg rintro - ⟨y, -, rfl⟩ exact y.2 exact (@subset_sInf_of_within ℝ (Set.Ici (0 : ℝ)) _ _ (_) s hs (OrderBot.bddBelow s) A).symm #align nnreal.coe_Inf NNReal.coe_sInf @[simp] theorem sInf_empty : sInf (βˆ… : Set ℝβ‰₯0) = 0 := by rw [← coe_eq_zero, coe_sInf, Set.image_empty, Real.sInf_empty] #align nnreal.Inf_empty NNReal.sInf_empty @[norm_cast]
Mathlib/Data/Real/NNReal.lean
550
551
theorem coe_iInf {ΞΉ : Sort*} (s : ΞΉ β†’ ℝβ‰₯0) : (↑(β¨… i, s i) : ℝ) = β¨… i, ↑(s i) := by
rw [iInf, iInf, coe_sInf, ← Set.range_comp]; rfl
import Mathlib.Algebra.Order.Group.Instances import Mathlib.Analysis.Convex.Segment import Mathlib.Tactic.GCongr #align_import analysis.convex.star from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" open Set open Convex Pointwise variable {π•œ E F : Type*} section OrderedSemiring variable [OrderedSemiring π•œ] section AddCommMonoid variable [AddCommMonoid E] [AddCommMonoid F] section AddCommGroup variable [AddCommGroup E] [AddCommGroup F] [Module π•œ E] [Module π•œ F] {x y : E} {s t : Set E} theorem StarConvex.add_smul_mem (hs : StarConvex π•œ x s) (hy : x + y ∈ s) {t : π•œ} (htβ‚€ : 0 ≀ t) (ht₁ : t ≀ 1) : x + t β€’ y ∈ s := by have h : x + t β€’ y = (1 - t) β€’ x + t β€’ (x + y) := by rw [smul_add, ← add_assoc, ← add_smul, sub_add_cancel, one_smul] rw [h] exact hs hy (sub_nonneg_of_le ht₁) htβ‚€ (sub_add_cancel _ _) #align star_convex.add_smul_mem StarConvex.add_smul_mem theorem StarConvex.smul_mem (hs : StarConvex π•œ 0 s) (hx : x ∈ s) {t : π•œ} (htβ‚€ : 0 ≀ t) (ht₁ : t ≀ 1) : t β€’ x ∈ s := by simpa using hs.add_smul_mem (by simpa using hx) htβ‚€ ht₁ #align star_convex.smul_mem StarConvex.smul_mem theorem StarConvex.add_smul_sub_mem (hs : StarConvex π•œ x s) (hy : y ∈ s) {t : π•œ} (htβ‚€ : 0 ≀ t) (ht₁ : t ≀ 1) : x + t β€’ (y - x) ∈ s := by apply hs.segment_subset hy rw [segment_eq_image'] exact mem_image_of_mem _ ⟨htβ‚€, htβ‚βŸ© #align star_convex.add_smul_sub_mem StarConvex.add_smul_sub_mem theorem StarConvex.affine_preimage (f : E →ᡃ[π•œ] F) {s : Set F} (hs : StarConvex π•œ (f x) s) : StarConvex π•œ x (f ⁻¹' s) := by intro y hy a b ha hb hab rw [mem_preimage, Convex.combo_affine_apply hab] exact hs hy ha hb hab #align star_convex.affine_preimage StarConvex.affine_preimage theorem StarConvex.affine_image (f : E →ᡃ[π•œ] F) {s : Set E} (hs : StarConvex π•œ x s) : StarConvex π•œ (f x) (f '' s) := by rintro y ⟨y', ⟨hy', hy'f⟩⟩ a b ha hb hab refine ⟨a β€’ x + b β€’ y', ⟨hs hy' ha hb hab, ?_⟩⟩ rw [Convex.combo_affine_apply hab, hy'f] #align star_convex.affine_image StarConvex.affine_image
Mathlib/Analysis/Convex/Star.lean
367
369
theorem StarConvex.neg (hs : StarConvex π•œ x s) : StarConvex π•œ (-x) (-s) := by
rw [← image_neg] exact hs.is_linear_image IsLinearMap.isLinearMap_neg
import Mathlib.Algebra.Lie.BaseChange import Mathlib.Algebra.Lie.Solvable import Mathlib.Algebra.Lie.Quotient import Mathlib.Algebra.Lie.Normalizer import Mathlib.LinearAlgebra.Eigenspace.Basic import Mathlib.Order.Filter.AtTopBot import Mathlib.RingTheory.Artinian import Mathlib.RingTheory.Nilpotent.Lemmas import Mathlib.Tactic.Monotonicity #align_import algebra.lie.nilpotent from "leanprover-community/mathlib"@"6b0169218d01f2837d79ea2784882009a0da1aa1" universe u v w w₁ wβ‚‚ section NilpotentModules variable {R : Type u} {L : Type v} {M : Type w} variable [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] variable [LieRingModule L M] [LieModule R L M] variable (k : β„•) (N : LieSubmodule R L M) namespace LieModule variable {Mβ‚‚ : Type w₁} [AddCommGroup Mβ‚‚] [Module R Mβ‚‚] [LieRingModule L Mβ‚‚] [LieModule R L Mβ‚‚] variable (R L M) theorem antitone_lowerCentralSeries : Antitone <| lowerCentralSeries R L M := by intro l k induction' k with k ih generalizing l <;> intro h Β· exact (Nat.le_zero.mp h).symm β–Έ le_rfl Β· rcases Nat.of_le_succ h with (hk | hk) Β· rw [lowerCentralSeries_succ] exact (LieSubmodule.mono_lie_right _ _ ⊀ (ih hk)).trans (LieSubmodule.lie_le_right _ _) Β· exact hk.symm β–Έ le_rfl #align lie_module.antitone_lower_central_series LieModule.antitone_lowerCentralSeries theorem eventually_iInf_lowerCentralSeries_eq [IsArtinian R M] : βˆ€αΆ  l in Filter.atTop, β¨… k, lowerCentralSeries R L M k = lowerCentralSeries R L M l := by have h_wf : WellFounded ((Β· > Β·) : (LieSubmodule R L M)α΅’α΅ˆ β†’ (LieSubmodule R L M)α΅’α΅ˆ β†’ Prop) := LieSubmodule.wellFounded_of_isArtinian R L M obtain ⟨n, hn : βˆ€ m, n ≀ m β†’ lowerCentralSeries R L M n = lowerCentralSeries R L M m⟩ := WellFounded.monotone_chain_condition.mp h_wf ⟨_, antitone_lowerCentralSeries R L M⟩ refine Filter.eventually_atTop.mpr ⟨n, fun l hl ↦ le_antisymm (iInf_le _ _) (le_iInf fun m ↦ ?_)⟩ rcases le_or_lt l m with h | h Β· rw [← hn _ hl, ← hn _ (hl.trans h)] Β· exact antitone_lowerCentralSeries R L M (le_of_lt h) theorem trivial_iff_lower_central_eq_bot : IsTrivial L M ↔ lowerCentralSeries R L M 1 = βŠ₯ := by constructor <;> intro h Β· erw [eq_bot_iff, LieSubmodule.lieSpan_le]; rintro m ⟨x, n, hn⟩; rw [← hn, h.trivial]; simp Β· rw [LieSubmodule.eq_bot_iff] at h; apply IsTrivial.mk; intro x m; apply h apply LieSubmodule.subset_lieSpan -- Porting note: was `use x, m; rfl` simp only [LieSubmodule.top_coe, Subtype.exists, LieSubmodule.mem_top, exists_prop, true_and, Set.mem_setOf] exact ⟨x, m, rfl⟩ #align lie_module.trivial_iff_lower_central_eq_bot LieModule.trivial_iff_lower_central_eq_bot theorem iterate_toEnd_mem_lowerCentralSeries (x : L) (m : M) (k : β„•) : (toEnd R L M x)^[k] m ∈ lowerCentralSeries R L M k := by induction' k with k ih Β· simp only [Nat.zero_eq, Function.iterate_zero, lowerCentralSeries_zero, LieSubmodule.mem_top] Β· simp only [lowerCentralSeries_succ, Function.comp_apply, Function.iterate_succ', toEnd_apply_apply] exact LieSubmodule.lie_mem_lie _ _ (LieSubmodule.mem_top x) ih #align lie_module.iterate_to_endomorphism_mem_lower_central_series LieModule.iterate_toEnd_mem_lowerCentralSeries theorem iterate_toEnd_mem_lowerCentralSeriesβ‚‚ (x y : L) (m : M) (k : β„•) : (toEnd R L M x βˆ˜β‚— toEnd R L M y)^[k] m ∈ lowerCentralSeries R L M (2 * k) := by induction' k with k ih Β· simp have hk : 2 * k.succ = (2 * k + 1) + 1 := rfl simp only [lowerCentralSeries_succ, Function.comp_apply, Function.iterate_succ', hk, toEnd_apply_apply, LinearMap.coe_comp, toEnd_apply_apply] refine LieSubmodule.lie_mem_lie _ _ (LieSubmodule.mem_top x) ?_ exact LieSubmodule.lie_mem_lie _ _ (LieSubmodule.mem_top y) ih variable {R L M} theorem map_lowerCentralSeries_le (f : M →ₗ⁅R,L⁆ Mβ‚‚) : (lowerCentralSeries R L M k).map f ≀ lowerCentralSeries R L Mβ‚‚ k := by induction' k with k ih Β· simp only [Nat.zero_eq, lowerCentralSeries_zero, le_top] Β· simp only [LieModule.lowerCentralSeries_succ, LieSubmodule.map_bracket_eq] exact LieSubmodule.mono_lie_right _ _ ⊀ ih #align lie_module.map_lower_central_series_le LieModule.map_lowerCentralSeries_le lemma map_lowerCentralSeries_eq {f : M →ₗ⁅R,L⁆ Mβ‚‚} (hf : Function.Surjective f) : (lowerCentralSeries R L M k).map f = lowerCentralSeries R L Mβ‚‚ k := by apply le_antisymm (map_lowerCentralSeries_le k f) induction' k with k ih Β· rwa [lowerCentralSeries_zero, lowerCentralSeries_zero, top_le_iff, f.map_top, f.range_eq_top] Β· simp only [lowerCentralSeries_succ, LieSubmodule.map_bracket_eq] apply LieSubmodule.mono_lie_right assumption variable (R L M) open LieAlgebra theorem derivedSeries_le_lowerCentralSeries (k : β„•) : derivedSeries R L k ≀ lowerCentralSeries R L L k := by induction' k with k h Β· rw [derivedSeries_def, derivedSeriesOfIdeal_zero, lowerCentralSeries_zero] Β· have h' : derivedSeries R L k ≀ ⊀ := by simp only [le_top] rw [derivedSeries_def, derivedSeriesOfIdeal_succ, lowerCentralSeries_succ] exact LieSubmodule.mono_lie _ _ _ _ h' h #align lie_module.derived_series_le_lower_central_series LieModule.derivedSeries_le_lowerCentralSeries class IsNilpotent : Prop where nilpotent : βˆƒ k, lowerCentralSeries R L M k = βŠ₯ #align lie_module.is_nilpotent LieModule.IsNilpotent theorem exists_lowerCentralSeries_eq_bot_of_isNilpotent [IsNilpotent R L M] : βˆƒ k, lowerCentralSeries R L M k = βŠ₯ := IsNilpotent.nilpotent @[simp] lemma iInf_lowerCentralSeries_eq_bot_of_isNilpotent [IsNilpotent R L M] : β¨… k, lowerCentralSeries R L M k = βŠ₯ := by obtain ⟨k, hk⟩ := exists_lowerCentralSeries_eq_bot_of_isNilpotent R L M rw [eq_bot_iff, ← hk] exact iInf_le _ _ theorem isNilpotent_iff : IsNilpotent R L M ↔ βˆƒ k, lowerCentralSeries R L M k = βŠ₯ := ⟨fun h => h.nilpotent, fun h => ⟨h⟩⟩ #align lie_module.is_nilpotent_iff LieModule.isNilpotent_iff variable {R L M} theorem _root_.LieSubmodule.isNilpotent_iff_exists_lcs_eq_bot (N : LieSubmodule R L M) : LieModule.IsNilpotent R L N ↔ βˆƒ k, N.lcs k = βŠ₯ := by rw [isNilpotent_iff] refine exists_congr fun k => ?_ rw [N.lowerCentralSeries_eq_lcs_comap k, LieSubmodule.comap_incl_eq_bot, inf_eq_right.mpr (N.lcs_le_self k)] #align lie_submodule.is_nilpotent_iff_exists_lcs_eq_bot LieSubmodule.isNilpotent_iff_exists_lcs_eq_bot variable (R L M) instance (priority := 100) trivialIsNilpotent [IsTrivial L M] : IsNilpotent R L M := ⟨by use 1; change β…βŠ€, βŠ€β† = βŠ₯; simp⟩ #align lie_module.trivial_is_nilpotent LieModule.trivialIsNilpotent theorem exists_forall_pow_toEnd_eq_zero [hM : IsNilpotent R L M] : βˆƒ k : β„•, βˆ€ x : L, toEnd R L M x ^ k = 0 := by obtain ⟨k, hM⟩ := hM use k intro x; ext m rw [LinearMap.pow_apply, LinearMap.zero_apply, ← @LieSubmodule.mem_bot R L M, ← hM] exact iterate_toEnd_mem_lowerCentralSeries R L M x m k #align lie_module.nilpotent_endo_of_nilpotent_module LieModule.exists_forall_pow_toEnd_eq_zero
Mathlib/Algebra/Lie/Nilpotent.lean
264
268
theorem isNilpotent_toEnd_of_isNilpotent [IsNilpotent R L M] (x : L) : _root_.IsNilpotent (toEnd R L M x) := by
change βˆƒ k, toEnd R L M x ^ k = 0 have := exists_forall_pow_toEnd_eq_zero R L M tauto
import Mathlib.Geometry.Manifold.MFDeriv.Defs #align_import geometry.manifold.mfderiv from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833" noncomputable section open scoped Topology Manifold open Set Bundle section DerivativesProperties variable {π•œ : Type*} [NontriviallyNormedField π•œ] {E : Type*} [NormedAddCommGroup E] [NormedSpace π•œ E] {H : Type*} [TopologicalSpace H] (I : ModelWithCorners π•œ E H) {M : Type*} [TopologicalSpace M] [ChartedSpace H M] {E' : Type*} [NormedAddCommGroup E'] [NormedSpace π•œ E'] {H' : Type*} [TopologicalSpace H'] {I' : ModelWithCorners π•œ E' H'} {M' : Type*} [TopologicalSpace M'] [ChartedSpace H' M'] {E'' : Type*} [NormedAddCommGroup E''] [NormedSpace π•œ E''] {H'' : Type*} [TopologicalSpace H''] {I'' : ModelWithCorners π•œ E'' H''} {M'' : Type*} [TopologicalSpace M''] [ChartedSpace H'' M''] {f fβ‚€ f₁ : M β†’ M'} {x : M} {s t : Set M} {g : M' β†’ M''} {u : Set M'} theorem uniqueMDiffWithinAt_univ : UniqueMDiffWithinAt I univ x := by unfold UniqueMDiffWithinAt simp only [preimage_univ, univ_inter] exact I.unique_diff _ (mem_range_self _) #align unique_mdiff_within_at_univ uniqueMDiffWithinAt_univ variable {I} theorem uniqueMDiffWithinAt_iff {s : Set M} {x : M} : UniqueMDiffWithinAt I s x ↔ UniqueDiffWithinAt π•œ ((extChartAt I x).symm ⁻¹' s ∩ (extChartAt I x).target) ((extChartAt I x) x) := by apply uniqueDiffWithinAt_congr rw [nhdsWithin_inter, nhdsWithin_inter, nhdsWithin_extChartAt_target_eq] #align unique_mdiff_within_at_iff uniqueMDiffWithinAt_iff nonrec theorem UniqueMDiffWithinAt.mono_nhds {s t : Set M} {x : M} (hs : UniqueMDiffWithinAt I s x) (ht : 𝓝[s] x ≀ 𝓝[t] x) : UniqueMDiffWithinAt I t x := hs.mono_nhds <| by simpa only [← map_extChartAt_nhdsWithin] using Filter.map_mono ht theorem UniqueMDiffWithinAt.mono_of_mem {s t : Set M} {x : M} (hs : UniqueMDiffWithinAt I s x) (ht : t ∈ 𝓝[s] x) : UniqueMDiffWithinAt I t x := hs.mono_nhds (nhdsWithin_le_iff.2 ht) theorem UniqueMDiffWithinAt.mono (h : UniqueMDiffWithinAt I s x) (st : s βŠ† t) : UniqueMDiffWithinAt I t x := UniqueDiffWithinAt.mono h <| inter_subset_inter (preimage_mono st) (Subset.refl _) #align unique_mdiff_within_at.mono UniqueMDiffWithinAt.mono theorem UniqueMDiffWithinAt.inter' (hs : UniqueMDiffWithinAt I s x) (ht : t ∈ 𝓝[s] x) : UniqueMDiffWithinAt I (s ∩ t) x := hs.mono_of_mem (Filter.inter_mem self_mem_nhdsWithin ht) #align unique_mdiff_within_at.inter' UniqueMDiffWithinAt.inter' theorem UniqueMDiffWithinAt.inter (hs : UniqueMDiffWithinAt I s x) (ht : t ∈ 𝓝 x) : UniqueMDiffWithinAt I (s ∩ t) x := hs.inter' (nhdsWithin_le_nhds ht) #align unique_mdiff_within_at.inter UniqueMDiffWithinAt.inter theorem IsOpen.uniqueMDiffWithinAt (hs : IsOpen s) (xs : x ∈ s) : UniqueMDiffWithinAt I s x := (uniqueMDiffWithinAt_univ I).mono_of_mem <| nhdsWithin_le_nhds <| hs.mem_nhds xs #align is_open.unique_mdiff_within_at IsOpen.uniqueMDiffWithinAt theorem UniqueMDiffOn.inter (hs : UniqueMDiffOn I s) (ht : IsOpen t) : UniqueMDiffOn I (s ∩ t) := fun _x hx => UniqueMDiffWithinAt.inter (hs _ hx.1) (ht.mem_nhds hx.2) #align unique_mdiff_on.inter UniqueMDiffOn.inter theorem IsOpen.uniqueMDiffOn (hs : IsOpen s) : UniqueMDiffOn I s := fun _x hx => hs.uniqueMDiffWithinAt hx #align is_open.unique_mdiff_on IsOpen.uniqueMDiffOn theorem uniqueMDiffOn_univ : UniqueMDiffOn I (univ : Set M) := isOpen_univ.uniqueMDiffOn #align unique_mdiff_on_univ uniqueMDiffOn_univ variable [Is : SmoothManifoldWithCorners I M] [I's : SmoothManifoldWithCorners I' M'] [I''s : SmoothManifoldWithCorners I'' M''] {f' fβ‚€' f₁' : TangentSpace I x β†’L[π•œ] TangentSpace I' (f x)} {g' : TangentSpace I' (f x) β†’L[π•œ] TangentSpace I'' (g (f x))} nonrec theorem UniqueMDiffWithinAt.eq (U : UniqueMDiffWithinAt I s x) (h : HasMFDerivWithinAt I I' f s x f') (h₁ : HasMFDerivWithinAt I I' f s x f₁') : f' = f₁' := by -- Porting note: didn't need `convert` because of finding instances by unification convert U.eq h.2 h₁.2 #align unique_mdiff_within_at.eq UniqueMDiffWithinAt.eq theorem UniqueMDiffOn.eq (U : UniqueMDiffOn I s) (hx : x ∈ s) (h : HasMFDerivWithinAt I I' f s x f') (h₁ : HasMFDerivWithinAt I I' f s x f₁') : f' = f₁' := UniqueMDiffWithinAt.eq (U _ hx) h h₁ #align unique_mdiff_on.eq UniqueMDiffOn.eq nonrec theorem UniqueMDiffWithinAt.prod {x : M} {y : M'} {s t} (hs : UniqueMDiffWithinAt I s x) (ht : UniqueMDiffWithinAt I' t y) : UniqueMDiffWithinAt (I.prod I') (s Γ—Λ’ t) (x, y) := by refine (hs.prod ht).mono ?_ rw [ModelWithCorners.range_prod, ← prod_inter_prod] rfl theorem UniqueMDiffOn.prod {s : Set M} {t : Set M'} (hs : UniqueMDiffOn I s) (ht : UniqueMDiffOn I' t) : UniqueMDiffOn (I.prod I') (s Γ—Λ’ t) := fun x h ↦ (hs x.1 h.1).prod (ht x.2 h.2) theorem mdifferentiableWithinAt_iff {f : M β†’ M'} {s : Set M} {x : M} : MDifferentiableWithinAt I I' f s x ↔ ContinuousWithinAt f s x ∧ DifferentiableWithinAt π•œ (writtenInExtChartAt I I' x f) ((extChartAt I x).target ∩ (extChartAt I x).symm ⁻¹' s) ((extChartAt I x) x) := by rw [mdifferentiableWithinAt_iff'] refine and_congr Iff.rfl (exists_congr fun f' => ?_) rw [inter_comm] simp only [HasFDerivWithinAt, nhdsWithin_inter, nhdsWithin_extChartAt_target_eq] #align mdifferentiable_within_at_iff mdifferentiableWithinAt_iff theorem mdifferentiableWithinAt_iff_of_mem_source {x' : M} {y : M'} (hx : x' ∈ (chartAt H x).source) (hy : f x' ∈ (chartAt H' y).source) : MDifferentiableWithinAt I I' f s x' ↔ ContinuousWithinAt f s x' ∧ DifferentiableWithinAt π•œ (extChartAt I' y ∘ f ∘ (extChartAt I x).symm) ((extChartAt I x).symm ⁻¹' s ∩ Set.range I) ((extChartAt I x) x') := (differentiable_within_at_localInvariantProp I I').liftPropWithinAt_indep_chart (StructureGroupoid.chart_mem_maximalAtlas _ x) hx (StructureGroupoid.chart_mem_maximalAtlas _ y) hy #align mdifferentiable_within_at_iff_of_mem_source mdifferentiableWithinAt_iff_of_mem_source theorem mfderivWithin_zero_of_not_mdifferentiableWithinAt (h : Β¬MDifferentiableWithinAt I I' f s x) : mfderivWithin I I' f s x = 0 := by simp only [mfderivWithin, h, if_neg, not_false_iff] #align mfderiv_within_zero_of_not_mdifferentiable_within_at mfderivWithin_zero_of_not_mdifferentiableWithinAt theorem mfderiv_zero_of_not_mdifferentiableAt (h : Β¬MDifferentiableAt I I' f x) : mfderiv I I' f x = 0 := by simp only [mfderiv, h, if_neg, not_false_iff] #align mfderiv_zero_of_not_mdifferentiable_at mfderiv_zero_of_not_mdifferentiableAt theorem HasMFDerivWithinAt.mono (h : HasMFDerivWithinAt I I' f t x f') (hst : s βŠ† t) : HasMFDerivWithinAt I I' f s x f' := ⟨ContinuousWithinAt.mono h.1 hst, HasFDerivWithinAt.mono h.2 (inter_subset_inter (preimage_mono hst) (Subset.refl _))⟩ #align has_mfderiv_within_at.mono HasMFDerivWithinAt.mono theorem HasMFDerivAt.hasMFDerivWithinAt (h : HasMFDerivAt I I' f x f') : HasMFDerivWithinAt I I' f s x f' := ⟨ContinuousAt.continuousWithinAt h.1, HasFDerivWithinAt.mono h.2 inter_subset_right⟩ #align has_mfderiv_at.has_mfderiv_within_at HasMFDerivAt.hasMFDerivWithinAt theorem HasMFDerivWithinAt.mdifferentiableWithinAt (h : HasMFDerivWithinAt I I' f s x f') : MDifferentiableWithinAt I I' f s x := ⟨h.1, ⟨f', h.2⟩⟩ #align has_mfderiv_within_at.mdifferentiable_within_at HasMFDerivWithinAt.mdifferentiableWithinAt theorem HasMFDerivAt.mdifferentiableAt (h : HasMFDerivAt I I' f x f') : MDifferentiableAt I I' f x := by rw [mdifferentiableAt_iff] exact ⟨h.1, ⟨f', h.2⟩⟩ #align has_mfderiv_at.mdifferentiable_at HasMFDerivAt.mdifferentiableAt @[simp, mfld_simps] theorem hasMFDerivWithinAt_univ : HasMFDerivWithinAt I I' f univ x f' ↔ HasMFDerivAt I I' f x f' := by simp only [HasMFDerivWithinAt, HasMFDerivAt, continuousWithinAt_univ, mfld_simps] #align has_mfderiv_within_at_univ hasMFDerivWithinAt_univ theorem hasMFDerivAt_unique (hβ‚€ : HasMFDerivAt I I' f x fβ‚€') (h₁ : HasMFDerivAt I I' f x f₁') : fβ‚€' = f₁' := by rw [← hasMFDerivWithinAt_univ] at hβ‚€ h₁ exact (uniqueMDiffWithinAt_univ I).eq hβ‚€ h₁ #align has_mfderiv_at_unique hasMFDerivAt_unique theorem hasMFDerivWithinAt_inter' (h : t ∈ 𝓝[s] x) : HasMFDerivWithinAt I I' f (s ∩ t) x f' ↔ HasMFDerivWithinAt I I' f s x f' := by rw [HasMFDerivWithinAt, HasMFDerivWithinAt, extChartAt_preimage_inter_eq, hasFDerivWithinAt_inter', continuousWithinAt_inter' h] exact extChartAt_preimage_mem_nhdsWithin I h #align has_mfderiv_within_at_inter' hasMFDerivWithinAt_inter' theorem hasMFDerivWithinAt_inter (h : t ∈ 𝓝 x) : HasMFDerivWithinAt I I' f (s ∩ t) x f' ↔ HasMFDerivWithinAt I I' f s x f' := by rw [HasMFDerivWithinAt, HasMFDerivWithinAt, extChartAt_preimage_inter_eq, hasFDerivWithinAt_inter, continuousWithinAt_inter h] exact extChartAt_preimage_mem_nhds I h #align has_mfderiv_within_at_inter hasMFDerivWithinAt_inter theorem HasMFDerivWithinAt.union (hs : HasMFDerivWithinAt I I' f s x f') (ht : HasMFDerivWithinAt I I' f t x f') : HasMFDerivWithinAt I I' f (s βˆͺ t) x f' := by constructor Β· exact ContinuousWithinAt.union hs.1 ht.1 Β· convert HasFDerivWithinAt.union hs.2 ht.2 using 1 simp only [union_inter_distrib_right, preimage_union] #align has_mfderiv_within_at.union HasMFDerivWithinAt.union theorem HasMFDerivWithinAt.mono_of_mem (h : HasMFDerivWithinAt I I' f s x f') (ht : s ∈ 𝓝[t] x) : HasMFDerivWithinAt I I' f t x f' := (hasMFDerivWithinAt_inter' ht).1 (h.mono inter_subset_right) #align has_mfderiv_within_at.nhds_within HasMFDerivWithinAt.mono_of_mem theorem HasMFDerivWithinAt.hasMFDerivAt (h : HasMFDerivWithinAt I I' f s x f') (hs : s ∈ 𝓝 x) : HasMFDerivAt I I' f x f' := by rwa [← univ_inter s, hasMFDerivWithinAt_inter hs, hasMFDerivWithinAt_univ] at h #align has_mfderiv_within_at.has_mfderiv_at HasMFDerivWithinAt.hasMFDerivAt theorem MDifferentiableWithinAt.hasMFDerivWithinAt (h : MDifferentiableWithinAt I I' f s x) : HasMFDerivWithinAt I I' f s x (mfderivWithin I I' f s x) := by refine ⟨h.1, ?_⟩ simp only [mfderivWithin, h, if_pos, mfld_simps] exact DifferentiableWithinAt.hasFDerivWithinAt h.2 #align mdifferentiable_within_at.has_mfderiv_within_at MDifferentiableWithinAt.hasMFDerivWithinAt protected theorem MDifferentiableWithinAt.mfderivWithin (h : MDifferentiableWithinAt I I' f s x) : mfderivWithin I I' f s x = fderivWithin π•œ (writtenInExtChartAt I I' x f : _) ((extChartAt I x).symm ⁻¹' s ∩ range I) ((extChartAt I x) x) := by simp only [mfderivWithin, h, if_pos] #align mdifferentiable_within_at.mfderiv_within MDifferentiableWithinAt.mfderivWithin theorem MDifferentiableAt.hasMFDerivAt (h : MDifferentiableAt I I' f x) : HasMFDerivAt I I' f x (mfderiv I I' f x) := by refine ⟨h.continuousAt, ?_⟩ simp only [mfderiv, h, if_pos, mfld_simps] exact DifferentiableWithinAt.hasFDerivWithinAt h.differentiableWithinAt_writtenInExtChartAt #align mdifferentiable_at.has_mfderiv_at MDifferentiableAt.hasMFDerivAt protected theorem MDifferentiableAt.mfderiv (h : MDifferentiableAt I I' f x) : mfderiv I I' f x = fderivWithin π•œ (writtenInExtChartAt I I' x f : _) (range I) ((extChartAt I x) x) := by simp only [mfderiv, h, if_pos] #align mdifferentiable_at.mfderiv MDifferentiableAt.mfderiv protected theorem HasMFDerivAt.mfderiv (h : HasMFDerivAt I I' f x f') : mfderiv I I' f x = f' := (hasMFDerivAt_unique h h.mdifferentiableAt.hasMFDerivAt).symm #align has_mfderiv_at.mfderiv HasMFDerivAt.mfderiv theorem HasMFDerivWithinAt.mfderivWithin (h : HasMFDerivWithinAt I I' f s x f') (hxs : UniqueMDiffWithinAt I s x) : mfderivWithin I I' f s x = f' := by ext rw [hxs.eq h h.mdifferentiableWithinAt.hasMFDerivWithinAt] #align has_mfderiv_within_at.mfderiv_within HasMFDerivWithinAt.mfderivWithin theorem MDifferentiable.mfderivWithin (h : MDifferentiableAt I I' f x) (hxs : UniqueMDiffWithinAt I s x) : mfderivWithin I I' f s x = mfderiv I I' f x := by apply HasMFDerivWithinAt.mfderivWithin _ hxs exact h.hasMFDerivAt.hasMFDerivWithinAt #align mdifferentiable.mfderiv_within MDifferentiable.mfderivWithin theorem mfderivWithin_subset (st : s βŠ† t) (hs : UniqueMDiffWithinAt I s x) (h : MDifferentiableWithinAt I I' f t x) : mfderivWithin I I' f s x = mfderivWithin I I' f t x := ((MDifferentiableWithinAt.hasMFDerivWithinAt h).mono st).mfderivWithin hs #align mfderiv_within_subset mfderivWithin_subset theorem MDifferentiableWithinAt.mono (hst : s βŠ† t) (h : MDifferentiableWithinAt I I' f t x) : MDifferentiableWithinAt I I' f s x := ⟨ContinuousWithinAt.mono h.1 hst, DifferentiableWithinAt.mono h.differentiableWithinAt_writtenInExtChartAt (inter_subset_inter_left _ (preimage_mono hst))⟩ #align mdifferentiable_within_at.mono MDifferentiableWithinAt.mono theorem mdifferentiableWithinAt_univ : MDifferentiableWithinAt I I' f univ x ↔ MDifferentiableAt I I' f x := by simp_rw [MDifferentiableWithinAt, MDifferentiableAt, ChartedSpace.LiftPropAt] #align mdifferentiable_within_at_univ mdifferentiableWithinAt_univ theorem mdifferentiableWithinAt_inter (ht : t ∈ 𝓝 x) : MDifferentiableWithinAt I I' f (s ∩ t) x ↔ MDifferentiableWithinAt I I' f s x := by rw [MDifferentiableWithinAt, MDifferentiableWithinAt, (differentiable_within_at_localInvariantProp I I').liftPropWithinAt_inter ht] #align mdifferentiable_within_at_inter mdifferentiableWithinAt_inter theorem mdifferentiableWithinAt_inter' (ht : t ∈ 𝓝[s] x) : MDifferentiableWithinAt I I' f (s ∩ t) x ↔ MDifferentiableWithinAt I I' f s x := by rw [MDifferentiableWithinAt, MDifferentiableWithinAt, (differentiable_within_at_localInvariantProp I I').liftPropWithinAt_inter' ht] #align mdifferentiable_within_at_inter' mdifferentiableWithinAt_inter' theorem MDifferentiableAt.mdifferentiableWithinAt (h : MDifferentiableAt I I' f x) : MDifferentiableWithinAt I I' f s x := MDifferentiableWithinAt.mono (subset_univ _) (mdifferentiableWithinAt_univ.2 h) #align mdifferentiable_at.mdifferentiable_within_at MDifferentiableAt.mdifferentiableWithinAt theorem MDifferentiableWithinAt.mdifferentiableAt (h : MDifferentiableWithinAt I I' f s x) (hs : s ∈ 𝓝 x) : MDifferentiableAt I I' f x := by have : s = univ ∩ s := by rw [univ_inter] rwa [this, mdifferentiableWithinAt_inter hs, mdifferentiableWithinAt_univ] at h #align mdifferentiable_within_at.mdifferentiable_at MDifferentiableWithinAt.mdifferentiableAt theorem MDifferentiableOn.mdifferentiableAt (h : MDifferentiableOn I I' f s) (hx : s ∈ 𝓝 x) : MDifferentiableAt I I' f x := (h x (mem_of_mem_nhds hx)).mdifferentiableAt hx theorem MDifferentiableOn.mono (h : MDifferentiableOn I I' f t) (st : s βŠ† t) : MDifferentiableOn I I' f s := fun x hx => (h x (st hx)).mono st #align mdifferentiable_on.mono MDifferentiableOn.mono theorem mdifferentiableOn_univ : MDifferentiableOn I I' f univ ↔ MDifferentiable I I' f := by simp only [MDifferentiableOn, mdifferentiableWithinAt_univ, mfld_simps]; rfl #align mdifferentiable_on_univ mdifferentiableOn_univ theorem MDifferentiable.mdifferentiableOn (h : MDifferentiable I I' f) : MDifferentiableOn I I' f s := (mdifferentiableOn_univ.2 h).mono (subset_univ _) #align mdifferentiable.mdifferentiable_on MDifferentiable.mdifferentiableOn theorem mdifferentiableOn_of_locally_mdifferentiableOn (h : βˆ€ x ∈ s, βˆƒ u, IsOpen u ∧ x ∈ u ∧ MDifferentiableOn I I' f (s ∩ u)) : MDifferentiableOn I I' f s := by intro x xs rcases h x xs with ⟨t, t_open, xt, ht⟩ exact (mdifferentiableWithinAt_inter (t_open.mem_nhds xt)).1 (ht x ⟨xs, xt⟩) #align mdifferentiable_on_of_locally_mdifferentiable_on mdifferentiableOn_of_locally_mdifferentiableOn @[simp, mfld_simps] theorem mfderivWithin_univ : mfderivWithin I I' f univ = mfderiv I I' f := by ext x : 1 simp only [mfderivWithin, mfderiv, mfld_simps] rw [mdifferentiableWithinAt_univ] #align mfderiv_within_univ mfderivWithin_univ theorem mfderivWithin_inter (ht : t ∈ 𝓝 x) : mfderivWithin I I' f (s ∩ t) x = mfderivWithin I I' f s x := by rw [mfderivWithin, mfderivWithin, extChartAt_preimage_inter_eq, mdifferentiableWithinAt_inter ht, fderivWithin_inter (extChartAt_preimage_mem_nhds I ht)] #align mfderiv_within_inter mfderivWithin_inter theorem mfderivWithin_of_mem_nhds (h : s ∈ 𝓝 x) : mfderivWithin I I' f s x = mfderiv I I' f x := by rw [← mfderivWithin_univ, ← univ_inter s, mfderivWithin_inter h] lemma mfderivWithin_of_isOpen (hs : IsOpen s) (hx : x ∈ s) : mfderivWithin I I' f s x = mfderiv I I' f x := mfderivWithin_of_mem_nhds (hs.mem_nhds hx) theorem mfderivWithin_eq_mfderiv (hs : UniqueMDiffWithinAt I s x) (h : MDifferentiableAt I I' f x) : mfderivWithin I I' f s x = mfderiv I I' f x := by rw [← mfderivWithin_univ] exact mfderivWithin_subset (subset_univ _) hs h.mdifferentiableWithinAt theorem mdifferentiableAt_iff_of_mem_source {x' : M} {y : M'} (hx : x' ∈ (chartAt H x).source) (hy : f x' ∈ (chartAt H' y).source) : MDifferentiableAt I I' f x' ↔ ContinuousAt f x' ∧ DifferentiableWithinAt π•œ (extChartAt I' y ∘ f ∘ (extChartAt I x).symm) (Set.range I) ((extChartAt I x) x') := mdifferentiableWithinAt_univ.symm.trans <| (mdifferentiableWithinAt_iff_of_mem_source hx hy).trans <| by rw [continuousWithinAt_univ, Set.preimage_univ, Set.univ_inter] #align mdifferentiable_at_iff_of_mem_source mdifferentiableAt_iff_of_mem_source -- Porting note: moved from `ContMDiffMFDeriv` variable {n : β„•βˆž} theorem ContMDiffWithinAt.mdifferentiableWithinAt (hf : ContMDiffWithinAt I I' n f s x) (hn : 1 ≀ n) : MDifferentiableWithinAt I I' f s x := by suffices h : MDifferentiableWithinAt I I' f (s ∩ f ⁻¹' (extChartAt I' (f x)).source) x by rwa [mdifferentiableWithinAt_inter'] at h apply hf.1.preimage_mem_nhdsWithin exact extChartAt_source_mem_nhds I' (f x) rw [mdifferentiableWithinAt_iff] exact ⟨hf.1.mono inter_subset_left, (hf.2.differentiableWithinAt hn).mono (by mfld_set_tac)⟩ #align cont_mdiff_within_at.mdifferentiable_within_at ContMDiffWithinAt.mdifferentiableWithinAt theorem ContMDiffAt.mdifferentiableAt (hf : ContMDiffAt I I' n f x) (hn : 1 ≀ n) : MDifferentiableAt I I' f x := mdifferentiableWithinAt_univ.1 <| ContMDiffWithinAt.mdifferentiableWithinAt hf hn #align cont_mdiff_at.mdifferentiable_at ContMDiffAt.mdifferentiableAt theorem ContMDiffOn.mdifferentiableOn (hf : ContMDiffOn I I' n f s) (hn : 1 ≀ n) : MDifferentiableOn I I' f s := fun x hx => (hf x hx).mdifferentiableWithinAt hn #align cont_mdiff_on.mdifferentiable_on ContMDiffOn.mdifferentiableOn theorem ContMDiff.mdifferentiable (hf : ContMDiff I I' n f) (hn : 1 ≀ n) : MDifferentiable I I' f := fun x => (hf x).mdifferentiableAt hn #align cont_mdiff.mdifferentiable ContMDiff.mdifferentiable nonrec theorem SmoothWithinAt.mdifferentiableWithinAt (hf : SmoothWithinAt I I' f s x) : MDifferentiableWithinAt I I' f s x := hf.mdifferentiableWithinAt le_top #align smooth_within_at.mdifferentiable_within_at SmoothWithinAt.mdifferentiableWithinAt nonrec theorem SmoothAt.mdifferentiableAt (hf : SmoothAt I I' f x) : MDifferentiableAt I I' f x := hf.mdifferentiableAt le_top #align smooth_at.mdifferentiable_at SmoothAt.mdifferentiableAt nonrec theorem SmoothOn.mdifferentiableOn (hf : SmoothOn I I' f s) : MDifferentiableOn I I' f s := hf.mdifferentiableOn le_top #align smooth_on.mdifferentiable_on SmoothOn.mdifferentiableOn theorem Smooth.mdifferentiable (hf : Smooth I I' f) : MDifferentiable I I' f := ContMDiff.mdifferentiable hf le_top #align smooth.mdifferentiable Smooth.mdifferentiable theorem Smooth.mdifferentiableAt (hf : Smooth I I' f) : MDifferentiableAt I I' f x := hf.mdifferentiable x #align smooth.mdifferentiable_at Smooth.mdifferentiableAt theorem Smooth.mdifferentiableWithinAt (hf : Smooth I I' f) : MDifferentiableWithinAt I I' f s x := hf.mdifferentiableAt.mdifferentiableWithinAt #align smooth.mdifferentiable_within_at Smooth.mdifferentiableWithinAt theorem HasMFDerivWithinAt.continuousWithinAt (h : HasMFDerivWithinAt I I' f s x f') : ContinuousWithinAt f s x := h.1 #align has_mfderiv_within_at.continuous_within_at HasMFDerivWithinAt.continuousWithinAt theorem HasMFDerivAt.continuousAt (h : HasMFDerivAt I I' f x f') : ContinuousAt f x := h.1 #align has_mfderiv_at.continuous_at HasMFDerivAt.continuousAt theorem MDifferentiableOn.continuousOn (h : MDifferentiableOn I I' f s) : ContinuousOn f s := fun x hx => (h x hx).continuousWithinAt #align mdifferentiable_on.continuous_on MDifferentiableOn.continuousOn theorem MDifferentiable.continuous (h : MDifferentiable I I' f) : Continuous f := continuous_iff_continuousAt.2 fun x => (h x).continuousAt #align mdifferentiable.continuous MDifferentiable.continuous theorem tangentMapWithin_subset {p : TangentBundle I M} (st : s βŠ† t) (hs : UniqueMDiffWithinAt I s p.1) (h : MDifferentiableWithinAt I I' f t p.1) : tangentMapWithin I I' f s p = tangentMapWithin I I' f t p := by simp only [tangentMapWithin, mfld_simps] rw [mfderivWithin_subset st hs h] #align tangent_map_within_subset tangentMapWithin_subset
Mathlib/Geometry/Manifold/MFDeriv/Basic.lean
460
462
theorem tangentMapWithin_univ : tangentMapWithin I I' f univ = tangentMap I I' f := by
ext p : 1 simp only [tangentMapWithin, tangentMap, mfld_simps]
import Mathlib.Algebra.Group.Submonoid.Basic import Mathlib.Algebra.Group.Subsemigroup.Operations import Mathlib.Algebra.Group.Nat import Mathlib.GroupTheory.GroupAction.Defs #align_import group_theory.submonoid.operations from "leanprover-community/mathlib"@"cf8e77c636317b059a8ce20807a29cf3772a0640" assert_not_exists MonoidWithZero variable {M N P : Type*} [MulOneClass M] [MulOneClass N] [MulOneClass P] (S : Submonoid M) section @[simps] def Submonoid.toAddSubmonoid : Submonoid M ≃o AddSubmonoid (Additive M) where toFun S := { carrier := Additive.toMul ⁻¹' S zero_mem' := S.one_mem' add_mem' := fun ha hb => S.mul_mem' ha hb } invFun S := { carrier := Additive.ofMul ⁻¹' S one_mem' := S.zero_mem' mul_mem' := fun ha hb => S.add_mem' ha hb} left_inv x := by cases x; rfl right_inv x := by cases x; rfl map_rel_iff' := Iff.rfl #align submonoid.to_add_submonoid Submonoid.toAddSubmonoid #align submonoid.to_add_submonoid_symm_apply_coe Submonoid.toAddSubmonoid_symm_apply_coe #align submonoid.to_add_submonoid_apply_coe Submonoid.toAddSubmonoid_apply_coe abbrev AddSubmonoid.toSubmonoid' : AddSubmonoid (Additive M) ≃o Submonoid M := Submonoid.toAddSubmonoid.symm #align add_submonoid.to_submonoid' AddSubmonoid.toSubmonoid' theorem Submonoid.toAddSubmonoid_closure (S : Set M) : Submonoid.toAddSubmonoid (Submonoid.closure S) = AddSubmonoid.closure (Additive.toMul ⁻¹' S) := le_antisymm (Submonoid.toAddSubmonoid.le_symm_apply.1 <| Submonoid.closure_le.2 (AddSubmonoid.subset_closure (M := Additive M))) (AddSubmonoid.closure_le.2 <| Submonoid.subset_closure (M := M)) #align submonoid.to_add_submonoid_closure Submonoid.toAddSubmonoid_closure theorem AddSubmonoid.toSubmonoid'_closure (S : Set (Additive M)) : AddSubmonoid.toSubmonoid' (AddSubmonoid.closure S) = Submonoid.closure (Multiplicative.ofAdd ⁻¹' S) := le_antisymm (AddSubmonoid.toSubmonoid'.le_symm_apply.1 <| AddSubmonoid.closure_le.2 (Submonoid.subset_closure (M := M))) (Submonoid.closure_le.2 <| AddSubmonoid.subset_closure (M := Additive M)) #align add_submonoid.to_submonoid'_closure AddSubmonoid.toSubmonoid'_closure end section variable {A : Type*} [AddZeroClass A] @[simps] def AddSubmonoid.toSubmonoid : AddSubmonoid A ≃o Submonoid (Multiplicative A) where toFun S := { carrier := Multiplicative.toAdd ⁻¹' S one_mem' := S.zero_mem' mul_mem' := fun ha hb => S.add_mem' ha hb } invFun S := { carrier := Multiplicative.ofAdd ⁻¹' S zero_mem' := S.one_mem' add_mem' := fun ha hb => S.mul_mem' ha hb} left_inv x := by cases x; rfl right_inv x := by cases x; rfl map_rel_iff' := Iff.rfl #align add_submonoid.to_submonoid AddSubmonoid.toSubmonoid #align add_submonoid.to_submonoid_symm_apply_coe AddSubmonoid.toSubmonoid_symm_apply_coe #align add_submonoid.to_submonoid_apply_coe AddSubmonoid.toSubmonoid_apply_coe abbrev Submonoid.toAddSubmonoid' : Submonoid (Multiplicative A) ≃o AddSubmonoid A := AddSubmonoid.toSubmonoid.symm #align submonoid.to_add_submonoid' Submonoid.toAddSubmonoid' theorem AddSubmonoid.toSubmonoid_closure (S : Set A) : (AddSubmonoid.toSubmonoid) (AddSubmonoid.closure S) = Submonoid.closure (Multiplicative.toAdd ⁻¹' S) := le_antisymm (AddSubmonoid.toSubmonoid.to_galoisConnection.l_le <| AddSubmonoid.closure_le.2 <| Submonoid.subset_closure (M := Multiplicative A)) (Submonoid.closure_le.2 <| AddSubmonoid.subset_closure (M := A)) #align add_submonoid.to_submonoid_closure AddSubmonoid.toSubmonoid_closure theorem Submonoid.toAddSubmonoid'_closure (S : Set (Multiplicative A)) : Submonoid.toAddSubmonoid' (Submonoid.closure S) = AddSubmonoid.closure (Additive.ofMul ⁻¹' S) := le_antisymm (Submonoid.toAddSubmonoid'.to_galoisConnection.l_le <| Submonoid.closure_le.2 <| AddSubmonoid.subset_closure (M := A)) (AddSubmonoid.closure_le.2 <| Submonoid.subset_closure (M := Multiplicative A)) #align submonoid.to_add_submonoid'_closure Submonoid.toAddSubmonoid'_closure end namespace Submonoid variable {F : Type*} [FunLike F M N] [mc : MonoidHomClass F M N] open Set @[to_additive "The preimage of an `AddSubmonoid` along an `AddMonoid` homomorphism is an `AddSubmonoid`."] def comap (f : F) (S : Submonoid N) : Submonoid M where carrier := f ⁻¹' S one_mem' := show f 1 ∈ S by rw [map_one]; exact S.one_mem mul_mem' ha hb := show f (_ * _) ∈ S by rw [map_mul]; exact S.mul_mem ha hb #align submonoid.comap Submonoid.comap #align add_submonoid.comap AddSubmonoid.comap @[to_additive (attr := simp)] theorem coe_comap (S : Submonoid N) (f : F) : (S.comap f : Set M) = f ⁻¹' S := rfl #align submonoid.coe_comap Submonoid.coe_comap #align add_submonoid.coe_comap AddSubmonoid.coe_comap @[to_additive (attr := simp)] theorem mem_comap {S : Submonoid N} {f : F} {x : M} : x ∈ S.comap f ↔ f x ∈ S := Iff.rfl #align submonoid.mem_comap Submonoid.mem_comap #align add_submonoid.mem_comap AddSubmonoid.mem_comap @[to_additive] theorem comap_comap (S : Submonoid P) (g : N β†’* P) (f : M β†’* N) : (S.comap g).comap f = S.comap (g.comp f) := rfl #align submonoid.comap_comap Submonoid.comap_comap #align add_submonoid.comap_comap AddSubmonoid.comap_comap @[to_additive (attr := simp)] theorem comap_id (S : Submonoid P) : S.comap (MonoidHom.id P) = S := ext (by simp) #align submonoid.comap_id Submonoid.comap_id #align add_submonoid.comap_id AddSubmonoid.comap_id @[to_additive "The image of an `AddSubmonoid` along an `AddMonoid` homomorphism is an `AddSubmonoid`."] def map (f : F) (S : Submonoid M) : Submonoid N where carrier := f '' S one_mem' := ⟨1, S.one_mem, map_one f⟩ mul_mem' := by rintro _ _ ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩; exact ⟨x * y, S.mul_mem hx hy, by rw [map_mul]⟩ #align submonoid.map Submonoid.map #align add_submonoid.map AddSubmonoid.map @[to_additive (attr := simp)] theorem coe_map (f : F) (S : Submonoid M) : (S.map f : Set N) = f '' S := rfl #align submonoid.coe_map Submonoid.coe_map #align add_submonoid.coe_map AddSubmonoid.coe_map @[to_additive (attr := simp)] theorem mem_map {f : F} {S : Submonoid M} {y : N} : y ∈ S.map f ↔ βˆƒ x ∈ S, f x = y := Iff.rfl #align submonoid.mem_map Submonoid.mem_map #align add_submonoid.mem_map AddSubmonoid.mem_map @[to_additive] theorem mem_map_of_mem (f : F) {S : Submonoid M} {x : M} (hx : x ∈ S) : f x ∈ S.map f := mem_image_of_mem f hx #align submonoid.mem_map_of_mem Submonoid.mem_map_of_mem #align add_submonoid.mem_map_of_mem AddSubmonoid.mem_map_of_mem @[to_additive] theorem apply_coe_mem_map (f : F) (S : Submonoid M) (x : S) : f x ∈ S.map f := mem_map_of_mem f x.2 #align submonoid.apply_coe_mem_map Submonoid.apply_coe_mem_map #align add_submonoid.apply_coe_mem_map AddSubmonoid.apply_coe_mem_map @[to_additive] theorem map_map (g : N β†’* P) (f : M β†’* N) : (S.map f).map g = S.map (g.comp f) := SetLike.coe_injective <| image_image _ _ _ #align submonoid.map_map Submonoid.map_map #align add_submonoid.map_map AddSubmonoid.map_map -- The simpNF linter says that the LHS can be simplified via `Submonoid.mem_map`. -- However this is a higher priority lemma. -- https://github.com/leanprover/std4/issues/207 @[to_additive (attr := simp 1100, nolint simpNF)] theorem mem_map_iff_mem {f : F} (hf : Function.Injective f) {S : Submonoid M} {x : M} : f x ∈ S.map f ↔ x ∈ S := hf.mem_set_image #align submonoid.mem_map_iff_mem Submonoid.mem_map_iff_mem #align add_submonoid.mem_map_iff_mem AddSubmonoid.mem_map_iff_mem @[to_additive] theorem map_le_iff_le_comap {f : F} {S : Submonoid M} {T : Submonoid N} : S.map f ≀ T ↔ S ≀ T.comap f := image_subset_iff #align submonoid.map_le_iff_le_comap Submonoid.map_le_iff_le_comap #align add_submonoid.map_le_iff_le_comap AddSubmonoid.map_le_iff_le_comap @[to_additive] theorem gc_map_comap (f : F) : GaloisConnection (map f) (comap f) := fun _ _ => map_le_iff_le_comap #align submonoid.gc_map_comap Submonoid.gc_map_comap #align add_submonoid.gc_map_comap AddSubmonoid.gc_map_comap @[to_additive] theorem map_le_of_le_comap {T : Submonoid N} {f : F} : S ≀ T.comap f β†’ S.map f ≀ T := (gc_map_comap f).l_le #align submonoid.map_le_of_le_comap Submonoid.map_le_of_le_comap #align add_submonoid.map_le_of_le_comap AddSubmonoid.map_le_of_le_comap @[to_additive] theorem le_comap_of_map_le {T : Submonoid N} {f : F} : S.map f ≀ T β†’ S ≀ T.comap f := (gc_map_comap f).le_u #align submonoid.le_comap_of_map_le Submonoid.le_comap_of_map_le #align add_submonoid.le_comap_of_map_le AddSubmonoid.le_comap_of_map_le @[to_additive] theorem le_comap_map {f : F} : S ≀ (S.map f).comap f := (gc_map_comap f).le_u_l _ #align submonoid.le_comap_map Submonoid.le_comap_map #align add_submonoid.le_comap_map AddSubmonoid.le_comap_map @[to_additive] theorem map_comap_le {S : Submonoid N} {f : F} : (S.comap f).map f ≀ S := (gc_map_comap f).l_u_le _ #align submonoid.map_comap_le Submonoid.map_comap_le #align add_submonoid.map_comap_le AddSubmonoid.map_comap_le @[to_additive] theorem monotone_map {f : F} : Monotone (map f) := (gc_map_comap f).monotone_l #align submonoid.monotone_map Submonoid.monotone_map #align add_submonoid.monotone_map AddSubmonoid.monotone_map @[to_additive] theorem monotone_comap {f : F} : Monotone (comap f) := (gc_map_comap f).monotone_u #align submonoid.monotone_comap Submonoid.monotone_comap #align add_submonoid.monotone_comap AddSubmonoid.monotone_comap @[to_additive (attr := simp)] theorem map_comap_map {f : F} : ((S.map f).comap f).map f = S.map f := (gc_map_comap f).l_u_l_eq_l _ #align submonoid.map_comap_map Submonoid.map_comap_map #align add_submonoid.map_comap_map AddSubmonoid.map_comap_map @[to_additive (attr := simp)] theorem comap_map_comap {S : Submonoid N} {f : F} : ((S.comap f).map f).comap f = S.comap f := (gc_map_comap f).u_l_u_eq_u _ #align submonoid.comap_map_comap Submonoid.comap_map_comap #align add_submonoid.comap_map_comap AddSubmonoid.comap_map_comap @[to_additive] theorem map_sup (S T : Submonoid M) (f : F) : (S βŠ” T).map f = S.map f βŠ” T.map f := (gc_map_comap f : GaloisConnection (map f) (comap f)).l_sup #align submonoid.map_sup Submonoid.map_sup #align add_submonoid.map_sup AddSubmonoid.map_sup @[to_additive] theorem map_iSup {ΞΉ : Sort*} (f : F) (s : ΞΉ β†’ Submonoid M) : (iSup s).map f = ⨆ i, (s i).map f := (gc_map_comap f : GaloisConnection (map f) (comap f)).l_iSup #align submonoid.map_supr Submonoid.map_iSup #align add_submonoid.map_supr AddSubmonoid.map_iSup @[to_additive] theorem comap_inf (S T : Submonoid N) (f : F) : (S βŠ“ T).comap f = S.comap f βŠ“ T.comap f := (gc_map_comap f : GaloisConnection (map f) (comap f)).u_inf #align submonoid.comap_inf Submonoid.comap_inf #align add_submonoid.comap_inf AddSubmonoid.comap_inf @[to_additive] theorem comap_iInf {ΞΉ : Sort*} (f : F) (s : ΞΉ β†’ Submonoid N) : (iInf s).comap f = β¨… i, (s i).comap f := (gc_map_comap f : GaloisConnection (map f) (comap f)).u_iInf #align submonoid.comap_infi Submonoid.comap_iInf #align add_submonoid.comap_infi AddSubmonoid.comap_iInf @[to_additive (attr := simp)] theorem map_bot (f : F) : (βŠ₯ : Submonoid M).map f = βŠ₯ := (gc_map_comap f).l_bot #align submonoid.map_bot Submonoid.map_bot #align add_submonoid.map_bot AddSubmonoid.map_bot @[to_additive (attr := simp)] theorem comap_top (f : F) : (⊀ : Submonoid N).comap f = ⊀ := (gc_map_comap f).u_top #align submonoid.comap_top Submonoid.comap_top #align add_submonoid.comap_top AddSubmonoid.comap_top @[to_additive (attr := simp)] theorem map_id (S : Submonoid M) : S.map (MonoidHom.id M) = S := ext fun _ => ⟨fun ⟨_, h, rfl⟩ => h, fun h => ⟨_, h, rfl⟩⟩ #align submonoid.map_id Submonoid.map_id #align add_submonoid.map_id AddSubmonoid.map_id variable {A : Type*} [SetLike A M] [hA : SubmonoidClass A M] (S' : A) instance AddSubmonoidClass.nSMul {M} [AddMonoid M] {A : Type*} [SetLike A M] [AddSubmonoidClass A M] (S : A) : SMul β„• S := ⟨fun n a => ⟨n β€’ a.1, nsmul_mem a.2 n⟩⟩ #align add_submonoid_class.has_nsmul AddSubmonoidClass.nSMul namespace MonoidHom variable {F : Type*} [FunLike F M N] [mc : MonoidHomClass F M N] open Submonoid library_note "range copy pattern" @[to_additive "The range of an `AddMonoidHom` is an `AddSubmonoid`."] def mrange (f : F) : Submonoid N := ((⊀ : Submonoid M).map f).copy (Set.range f) Set.image_univ.symm #align monoid_hom.mrange MonoidHom.mrange #align add_monoid_hom.mrange AddMonoidHom.mrange @[to_additive (attr := simp)] theorem coe_mrange (f : F) : (mrange f : Set N) = Set.range f := rfl #align monoid_hom.coe_mrange MonoidHom.coe_mrange #align add_monoid_hom.coe_mrange AddMonoidHom.coe_mrange @[to_additive (attr := simp)] theorem mem_mrange {f : F} {y : N} : y ∈ mrange f ↔ βˆƒ x, f x = y := Iff.rfl #align monoid_hom.mem_mrange MonoidHom.mem_mrange #align add_monoid_hom.mem_mrange AddMonoidHom.mem_mrange @[to_additive] theorem mrange_eq_map (f : F) : mrange f = (⊀ : Submonoid M).map f := Submonoid.copy_eq _ #align monoid_hom.mrange_eq_map MonoidHom.mrange_eq_map #align add_monoid_hom.mrange_eq_map AddMonoidHom.mrange_eq_map @[to_additive (attr := simp)] theorem mrange_id : mrange (MonoidHom.id M) = ⊀ := by simp [mrange_eq_map] @[to_additive] theorem map_mrange (g : N β†’* P) (f : M β†’* N) : f.mrange.map g = mrange (comp g f) := by simpa only [mrange_eq_map] using (⊀ : Submonoid M).map_map g f #align monoid_hom.map_mrange MonoidHom.map_mrange #align add_monoid_hom.map_mrange AddMonoidHom.map_mrange @[to_additive] theorem mrange_top_iff_surjective {f : F} : mrange f = (⊀ : Submonoid N) ↔ Function.Surjective f := SetLike.ext'_iff.trans <| Iff.trans (by rw [coe_mrange, coe_top]) Set.range_iff_surjective #align monoid_hom.mrange_top_iff_surjective MonoidHom.mrange_top_iff_surjective #align add_monoid_hom.mrange_top_iff_surjective AddMonoidHom.mrange_top_iff_surjective @[to_additive (attr := simp) "The range of a surjective `AddMonoid` hom is the whole of the codomain."] theorem mrange_top_of_surjective (f : F) (hf : Function.Surjective f) : mrange f = (⊀ : Submonoid N) := mrange_top_iff_surjective.2 hf #align monoid_hom.mrange_top_of_surjective MonoidHom.mrange_top_of_surjective #align add_monoid_hom.mrange_top_of_surjective AddMonoidHom.mrange_top_of_surjective @[to_additive] theorem mclosure_preimage_le (f : F) (s : Set N) : closure (f ⁻¹' s) ≀ (closure s).comap f := closure_le.2 fun _ hx => SetLike.mem_coe.2 <| mem_comap.2 <| subset_closure hx #align monoid_hom.mclosure_preimage_le MonoidHom.mclosure_preimage_le #align add_monoid_hom.mclosure_preimage_le AddMonoidHom.mclosure_preimage_le @[to_additive "The image under an `AddMonoid` hom of the `AddSubmonoid` generated by a set equals the `AddSubmonoid` generated by the image of the set."] theorem map_mclosure (f : F) (s : Set M) : (closure s).map f = closure (f '' s) := le_antisymm (map_le_iff_le_comap.2 <| le_trans (closure_mono <| Set.subset_preimage_image _ _) (mclosure_preimage_le _ _)) (closure_le.2 <| Set.image_subset _ subset_closure) #align monoid_hom.map_mclosure MonoidHom.map_mclosure #align add_monoid_hom.map_mclosure AddMonoidHom.map_mclosure @[to_additive (attr := simp)] theorem mclosure_range (f : F) : closure (Set.range f) = mrange f := by rw [← Set.image_univ, ← map_mclosure, mrange_eq_map, closure_univ] @[to_additive "Restriction of an `AddMonoid` hom to an `AddSubmonoid` of the domain."] def restrict {N S : Type*} [MulOneClass N] [SetLike S M] [SubmonoidClass S M] (f : M β†’* N) (s : S) : s β†’* N := f.comp (SubmonoidClass.subtype _) #align monoid_hom.restrict MonoidHom.restrict #align add_monoid_hom.restrict AddMonoidHom.restrict @[to_additive (attr := simp)] theorem restrict_apply {N S : Type*} [MulOneClass N] [SetLike S M] [SubmonoidClass S M] (f : M β†’* N) (s : S) (x : s) : f.restrict s x = f x := rfl #align monoid_hom.restrict_apply MonoidHom.restrict_apply #align add_monoid_hom.restrict_apply AddMonoidHom.restrict_apply @[to_additive (attr := simp)] theorem restrict_mrange (f : M β†’* N) : mrange (f.restrict S) = S.map f := by simp [SetLike.ext_iff] #align monoid_hom.restrict_mrange MonoidHom.restrict_mrange #align add_monoid_hom.restrict_mrange AddMonoidHom.restrict_mrange @[to_additive (attr := simps apply) "Restriction of an `AddMonoid` hom to an `AddSubmonoid` of the codomain."] def codRestrict {S} [SetLike S N] [SubmonoidClass S N] (f : M β†’* N) (s : S) (h : βˆ€ x, f x ∈ s) : M β†’* s where toFun n := ⟨f n, h n⟩ map_one' := Subtype.eq f.map_one map_mul' x y := Subtype.eq (f.map_mul x y) #align monoid_hom.cod_restrict MonoidHom.codRestrict #align add_monoid_hom.cod_restrict AddMonoidHom.codRestrict #align monoid_hom.cod_restrict_apply MonoidHom.codRestrict_apply @[to_additive "Restriction of an `AddMonoid` hom to its range interpreted as a submonoid."] def mrangeRestrict {N} [MulOneClass N] (f : M β†’* N) : M β†’* (mrange f) := (f.codRestrict (mrange f)) fun x => ⟨x, rfl⟩ #align monoid_hom.mrange_restrict MonoidHom.mrangeRestrict #align add_monoid_hom.mrange_restrict AddMonoidHom.mrangeRestrict @[to_additive (attr := simp)] theorem coe_mrangeRestrict {N} [MulOneClass N] (f : M β†’* N) (x : M) : (f.mrangeRestrict x : N) = f x := rfl #align monoid_hom.coe_mrange_restrict MonoidHom.coe_mrangeRestrict #align add_monoid_hom.coe_mrange_restrict AddMonoidHom.coe_mrangeRestrict @[to_additive] theorem mrangeRestrict_surjective (f : M β†’* N) : Function.Surjective f.mrangeRestrict := fun ⟨_, ⟨x, rfl⟩⟩ => ⟨x, rfl⟩ #align monoid_hom.mrange_restrict_surjective MonoidHom.mrangeRestrict_surjective #align add_monoid_hom.mrange_restrict_surjective AddMonoidHom.mrangeRestrict_surjective @[to_additive "The additive kernel of an `AddMonoid` hom is the `AddSubmonoid` of elements such that `f x = 0`"] def mker (f : F) : Submonoid M := (βŠ₯ : Submonoid N).comap f #align monoid_hom.mker MonoidHom.mker #align add_monoid_hom.mker AddMonoidHom.mker @[to_additive] theorem mem_mker (f : F) {x : M} : x ∈ mker f ↔ f x = 1 := Iff.rfl #align monoid_hom.mem_mker MonoidHom.mem_mker #align add_monoid_hom.mem_mker AddMonoidHom.mem_mker @[to_additive] theorem coe_mker (f : F) : (mker f : Set M) = (f : M β†’ N) ⁻¹' {1} := rfl #align monoid_hom.coe_mker MonoidHom.coe_mker #align add_monoid_hom.coe_mker AddMonoidHom.coe_mker @[to_additive] instance decidableMemMker [DecidableEq N] (f : F) : DecidablePred (Β· ∈ mker f) := fun x => decidable_of_iff (f x = 1) (mem_mker f) #align monoid_hom.decidable_mem_mker MonoidHom.decidableMemMker #align add_monoid_hom.decidable_mem_mker AddMonoidHom.decidableMemMker @[to_additive] theorem comap_mker (g : N β†’* P) (f : M β†’* N) : g.mker.comap f = mker (comp g f) := rfl #align monoid_hom.comap_mker MonoidHom.comap_mker #align add_monoid_hom.comap_mker AddMonoidHom.comap_mker @[to_additive (attr := simp)] theorem comap_bot' (f : F) : (βŠ₯ : Submonoid N).comap f = mker f := rfl #align monoid_hom.comap_bot' MonoidHom.comap_bot' #align add_monoid_hom.comap_bot' AddMonoidHom.comap_bot' @[to_additive (attr := simp)] theorem restrict_mker (f : M β†’* N) : mker (f.restrict S) = f.mker.comap S.subtype := rfl #align monoid_hom.restrict_mker MonoidHom.restrict_mker #align add_monoid_hom.restrict_mker AddMonoidHom.restrict_mker @[to_additive] theorem mrangeRestrict_mker (f : M β†’* N) : mker (mrangeRestrict f) = mker f := by ext x change (⟨f x, _⟩ : mrange f) = ⟨1, _⟩ ↔ f x = 1 simp #align monoid_hom.range_restrict_mker MonoidHom.mrangeRestrict_mker #align add_monoid_hom.range_restrict_mker AddMonoidHom.mrangeRestrict_mker @[to_additive (attr := simp)] theorem mker_one : mker (1 : M β†’* N) = ⊀ := by ext simp [mem_mker] #align monoid_hom.mker_one MonoidHom.mker_one #align add_monoid_hom.mker_zero AddMonoidHom.mker_zero @[to_additive prod_map_comap_prod'] theorem prod_map_comap_prod' {M' : Type*} {N' : Type*} [MulOneClass M'] [MulOneClass N'] (f : M β†’* N) (g : M' β†’* N') (S : Submonoid N) (S' : Submonoid N') : (S.prod S').comap (prodMap f g) = (S.comap f).prod (S'.comap g) := SetLike.coe_injective <| Set.preimage_prod_map_prod f g _ _ #align monoid_hom.prod_map_comap_prod' MonoidHom.prod_map_comap_prod' -- Porting note: to_additive translated the name incorrectly in mathlib 3. #align add_monoid_hom.sum_map_comap_sum' AddMonoidHom.prod_map_comap_prod' @[to_additive mker_prod_map] theorem mker_prod_map {M' : Type*} {N' : Type*} [MulOneClass M'] [MulOneClass N'] (f : M β†’* N) (g : M' β†’* N') : mker (prodMap f g) = f.mker.prod (mker g) := by rw [← comap_bot', ← comap_bot', ← comap_bot', ← prod_map_comap_prod', bot_prod_bot] #align monoid_hom.mker_prod_map MonoidHom.mker_prod_map -- Porting note: to_additive translated the name incorrectly in mathlib 3. #align add_monoid_hom.mker_sum_map AddMonoidHom.mker_prod_map @[to_additive (attr := simp)] theorem mker_inl : mker (inl M N) = βŠ₯ := by ext x simp [mem_mker] #align monoid_hom.mker_inl MonoidHom.mker_inl #align add_monoid_hom.mker_inl AddMonoidHom.mker_inl @[to_additive (attr := simp)] theorem mker_inr : mker (inr M N) = βŠ₯ := by ext x simp [mem_mker] #align monoid_hom.mker_inr MonoidHom.mker_inr #align add_monoid_hom.mker_inr AddMonoidHom.mker_inr @[to_additive (attr := simp)] lemma mker_fst : mker (fst M N) = .prod βŠ₯ ⊀ := SetLike.ext fun _ => (and_true_iff _).symm @[to_additive (attr := simp)] lemma mker_snd : mker (snd M N) = .prod ⊀ βŠ₯ := SetLike.ext fun _ => (true_and_iff _).symm @[to_additive (attr := simps) "the `AddMonoidHom` from the preimage of an additive submonoid to itself."] def submonoidComap (f : M β†’* N) (N' : Submonoid N) : N'.comap f β†’* N' where toFun x := ⟨f x, x.2⟩ map_one' := Subtype.eq f.map_one map_mul' x y := Subtype.eq (f.map_mul x y) #align monoid_hom.submonoid_comap MonoidHom.submonoidComap #align add_monoid_hom.add_submonoid_comap AddMonoidHom.addSubmonoidComap #align monoid_hom.submonoid_comap_apply_coe MonoidHom.submonoidComap_apply_coe #align add_monoid_hom.submonoid_comap_apply_coe AddMonoidHom.addSubmonoidComap_apply_coe @[to_additive (attr := simps) "the `AddMonoidHom` from an additive submonoid to its image. See `AddEquiv.AddSubmonoidMap` for a variant for `AddEquiv`s."] def submonoidMap (f : M β†’* N) (M' : Submonoid M) : M' β†’* M'.map f where toFun x := ⟨f x, ⟨x, x.2, rfl⟩⟩ map_one' := Subtype.eq <| f.map_one map_mul' x y := Subtype.eq <| f.map_mul x y #align monoid_hom.submonoid_map MonoidHom.submonoidMap #align add_monoid_hom.add_submonoid_map AddMonoidHom.addSubmonoidMap #align monoid_hom.submonoid_map_apply_coe MonoidHom.submonoidMap_apply_coe #align add_monoid_hom.submonoid_map_apply_coe AddMonoidHom.addSubmonoidMap_apply_coe @[to_additive]
Mathlib/Algebra/Group/Submonoid/Operations.lean
1,211
1,214
theorem submonoidMap_surjective (f : M β†’* N) (M' : Submonoid M) : Function.Surjective (f.submonoidMap M') := by
rintro ⟨_, x, hx, rfl⟩ exact ⟨⟨x, hx⟩, rfl⟩
import Mathlib.Algebra.Order.Monoid.Defs import Mathlib.Algebra.Order.Sub.Defs import Mathlib.Util.AssertExists #align_import algebra.order.group.defs from "leanprover-community/mathlib"@"b599f4e4e5cf1fbcb4194503671d3d9e569c1fce" open Function universe u variable {Ξ± : Type u} class OrderedAddCommGroup (Ξ± : Type u) extends AddCommGroup Ξ±, PartialOrder Ξ± where protected add_le_add_left : βˆ€ a b : Ξ±, a ≀ b β†’ βˆ€ c : Ξ±, c + a ≀ c + b #align ordered_add_comm_group OrderedAddCommGroup class OrderedCommGroup (Ξ± : Type u) extends CommGroup Ξ±, PartialOrder Ξ± where protected mul_le_mul_left : βˆ€ a b : Ξ±, a ≀ b β†’ βˆ€ c : Ξ±, c * a ≀ c * b #align ordered_comm_group OrderedCommGroup attribute [to_additive] OrderedCommGroup @[to_additive] instance OrderedCommGroup.to_covariantClass_left_le (Ξ± : Type u) [OrderedCommGroup Ξ±] : CovariantClass Ξ± Ξ± (Β· * Β·) (Β· ≀ Β·) where elim a b c bc := OrderedCommGroup.mul_le_mul_left b c bc a #align ordered_comm_group.to_covariant_class_left_le OrderedCommGroup.to_covariantClass_left_le #align ordered_add_comm_group.to_covariant_class_left_le OrderedAddCommGroup.to_covariantClass_left_le -- See note [lower instance priority] @[to_additive OrderedAddCommGroup.toOrderedCancelAddCommMonoid] instance (priority := 100) OrderedCommGroup.toOrderedCancelCommMonoid [OrderedCommGroup Ξ±] : OrderedCancelCommMonoid Ξ± := { β€ΉOrderedCommGroup Ξ±β€Ί with le_of_mul_le_mul_left := fun a b c ↦ le_of_mul_le_mul_left' } #align ordered_comm_group.to_ordered_cancel_comm_monoid OrderedCommGroup.toOrderedCancelCommMonoid #align ordered_add_comm_group.to_ordered_cancel_add_comm_monoid OrderedAddCommGroup.toOrderedCancelAddCommMonoid example (Ξ± : Type u) [OrderedAddCommGroup Ξ±] : CovariantClass Ξ± Ξ± (swap (Β· + Β·)) (Β· < Β·) := IsRightCancelAdd.covariant_swap_add_lt_of_covariant_swap_add_le Ξ± -- Porting note: this instance is not used, -- and causes timeouts after lean4#2210. -- It was introduced in https://github.com/leanprover-community/mathlib/pull/17564 -- but without the motivation clearly explained. @[to_additive "A choice-free shortcut instance."] theorem OrderedCommGroup.to_contravariantClass_left_le (Ξ± : Type u) [OrderedCommGroup Ξ±] : ContravariantClass Ξ± Ξ± (Β· * Β·) (Β· ≀ Β·) where elim a b c bc := by simpa using mul_le_mul_left' bc a⁻¹ #align ordered_comm_group.to_contravariant_class_left_le OrderedCommGroup.to_contravariantClass_left_le #align ordered_add_comm_group.to_contravariant_class_left_le OrderedAddCommGroup.to_contravariantClass_left_le -- Porting note: this instance is not used, -- and causes timeouts after lean4#2210. -- See further explanation on `OrderedCommGroup.to_contravariantClass_left_le`. @[to_additive "A choice-free shortcut instance."] theorem OrderedCommGroup.to_contravariantClass_right_le (Ξ± : Type u) [OrderedCommGroup Ξ±] : ContravariantClass Ξ± Ξ± (swap (Β· * Β·)) (Β· ≀ Β·) where elim a b c bc := by simpa using mul_le_mul_right' bc a⁻¹ #align ordered_comm_group.to_contravariant_class_right_le OrderedCommGroup.to_contravariantClass_right_le #align ordered_add_comm_group.to_contravariant_class_right_le OrderedAddCommGroup.to_contravariantClass_right_le section Group variable [Group Ξ±] section Preorder variable [Preorder Ξ±] section CommGroup variable [CommGroup Ξ±] section CommGroup variable [CommGroup Ξ±] section LE variable [LE Ξ±] [CovariantClass Ξ± Ξ± (Β· * Β·) (Β· ≀ Β·)] {a b c d : Ξ±} @[to_additive sub_le_sub_iff] theorem div_le_div_iff' : a / b ≀ c / d ↔ a * d ≀ c * b := by simpa only [div_eq_mul_inv] using mul_inv_le_mul_inv_iff' #align div_le_div_iff' div_le_div_iff' #align sub_le_sub_iff sub_le_sub_iff @[to_additive] theorem le_div_iff_mul_le' : b ≀ c / a ↔ a * b ≀ c := by rw [le_div_iff_mul_le, mul_comm] #align le_div_iff_mul_le' le_div_iff_mul_le' #align le_sub_iff_add_le' le_sub_iff_add_le' alias ⟨add_le_of_le_sub_left, le_sub_left_of_add_le⟩ := le_sub_iff_add_le' #align le_sub_left_of_add_le le_sub_left_of_add_le #align add_le_of_le_sub_left add_le_of_le_sub_left @[to_additive]
Mathlib/Algebra/Order/Group/Defs.lean
816
816
theorem div_le_iff_le_mul' : a / b ≀ c ↔ a ≀ b * c := by
rw [div_le_iff_le_mul, mul_comm]
import Mathlib.Algebra.Order.CauSeq.BigOperators import Mathlib.Data.Complex.Abs import Mathlib.Data.Complex.BigOperators import Mathlib.Data.Nat.Choose.Sum #align_import data.complex.exponential from "leanprover-community/mathlib"@"a8b2226cfb0a79f5986492053fc49b1a0c6aeffb" open CauSeq Finset IsAbsoluteValue open scoped Classical ComplexConjugate namespace Complex variable (x y : β„‚) @[simp] theorem exp_zero : exp 0 = 1 := by rw [exp] refine lim_eq_of_equiv_const fun Ξ΅ Ξ΅0 => ⟨1, fun j hj => ?_⟩ convert (config := .unfoldSameFun) Ξ΅0 -- Porting note: Ξ΅0 : Ξ΅ > 0 but goal is _ < Ξ΅ cases' j with j j Β· exact absurd hj (not_le_of_gt zero_lt_one) Β· dsimp [exp'] induction' j with j ih Β· dsimp [exp']; simp [show Nat.succ 0 = 1 from rfl] Β· rw [← ih (by simp [Nat.succ_le_succ])] simp only [sum_range_succ, pow_succ] simp #align complex.exp_zero Complex.exp_zero theorem exp_add : exp (x + y) = exp x * exp y := by have hj : βˆ€ j : β„•, (βˆ‘ m ∈ range j, (x + y) ^ m / m.factorial) = βˆ‘ i ∈ range j, βˆ‘ k ∈ range (i + 1), x ^ k / k.factorial * (y ^ (i - k) / (i - k).factorial) := by intro j refine Finset.sum_congr rfl fun m _ => ?_ rw [add_pow, div_eq_mul_inv, sum_mul] refine Finset.sum_congr rfl fun I hi => ?_ have h₁ : (m.choose I : β„‚) β‰  0 := Nat.cast_ne_zero.2 (pos_iff_ne_zero.1 (Nat.choose_pos (Nat.le_of_lt_succ (mem_range.1 hi)))) have hβ‚‚ := Nat.choose_mul_factorial_mul_factorial (Nat.le_of_lt_succ <| Finset.mem_range.1 hi) rw [← hβ‚‚, Nat.cast_mul, Nat.cast_mul, mul_inv, mul_inv] simp only [mul_left_comm (m.choose I : β„‚), mul_assoc, mul_left_comm (m.choose I : β„‚)⁻¹, mul_comm (m.choose I : β„‚)] rw [inv_mul_cancel h₁] simp [div_eq_mul_inv, mul_comm, mul_assoc, mul_left_comm] simp_rw [exp, exp', lim_mul_lim] apply (lim_eq_lim_of_equiv _).symm simp only [hj] exact cauchy_product (isCauSeq_abs_exp x) (isCauSeq_exp y) #align complex.exp_add Complex.exp_add -- Porting note (#11445): new definition noncomputable def expMonoidHom : MonoidHom (Multiplicative β„‚) β„‚ := { toFun := fun z => exp (Multiplicative.toAdd z), map_one' := by simp, map_mul' := by simp [exp_add] } theorem exp_list_sum (l : List β„‚) : exp l.sum = (l.map exp).prod := map_list_prod (M := Multiplicative β„‚) expMonoidHom l #align complex.exp_list_sum Complex.exp_list_sum theorem exp_multiset_sum (s : Multiset β„‚) : exp s.sum = (s.map exp).prod := @MonoidHom.map_multiset_prod (Multiplicative β„‚) β„‚ _ _ expMonoidHom s #align complex.exp_multiset_sum Complex.exp_multiset_sum theorem exp_sum {Ξ± : Type*} (s : Finset Ξ±) (f : Ξ± β†’ β„‚) : exp (βˆ‘ x ∈ s, f x) = ∏ x ∈ s, exp (f x) := map_prod (Ξ² := Multiplicative β„‚) expMonoidHom f s #align complex.exp_sum Complex.exp_sum lemma exp_nsmul (x : β„‚) (n : β„•) : exp (n β€’ x) = exp x ^ n := @MonoidHom.map_pow (Multiplicative β„‚) β„‚ _ _ expMonoidHom _ _ theorem exp_nat_mul (x : β„‚) : βˆ€ n : β„•, exp (n * x) = exp x ^ n | 0 => by rw [Nat.cast_zero, zero_mul, exp_zero, pow_zero] | Nat.succ n => by rw [pow_succ, Nat.cast_add_one, add_mul, exp_add, ← exp_nat_mul _ n, one_mul] #align complex.exp_nat_mul Complex.exp_nat_mul theorem exp_ne_zero : exp x β‰  0 := fun h => zero_ne_one <| by rw [← exp_zero, ← add_neg_self x, exp_add, h]; simp #align complex.exp_ne_zero Complex.exp_ne_zero theorem exp_neg : exp (-x) = (exp x)⁻¹ := by rw [← mul_right_inj' (exp_ne_zero x), ← exp_add]; simp [mul_inv_cancel (exp_ne_zero x)] #align complex.exp_neg Complex.exp_neg theorem exp_sub : exp (x - y) = exp x / exp y := by simp [sub_eq_add_neg, exp_add, exp_neg, div_eq_mul_inv] #align complex.exp_sub Complex.exp_sub theorem exp_int_mul (z : β„‚) (n : β„€) : Complex.exp (n * z) = Complex.exp z ^ n := by cases n Β· simp [exp_nat_mul] Β· simp [exp_add, add_mul, pow_add, exp_neg, exp_nat_mul] #align complex.exp_int_mul Complex.exp_int_mul @[simp] theorem exp_conj : exp (conj x) = conj (exp x) := by dsimp [exp] rw [← lim_conj] refine congr_arg CauSeq.lim (CauSeq.ext fun _ => ?_) dsimp [exp', Function.comp_def, cauSeqConj] rw [map_sum (starRingEnd _)] refine sum_congr rfl fun n _ => ?_ rw [map_divβ‚€, map_pow, ← ofReal_natCast, conj_ofReal] #align complex.exp_conj Complex.exp_conj @[simp] theorem ofReal_exp_ofReal_re (x : ℝ) : ((exp x).re : β„‚) = exp x := conj_eq_iff_re.1 <| by rw [← exp_conj, conj_ofReal] #align complex.of_real_exp_of_real_re Complex.ofReal_exp_ofReal_re @[simp, norm_cast] theorem ofReal_exp (x : ℝ) : (Real.exp x : β„‚) = exp x := ofReal_exp_ofReal_re _ #align complex.of_real_exp Complex.ofReal_exp @[simp] theorem exp_ofReal_im (x : ℝ) : (exp x).im = 0 := by rw [← ofReal_exp_ofReal_re, ofReal_im] #align complex.exp_of_real_im Complex.exp_ofReal_im theorem exp_ofReal_re (x : ℝ) : (exp x).re = Real.exp x := rfl #align complex.exp_of_real_re Complex.exp_ofReal_re theorem two_sinh : 2 * sinh x = exp x - exp (-x) := mul_div_cancelβ‚€ _ two_ne_zero #align complex.two_sinh Complex.two_sinh theorem two_cosh : 2 * cosh x = exp x + exp (-x) := mul_div_cancelβ‚€ _ two_ne_zero #align complex.two_cosh Complex.two_cosh @[simp] theorem sinh_zero : sinh 0 = 0 := by simp [sinh] #align complex.sinh_zero Complex.sinh_zero @[simp] theorem sinh_neg : sinh (-x) = -sinh x := by simp [sinh, exp_neg, (neg_div _ _).symm, add_mul] #align complex.sinh_neg Complex.sinh_neg private theorem sinh_add_aux {a b c d : β„‚} : (a - b) * (c + d) + (a + b) * (c - d) = 2 * (a * c - b * d) := by ring theorem sinh_add : sinh (x + y) = sinh x * cosh y + cosh x * sinh y := by rw [← mul_right_inj' (two_ne_zero' β„‚), two_sinh, exp_add, neg_add, exp_add, eq_comm, mul_add, ← mul_assoc, two_sinh, mul_left_comm, two_sinh, ← mul_right_inj' (two_ne_zero' β„‚), mul_add, mul_left_comm, two_cosh, ← mul_assoc, two_cosh] exact sinh_add_aux #align complex.sinh_add Complex.sinh_add @[simp] theorem cosh_zero : cosh 0 = 1 := by simp [cosh] #align complex.cosh_zero Complex.cosh_zero @[simp] theorem cosh_neg : cosh (-x) = cosh x := by simp [add_comm, cosh, exp_neg] #align complex.cosh_neg Complex.cosh_neg private theorem cosh_add_aux {a b c d : β„‚} : (a + b) * (c + d) + (a - b) * (c - d) = 2 * (a * c + b * d) := by ring theorem cosh_add : cosh (x + y) = cosh x * cosh y + sinh x * sinh y := by rw [← mul_right_inj' (two_ne_zero' β„‚), two_cosh, exp_add, neg_add, exp_add, eq_comm, mul_add, ← mul_assoc, two_cosh, ← mul_assoc, two_sinh, ← mul_right_inj' (two_ne_zero' β„‚), mul_add, mul_left_comm, two_cosh, mul_left_comm, two_sinh] exact cosh_add_aux #align complex.cosh_add Complex.cosh_add theorem sinh_sub : sinh (x - y) = sinh x * cosh y - cosh x * sinh y := by simp [sub_eq_add_neg, sinh_add, sinh_neg, cosh_neg] #align complex.sinh_sub Complex.sinh_sub theorem cosh_sub : cosh (x - y) = cosh x * cosh y - sinh x * sinh y := by simp [sub_eq_add_neg, cosh_add, sinh_neg, cosh_neg] #align complex.cosh_sub Complex.cosh_sub theorem sinh_conj : sinh (conj x) = conj (sinh x) := by rw [sinh, ← RingHom.map_neg, exp_conj, exp_conj, ← RingHom.map_sub, sinh, map_divβ‚€] -- Porting note: not nice simp [← one_add_one_eq_two] #align complex.sinh_conj Complex.sinh_conj @[simp] theorem ofReal_sinh_ofReal_re (x : ℝ) : ((sinh x).re : β„‚) = sinh x := conj_eq_iff_re.1 <| by rw [← sinh_conj, conj_ofReal] #align complex.of_real_sinh_of_real_re Complex.ofReal_sinh_ofReal_re @[simp, norm_cast] theorem ofReal_sinh (x : ℝ) : (Real.sinh x : β„‚) = sinh x := ofReal_sinh_ofReal_re _ #align complex.of_real_sinh Complex.ofReal_sinh @[simp] theorem sinh_ofReal_im (x : ℝ) : (sinh x).im = 0 := by rw [← ofReal_sinh_ofReal_re, ofReal_im] #align complex.sinh_of_real_im Complex.sinh_ofReal_im theorem sinh_ofReal_re (x : ℝ) : (sinh x).re = Real.sinh x := rfl #align complex.sinh_of_real_re Complex.sinh_ofReal_re theorem cosh_conj : cosh (conj x) = conj (cosh x) := by rw [cosh, ← RingHom.map_neg, exp_conj, exp_conj, ← RingHom.map_add, cosh, map_divβ‚€] -- Porting note: not nice simp [← one_add_one_eq_two] #align complex.cosh_conj Complex.cosh_conj theorem ofReal_cosh_ofReal_re (x : ℝ) : ((cosh x).re : β„‚) = cosh x := conj_eq_iff_re.1 <| by rw [← cosh_conj, conj_ofReal] #align complex.of_real_cosh_of_real_re Complex.ofReal_cosh_ofReal_re @[simp, norm_cast] theorem ofReal_cosh (x : ℝ) : (Real.cosh x : β„‚) = cosh x := ofReal_cosh_ofReal_re _ #align complex.of_real_cosh Complex.ofReal_cosh @[simp] theorem cosh_ofReal_im (x : ℝ) : (cosh x).im = 0 := by rw [← ofReal_cosh_ofReal_re, ofReal_im] #align complex.cosh_of_real_im Complex.cosh_ofReal_im @[simp] theorem cosh_ofReal_re (x : ℝ) : (cosh x).re = Real.cosh x := rfl #align complex.cosh_of_real_re Complex.cosh_ofReal_re theorem tanh_eq_sinh_div_cosh : tanh x = sinh x / cosh x := rfl #align complex.tanh_eq_sinh_div_cosh Complex.tanh_eq_sinh_div_cosh @[simp] theorem tanh_zero : tanh 0 = 0 := by simp [tanh] #align complex.tanh_zero Complex.tanh_zero @[simp] theorem tanh_neg : tanh (-x) = -tanh x := by simp [tanh, neg_div] #align complex.tanh_neg Complex.tanh_neg theorem tanh_conj : tanh (conj x) = conj (tanh x) := by rw [tanh, sinh_conj, cosh_conj, ← map_divβ‚€, tanh] #align complex.tanh_conj Complex.tanh_conj @[simp] theorem ofReal_tanh_ofReal_re (x : ℝ) : ((tanh x).re : β„‚) = tanh x := conj_eq_iff_re.1 <| by rw [← tanh_conj, conj_ofReal] #align complex.of_real_tanh_of_real_re Complex.ofReal_tanh_ofReal_re @[simp, norm_cast] theorem ofReal_tanh (x : ℝ) : (Real.tanh x : β„‚) = tanh x := ofReal_tanh_ofReal_re _ #align complex.of_real_tanh Complex.ofReal_tanh @[simp] theorem tanh_ofReal_im (x : ℝ) : (tanh x).im = 0 := by rw [← ofReal_tanh_ofReal_re, ofReal_im] #align complex.tanh_of_real_im Complex.tanh_ofReal_im theorem tanh_ofReal_re (x : ℝ) : (tanh x).re = Real.tanh x := rfl #align complex.tanh_of_real_re Complex.tanh_ofReal_re @[simp] theorem cosh_add_sinh : cosh x + sinh x = exp x := by rw [← mul_right_inj' (two_ne_zero' β„‚), mul_add, two_cosh, two_sinh, add_add_sub_cancel, two_mul] #align complex.cosh_add_sinh Complex.cosh_add_sinh @[simp] theorem sinh_add_cosh : sinh x + cosh x = exp x := by rw [add_comm, cosh_add_sinh] #align complex.sinh_add_cosh Complex.sinh_add_cosh @[simp] theorem exp_sub_cosh : exp x - cosh x = sinh x := sub_eq_iff_eq_add.2 (sinh_add_cosh x).symm #align complex.exp_sub_cosh Complex.exp_sub_cosh @[simp] theorem exp_sub_sinh : exp x - sinh x = cosh x := sub_eq_iff_eq_add.2 (cosh_add_sinh x).symm #align complex.exp_sub_sinh Complex.exp_sub_sinh @[simp] theorem cosh_sub_sinh : cosh x - sinh x = exp (-x) := by rw [← mul_right_inj' (two_ne_zero' β„‚), mul_sub, two_cosh, two_sinh, add_sub_sub_cancel, two_mul] #align complex.cosh_sub_sinh Complex.cosh_sub_sinh @[simp] theorem sinh_sub_cosh : sinh x - cosh x = -exp (-x) := by rw [← neg_sub, cosh_sub_sinh] #align complex.sinh_sub_cosh Complex.sinh_sub_cosh @[simp] theorem cosh_sq_sub_sinh_sq : cosh x ^ 2 - sinh x ^ 2 = 1 := by rw [sq_sub_sq, cosh_add_sinh, cosh_sub_sinh, ← exp_add, add_neg_self, exp_zero] #align complex.cosh_sq_sub_sinh_sq Complex.cosh_sq_sub_sinh_sq theorem cosh_sq : cosh x ^ 2 = sinh x ^ 2 + 1 := by rw [← cosh_sq_sub_sinh_sq x] ring #align complex.cosh_sq Complex.cosh_sq theorem sinh_sq : sinh x ^ 2 = cosh x ^ 2 - 1 := by rw [← cosh_sq_sub_sinh_sq x] ring #align complex.sinh_sq Complex.sinh_sq theorem cosh_two_mul : cosh (2 * x) = cosh x ^ 2 + sinh x ^ 2 := by rw [two_mul, cosh_add, sq, sq] #align complex.cosh_two_mul Complex.cosh_two_mul theorem sinh_two_mul : sinh (2 * x) = 2 * sinh x * cosh x := by rw [two_mul, sinh_add] ring #align complex.sinh_two_mul Complex.sinh_two_mul theorem cosh_three_mul : cosh (3 * x) = 4 * cosh x ^ 3 - 3 * cosh x := by have h1 : x + 2 * x = 3 * x := by ring rw [← h1, cosh_add x (2 * x)] simp only [cosh_two_mul, sinh_two_mul] have h2 : sinh x * (2 * sinh x * cosh x) = 2 * cosh x * sinh x ^ 2 := by ring rw [h2, sinh_sq] ring #align complex.cosh_three_mul Complex.cosh_three_mul
Mathlib/Data/Complex/Exponential.lean
475
481
theorem sinh_three_mul : sinh (3 * x) = 4 * sinh x ^ 3 + 3 * sinh x := by
have h1 : x + 2 * x = 3 * x := by ring rw [← h1, sinh_add x (2 * x)] simp only [cosh_two_mul, sinh_two_mul] have h2 : cosh x * (2 * sinh x * cosh x) = 2 * sinh x * cosh x ^ 2 := by ring rw [h2, cosh_sq] ring
import Mathlib.LinearAlgebra.CliffordAlgebra.Grading import Mathlib.Algebra.Module.Opposites #align_import linear_algebra.clifford_algebra.conjugation from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0" variable {R : Type*} [CommRing R] variable {M : Type*} [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} namespace CliffordAlgebra section Submodule variable (Q) section Involute theorem submodule_map_involute_eq_comap (p : Submodule R (CliffordAlgebra Q)) : p.map (involute : CliffordAlgebra Q →ₐ[R] CliffordAlgebra Q).toLinearMap = p.comap (involute : CliffordAlgebra Q →ₐ[R] CliffordAlgebra Q).toLinearMap := Submodule.map_equiv_eq_comap_symm involuteEquiv.toLinearEquiv _ #align clifford_algebra.submodule_map_involute_eq_comap CliffordAlgebra.submodule_map_involute_eq_comap @[simp] theorem ΞΉ_range_map_involute : (ΞΉ Q).range.map (involute : CliffordAlgebra Q →ₐ[R] CliffordAlgebra Q).toLinearMap = LinearMap.range (ΞΉ Q) := (ΞΉ_range_map_lift _ _).trans (LinearMap.range_neg _) #align clifford_algebra.ΞΉ_range_map_involute CliffordAlgebra.ΞΉ_range_map_involute @[simp] theorem ΞΉ_range_comap_involute : (ΞΉ Q).range.comap (involute : CliffordAlgebra Q →ₐ[R] CliffordAlgebra Q).toLinearMap = LinearMap.range (ΞΉ Q) := by rw [← submodule_map_involute_eq_comap, ΞΉ_range_map_involute] #align clifford_algebra.ΞΉ_range_comap_involute CliffordAlgebra.ΞΉ_range_comap_involute @[simp]
Mathlib/LinearAlgebra/CliffordAlgebra/Conjugation.lean
234
237
theorem evenOdd_map_involute (n : ZMod 2) : (evenOdd Q n).map (involute : CliffordAlgebra Q →ₐ[R] CliffordAlgebra Q).toLinearMap = evenOdd Q n := by
simp_rw [evenOdd, Submodule.map_iSup, Submodule.map_pow, ΞΉ_range_map_involute]
import Mathlib.Data.Set.Basic #align_import order.circular from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec" class Btw (Ξ± : Type*) where btw : Ξ± β†’ Ξ± β†’ Ξ± β†’ Prop #align has_btw Btw export Btw (btw) class SBtw (Ξ± : Type*) where sbtw : Ξ± β†’ Ξ± β†’ Ξ± β†’ Prop #align has_sbtw SBtw export SBtw (sbtw) class CircularPreorder (Ξ± : Type*) extends Btw Ξ±, SBtw Ξ± where btw_refl (a : Ξ±) : btw a a a btw_cyclic_left {a b c : Ξ±} : btw a b c β†’ btw b c a sbtw := fun a b c => btw a b c ∧ Β¬btw c b a sbtw_iff_btw_not_btw {a b c : Ξ±} : sbtw a b c ↔ btw a b c ∧ Β¬btw c b a := by intros; rfl sbtw_trans_left {a b c d : Ξ±} : sbtw a b c β†’ sbtw b d c β†’ sbtw a d c #align circular_preorder CircularPreorder export CircularPreorder (btw_refl btw_cyclic_left sbtw_trans_left) class CircularPartialOrder (Ξ± : Type*) extends CircularPreorder Ξ± where btw_antisymm {a b c : Ξ±} : btw a b c β†’ btw c b a β†’ a = b ∨ b = c ∨ c = a #align circular_partial_order CircularPartialOrder export CircularPartialOrder (btw_antisymm) class CircularOrder (Ξ± : Type*) extends CircularPartialOrder Ξ± where btw_total : βˆ€ a b c : Ξ±, btw a b c ∨ btw c b a #align circular_order CircularOrder export CircularOrder (btw_total) section CircularOrder variable {Ξ± : Type*} [CircularOrder Ξ±] theorem left_mem_cIcc (a b : Ξ±) : a ∈ cIcc a b := btw_rfl_left #align set.left_mem_cIcc Set.left_mem_cIcc theorem right_mem_cIcc (a b : Ξ±) : b ∈ cIcc a b := btw_rfl_right #align set.right_mem_cIcc Set.right_mem_cIcc
Mathlib/Order/Circular.lean
369
371
theorem compl_cIcc {a b : α} : (cIcc a b)ᢜ = cIoo b a := by
ext rw [Set.mem_cIoo, sbtw_iff_not_btw, cIcc, mem_compl_iff, mem_setOf]
import Mathlib.Algebra.Module.BigOperators import Mathlib.Data.Fintype.BigOperators import Mathlib.LinearAlgebra.AffineSpace.AffineMap import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace import Mathlib.LinearAlgebra.Finsupp import Mathlib.Tactic.FinCases #align_import linear_algebra.affine_space.combination from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0" noncomputable section open Affine namespace Finset theorem univ_fin2 : (univ : Finset (Fin 2)) = {0, 1} := by ext x fin_cases x <;> simp #align finset.univ_fin2 Finset.univ_fin2 variable {k : Type*} {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V] variable [S : AffineSpace V P] variable {ΞΉ : Type*} (s : Finset ΞΉ) variable {ΞΉβ‚‚ : Type*} (sβ‚‚ : Finset ΞΉβ‚‚) def weightedVSubOfPoint (p : ΞΉ β†’ P) (b : P) : (ΞΉ β†’ k) β†’β‚—[k] V := βˆ‘ i ∈ s, (LinearMap.proj i : (ΞΉ β†’ k) β†’β‚—[k] k).smulRight (p i -α΅₯ b) #align finset.weighted_vsub_of_point Finset.weightedVSubOfPoint @[simp] theorem weightedVSubOfPoint_apply (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) (b : P) : s.weightedVSubOfPoint p b w = βˆ‘ i ∈ s, w i β€’ (p i -α΅₯ b) := by simp [weightedVSubOfPoint, LinearMap.sum_apply] #align finset.weighted_vsub_of_point_apply Finset.weightedVSubOfPoint_apply @[simp (high)] theorem weightedVSubOfPoint_apply_const (w : ΞΉ β†’ k) (p : P) (b : P) : s.weightedVSubOfPoint (fun _ => p) b w = (βˆ‘ i ∈ s, w i) β€’ (p -α΅₯ b) := by rw [weightedVSubOfPoint_apply, sum_smul] #align finset.weighted_vsub_of_point_apply_const Finset.weightedVSubOfPoint_apply_const theorem weightedVSubOfPoint_congr {w₁ wβ‚‚ : ΞΉ β†’ k} (hw : βˆ€ i ∈ s, w₁ i = wβ‚‚ i) {p₁ pβ‚‚ : ΞΉ β†’ P} (hp : βˆ€ i ∈ s, p₁ i = pβ‚‚ i) (b : P) : s.weightedVSubOfPoint p₁ b w₁ = s.weightedVSubOfPoint pβ‚‚ b wβ‚‚ := by simp_rw [weightedVSubOfPoint_apply] refine sum_congr rfl fun i hi => ?_ rw [hw i hi, hp i hi] #align finset.weighted_vsub_of_point_congr Finset.weightedVSubOfPoint_congr theorem weightedVSubOfPoint_eq_of_weights_eq (p : ΞΉ β†’ P) (j : ΞΉ) (w₁ wβ‚‚ : ΞΉ β†’ k) (hw : βˆ€ i, i β‰  j β†’ w₁ i = wβ‚‚ i) : s.weightedVSubOfPoint p (p j) w₁ = s.weightedVSubOfPoint p (p j) wβ‚‚ := by simp only [Finset.weightedVSubOfPoint_apply] congr ext i rcases eq_or_ne i j with h | h Β· simp [h] Β· simp [hw i h] #align finset.weighted_vsub_of_point_eq_of_weights_eq Finset.weightedVSubOfPoint_eq_of_weights_eq theorem weightedVSubOfPoint_eq_of_sum_eq_zero (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) (h : βˆ‘ i ∈ s, w i = 0) (b₁ bβ‚‚ : P) : s.weightedVSubOfPoint p b₁ w = s.weightedVSubOfPoint p bβ‚‚ w := by apply eq_of_sub_eq_zero rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← sum_sub_distrib] conv_lhs => congr Β· skip Β· ext rw [← smul_sub, vsub_sub_vsub_cancel_left] rw [← sum_smul, h, zero_smul] #align finset.weighted_vsub_of_point_eq_of_sum_eq_zero Finset.weightedVSubOfPoint_eq_of_sum_eq_zero theorem weightedVSubOfPoint_vadd_eq_of_sum_eq_one (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) (h : βˆ‘ i ∈ s, w i = 1) (b₁ bβ‚‚ : P) : s.weightedVSubOfPoint p b₁ w +α΅₯ b₁ = s.weightedVSubOfPoint p bβ‚‚ w +α΅₯ bβ‚‚ := by erw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← @vsub_eq_zero_iff_eq V, vadd_vsub_assoc, vsub_vadd_eq_vsub_sub, ← add_sub_assoc, add_comm, add_sub_assoc, ← sum_sub_distrib] conv_lhs => congr Β· skip Β· congr Β· skip Β· ext rw [← smul_sub, vsub_sub_vsub_cancel_left] rw [← sum_smul, h, one_smul, vsub_add_vsub_cancel, vsub_self] #align finset.weighted_vsub_of_point_vadd_eq_of_sum_eq_one Finset.weightedVSubOfPoint_vadd_eq_of_sum_eq_one @[simp (high)] theorem weightedVSubOfPoint_erase [DecidableEq ΞΉ] (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) (i : ΞΉ) : (s.erase i).weightedVSubOfPoint p (p i) w = s.weightedVSubOfPoint p (p i) w := by rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply] apply sum_erase rw [vsub_self, smul_zero] #align finset.weighted_vsub_of_point_erase Finset.weightedVSubOfPoint_erase @[simp (high)] theorem weightedVSubOfPoint_insert [DecidableEq ΞΉ] (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) (i : ΞΉ) : (insert i s).weightedVSubOfPoint p (p i) w = s.weightedVSubOfPoint p (p i) w := by rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply] apply sum_insert_zero rw [vsub_self, smul_zero] #align finset.weighted_vsub_of_point_insert Finset.weightedVSubOfPoint_insert theorem weightedVSubOfPoint_indicator_subset (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) (b : P) {s₁ sβ‚‚ : Finset ΞΉ} (h : s₁ βŠ† sβ‚‚) : s₁.weightedVSubOfPoint p b w = sβ‚‚.weightedVSubOfPoint p b (Set.indicator (↑s₁) w) := by rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply] exact Eq.symm <| sum_indicator_subset_of_eq_zero w (fun i wi => wi β€’ (p i -α΅₯ b : V)) h fun i => zero_smul k _ #align finset.weighted_vsub_of_point_indicator_subset Finset.weightedVSubOfPoint_indicator_subset theorem weightedVSubOfPoint_map (e : ΞΉβ‚‚ β†ͺ ΞΉ) (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) (b : P) : (sβ‚‚.map e).weightedVSubOfPoint p b w = sβ‚‚.weightedVSubOfPoint (p ∘ e) b (w ∘ e) := by simp_rw [weightedVSubOfPoint_apply] exact Finset.sum_map _ _ _ #align finset.weighted_vsub_of_point_map Finset.weightedVSubOfPoint_map theorem sum_smul_vsub_eq_weightedVSubOfPoint_sub (w : ΞΉ β†’ k) (p₁ pβ‚‚ : ΞΉ β†’ P) (b : P) : (βˆ‘ i ∈ s, w i β€’ (p₁ i -α΅₯ pβ‚‚ i)) = s.weightedVSubOfPoint p₁ b w - s.weightedVSubOfPoint pβ‚‚ b w := by simp_rw [weightedVSubOfPoint_apply, ← sum_sub_distrib, ← smul_sub, vsub_sub_vsub_cancel_right] #align finset.sum_smul_vsub_eq_weighted_vsub_of_point_sub Finset.sum_smul_vsub_eq_weightedVSubOfPoint_sub theorem sum_smul_vsub_const_eq_weightedVSubOfPoint_sub (w : ΞΉ β†’ k) (p₁ : ΞΉ β†’ P) (pβ‚‚ b : P) : (βˆ‘ i ∈ s, w i β€’ (p₁ i -α΅₯ pβ‚‚)) = s.weightedVSubOfPoint p₁ b w - (βˆ‘ i ∈ s, w i) β€’ (pβ‚‚ -α΅₯ b) := by rw [sum_smul_vsub_eq_weightedVSubOfPoint_sub, weightedVSubOfPoint_apply_const] #align finset.sum_smul_vsub_const_eq_weighted_vsub_of_point_sub Finset.sum_smul_vsub_const_eq_weightedVSubOfPoint_sub theorem sum_smul_const_vsub_eq_sub_weightedVSubOfPoint (w : ΞΉ β†’ k) (pβ‚‚ : ΞΉ β†’ P) (p₁ b : P) : (βˆ‘ i ∈ s, w i β€’ (p₁ -α΅₯ pβ‚‚ i)) = (βˆ‘ i ∈ s, w i) β€’ (p₁ -α΅₯ b) - s.weightedVSubOfPoint pβ‚‚ b w := by rw [sum_smul_vsub_eq_weightedVSubOfPoint_sub, weightedVSubOfPoint_apply_const] #align finset.sum_smul_const_vsub_eq_sub_weighted_vsub_of_point Finset.sum_smul_const_vsub_eq_sub_weightedVSubOfPoint theorem weightedVSubOfPoint_sdiff [DecidableEq ΞΉ] {sβ‚‚ : Finset ΞΉ} (h : sβ‚‚ βŠ† s) (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) (b : P) : (s \ sβ‚‚).weightedVSubOfPoint p b w + sβ‚‚.weightedVSubOfPoint p b w = s.weightedVSubOfPoint p b w := by simp_rw [weightedVSubOfPoint_apply, sum_sdiff h] #align finset.weighted_vsub_of_point_sdiff Finset.weightedVSubOfPoint_sdiff theorem weightedVSubOfPoint_sdiff_sub [DecidableEq ΞΉ] {sβ‚‚ : Finset ΞΉ} (h : sβ‚‚ βŠ† s) (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) (b : P) : (s \ sβ‚‚).weightedVSubOfPoint p b w - sβ‚‚.weightedVSubOfPoint p b (-w) = s.weightedVSubOfPoint p b w := by rw [map_neg, sub_neg_eq_add, s.weightedVSubOfPoint_sdiff h] #align finset.weighted_vsub_of_point_sdiff_sub Finset.weightedVSubOfPoint_sdiff_sub theorem weightedVSubOfPoint_subtype_eq_filter (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) (b : P) (pred : ΞΉ β†’ Prop) [DecidablePred pred] : ((s.subtype pred).weightedVSubOfPoint (fun i => p i) b fun i => w i) = (s.filter pred).weightedVSubOfPoint p b w := by rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← sum_subtype_eq_sum_filter] #align finset.weighted_vsub_of_point_subtype_eq_filter Finset.weightedVSubOfPoint_subtype_eq_filter theorem weightedVSubOfPoint_filter_of_ne (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) (b : P) {pred : ΞΉ β†’ Prop} [DecidablePred pred] (h : βˆ€ i ∈ s, w i β‰  0 β†’ pred i) : (s.filter pred).weightedVSubOfPoint p b w = s.weightedVSubOfPoint p b w := by rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, sum_filter_of_ne] intro i hi hne refine h i hi ?_ intro hw simp [hw] at hne #align finset.weighted_vsub_of_point_filter_of_ne Finset.weightedVSubOfPoint_filter_of_ne theorem weightedVSubOfPoint_const_smul (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) (b : P) (c : k) : s.weightedVSubOfPoint p b (c β€’ w) = c β€’ s.weightedVSubOfPoint p b w := by simp_rw [weightedVSubOfPoint_apply, smul_sum, Pi.smul_apply, smul_smul, smul_eq_mul] #align finset.weighted_vsub_of_point_const_smul Finset.weightedVSubOfPoint_const_smul def weightedVSub (p : ΞΉ β†’ P) : (ΞΉ β†’ k) β†’β‚—[k] V := s.weightedVSubOfPoint p (Classical.choice S.nonempty) #align finset.weighted_vsub Finset.weightedVSub theorem weightedVSub_apply (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) : s.weightedVSub p w = βˆ‘ i ∈ s, w i β€’ (p i -α΅₯ Classical.choice S.nonempty) := by simp [weightedVSub, LinearMap.sum_apply] #align finset.weighted_vsub_apply Finset.weightedVSub_apply theorem weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) (h : βˆ‘ i ∈ s, w i = 0) (b : P) : s.weightedVSub p w = s.weightedVSubOfPoint p b w := s.weightedVSubOfPoint_eq_of_sum_eq_zero w p h _ _ #align finset.weighted_vsub_eq_weighted_vsub_of_point_of_sum_eq_zero Finset.weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero @[simp] theorem weightedVSub_apply_const (w : ΞΉ β†’ k) (p : P) (h : βˆ‘ i ∈ s, w i = 0) : s.weightedVSub (fun _ => p) w = 0 := by rw [weightedVSub, weightedVSubOfPoint_apply_const, h, zero_smul] #align finset.weighted_vsub_apply_const Finset.weightedVSub_apply_const @[simp] theorem weightedVSub_empty (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) : (βˆ… : Finset ΞΉ).weightedVSub p w = (0 : V) := by simp [weightedVSub_apply] #align finset.weighted_vsub_empty Finset.weightedVSub_empty theorem weightedVSub_congr {w₁ wβ‚‚ : ΞΉ β†’ k} (hw : βˆ€ i ∈ s, w₁ i = wβ‚‚ i) {p₁ pβ‚‚ : ΞΉ β†’ P} (hp : βˆ€ i ∈ s, p₁ i = pβ‚‚ i) : s.weightedVSub p₁ w₁ = s.weightedVSub pβ‚‚ wβ‚‚ := s.weightedVSubOfPoint_congr hw hp _ #align finset.weighted_vsub_congr Finset.weightedVSub_congr theorem weightedVSub_indicator_subset (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) {s₁ sβ‚‚ : Finset ΞΉ} (h : s₁ βŠ† sβ‚‚) : s₁.weightedVSub p w = sβ‚‚.weightedVSub p (Set.indicator (↑s₁) w) := weightedVSubOfPoint_indicator_subset _ _ _ h #align finset.weighted_vsub_indicator_subset Finset.weightedVSub_indicator_subset theorem weightedVSub_map (e : ΞΉβ‚‚ β†ͺ ΞΉ) (w : ΞΉ β†’ k) (p : ΞΉ β†’ P) : (sβ‚‚.map e).weightedVSub p w = sβ‚‚.weightedVSub (p ∘ e) (w ∘ e) := sβ‚‚.weightedVSubOfPoint_map _ _ _ _ #align finset.weighted_vsub_map Finset.weightedVSub_map theorem sum_smul_vsub_eq_weightedVSub_sub (w : ΞΉ β†’ k) (p₁ pβ‚‚ : ΞΉ β†’ P) : (βˆ‘ i ∈ s, w i β€’ (p₁ i -α΅₯ pβ‚‚ i)) = s.weightedVSub p₁ w - s.weightedVSub pβ‚‚ w := s.sum_smul_vsub_eq_weightedVSubOfPoint_sub _ _ _ _ #align finset.sum_smul_vsub_eq_weighted_vsub_sub Finset.sum_smul_vsub_eq_weightedVSub_sub theorem sum_smul_vsub_const_eq_weightedVSub (w : ΞΉ β†’ k) (p₁ : ΞΉ β†’ P) (pβ‚‚ : P) (h : βˆ‘ i ∈ s, w i = 0) : (βˆ‘ i ∈ s, w i β€’ (p₁ i -α΅₯ pβ‚‚)) = s.weightedVSub p₁ w := by rw [sum_smul_vsub_eq_weightedVSub_sub, s.weightedVSub_apply_const _ _ h, sub_zero] #align finset.sum_smul_vsub_const_eq_weighted_vsub Finset.sum_smul_vsub_const_eq_weightedVSub
Mathlib/LinearAlgebra/AffineSpace/Combination.lean
320
322
theorem sum_smul_const_vsub_eq_neg_weightedVSub (w : ΞΉ β†’ k) (pβ‚‚ : ΞΉ β†’ P) (p₁ : P) (h : βˆ‘ i ∈ s, w i = 0) : (βˆ‘ i ∈ s, w i β€’ (p₁ -α΅₯ pβ‚‚ i)) = -s.weightedVSub pβ‚‚ w := by
rw [sum_smul_vsub_eq_weightedVSub_sub, s.weightedVSub_apply_const _ _ h, zero_sub]
import Mathlib.Algebra.Algebra.Subalgebra.Operations import Mathlib.Algebra.Ring.Fin import Mathlib.RingTheory.Ideal.Quotient #align_import ring_theory.ideal.quotient_operations from "leanprover-community/mathlib"@"b88d81c84530450a8989e918608e5960f015e6c8" universe u v w namespace Ideal open Function RingHom variable {R : Type u} {S : Type v} {F : Type w} [CommRing R] [Semiring S] @[simp] theorem map_quotient_self (I : Ideal R) : map (Quotient.mk I) I = βŠ₯ := eq_bot_iff.2 <| Ideal.map_le_iff_le_comap.2 fun _ hx => (Submodule.mem_bot (R β§Έ I)).2 <| Ideal.Quotient.eq_zero_iff_mem.2 hx #align ideal.map_quotient_self Ideal.map_quotient_self @[simp] theorem mk_ker {I : Ideal R} : ker (Quotient.mk I) = I := by ext rw [ker, mem_comap, Submodule.mem_bot, Quotient.eq_zero_iff_mem] #align ideal.mk_ker Ideal.mk_ker theorem map_mk_eq_bot_of_le {I J : Ideal R} (h : I ≀ J) : I.map (Quotient.mk J) = βŠ₯ := by rw [map_eq_bot_iff_le_ker, mk_ker] exact h #align ideal.map_mk_eq_bot_of_le Ideal.map_mk_eq_bot_of_le theorem ker_quotient_lift {I : Ideal R} (f : R β†’+* S) (H : I ≀ ker f) : ker (Ideal.Quotient.lift I f H) = f.ker.map (Quotient.mk I) := by apply Ideal.ext intro x constructor Β· intro hx obtain ⟨y, hy⟩ := Quotient.mk_surjective x rw [mem_ker, ← hy, Ideal.Quotient.lift_mk, ← mem_ker] at hx rw [← hy, mem_map_iff_of_surjective (Quotient.mk I) Quotient.mk_surjective] exact ⟨y, hx, rfl⟩ Β· intro hx rw [mem_map_iff_of_surjective (Quotient.mk I) Quotient.mk_surjective] at hx obtain ⟨y, hy⟩ := hx rw [mem_ker, ← hy.right, Ideal.Quotient.lift_mk] exact hy.left #align ideal.ker_quotient_lift Ideal.ker_quotient_lift lemma injective_lift_iff {I : Ideal R} {f : R β†’+* S} (H : βˆ€ (a : R), a ∈ I β†’ f a = 0) : Injective (Quotient.lift I f H) ↔ ker f = I := by rw [injective_iff_ker_eq_bot, ker_quotient_lift, map_eq_bot_iff_le_ker, mk_ker] constructor Β· exact fun h ↦ le_antisymm h H Β· rintro rfl; rfl lemma ker_Pi_Quotient_mk {ΞΉ : Type*} (I : ΞΉ β†’ Ideal R) : ker (Pi.ringHom fun i : ΞΉ ↦ Quotient.mk (I i)) = β¨… i, I i := by simp [Pi.ker_ringHom, mk_ker] @[simp] theorem bot_quotient_isMaximal_iff (I : Ideal R) : (βŠ₯ : Ideal (R β§Έ I)).IsMaximal ↔ I.IsMaximal := ⟨fun hI => mk_ker (I := I) β–Έ comap_isMaximal_of_surjective (Quotient.mk I) Quotient.mk_surjective (K := βŠ₯) (H := hI), fun hI => by letI := Quotient.field I exact bot_isMaximal⟩ #align ideal.bot_quotient_is_maximal_iff Ideal.bot_quotient_isMaximal_iff @[simp] theorem mem_quotient_iff_mem_sup {I J : Ideal R} {x : R} : Quotient.mk I x ∈ J.map (Quotient.mk I) ↔ x ∈ J βŠ” I := by rw [← mem_comap, comap_map_of_surjective (Quotient.mk I) Quotient.mk_surjective, ← ker_eq_comap_bot, mk_ker] #align ideal.mem_quotient_iff_mem_sup Ideal.mem_quotient_iff_mem_sup theorem mem_quotient_iff_mem {I J : Ideal R} (hIJ : I ≀ J) {x : R} : Quotient.mk I x ∈ J.map (Quotient.mk I) ↔ x ∈ J := by rw [mem_quotient_iff_mem_sup, sup_eq_left.mpr hIJ] #align ideal.mem_quotient_iff_mem Ideal.mem_quotient_iff_mem section QuotientAlgebra variable (R₁ Rβ‚‚ : Type*) {A B : Type*} variable [CommSemiring R₁] [CommSemiring Rβ‚‚] [CommRing A] variable [Algebra R₁ A] [Algebra Rβ‚‚ A] instance Quotient.algebra {I : Ideal A} : Algebra R₁ (A β§Έ I) := { toRingHom := (Ideal.Quotient.mk I).comp (algebraMap R₁ A) smul_def' := fun _ x => Quotient.inductionOn' x fun _ => ((Quotient.mk I).congr_arg <| Algebra.smul_def _ _).trans (RingHom.map_mul _ _ _) commutes' := fun _ _ => mul_comm _ _ } #align ideal.quotient.algebra Ideal.Quotient.algebra -- Lean can struggle to find this instance later if we don't provide this shortcut -- Porting note: this can probably now be deleted -- update: maybe not - removal causes timeouts instance Quotient.isScalarTower [SMul R₁ Rβ‚‚] [IsScalarTower R₁ Rβ‚‚ A] (I : Ideal A) : IsScalarTower R₁ Rβ‚‚ (A β§Έ I) := by infer_instance #align ideal.quotient.is_scalar_tower Ideal.Quotient.isScalarTower def Quotient.mkₐ (I : Ideal A) : A →ₐ[R₁] A β§Έ I := ⟨⟨⟨⟨fun a => Submodule.Quotient.mk a, rfl⟩, fun _ _ => rfl⟩, rfl, fun _ _ => rfl⟩, fun _ => rfl⟩ #align ideal.quotient.mkₐ Ideal.Quotient.mkₐ theorem Quotient.algHom_ext {I : Ideal A} {S} [Semiring S] [Algebra R₁ S] ⦃f g : A β§Έ I →ₐ[R₁] S⦄ (h : f.comp (Quotient.mkₐ R₁ I) = g.comp (Quotient.mkₐ R₁ I)) : f = g := AlgHom.ext fun x => Quotient.inductionOn' x <| AlgHom.congr_fun h #align ideal.quotient.alg_hom_ext Ideal.Quotient.algHom_ext theorem Quotient.alg_map_eq (I : Ideal A) : algebraMap R₁ (A β§Έ I) = (algebraMap A (A β§Έ I)).comp (algebraMap R₁ A) := rfl #align ideal.quotient.alg_map_eq Ideal.Quotient.alg_map_eq theorem Quotient.mkₐ_toRingHom (I : Ideal A) : (Quotient.mkₐ R₁ I).toRingHom = Ideal.Quotient.mk I := rfl #align ideal.quotient.mkₐ_to_ring_hom Ideal.Quotient.mkₐ_toRingHom @[simp] theorem Quotient.mkₐ_eq_mk (I : Ideal A) : ⇑(Quotient.mkₐ R₁ I) = Quotient.mk I := rfl #align ideal.quotient.mkₐ_eq_mk Ideal.Quotient.mkₐ_eq_mk @[simp] theorem Quotient.algebraMap_eq (I : Ideal R) : algebraMap R (R β§Έ I) = Quotient.mk I := rfl #align ideal.quotient.algebra_map_eq Ideal.Quotient.algebraMap_eq @[simp] theorem Quotient.mk_comp_algebraMap (I : Ideal A) : (Quotient.mk I).comp (algebraMap R₁ A) = algebraMap R₁ (A β§Έ I) := rfl #align ideal.quotient.mk_comp_algebra_map Ideal.Quotient.mk_comp_algebraMap @[simp] theorem Quotient.mk_algebraMap (I : Ideal A) (x : R₁) : Quotient.mk I (algebraMap R₁ A x) = algebraMap R₁ (A β§Έ I) x := rfl #align ideal.quotient.mk_algebra_map Ideal.Quotient.mk_algebraMap theorem Quotient.mkₐ_surjective (I : Ideal A) : Function.Surjective (Quotient.mkₐ R₁ I) := surjective_quot_mk _ #align ideal.quotient.mkₐ_surjective Ideal.Quotient.mkₐ_surjective @[simp] theorem Quotient.mkₐ_ker (I : Ideal A) : RingHom.ker (Quotient.mkₐ R₁ I : A β†’+* A β§Έ I) = I := Ideal.mk_ker #align ideal.quotient.mkₐ_ker Ideal.Quotient.mkₐ_ker variable {R₁} section variable [Semiring B] [Algebra R₁ B] def Quotient.liftₐ (I : Ideal A) (f : A →ₐ[R₁] B) (hI : βˆ€ a : A, a ∈ I β†’ f a = 0) : A β§Έ I →ₐ[R₁] B := {-- this is IsScalarTower.algebraMap_apply R₁ A (A β§Έ I) but the file `Algebra.Algebra.Tower` -- imports this file. Ideal.Quotient.lift I (f : A β†’+* B) hI with commutes' := fun r => by have : algebraMap R₁ (A β§Έ I) r = algebraMap A (A β§Έ I) (algebraMap R₁ A r) := by simp_rw [Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul] rw [this, Ideal.Quotient.algebraMap_eq, RingHom.toFun_eq_coe, Ideal.Quotient.lift_mk, AlgHom.coe_toRingHom, Algebra.algebraMap_eq_smul_one, Algebra.algebraMap_eq_smul_one, map_smul, map_one] } #align ideal.quotient.liftₐ Ideal.Quotient.liftₐ @[simp] theorem Quotient.liftₐ_apply (I : Ideal A) (f : A →ₐ[R₁] B) (hI : βˆ€ a : A, a ∈ I β†’ f a = 0) (x) : Ideal.Quotient.liftₐ I f hI x = Ideal.Quotient.lift I (f : A β†’+* B) hI x := rfl #align ideal.quotient.liftₐ_apply Ideal.Quotient.liftₐ_apply theorem Quotient.liftₐ_comp (I : Ideal A) (f : A →ₐ[R₁] B) (hI : βˆ€ a : A, a ∈ I β†’ f a = 0) : (Ideal.Quotient.liftₐ I f hI).comp (Ideal.Quotient.mkₐ R₁ I) = f := AlgHom.ext fun _ => (Ideal.Quotient.lift_mk I (f : A β†’+* B) hI : _) #align ideal.quotient.liftₐ_comp Ideal.Quotient.liftₐ_comp theorem KerLift.map_smul (f : A →ₐ[R₁] B) (r : R₁) (x : A β§Έ (RingHom.ker f)) : f.kerLift (r β€’ x) = r β€’ f.kerLift x := by obtain ⟨a, rfl⟩ := Quotient.mkₐ_surjective R₁ _ x exact f.map_smul _ _ #align ideal.ker_lift.map_smul Ideal.KerLift.map_smul def kerLiftAlg (f : A →ₐ[R₁] B) : A β§Έ (RingHom.ker f) →ₐ[R₁] B := AlgHom.mk' (RingHom.kerLift (f : A β†’+* B)) fun _ _ => KerLift.map_smul f _ _ #align ideal.ker_lift_alg Ideal.kerLiftAlg @[simp] theorem kerLiftAlg_mk (f : A →ₐ[R₁] B) (a : A) : kerLiftAlg f (Quotient.mk (RingHom.ker f) a) = f a := by rfl #align ideal.ker_lift_alg_mk Ideal.kerLiftAlg_mk @[simp] theorem kerLiftAlg_toRingHom (f : A →ₐ[R₁] B) : (kerLiftAlg f : A β§Έ ker f β†’+* B) = RingHom.kerLift (f : A β†’+* B) := rfl #align ideal.ker_lift_alg_to_ring_hom Ideal.kerLiftAlg_toRingHom theorem kerLiftAlg_injective (f : A →ₐ[R₁] B) : Function.Injective (kerLiftAlg f) := RingHom.kerLift_injective (R := A) (S := B) f #align ideal.ker_lift_alg_injective Ideal.kerLiftAlg_injective @[simps!] def quotientKerAlgEquivOfRightInverse {f : A →ₐ[R₁] B} {g : B β†’ A} (hf : Function.RightInverse g f) : (A β§Έ RingHom.ker f) ≃ₐ[R₁] B := { RingHom.quotientKerEquivOfRightInverse hf, kerLiftAlg f with } #align ideal.quotient_ker_alg_equiv_of_right_inverse Ideal.quotientKerAlgEquivOfRightInverse #align ideal.quotient_ker_alg_equiv_of_right_inverse.apply Ideal.quotientKerAlgEquivOfRightInverse_apply #align ideal.quotient_ker_alg_equiv_of_right_inverse_symm.apply Ideal.quotientKerAlgEquivOfRightInverse_symm_apply @[deprecated (since := "2024-02-27")] alias quotientKerAlgEquivOfRightInverse.apply := quotientKerAlgEquivOfRightInverse_apply @[deprecated (since := "2024-02-27")] alias QuotientKerAlgEquivOfRightInverseSymm.apply := quotientKerAlgEquivOfRightInverse_symm_apply @[simps!] noncomputable def quotientKerAlgEquivOfSurjective {f : A →ₐ[R₁] B} (hf : Function.Surjective f) : (A β§Έ (RingHom.ker f)) ≃ₐ[R₁] B := quotientKerAlgEquivOfRightInverse (Classical.choose_spec hf.hasRightInverse) #align ideal.quotient_ker_alg_equiv_of_surjective Ideal.quotientKerAlgEquivOfSurjective end section variable [CommRing B] [Algebra R₁ B] def quotientMapₐ {I : Ideal A} (J : Ideal B) (f : A →ₐ[R₁] B) (hIJ : I ≀ J.comap f) : A β§Έ I →ₐ[R₁] B β§Έ J := { quotientMap J (f : A β†’+* B) hIJ with commutes' := fun r => by simp only [RingHom.toFun_eq_coe, quotientMap_algebraMap, AlgHom.coe_toRingHom, AlgHom.commutes, Quotient.mk_algebraMap] } #align ideal.quotient_mapₐ Ideal.quotientMapₐ @[simp] theorem quotient_map_mkₐ {I : Ideal A} (J : Ideal B) (f : A →ₐ[R₁] B) (H : I ≀ J.comap f) {x : A} : quotientMapₐ J f H (Quotient.mk I x) = Quotient.mkₐ R₁ J (f x) := rfl #align ideal.quotient_map_mkₐ Ideal.quotient_map_mkₐ theorem quotient_map_comp_mkₐ {I : Ideal A} (J : Ideal B) (f : A →ₐ[R₁] B) (H : I ≀ J.comap f) : (quotientMapₐ J f H).comp (Quotient.mkₐ R₁ I) = (Quotient.mkₐ R₁ J).comp f := AlgHom.ext fun x => by simp only [quotient_map_mkₐ, Quotient.mkₐ_eq_mk, AlgHom.comp_apply] #align ideal.quotient_map_comp_mkₐ Ideal.quotient_map_comp_mkₐ def quotientEquivAlg (I : Ideal A) (J : Ideal B) (f : A ≃ₐ[R₁] B) (hIJ : J = I.map (f : A β†’+* B)) : (A β§Έ I) ≃ₐ[R₁] B β§Έ J := { quotientEquiv I J (f : A ≃+* B) hIJ with commutes' := fun r => by -- Porting note: Needed to add the below lemma because Equivs coerce weird have : βˆ€ (e : RingEquiv (A β§Έ I) (B β§Έ J)), Equiv.toFun e.toEquiv = DFunLike.coe e := fun _ ↦ rfl rw [this] simp only [quotientEquiv_apply, RingHom.toFun_eq_coe, quotientMap_algebraMap, RingEquiv.coe_toRingHom, AlgEquiv.coe_ringEquiv, AlgEquiv.commutes, Quotient.mk_algebraMap]} #align ideal.quotient_equiv_alg Ideal.quotientEquivAlg end instance (priority := 100) quotientAlgebra {I : Ideal A} [Algebra R A] : Algebra (R β§Έ I.comap (algebraMap R A)) (A β§Έ I) := (quotientMap I (algebraMap R A) (le_of_eq rfl)).toAlgebra #align ideal.quotient_algebra Ideal.quotientAlgebra theorem algebraMap_quotient_injective {I : Ideal A} [Algebra R A] : Function.Injective (algebraMap (R β§Έ I.comap (algebraMap R A)) (A β§Έ I)) := by rintro ⟨a⟩ ⟨b⟩ hab replace hab := Quotient.eq.mp hab rw [← RingHom.map_sub] at hab exact Quotient.eq.mpr hab #align ideal.algebra_map_quotient_injective Ideal.algebraMap_quotient_injective variable (R₁) def quotientEquivAlgOfEq {I J : Ideal A} (h : I = J) : (A β§Έ I) ≃ₐ[R₁] A β§Έ J := quotientEquivAlg I J AlgEquiv.refl <| h β–Έ (map_id I).symm #align ideal.quotient_equiv_alg_of_eq Ideal.quotientEquivAlgOfEq @[simp] theorem quotientEquivAlgOfEq_mk {I J : Ideal A} (h : I = J) (x : A) : quotientEquivAlgOfEq R₁ h (Ideal.Quotient.mk I x) = Ideal.Quotient.mk J x := rfl #align ideal.quotient_equiv_alg_of_eq_mk Ideal.quotientEquivAlgOfEq_mk @[simp]
Mathlib/RingTheory/Ideal/QuotientOperations.lean
676
679
theorem quotientEquivAlgOfEq_symm {I J : Ideal A} (h : I = J) : (quotientEquivAlgOfEq R₁ h).symm = quotientEquivAlgOfEq R₁ h.symm := by
ext rfl
import Mathlib.Init.Control.Combinators import Mathlib.Init.Function import Mathlib.Tactic.CasesM import Mathlib.Tactic.Attr.Core #align_import control.basic from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" universe u v w variable {Ξ± Ξ² Ξ³ : Type u} section Monad variable {m : Type u β†’ Type v} [Monad m] [LawfulMonad m] open List #align list.mpartition List.partitionM
Mathlib/Control/Basic.lean
83
85
theorem map_bind (x : m Ξ±) {g : Ξ± β†’ m Ξ²} {f : Ξ² β†’ Ξ³} : f <$> (x >>= g) = x >>= fun a => f <$> g a := by
rw [← bind_pure_comp, bind_assoc]; simp [bind_pure_comp]
import Mathlib.Data.Fin.VecNotation import Mathlib.SetTheory.Cardinal.Basic #align_import model_theory.basic from "leanprover-community/mathlib"@"369525b73f229ccd76a6ec0e0e0bf2be57599768" set_option autoImplicit true universe u v u' v' w w' open Cardinal open Cardinal namespace FirstOrder -- intended to be used with explicit universe parameters @[nolint checkUnivs] structure Language where Functions : β„• β†’ Type u Relations : β„• β†’ Type v #align first_order.language FirstOrder.Language --@[simp] def Sequenceβ‚‚ (aβ‚€ a₁ aβ‚‚ : Type u) : β„• β†’ Type u | 0 => aβ‚€ | 1 => a₁ | 2 => aβ‚‚ | _ => PEmpty #align first_order.sequenceβ‚‚ FirstOrder.Sequenceβ‚‚ namespace Language @[simps] protected def mkβ‚‚ (c f₁ fβ‚‚ : Type u) (r₁ rβ‚‚ : Type v) : Language := ⟨Sequenceβ‚‚ c f₁ fβ‚‚, Sequenceβ‚‚ PEmpty r₁ rβ‚‚βŸ© #align first_order.language.mkβ‚‚ FirstOrder.Language.mkβ‚‚ protected def empty : Language := ⟨fun _ => Empty, fun _ => Empty⟩ #align first_order.language.empty FirstOrder.Language.empty instance : Inhabited Language := ⟨Language.empty⟩ protected def sum (L : Language.{u, v}) (L' : Language.{u', v'}) : Language := ⟨fun n => Sum (L.Functions n) (L'.Functions n), fun n => Sum (L.Relations n) (L'.Relations n)⟩ #align first_order.language.sum FirstOrder.Language.sum variable (L : Language.{u, v}) -- Porting note(#5171): this linter isn't ported yet. -- @[nolint has_nonempty_instance] protected def Constants := L.Functions 0 #align first_order.language.constants FirstOrder.Language.Constants @[simp] theorem constants_mkβ‚‚ (c f₁ fβ‚‚ : Type u) (r₁ rβ‚‚ : Type v) : (Language.mkβ‚‚ c f₁ fβ‚‚ r₁ rβ‚‚).Constants = c := rfl #align first_order.language.constants_mkβ‚‚ FirstOrder.Language.constants_mkβ‚‚ -- Porting note(#5171): this linter isn't ported yet. -- @[nolint has_nonempty_instance] def Symbols := Sum (Ξ£l, L.Functions l) (Ξ£l, L.Relations l) #align first_order.language.symbols FirstOrder.Language.Symbols def card : Cardinal := #L.Symbols #align first_order.language.card FirstOrder.Language.card class IsRelational : Prop where empty_functions : βˆ€ n, IsEmpty (L.Functions n) #align first_order.language.is_relational FirstOrder.Language.IsRelational class IsAlgebraic : Prop where empty_relations : βˆ€ n, IsEmpty (L.Relations n) #align first_order.language.is_algebraic FirstOrder.Language.IsAlgebraic variable {L} {L' : Language.{u', v'}} theorem card_eq_card_functions_add_card_relations : L.card = (Cardinal.sum fun l => Cardinal.lift.{v} #(L.Functions l)) + Cardinal.sum fun l => Cardinal.lift.{u} #(L.Relations l) := by simp [card, Symbols] #align first_order.language.card_eq_card_functions_add_card_relations FirstOrder.Language.card_eq_card_functions_add_card_relations instance [L.IsRelational] {n : β„•} : IsEmpty (L.Functions n) := IsRelational.empty_functions n instance [L.IsAlgebraic] {n : β„•} : IsEmpty (L.Relations n) := IsAlgebraic.empty_relations n instance isRelational_of_empty_functions {symb : β„• β†’ Type*} : IsRelational ⟨fun _ => Empty, symb⟩ := ⟨fun _ => instIsEmptyEmpty⟩ #align first_order.language.is_relational_of_empty_functions FirstOrder.Language.isRelational_of_empty_functions instance isAlgebraic_of_empty_relations {symb : β„• β†’ Type*} : IsAlgebraic ⟨symb, fun _ => Empty⟩ := ⟨fun _ => instIsEmptyEmpty⟩ #align first_order.language.is_algebraic_of_empty_relations FirstOrder.Language.isAlgebraic_of_empty_relations instance isRelational_empty : IsRelational Language.empty := Language.isRelational_of_empty_functions #align first_order.language.is_relational_empty FirstOrder.Language.isRelational_empty instance isAlgebraic_empty : IsAlgebraic Language.empty := Language.isAlgebraic_of_empty_relations #align first_order.language.is_algebraic_empty FirstOrder.Language.isAlgebraic_empty instance isRelational_sum [L.IsRelational] [L'.IsRelational] : IsRelational (L.sum L') := ⟨fun _ => instIsEmptySum⟩ #align first_order.language.is_relational_sum FirstOrder.Language.isRelational_sum instance isAlgebraic_sum [L.IsAlgebraic] [L'.IsAlgebraic] : IsAlgebraic (L.sum L') := ⟨fun _ => instIsEmptySum⟩ #align first_order.language.is_algebraic_sum FirstOrder.Language.isAlgebraic_sum instance isRelational_mkβ‚‚ {c f₁ fβ‚‚ : Type u} {r₁ rβ‚‚ : Type v} [h0 : IsEmpty c] [h1 : IsEmpty f₁] [h2 : IsEmpty fβ‚‚] : IsRelational (Language.mkβ‚‚ c f₁ fβ‚‚ r₁ rβ‚‚) := ⟨fun n => Nat.casesOn n h0 fun n => Nat.casesOn n h1 fun n => Nat.casesOn n h2 fun _ => inferInstanceAs (IsEmpty PEmpty)⟩ #align first_order.language.is_relational_mkβ‚‚ FirstOrder.Language.isRelational_mkβ‚‚ instance isAlgebraic_mkβ‚‚ {c f₁ fβ‚‚ : Type u} {r₁ rβ‚‚ : Type v} [h1 : IsEmpty r₁] [h2 : IsEmpty rβ‚‚] : IsAlgebraic (Language.mkβ‚‚ c f₁ fβ‚‚ r₁ rβ‚‚) := ⟨fun n => Nat.casesOn n (inferInstanceAs (IsEmpty PEmpty)) fun n => Nat.casesOn n h1 fun n => Nat.casesOn n h2 fun _ => inferInstanceAs (IsEmpty PEmpty)⟩ #align first_order.language.is_algebraic_mkβ‚‚ FirstOrder.Language.isAlgebraic_mkβ‚‚ instance subsingleton_mkβ‚‚_functions {c f₁ fβ‚‚ : Type u} {r₁ rβ‚‚ : Type v} [h0 : Subsingleton c] [h1 : Subsingleton f₁] [h2 : Subsingleton fβ‚‚] {n : β„•} : Subsingleton ((Language.mkβ‚‚ c f₁ fβ‚‚ r₁ rβ‚‚).Functions n) := Nat.casesOn n h0 fun n => Nat.casesOn n h1 fun n => Nat.casesOn n h2 fun _ => ⟨fun x => PEmpty.elim x⟩ #align first_order.language.subsingleton_mkβ‚‚_functions FirstOrder.Language.subsingleton_mkβ‚‚_functions instance subsingleton_mkβ‚‚_relations {c f₁ fβ‚‚ : Type u} {r₁ rβ‚‚ : Type v} [h1 : Subsingleton r₁] [h2 : Subsingleton rβ‚‚] {n : β„•} : Subsingleton ((Language.mkβ‚‚ c f₁ fβ‚‚ r₁ rβ‚‚).Relations n) := Nat.casesOn n ⟨fun x => PEmpty.elim x⟩ fun n => Nat.casesOn n h1 fun n => Nat.casesOn n h2 fun _ => ⟨fun x => PEmpty.elim x⟩ #align first_order.language.subsingleton_mkβ‚‚_relations FirstOrder.Language.subsingleton_mkβ‚‚_relations @[simp] theorem empty_card : Language.empty.card = 0 := by simp [card_eq_card_functions_add_card_relations] #align first_order.language.empty_card FirstOrder.Language.empty_card instance isEmpty_empty : IsEmpty Language.empty.Symbols := by simp only [Language.Symbols, isEmpty_sum, isEmpty_sigma] exact ⟨fun _ => inferInstance, fun _ => inferInstance⟩ #align first_order.language.is_empty_empty FirstOrder.Language.isEmpty_empty instance Countable.countable_functions [h : Countable L.Symbols] : Countable (Ξ£l, L.Functions l) := @Function.Injective.countable _ _ h _ Sum.inl_injective #align first_order.language.countable.countable_functions FirstOrder.Language.Countable.countable_functions @[simp] theorem card_functions_sum (i : β„•) : #((L.sum L').Functions i) = (Cardinal.lift.{u'} #(L.Functions i) + Cardinal.lift.{u} #(L'.Functions i) : Cardinal) := by simp [Language.sum] #align first_order.language.card_functions_sum FirstOrder.Language.card_functions_sum @[simp] theorem card_relations_sum (i : β„•) : #((L.sum L').Relations i) = Cardinal.lift.{v'} #(L.Relations i) + Cardinal.lift.{v} #(L'.Relations i) := by simp [Language.sum] #align first_order.language.card_relations_sum FirstOrder.Language.card_relations_sum @[simp] theorem card_sum : (L.sum L').card = Cardinal.lift.{max u' v'} L.card + Cardinal.lift.{max u v} L'.card := by simp only [card_eq_card_functions_add_card_relations, card_functions_sum, card_relations_sum, sum_add_distrib', lift_add, lift_sum, lift_lift] simp only [add_assoc, add_comm (Cardinal.sum fun i => (#(L'.Functions i)).lift)] #align first_order.language.card_sum FirstOrder.Language.card_sum @[simp] theorem card_mkβ‚‚ (c f₁ fβ‚‚ : Type u) (r₁ rβ‚‚ : Type v) : (Language.mkβ‚‚ c f₁ fβ‚‚ r₁ rβ‚‚).card = Cardinal.lift.{v} #c + Cardinal.lift.{v} #f₁ + Cardinal.lift.{v} #fβ‚‚ + Cardinal.lift.{u} #r₁ + Cardinal.lift.{u} #rβ‚‚ := by simp [card_eq_card_functions_add_card_relations, add_assoc] #align first_order.language.card_mkβ‚‚ FirstOrder.Language.card_mkβ‚‚ variable (L) (M : Type w) @[ext] class Structure where funMap : βˆ€ {n}, L.Functions n β†’ (Fin n β†’ M) β†’ M RelMap : βˆ€ {n}, L.Relations n β†’ (Fin n β†’ M) β†’ Prop set_option linter.uppercaseLean3 false in #align first_order.language.Structure FirstOrder.Language.Structure set_option linter.uppercaseLean3 false in #align first_order.language.Structure.fun_map FirstOrder.Language.Structure.funMap set_option linter.uppercaseLean3 false in #align first_order.language.Structure.rel_map FirstOrder.Language.Structure.RelMap variable (N : Type w') [L.Structure M] [L.Structure N] open Structure def Inhabited.trivialStructure {Ξ± : Type*} [Inhabited Ξ±] : L.Structure Ξ± := ⟨default, default⟩ #align first_order.language.inhabited.trivial_structure FirstOrder.Language.Inhabited.trivialStructure structure Hom where toFun : M β†’ N -- Porting note: -- The autoparam here used to be `obviously`. We would like to replace it with `aesop` -- but that isn't currently sufficient. -- See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Aesop.20and.20cases -- If that can be improved, we should change this to `by aesop` and remove the proofs below. map_fun' : βˆ€ {n} (f : L.Functions n) (x), toFun (funMap f x) = funMap f (toFun ∘ x) := by intros; trivial map_rel' : βˆ€ {n} (r : L.Relations n) (x), RelMap r x β†’ RelMap r (toFun ∘ x) := by -- Porting note: see porting note on `Hom.map_fun'` intros; trivial #align first_order.language.hom FirstOrder.Language.Hom @[inherit_doc] scoped[FirstOrder] notation:25 A " β†’[" L "] " B => FirstOrder.Language.Hom L A B structure Embedding extends M β†ͺ N where map_fun' : βˆ€ {n} (f : L.Functions n) (x), toFun (funMap f x) = funMap f (toFun ∘ x) := by -- Porting note: see porting note on `Hom.map_fun'` intros; trivial map_rel' : βˆ€ {n} (r : L.Relations n) (x), RelMap r (toFun ∘ x) ↔ RelMap r x := by -- Porting note: see porting note on `Hom.map_fun'` intros; trivial #align first_order.language.embedding FirstOrder.Language.Embedding @[inherit_doc] scoped[FirstOrder] notation:25 A " β†ͺ[" L "] " B => FirstOrder.Language.Embedding L A B structure Equiv extends M ≃ N where map_fun' : βˆ€ {n} (f : L.Functions n) (x), toFun (funMap f x) = funMap f (toFun ∘ x) := by -- Porting note: see porting note on `Hom.map_fun'` intros; trivial map_rel' : βˆ€ {n} (r : L.Relations n) (x), RelMap r (toFun ∘ x) ↔ RelMap r x := by -- Porting note: see porting note on `Hom.map_fun'` intros; trivial #align first_order.language.equiv FirstOrder.Language.Equiv @[inherit_doc] scoped[FirstOrder] notation:25 A " ≃[" L "] " B => FirstOrder.Language.Equiv L A B -- Porting note: was [L.Structure P] and [L.Structure Q] -- The former reported an error. variable {L M N} {P : Type*} [Structure L P] {Q : Type*} [Structure L Q] -- Porting note (#11445): new definition @[coe] def constantMap (c : L.Constants) : M := funMap c default instance : CoeTC L.Constants M := ⟨constantMap⟩ theorem funMap_eq_coe_constants {c : L.Constants} {x : Fin 0 β†’ M} : funMap c x = c := congr rfl (funext finZeroElim) #align first_order.language.fun_map_eq_coe_constants FirstOrder.Language.funMap_eq_coe_constants theorem nonempty_of_nonempty_constants [h : Nonempty L.Constants] : Nonempty M := h.map (↑) #align first_order.language.nonempty_of_nonempty_constants FirstOrder.Language.nonempty_of_nonempty_constants def funMapβ‚‚ {c f₁ fβ‚‚ : Type u} {r₁ rβ‚‚ : Type v} (c' : c β†’ M) (f₁' : f₁ β†’ M β†’ M) (fβ‚‚' : fβ‚‚ β†’ M β†’ M β†’ M) : βˆ€ {n}, (Language.mkβ‚‚ c f₁ fβ‚‚ r₁ rβ‚‚).Functions n β†’ (Fin n β†’ M) β†’ M | 0, f, _ => c' f | 1, f, x => f₁' f (x 0) | 2, f, x => fβ‚‚' f (x 0) (x 1) | _ + 3, f, _ => PEmpty.elim f #align first_order.language.fun_mapβ‚‚ FirstOrder.Language.funMapβ‚‚ def RelMapβ‚‚ {c f₁ fβ‚‚ : Type u} {r₁ rβ‚‚ : Type v} (r₁' : r₁ β†’ Set M) (rβ‚‚' : rβ‚‚ β†’ M β†’ M β†’ Prop) : βˆ€ {n}, (Language.mkβ‚‚ c f₁ fβ‚‚ r₁ rβ‚‚).Relations n β†’ (Fin n β†’ M) β†’ Prop | 0, r, _ => PEmpty.elim r | 1, r, x => x 0 ∈ r₁' r | 2, r, x => rβ‚‚' r (x 0) (x 1) | _ + 3, r, _ => PEmpty.elim r #align first_order.language.rel_mapβ‚‚ FirstOrder.Language.RelMapβ‚‚ protected def Structure.mkβ‚‚ {c f₁ fβ‚‚ : Type u} {r₁ rβ‚‚ : Type v} (c' : c β†’ M) (f₁' : f₁ β†’ M β†’ M) (fβ‚‚' : fβ‚‚ β†’ M β†’ M β†’ M) (r₁' : r₁ β†’ Set M) (rβ‚‚' : rβ‚‚ β†’ M β†’ M β†’ Prop) : (Language.mkβ‚‚ c f₁ fβ‚‚ r₁ rβ‚‚).Structure M := ⟨funMapβ‚‚ c' f₁' fβ‚‚', RelMapβ‚‚ r₁' rβ‚‚'⟩ set_option linter.uppercaseLean3 false in #align first_order.language.Structure.mkβ‚‚ FirstOrder.Language.Structure.mkβ‚‚ class HomClass (L : outParam Language) (F M N : Type*) [FunLike F M N] [L.Structure M] [L.Structure N] : Prop where map_fun : βˆ€ (Ο† : F) {n} (f : L.Functions n) (x), Ο† (funMap f x) = funMap f (Ο† ∘ x) map_rel : βˆ€ (Ο† : F) {n} (r : L.Relations n) (x), RelMap r x β†’ RelMap r (Ο† ∘ x) #align first_order.language.hom_class FirstOrder.Language.HomClass class StrongHomClass (L : outParam Language) (F M N : Type*) [FunLike F M N] [L.Structure M] [L.Structure N] : Prop where map_fun : βˆ€ (Ο† : F) {n} (f : L.Functions n) (x), Ο† (funMap f x) = funMap f (Ο† ∘ x) map_rel : βˆ€ (Ο† : F) {n} (r : L.Relations n) (x), RelMap r (Ο† ∘ x) ↔ RelMap r x #align first_order.language.strong_hom_class FirstOrder.Language.StrongHomClass -- Porting note: using implicit brackets for `Structure` arguments instance (priority := 100) StrongHomClass.homClass [L.Structure M] [L.Structure N] [FunLike F M N] [StrongHomClass L F M N] : HomClass L F M N where map_fun := StrongHomClass.map_fun map_rel Ο† _ R x := (StrongHomClass.map_rel Ο† R x).2 #align first_order.language.strong_hom_class.hom_class FirstOrder.Language.StrongHomClass.homClass theorem HomClass.strongHomClassOfIsAlgebraic [L.IsAlgebraic] {F M N} [L.Structure M] [L.Structure N] [FunLike F M N] [HomClass L F M N] : StrongHomClass L F M N where map_fun := HomClass.map_fun map_rel _ n R _ := (IsAlgebraic.empty_relations n).elim R #align first_order.language.hom_class.strong_hom_class_of_is_algebraic FirstOrder.Language.HomClass.strongHomClassOfIsAlgebraic theorem HomClass.map_constants {F M N} [L.Structure M] [L.Structure N] [FunLike F M N] [HomClass L F M N] (Ο† : F) (c : L.Constants) : Ο† c = c := (HomClass.map_fun Ο† c default).trans (congr rfl (funext default)) #align first_order.language.hom_class.map_constants FirstOrder.Language.HomClass.map_constants attribute [inherit_doc FirstOrder.Language.Hom.map_fun'] FirstOrder.Language.Embedding.map_fun' FirstOrder.Language.HomClass.map_fun FirstOrder.Language.StrongHomClass.map_fun FirstOrder.Language.Equiv.map_fun' attribute [inherit_doc FirstOrder.Language.Hom.map_rel'] FirstOrder.Language.Embedding.map_rel' FirstOrder.Language.HomClass.map_rel FirstOrder.Language.StrongHomClass.map_rel FirstOrder.Language.Equiv.map_rel' def HomClass.toHom {F M N} [L.Structure M] [L.Structure N] [FunLike F M N] [HomClass L F M N] : F β†’ M β†’[L] N := fun Ο† => βŸ¨Ο†, HomClass.map_fun Ο†, HomClass.map_rel Ο†βŸ© #align first_order.language.hom_class.to_hom FirstOrder.Language.HomClass.toHom namespace Embedding instance funLike : FunLike (M β†ͺ[L] N) M N where coe f := f.toFun coe_injective' f g h := by cases f cases g congr ext x exact Function.funext_iff.1 h x instance embeddingLike : EmbeddingLike (M β†ͺ[L] N) M N where injective' f := f.toEmbedding.injective #align first_order.language.embedding.embedding_like FirstOrder.Language.Embedding.embeddingLike instance strongHomClass : StrongHomClass L (M β†ͺ[L] N) M N where map_fun := map_fun' map_rel := map_rel' #align first_order.language.embedding.strong_hom_class FirstOrder.Language.Embedding.strongHomClass #noalign first_order.language.embedding.has_coe_to_fun -- Porting note: replaced by funLike instance @[simp] theorem map_fun (Ο† : M β†ͺ[L] N) {n : β„•} (f : L.Functions n) (x : Fin n β†’ M) : Ο† (funMap f x) = funMap f (Ο† ∘ x) := HomClass.map_fun Ο† f x #align first_order.language.embedding.map_fun FirstOrder.Language.Embedding.map_fun @[simp] theorem map_constants (Ο† : M β†ͺ[L] N) (c : L.Constants) : Ο† c = c := HomClass.map_constants Ο† c #align first_order.language.embedding.map_constants FirstOrder.Language.Embedding.map_constants @[simp] theorem map_rel (Ο† : M β†ͺ[L] N) {n : β„•} (r : L.Relations n) (x : Fin n β†’ M) : RelMap r (Ο† ∘ x) ↔ RelMap r x := StrongHomClass.map_rel Ο† r x #align first_order.language.embedding.map_rel FirstOrder.Language.Embedding.map_rel def toHom : (M β†ͺ[L] N) β†’ M β†’[L] N := HomClass.toHom #align first_order.language.embedding.to_hom FirstOrder.Language.Embedding.toHom @[simp] theorem coe_toHom {f : M β†ͺ[L] N} : (f.toHom : M β†’ N) = f := rfl #align first_order.language.embedding.coe_to_hom FirstOrder.Language.Embedding.coe_toHom theorem coe_injective : @Function.Injective (M β†ͺ[L] N) (M β†’ N) (↑) | f, g, h => by cases f cases g congr ext x exact Function.funext_iff.1 h x #align first_order.language.embedding.coe_injective FirstOrder.Language.Embedding.coe_injective @[ext] theorem ext ⦃f g : M β†ͺ[L] N⦄ (h : βˆ€ x, f x = g x) : f = g := coe_injective (funext h) #align first_order.language.embedding.ext FirstOrder.Language.Embedding.ext theorem ext_iff {f g : M β†ͺ[L] N} : f = g ↔ βˆ€ x, f x = g x := ⟨fun h _ => h β–Έ rfl, fun h => ext h⟩ #align first_order.language.embedding.ext_iff FirstOrder.Language.Embedding.ext_iff theorem toHom_injective : @Function.Injective (M β†ͺ[L] N) (M β†’[L] N) (Β·.toHom) := by intro f f' h ext exact congr_fun (congr_arg (↑) h) _ @[simp] theorem toHom_inj {f g : M β†ͺ[L] N} : f.toHom = g.toHom ↔ f = g := ⟨fun h ↦ toHom_injective h, fun h ↦ congr_arg (Β·.toHom) h⟩ theorem injective (f : M β†ͺ[L] N) : Function.Injective f := f.toEmbedding.injective #align first_order.language.embedding.injective FirstOrder.Language.Embedding.injective @[simps!] def ofInjective [L.IsAlgebraic] {f : M β†’[L] N} (hf : Function.Injective f) : M β†ͺ[L] N := { f with inj' := hf map_rel' := fun {_} r x => StrongHomClass.map_rel f r x } #align first_order.language.embedding.of_injective FirstOrder.Language.Embedding.ofInjective @[simp] theorem coeFn_ofInjective [L.IsAlgebraic] {f : M β†’[L] N} (hf : Function.Injective f) : (ofInjective hf : M β†’ N) = f := rfl #align first_order.language.embedding.coe_fn_of_injective FirstOrder.Language.Embedding.coeFn_ofInjective @[simp]
Mathlib/ModelTheory/Basic.lean
698
700
theorem ofInjective_toHom [L.IsAlgebraic] {f : M β†’[L] N} (hf : Function.Injective f) : (ofInjective hf).toHom = f := by
ext; simp
import Mathlib.Algebra.Group.Units.Hom import Mathlib.Algebra.GroupWithZero.Commute import Mathlib.Algebra.GroupWithZero.Hom import Mathlib.GroupTheory.GroupAction.Units #align_import algebra.group_with_zero.units.lemmas from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" assert_not_exists DenselyOrdered variable {Ξ± Mβ‚€ Gβ‚€ Mβ‚€' Gβ‚€' F F' : Type*} variable [MonoidWithZero Mβ‚€] section MonoidWithZero variable [GroupWithZero Gβ‚€] [Nontrivial Mβ‚€] [MonoidWithZero Mβ‚€'] [FunLike F Gβ‚€ Mβ‚€] [MonoidWithZeroHomClass F Gβ‚€ Mβ‚€] [FunLike F' Gβ‚€ Mβ‚€'] [MonoidWithZeroHomClass F' Gβ‚€ Mβ‚€'] (f : F) {a : Gβ‚€} theorem map_ne_zero : f a β‰  0 ↔ a β‰  0 := ⟨fun hfa ha => hfa <| ha.symm β–Έ map_zero f, fun ha => ((IsUnit.mk0 a ha).map f).ne_zero⟩ #align map_ne_zero map_ne_zero @[simp] theorem map_eq_zero : f a = 0 ↔ a = 0 := not_iff_not.1 (map_ne_zero f) #align map_eq_zero map_eq_zero
Mathlib/Algebra/GroupWithZero/Units/Lemmas.lean
49
52
theorem eq_on_invβ‚€ (f g : F') (h : f a = g a) : f a⁻¹ = g a⁻¹ := by
rcases eq_or_ne a 0 with (rfl | ha) Β· rw [inv_zero, map_zero, map_zero] Β· exact (IsUnit.mk0 a ha).eq_on_inv f g h
import Mathlib.MeasureTheory.Decomposition.RadonNikodym import Mathlib.MeasureTheory.Measure.Haar.OfBasis import Mathlib.Probability.Independence.Basic #align_import probability.density from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" open scoped Classical MeasureTheory NNReal ENNReal open TopologicalSpace MeasureTheory.Measure noncomputable section namespace MeasureTheory variable {Ξ© E : Type*} [MeasurableSpace E] class HasPDF {m : MeasurableSpace Ξ©} (X : Ξ© β†’ E) (β„™ : Measure Ξ©) (ΞΌ : Measure E := by volume_tac) : Prop where pdf' : AEMeasurable X β„™ ∧ (map X β„™).HaveLebesgueDecomposition ΞΌ ∧ map X β„™ β‰ͺ ΞΌ #align measure_theory.has_pdf MeasureTheory.HasPDF def pdf {_ : MeasurableSpace Ξ©} (X : Ξ© β†’ E) (β„™ : Measure Ξ©) (ΞΌ : Measure E := by volume_tac) : E β†’ ℝβ‰₯0∞ := (map X β„™).rnDeriv ΞΌ #align measure_theory.pdf MeasureTheory.pdf theorem pdf_def {_ : MeasurableSpace Ξ©} {β„™ : Measure Ξ©} {ΞΌ : Measure E} {X : Ξ© β†’ E} : pdf X β„™ ΞΌ = (map X β„™).rnDeriv ΞΌ := rfl theorem pdf_of_not_aemeasurable {_ : MeasurableSpace Ξ©} {β„™ : Measure Ξ©} {ΞΌ : Measure E} {X : Ξ© β†’ E} (hX : Β¬AEMeasurable X β„™) : pdf X β„™ ΞΌ =ᡐ[ΞΌ] 0 := by rw [pdf_def, map_of_not_aemeasurable hX] exact rnDeriv_zero ΞΌ #align measure_theory.pdf_eq_zero_of_not_measurable MeasureTheory.pdf_of_not_aemeasurable theorem pdf_of_not_haveLebesgueDecomposition {_ : MeasurableSpace Ξ©} {β„™ : Measure Ξ©} {ΞΌ : Measure E} {X : Ξ© β†’ E} (h : Β¬(map X β„™).HaveLebesgueDecomposition ΞΌ) : pdf X β„™ ΞΌ = 0 := rnDeriv_of_not_haveLebesgueDecomposition h theorem aemeasurable_of_pdf_ne_zero {m : MeasurableSpace Ξ©} {β„™ : Measure Ξ©} {ΞΌ : Measure E} (X : Ξ© β†’ E) (h : Β¬pdf X β„™ ΞΌ =ᡐ[ΞΌ] 0) : AEMeasurable X β„™ := by contrapose! h exact pdf_of_not_aemeasurable h #align measure_theory.measurable_of_pdf_ne_zero MeasureTheory.aemeasurable_of_pdf_ne_zero theorem hasPDF_of_pdf_ne_zero {m : MeasurableSpace Ξ©} {β„™ : Measure Ξ©} {ΞΌ : Measure E} {X : Ξ© β†’ E} (hac : map X β„™ β‰ͺ ΞΌ) (hpdf : Β¬pdf X β„™ ΞΌ =ᡐ[ΞΌ] 0) : HasPDF X β„™ ΞΌ := by refine ⟨?_, ?_, hac⟩ Β· exact aemeasurable_of_pdf_ne_zero X hpdf Β· contrapose! hpdf have := pdf_of_not_haveLebesgueDecomposition hpdf filter_upwards using congrFun this #align measure_theory.has_pdf_of_pdf_ne_zero MeasureTheory.hasPDF_of_pdf_ne_zero @[measurability] theorem measurable_pdf {m : MeasurableSpace Ξ©} (X : Ξ© β†’ E) (β„™ : Measure Ξ©) (ΞΌ : Measure E := by volume_tac) : Measurable (pdf X β„™ ΞΌ) := by exact measurable_rnDeriv _ _ #align measure_theory.measurable_pdf MeasureTheory.measurable_pdf theorem withDensity_pdf_le_map {_ : MeasurableSpace Ξ©} (X : Ξ© β†’ E) (β„™ : Measure Ξ©) (ΞΌ : Measure E := by volume_tac) : ΞΌ.withDensity (pdf X β„™ ΞΌ) ≀ map X β„™ := withDensity_rnDeriv_le _ _ theorem set_lintegral_pdf_le_map {m : MeasurableSpace Ξ©} (X : Ξ© β†’ E) (β„™ : Measure Ξ©) (ΞΌ : Measure E := by volume_tac) (s : Set E) : ∫⁻ x in s, pdf X β„™ ΞΌ x βˆ‚ΞΌ ≀ map X β„™ s := by apply (withDensity_apply_le _ s).trans exact withDensity_pdf_le_map _ _ _ s theorem map_eq_withDensity_pdf {m : MeasurableSpace Ξ©} (X : Ξ© β†’ E) (β„™ : Measure Ξ©) (ΞΌ : Measure E := by volume_tac) [hX : HasPDF X β„™ ΞΌ] : map X β„™ = ΞΌ.withDensity (pdf X β„™ ΞΌ) := by rw [pdf_def, withDensity_rnDeriv_eq _ _ hX.absolutelyContinuous] #align measure_theory.map_eq_with_density_pdf MeasureTheory.map_eq_withDensity_pdf theorem map_eq_set_lintegral_pdf {m : MeasurableSpace Ξ©} (X : Ξ© β†’ E) (β„™ : Measure Ξ©) (ΞΌ : Measure E := by volume_tac) [hX : HasPDF X β„™ ΞΌ] {s : Set E} (hs : MeasurableSet s) : map X β„™ s = ∫⁻ x in s, pdf X β„™ ΞΌ x βˆ‚ΞΌ := by rw [← withDensity_apply _ hs, map_eq_withDensity_pdf X β„™ ΞΌ] #align measure_theory.map_eq_set_lintegral_pdf MeasureTheory.map_eq_set_lintegral_pdf namespace pdf variable {m : MeasurableSpace Ξ©} {β„™ : Measure Ξ©} {ΞΌ : Measure E} protected theorem congr {X Y : Ξ© β†’ E} (hXY : X =ᡐ[β„™] Y) : pdf X β„™ ΞΌ = pdf Y β„™ ΞΌ := by rw [pdf_def, pdf_def, map_congr hXY]
Mathlib/Probability/Density.lean
202
205
theorem lintegral_eq_measure_univ {X : Ξ© β†’ E} [HasPDF X β„™ ΞΌ] : ∫⁻ x, pdf X β„™ ΞΌ x βˆ‚ΞΌ = β„™ Set.univ := by
rw [← set_lintegral_univ, ← map_eq_set_lintegral_pdf X β„™ ΞΌ MeasurableSet.univ, map_apply_of_aemeasurable (HasPDF.aemeasurable X β„™ ΞΌ) MeasurableSet.univ, Set.preimage_univ]
import Mathlib.CategoryTheory.Sites.Subsheaf import Mathlib.CategoryTheory.Sites.CompatibleSheafification import Mathlib.CategoryTheory.Sites.LocallyInjective #align_import category_theory.sites.surjective from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe v u w v' u' w' open Opposite CategoryTheory CategoryTheory.GrothendieckTopology namespace CategoryTheory variable {C : Type u} [Category.{v} C] (J : GrothendieckTopology C) attribute [local instance] ConcreteCategory.hasCoeToSort ConcreteCategory.instFunLike variable {A : Type u'} [Category.{v'} A] [ConcreteCategory.{w'} A] namespace Presheaf @[simps (config := .lemmasOnly)] def imageSieve {F G : Cα΅’α΅– β₯€ A} (f : F ⟢ G) {U : C} (s : G.obj (op U)) : Sieve U where arrows V i := βˆƒ t : F.obj (op V), f.app _ t = G.map i.op s downward_closed := by rintro V W i ⟨t, ht⟩ j refine ⟨F.map j.op t, ?_⟩ rw [op_comp, G.map_comp, comp_apply, ← ht, elementwise_of% f.naturality] #align category_theory.image_sieve CategoryTheory.Presheaf.imageSieve theorem imageSieve_eq_sieveOfSection {F G : Cα΅’α΅– β₯€ A} (f : F ⟢ G) {U : C} (s : G.obj (op U)) : imageSieve f s = (imagePresheaf (whiskerRight f (forget A))).sieveOfSection s := rfl #align category_theory.image_sieve_eq_sieve_of_section CategoryTheory.Presheaf.imageSieve_eq_sieveOfSection theorem imageSieve_whisker_forget {F G : Cα΅’α΅– β₯€ A} (f : F ⟢ G) {U : C} (s : G.obj (op U)) : imageSieve (whiskerRight f (forget A)) s = imageSieve f s := rfl #align category_theory.image_sieve_whisker_forget CategoryTheory.Presheaf.imageSieve_whisker_forget theorem imageSieve_app {F G : Cα΅’α΅– β₯€ A} (f : F ⟢ G) {U : C} (s : F.obj (op U)) : imageSieve f (f.app _ s) = ⊀ := by ext V i simp only [Sieve.top_apply, iff_true_iff, imageSieve_apply] have := elementwise_of% (f.naturality i.op) exact ⟨F.map i.op s, this s⟩ #align category_theory.image_sieve_app CategoryTheory.Presheaf.imageSieve_app noncomputable def localPreimage {F G : Cα΅’α΅– β₯€ A} (f : F ⟢ G) {U : Cα΅’α΅–} (s : G.obj U) {V : C} (g : V ⟢ U.unop) (hg : imageSieve f s g) : F.obj (op V) := hg.choose @[simp] lemma app_localPreimage {F G : Cα΅’α΅– β₯€ A} (f : F ⟢ G) {U : Cα΅’α΅–} (s : G.obj U) {V : C} (g : V ⟢ U.unop) (hg : imageSieve f s g) : f.app _ (localPreimage f s g hg) = G.map g.op s := hg.choose_spec class IsLocallySurjective {F G : Cα΅’α΅– β₯€ A} (f : F ⟢ G) : Prop where imageSieve_mem {U : C} (s : G.obj (op U)) : imageSieve f s ∈ J U #align category_theory.is_locally_surjective CategoryTheory.Presheaf.IsLocallySurjective lemma imageSieve_mem {F G : Cα΅’α΅– β₯€ A} (f : F ⟢ G) [IsLocallySurjective J f] {U : Cα΅’α΅–} (s : G.obj U) : imageSieve f s ∈ J U.unop := IsLocallySurjective.imageSieve_mem _ instance {F G : Cα΅’α΅– β₯€ A} (f : F ⟢ G) [IsLocallySurjective J f] : IsLocallySurjective J (whiskerRight f (forget A)) where imageSieve_mem s := imageSieve_mem J f s
Mathlib/CategoryTheory/Sites/LocallySurjective.lean
101
105
theorem isLocallySurjective_iff_imagePresheaf_sheafify_eq_top {F G : Cα΅’α΅– β₯€ A} (f : F ⟢ G) : IsLocallySurjective J f ↔ (imagePresheaf (whiskerRight f (forget A))).sheafify J = ⊀ := by
simp only [Subpresheaf.ext_iff, Function.funext_iff, Set.ext_iff, top_subpresheaf_obj, Set.top_eq_univ, Set.mem_univ, iff_true_iff] exact ⟨fun H _ => H.imageSieve_mem, fun H => ⟨H _⟩⟩
import Mathlib.FieldTheory.Minpoly.Field #align_import ring_theory.power_basis from "leanprover-community/mathlib"@"d1d69e99ed34c95266668af4e288fc1c598b9a7f" open Polynomial open Polynomial variable {R S T : Type*} [CommRing R] [Ring S] [Algebra R S] variable {A B : Type*} [CommRing A] [CommRing B] [IsDomain B] [Algebra A B] variable {K : Type*} [Field K] -- Porting note(#5171): this linter isn't ported yet. -- @[nolint has_nonempty_instance] structure PowerBasis (R S : Type*) [CommRing R] [Ring S] [Algebra R S] where gen : S dim : β„• basis : Basis (Fin dim) R S basis_eq_pow : βˆ€ (i), basis i = gen ^ (i : β„•) #align power_basis PowerBasis -- this is usually not needed because of `basis_eq_pow` but can be needed in some cases; -- in such circumstances, add it manually using `@[simps dim gen basis]`. initialize_simps_projections PowerBasis (-basis) namespace PowerBasis @[simp] theorem coe_basis (pb : PowerBasis R S) : ⇑pb.basis = fun i : Fin pb.dim => pb.gen ^ (i : β„•) := funext pb.basis_eq_pow #align power_basis.coe_basis PowerBasis.coe_basis theorem finite (pb : PowerBasis R S) : Module.Finite R S := .of_basis pb.basis #align power_basis.finite_dimensional PowerBasis.finite @[deprecated] alias finiteDimensional := PowerBasis.finite theorem finrank [StrongRankCondition R] (pb : PowerBasis R S) : FiniteDimensional.finrank R S = pb.dim := by rw [FiniteDimensional.finrank_eq_card_basis pb.basis, Fintype.card_fin] #align power_basis.finrank PowerBasis.finrank theorem mem_span_pow' {x y : S} {d : β„•} : y ∈ Submodule.span R (Set.range fun i : Fin d => x ^ (i : β„•)) ↔ βˆƒ f : R[X], f.degree < d ∧ y = aeval x f := by have : (Set.range fun i : Fin d => x ^ (i : β„•)) = (fun i : β„• => x ^ i) '' ↑(Finset.range d) := by ext n simp_rw [Set.mem_range, Set.mem_image, Finset.mem_coe, Finset.mem_range] exact ⟨fun ⟨⟨i, hi⟩, hy⟩ => ⟨i, hi, hy⟩, fun ⟨i, hi, hy⟩ => ⟨⟨i, hi⟩, hy⟩⟩ simp only [this, Finsupp.mem_span_image_iff_total, degree_lt_iff_coeff_zero, support, exists_iff_exists_finsupp, coeff, aeval_def, evalβ‚‚RingHom', evalβ‚‚_eq_sum, Polynomial.sum, Finsupp.mem_supported', Finsupp.total, Finsupp.sum, Algebra.smul_def, evalβ‚‚_zero, exists_prop, LinearMap.id_coe, evalβ‚‚_one, id, not_lt, Finsupp.coe_lsum, LinearMap.coe_smulRight, Finset.mem_range, AlgHom.coe_mks, Finset.mem_coe] simp_rw [@eq_comm _ y] exact Iff.rfl #align power_basis.mem_span_pow' PowerBasis.mem_span_pow' theorem mem_span_pow {x y : S} {d : β„•} (hd : d β‰  0) : y ∈ Submodule.span R (Set.range fun i : Fin d => x ^ (i : β„•)) ↔ βˆƒ f : R[X], f.natDegree < d ∧ y = aeval x f := by rw [mem_span_pow'] constructor <;> Β· rintro ⟨f, h, hy⟩ refine ⟨f, ?_, hy⟩ by_cases hf : f = 0 Β· simp only [hf, natDegree_zero, degree_zero] at h ⊒ first | exact lt_of_le_of_ne (Nat.zero_le d) hd.symm | exact WithBot.bot_lt_coe d simp_all only [degree_eq_natDegree hf] Β· first | exact WithBot.coe_lt_coe.1 h | exact WithBot.coe_lt_coe.2 h #align power_basis.mem_span_pow PowerBasis.mem_span_pow theorem dim_ne_zero [Nontrivial S] (pb : PowerBasis R S) : pb.dim β‰  0 := fun h => not_nonempty_iff.mpr (h.symm β–Έ Fin.isEmpty : IsEmpty (Fin pb.dim)) pb.basis.index_nonempty #align power_basis.dim_ne_zero PowerBasis.dim_ne_zero theorem dim_pos [Nontrivial S] (pb : PowerBasis R S) : 0 < pb.dim := Nat.pos_of_ne_zero pb.dim_ne_zero #align power_basis.dim_pos PowerBasis.dim_pos theorem exists_eq_aeval [Nontrivial S] (pb : PowerBasis R S) (y : S) : βˆƒ f : R[X], f.natDegree < pb.dim ∧ y = aeval pb.gen f := (mem_span_pow pb.dim_ne_zero).mp (by simpa using pb.basis.mem_span y) #align power_basis.exists_eq_aeval PowerBasis.exists_eq_aeval
Mathlib/RingTheory/PowerBasis.lean
132
135
theorem exists_eq_aeval' (pb : PowerBasis R S) (y : S) : βˆƒ f : R[X], y = aeval pb.gen f := by
nontriviality S obtain ⟨f, _, hf⟩ := exists_eq_aeval pb y exact ⟨f, hf⟩
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] section IdealOperations open LieSubmodule LieSubalgebra variable {R : Type u} {L : Type v} {M : Type w} variable [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] variable [LieRingModule L M] [LieModule R L M] variable (N N' : LieSubmodule R L M) (I J : LieIdeal R L) @[simp] theorem LieSubmodule.trivial_lie_oper_zero [LieModule.IsTrivial L M] : ⁅I, N⁆ = βŠ₯ := by suffices ⁅I, N⁆ ≀ βŠ₯ from le_bot_iff.mp this rw [lieIdeal_oper_eq_span, LieSubmodule.lieSpan_le] rintro m ⟨x, n, h⟩; rw [trivial_lie_zero] at h; simp [← h] #align lie_submodule.trivial_lie_oper_zero LieSubmodule.trivial_lie_oper_zero
Mathlib/Algebra/Lie/Abelian.lean
318
326
theorem LieSubmodule.lie_abelian_iff_lie_self_eq_bot : IsLieAbelian I ↔ ⁅I, I⁆ = βŠ₯ := by
simp only [_root_.eq_bot_iff, lieIdeal_oper_eq_span, LieSubmodule.lieSpan_le, LieSubmodule.bot_coe, Set.subset_singleton_iff, Set.mem_setOf_eq, exists_imp] refine ⟨fun h z x y hz => hz.symm.trans (((I : LieSubalgebra R L).coe_bracket x y).symm.trans ((coe_zero_iff_zero _ _).mpr (by apply h.trivial))), fun h => ⟨fun x y => ((I : LieSubalgebra R L).coe_zero_iff_zero _).mp (h _ x y rfl)⟩⟩
import Mathlib.Data.Complex.Module import Mathlib.Data.Complex.Order import Mathlib.Data.Complex.Exponential import Mathlib.Analysis.RCLike.Basic import Mathlib.Topology.Algebra.InfiniteSum.Module import Mathlib.Topology.Instances.RealVectorSpace #align_import analysis.complex.basic from "leanprover-community/mathlib"@"3f655f5297b030a87d641ad4e825af8d9679eb0b" assert_not_exists Absorbs noncomputable section namespace Complex variable {z : β„‚} open ComplexConjugate Topology Filter instance : Norm β„‚ := ⟨abs⟩ @[simp] theorem norm_eq_abs (z : β„‚) : β€–zβ€– = abs z := rfl #align complex.norm_eq_abs Complex.norm_eq_abs lemma norm_I : β€–Iβ€– = 1 := abs_I theorem norm_exp_ofReal_mul_I (t : ℝ) : β€–exp (t * I)β€– = 1 := by simp only [norm_eq_abs, abs_exp_ofReal_mul_I] set_option linter.uppercaseLean3 false in #align complex.norm_exp_of_real_mul_I Complex.norm_exp_ofReal_mul_I instance instNormedAddCommGroup : NormedAddCommGroup β„‚ := AddGroupNorm.toNormedAddCommGroup { abs with map_zero' := map_zero abs neg' := abs.map_neg eq_zero_of_map_eq_zero' := fun _ => abs.eq_zero.1 } instance : NormedField β„‚ where dist_eq _ _ := rfl norm_mul' := map_mul abs instance : DenselyNormedField β„‚ where lt_norm_lt r₁ rβ‚‚ hβ‚€ hr := let ⟨x, h⟩ := exists_between hr ⟨x, by rwa [norm_eq_abs, abs_ofReal, abs_of_pos (hβ‚€.trans_lt h.1)]⟩ instance {R : Type*} [NormedField R] [NormedAlgebra R ℝ] : NormedAlgebra R β„‚ where norm_smul_le r x := by rw [← algebraMap_smul ℝ r x, real_smul, norm_mul, norm_eq_abs, abs_ofReal, ← Real.norm_eq_abs, norm_algebraMap'] variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace β„‚ E] -- see Note [lower instance priority] instance (priority := 900) _root_.NormedSpace.complexToReal : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ β„‚ E #align normed_space.complex_to_real NormedSpace.complexToReal -- see Note [lower instance priority] instance (priority := 900) _root_.NormedAlgebra.complexToReal {A : Type*} [SeminormedRing A] [NormedAlgebra β„‚ A] : NormedAlgebra ℝ A := NormedAlgebra.restrictScalars ℝ β„‚ A theorem dist_eq (z w : β„‚) : dist z w = abs (z - w) := rfl #align complex.dist_eq Complex.dist_eq theorem dist_eq_re_im (z w : β„‚) : dist z w = √((z.re - w.re) ^ 2 + (z.im - w.im) ^ 2) := by rw [sq, sq] rfl #align complex.dist_eq_re_im Complex.dist_eq_re_im @[simp] theorem dist_mk (x₁ y₁ xβ‚‚ yβ‚‚ : ℝ) : dist (mk x₁ y₁) (mk xβ‚‚ yβ‚‚) = √((x₁ - xβ‚‚) ^ 2 + (y₁ - yβ‚‚) ^ 2) := dist_eq_re_im _ _ #align complex.dist_mk Complex.dist_mk theorem dist_of_re_eq {z w : β„‚} (h : z.re = w.re) : dist z w = dist z.im w.im := by rw [dist_eq_re_im, h, sub_self, zero_pow two_ne_zero, zero_add, Real.sqrt_sq_eq_abs, Real.dist_eq] #align complex.dist_of_re_eq Complex.dist_of_re_eq theorem nndist_of_re_eq {z w : β„‚} (h : z.re = w.re) : nndist z w = nndist z.im w.im := NNReal.eq <| dist_of_re_eq h #align complex.nndist_of_re_eq Complex.nndist_of_re_eq theorem edist_of_re_eq {z w : β„‚} (h : z.re = w.re) : edist z w = edist z.im w.im := by rw [edist_nndist, edist_nndist, nndist_of_re_eq h] #align complex.edist_of_re_eq Complex.edist_of_re_eq theorem dist_of_im_eq {z w : β„‚} (h : z.im = w.im) : dist z w = dist z.re w.re := by rw [dist_eq_re_im, h, sub_self, zero_pow two_ne_zero, add_zero, Real.sqrt_sq_eq_abs, Real.dist_eq] #align complex.dist_of_im_eq Complex.dist_of_im_eq theorem nndist_of_im_eq {z w : β„‚} (h : z.im = w.im) : nndist z w = nndist z.re w.re := NNReal.eq <| dist_of_im_eq h #align complex.nndist_of_im_eq Complex.nndist_of_im_eq theorem edist_of_im_eq {z w : β„‚} (h : z.im = w.im) : edist z w = edist z.re w.re := by rw [edist_nndist, edist_nndist, nndist_of_im_eq h] #align complex.edist_of_im_eq Complex.edist_of_im_eq theorem dist_conj_self (z : β„‚) : dist (conj z) z = 2 * |z.im| := by rw [dist_of_re_eq (conj_re z), conj_im, dist_comm, Real.dist_eq, sub_neg_eq_add, ← two_mul, _root_.abs_mul, abs_of_pos (zero_lt_two' ℝ)] #align complex.dist_conj_self Complex.dist_conj_self theorem nndist_conj_self (z : β„‚) : nndist (conj z) z = 2 * Real.nnabs z.im := NNReal.eq <| by rw [← dist_nndist, NNReal.coe_mul, NNReal.coe_two, Real.coe_nnabs, dist_conj_self] #align complex.nndist_conj_self Complex.nndist_conj_self theorem dist_self_conj (z : β„‚) : dist z (conj z) = 2 * |z.im| := by rw [dist_comm, dist_conj_self] #align complex.dist_self_conj Complex.dist_self_conj theorem nndist_self_conj (z : β„‚) : nndist z (conj z) = 2 * Real.nnabs z.im := by rw [nndist_comm, nndist_conj_self] #align complex.nndist_self_conj Complex.nndist_self_conj @[simp 1100] theorem comap_abs_nhds_zero : comap abs (𝓝 0) = 𝓝 0 := comap_norm_nhds_zero #align complex.comap_abs_nhds_zero Complex.comap_abs_nhds_zero theorem norm_real (r : ℝ) : β€–(r : β„‚)β€– = β€–rβ€– := abs_ofReal _ #align complex.norm_real Complex.norm_real @[simp 1100] theorem norm_rat (r : β„š) : β€–(r : β„‚)β€– = |(r : ℝ)| := by rw [← ofReal_ratCast] exact norm_real _ #align complex.norm_rat Complex.norm_rat @[simp 1100] theorem norm_nat (n : β„•) : β€–(n : β„‚)β€– = n := abs_natCast _ #align complex.norm_nat Complex.norm_nat @[simp 1100] lemma norm_int {n : β„€} : β€–(n : β„‚)β€– = |(n : ℝ)| := abs_intCast n #align complex.norm_int Complex.norm_int theorem norm_int_of_nonneg {n : β„€} (hn : 0 ≀ n) : β€–(n : β„‚)β€– = n := by rw [norm_int, ← Int.cast_abs, _root_.abs_of_nonneg hn] #align complex.norm_int_of_nonneg Complex.norm_int_of_nonneg lemma normSq_eq_norm_sq (z : β„‚) : normSq z = β€–zβ€– ^ 2 := by rw [normSq_eq_abs, norm_eq_abs] @[continuity] theorem continuous_abs : Continuous abs := continuous_norm #align complex.continuous_abs Complex.continuous_abs @[continuity] theorem continuous_normSq : Continuous normSq := by simpa [← normSq_eq_abs] using continuous_abs.pow 2 #align complex.continuous_norm_sq Complex.continuous_normSq @[simp, norm_cast] theorem nnnorm_real (r : ℝ) : β€–(r : β„‚)β€–β‚Š = β€–rβ€–β‚Š := Subtype.ext <| norm_real r #align complex.nnnorm_real Complex.nnnorm_real @[simp, norm_cast] theorem nnnorm_nat (n : β„•) : β€–(n : β„‚)β€–β‚Š = n := Subtype.ext <| by simp #align complex.nnnorm_nat Complex.nnnorm_nat @[simp, norm_cast] theorem nnnorm_int (n : β„€) : β€–(n : β„‚)β€–β‚Š = β€–nβ€–β‚Š := Subtype.ext norm_int #align complex.nnnorm_int Complex.nnnorm_int theorem nnnorm_eq_one_of_pow_eq_one {ΞΆ : β„‚} {n : β„•} (h : ΞΆ ^ n = 1) (hn : n β‰  0) : β€–ΞΆβ€–β‚Š = 1 := (pow_left_inj zero_le' zero_le' hn).1 <| by rw [← nnnorm_pow, h, nnnorm_one, one_pow] #align complex.nnnorm_eq_one_of_pow_eq_one Complex.nnnorm_eq_one_of_pow_eq_one theorem norm_eq_one_of_pow_eq_one {ΞΆ : β„‚} {n : β„•} (h : ΞΆ ^ n = 1) (hn : n β‰  0) : β€–ΞΆβ€– = 1 := congr_arg Subtype.val (nnnorm_eq_one_of_pow_eq_one h hn) #align complex.norm_eq_one_of_pow_eq_one Complex.norm_eq_one_of_pow_eq_one theorem equivRealProd_apply_le (z : β„‚) : β€–equivRealProd zβ€– ≀ abs z := by simp [Prod.norm_def, abs_re_le_abs, abs_im_le_abs] #align complex.equiv_real_prod_apply_le Complex.equivRealProd_apply_le theorem equivRealProd_apply_le' (z : β„‚) : β€–equivRealProd zβ€– ≀ 1 * abs z := by simpa using equivRealProd_apply_le z #align complex.equiv_real_prod_apply_le' Complex.equivRealProd_apply_le' theorem lipschitz_equivRealProd : LipschitzWith 1 equivRealProd := by simpa using AddMonoidHomClass.lipschitz_of_bound equivRealProdLm 1 equivRealProd_apply_le' #align complex.lipschitz_equiv_real_prod Complex.lipschitz_equivRealProd theorem antilipschitz_equivRealProd : AntilipschitzWith (NNReal.sqrt 2) equivRealProd := AddMonoidHomClass.antilipschitz_of_bound equivRealProdLm fun z ↦ by simpa only [Real.coe_sqrt, NNReal.coe_ofNat] using abs_le_sqrt_two_mul_max z #align complex.antilipschitz_equiv_real_prod Complex.antilipschitz_equivRealProd theorem uniformEmbedding_equivRealProd : UniformEmbedding equivRealProd := antilipschitz_equivRealProd.uniformEmbedding lipschitz_equivRealProd.uniformContinuous #align complex.uniform_embedding_equiv_real_prod Complex.uniformEmbedding_equivRealProd instance : CompleteSpace β„‚ := (completeSpace_congr uniformEmbedding_equivRealProd).mpr inferInstance instance instT2Space : T2Space β„‚ := TopologicalSpace.t2Space_of_metrizableSpace @[simps! (config := { simpRhs := true }) apply symm_apply_re symm_apply_im] def equivRealProdCLM : β„‚ ≃L[ℝ] ℝ Γ— ℝ := equivRealProdLm.toContinuousLinearEquivOfBounds 1 (√2) equivRealProd_apply_le' fun p => abs_le_sqrt_two_mul_max (equivRealProd.symm p) #align complex.equiv_real_prod_clm Complex.equivRealProdCLM theorem equivRealProdCLM_symm_apply (p : ℝ Γ— ℝ) : Complex.equivRealProdCLM.symm p = p.1 + p.2 * Complex.I := Complex.equivRealProd_symm_apply p instance : ProperSpace β„‚ := (id lipschitz_equivRealProd : LipschitzWith 1 equivRealProdCLM.toHomeomorph).properSpace theorem tendsto_abs_cocompact_atTop : Tendsto abs (cocompact β„‚) atTop := tendsto_norm_cocompact_atTop #align complex.tendsto_abs_cocompact_at_top Complex.tendsto_abs_cocompact_atTop theorem tendsto_normSq_cocompact_atTop : Tendsto normSq (cocompact β„‚) atTop := by simpa [mul_self_abs] using tendsto_abs_cocompact_atTop.atTop_mul_atTop tendsto_abs_cocompact_atTop #align complex.tendsto_norm_sq_cocompact_at_top Complex.tendsto_normSq_cocompact_atTop open ContinuousLinearMap def reCLM : β„‚ β†’L[ℝ] ℝ := reLm.mkContinuous 1 fun x => by simp [abs_re_le_abs] #align complex.re_clm Complex.reCLM @[continuity, fun_prop] theorem continuous_re : Continuous re := reCLM.continuous #align complex.continuous_re Complex.continuous_re @[simp] theorem reCLM_coe : (reCLM : β„‚ β†’β‚—[ℝ] ℝ) = reLm := rfl #align complex.re_clm_coe Complex.reCLM_coe @[simp] theorem reCLM_apply (z : β„‚) : (reCLM : β„‚ β†’ ℝ) z = z.re := rfl #align complex.re_clm_apply Complex.reCLM_apply def imCLM : β„‚ β†’L[ℝ] ℝ := imLm.mkContinuous 1 fun x => by simp [abs_im_le_abs] #align complex.im_clm Complex.imCLM @[continuity, fun_prop] theorem continuous_im : Continuous im := imCLM.continuous #align complex.continuous_im Complex.continuous_im @[simp] theorem imCLM_coe : (imCLM : β„‚ β†’β‚—[ℝ] ℝ) = imLm := rfl #align complex.im_clm_coe Complex.imCLM_coe @[simp] theorem imCLM_apply (z : β„‚) : (imCLM : β„‚ β†’ ℝ) z = z.im := rfl #align complex.im_clm_apply Complex.imCLM_apply
Mathlib/Analysis/Complex/Basic.lean
309
313
theorem restrictScalars_one_smulRight' (x : E) : ContinuousLinearMap.restrictScalars ℝ ((1 : β„‚ β†’L[β„‚] β„‚).smulRight x : β„‚ β†’L[β„‚] E) = reCLM.smulRight x + I β€’ imCLM.smulRight x := by
ext ⟨a, b⟩ simp [mk_eq_add_mul_I, mul_smul, smul_comm I b x]
import Mathlib.Data.Int.Bitwise import Mathlib.LinearAlgebra.Matrix.NonsingularInverse import Mathlib.LinearAlgebra.Matrix.Symmetric #align_import linear_algebra.matrix.zpow from "leanprover-community/mathlib"@"03fda9112aa6708947da13944a19310684bfdfcb" open Matrix namespace Matrix variable {n' : Type*} [DecidableEq n'] [Fintype n'] {R : Type*} [CommRing R] local notation "M" => Matrix n' n' R noncomputable instance : DivInvMonoid M := { show Monoid M by infer_instance, show Inv M by infer_instance with } section ZPow open Int @[simp] theorem one_zpow : βˆ€ n : β„€, (1 : M) ^ n = 1 | (n : β„•) => by rw [zpow_natCast, one_pow] | -[n+1] => by rw [zpow_negSucc, one_pow, inv_one] #align matrix.one_zpow Matrix.one_zpow theorem zero_zpow : βˆ€ z : β„€, z β‰  0 β†’ (0 : M) ^ z = 0 | (n : β„•), h => by rw [zpow_natCast, zero_pow] exact mod_cast h | -[n+1], _ => by simp [zero_pow n.succ_ne_zero] #align matrix.zero_zpow Matrix.zero_zpow theorem zero_zpow_eq (n : β„€) : (0 : M) ^ n = if n = 0 then 1 else 0 := by split_ifs with h Β· rw [h, zpow_zero] Β· rw [zero_zpow _ h] #align matrix.zero_zpow_eq Matrix.zero_zpow_eq theorem inv_zpow (A : M) : βˆ€ n : β„€, A⁻¹ ^ n = (A ^ n)⁻¹ | (n : β„•) => by rw [zpow_natCast, zpow_natCast, inv_pow'] | -[n+1] => by rw [zpow_negSucc, zpow_negSucc, inv_pow'] #align matrix.inv_zpow Matrix.inv_zpow @[simp] theorem zpow_neg_one (A : M) : A ^ (-1 : β„€) = A⁻¹ := by convert DivInvMonoid.zpow_neg' 0 A simp only [zpow_one, Int.ofNat_zero, Int.ofNat_succ, zpow_eq_pow, zero_add] #align matrix.zpow_neg_one Matrix.zpow_neg_one #align matrix.zpow_coe_nat zpow_natCast @[simp] theorem zpow_neg_natCast (A : M) (n : β„•) : A ^ (-n : β„€) = (A ^ n)⁻¹ := by cases n Β· simp Β· exact DivInvMonoid.zpow_neg' _ _ #align matrix.zpow_neg_coe_nat Matrix.zpow_neg_natCast @[deprecated (since := "2024-04-05")] alias zpow_neg_coe_nat := zpow_neg_natCast theorem _root_.IsUnit.det_zpow {A : M} (h : IsUnit A.det) (n : β„€) : IsUnit (A ^ n).det := by cases' n with n n Β· simpa using h.pow n Β· simpa using h.pow n.succ #align is_unit.det_zpow IsUnit.det_zpow theorem isUnit_det_zpow_iff {A : M} {z : β„€} : IsUnit (A ^ z).det ↔ IsUnit A.det ∨ z = 0 := by induction' z using Int.induction_on with z _ z _ Β· simp Β· rw [← Int.ofNat_succ, zpow_natCast, det_pow, isUnit_pow_succ_iff, ← Int.ofNat_zero, Int.ofNat_inj] simp Β· rw [← neg_add', ← Int.ofNat_succ, zpow_neg_natCast, isUnit_nonsing_inv_det_iff, det_pow, isUnit_pow_succ_iff, neg_eq_zero, ← Int.ofNat_zero, Int.ofNat_inj] simp #align matrix.is_unit_det_zpow_iff Matrix.isUnit_det_zpow_iff theorem zpow_neg {A : M} (h : IsUnit A.det) : βˆ€ n : β„€, A ^ (-n) = (A ^ n)⁻¹ | (n : β„•) => zpow_neg_natCast _ _ | -[n+1] => by rw [zpow_negSucc, neg_negSucc, zpow_natCast, nonsing_inv_nonsing_inv] rw [det_pow] exact h.pow _ #align matrix.zpow_neg Matrix.zpow_neg theorem inv_zpow' {A : M} (h : IsUnit A.det) (n : β„€) : A⁻¹ ^ n = A ^ (-n) := by rw [zpow_neg h, inv_zpow] #align matrix.inv_zpow' Matrix.inv_zpow' theorem zpow_add_one {A : M} (h : IsUnit A.det) : βˆ€ n : β„€, A ^ (n + 1) = A ^ n * A | (n : β„•) => by simp only [← Nat.cast_succ, pow_succ, zpow_natCast] | -[n+1] => calc A ^ (-(n + 1) + 1 : β„€) = (A ^ n)⁻¹ := by rw [neg_add, neg_add_cancel_right, zpow_neg h, zpow_natCast] _ = (A * A ^ n)⁻¹ * A := by rw [mul_inv_rev, Matrix.mul_assoc, nonsing_inv_mul _ h, Matrix.mul_one] _ = A ^ (-(n + 1 : β„€)) * A := by rw [zpow_neg h, ← Int.ofNat_succ, zpow_natCast, pow_succ'] #align matrix.zpow_add_one Matrix.zpow_add_one theorem zpow_sub_one {A : M} (h : IsUnit A.det) (n : β„€) : A ^ (n - 1) = A ^ n * A⁻¹ := calc A ^ (n - 1) = A ^ (n - 1) * A * A⁻¹ := by rw [mul_assoc, mul_nonsing_inv _ h, mul_one] _ = A ^ n * A⁻¹ := by rw [← zpow_add_one h, sub_add_cancel] #align matrix.zpow_sub_one Matrix.zpow_sub_one theorem zpow_add {A : M} (ha : IsUnit A.det) (m n : β„€) : A ^ (m + n) = A ^ m * A ^ n := by induction n using Int.induction_on with | hz => simp | hp n ihn => simp only [← add_assoc, zpow_add_one ha, ihn, mul_assoc] | hn n ihn => rw [zpow_sub_one ha, ← mul_assoc, ← ihn, ← zpow_sub_one ha, add_sub_assoc] #align matrix.zpow_add Matrix.zpow_add theorem zpow_add_of_nonpos {A : M} {m n : β„€} (hm : m ≀ 0) (hn : n ≀ 0) : A ^ (m + n) = A ^ m * A ^ n := by rcases nonsing_inv_cancel_or_zero A with (⟨h, _⟩ | h) Β· exact zpow_add (isUnit_det_of_left_inverse h) m n Β· obtain ⟨k, rfl⟩ := exists_eq_neg_ofNat hm obtain ⟨l, rfl⟩ := exists_eq_neg_ofNat hn simp_rw [← neg_add, ← Int.ofNat_add, zpow_neg_natCast, ← inv_pow', h, pow_add] #align matrix.zpow_add_of_nonpos Matrix.zpow_add_of_nonpos theorem zpow_add_of_nonneg {A : M} {m n : β„€} (hm : 0 ≀ m) (hn : 0 ≀ n) : A ^ (m + n) = A ^ m * A ^ n := by obtain ⟨k, rfl⟩ := eq_ofNat_of_zero_le hm obtain ⟨l, rfl⟩ := eq_ofNat_of_zero_le hn rw [← Int.ofNat_add, zpow_natCast, zpow_natCast, zpow_natCast, pow_add] #align matrix.zpow_add_of_nonneg Matrix.zpow_add_of_nonneg theorem zpow_one_add {A : M} (h : IsUnit A.det) (i : β„€) : A ^ (1 + i) = A * A ^ i := by rw [zpow_add h, zpow_one] #align matrix.zpow_one_add Matrix.zpow_one_add theorem SemiconjBy.zpow_right {A X Y : M} (hx : IsUnit X.det) (hy : IsUnit Y.det) (h : SemiconjBy A X Y) : βˆ€ m : β„€, SemiconjBy A (X ^ m) (Y ^ m) | (n : β„•) => by simp [h.pow_right n] | -[n+1] => by have hx' : IsUnit (X ^ n.succ).det := by rw [det_pow] exact hx.pow n.succ have hy' : IsUnit (Y ^ n.succ).det := by rw [det_pow] exact hy.pow n.succ rw [zpow_negSucc, zpow_negSucc, nonsing_inv_apply _ hx', nonsing_inv_apply _ hy', SemiconjBy] refine (isRegular_of_isLeftRegular_det hy'.isRegular.left).left ?_ dsimp only rw [← mul_assoc, ← (h.pow_right n.succ).eq, mul_assoc, mul_smul, mul_adjugate, ← Matrix.mul_assoc, mul_smul (Y ^ _) (↑hy'.unit⁻¹ : R), mul_adjugate, smul_smul, smul_smul, hx'.val_inv_mul, hy'.val_inv_mul, one_smul, Matrix.mul_one, Matrix.one_mul] #align matrix.semiconj_by.zpow_right Matrix.SemiconjBy.zpow_right theorem Commute.zpow_right {A B : M} (h : Commute A B) (m : β„€) : Commute A (B ^ m) := by rcases nonsing_inv_cancel_or_zero B with (⟨hB, _⟩ | hB) Β· refine SemiconjBy.zpow_right ?_ ?_ h _ <;> exact isUnit_det_of_left_inverse hB Β· cases m Β· simpa using h.pow_right _ Β· simp [← inv_pow', hB] #align matrix.commute.zpow_right Matrix.Commute.zpow_right theorem Commute.zpow_left {A B : M} (h : Commute A B) (m : β„€) : Commute (A ^ m) B := (Commute.zpow_right h.symm m).symm #align matrix.commute.zpow_left Matrix.Commute.zpow_left theorem Commute.zpow_zpow {A B : M} (h : Commute A B) (m n : β„€) : Commute (A ^ m) (B ^ n) := Commute.zpow_right (Commute.zpow_left h _) _ #align matrix.commute.zpow_zpow Matrix.Commute.zpow_zpow theorem Commute.zpow_self (A : M) (n : β„€) : Commute (A ^ n) A := Commute.zpow_left (Commute.refl A) _ #align matrix.commute.zpow_self Matrix.Commute.zpow_self theorem Commute.self_zpow (A : M) (n : β„€) : Commute A (A ^ n) := Commute.zpow_right (Commute.refl A) _ #align matrix.commute.self_zpow Matrix.Commute.self_zpow theorem Commute.zpow_zpow_self (A : M) (m n : β„€) : Commute (A ^ m) (A ^ n) := Commute.zpow_zpow (Commute.refl A) _ _ #align matrix.commute.zpow_zpow_self Matrix.Commute.zpow_zpow_self set_option linter.deprecated false in theorem zpow_bit0 (A : M) (n : β„€) : A ^ bit0 n = A ^ n * A ^ n := by rcases le_total 0 n with nonneg | nonpos Β· exact zpow_add_of_nonneg nonneg nonneg Β· exact zpow_add_of_nonpos nonpos nonpos #align matrix.zpow_bit0 Matrix.zpow_bit0 theorem zpow_add_one_of_ne_neg_one {A : M} : βˆ€ n : β„€, n β‰  -1 β†’ A ^ (n + 1) = A ^ n * A | (n : β„•), _ => by simp only [pow_succ, ← Nat.cast_succ, zpow_natCast] | -1, h => absurd rfl h | -((n : β„•) + 2), _ => by rcases nonsing_inv_cancel_or_zero A with (⟨h, _⟩ | h) Β· apply zpow_add_one (isUnit_det_of_left_inverse h) Β· show A ^ (-((n + 1 : β„•) : β„€)) = A ^ (-((n + 2 : β„•) : β„€)) * A simp_rw [zpow_neg_natCast, ← inv_pow', h, zero_pow $ Nat.succ_ne_zero _, zero_mul] #align matrix.zpow_add_one_of_ne_neg_one Matrix.zpow_add_one_of_ne_neg_one set_option linter.deprecated false in theorem zpow_bit1 (A : M) (n : β„€) : A ^ bit1 n = A ^ n * A ^ n * A := by rw [bit1, zpow_add_one_of_ne_neg_one, zpow_bit0] intro h simpa using congr_arg bodd h #align matrix.zpow_bit1 Matrix.zpow_bit1 theorem zpow_mul (A : M) (h : IsUnit A.det) : βˆ€ m n : β„€, A ^ (m * n) = (A ^ m) ^ n | (m : β„•), (n : β„•) => by rw [zpow_natCast, zpow_natCast, ← pow_mul, ← zpow_natCast, Int.ofNat_mul] | (m : β„•), -[n+1] => by rw [zpow_natCast, zpow_negSucc, ← pow_mul, ofNat_mul_negSucc, zpow_neg_natCast] | -[m+1], (n : β„•) => by rw [zpow_natCast, zpow_negSucc, ← inv_pow', ← pow_mul, negSucc_mul_ofNat, zpow_neg_natCast, inv_pow'] | -[m+1], -[n+1] => by rw [zpow_negSucc, zpow_negSucc, negSucc_mul_negSucc, ← Int.ofNat_mul, zpow_natCast, inv_pow', ← pow_mul, nonsing_inv_nonsing_inv] rw [det_pow] exact h.pow _ #align matrix.zpow_mul Matrix.zpow_mul theorem zpow_mul' (A : M) (h : IsUnit A.det) (m n : β„€) : A ^ (m * n) = (A ^ n) ^ m := by rw [mul_comm, zpow_mul _ h] #align matrix.zpow_mul' Matrix.zpow_mul' @[simp, norm_cast] theorem coe_units_zpow (u : MΛ£) : βˆ€ n : β„€, ((u ^ n : MΛ£) : M) = (u : M) ^ n | (n : β„•) => by rw [zpow_natCast, zpow_natCast, Units.val_pow_eq_pow_val] | -[k+1] => by rw [zpow_negSucc, zpow_negSucc, ← inv_pow, u⁻¹.val_pow_eq_pow_val, ← inv_pow', coe_units_inv] #align matrix.coe_units_zpow Matrix.coe_units_zpow theorem zpow_ne_zero_of_isUnit_det [Nonempty n'] [Nontrivial R] {A : M} (ha : IsUnit A.det) (z : β„€) : A ^ z β‰  0 := by have := ha.det_zpow z contrapose! this rw [this, det_zero β€Ή_β€Ί] exact not_isUnit_zero #align matrix.zpow_ne_zero_of_is_unit_det Matrix.zpow_ne_zero_of_isUnit_det theorem zpow_sub {A : M} (ha : IsUnit A.det) (z1 z2 : β„€) : A ^ (z1 - z2) = A ^ z1 / A ^ z2 := by rw [sub_eq_add_neg, zpow_add ha, zpow_neg ha, div_eq_mul_inv] #align matrix.zpow_sub Matrix.zpow_sub theorem Commute.mul_zpow {A B : M} (h : Commute A B) : βˆ€ i : β„€, (A * B) ^ i = A ^ i * B ^ i | (n : β„•) => by simp [h.mul_pow n] | -[n+1] => by rw [zpow_negSucc, zpow_negSucc, zpow_negSucc, ← mul_inv_rev, h.mul_pow n.succ, (h.pow_pow _ _).eq] #align matrix.commute.mul_zpow Matrix.Commute.mul_zpow set_option linter.deprecated false in theorem zpow_bit0' (A : M) (n : β„€) : A ^ bit0 n = (A * A) ^ n := (zpow_bit0 A n).trans (Commute.mul_zpow (Commute.refl A) n).symm #align matrix.zpow_bit0' Matrix.zpow_bit0' set_option linter.deprecated false in theorem zpow_bit1' (A : M) (n : β„€) : A ^ bit1 n = (A * A) ^ n * A := by rw [zpow_bit1, Commute.mul_zpow (Commute.refl A)] #align matrix.zpow_bit1' Matrix.zpow_bit1' theorem zpow_neg_mul_zpow_self (n : β„€) {A : M} (h : IsUnit A.det) : A ^ (-n) * A ^ n = 1 := by rw [zpow_neg h, nonsing_inv_mul _ (h.det_zpow _)] #align matrix.zpow_neg_mul_zpow_self Matrix.zpow_neg_mul_zpow_self
Mathlib/LinearAlgebra/Matrix/ZPow.lean
325
325
theorem one_div_pow {A : M} (n : β„•) : (1 / A) ^ n = 1 / A ^ n := by
simp only [one_div, inv_pow']
import Mathlib.Data.Option.NAry import Mathlib.Data.Seq.Computation #align_import data.seq.seq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" namespace Stream' universe u v w def IsSeq {Ξ± : Type u} (s : Stream' (Option Ξ±)) : Prop := βˆ€ {n : β„•}, s n = none β†’ s (n + 1) = none #align stream.is_seq Stream'.IsSeq def Seq (Ξ± : Type u) : Type u := { f : Stream' (Option Ξ±) // f.IsSeq } #align stream.seq Stream'.Seq def Seq1 (Ξ±) := Ξ± Γ— Seq Ξ± #align stream.seq1 Stream'.Seq1 namespace Seq variable {Ξ± : Type u} {Ξ² : Type v} {Ξ³ : Type w} def nil : Seq Ξ± := ⟨Stream'.const none, fun {_} _ => rfl⟩ #align stream.seq.nil Stream'.Seq.nil instance : Inhabited (Seq Ξ±) := ⟨nil⟩ def cons (a : Ξ±) (s : Seq Ξ±) : Seq Ξ± := ⟨some a::s.1, by rintro (n | _) h Β· contradiction Β· exact s.2 h⟩ #align stream.seq.cons Stream'.Seq.cons @[simp] theorem val_cons (s : Seq Ξ±) (x : Ξ±) : (cons x s).val = some x::s.val := rfl #align stream.seq.val_cons Stream'.Seq.val_cons def get? : Seq Ξ± β†’ β„• β†’ Option Ξ± := Subtype.val #align stream.seq.nth Stream'.Seq.get? @[simp] theorem get?_mk (f hf) : @get? Ξ± ⟨f, hf⟩ = f := rfl #align stream.seq.nth_mk Stream'.Seq.get?_mk @[simp] theorem get?_nil (n : β„•) : (@nil Ξ±).get? n = none := rfl #align stream.seq.nth_nil Stream'.Seq.get?_nil @[simp] theorem get?_cons_zero (a : Ξ±) (s : Seq Ξ±) : (cons a s).get? 0 = some a := rfl #align stream.seq.nth_cons_zero Stream'.Seq.get?_cons_zero @[simp] theorem get?_cons_succ (a : Ξ±) (s : Seq Ξ±) (n : β„•) : (cons a s).get? (n + 1) = s.get? n := rfl #align stream.seq.nth_cons_succ Stream'.Seq.get?_cons_succ @[ext] protected theorem ext {s t : Seq Ξ±} (h : βˆ€ n : β„•, s.get? n = t.get? n) : s = t := Subtype.eq <| funext h #align stream.seq.ext Stream'.Seq.ext theorem cons_injective2 : Function.Injective2 (cons : Ξ± β†’ Seq Ξ± β†’ Seq Ξ±) := fun x y s t h => ⟨by rw [← Option.some_inj, ← get?_cons_zero, h, get?_cons_zero], Seq.ext fun n => by simp_rw [← get?_cons_succ x s n, h, get?_cons_succ]⟩ #align stream.seq.cons_injective2 Stream'.Seq.cons_injective2 theorem cons_left_injective (s : Seq Ξ±) : Function.Injective fun x => cons x s := cons_injective2.left _ #align stream.seq.cons_left_injective Stream'.Seq.cons_left_injective theorem cons_right_injective (x : Ξ±) : Function.Injective (cons x) := cons_injective2.right _ #align stream.seq.cons_right_injective Stream'.Seq.cons_right_injective def TerminatedAt (s : Seq Ξ±) (n : β„•) : Prop := s.get? n = none #align stream.seq.terminated_at Stream'.Seq.TerminatedAt instance terminatedAtDecidable (s : Seq Ξ±) (n : β„•) : Decidable (s.TerminatedAt n) := decidable_of_iff' (s.get? n).isNone <| by unfold TerminatedAt; cases s.get? n <;> simp #align stream.seq.terminated_at_decidable Stream'.Seq.terminatedAtDecidable def Terminates (s : Seq Ξ±) : Prop := βˆƒ n : β„•, s.TerminatedAt n #align stream.seq.terminates Stream'.Seq.Terminates theorem not_terminates_iff {s : Seq Ξ±} : Β¬s.Terminates ↔ βˆ€ n, (s.get? n).isSome := by simp only [Terminates, TerminatedAt, ← Ne.eq_def, Option.ne_none_iff_isSome, not_exists, iff_self] #align stream.seq.not_terminates_iff Stream'.Seq.not_terminates_iff @[simp] def omap (f : Ξ² β†’ Ξ³) : Option (Ξ± Γ— Ξ²) β†’ Option (Ξ± Γ— Ξ³) | none => none | some (a, b) => some (a, f b) #align stream.seq.omap Stream'.Seq.omap def head (s : Seq Ξ±) : Option Ξ± := get? s 0 #align stream.seq.head Stream'.Seq.head def tail (s : Seq Ξ±) : Seq Ξ± := ⟨s.1.tail, fun n' => by cases' s with f al exact al n'⟩ #align stream.seq.tail Stream'.Seq.tail protected def Mem (a : Ξ±) (s : Seq Ξ±) := some a ∈ s.1 #align stream.seq.mem Stream'.Seq.Mem instance : Membership Ξ± (Seq Ξ±) := ⟨Seq.Mem⟩ theorem le_stable (s : Seq Ξ±) {m n} (h : m ≀ n) : s.get? m = none β†’ s.get? n = none := by cases' s with f al induction' h with n _ IH exacts [id, fun h2 => al (IH h2)] #align stream.seq.le_stable Stream'.Seq.le_stable theorem terminated_stable : βˆ€ (s : Seq Ξ±) {m n : β„•}, m ≀ n β†’ s.TerminatedAt m β†’ s.TerminatedAt n := le_stable #align stream.seq.terminated_stable Stream'.Seq.terminated_stable
Mathlib/Data/Seq/Seq.lean
174
178
theorem ge_stable (s : Seq Ξ±) {aβ‚™ : Ξ±} {n m : β„•} (m_le_n : m ≀ n) (s_nth_eq_some : s.get? n = some aβ‚™) : βˆƒ aβ‚˜ : Ξ±, s.get? m = some aβ‚˜ := have : s.get? n β‰  none := by
simp [s_nth_eq_some] have : s.get? m β‰  none := mt (s.le_stable m_le_n) this Option.ne_none_iff_exists'.mp this
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] theorem interior_compl : interior sᢜ = (closure s)ᢜ := by simp [closure_eq_compl_interior_compl] #align interior_compl interior_compl @[simp] theorem closure_compl : closure sᢜ = (interior s)ᢜ := by simp [closure_eq_compl_interior_compl] #align closure_compl closure_compl theorem mem_closure_iff : x ∈ closure s ↔ βˆ€ o, IsOpen o β†’ x ∈ o β†’ (o ∩ s).Nonempty := ⟨fun h o oo ao => by_contradiction fun os => have : s βŠ† oᢜ := fun x xs xo => os ⟨x, xo, xs⟩ closure_minimal this (isClosed_compl_iff.2 oo) h ao, fun H _ ⟨h₁, hβ‚‚βŸ© => by_contradiction fun nc => let ⟨_, hc, hs⟩ := H _ h₁.isOpen_compl nc hc (hβ‚‚ hs)⟩ #align mem_closure_iff mem_closure_iff theorem closure_inter_open_nonempty_iff (h : IsOpen t) : (closure s ∩ t).Nonempty ↔ (s ∩ t).Nonempty := ⟨fun ⟨_x, hxcs, hxt⟩ => inter_comm t s β–Έ mem_closure_iff.1 hxcs t h hxt, fun h => h.mono <| inf_le_inf_right t subset_closure⟩ #align closure_inter_open_nonempty_iff closure_inter_open_nonempty_iff theorem Filter.le_lift'_closure (l : Filter X) : l ≀ l.lift' closure := le_lift'.2 fun _ h => mem_of_superset h subset_closure #align filter.le_lift'_closure Filter.le_lift'_closure theorem Filter.HasBasis.lift'_closure {l : Filter X} {p : ΞΉ β†’ Prop} {s : ΞΉ β†’ Set X} (h : l.HasBasis p s) : (l.lift' closure).HasBasis p fun i => closure (s i) := h.lift' (monotone_closure X) #align filter.has_basis.lift'_closure Filter.HasBasis.lift'_closure theorem Filter.HasBasis.lift'_closure_eq_self {l : Filter X} {p : ΞΉ β†’ Prop} {s : ΞΉ β†’ Set X} (h : l.HasBasis p s) (hc : βˆ€ i, p i β†’ IsClosed (s i)) : l.lift' closure = l := le_antisymm (h.ge_iff.2 fun i hi => (hc i hi).closure_eq β–Έ mem_lift' (h.mem_of_mem hi)) l.le_lift'_closure #align filter.has_basis.lift'_closure_eq_self Filter.HasBasis.lift'_closure_eq_self @[simp] theorem Filter.lift'_closure_eq_bot {l : Filter X} : l.lift' closure = βŠ₯ ↔ l = βŠ₯ := ⟨fun h => bot_unique <| h β–Έ l.le_lift'_closure, fun h => h.symm β–Έ by rw [lift'_bot (monotone_closure _), closure_empty, principal_empty]⟩ #align filter.lift'_closure_eq_bot Filter.lift'_closure_eq_bot theorem dense_iff_closure_eq : Dense s ↔ closure s = univ := eq_univ_iff_forall.symm #align dense_iff_closure_eq dense_iff_closure_eq alias ⟨Dense.closure_eq, _⟩ := dense_iff_closure_eq #align dense.closure_eq Dense.closure_eq theorem interior_eq_empty_iff_dense_compl : interior s = βˆ… ↔ Dense sᢜ := by rw [dense_iff_closure_eq, closure_compl, compl_univ_iff] #align interior_eq_empty_iff_dense_compl interior_eq_empty_iff_dense_compl theorem Dense.interior_compl (h : Dense s) : interior sᢜ = βˆ… := interior_eq_empty_iff_dense_compl.2 <| by rwa [compl_compl] #align dense.interior_compl Dense.interior_compl @[simp] theorem dense_closure : Dense (closure s) ↔ Dense s := by rw [Dense, Dense, closure_closure] #align dense_closure dense_closure protected alias ⟨_, Dense.closure⟩ := dense_closure alias ⟨Dense.of_closure, _⟩ := dense_closure #align dense.of_closure Dense.of_closure #align dense.closure Dense.closure @[simp] theorem dense_univ : Dense (univ : Set X) := fun _ => subset_closure trivial #align dense_univ dense_univ theorem dense_iff_inter_open : Dense s ↔ βˆ€ U, IsOpen U β†’ U.Nonempty β†’ (U ∩ s).Nonempty := by constructor <;> intro h Β· rintro U U_op ⟨x, x_in⟩ exact mem_closure_iff.1 (h _) U U_op x_in Β· intro x rw [mem_closure_iff] intro U U_op x_in exact h U U_op ⟨_, x_in⟩ #align dense_iff_inter_open dense_iff_inter_open alias ⟨Dense.inter_open_nonempty, _⟩ := dense_iff_inter_open #align dense.inter_open_nonempty Dense.inter_open_nonempty theorem Dense.exists_mem_open (hs : Dense s) {U : Set X} (ho : IsOpen U) (hne : U.Nonempty) : βˆƒ x ∈ s, x ∈ U := let ⟨x, hx⟩ := hs.inter_open_nonempty U ho hne ⟨x, hx.2, hx.1⟩ #align dense.exists_mem_open Dense.exists_mem_open theorem Dense.nonempty_iff (hs : Dense s) : s.Nonempty ↔ Nonempty X := ⟨fun ⟨x, _⟩ => ⟨x⟩, fun ⟨x⟩ => let ⟨y, hy⟩ := hs.inter_open_nonempty _ isOpen_univ ⟨x, trivial⟩ ⟨y, hy.2⟩⟩ #align dense.nonempty_iff Dense.nonempty_iff theorem Dense.nonempty [h : Nonempty X] (hs : Dense s) : s.Nonempty := hs.nonempty_iff.2 h #align dense.nonempty Dense.nonempty @[mono] theorem Dense.mono (h : s₁ βŠ† sβ‚‚) (hd : Dense s₁) : Dense sβ‚‚ := fun x => closure_mono h (hd x) #align dense.mono Dense.mono theorem dense_compl_singleton_iff_not_open : Dense ({x}ᢜ : Set X) ↔ Β¬IsOpen ({x} : Set X) := by constructor Β· intro hd ho exact (hd.inter_open_nonempty _ ho (singleton_nonempty _)).ne_empty (inter_compl_self _) Β· refine fun ho => dense_iff_inter_open.2 fun U hU hne => inter_compl_nonempty_iff.2 fun hUx => ?_ obtain rfl : U = {x} := eq_singleton_iff_nonempty_unique_mem.2 ⟨hne, hUx⟩ exact ho hU #align dense_compl_singleton_iff_not_open dense_compl_singleton_iff_not_open @[simp] theorem closure_diff_interior (s : Set X) : closure s \ interior s = frontier s := rfl #align closure_diff_interior closure_diff_interior lemma disjoint_interior_frontier : Disjoint (interior s) (frontier s) := by rw [disjoint_iff_inter_eq_empty, ← closure_diff_interior, diff_eq, ← inter_assoc, inter_comm, ← inter_assoc, compl_inter_self, empty_inter] @[simp] theorem closure_diff_frontier (s : Set X) : closure s \ frontier s = interior s := by rw [frontier, diff_diff_right_self, inter_eq_self_of_subset_right interior_subset_closure] #align closure_diff_frontier closure_diff_frontier @[simp] theorem self_diff_frontier (s : Set X) : s \ frontier s = interior s := by rw [frontier, diff_diff_right, diff_eq_empty.2 subset_closure, inter_eq_self_of_subset_right interior_subset, empty_union] #align self_diff_frontier self_diff_frontier theorem frontier_eq_closure_inter_closure : frontier s = closure s ∩ closure sᢜ := by rw [closure_compl, frontier, diff_eq] #align frontier_eq_closure_inter_closure frontier_eq_closure_inter_closure theorem frontier_subset_closure : frontier s βŠ† closure s := diff_subset #align frontier_subset_closure frontier_subset_closure theorem IsClosed.frontier_subset (hs : IsClosed s) : frontier s βŠ† s := frontier_subset_closure.trans hs.closure_eq.subset #align is_closed.frontier_subset IsClosed.frontier_subset theorem frontier_closure_subset : frontier (closure s) βŠ† frontier s := diff_subset_diff closure_closure.subset <| interior_mono subset_closure #align frontier_closure_subset frontier_closure_subset theorem frontier_interior_subset : frontier (interior s) βŠ† frontier s := diff_subset_diff (closure_mono interior_subset) interior_interior.symm.subset #align frontier_interior_subset frontier_interior_subset @[simp] theorem frontier_compl (s : Set X) : frontier sᢜ = frontier s := by simp only [frontier_eq_closure_inter_closure, compl_compl, inter_comm] #align frontier_compl frontier_compl @[simp] theorem frontier_univ : frontier (univ : Set X) = βˆ… := by simp [frontier] #align frontier_univ frontier_univ @[simp] theorem frontier_empty : frontier (βˆ… : Set X) = βˆ… := by simp [frontier] #align frontier_empty frontier_empty theorem frontier_inter_subset (s t : Set X) : frontier (s ∩ t) βŠ† frontier s ∩ closure t βˆͺ closure s ∩ frontier t := by simp only [frontier_eq_closure_inter_closure, compl_inter, closure_union] refine (inter_subset_inter_left _ (closure_inter_subset_inter_closure s t)).trans_eq ?_ simp only [inter_union_distrib_left, union_inter_distrib_right, inter_assoc, inter_comm (closure t)] #align frontier_inter_subset frontier_inter_subset theorem frontier_union_subset (s t : Set X) : frontier (s βˆͺ t) βŠ† frontier s ∩ closure tᢜ βˆͺ closure sᢜ ∩ frontier t := by simpa only [frontier_compl, ← compl_union] using frontier_inter_subset sᢜ tᢜ #align frontier_union_subset frontier_union_subset theorem IsClosed.frontier_eq (hs : IsClosed s) : frontier s = s \ interior s := by rw [frontier, hs.closure_eq] #align is_closed.frontier_eq IsClosed.frontier_eq theorem IsOpen.frontier_eq (hs : IsOpen s) : frontier s = closure s \ s := by rw [frontier, hs.interior_eq] #align is_open.frontier_eq IsOpen.frontier_eq theorem IsOpen.inter_frontier_eq (hs : IsOpen s) : s ∩ frontier s = βˆ… := by rw [hs.frontier_eq, inter_diff_self] #align is_open.inter_frontier_eq IsOpen.inter_frontier_eq theorem isClosed_frontier : IsClosed (frontier s) := by rw [frontier_eq_closure_inter_closure]; exact IsClosed.inter isClosed_closure isClosed_closure #align is_closed_frontier isClosed_frontier theorem interior_frontier (h : IsClosed s) : interior (frontier s) = βˆ… := by have A : frontier s = s \ interior s := h.frontier_eq have B : interior (frontier s) βŠ† interior s := by rw [A]; exact interior_mono diff_subset have C : interior (frontier s) βŠ† frontier s := interior_subset have : interior (frontier s) βŠ† interior s ∩ (s \ interior s) := subset_inter B (by simpa [A] using C) rwa [inter_diff_self, subset_empty_iff] at this #align interior_frontier interior_frontier theorem closure_eq_interior_union_frontier (s : Set X) : closure s = interior s βˆͺ frontier s := (union_diff_cancel interior_subset_closure).symm #align closure_eq_interior_union_frontier closure_eq_interior_union_frontier theorem closure_eq_self_union_frontier (s : Set X) : closure s = s βˆͺ frontier s := (union_diff_cancel' interior_subset subset_closure).symm #align closure_eq_self_union_frontier closure_eq_self_union_frontier theorem Disjoint.frontier_left (ht : IsOpen t) (hd : Disjoint s t) : Disjoint (frontier s) t := subset_compl_iff_disjoint_right.1 <| frontier_subset_closure.trans <| closure_minimal (disjoint_left.1 hd) <| isClosed_compl_iff.2 ht #align disjoint.frontier_left Disjoint.frontier_left theorem Disjoint.frontier_right (hs : IsOpen s) (hd : Disjoint s t) : Disjoint s (frontier t) := (hd.symm.frontier_left hs).symm #align disjoint.frontier_right Disjoint.frontier_right theorem frontier_eq_inter_compl_interior : frontier s = (interior s)ᢜ ∩ (interior sᢜ)ᢜ := by rw [← frontier_compl, ← closure_compl, ← diff_eq, closure_diff_interior] #align frontier_eq_inter_compl_interior frontier_eq_inter_compl_interior theorem compl_frontier_eq_union_interior : (frontier s)ᢜ = interior s βˆͺ interior sᢜ := by rw [frontier_eq_inter_compl_interior] simp only [compl_inter, compl_compl] #align compl_frontier_eq_union_interior compl_frontier_eq_union_interior theorem nhds_def' (x : X) : 𝓝 x = β¨… (s : Set X) (_ : IsOpen s) (_ : x ∈ s), π“Ÿ s := by simp only [nhds_def, mem_setOf_eq, @and_comm (x ∈ _), iInf_and] #align nhds_def' nhds_def' theorem nhds_basis_opens (x : X) : (𝓝 x).HasBasis (fun s : Set X => x ∈ s ∧ IsOpen s) fun s => s := by rw [nhds_def] exact hasBasis_biInf_principal (fun s ⟨has, hs⟩ t ⟨hat, ht⟩ => ⟨s ∩ t, ⟨⟨has, hat⟩, IsOpen.inter hs ht⟩, ⟨inter_subset_left, inter_subset_right⟩⟩) ⟨univ, ⟨mem_univ x, isOpen_univ⟩⟩ #align nhds_basis_opens nhds_basis_opens theorem nhds_basis_closeds (x : X) : (𝓝 x).HasBasis (fun s : Set X => x βˆ‰ s ∧ IsClosed s) compl := ⟨fun t => (nhds_basis_opens x).mem_iff.trans <| compl_surjective.exists.trans <| by simp only [isOpen_compl_iff, mem_compl_iff]⟩ #align nhds_basis_closeds nhds_basis_closeds @[simp] theorem lift'_nhds_interior (x : X) : (𝓝 x).lift' interior = 𝓝 x := (nhds_basis_opens x).lift'_interior_eq_self fun _ ↦ And.right theorem Filter.HasBasis.nhds_interior {x : X} {p : ΞΉ β†’ Prop} {s : ΞΉ β†’ Set X} (h : (𝓝 x).HasBasis p s) : (𝓝 x).HasBasis p (interior <| s Β·) := lift'_nhds_interior x β–Έ h.lift'_interior theorem le_nhds_iff {f} : f ≀ 𝓝 x ↔ βˆ€ s : Set X, x ∈ s β†’ IsOpen s β†’ s ∈ f := by simp [nhds_def] #align le_nhds_iff le_nhds_iff theorem nhds_le_of_le {f} (h : x ∈ s) (o : IsOpen s) (sf : π“Ÿ s ≀ f) : 𝓝 x ≀ f := by rw [nhds_def]; exact iInfβ‚‚_le_of_le s ⟨h, o⟩ sf #align nhds_le_of_le nhds_le_of_le theorem mem_nhds_iff : s ∈ 𝓝 x ↔ βˆƒ t βŠ† s, IsOpen t ∧ x ∈ t := (nhds_basis_opens x).mem_iff.trans <| exists_congr fun _ => ⟨fun h => ⟨h.2, h.1.2, h.1.1⟩, fun h => ⟨⟨h.2.2, h.2.1⟩, h.1⟩⟩ #align mem_nhds_iff mem_nhds_iffβ‚“ theorem eventually_nhds_iff {p : X β†’ Prop} : (βˆ€αΆ  x in 𝓝 x, p x) ↔ βˆƒ t : Set X, (βˆ€ x ∈ t, p x) ∧ IsOpen t ∧ x ∈ t := mem_nhds_iff.trans <| by simp only [subset_def, exists_prop, mem_setOf_eq] #align eventually_nhds_iff eventually_nhds_iff theorem mem_interior_iff_mem_nhds : x ∈ interior s ↔ s ∈ 𝓝 x := mem_interior.trans mem_nhds_iff.symm #align mem_interior_iff_mem_nhds mem_interior_iff_mem_nhds theorem map_nhds {f : X β†’ Ξ±} : map f (𝓝 x) = β¨… s ∈ { s : Set X | x ∈ s ∧ IsOpen s }, π“Ÿ (f '' s) := ((nhds_basis_opens x).map f).eq_biInf #align map_nhds map_nhds theorem mem_of_mem_nhds : s ∈ 𝓝 x β†’ x ∈ s := fun H => let ⟨_t, ht, _, hs⟩ := mem_nhds_iff.1 H; ht hs #align mem_of_mem_nhds mem_of_mem_nhds theorem Filter.Eventually.self_of_nhds {p : X β†’ Prop} (h : βˆ€αΆ  y in 𝓝 x, p y) : p x := mem_of_mem_nhds h #align filter.eventually.self_of_nhds Filter.Eventually.self_of_nhds theorem IsOpen.mem_nhds (hs : IsOpen s) (hx : x ∈ s) : s ∈ 𝓝 x := mem_nhds_iff.2 ⟨s, Subset.refl _, hs, hx⟩ #align is_open.mem_nhds IsOpen.mem_nhds protected theorem IsOpen.mem_nhds_iff (hs : IsOpen s) : s ∈ 𝓝 x ↔ x ∈ s := ⟨mem_of_mem_nhds, fun hx => mem_nhds_iff.2 ⟨s, Subset.rfl, hs, hx⟩⟩ #align is_open.mem_nhds_iff IsOpen.mem_nhds_iff theorem IsClosed.compl_mem_nhds (hs : IsClosed s) (hx : x βˆ‰ s) : sᢜ ∈ 𝓝 x := hs.isOpen_compl.mem_nhds (mem_compl hx) #align is_closed.compl_mem_nhds IsClosed.compl_mem_nhds theorem IsOpen.eventually_mem (hs : IsOpen s) (hx : x ∈ s) : βˆ€αΆ  x in 𝓝 x, x ∈ s := IsOpen.mem_nhds hs hx #align is_open.eventually_mem IsOpen.eventually_mem theorem nhds_basis_opens' (x : X) : (𝓝 x).HasBasis (fun s : Set X => s ∈ 𝓝 x ∧ IsOpen s) fun x => x := by convert nhds_basis_opens x using 2 exact and_congr_left_iff.2 IsOpen.mem_nhds_iff #align nhds_basis_opens' nhds_basis_opens' theorem exists_open_set_nhds {U : Set X} (h : βˆ€ x ∈ s, U ∈ 𝓝 x) : βˆƒ V : Set X, s βŠ† V ∧ IsOpen V ∧ V βŠ† U := ⟨interior U, fun x hx => mem_interior_iff_mem_nhds.2 <| h x hx, isOpen_interior, interior_subset⟩ #align exists_open_set_nhds exists_open_set_nhds theorem exists_open_set_nhds' {U : Set X} (h : U ∈ ⨆ x ∈ s, 𝓝 x) : βˆƒ V : Set X, s βŠ† V ∧ IsOpen V ∧ V βŠ† U := exists_open_set_nhds (by simpa using h) #align exists_open_set_nhds' exists_open_set_nhds' theorem Filter.Eventually.eventually_nhds {p : X β†’ Prop} (h : βˆ€αΆ  y in 𝓝 x, p y) : βˆ€αΆ  y in 𝓝 x, βˆ€αΆ  x in 𝓝 y, p x := let ⟨t, htp, hto, ha⟩ := eventually_nhds_iff.1 h eventually_nhds_iff.2 ⟨t, fun _x hx => eventually_nhds_iff.2 ⟨t, htp, hto, hx⟩, hto, ha⟩ #align filter.eventually.eventually_nhds Filter.Eventually.eventually_nhds @[simp] theorem eventually_eventually_nhds {p : X β†’ Prop} : (βˆ€αΆ  y in 𝓝 x, βˆ€αΆ  x in 𝓝 y, p x) ↔ βˆ€αΆ  x in 𝓝 x, p x := ⟨fun h => h.self_of_nhds, fun h => h.eventually_nhds⟩ #align eventually_eventually_nhds eventually_eventually_nhds @[simp] theorem frequently_frequently_nhds {p : X β†’ Prop} : (βˆƒαΆ  x' in 𝓝 x, βˆƒαΆ  x'' in 𝓝 x', p x'') ↔ βˆƒαΆ  x in 𝓝 x, p x := by rw [← not_iff_not] simp only [not_frequently, eventually_eventually_nhds] #align frequently_frequently_nhds frequently_frequently_nhds @[simp] theorem eventually_mem_nhds : (βˆ€αΆ  x' in 𝓝 x, s ∈ 𝓝 x') ↔ s ∈ 𝓝 x := eventually_eventually_nhds #align eventually_mem_nhds eventually_mem_nhds @[simp] theorem nhds_bind_nhds : (𝓝 x).bind 𝓝 = 𝓝 x := Filter.ext fun _ => eventually_eventually_nhds #align nhds_bind_nhds nhds_bind_nhds @[simp] theorem eventually_eventuallyEq_nhds {f g : X β†’ Ξ±} : (βˆ€αΆ  y in 𝓝 x, f =αΆ [𝓝 y] g) ↔ f =αΆ [𝓝 x] g := eventually_eventually_nhds #align eventually_eventually_eq_nhds eventually_eventuallyEq_nhds theorem Filter.EventuallyEq.eq_of_nhds {f g : X β†’ Ξ±} (h : f =αΆ [𝓝 x] g) : f x = g x := h.self_of_nhds #align filter.eventually_eq.eq_of_nhds Filter.EventuallyEq.eq_of_nhds @[simp] theorem eventually_eventuallyLE_nhds [LE Ξ±] {f g : X β†’ Ξ±} : (βˆ€αΆ  y in 𝓝 x, f ≀ᢠ[𝓝 y] g) ↔ f ≀ᢠ[𝓝 x] g := eventually_eventually_nhds #align eventually_eventually_le_nhds eventually_eventuallyLE_nhds theorem Filter.EventuallyEq.eventuallyEq_nhds {f g : X β†’ Ξ±} (h : f =αΆ [𝓝 x] g) : βˆ€αΆ  y in 𝓝 x, f =αΆ [𝓝 y] g := h.eventually_nhds #align filter.eventually_eq.eventually_eq_nhds Filter.EventuallyEq.eventuallyEq_nhds theorem Filter.EventuallyLE.eventuallyLE_nhds [LE Ξ±] {f g : X β†’ Ξ±} (h : f ≀ᢠ[𝓝 x] g) : βˆ€αΆ  y in 𝓝 x, f ≀ᢠ[𝓝 y] g := h.eventually_nhds #align filter.eventually_le.eventually_le_nhds Filter.EventuallyLE.eventuallyLE_nhds theorem all_mem_nhds (x : X) (P : Set X β†’ Prop) (hP : βˆ€ s t, s βŠ† t β†’ P s β†’ P t) : (βˆ€ s ∈ 𝓝 x, P s) ↔ βˆ€ s, IsOpen s β†’ x ∈ s β†’ P s := ((nhds_basis_opens x).forall_iff hP).trans <| by simp only [@and_comm (x ∈ _), and_imp] #align all_mem_nhds all_mem_nhds theorem all_mem_nhds_filter (x : X) (f : Set X β†’ Set Ξ±) (hf : βˆ€ s t, s βŠ† t β†’ f s βŠ† f t) (l : Filter Ξ±) : (βˆ€ s ∈ 𝓝 x, f s ∈ l) ↔ βˆ€ s, IsOpen s β†’ x ∈ s β†’ f s ∈ l := all_mem_nhds _ _ fun s t ssubt h => mem_of_superset h (hf s t ssubt) #align all_mem_nhds_filter all_mem_nhds_filter theorem tendsto_nhds {f : Ξ± β†’ X} {l : Filter Ξ±} : Tendsto f l (𝓝 x) ↔ βˆ€ s, IsOpen s β†’ x ∈ s β†’ f ⁻¹' s ∈ l := all_mem_nhds_filter _ _ (fun _ _ h => preimage_mono h) _ #align tendsto_nhds tendsto_nhds theorem tendsto_atTop_nhds [Nonempty Ξ±] [SemilatticeSup Ξ±] {f : Ξ± β†’ X} : Tendsto f atTop (𝓝 x) ↔ βˆ€ U : Set X, x ∈ U β†’ IsOpen U β†’ βˆƒ N, βˆ€ n, N ≀ n β†’ f n ∈ U := (atTop_basis.tendsto_iff (nhds_basis_opens x)).trans <| by simp only [and_imp, exists_prop, true_and_iff, mem_Ici, ge_iff_le] #align tendsto_at_top_nhds tendsto_atTop_nhds theorem tendsto_const_nhds {f : Filter Ξ±} : Tendsto (fun _ : Ξ± => x) f (𝓝 x) := tendsto_nhds.mpr fun _ _ ha => univ_mem' fun _ => ha #align tendsto_const_nhds tendsto_const_nhds theorem tendsto_atTop_of_eventually_const {ΞΉ : Type*} [SemilatticeSup ΞΉ] [Nonempty ΞΉ] {u : ΞΉ β†’ X} {iβ‚€ : ΞΉ} (h : βˆ€ i β‰₯ iβ‚€, u i = x) : Tendsto u atTop (𝓝 x) := Tendsto.congr' (EventuallyEq.symm (eventually_atTop.mpr ⟨iβ‚€, h⟩)) tendsto_const_nhds #align tendsto_at_top_of_eventually_const tendsto_atTop_of_eventually_const theorem tendsto_atBot_of_eventually_const {ΞΉ : Type*} [SemilatticeInf ΞΉ] [Nonempty ΞΉ] {u : ΞΉ β†’ X} {iβ‚€ : ΞΉ} (h : βˆ€ i ≀ iβ‚€, u i = x) : Tendsto u atBot (𝓝 x) := Tendsto.congr' (EventuallyEq.symm (eventually_atBot.mpr ⟨iβ‚€, h⟩)) tendsto_const_nhds #align tendsto_at_bot_of_eventually_const tendsto_atBot_of_eventually_const theorem pure_le_nhds : pure ≀ (𝓝 : X β†’ Filter X) := fun _ _ hs => mem_pure.2 <| mem_of_mem_nhds hs #align pure_le_nhds pure_le_nhds theorem tendsto_pure_nhds (f : Ξ± β†’ X) (a : Ξ±) : Tendsto f (pure a) (𝓝 (f a)) := (tendsto_pure_pure f a).mono_right (pure_le_nhds _) #align tendsto_pure_nhds tendsto_pure_nhds theorem OrderTop.tendsto_atTop_nhds [PartialOrder Ξ±] [OrderTop Ξ±] (f : Ξ± β†’ X) : Tendsto f atTop (𝓝 (f ⊀)) := (tendsto_atTop_pure f).mono_right (pure_le_nhds _) #align order_top.tendsto_at_top_nhds OrderTop.tendsto_atTop_nhds @[simp] instance nhds_neBot : NeBot (𝓝 x) := neBot_of_le (pure_le_nhds x) #align nhds_ne_bot nhds_neBot theorem tendsto_nhds_of_eventually_eq {l : Filter Ξ±} {f : Ξ± β†’ X} (h : βˆ€αΆ  x' in l, f x' = x) : Tendsto f l (𝓝 x) := tendsto_const_nhds.congr' (.symm h) theorem Filter.EventuallyEq.tendsto {l : Filter Ξ±} {f : Ξ± β†’ X} (hf : f =αΆ [l] fun _ ↦ x) : Tendsto f l (𝓝 x) := tendsto_nhds_of_eventually_eq hf theorem ClusterPt.neBot {F : Filter X} (h : ClusterPt x F) : NeBot (𝓝 x βŠ“ F) := h #align cluster_pt.ne_bot ClusterPt.neBot theorem Filter.HasBasis.clusterPt_iff {ΞΉX ΞΉF} {pX : ΞΉX β†’ Prop} {sX : ΞΉX β†’ Set X} {pF : ΞΉF β†’ Prop} {sF : ΞΉF β†’ Set X} {F : Filter X} (hX : (𝓝 x).HasBasis pX sX) (hF : F.HasBasis pF sF) : ClusterPt x F ↔ βˆ€ ⦃i⦄, pX i β†’ βˆ€ ⦃j⦄, pF j β†’ (sX i ∩ sF j).Nonempty := hX.inf_basis_neBot_iff hF #align filter.has_basis.cluster_pt_iff Filter.HasBasis.clusterPt_iff theorem clusterPt_iff {F : Filter X} : ClusterPt x F ↔ βˆ€ ⦃U : Set X⦄, U ∈ 𝓝 x β†’ βˆ€ ⦃V⦄, V ∈ F β†’ (U ∩ V).Nonempty := inf_neBot_iff #align cluster_pt_iff clusterPt_iff theorem clusterPt_iff_not_disjoint {F : Filter X} : ClusterPt x F ↔ Β¬Disjoint (𝓝 x) F := by rw [disjoint_iff, ClusterPt, neBot_iff] theorem clusterPt_principal_iff : ClusterPt x (π“Ÿ s) ↔ βˆ€ U ∈ 𝓝 x, (U ∩ s).Nonempty := inf_principal_neBot_iff #align cluster_pt_principal_iff clusterPt_principal_iff theorem clusterPt_principal_iff_frequently : ClusterPt x (π“Ÿ s) ↔ βˆƒαΆ  y in 𝓝 x, y ∈ s := by simp only [clusterPt_principal_iff, frequently_iff, Set.Nonempty, exists_prop, mem_inter_iff] #align cluster_pt_principal_iff_frequently clusterPt_principal_iff_frequently theorem ClusterPt.of_le_nhds {f : Filter X} (H : f ≀ 𝓝 x) [NeBot f] : ClusterPt x f := by rwa [ClusterPt, inf_eq_right.mpr H] #align cluster_pt.of_le_nhds ClusterPt.of_le_nhds theorem ClusterPt.of_le_nhds' {f : Filter X} (H : f ≀ 𝓝 x) (_hf : NeBot f) : ClusterPt x f := ClusterPt.of_le_nhds H #align cluster_pt.of_le_nhds' ClusterPt.of_le_nhds' theorem ClusterPt.of_nhds_le {f : Filter X} (H : 𝓝 x ≀ f) : ClusterPt x f := by simp only [ClusterPt, inf_eq_left.mpr H, nhds_neBot] #align cluster_pt.of_nhds_le ClusterPt.of_nhds_le theorem ClusterPt.mono {f g : Filter X} (H : ClusterPt x f) (h : f ≀ g) : ClusterPt x g := NeBot.mono H <| inf_le_inf_left _ h #align cluster_pt.mono ClusterPt.mono theorem ClusterPt.of_inf_left {f g : Filter X} (H : ClusterPt x <| f βŠ“ g) : ClusterPt x f := H.mono inf_le_left #align cluster_pt.of_inf_left ClusterPt.of_inf_left theorem ClusterPt.of_inf_right {f g : Filter X} (H : ClusterPt x <| f βŠ“ g) : ClusterPt x g := H.mono inf_le_right #align cluster_pt.of_inf_right ClusterPt.of_inf_right theorem Ultrafilter.clusterPt_iff {f : Ultrafilter X} : ClusterPt x f ↔ ↑f ≀ 𝓝 x := ⟨f.le_of_inf_neBot', fun h => ClusterPt.of_le_nhds h⟩ #align ultrafilter.cluster_pt_iff Ultrafilter.clusterPt_iff theorem clusterPt_iff_ultrafilter {f : Filter X} : ClusterPt x f ↔ βˆƒ u : Ultrafilter X, u ≀ f ∧ u ≀ 𝓝 x := by simp_rw [ClusterPt, ← le_inf_iff, exists_ultrafilter_iff, inf_comm] theorem mapClusterPt_def {ΞΉ : Type*} (x : X) (F : Filter ΞΉ) (u : ΞΉ β†’ X) : MapClusterPt x F u ↔ ClusterPt x (map u F) := Iff.rfl theorem mapClusterPt_iff {ΞΉ : Type*} (x : X) (F : Filter ΞΉ) (u : ΞΉ β†’ X) : MapClusterPt x F u ↔ βˆ€ s ∈ 𝓝 x, βˆƒαΆ  a in F, u a ∈ s := by simp_rw [MapClusterPt, ClusterPt, inf_neBot_iff_frequently_left, frequently_map] rfl #align map_cluster_pt_iff mapClusterPt_iff theorem mapClusterPt_iff_ultrafilter {ΞΉ : Type*} (x : X) (F : Filter ΞΉ) (u : ΞΉ β†’ X) : MapClusterPt x F u ↔ βˆƒ U : Ultrafilter ΞΉ, U ≀ F ∧ Tendsto u U (𝓝 x) := by simp_rw [MapClusterPt, ClusterPt, ← Filter.push_pull', map_neBot_iff, tendsto_iff_comap, ← le_inf_iff, exists_ultrafilter_iff, inf_comm] theorem mapClusterPt_comp {X Ξ± Ξ² : Type*} {x : X} [TopologicalSpace X] {F : Filter Ξ±} {Ο† : Ξ± β†’ Ξ²} {u : Ξ² β†’ X} : MapClusterPt x F (u ∘ Ο†) ↔ MapClusterPt x (map Ο† F) u := Iff.rfl theorem mapClusterPt_of_comp {F : Filter Ξ±} {Ο† : Ξ² β†’ Ξ±} {p : Filter Ξ²} {u : Ξ± β†’ X} [NeBot p] (h : Tendsto Ο† p F) (H : Tendsto (u ∘ Ο†) p (𝓝 x)) : MapClusterPt x F u := by have := calc map (u ∘ Ο†) p = map u (map Ο† p) := map_map _ ≀ map u F := map_mono h have : map (u ∘ Ο†) p ≀ 𝓝 x βŠ“ map u F := le_inf H this exact neBot_of_le this #align map_cluster_pt_of_comp mapClusterPt_of_comp theorem acc_iff_cluster (x : X) (F : Filter X) : AccPt x F ↔ ClusterPt x (π“Ÿ {x}ᢜ βŠ“ F) := by rw [AccPt, nhdsWithin, ClusterPt, inf_assoc] #align acc_iff_cluster acc_iff_cluster theorem acc_principal_iff_cluster (x : X) (C : Set X) : AccPt x (π“Ÿ C) ↔ ClusterPt x (π“Ÿ (C \ {x})) := by rw [acc_iff_cluster, inf_principal, inter_comm, diff_eq] #align acc_principal_iff_cluster acc_principal_iff_cluster theorem accPt_iff_nhds (x : X) (C : Set X) : AccPt x (π“Ÿ C) ↔ βˆ€ U ∈ 𝓝 x, βˆƒ y ∈ U ∩ C, y β‰  x := by simp [acc_principal_iff_cluster, clusterPt_principal_iff, Set.Nonempty, exists_prop, and_assoc, @and_comm (Β¬_ = x)] #align acc_pt_iff_nhds accPt_iff_nhds theorem accPt_iff_frequently (x : X) (C : Set X) : AccPt x (π“Ÿ C) ↔ βˆƒαΆ  y in 𝓝 x, y β‰  x ∧ y ∈ C := by simp [acc_principal_iff_cluster, clusterPt_principal_iff_frequently, and_comm] #align acc_pt_iff_frequently accPt_iff_frequently theorem AccPt.mono {F G : Filter X} (h : AccPt x F) (hFG : F ≀ G) : AccPt x G := NeBot.mono h (inf_le_inf_left _ hFG) #align acc_pt.mono AccPt.mono theorem interior_eq_nhds' : interior s = { x | s ∈ 𝓝 x } := Set.ext fun x => by simp only [mem_interior, mem_nhds_iff, mem_setOf_eq] #align interior_eq_nhds' interior_eq_nhds' theorem interior_eq_nhds : interior s = { x | 𝓝 x ≀ π“Ÿ s } := interior_eq_nhds'.trans <| by simp only [le_principal_iff] #align interior_eq_nhds interior_eq_nhds @[simp] theorem interior_mem_nhds : interior s ∈ 𝓝 x ↔ s ∈ 𝓝 x := ⟨fun h => mem_of_superset h interior_subset, fun h => IsOpen.mem_nhds isOpen_interior (mem_interior_iff_mem_nhds.2 h)⟩ #align interior_mem_nhds interior_mem_nhds theorem interior_setOf_eq {p : X β†’ Prop} : interior { x | p x } = { x | βˆ€αΆ  y in 𝓝 x, p y } := interior_eq_nhds' #align interior_set_of_eq interior_setOf_eq theorem isOpen_setOf_eventually_nhds {p : X β†’ Prop} : IsOpen { x | βˆ€αΆ  y in 𝓝 x, p y } := by simp only [← interior_setOf_eq, isOpen_interior] #align is_open_set_of_eventually_nhds isOpen_setOf_eventually_nhds theorem subset_interior_iff_nhds {V : Set X} : s βŠ† interior V ↔ βˆ€ x ∈ s, V ∈ 𝓝 x := by simp_rw [subset_def, mem_interior_iff_mem_nhds] #align subset_interior_iff_nhds subset_interior_iff_nhds theorem isOpen_iff_nhds : IsOpen s ↔ βˆ€ x ∈ s, 𝓝 x ≀ π“Ÿ s := calc IsOpen s ↔ s βŠ† interior s := subset_interior_iff_isOpen.symm _ ↔ βˆ€ x ∈ s, 𝓝 x ≀ π“Ÿ s := by simp_rw [interior_eq_nhds, subset_def, mem_setOf] #align is_open_iff_nhds isOpen_iff_nhds theorem TopologicalSpace.ext_iff_nhds {t t' : TopologicalSpace X} : t = t' ↔ βˆ€ x, @nhds _ t x = @nhds _ t' x := ⟨fun H x ↦ congrFun (congrArg _ H) _, fun H ↦ by ext; simp_rw [@isOpen_iff_nhds _ _ _, H]⟩ alias ⟨_, TopologicalSpace.ext_nhds⟩ := TopologicalSpace.ext_iff_nhds theorem isOpen_iff_mem_nhds : IsOpen s ↔ βˆ€ x ∈ s, s ∈ 𝓝 x := isOpen_iff_nhds.trans <| forall_congr' fun _ => imp_congr_right fun _ => le_principal_iff #align is_open_iff_mem_nhds isOpen_iff_mem_nhds theorem isOpen_iff_eventually : IsOpen s ↔ βˆ€ x, x ∈ s β†’ βˆ€αΆ  y in 𝓝 x, y ∈ s := isOpen_iff_mem_nhds #align is_open_iff_eventually isOpen_iff_eventually theorem isOpen_iff_ultrafilter : IsOpen s ↔ βˆ€ x ∈ s, βˆ€ (l : Ultrafilter X), ↑l ≀ 𝓝 x β†’ s ∈ l := by simp_rw [isOpen_iff_mem_nhds, ← mem_iff_ultrafilter] #align is_open_iff_ultrafilter isOpen_iff_ultrafilter theorem isOpen_singleton_iff_nhds_eq_pure (x : X) : IsOpen ({x} : Set X) ↔ 𝓝 x = pure x := by constructor Β· intro h apply le_antisymm _ (pure_le_nhds x) rw [le_pure_iff] exact h.mem_nhds (mem_singleton x) Β· intro h simp [isOpen_iff_nhds, h] #align is_open_singleton_iff_nhds_eq_pure isOpen_singleton_iff_nhds_eq_pure theorem isOpen_singleton_iff_punctured_nhds (x : X) : IsOpen ({x} : Set X) ↔ 𝓝[β‰ ] x = βŠ₯ := by rw [isOpen_singleton_iff_nhds_eq_pure, nhdsWithin, ← mem_iff_inf_principal_compl, ← le_pure_iff, nhds_neBot.le_pure_iff] #align is_open_singleton_iff_punctured_nhds isOpen_singleton_iff_punctured_nhds theorem mem_closure_iff_frequently : x ∈ closure s ↔ βˆƒαΆ  x in 𝓝 x, x ∈ s := by rw [Filter.Frequently, Filter.Eventually, ← mem_interior_iff_mem_nhds, closure_eq_compl_interior_compl, mem_compl_iff, compl_def] #align mem_closure_iff_frequently mem_closure_iff_frequently alias ⟨_, Filter.Frequently.mem_closure⟩ := mem_closure_iff_frequently #align filter.frequently.mem_closure Filter.Frequently.mem_closure theorem isClosed_iff_frequently : IsClosed s ↔ βˆ€ x, (βˆƒαΆ  y in 𝓝 x, y ∈ s) β†’ x ∈ s := by rw [← closure_subset_iff_isClosed] refine forall_congr' fun x => ?_ rw [mem_closure_iff_frequently] #align is_closed_iff_frequently isClosed_iff_frequently theorem isClosed_setOf_clusterPt {f : Filter X} : IsClosed { x | ClusterPt x f } := by simp only [ClusterPt, inf_neBot_iff_frequently_left, setOf_forall, imp_iff_not_or] refine isClosed_iInter fun p => IsClosed.union ?_ ?_ <;> apply isClosed_compl_iff.2 exacts [isOpen_setOf_eventually_nhds, isOpen_const] #align is_closed_set_of_cluster_pt isClosed_setOf_clusterPt theorem mem_closure_iff_clusterPt : x ∈ closure s ↔ ClusterPt x (π“Ÿ s) := mem_closure_iff_frequently.trans clusterPt_principal_iff_frequently.symm #align mem_closure_iff_cluster_pt mem_closure_iff_clusterPt theorem mem_closure_iff_nhds_ne_bot : x ∈ closure s ↔ 𝓝 x βŠ“ π“Ÿ s β‰  βŠ₯ := mem_closure_iff_clusterPt.trans neBot_iff #align mem_closure_iff_nhds_ne_bot mem_closure_iff_nhds_ne_bot @[deprecated (since := "2024-01-28")] alias mem_closure_iff_nhds_neBot := mem_closure_iff_nhds_ne_bot theorem mem_closure_iff_nhdsWithin_neBot : x ∈ closure s ↔ NeBot (𝓝[s] x) := mem_closure_iff_clusterPt #align mem_closure_iff_nhds_within_ne_bot mem_closure_iff_nhdsWithin_neBot lemma not_mem_closure_iff_nhdsWithin_eq_bot : x βˆ‰ closure s ↔ 𝓝[s] x = βŠ₯ := by rw [mem_closure_iff_nhdsWithin_neBot, not_neBot] theorem dense_compl_singleton (x : X) [NeBot (𝓝[β‰ ] x)] : Dense ({x}ᢜ : Set X) := by intro y rcases eq_or_ne y x with (rfl | hne) Β· rwa [mem_closure_iff_nhdsWithin_neBot] Β· exact subset_closure hne #align dense_compl_singleton dense_compl_singleton -- Porting note (#10618): was a `@[simp]` lemma but `simp` can prove it theorem closure_compl_singleton (x : X) [NeBot (𝓝[β‰ ] x)] : closure {x}ᢜ = (univ : Set X) := (dense_compl_singleton x).closure_eq #align closure_compl_singleton closure_compl_singleton @[simp] theorem interior_singleton (x : X) [NeBot (𝓝[β‰ ] x)] : interior {x} = (βˆ… : Set X) := interior_eq_empty_iff_dense_compl.2 (dense_compl_singleton x) #align interior_singleton interior_singleton theorem not_isOpen_singleton (x : X) [NeBot (𝓝[β‰ ] x)] : Β¬IsOpen ({x} : Set X) := dense_compl_singleton_iff_not_open.1 (dense_compl_singleton x) #align not_is_open_singleton not_isOpen_singleton theorem closure_eq_cluster_pts : closure s = { a | ClusterPt a (π“Ÿ s) } := Set.ext fun _ => mem_closure_iff_clusterPt #align closure_eq_cluster_pts closure_eq_cluster_pts theorem mem_closure_iff_nhds : x ∈ closure s ↔ βˆ€ t ∈ 𝓝 x, (t ∩ s).Nonempty := mem_closure_iff_clusterPt.trans clusterPt_principal_iff #align mem_closure_iff_nhds mem_closure_iff_nhds theorem mem_closure_iff_nhds' : x ∈ closure s ↔ βˆ€ t ∈ 𝓝 x, βˆƒ y : s, ↑y ∈ t := by simp only [mem_closure_iff_nhds, Set.inter_nonempty_iff_exists_right, SetCoe.exists, exists_prop] #align mem_closure_iff_nhds' mem_closure_iff_nhds' theorem mem_closure_iff_comap_neBot : x ∈ closure s ↔ NeBot (comap ((↑) : s β†’ X) (𝓝 x)) := by simp_rw [mem_closure_iff_nhds, comap_neBot_iff, Set.inter_nonempty_iff_exists_right, SetCoe.exists, exists_prop] #align mem_closure_iff_comap_ne_bot mem_closure_iff_comap_neBot theorem mem_closure_iff_nhds_basis' {p : ΞΉ β†’ Prop} {s : ΞΉ β†’ Set X} (h : (𝓝 x).HasBasis p s) : x ∈ closure t ↔ βˆ€ i, p i β†’ (s i ∩ t).Nonempty := mem_closure_iff_clusterPt.trans <| (h.clusterPt_iff (hasBasis_principal _)).trans <| by simp only [exists_prop, forall_const] #align mem_closure_iff_nhds_basis' mem_closure_iff_nhds_basis' theorem mem_closure_iff_nhds_basis {p : ΞΉ β†’ Prop} {s : ΞΉ β†’ Set X} (h : (𝓝 x).HasBasis p s) : x ∈ closure t ↔ βˆ€ i, p i β†’ βˆƒ y ∈ t, y ∈ s i := (mem_closure_iff_nhds_basis' h).trans <| by simp only [Set.Nonempty, mem_inter_iff, exists_prop, and_comm] #align mem_closure_iff_nhds_basis mem_closure_iff_nhds_basis theorem clusterPt_iff_forall_mem_closure {F : Filter X} : ClusterPt x F ↔ βˆ€ s ∈ F, x ∈ closure s := by simp_rw [ClusterPt, inf_neBot_iff, mem_closure_iff_nhds] rw [forallβ‚‚_swap] theorem clusterPt_iff_lift'_closure {F : Filter X} : ClusterPt x F ↔ pure x ≀ (F.lift' closure) := by simp_rw [clusterPt_iff_forall_mem_closure, (hasBasis_pure _).le_basis_iff F.basis_sets.lift'_closure, id, singleton_subset_iff, true_and, exists_const] theorem clusterPt_iff_lift'_closure' {F : Filter X} : ClusterPt x F ↔ (F.lift' closure βŠ“ pure x).NeBot := by rw [clusterPt_iff_lift'_closure, ← Ultrafilter.coe_pure, inf_comm, Ultrafilter.inf_neBot_iff] @[simp] theorem clusterPt_lift'_closure_iff {F : Filter X} : ClusterPt x (F.lift' closure) ↔ ClusterPt x F := by simp [clusterPt_iff_lift'_closure, lift'_lift'_assoc (monotone_closure X) (monotone_closure X)]
Mathlib/Topology/Basic.lean
1,332
1,334
theorem mem_closure_iff_ultrafilter : x ∈ closure s ↔ βˆƒ u : Ultrafilter X, s ∈ u ∧ ↑u ≀ 𝓝 x := by
simp [closure_eq_cluster_pts, ClusterPt, ← exists_ultrafilter_iff, and_comm]
import Mathlib.Order.Interval.Set.UnorderedInterval import Mathlib.Algebra.Order.Interval.Set.Monoid import Mathlib.Data.Set.Pointwise.Basic import Mathlib.Algebra.Order.Field.Basic import Mathlib.Algebra.Order.Group.MinMax #align_import data.set.pointwise.interval from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" open Interval Pointwise variable {Ξ± : Type*} namespace Set section LinearOrderedField variable [LinearOrderedField Ξ±] {a : Ξ±} @[simp] theorem preimage_mul_const_Iio (a : Ξ±) {c : Ξ±} (h : 0 < c) : (fun x => x * c) ⁻¹' Iio a = Iio (a / c) := ext fun _x => (lt_div_iff h).symm #align set.preimage_mul_const_Iio Set.preimage_mul_const_Iio @[simp] theorem preimage_mul_const_Ioi (a : Ξ±) {c : Ξ±} (h : 0 < c) : (fun x => x * c) ⁻¹' Ioi a = Ioi (a / c) := ext fun _x => (div_lt_iff h).symm #align set.preimage_mul_const_Ioi Set.preimage_mul_const_Ioi @[simp] theorem preimage_mul_const_Iic (a : Ξ±) {c : Ξ±} (h : 0 < c) : (fun x => x * c) ⁻¹' Iic a = Iic (a / c) := ext fun _x => (le_div_iff h).symm #align set.preimage_mul_const_Iic Set.preimage_mul_const_Iic @[simp] theorem preimage_mul_const_Ici (a : Ξ±) {c : Ξ±} (h : 0 < c) : (fun x => x * c) ⁻¹' Ici a = Ici (a / c) := ext fun _x => (div_le_iff h).symm #align set.preimage_mul_const_Ici Set.preimage_mul_const_Ici @[simp] theorem preimage_mul_const_Ioo (a b : Ξ±) {c : Ξ±} (h : 0 < c) : (fun x => x * c) ⁻¹' Ioo a b = Ioo (a / c) (b / c) := by simp [← Ioi_inter_Iio, h] #align set.preimage_mul_const_Ioo Set.preimage_mul_const_Ioo @[simp]
Mathlib/Data/Set/Pointwise/Interval.lean
624
625
theorem preimage_mul_const_Ioc (a b : α) {c : α} (h : 0 < c) : (fun x => x * c) ⁻¹' Ioc a b = Ioc (a / c) (b / c) := by
simp [← Ioi_inter_Iic, h]
import Mathlib.Algebra.BigOperators.NatAntidiagonal import Mathlib.Algebra.Polynomial.RingDivision #align_import data.polynomial.mirror from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" namespace Polynomial open Polynomial section Semiring variable {R : Type*} [Semiring R] (p q : R[X]) noncomputable def mirror := p.reverse * X ^ p.natTrailingDegree #align polynomial.mirror Polynomial.mirror @[simp] theorem mirror_zero : (0 : R[X]).mirror = 0 := by simp [mirror] #align polynomial.mirror_zero Polynomial.mirror_zero theorem mirror_monomial (n : β„•) (a : R) : (monomial n a).mirror = monomial n a := by classical by_cases ha : a = 0 Β· rw [ha, monomial_zero_right, mirror_zero] Β· rw [mirror, reverse, natDegree_monomial n a, if_neg ha, natTrailingDegree_monomial ha, ← C_mul_X_pow_eq_monomial, reflect_C_mul_X_pow, revAt_le (le_refl n), tsub_self, pow_zero, mul_one] #align polynomial.mirror_monomial Polynomial.mirror_monomial theorem mirror_C (a : R) : (C a).mirror = C a := mirror_monomial 0 a set_option linter.uppercaseLean3 false in #align polynomial.mirror_C Polynomial.mirror_C theorem mirror_X : X.mirror = (X : R[X]) := mirror_monomial 1 (1 : R) set_option linter.uppercaseLean3 false in #align polynomial.mirror_X Polynomial.mirror_X theorem mirror_natDegree : p.mirror.natDegree = p.natDegree := by by_cases hp : p = 0 Β· rw [hp, mirror_zero] nontriviality R rw [mirror, natDegree_mul', reverse_natDegree, natDegree_X_pow, tsub_add_cancel_of_le p.natTrailingDegree_le_natDegree] rwa [leadingCoeff_X_pow, mul_one, reverse_leadingCoeff, Ne, trailingCoeff_eq_zero] #align polynomial.mirror_nat_degree Polynomial.mirror_natDegree theorem mirror_natTrailingDegree : p.mirror.natTrailingDegree = p.natTrailingDegree := by by_cases hp : p = 0 Β· rw [hp, mirror_zero] Β· rw [mirror, natTrailingDegree_mul_X_pow ((mt reverse_eq_zero.mp) hp), natTrailingDegree_reverse, zero_add] #align polynomial.mirror_nat_trailing_degree Polynomial.mirror_natTrailingDegree
Mathlib/Algebra/Polynomial/Mirror.lean
82
97
theorem coeff_mirror (n : β„•) : p.mirror.coeff n = p.coeff (revAt (p.natDegree + p.natTrailingDegree) n) := by
by_cases h2 : p.natDegree < n Β· rw [coeff_eq_zero_of_natDegree_lt (by rwa [mirror_natDegree])] by_cases h1 : n ≀ p.natDegree + p.natTrailingDegree Β· rw [revAt_le h1, coeff_eq_zero_of_lt_natTrailingDegree] exact (tsub_lt_iff_left h1).mpr (Nat.add_lt_add_right h2 _) Β· rw [← revAtFun_eq, revAtFun, if_neg h1, coeff_eq_zero_of_natDegree_lt h2] rw [not_lt] at h2 rw [revAt_le (h2.trans (Nat.le_add_right _ _))] by_cases h3 : p.natTrailingDegree ≀ n Β· rw [← tsub_add_eq_add_tsub h2, ← tsub_tsub_assoc h2 h3, mirror, coeff_mul_X_pow', if_pos h3, coeff_reverse, revAt_le (tsub_le_self.trans h2)] rw [not_le] at h3 rw [coeff_eq_zero_of_natDegree_lt (lt_tsub_iff_right.mpr (Nat.add_lt_add_left h3 _))] exact coeff_eq_zero_of_lt_natTrailingDegree (by rwa [mirror_natTrailingDegree])
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Arctan import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine #align_import geometry.euclidean.angle.unoriented.right_angle from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" noncomputable section open scoped EuclideanGeometry open scoped Real open scoped RealInnerProductSpace namespace EuclideanGeometry open InnerProductGeometry variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P]
Mathlib/Geometry/Euclidean/Angle/Unoriented/RightAngle.lean
360
365
theorem dist_sq_eq_dist_sq_add_dist_sq_iff_angle_eq_pi_div_two (p1 p2 p3 : P) : dist p1 p3 * dist p1 p3 = dist p1 p2 * dist p1 p2 + dist p3 p2 * dist p3 p2 ↔ ∠ p1 p2 p3 = Ο€ / 2 := by
erw [dist_comm p3 p2, dist_eq_norm_vsub V p1 p3, dist_eq_norm_vsub V p1 p2, dist_eq_norm_vsub V p2 p3, ← norm_sub_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two, vsub_sub_vsub_cancel_right p1, ← neg_vsub_eq_vsub_rev p2 p3, norm_neg]
import Mathlib.Probability.Kernel.CondDistrib #align_import probability.kernel.condexp from "leanprover-community/mathlib"@"00abe0695d8767201e6d008afa22393978bb324d" open MeasureTheory Set Filter TopologicalSpace open scoped ENNReal MeasureTheory ProbabilityTheory namespace ProbabilityTheory variable {Ξ© F : Type*} {m : MeasurableSpace Ξ©} [mΞ© : MeasurableSpace Ξ©] [StandardBorelSpace Ξ©] [Nonempty Ξ©] {ΞΌ : Measure Ξ©} [IsFiniteMeasure ΞΌ] noncomputable irreducible_def condexpKernel (ΞΌ : Measure Ξ©) [IsFiniteMeasure ΞΌ] (m : MeasurableSpace Ξ©) : @kernel Ξ© Ξ© m mΞ© := kernel.comap (@condDistrib Ξ© Ξ© Ξ© mΞ© _ _ mΞ© (m βŠ“ mΞ©) id id ΞΌ _) id (measurable_id'' (inf_le_left : m βŠ“ mΞ© ≀ m)) #align probability_theory.condexp_kernel ProbabilityTheory.condexpKernel lemma condexpKernel_apply_eq_condDistrib {Ο‰ : Ξ©} : condexpKernel ΞΌ m Ο‰ = @condDistrib Ξ© Ξ© Ξ© mΞ© _ _ mΞ© (m βŠ“ mΞ©) id id ΞΌ _ (id Ο‰) := by simp_rw [condexpKernel, kernel.comap_apply] instance : IsMarkovKernel (condexpKernel ΞΌ m) := by simp only [condexpKernel]; infer_instance section Integrability variable [NormedAddCommGroup F] {f : Ξ© β†’ F} theorem _root_.MeasureTheory.Integrable.condexpKernel_ae (hf_int : Integrable f ΞΌ) : βˆ€α΅ Ο‰ βˆ‚ΞΌ, Integrable f (condexpKernel ΞΌ m Ο‰) := by rw [condexpKernel] convert Integrable.condDistrib_ae (aemeasurable_id'' ΞΌ (inf_le_right : m βŠ“ mΞ© ≀ mΞ©)) aemeasurable_id (hf_int.comp_snd_map_prod_id (inf_le_right : m βŠ“ mΞ© ≀ mΞ©)) using 1 #align measure_theory.integrable.condexp_kernel_ae MeasureTheory.Integrable.condexpKernel_ae theorem _root_.MeasureTheory.Integrable.integral_norm_condexpKernel (hf_int : Integrable f ΞΌ) : Integrable (fun Ο‰ => ∫ y, β€–f yβ€– βˆ‚condexpKernel ΞΌ m Ο‰) ΞΌ := by rw [condexpKernel] convert Integrable.integral_norm_condDistrib (aemeasurable_id'' ΞΌ (inf_le_right : m βŠ“ mΞ© ≀ mΞ©)) aemeasurable_id (hf_int.comp_snd_map_prod_id (inf_le_right : m βŠ“ mΞ© ≀ mΞ©)) using 1 #align measure_theory.integrable.integral_norm_condexp_kernel MeasureTheory.Integrable.integral_norm_condexpKernel
Mathlib/Probability/Kernel/Condexp.lean
141
147
theorem _root_.MeasureTheory.Integrable.norm_integral_condexpKernel [NormedSpace ℝ F] (hf_int : Integrable f ΞΌ) : Integrable (fun Ο‰ => β€–βˆ« y, f y βˆ‚condexpKernel ΞΌ m Ο‰β€–) ΞΌ := by
rw [condexpKernel] convert Integrable.norm_integral_condDistrib (aemeasurable_id'' ΞΌ (inf_le_right : m βŠ“ mΞ© ≀ mΞ©)) aemeasurable_id (hf_int.comp_snd_map_prod_id (inf_le_right : m βŠ“ mΞ© ≀ mΞ©)) using 1
import Mathlib.Algebra.GroupPower.IterateHom import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Order.Iterate import Mathlib.Order.SemiconjSup import Mathlib.Tactic.Monotonicity import Mathlib.Topology.Order.MonotoneContinuity #align_import dynamics.circle.rotation_number.translation_number from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open scoped Classical open Filter Set Int Topology open Function hiding Commute structure CircleDeg1Lift extends ℝ β†’o ℝ : Type where map_add_one' : βˆ€ x, toFun (x + 1) = toFun x + 1 #align circle_deg1_lift CircleDeg1Lift namespace CircleDeg1Lift instance : FunLike CircleDeg1Lift ℝ ℝ where coe f := f.toFun coe_injective' | ⟨⟨_, _⟩, _⟩, ⟨⟨_, _⟩, _⟩, rfl => rfl instance : OrderHomClass CircleDeg1Lift ℝ ℝ where map_rel f _ _ h := f.monotone' h @[simp] theorem coe_mk (f h) : ⇑(mk f h) = f := rfl #align circle_deg1_lift.coe_mk CircleDeg1Lift.coe_mk variable (f g : CircleDeg1Lift) @[simp] theorem coe_toOrderHom : ⇑f.toOrderHom = f := rfl protected theorem monotone : Monotone f := f.monotone' #align circle_deg1_lift.monotone CircleDeg1Lift.monotone @[mono] theorem mono {x y} (h : x ≀ y) : f x ≀ f y := f.monotone h #align circle_deg1_lift.mono CircleDeg1Lift.mono theorem strictMono_iff_injective : StrictMono f ↔ Injective f := f.monotone.strictMono_iff_injective #align circle_deg1_lift.strict_mono_iff_injective CircleDeg1Lift.strictMono_iff_injective @[simp] theorem map_add_one : βˆ€ x, f (x + 1) = f x + 1 := f.map_add_one' #align circle_deg1_lift.map_add_one CircleDeg1Lift.map_add_one @[simp] theorem map_one_add (x : ℝ) : f (1 + x) = 1 + f x := by rw [add_comm, map_add_one, add_comm 1] #align circle_deg1_lift.map_one_add CircleDeg1Lift.map_one_add #noalign circle_deg1_lift.coe_inj -- Use `DFunLike.coe_inj` @[ext] theorem ext ⦃f g : CircleDeg1Lift⦄ (h : βˆ€ x, f x = g x) : f = g := DFunLike.ext f g h #align circle_deg1_lift.ext CircleDeg1Lift.ext theorem ext_iff {f g : CircleDeg1Lift} : f = g ↔ βˆ€ x, f x = g x := DFunLike.ext_iff #align circle_deg1_lift.ext_iff CircleDeg1Lift.ext_iff instance : Monoid CircleDeg1Lift where mul f g := { toOrderHom := f.1.comp g.1 map_add_one' := fun x => by simp [map_add_one] } one := ⟨.id, fun _ => rfl⟩ mul_one f := rfl one_mul f := rfl mul_assoc f₁ fβ‚‚ f₃ := DFunLike.coe_injective rfl instance : Inhabited CircleDeg1Lift := ⟨1⟩ @[simp] theorem coe_mul : ⇑(f * g) = f ∘ g := rfl #align circle_deg1_lift.coe_mul CircleDeg1Lift.coe_mul theorem mul_apply (x) : (f * g) x = f (g x) := rfl #align circle_deg1_lift.mul_apply CircleDeg1Lift.mul_apply @[simp] theorem coe_one : ⇑(1 : CircleDeg1Lift) = id := rfl #align circle_deg1_lift.coe_one CircleDeg1Lift.coe_one instance unitsHasCoeToFun : CoeFun CircleDeg1LiftΛ£ fun _ => ℝ β†’ ℝ := ⟨fun f => ⇑(f : CircleDeg1Lift)⟩ #align circle_deg1_lift.units_has_coe_to_fun CircleDeg1Lift.unitsHasCoeToFun #noalign circle_deg1_lift.units_coe -- now LHS = RHS @[simp] theorem units_inv_apply_apply (f : CircleDeg1LiftΛ£) (x : ℝ) : (f⁻¹ : CircleDeg1LiftΛ£) (f x) = x := by simp only [← mul_apply, f.inv_mul, coe_one, id] #align circle_deg1_lift.units_inv_apply_apply CircleDeg1Lift.units_inv_apply_apply @[simp] theorem units_apply_inv_apply (f : CircleDeg1LiftΛ£) (x : ℝ) : f ((f⁻¹ : CircleDeg1LiftΛ£) x) = x := by simp only [← mul_apply, f.mul_inv, coe_one, id] #align circle_deg1_lift.units_apply_inv_apply CircleDeg1Lift.units_apply_inv_apply def toOrderIso : CircleDeg1LiftΛ£ β†’* ℝ ≃o ℝ where toFun f := { toFun := f invFun := ⇑f⁻¹ left_inv := units_inv_apply_apply f right_inv := units_apply_inv_apply f map_rel_iff' := ⟨fun h => by simpa using mono (↑f⁻¹) h, mono f⟩ } map_one' := rfl map_mul' f g := rfl #align circle_deg1_lift.to_order_iso CircleDeg1Lift.toOrderIso @[simp] theorem coe_toOrderIso (f : CircleDeg1LiftΛ£) : ⇑(toOrderIso f) = f := rfl #align circle_deg1_lift.coe_to_order_iso CircleDeg1Lift.coe_toOrderIso @[simp] theorem coe_toOrderIso_symm (f : CircleDeg1LiftΛ£) : ⇑(toOrderIso f).symm = (f⁻¹ : CircleDeg1LiftΛ£) := rfl #align circle_deg1_lift.coe_to_order_iso_symm CircleDeg1Lift.coe_toOrderIso_symm @[simp] theorem coe_toOrderIso_inv (f : CircleDeg1LiftΛ£) : ⇑(toOrderIso f)⁻¹ = (f⁻¹ : CircleDeg1LiftΛ£) := rfl #align circle_deg1_lift.coe_to_order_iso_inv CircleDeg1Lift.coe_toOrderIso_inv theorem isUnit_iff_bijective {f : CircleDeg1Lift} : IsUnit f ↔ Bijective f := ⟨fun ⟨u, h⟩ => h β–Έ (toOrderIso u).bijective, fun h => Units.isUnit { val := f inv := { toFun := (Equiv.ofBijective f h).symm monotone' := fun x y hxy => (f.strictMono_iff_injective.2 h.1).le_iff_le.1 (by simp only [Equiv.ofBijective_apply_symm_apply f h, hxy]) map_add_one' := fun x => h.1 <| by simp only [Equiv.ofBijective_apply_symm_apply f, f.map_add_one] } val_inv := ext <| Equiv.ofBijective_apply_symm_apply f h inv_val := ext <| Equiv.ofBijective_symm_apply_apply f h }⟩ #align circle_deg1_lift.is_unit_iff_bijective CircleDeg1Lift.isUnit_iff_bijective theorem coe_pow : βˆ€ n : β„•, ⇑(f ^ n) = f^[n] | 0 => rfl | n + 1 => by ext x simp [coe_pow n, pow_succ] #align circle_deg1_lift.coe_pow CircleDeg1Lift.coe_pow theorem semiconjBy_iff_semiconj {f g₁ gβ‚‚ : CircleDeg1Lift} : SemiconjBy f g₁ gβ‚‚ ↔ Semiconj f g₁ gβ‚‚ := ext_iff #align circle_deg1_lift.semiconj_by_iff_semiconj CircleDeg1Lift.semiconjBy_iff_semiconj theorem commute_iff_commute {f g : CircleDeg1Lift} : Commute f g ↔ Function.Commute f g := ext_iff #align circle_deg1_lift.commute_iff_commute CircleDeg1Lift.commute_iff_commute def translate : Multiplicative ℝ β†’* CircleDeg1LiftΛ£ := MonoidHom.toHomUnits <| { toFun := fun x => ⟨⟨fun y => Multiplicative.toAdd x + y, fun _ _ h => add_le_add_left h _⟩, fun _ => (add_assoc _ _ _).symm⟩ map_one' := ext <| zero_add map_mul' := fun _ _ => ext <| add_assoc _ _ } #align circle_deg1_lift.translate CircleDeg1Lift.translate @[simp] theorem translate_apply (x y : ℝ) : translate (Multiplicative.ofAdd x) y = x + y := rfl #align circle_deg1_lift.translate_apply CircleDeg1Lift.translate_apply @[simp] theorem translate_inv_apply (x y : ℝ) : (translate <| Multiplicative.ofAdd x)⁻¹ y = -x + y := rfl #align circle_deg1_lift.translate_inv_apply CircleDeg1Lift.translate_inv_apply @[simp] theorem translate_zpow (x : ℝ) (n : β„€) : translate (Multiplicative.ofAdd x) ^ n = translate (Multiplicative.ofAdd <| ↑n * x) := by simp only [← zsmul_eq_mul, ofAdd_zsmul, MonoidHom.map_zpow] #align circle_deg1_lift.translate_zpow CircleDeg1Lift.translate_zpow @[simp] theorem translate_pow (x : ℝ) (n : β„•) : translate (Multiplicative.ofAdd x) ^ n = translate (Multiplicative.ofAdd <| ↑n * x) := translate_zpow x n #align circle_deg1_lift.translate_pow CircleDeg1Lift.translate_pow @[simp] theorem translate_iterate (x : ℝ) (n : β„•) : (translate (Multiplicative.ofAdd x))^[n] = translate (Multiplicative.ofAdd <| ↑n * x) := by rw [← coe_pow, ← Units.val_pow_eq_pow_val, translate_pow] #align circle_deg1_lift.translate_iterate CircleDeg1Lift.translate_iterate theorem commute_nat_add (n : β„•) : Function.Commute f (n + Β·) := by simpa only [nsmul_one, add_left_iterate] using Function.Commute.iterate_right f.map_one_add n #align circle_deg1_lift.commute_nat_add CircleDeg1Lift.commute_nat_add theorem commute_add_nat (n : β„•) : Function.Commute f (Β· + n) := by simp only [add_comm _ (n : ℝ), f.commute_nat_add n] #align circle_deg1_lift.commute_add_nat CircleDeg1Lift.commute_add_nat theorem commute_sub_nat (n : β„•) : Function.Commute f (Β· - n) := by simpa only [sub_eq_add_neg] using (f.commute_add_nat n).inverses_right (Equiv.addRight _).right_inv (Equiv.addRight _).left_inv #align circle_deg1_lift.commute_sub_nat CircleDeg1Lift.commute_sub_nat theorem commute_add_int : βˆ€ n : β„€, Function.Commute f (Β· + n) | (n : β„•) => f.commute_add_nat n | -[n+1] => by simpa [sub_eq_add_neg] using f.commute_sub_nat (n + 1) #align circle_deg1_lift.commute_add_int CircleDeg1Lift.commute_add_int theorem commute_int_add (n : β„€) : Function.Commute f (n + Β·) := by simpa only [add_comm _ (n : ℝ)] using f.commute_add_int n #align circle_deg1_lift.commute_int_add CircleDeg1Lift.commute_int_add theorem commute_sub_int (n : β„€) : Function.Commute f (Β· - n) := by simpa only [sub_eq_add_neg] using (f.commute_add_int n).inverses_right (Equiv.addRight _).right_inv (Equiv.addRight _).left_inv #align circle_deg1_lift.commute_sub_int CircleDeg1Lift.commute_sub_int @[simp] theorem map_int_add (m : β„€) (x : ℝ) : f (m + x) = m + f x := f.commute_int_add m x #align circle_deg1_lift.map_int_add CircleDeg1Lift.map_int_add @[simp] theorem map_add_int (x : ℝ) (m : β„€) : f (x + m) = f x + m := f.commute_add_int m x #align circle_deg1_lift.map_add_int CircleDeg1Lift.map_add_int @[simp] theorem map_sub_int (x : ℝ) (n : β„€) : f (x - n) = f x - n := f.commute_sub_int n x #align circle_deg1_lift.map_sub_int CircleDeg1Lift.map_sub_int @[simp] theorem map_add_nat (x : ℝ) (n : β„•) : f (x + n) = f x + n := f.map_add_int x n #align circle_deg1_lift.map_add_nat CircleDeg1Lift.map_add_nat @[simp] theorem map_nat_add (n : β„•) (x : ℝ) : f (n + x) = n + f x := f.map_int_add n x #align circle_deg1_lift.map_nat_add CircleDeg1Lift.map_nat_add @[simp] theorem map_sub_nat (x : ℝ) (n : β„•) : f (x - n) = f x - n := f.map_sub_int x n #align circle_deg1_lift.map_sub_nat CircleDeg1Lift.map_sub_nat theorem map_int_of_map_zero (n : β„€) : f n = f 0 + n := by rw [← f.map_add_int, zero_add] #align circle_deg1_lift.map_int_of_map_zero CircleDeg1Lift.map_int_of_map_zero @[simp] theorem map_fract_sub_fract_eq (x : ℝ) : f (fract x) - fract x = f x - x := by rw [Int.fract, f.map_sub_int, sub_sub_sub_cancel_right] #align circle_deg1_lift.map_fract_sub_fract_eq CircleDeg1Lift.map_fract_sub_fract_eq noncomputable instance : Lattice CircleDeg1Lift where sup f g := { toFun := fun x => max (f x) (g x) monotone' := fun x y h => max_le_max (f.mono h) (g.mono h) -- TODO: generalize to `Monotone.max` map_add_one' := fun x => by simp [max_add_add_right] } le f g := βˆ€ x, f x ≀ g x le_refl f x := le_refl (f x) le_trans f₁ fβ‚‚ f₃ h₁₂ h₂₃ x := le_trans (h₁₂ x) (h₂₃ x) le_antisymm f₁ fβ‚‚ h₁₂ h₂₁ := ext fun x => le_antisymm (h₁₂ x) (h₂₁ x) le_sup_left f g x := le_max_left (f x) (g x) le_sup_right f g x := le_max_right (f x) (g x) sup_le f₁ fβ‚‚ f₃ h₁ hβ‚‚ x := max_le (h₁ x) (hβ‚‚ x) inf f g := { toFun := fun x => min (f x) (g x) monotone' := fun x y h => min_le_min (f.mono h) (g.mono h) map_add_one' := fun x => by simp [min_add_add_right] } inf_le_left f g x := min_le_left (f x) (g x) inf_le_right f g x := min_le_right (f x) (g x) le_inf f₁ fβ‚‚ f₃ hβ‚‚ h₃ x := le_min (hβ‚‚ x) (h₃ x) @[simp] theorem sup_apply (x : ℝ) : (f βŠ” g) x = max (f x) (g x) := rfl #align circle_deg1_lift.sup_apply CircleDeg1Lift.sup_apply @[simp] theorem inf_apply (x : ℝ) : (f βŠ“ g) x = min (f x) (g x) := rfl #align circle_deg1_lift.inf_apply CircleDeg1Lift.inf_apply theorem iterate_monotone (n : β„•) : Monotone fun f : CircleDeg1Lift => f^[n] := fun f _ h => f.monotone.iterate_le_of_le h _ #align circle_deg1_lift.iterate_monotone CircleDeg1Lift.iterate_monotone theorem iterate_mono {f g : CircleDeg1Lift} (h : f ≀ g) (n : β„•) : f^[n] ≀ g^[n] := iterate_monotone n h #align circle_deg1_lift.iterate_mono CircleDeg1Lift.iterate_mono theorem pow_mono {f g : CircleDeg1Lift} (h : f ≀ g) (n : β„•) : f ^ n ≀ g ^ n := fun x => by simp only [coe_pow, iterate_mono h n x] #align circle_deg1_lift.pow_mono CircleDeg1Lift.pow_mono theorem pow_monotone (n : β„•) : Monotone fun f : CircleDeg1Lift => f ^ n := fun _ _ h => pow_mono h n #align circle_deg1_lift.pow_monotone CircleDeg1Lift.pow_monotone theorem map_le_of_map_zero (x : ℝ) : f x ≀ f 0 + ⌈xβŒ‰ := calc f x ≀ f ⌈xβŒ‰ := f.monotone <| le_ceil _ _ = f 0 + ⌈xβŒ‰ := f.map_int_of_map_zero _ #align circle_deg1_lift.map_le_of_map_zero CircleDeg1Lift.map_le_of_map_zero theorem map_map_zero_le : f (g 0) ≀ f 0 + ⌈g 0βŒ‰ := f.map_le_of_map_zero (g 0) #align circle_deg1_lift.map_map_zero_le CircleDeg1Lift.map_map_zero_le theorem floor_map_map_zero_le : ⌊f (g 0)βŒ‹ ≀ ⌊f 0βŒ‹ + ⌈g 0βŒ‰ := calc ⌊f (g 0)βŒ‹ ≀ ⌊f 0 + ⌈g 0βŒ‰βŒ‹ := floor_mono <| f.map_map_zero_le g _ = ⌊f 0βŒ‹ + ⌈g 0βŒ‰ := floor_add_int _ _ #align circle_deg1_lift.floor_map_map_zero_le CircleDeg1Lift.floor_map_map_zero_le theorem ceil_map_map_zero_le : ⌈f (g 0)βŒ‰ ≀ ⌈f 0βŒ‰ + ⌈g 0βŒ‰ := calc ⌈f (g 0)βŒ‰ ≀ ⌈f 0 + ⌈g 0βŒ‰βŒ‰ := ceil_mono <| f.map_map_zero_le g _ = ⌈f 0βŒ‰ + ⌈g 0βŒ‰ := ceil_add_int _ _ #align circle_deg1_lift.ceil_map_map_zero_le CircleDeg1Lift.ceil_map_map_zero_le theorem map_map_zero_lt : f (g 0) < f 0 + g 0 + 1 := calc f (g 0) ≀ f 0 + ⌈g 0βŒ‰ := f.map_map_zero_le g _ < f 0 + (g 0 + 1) := add_lt_add_left (ceil_lt_add_one _) _ _ = f 0 + g 0 + 1 := (add_assoc _ _ _).symm #align circle_deg1_lift.map_map_zero_lt CircleDeg1Lift.map_map_zero_lt theorem le_map_of_map_zero (x : ℝ) : f 0 + ⌊xβŒ‹ ≀ f x := calc f 0 + ⌊xβŒ‹ = f ⌊xβŒ‹ := (f.map_int_of_map_zero _).symm _ ≀ f x := f.monotone <| floor_le _ #align circle_deg1_lift.le_map_of_map_zero CircleDeg1Lift.le_map_of_map_zero theorem le_map_map_zero : f 0 + ⌊g 0βŒ‹ ≀ f (g 0) := f.le_map_of_map_zero (g 0) #align circle_deg1_lift.le_map_map_zero CircleDeg1Lift.le_map_map_zero theorem le_floor_map_map_zero : ⌊f 0βŒ‹ + ⌊g 0βŒ‹ ≀ ⌊f (g 0)βŒ‹ := calc ⌊f 0βŒ‹ + ⌊g 0βŒ‹ = ⌊f 0 + ⌊g 0βŒ‹βŒ‹ := (floor_add_int _ _).symm _ ≀ ⌊f (g 0)βŒ‹ := floor_mono <| f.le_map_map_zero g #align circle_deg1_lift.le_floor_map_map_zero CircleDeg1Lift.le_floor_map_map_zero theorem le_ceil_map_map_zero : ⌈f 0βŒ‰ + ⌊g 0βŒ‹ ≀ ⌈(f * g) 0βŒ‰ := calc ⌈f 0βŒ‰ + ⌊g 0βŒ‹ = ⌈f 0 + ⌊g 0βŒ‹βŒ‰ := (ceil_add_int _ _).symm _ ≀ ⌈f (g 0)βŒ‰ := ceil_mono <| f.le_map_map_zero g #align circle_deg1_lift.le_ceil_map_map_zero CircleDeg1Lift.le_ceil_map_map_zero theorem lt_map_map_zero : f 0 + g 0 - 1 < f (g 0) := calc f 0 + g 0 - 1 = f 0 + (g 0 - 1) := add_sub_assoc _ _ _ _ < f 0 + ⌊g 0βŒ‹ := add_lt_add_left (sub_one_lt_floor _) _ _ ≀ f (g 0) := f.le_map_map_zero g #align circle_deg1_lift.lt_map_map_zero CircleDeg1Lift.lt_map_map_zero theorem dist_map_map_zero_lt : dist (f 0 + g 0) (f (g 0)) < 1 := by rw [dist_comm, Real.dist_eq, abs_lt, lt_sub_iff_add_lt', sub_lt_iff_lt_add', ← sub_eq_add_neg] exact ⟨f.lt_map_map_zero g, f.map_map_zero_lt g⟩ #align circle_deg1_lift.dist_map_map_zero_lt CircleDeg1Lift.dist_map_map_zero_lt theorem dist_map_zero_lt_of_semiconj {f g₁ gβ‚‚ : CircleDeg1Lift} (h : Function.Semiconj f g₁ gβ‚‚) : dist (g₁ 0) (gβ‚‚ 0) < 2 := calc dist (g₁ 0) (gβ‚‚ 0) ≀ dist (g₁ 0) (f (g₁ 0) - f 0) + dist _ (gβ‚‚ 0) := dist_triangle _ _ _ _ = dist (f 0 + g₁ 0) (f (g₁ 0)) + dist (gβ‚‚ 0 + f 0) (gβ‚‚ (f 0)) := by simp only [h.eq, Real.dist_eq, sub_sub, add_comm (f 0), sub_sub_eq_add_sub, abs_sub_comm (gβ‚‚ (f 0))] _ < 1 + 1 := add_lt_add (f.dist_map_map_zero_lt g₁) (gβ‚‚.dist_map_map_zero_lt f) _ = 2 := one_add_one_eq_two #align circle_deg1_lift.dist_map_zero_lt_of_semiconj CircleDeg1Lift.dist_map_zero_lt_of_semiconj theorem dist_map_zero_lt_of_semiconjBy {f g₁ gβ‚‚ : CircleDeg1Lift} (h : SemiconjBy f g₁ gβ‚‚) : dist (g₁ 0) (gβ‚‚ 0) < 2 := dist_map_zero_lt_of_semiconj <| semiconjBy_iff_semiconj.1 h #align circle_deg1_lift.dist_map_zero_lt_of_semiconj_by CircleDeg1Lift.dist_map_zero_lt_of_semiconjBy protected theorem tendsto_atBot : Tendsto f atBot atBot := tendsto_atBot_mono f.map_le_of_map_zero <| tendsto_atBot_add_const_left _ _ <| (tendsto_atBot_mono fun x => (ceil_lt_add_one x).le) <| tendsto_atBot_add_const_right _ _ tendsto_id #align circle_deg1_lift.tendsto_at_bot CircleDeg1Lift.tendsto_atBot protected theorem tendsto_atTop : Tendsto f atTop atTop := tendsto_atTop_mono f.le_map_of_map_zero <| tendsto_atTop_add_const_left _ _ <| (tendsto_atTop_mono fun x => (sub_one_lt_floor x).le) <| by simpa [sub_eq_add_neg] using tendsto_atTop_add_const_right _ _ tendsto_id #align circle_deg1_lift.tendsto_at_top CircleDeg1Lift.tendsto_atTop theorem continuous_iff_surjective : Continuous f ↔ Function.Surjective f := ⟨fun h => h.surjective f.tendsto_atTop f.tendsto_atBot, f.monotone.continuous_of_surjective⟩ #align circle_deg1_lift.continuous_iff_surjective CircleDeg1Lift.continuous_iff_surjective theorem iterate_le_of_map_le_add_int {x : ℝ} {m : β„€} (h : f x ≀ x + m) (n : β„•) : f^[n] x ≀ x + n * m := by simpa only [nsmul_eq_mul, add_right_iterate] using (f.commute_add_int m).iterate_le_of_map_le f.monotone (monotone_id.add_const (m : ℝ)) h n #align circle_deg1_lift.iterate_le_of_map_le_add_int CircleDeg1Lift.iterate_le_of_map_le_add_int theorem le_iterate_of_add_int_le_map {x : ℝ} {m : β„€} (h : x + m ≀ f x) (n : β„•) : x + n * m ≀ f^[n] x := by simpa only [nsmul_eq_mul, add_right_iterate] using (f.commute_add_int m).symm.iterate_le_of_map_le (monotone_id.add_const (m : ℝ)) f.monotone h n #align circle_deg1_lift.le_iterate_of_add_int_le_map CircleDeg1Lift.le_iterate_of_add_int_le_map theorem iterate_eq_of_map_eq_add_int {x : ℝ} {m : β„€} (h : f x = x + m) (n : β„•) : f^[n] x = x + n * m := by simpa only [nsmul_eq_mul, add_right_iterate] using (f.commute_add_int m).iterate_eq_of_map_eq n h #align circle_deg1_lift.iterate_eq_of_map_eq_add_int CircleDeg1Lift.iterate_eq_of_map_eq_add_int theorem iterate_pos_le_iff {x : ℝ} {m : β„€} {n : β„•} (hn : 0 < n) : f^[n] x ≀ x + n * m ↔ f x ≀ x + m := by simpa only [nsmul_eq_mul, add_right_iterate] using (f.commute_add_int m).iterate_pos_le_iff_map_le f.monotone (strictMono_id.add_const (m : ℝ)) hn #align circle_deg1_lift.iterate_pos_le_iff CircleDeg1Lift.iterate_pos_le_iff theorem iterate_pos_lt_iff {x : ℝ} {m : β„€} {n : β„•} (hn : 0 < n) : f^[n] x < x + n * m ↔ f x < x + m := by simpa only [nsmul_eq_mul, add_right_iterate] using (f.commute_add_int m).iterate_pos_lt_iff_map_lt f.monotone (strictMono_id.add_const (m : ℝ)) hn #align circle_deg1_lift.iterate_pos_lt_iff CircleDeg1Lift.iterate_pos_lt_iff
Mathlib/Dynamics/Circle/RotationNumber/TranslationNumber.lean
600
603
theorem iterate_pos_eq_iff {x : ℝ} {m : β„€} {n : β„•} (hn : 0 < n) : f^[n] x = x + n * m ↔ f x = x + m := by
simpa only [nsmul_eq_mul, add_right_iterate] using (f.commute_add_int m).iterate_pos_eq_iff_map_eq f.monotone (strictMono_id.add_const (m : ℝ)) hn
import Mathlib.NumberTheory.FLT.Basic import Mathlib.NumberTheory.PythagoreanTriples import Mathlib.RingTheory.Coprime.Lemmas import Mathlib.Tactic.LinearCombination #align_import number_theory.fermat4 from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1" noncomputable section open scoped Classical def Fermat42 (a b c : β„€) : Prop := a β‰  0 ∧ b β‰  0 ∧ a ^ 4 + b ^ 4 = c ^ 2 #align fermat_42 Fermat42 namespace Fermat42 theorem comm {a b c : β„€} : Fermat42 a b c ↔ Fermat42 b a c := by delta Fermat42 rw [add_comm] tauto #align fermat_42.comm Fermat42.comm theorem mul {a b c k : β„€} (hk0 : k β‰  0) : Fermat42 a b c ↔ Fermat42 (k * a) (k * b) (k ^ 2 * c) := by delta Fermat42 constructor Β· intro f42 constructor Β· exact mul_ne_zero hk0 f42.1 constructor Β· exact mul_ne_zero hk0 f42.2.1 Β· have H : a ^ 4 + b ^ 4 = c ^ 2 := f42.2.2 linear_combination k ^ 4 * H Β· intro f42 constructor Β· exact right_ne_zero_of_mul f42.1 constructor Β· exact right_ne_zero_of_mul f42.2.1 apply (mul_right_inj' (pow_ne_zero 4 hk0)).mp linear_combination f42.2.2 #align fermat_42.mul Fermat42.mul theorem ne_zero {a b c : β„€} (h : Fermat42 a b c) : c β‰  0 := by apply ne_zero_pow two_ne_zero _; apply ne_of_gt rw [← h.2.2, (by ring : a ^ 4 + b ^ 4 = (a ^ 2) ^ 2 + (b ^ 2) ^ 2)] exact add_pos (sq_pos_of_ne_zero (pow_ne_zero 2 h.1)) (sq_pos_of_ne_zero (pow_ne_zero 2 h.2.1)) #align fermat_42.ne_zero Fermat42.ne_zero def Minimal (a b c : β„€) : Prop := Fermat42 a b c ∧ βˆ€ a1 b1 c1 : β„€, Fermat42 a1 b1 c1 β†’ Int.natAbs c ≀ Int.natAbs c1 #align fermat_42.minimal Fermat42.Minimal theorem exists_minimal {a b c : β„€} (h : Fermat42 a b c) : βˆƒ a0 b0 c0, Minimal a0 b0 c0 := by let S : Set β„• := { n | βˆƒ s : β„€ Γ— β„€ Γ— β„€, Fermat42 s.1 s.2.1 s.2.2 ∧ n = Int.natAbs s.2.2 } have S_nonempty : S.Nonempty := by use Int.natAbs c rw [Set.mem_setOf_eq] use ⟨a, ⟨b, c⟩⟩ let m : β„• := Nat.find S_nonempty have m_mem : m ∈ S := Nat.find_spec S_nonempty rcases m_mem with ⟨s0, hs0, hs1⟩ use s0.1, s0.2.1, s0.2.2, hs0 intro a1 b1 c1 h1 rw [← hs1] apply Nat.find_min' use ⟨a1, ⟨b1, c1⟩⟩ #align fermat_42.exists_minimal Fermat42.exists_minimal theorem coprime_of_minimal {a b c : β„€} (h : Minimal a b c) : IsCoprime a b := by apply Int.gcd_eq_one_iff_coprime.mp by_contra hab obtain ⟨p, hp, hpa, hpb⟩ := Nat.Prime.not_coprime_iff_dvd.mp hab obtain ⟨a1, rfl⟩ := Int.natCast_dvd.mpr hpa obtain ⟨b1, rfl⟩ := Int.natCast_dvd.mpr hpb have hpc : (p : β„€) ^ 2 ∣ c := by rw [← Int.pow_dvd_pow_iff two_ne_zero, ← h.1.2.2] apply Dvd.intro (a1 ^ 4 + b1 ^ 4) ring obtain ⟨c1, rfl⟩ := hpc have hf : Fermat42 a1 b1 c1 := (Fermat42.mul (Int.natCast_ne_zero.mpr (Nat.Prime.ne_zero hp))).mpr h.1 apply Nat.le_lt_asymm (h.2 _ _ _ hf) rw [Int.natAbs_mul, lt_mul_iff_one_lt_left, Int.natAbs_pow, Int.natAbs_ofNat] Β· exact Nat.one_lt_pow two_ne_zero (Nat.Prime.one_lt hp) Β· exact Nat.pos_of_ne_zero (Int.natAbs_ne_zero.2 (ne_zero hf)) #align fermat_42.coprime_of_minimal Fermat42.coprime_of_minimal theorem minimal_comm {a b c : β„€} : Minimal a b c β†’ Minimal b a c := fun ⟨h1, h2⟩ => ⟨Fermat42.comm.mp h1, h2⟩ #align fermat_42.minimal_comm Fermat42.minimal_comm theorem neg_of_minimal {a b c : β„€} : Minimal a b c β†’ Minimal a b (-c) := by rintro ⟨⟨ha, hb, heq⟩, h2⟩ constructor Β· apply And.intro ha (And.intro hb _) rw [heq] exact (neg_sq c).symm rwa [Int.natAbs_neg c] #align fermat_42.neg_of_minimal Fermat42.neg_of_minimal theorem exists_odd_minimal {a b c : β„€} (h : Fermat42 a b c) : βˆƒ a0 b0 c0, Minimal a0 b0 c0 ∧ a0 % 2 = 1 := by obtain ⟨a0, b0, c0, hf⟩ := exists_minimal h cases' Int.emod_two_eq_zero_or_one a0 with hap hap Β· cases' Int.emod_two_eq_zero_or_one b0 with hbp hbp Β· exfalso have h1 : 2 ∣ (Int.gcd a0 b0 : β„€) := Int.dvd_gcd (Int.dvd_of_emod_eq_zero hap) (Int.dvd_of_emod_eq_zero hbp) rw [Int.gcd_eq_one_iff_coprime.mpr (coprime_of_minimal hf)] at h1 revert h1 decide Β· exact ⟨b0, ⟨a0, ⟨c0, minimal_comm hf, hbp⟩⟩⟩ exact ⟨a0, ⟨b0, ⟨c0, hf, hap⟩⟩⟩ #align fermat_42.exists_odd_minimal Fermat42.exists_odd_minimal
Mathlib/NumberTheory/FLT/Four.lean
141
149
theorem exists_pos_odd_minimal {a b c : β„€} (h : Fermat42 a b c) : βˆƒ a0 b0 c0, Minimal a0 b0 c0 ∧ a0 % 2 = 1 ∧ 0 < c0 := by
obtain ⟨a0, b0, c0, hf, hc⟩ := exists_odd_minimal h rcases lt_trichotomy 0 c0 with (h1 | h1 | h1) · use a0, b0, c0 · exfalso exact ne_zero hf.1 h1.symm · use a0, b0, -c0, neg_of_minimal hf, hc exact neg_pos.mpr h1
import Mathlib.Algebra.Algebra.Tower import Mathlib.Algebra.GroupWithZero.Divisibility import Mathlib.Algebra.Regular.Pow import Mathlib.Algebra.MonoidAlgebra.Support import Mathlib.Data.Finsupp.Antidiagonal import Mathlib.Order.SymmDiff import Mathlib.RingTheory.Adjoin.Basic #align_import data.mv_polynomial.basic from "leanprover-community/mathlib"@"c8734e8953e4b439147bd6f75c2163f6d27cdce6" noncomputable section open Set Function Finsupp AddMonoidAlgebra open scoped Pointwise universe u v w x variable {R : Type u} {S₁ : Type v} {Sβ‚‚ : Type w} {S₃ : Type x} def MvPolynomial (Οƒ : Type*) (R : Type*) [CommSemiring R] := AddMonoidAlgebra R (Οƒ β†’β‚€ β„•) #align mv_polynomial MvPolynomial namespace MvPolynomial -- Porting note: because of `MvPolynomial.C` and `MvPolynomial.X` this linter throws -- tons of warnings in this file, and it's easier to just disable them globally in the file set_option linter.uppercaseLean3 false variable {Οƒ : Type*} {a a' a₁ aβ‚‚ : R} {e : β„•} {n m : Οƒ} {s : Οƒ β†’β‚€ β„•} section CommSemiring variable [CommSemiring R] [CommSemiring S₁] {p q : MvPolynomial Οƒ R} def monomial (s : Οƒ β†’β‚€ β„•) : R β†’β‚—[R] MvPolynomial Οƒ R := lsingle s #align mv_polynomial.monomial MvPolynomial.monomial theorem single_eq_monomial (s : Οƒ β†’β‚€ β„•) (a : R) : Finsupp.single s a = monomial s a := rfl #align mv_polynomial.single_eq_monomial MvPolynomial.single_eq_monomial theorem mul_def : p * q = p.sum fun m a => q.sum fun n b => monomial (m + n) (a * b) := AddMonoidAlgebra.mul_def #align mv_polynomial.mul_def MvPolynomial.mul_def def C : R β†’+* MvPolynomial Οƒ R := { singleZeroRingHom with toFun := monomial 0 } #align mv_polynomial.C MvPolynomial.C variable (R Οƒ) @[simp] theorem algebraMap_eq : algebraMap R (MvPolynomial Οƒ R) = C := rfl #align mv_polynomial.algebra_map_eq MvPolynomial.algebraMap_eq variable {R Οƒ} def X (n : Οƒ) : MvPolynomial Οƒ R := monomial (Finsupp.single n 1) 1 #align mv_polynomial.X MvPolynomial.X theorem monomial_left_injective {r : R} (hr : r β‰  0) : Function.Injective fun s : Οƒ β†’β‚€ β„• => monomial s r := Finsupp.single_left_injective hr #align mv_polynomial.monomial_left_injective MvPolynomial.monomial_left_injective @[simp] theorem monomial_left_inj {s t : Οƒ β†’β‚€ β„•} {r : R} (hr : r β‰  0) : monomial s r = monomial t r ↔ s = t := Finsupp.single_left_inj hr #align mv_polynomial.monomial_left_inj MvPolynomial.monomial_left_inj theorem C_apply : (C a : MvPolynomial Οƒ R) = monomial 0 a := rfl #align mv_polynomial.C_apply MvPolynomial.C_apply -- Porting note (#10618): `simp` can prove this theorem C_0 : C 0 = (0 : MvPolynomial Οƒ R) := map_zero _ #align mv_polynomial.C_0 MvPolynomial.C_0 -- Porting note (#10618): `simp` can prove this theorem C_1 : C 1 = (1 : MvPolynomial Οƒ R) := rfl #align mv_polynomial.C_1 MvPolynomial.C_1 theorem C_mul_monomial : C a * monomial s a' = monomial s (a * a') := by -- Porting note: this `show` feels like defeq abuse, but I can't find the appropriate lemmas show AddMonoidAlgebra.single _ _ * AddMonoidAlgebra.single _ _ = AddMonoidAlgebra.single _ _ simp [C_apply, single_mul_single] #align mv_polynomial.C_mul_monomial MvPolynomial.C_mul_monomial -- Porting note (#10618): `simp` can prove this theorem C_add : (C (a + a') : MvPolynomial Οƒ R) = C a + C a' := Finsupp.single_add _ _ _ #align mv_polynomial.C_add MvPolynomial.C_add -- Porting note (#10618): `simp` can prove this theorem C_mul : (C (a * a') : MvPolynomial Οƒ R) = C a * C a' := C_mul_monomial.symm #align mv_polynomial.C_mul MvPolynomial.C_mul -- Porting note (#10618): `simp` can prove this theorem C_pow (a : R) (n : β„•) : (C (a ^ n) : MvPolynomial Οƒ R) = C a ^ n := map_pow _ _ _ #align mv_polynomial.C_pow MvPolynomial.C_pow theorem C_injective (Οƒ : Type*) (R : Type*) [CommSemiring R] : Function.Injective (C : R β†’ MvPolynomial Οƒ R) := Finsupp.single_injective _ #align mv_polynomial.C_injective MvPolynomial.C_injective theorem C_surjective {R : Type*} [CommSemiring R] (Οƒ : Type*) [IsEmpty Οƒ] : Function.Surjective (C : R β†’ MvPolynomial Οƒ R) := by refine fun p => ⟨p.toFun 0, Finsupp.ext fun a => ?_⟩ simp only [C_apply, ← single_eq_monomial, (Finsupp.ext isEmptyElim (Ξ± := Οƒ) : a = 0), single_eq_same] rfl #align mv_polynomial.C_surjective MvPolynomial.C_surjective @[simp] theorem C_inj {Οƒ : Type*} (R : Type*) [CommSemiring R] (r s : R) : (C r : MvPolynomial Οƒ R) = C s ↔ r = s := (C_injective Οƒ R).eq_iff #align mv_polynomial.C_inj MvPolynomial.C_inj instance nontrivial_of_nontrivial (Οƒ : Type*) (R : Type*) [CommSemiring R] [Nontrivial R] : Nontrivial (MvPolynomial Οƒ R) := inferInstanceAs (Nontrivial <| AddMonoidAlgebra R (Οƒ β†’β‚€ β„•)) instance infinite_of_infinite (Οƒ : Type*) (R : Type*) [CommSemiring R] [Infinite R] : Infinite (MvPolynomial Οƒ R) := Infinite.of_injective C (C_injective _ _) #align mv_polynomial.infinite_of_infinite MvPolynomial.infinite_of_infinite instance infinite_of_nonempty (Οƒ : Type*) (R : Type*) [Nonempty Οƒ] [CommSemiring R] [Nontrivial R] : Infinite (MvPolynomial Οƒ R) := Infinite.of_injective ((fun s : Οƒ β†’β‚€ β„• => monomial s 1) ∘ Finsupp.single (Classical.arbitrary Οƒ)) <| (monomial_left_injective one_ne_zero).comp (Finsupp.single_injective _) #align mv_polynomial.infinite_of_nonempty MvPolynomial.infinite_of_nonempty theorem C_eq_coe_nat (n : β„•) : (C ↑n : MvPolynomial Οƒ R) = n := by induction n <;> simp [Nat.succ_eq_add_one, *] #align mv_polynomial.C_eq_coe_nat MvPolynomial.C_eq_coe_nat theorem C_mul' : MvPolynomial.C a * p = a β€’ p := (Algebra.smul_def a p).symm #align mv_polynomial.C_mul' MvPolynomial.C_mul' theorem smul_eq_C_mul (p : MvPolynomial Οƒ R) (a : R) : a β€’ p = C a * p := C_mul'.symm #align mv_polynomial.smul_eq_C_mul MvPolynomial.smul_eq_C_mul theorem C_eq_smul_one : (C a : MvPolynomial Οƒ R) = a β€’ (1 : MvPolynomial Οƒ R) := by rw [← C_mul', mul_one] #align mv_polynomial.C_eq_smul_one MvPolynomial.C_eq_smul_one theorem smul_monomial {S₁ : Type*} [SMulZeroClass S₁ R] (r : S₁) : r β€’ monomial s a = monomial s (r β€’ a) := Finsupp.smul_single _ _ _ #align mv_polynomial.smul_monomial MvPolynomial.smul_monomial theorem X_injective [Nontrivial R] : Function.Injective (X : Οƒ β†’ MvPolynomial Οƒ R) := (monomial_left_injective one_ne_zero).comp (Finsupp.single_left_injective one_ne_zero) #align mv_polynomial.X_injective MvPolynomial.X_injective @[simp] theorem X_inj [Nontrivial R] (m n : Οƒ) : X m = (X n : MvPolynomial Οƒ R) ↔ m = n := X_injective.eq_iff #align mv_polynomial.X_inj MvPolynomial.X_inj theorem monomial_pow : monomial s a ^ e = monomial (e β€’ s) (a ^ e) := AddMonoidAlgebra.single_pow e #align mv_polynomial.monomial_pow MvPolynomial.monomial_pow @[simp] theorem monomial_mul {s s' : Οƒ β†’β‚€ β„•} {a b : R} : monomial s a * monomial s' b = monomial (s + s') (a * b) := AddMonoidAlgebra.single_mul_single #align mv_polynomial.monomial_mul MvPolynomial.monomial_mul variable (Οƒ R) def monomialOneHom : Multiplicative (Οƒ β†’β‚€ β„•) β†’* MvPolynomial Οƒ R := AddMonoidAlgebra.of _ _ #align mv_polynomial.monomial_one_hom MvPolynomial.monomialOneHom variable {Οƒ R} @[simp] theorem monomialOneHom_apply : monomialOneHom R Οƒ s = (monomial s 1 : MvPolynomial Οƒ R) := rfl #align mv_polynomial.monomial_one_hom_apply MvPolynomial.monomialOneHom_apply theorem X_pow_eq_monomial : X n ^ e = monomial (Finsupp.single n e) (1 : R) := by simp [X, monomial_pow] #align mv_polynomial.X_pow_eq_monomial MvPolynomial.X_pow_eq_monomial theorem monomial_add_single : monomial (s + Finsupp.single n e) a = monomial s a * X n ^ e := by rw [X_pow_eq_monomial, monomial_mul, mul_one] #align mv_polynomial.monomial_add_single MvPolynomial.monomial_add_single theorem monomial_single_add : monomial (Finsupp.single n e + s) a = X n ^ e * monomial s a := by rw [X_pow_eq_monomial, monomial_mul, one_mul] #align mv_polynomial.monomial_single_add MvPolynomial.monomial_single_add theorem C_mul_X_pow_eq_monomial {s : Οƒ} {a : R} {n : β„•} : C a * X s ^ n = monomial (Finsupp.single s n) a := by rw [← zero_add (Finsupp.single s n), monomial_add_single, C_apply] #align mv_polynomial.C_mul_X_pow_eq_monomial MvPolynomial.C_mul_X_pow_eq_monomial theorem C_mul_X_eq_monomial {s : Οƒ} {a : R} : C a * X s = monomial (Finsupp.single s 1) a := by rw [← C_mul_X_pow_eq_monomial, pow_one] #align mv_polynomial.C_mul_X_eq_monomial MvPolynomial.C_mul_X_eq_monomial -- Porting note (#10618): `simp` can prove this theorem monomial_zero {s : Οƒ β†’β‚€ β„•} : monomial s (0 : R) = 0 := Finsupp.single_zero _ #align mv_polynomial.monomial_zero MvPolynomial.monomial_zero @[simp] theorem monomial_zero' : (monomial (0 : Οƒ β†’β‚€ β„•) : R β†’ MvPolynomial Οƒ R) = C := rfl #align mv_polynomial.monomial_zero' MvPolynomial.monomial_zero' @[simp] theorem monomial_eq_zero {s : Οƒ β†’β‚€ β„•} {b : R} : monomial s b = 0 ↔ b = 0 := Finsupp.single_eq_zero #align mv_polynomial.monomial_eq_zero MvPolynomial.monomial_eq_zero @[simp] theorem sum_monomial_eq {A : Type*} [AddCommMonoid A] {u : Οƒ β†’β‚€ β„•} {r : R} {b : (Οƒ β†’β‚€ β„•) β†’ R β†’ A} (w : b u 0 = 0) : sum (monomial u r) b = b u r := Finsupp.sum_single_index w #align mv_polynomial.sum_monomial_eq MvPolynomial.sum_monomial_eq @[simp] theorem sum_C {A : Type*} [AddCommMonoid A] {b : (Οƒ β†’β‚€ β„•) β†’ R β†’ A} (w : b 0 0 = 0) : sum (C a) b = b 0 a := sum_monomial_eq w #align mv_polynomial.sum_C MvPolynomial.sum_C theorem monomial_sum_one {Ξ± : Type*} (s : Finset Ξ±) (f : Ξ± β†’ Οƒ β†’β‚€ β„•) : (monomial (βˆ‘ i ∈ s, f i) 1 : MvPolynomial Οƒ R) = ∏ i ∈ s, monomial (f i) 1 := map_prod (monomialOneHom R Οƒ) (fun i => Multiplicative.ofAdd (f i)) s #align mv_polynomial.monomial_sum_one MvPolynomial.monomial_sum_one theorem monomial_sum_index {Ξ± : Type*} (s : Finset Ξ±) (f : Ξ± β†’ Οƒ β†’β‚€ β„•) (a : R) : monomial (βˆ‘ i ∈ s, f i) a = C a * ∏ i ∈ s, monomial (f i) 1 := by rw [← monomial_sum_one, C_mul', ← (monomial _).map_smul, smul_eq_mul, mul_one] #align mv_polynomial.monomial_sum_index MvPolynomial.monomial_sum_index theorem monomial_finsupp_sum_index {Ξ± Ξ² : Type*} [Zero Ξ²] (f : Ξ± β†’β‚€ Ξ²) (g : Ξ± β†’ Ξ² β†’ Οƒ β†’β‚€ β„•) (a : R) : monomial (f.sum g) a = C a * f.prod fun a b => monomial (g a b) 1 := monomial_sum_index _ _ _ #align mv_polynomial.monomial_finsupp_sum_index MvPolynomial.monomial_finsupp_sum_index theorem monomial_eq_monomial_iff {Ξ± : Type*} (a₁ aβ‚‚ : Ξ± β†’β‚€ β„•) (b₁ bβ‚‚ : R) : monomial a₁ b₁ = monomial aβ‚‚ bβ‚‚ ↔ a₁ = aβ‚‚ ∧ b₁ = bβ‚‚ ∨ b₁ = 0 ∧ bβ‚‚ = 0 := Finsupp.single_eq_single_iff _ _ _ _ #align mv_polynomial.monomial_eq_monomial_iff MvPolynomial.monomial_eq_monomial_iff theorem monomial_eq : monomial s a = C a * (s.prod fun n e => X n ^ e : MvPolynomial Οƒ R) := by simp only [X_pow_eq_monomial, ← monomial_finsupp_sum_index, Finsupp.sum_single] #align mv_polynomial.monomial_eq MvPolynomial.monomial_eq @[simp] lemma prod_X_pow_eq_monomial : ∏ x ∈ s.support, X x ^ s x = monomial s (1 : R) := by simp only [monomial_eq, map_one, one_mul, Finsupp.prod] theorem induction_on_monomial {M : MvPolynomial Οƒ R β†’ Prop} (h_C : βˆ€ a, M (C a)) (h_X : βˆ€ p n, M p β†’ M (p * X n)) : βˆ€ s a, M (monomial s a) := by intro s a apply @Finsupp.induction Οƒ β„• _ _ s Β· show M (monomial 0 a) exact h_C a Β· intro n e p _hpn _he ih have : βˆ€ e : β„•, M (monomial p a * X n ^ e) := by intro e induction e with | zero => simp [ih] | succ e e_ih => simp [ih, pow_succ, (mul_assoc _ _ _).symm, h_X, e_ih] simp [add_comm, monomial_add_single, this] #align mv_polynomial.induction_on_monomial MvPolynomial.induction_on_monomial @[elab_as_elim] theorem induction_on' {P : MvPolynomial Οƒ R β†’ Prop} (p : MvPolynomial Οƒ R) (h1 : βˆ€ (u : Οƒ β†’β‚€ β„•) (a : R), P (monomial u a)) (h2 : βˆ€ p q : MvPolynomial Οƒ R, P p β†’ P q β†’ P (p + q)) : P p := Finsupp.induction p (suffices P (monomial 0 0) by rwa [monomial_zero] at this show P (monomial 0 0) from h1 0 0) fun a b f _ha _hb hPf => h2 _ _ (h1 _ _) hPf #align mv_polynomial.induction_on' MvPolynomial.induction_on' theorem induction_on''' {M : MvPolynomial Οƒ R β†’ Prop} (p : MvPolynomial Οƒ R) (h_C : βˆ€ a, M (C a)) (h_add_weak : βˆ€ (a : Οƒ β†’β‚€ β„•) (b : R) (f : (Οƒ β†’β‚€ β„•) β†’β‚€ R), a βˆ‰ f.support β†’ b β‰  0 β†’ M f β†’ M ((show (Οƒ β†’β‚€ β„•) β†’β‚€ R from monomial a b) + f)) : M p := -- Porting note: I had to add the `show ... from ...` above, a type ascription was insufficient. Finsupp.induction p (C_0.rec <| h_C 0) h_add_weak #align mv_polynomial.induction_on''' MvPolynomial.induction_on''' theorem induction_on'' {M : MvPolynomial Οƒ R β†’ Prop} (p : MvPolynomial Οƒ R) (h_C : βˆ€ a, M (C a)) (h_add_weak : βˆ€ (a : Οƒ β†’β‚€ β„•) (b : R) (f : (Οƒ β†’β‚€ β„•) β†’β‚€ R), a βˆ‰ f.support β†’ b β‰  0 β†’ M f β†’ M (monomial a b) β†’ M ((show (Οƒ β†’β‚€ β„•) β†’β‚€ R from monomial a b) + f)) (h_X : βˆ€ (p : MvPolynomial Οƒ R) (n : Οƒ), M p β†’ M (p * MvPolynomial.X n)) : M p := -- Porting note: I had to add the `show ... from ...` above, a type ascription was insufficient. induction_on''' p h_C fun a b f ha hb hf => h_add_weak a b f ha hb hf <| induction_on_monomial h_C h_X a b #align mv_polynomial.induction_on'' MvPolynomial.induction_on'' @[recursor 5] theorem induction_on {M : MvPolynomial Οƒ R β†’ Prop} (p : MvPolynomial Οƒ R) (h_C : βˆ€ a, M (C a)) (h_add : βˆ€ p q, M p β†’ M q β†’ M (p + q)) (h_X : βˆ€ p n, M p β†’ M (p * X n)) : M p := induction_on'' p h_C (fun a b f _ha _hb hf hm => h_add (monomial a b) f hm hf) h_X #align mv_polynomial.induction_on MvPolynomial.induction_on theorem ringHom_ext {A : Type*} [Semiring A] {f g : MvPolynomial Οƒ R β†’+* A} (hC : βˆ€ r, f (C r) = g (C r)) (hX : βˆ€ i, f (X i) = g (X i)) : f = g := by refine AddMonoidAlgebra.ringHom_ext' ?_ ?_ -- Porting note: this has high priority, but Lean still chooses `RingHom.ext`, why? -- probably because of the type synonym Β· ext x exact hC _ Β· apply Finsupp.mulHom_ext'; intros x -- Porting note: `Finsupp.mulHom_ext'` needs to have increased priority apply MonoidHom.ext_mnat exact hX _ #align mv_polynomial.ring_hom_ext MvPolynomial.ringHom_ext @[ext 1100] theorem ringHom_ext' {A : Type*} [Semiring A] {f g : MvPolynomial Οƒ R β†’+* A} (hC : f.comp C = g.comp C) (hX : βˆ€ i, f (X i) = g (X i)) : f = g := ringHom_ext (RingHom.ext_iff.1 hC) hX #align mv_polynomial.ring_hom_ext' MvPolynomial.ringHom_ext' theorem hom_eq_hom [Semiring Sβ‚‚] (f g : MvPolynomial Οƒ R β†’+* Sβ‚‚) (hC : f.comp C = g.comp C) (hX : βˆ€ n : Οƒ, f (X n) = g (X n)) (p : MvPolynomial Οƒ R) : f p = g p := RingHom.congr_fun (ringHom_ext' hC hX) p #align mv_polynomial.hom_eq_hom MvPolynomial.hom_eq_hom theorem is_id (f : MvPolynomial Οƒ R β†’+* MvPolynomial Οƒ R) (hC : f.comp C = C) (hX : βˆ€ n : Οƒ, f (X n) = X n) (p : MvPolynomial Οƒ R) : f p = p := hom_eq_hom f (RingHom.id _) hC hX p #align mv_polynomial.is_id MvPolynomial.is_id @[ext 1100] theorem algHom_ext' {A B : Type*} [CommSemiring A] [CommSemiring B] [Algebra R A] [Algebra R B] {f g : MvPolynomial Οƒ A →ₐ[R] B} (h₁ : f.comp (IsScalarTower.toAlgHom R A (MvPolynomial Οƒ A)) = g.comp (IsScalarTower.toAlgHom R A (MvPolynomial Οƒ A))) (hβ‚‚ : βˆ€ i, f (X i) = g (X i)) : f = g := AlgHom.coe_ringHom_injective (MvPolynomial.ringHom_ext' (congr_arg AlgHom.toRingHom h₁) hβ‚‚) #align mv_polynomial.alg_hom_ext' MvPolynomial.algHom_ext' @[ext 1200] theorem algHom_ext {A : Type*} [Semiring A] [Algebra R A] {f g : MvPolynomial Οƒ R →ₐ[R] A} (hf : βˆ€ i : Οƒ, f (X i) = g (X i)) : f = g := AddMonoidAlgebra.algHom_ext' (mulHom_ext' fun X : Οƒ => MonoidHom.ext_mnat (hf X)) #align mv_polynomial.alg_hom_ext MvPolynomial.algHom_ext @[simp] theorem algHom_C {Ο„ : Type*} (f : MvPolynomial Οƒ R →ₐ[R] MvPolynomial Ο„ R) (r : R) : f (C r) = C r := f.commutes r #align mv_polynomial.alg_hom_C MvPolynomial.algHom_C @[simp] theorem adjoin_range_X : Algebra.adjoin R (range (X : Οƒ β†’ MvPolynomial Οƒ R)) = ⊀ := by set S := Algebra.adjoin R (range (X : Οƒ β†’ MvPolynomial Οƒ R)) refine top_unique fun p hp => ?_; clear hp induction p using MvPolynomial.induction_on with | h_C => exact S.algebraMap_mem _ | h_add p q hp hq => exact S.add_mem hp hq | h_X p i hp => exact S.mul_mem hp (Algebra.subset_adjoin <| mem_range_self _) #align mv_polynomial.adjoin_range_X MvPolynomial.adjoin_range_X @[ext] theorem linearMap_ext {M : Type*} [AddCommMonoid M] [Module R M] {f g : MvPolynomial Οƒ R β†’β‚—[R] M} (h : βˆ€ s, f βˆ˜β‚— monomial s = g βˆ˜β‚— monomial s) : f = g := Finsupp.lhom_ext' h #align mv_polynomial.linear_map_ext MvPolynomial.linearMap_ext section Aeval variable [Algebra R S₁] [CommSemiring Sβ‚‚] variable (f : Οƒ β†’ S₁) @[simp] theorem algebraMap_apply (r : R) : algebraMap R (MvPolynomial Οƒ S₁) r = C (algebraMap R S₁ r) := rfl #align mv_polynomial.algebra_map_apply MvPolynomial.algebraMap_apply def aeval : MvPolynomial Οƒ R →ₐ[R] S₁ := { evalβ‚‚Hom (algebraMap R S₁) f with commutes' := fun _r => evalβ‚‚_C _ _ _ } #align mv_polynomial.aeval MvPolynomial.aeval theorem aeval_def (p : MvPolynomial Οƒ R) : aeval f p = evalβ‚‚ (algebraMap R S₁) f p := rfl #align mv_polynomial.aeval_def MvPolynomial.aeval_def theorem aeval_eq_evalβ‚‚Hom (p : MvPolynomial Οƒ R) : aeval f p = evalβ‚‚Hom (algebraMap R S₁) f p := rfl #align mv_polynomial.aeval_eq_evalβ‚‚_hom MvPolynomial.aeval_eq_evalβ‚‚Hom @[simp] lemma coe_aeval_eq_eval : RingHomClass.toRingHom (MvPolynomial.aeval f) = MvPolynomial.eval f := rfl @[simp] theorem aeval_X (s : Οƒ) : aeval f (X s : MvPolynomial _ R) = f s := evalβ‚‚_X _ _ _ #align mv_polynomial.aeval_X MvPolynomial.aeval_X @[simp] theorem aeval_C (r : R) : aeval f (C r) = algebraMap R S₁ r := evalβ‚‚_C _ _ _ #align mv_polynomial.aeval_C MvPolynomial.aeval_C
Mathlib/Algebra/MvPolynomial/Basic.lean
1,547
1,549
theorem aeval_unique (Ο† : MvPolynomial Οƒ R →ₐ[R] S₁) : Ο† = aeval (Ο† ∘ X) := by
ext i simp
import Mathlib.Algebra.Algebra.Unitization import Mathlib.Algebra.Star.NonUnitalSubalgebra import Mathlib.Algebra.Star.Subalgebra import Mathlib.GroupTheory.GroupAction.Ring section Subalgebra variable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] def Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A := { S with smul_mem' := fun r _x hx => S.smul_mem hx r } theorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) : (1 : A) ∈ S.toNonUnitalSubalgebra := S.one_mem def NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) : Subalgebra R A := { S with one_mem' := h1 algebraMap_mem' := fun r => (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm β–Έ SMulMemClass.smul_mem r h1 } theorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) : S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl
Mathlib/Algebra/Algebra/Subalgebra/Unitization.lean
73
75
theorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by
cases S; rfl
import Mathlib.Algebra.Group.Basic import Mathlib.Algebra.Group.Commute.Defs import Mathlib.Logic.Unique import Mathlib.Tactic.Nontriviality import Mathlib.Tactic.Lift #align_import algebra.group.units from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" assert_not_exists Multiplicative assert_not_exists MonoidWithZero assert_not_exists DenselyOrdered open Function universe u variable {Ξ± : Type u} structure Units (Ξ± : Type u) [Monoid Ξ±] where val : Ξ± inv : Ξ± val_inv : val * inv = 1 inv_val : inv * val = 1 #align units Units #align units.val Units.val #align units.inv Units.inv #align units.val_inv Units.val_inv #align units.inv_val Units.inv_val attribute [coe] Units.val @[inherit_doc] postfix:1024 "Λ£" => Units -- We don't provide notation for the additive version, because its use is somewhat rare. structure AddUnits (Ξ± : Type u) [AddMonoid Ξ±] where val : Ξ± neg : Ξ± val_neg : val + neg = 0 neg_val : neg + val = 0 #align add_units AddUnits #align add_units.val AddUnits.val #align add_units.neg AddUnits.neg #align add_units.val_neg AddUnits.val_neg #align add_units.neg_val AddUnits.neg_val attribute [to_additive] Units attribute [coe] AddUnits.val namespace Units section Monoid variable [Monoid Ξ±] -- Porting note: unclear whether this should be a `CoeHead` or `CoeTail` @[to_additive "An additive unit can be interpreted as a term in the base `AddMonoid`."] instance : CoeHead Ξ±Λ£ Ξ± := ⟨val⟩ @[to_additive "The additive inverse of an additive unit in an `AddMonoid`."] instance instInv : Inv Ξ±Λ£ := ⟨fun u => ⟨u.2, u.1, u.4, u.3⟩⟩ attribute [instance] AddUnits.instNeg #noalign units.simps.coe #noalign add_units.simps.coe @[to_additive "See Note [custom simps projection]"] def Simps.val_inv (u : Ξ±Λ£) : Ξ± := ↑(u⁻¹) #align units.simps.coe_inv Units.Simps.val_inv #align add_units.simps.coe_neg AddUnits.Simps.val_neg initialize_simps_projections Units (as_prefix val, val_inv β†’ null, inv β†’ val_inv, as_prefix val_inv) initialize_simps_projections AddUnits (as_prefix val, val_neg β†’ null, neg β†’ val_neg, as_prefix val_neg) -- Porting note: removed `simp` tag because of the tautology @[to_additive] theorem val_mk (a : Ξ±) (b h₁ hβ‚‚) : ↑(Units.mk a b h₁ hβ‚‚) = a := rfl #align units.coe_mk Units.val_mk #align add_units.coe_mk AddUnits.val_mk @[to_additive (attr := ext)] theorem ext : Function.Injective (val : Ξ±Λ£ β†’ Ξ±) | ⟨v, i₁, vi₁, ivβ‚βŸ©, ⟨v', iβ‚‚, viβ‚‚, ivβ‚‚βŸ©, e => by simp only at e; subst v'; congr; simpa only [ivβ‚‚, vi₁, one_mul, mul_one] using mul_assoc iβ‚‚ v i₁ #align units.ext Units.ext #align add_units.ext AddUnits.ext @[to_additive (attr := norm_cast)] theorem eq_iff {a b : Ξ±Λ£} : (a : Ξ±) = b ↔ a = b := ext.eq_iff #align units.eq_iff Units.eq_iff #align add_units.eq_iff AddUnits.eq_iff @[to_additive] theorem ext_iff {a b : Ξ±Λ£} : a = b ↔ (a : Ξ±) = b := eq_iff.symm #align units.ext_iff Units.ext_iff #align add_units.ext_iff AddUnits.ext_iff @[to_additive "Additive units have decidable equality if the base `AddMonoid` has deciable equality."] instance [DecidableEq Ξ±] : DecidableEq Ξ±Λ£ := fun _ _ => decidable_of_iff' _ ext_iff @[to_additive (attr := simp)] theorem mk_val (u : Ξ±Λ£) (y h₁ hβ‚‚) : mk (u : Ξ±) y h₁ hβ‚‚ = u := ext rfl #align units.mk_coe Units.mk_val #align add_units.mk_coe AddUnits.mk_val @[to_additive (attr := simps) "Copy an `AddUnit`, adjusting definitional equalities."] def copy (u : Ξ±Λ£) (val : Ξ±) (hv : val = u) (inv : Ξ±) (hi : inv = ↑u⁻¹) : Ξ±Λ£ := { val, inv, inv_val := hv.symm β–Έ hi.symm β–Έ u.inv_val, val_inv := hv.symm β–Έ hi.symm β–Έ u.val_inv } #align units.copy Units.copy #align add_units.copy AddUnits.copy #align units.coe_copy Units.val_copy #align add_units.coe_copy AddUnits.val_copy #align units.coe_inv_copy Units.val_inv_copy #align add_units.coe_neg_copy AddUnits.val_neg_copy @[to_additive] theorem copy_eq (u : Ξ±Λ£) (val hv inv hi) : u.copy val hv inv hi = u := ext hv #align units.copy_eq Units.copy_eq #align add_units.copy_eq AddUnits.copy_eq @[to_additive "Additive units of an additive monoid have an induced addition."] instance : Mul Ξ±Λ£ where mul u₁ uβ‚‚ := ⟨u₁.val * uβ‚‚.val, uβ‚‚.inv * u₁.inv, by rw [mul_assoc, ← mul_assoc uβ‚‚.val, val_inv, one_mul, val_inv], by rw [mul_assoc, ← mul_assoc u₁.inv, inv_val, one_mul, inv_val]⟩ @[to_additive "Additive units of an additive monoid have a zero."] instance : One Ξ±Λ£ where one := ⟨1, 1, one_mul 1, one_mul 1⟩ @[to_additive "Additive units of an additive monoid have an addition and an additive identity."] instance instMulOneClass : MulOneClass Ξ±Λ£ where one_mul u := ext <| one_mul (u : Ξ±) mul_one u := ext <| mul_one (u : Ξ±) @[to_additive "Additive units of an additive monoid are inhabited because `0` is an additive unit."] instance : Inhabited Ξ±Λ£ := ⟨1⟩ @[to_additive "Additive units of an additive monoid have a representation of the base value in the `AddMonoid`."] instance [Repr Ξ±] : Repr Ξ±Λ£ := ⟨reprPrec ∘ val⟩ variable (a b c : Ξ±Λ£) {u : Ξ±Λ£} @[to_additive (attr := simp, norm_cast)] theorem val_mul : (↑(a * b) : Ξ±) = a * b := rfl #align units.coe_mul Units.val_mul #align add_units.coe_add AddUnits.val_add @[to_additive (attr := simp, norm_cast)] theorem val_one : ((1 : Ξ±Λ£) : Ξ±) = 1 := rfl #align units.coe_one Units.val_one #align add_units.coe_zero AddUnits.val_zero @[to_additive (attr := simp, norm_cast)] theorem val_eq_one {a : Ξ±Λ£} : (a : Ξ±) = 1 ↔ a = 1 := by rw [← Units.val_one, eq_iff] #align units.coe_eq_one Units.val_eq_one #align add_units.coe_eq_zero AddUnits.val_eq_zero @[to_additive (attr := simp)] theorem inv_mk (x y : Ξ±) (h₁ hβ‚‚) : (mk x y h₁ hβ‚‚)⁻¹ = mk y x hβ‚‚ h₁ := rfl #align units.inv_mk Units.inv_mk #align add_units.neg_mk AddUnits.neg_mk -- Porting note: coercions are now eagerly elaborated, so no need for `val_eq_coe` #noalign units.val_eq_coe #noalign add_units.val_eq_coe @[to_additive (attr := simp)] theorem inv_eq_val_inv : a.inv = ((a⁻¹ : Ξ±Λ£) : Ξ±) := rfl #align units.inv_eq_coe_inv Units.inv_eq_val_inv #align add_units.neg_eq_coe_neg AddUnits.neg_eq_val_neg @[to_additive (attr := simp)] theorem inv_mul : (↑a⁻¹ * a : Ξ±) = 1 := inv_val _ #align units.inv_mul Units.inv_mul #align add_units.neg_add AddUnits.neg_add @[to_additive (attr := simp)] theorem mul_inv : (a * ↑a⁻¹ : Ξ±) = 1 := val_inv _ #align units.mul_inv Units.mul_inv #align add_units.add_neg AddUnits.add_neg @[to_additive] lemma commute_coe_inv : Commute (a : Ξ±) ↑a⁻¹ := by rw [Commute, SemiconjBy, inv_mul, mul_inv] @[to_additive] lemma commute_inv_coe : Commute ↑a⁻¹ (a : Ξ±) := a.commute_coe_inv.symm @[to_additive] theorem inv_mul_of_eq {a : Ξ±} (h : ↑u = a) : ↑u⁻¹ * a = 1 := by rw [← h, u.inv_mul] #align units.inv_mul_of_eq Units.inv_mul_of_eq #align add_units.neg_add_of_eq AddUnits.neg_add_of_eq @[to_additive] theorem mul_inv_of_eq {a : Ξ±} (h : ↑u = a) : a * ↑u⁻¹ = 1 := by rw [← h, u.mul_inv] #align units.mul_inv_of_eq Units.mul_inv_of_eq #align add_units.add_neg_of_eq AddUnits.add_neg_of_eq @[to_additive (attr := simp)] theorem mul_inv_cancel_left (a : Ξ±Λ£) (b : Ξ±) : (a : Ξ±) * (↑a⁻¹ * b) = b := by rw [← mul_assoc, mul_inv, one_mul] #align units.mul_inv_cancel_left Units.mul_inv_cancel_left #align add_units.add_neg_cancel_left AddUnits.add_neg_cancel_left @[to_additive (attr := simp)] theorem inv_mul_cancel_left (a : Ξ±Λ£) (b : Ξ±) : (↑a⁻¹ : Ξ±) * (a * b) = b := by rw [← mul_assoc, inv_mul, one_mul] #align units.inv_mul_cancel_left Units.inv_mul_cancel_left #align add_units.neg_add_cancel_left AddUnits.neg_add_cancel_left @[to_additive (attr := simp)] theorem mul_inv_cancel_right (a : Ξ±) (b : Ξ±Λ£) : a * b * ↑b⁻¹ = a := by rw [mul_assoc, mul_inv, mul_one] #align units.mul_inv_cancel_right Units.mul_inv_cancel_right #align add_units.add_neg_cancel_right AddUnits.add_neg_cancel_right @[to_additive (attr := simp)]
Mathlib/Algebra/Group/Units.lean
304
305
theorem inv_mul_cancel_right (a : Ξ±) (b : Ξ±Λ£) : a * ↑b⁻¹ * b = a := by
rw [mul_assoc, inv_mul, mul_one]
import Mathlib.Analysis.Calculus.MeanValue import Mathlib.Analysis.NormedSpace.RCLike import Mathlib.Order.Filter.Curry #align_import analysis.calculus.uniform_limits_deriv from "leanprover-community/mathlib"@"3f655f5297b030a87d641ad4e825af8d9679eb0b" open Filter open scoped uniformity Filter Topology section deriv variable {ΞΉ : Type*} {l : Filter ΞΉ} {π•œ : Type*} [RCLike π•œ] {G : Type*} [NormedAddCommGroup G] [NormedSpace π•œ G] {f : ΞΉ β†’ π•œ β†’ G} {g : π•œ β†’ G} {f' : ΞΉ β†’ π•œ β†’ G} {g' : π•œ β†’ G} {x : π•œ} theorem UniformCauchySeqOnFilter.one_smulRight {l' : Filter π•œ} (hf' : UniformCauchySeqOnFilter f' l l') : UniformCauchySeqOnFilter (fun n => fun z => (1 : π•œ β†’L[π•œ] π•œ).smulRight (f' n z)) l l' := by -- The tricky part of this proof is that operator norms are written in terms of `≀` whereas -- metrics are written in terms of `<`. So we need to shrink `Ξ΅` utilizing the archimedean -- property of `ℝ` rw [SeminormedAddGroup.uniformCauchySeqOnFilter_iff_tendstoUniformlyOnFilter_zero, Metric.tendstoUniformlyOnFilter_iff] at hf' ⊒ intro Ξ΅ hΞ΅ obtain ⟨q, hq, hq'⟩ := exists_between hΞ΅.lt apply (hf' q hq).mono intro n hn refine lt_of_le_of_lt ?_ hq' simp only [dist_eq_norm, Pi.zero_apply, zero_sub, norm_neg] at hn ⊒ refine ContinuousLinearMap.opNorm_le_bound _ hq.le ?_ intro z simp only [ContinuousLinearMap.coe_sub', Pi.sub_apply, ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply] rw [← smul_sub, norm_smul, mul_comm] gcongr #align uniform_cauchy_seq_on_filter.one_smul_right UniformCauchySeqOnFilter.one_smulRight theorem uniformCauchySeqOnFilter_of_deriv (hf' : UniformCauchySeqOnFilter f' l (𝓝 x)) (hf : βˆ€αΆ  n : ΞΉ Γ— π•œ in l Γ—Λ’ 𝓝 x, HasDerivAt (f n.1) (f' n.1 n.2) n.2) (hfg : Cauchy (map (fun n => f n x) l)) : UniformCauchySeqOnFilter f l (𝓝 x) := by simp_rw [hasDerivAt_iff_hasFDerivAt] at hf exact uniformCauchySeqOnFilter_of_fderiv hf'.one_smulRight hf hfg #align uniform_cauchy_seq_on_filter_of_deriv uniformCauchySeqOnFilter_of_deriv theorem uniformCauchySeqOn_ball_of_deriv {r : ℝ} (hf' : UniformCauchySeqOn f' l (Metric.ball x r)) (hf : βˆ€ n : ΞΉ, βˆ€ y : π•œ, y ∈ Metric.ball x r β†’ HasDerivAt (f n) (f' n y) y) (hfg : Cauchy (map (fun n => f n x) l)) : UniformCauchySeqOn f l (Metric.ball x r) := by simp_rw [hasDerivAt_iff_hasFDerivAt] at hf rw [uniformCauchySeqOn_iff_uniformCauchySeqOnFilter] at hf' have hf' : UniformCauchySeqOn (fun n => fun z => (1 : π•œ β†’L[π•œ] π•œ).smulRight (f' n z)) l (Metric.ball x r) := by rw [uniformCauchySeqOn_iff_uniformCauchySeqOnFilter] exact hf'.one_smulRight exact uniformCauchySeqOn_ball_of_fderiv hf' hf hfg #align uniform_cauchy_seq_on_ball_of_deriv uniformCauchySeqOn_ball_of_deriv theorem hasDerivAt_of_tendstoUniformlyOnFilter [NeBot l] (hf' : TendstoUniformlyOnFilter f' g' l (𝓝 x)) (hf : βˆ€αΆ  n : ΞΉ Γ— π•œ in l Γ—Λ’ 𝓝 x, HasDerivAt (f n.1) (f' n.1 n.2) n.2) (hfg : βˆ€αΆ  y in 𝓝 x, Tendsto (fun n => f n y) l (𝓝 (g y))) : HasDerivAt g (g' x) x := by -- The first part of the proof rewrites `hf` and the goal to be functions so that Lean -- can recognize them when we apply `hasFDerivAt_of_tendstoUniformlyOnFilter` let F' n z := (1 : π•œ β†’L[π•œ] π•œ).smulRight (f' n z) let G' z := (1 : π•œ β†’L[π•œ] π•œ).smulRight (g' z) simp_rw [hasDerivAt_iff_hasFDerivAt] at hf ⊒ -- Now we need to rewrite hf' in terms of `ContinuousLinearMap`s. The tricky part is that -- operator norms are written in terms of `≀` whereas metrics are written in terms of `<`. So we -- need to shrink `Ξ΅` utilizing the archimedean property of `ℝ` have hf' : TendstoUniformlyOnFilter F' G' l (𝓝 x) := by rw [Metric.tendstoUniformlyOnFilter_iff] at hf' ⊒ intro Ξ΅ hΞ΅ obtain ⟨q, hq, hq'⟩ := exists_between hΞ΅.lt apply (hf' q hq).mono intro n hn refine lt_of_le_of_lt ?_ hq' simp only [dist_eq_norm] at hn ⊒ refine ContinuousLinearMap.opNorm_le_bound _ hq.le ?_ intro z simp only [F', G', ContinuousLinearMap.coe_sub', Pi.sub_apply, ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply] rw [← smul_sub, norm_smul, mul_comm] gcongr exact hasFDerivAt_of_tendstoUniformlyOnFilter hf' hf hfg #align has_deriv_at_of_tendsto_uniformly_on_filter hasDerivAt_of_tendstoUniformlyOnFilter theorem hasDerivAt_of_tendstoLocallyUniformlyOn [NeBot l] {s : Set π•œ} (hs : IsOpen s) (hf' : TendstoLocallyUniformlyOn f' g' l s) (hf : βˆ€αΆ  n in l, βˆ€ x ∈ s, HasDerivAt (f n) (f' n x) x) (hfg : βˆ€ x ∈ s, Tendsto (fun n => f n x) l (𝓝 (g x))) (hx : x ∈ s) : HasDerivAt g (g' x) x := by have h1 : s ∈ 𝓝 x := hs.mem_nhds hx have h2 : βˆ€αΆ  n : ΞΉ Γ— π•œ in l Γ—Λ’ 𝓝 x, HasDerivAt (f n.1) (f' n.1 n.2) n.2 := eventually_prod_iff.2 ⟨_, hf, fun x => x ∈ s, h1, fun {n} => id⟩ refine hasDerivAt_of_tendstoUniformlyOnFilter ?_ h2 (eventually_of_mem h1 hfg) simpa [IsOpen.nhdsWithin_eq hs hx] using tendstoLocallyUniformlyOn_iff_filter.mp hf' x hx #align has_deriv_at_of_tendsto_locally_uniformly_on hasDerivAt_of_tendstoLocallyUniformlyOn theorem hasDerivAt_of_tendsto_locally_uniformly_on' [NeBot l] {s : Set π•œ} (hs : IsOpen s) (hf' : TendstoLocallyUniformlyOn (deriv ∘ f) g' l s) (hf : βˆ€αΆ  n in l, DifferentiableOn π•œ (f n) s) (hfg : βˆ€ x ∈ s, Tendsto (fun n => f n x) l (𝓝 (g x))) (hx : x ∈ s) : HasDerivAt g (g' x) x := by refine hasDerivAt_of_tendstoLocallyUniformlyOn hs hf' ?_ hfg hx filter_upwards [hf] with n h z hz using ((h z hz).differentiableAt (hs.mem_nhds hz)).hasDerivAt #align has_deriv_at_of_tendsto_locally_uniformly_on' hasDerivAt_of_tendsto_locally_uniformly_on' theorem hasDerivAt_of_tendstoUniformlyOn [NeBot l] {s : Set π•œ} (hs : IsOpen s) (hf' : TendstoUniformlyOn f' g' l s) (hf : βˆ€αΆ  n in l, βˆ€ x : π•œ, x ∈ s β†’ HasDerivAt (f n) (f' n x) x) (hfg : βˆ€ x : π•œ, x ∈ s β†’ Tendsto (fun n => f n x) l (𝓝 (g x))) : βˆ€ x : π•œ, x ∈ s β†’ HasDerivAt g (g' x) x := fun _ => hasDerivAt_of_tendstoLocallyUniformlyOn hs hf'.tendstoLocallyUniformlyOn hf hfg #align has_deriv_at_of_tendsto_uniformly_on hasDerivAt_of_tendstoUniformlyOn
Mathlib/Analysis/Calculus/UniformLimitsDeriv.lean
556
564
theorem hasDerivAt_of_tendstoUniformly [NeBot l] (hf' : TendstoUniformly f' g' l) (hf : βˆ€αΆ  n in l, βˆ€ x : π•œ, HasDerivAt (f n) (f' n x) x) (hfg : βˆ€ x : π•œ, Tendsto (fun n => f n x) l (𝓝 (g x))) : βˆ€ x : π•œ, HasDerivAt g (g' x) x := by
intro x have hf : βˆ€αΆ  n in l, βˆ€ x : π•œ, x ∈ Set.univ β†’ HasDerivAt (f n) (f' n x) x := by filter_upwards [hf] with n h x _ using h x have hfg : βˆ€ x : π•œ, x ∈ Set.univ β†’ Tendsto (fun n => f n x) l (𝓝 (g x)) := by simp [hfg] have hf' : TendstoUniformlyOn f' g' l Set.univ := by rwa [tendstoUniformlyOn_univ] exact hasDerivAt_of_tendstoUniformlyOn isOpen_univ hf' hf hfg x (Set.mem_univ x)
import Mathlib.Algebra.BigOperators.NatAntidiagonal import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Data.Nat.Choose.Sum import Mathlib.RingTheory.PowerSeries.Basic #align_import ring_theory.power_series.well_known from "leanprover-community/mathlib"@"8199f6717c150a7fe91c4534175f4cf99725978f" namespace PowerSeries section invOneSubPow variable {S : Type*} [CommRing S] (d : β„•) theorem mk_one_mul_one_sub_eq_one : (mk 1 : S⟦X⟧) * (1 - X) = 1 := by rw [mul_comm, ext_iff] intro n cases n with | zero => simp | succ n => simp [sub_mul] theorem mk_one_pow_eq_mk_choose_add : (mk 1 : S⟦X⟧) ^ (d + 1) = (mk fun n => Nat.choose (d + n) d : S⟦X⟧) := by induction d with | zero => ext; simp | succ d hd => ext n rw [pow_add, hd, pow_one, mul_comm, coeff_mul] simp_rw [coeff_mk, Pi.one_apply, one_mul] norm_cast rw [Finset.sum_antidiagonal_choose_add, ← Nat.choose_succ_succ, Nat.succ_eq_add_one, add_right_comm] noncomputable def invOneSubPow : S⟦X⟧ˣ where val := mk fun n => Nat.choose (d + n) d inv := (1 - X) ^ (d + 1) val_inv := by rw [← mk_one_pow_eq_mk_choose_add, ← mul_pow, mk_one_mul_one_sub_eq_one, one_pow] inv_val := by rw [← mk_one_pow_eq_mk_choose_add, ← mul_pow, mul_comm, mk_one_mul_one_sub_eq_one, one_pow] theorem invOneSubPow_val_eq_mk_choose_add : (invOneSubPow d).val = (mk fun n => Nat.choose (d + n) d : S⟦X⟧) := rfl
Mathlib/RingTheory/PowerSeries/WellKnown.lean
123
125
theorem invOneSubPow_val_zero_eq_invUnitSub_one : (invOneSubPow 0).val = invUnitsSub (1 : SΛ£) := by
simp [invOneSubPow, invUnitsSub]
import Mathlib.Algebra.Order.CauSeq.BigOperators import Mathlib.Data.Complex.Abs import Mathlib.Data.Complex.BigOperators import Mathlib.Data.Nat.Choose.Sum #align_import data.complex.exponential from "leanprover-community/mathlib"@"a8b2226cfb0a79f5986492053fc49b1a0c6aeffb" open CauSeq Finset IsAbsoluteValue open scoped Classical ComplexConjugate namespace Complex variable (x y : β„‚) @[simp] theorem exp_zero : exp 0 = 1 := by rw [exp] refine lim_eq_of_equiv_const fun Ξ΅ Ξ΅0 => ⟨1, fun j hj => ?_⟩ convert (config := .unfoldSameFun) Ξ΅0 -- Porting note: Ξ΅0 : Ξ΅ > 0 but goal is _ < Ξ΅ cases' j with j j Β· exact absurd hj (not_le_of_gt zero_lt_one) Β· dsimp [exp'] induction' j with j ih Β· dsimp [exp']; simp [show Nat.succ 0 = 1 from rfl] Β· rw [← ih (by simp [Nat.succ_le_succ])] simp only [sum_range_succ, pow_succ] simp #align complex.exp_zero Complex.exp_zero theorem exp_add : exp (x + y) = exp x * exp y := by have hj : βˆ€ j : β„•, (βˆ‘ m ∈ range j, (x + y) ^ m / m.factorial) = βˆ‘ i ∈ range j, βˆ‘ k ∈ range (i + 1), x ^ k / k.factorial * (y ^ (i - k) / (i - k).factorial) := by intro j refine Finset.sum_congr rfl fun m _ => ?_ rw [add_pow, div_eq_mul_inv, sum_mul] refine Finset.sum_congr rfl fun I hi => ?_ have h₁ : (m.choose I : β„‚) β‰  0 := Nat.cast_ne_zero.2 (pos_iff_ne_zero.1 (Nat.choose_pos (Nat.le_of_lt_succ (mem_range.1 hi)))) have hβ‚‚ := Nat.choose_mul_factorial_mul_factorial (Nat.le_of_lt_succ <| Finset.mem_range.1 hi) rw [← hβ‚‚, Nat.cast_mul, Nat.cast_mul, mul_inv, mul_inv] simp only [mul_left_comm (m.choose I : β„‚), mul_assoc, mul_left_comm (m.choose I : β„‚)⁻¹, mul_comm (m.choose I : β„‚)] rw [inv_mul_cancel h₁] simp [div_eq_mul_inv, mul_comm, mul_assoc, mul_left_comm] simp_rw [exp, exp', lim_mul_lim] apply (lim_eq_lim_of_equiv _).symm simp only [hj] exact cauchy_product (isCauSeq_abs_exp x) (isCauSeq_exp y) #align complex.exp_add Complex.exp_add -- Porting note (#11445): new definition noncomputable def expMonoidHom : MonoidHom (Multiplicative β„‚) β„‚ := { toFun := fun z => exp (Multiplicative.toAdd z), map_one' := by simp, map_mul' := by simp [exp_add] } theorem exp_list_sum (l : List β„‚) : exp l.sum = (l.map exp).prod := map_list_prod (M := Multiplicative β„‚) expMonoidHom l #align complex.exp_list_sum Complex.exp_list_sum theorem exp_multiset_sum (s : Multiset β„‚) : exp s.sum = (s.map exp).prod := @MonoidHom.map_multiset_prod (Multiplicative β„‚) β„‚ _ _ expMonoidHom s #align complex.exp_multiset_sum Complex.exp_multiset_sum theorem exp_sum {Ξ± : Type*} (s : Finset Ξ±) (f : Ξ± β†’ β„‚) : exp (βˆ‘ x ∈ s, f x) = ∏ x ∈ s, exp (f x) := map_prod (Ξ² := Multiplicative β„‚) expMonoidHom f s #align complex.exp_sum Complex.exp_sum lemma exp_nsmul (x : β„‚) (n : β„•) : exp (n β€’ x) = exp x ^ n := @MonoidHom.map_pow (Multiplicative β„‚) β„‚ _ _ expMonoidHom _ _ theorem exp_nat_mul (x : β„‚) : βˆ€ n : β„•, exp (n * x) = exp x ^ n | 0 => by rw [Nat.cast_zero, zero_mul, exp_zero, pow_zero] | Nat.succ n => by rw [pow_succ, Nat.cast_add_one, add_mul, exp_add, ← exp_nat_mul _ n, one_mul] #align complex.exp_nat_mul Complex.exp_nat_mul theorem exp_ne_zero : exp x β‰  0 := fun h => zero_ne_one <| by rw [← exp_zero, ← add_neg_self x, exp_add, h]; simp #align complex.exp_ne_zero Complex.exp_ne_zero theorem exp_neg : exp (-x) = (exp x)⁻¹ := by rw [← mul_right_inj' (exp_ne_zero x), ← exp_add]; simp [mul_inv_cancel (exp_ne_zero x)] #align complex.exp_neg Complex.exp_neg theorem exp_sub : exp (x - y) = exp x / exp y := by simp [sub_eq_add_neg, exp_add, exp_neg, div_eq_mul_inv] #align complex.exp_sub Complex.exp_sub theorem exp_int_mul (z : β„‚) (n : β„€) : Complex.exp (n * z) = Complex.exp z ^ n := by cases n Β· simp [exp_nat_mul] Β· simp [exp_add, add_mul, pow_add, exp_neg, exp_nat_mul] #align complex.exp_int_mul Complex.exp_int_mul @[simp] theorem exp_conj : exp (conj x) = conj (exp x) := by dsimp [exp] rw [← lim_conj] refine congr_arg CauSeq.lim (CauSeq.ext fun _ => ?_) dsimp [exp', Function.comp_def, cauSeqConj] rw [map_sum (starRingEnd _)] refine sum_congr rfl fun n _ => ?_ rw [map_divβ‚€, map_pow, ← ofReal_natCast, conj_ofReal] #align complex.exp_conj Complex.exp_conj @[simp] theorem ofReal_exp_ofReal_re (x : ℝ) : ((exp x).re : β„‚) = exp x := conj_eq_iff_re.1 <| by rw [← exp_conj, conj_ofReal] #align complex.of_real_exp_of_real_re Complex.ofReal_exp_ofReal_re @[simp, norm_cast] theorem ofReal_exp (x : ℝ) : (Real.exp x : β„‚) = exp x := ofReal_exp_ofReal_re _ #align complex.of_real_exp Complex.ofReal_exp @[simp] theorem exp_ofReal_im (x : ℝ) : (exp x).im = 0 := by rw [← ofReal_exp_ofReal_re, ofReal_im] #align complex.exp_of_real_im Complex.exp_ofReal_im theorem exp_ofReal_re (x : ℝ) : (exp x).re = Real.exp x := rfl #align complex.exp_of_real_re Complex.exp_ofReal_re theorem two_sinh : 2 * sinh x = exp x - exp (-x) := mul_div_cancelβ‚€ _ two_ne_zero #align complex.two_sinh Complex.two_sinh theorem two_cosh : 2 * cosh x = exp x + exp (-x) := mul_div_cancelβ‚€ _ two_ne_zero #align complex.two_cosh Complex.two_cosh @[simp] theorem sinh_zero : sinh 0 = 0 := by simp [sinh] #align complex.sinh_zero Complex.sinh_zero @[simp] theorem sinh_neg : sinh (-x) = -sinh x := by simp [sinh, exp_neg, (neg_div _ _).symm, add_mul] #align complex.sinh_neg Complex.sinh_neg private theorem sinh_add_aux {a b c d : β„‚} : (a - b) * (c + d) + (a + b) * (c - d) = 2 * (a * c - b * d) := by ring theorem sinh_add : sinh (x + y) = sinh x * cosh y + cosh x * sinh y := by rw [← mul_right_inj' (two_ne_zero' β„‚), two_sinh, exp_add, neg_add, exp_add, eq_comm, mul_add, ← mul_assoc, two_sinh, mul_left_comm, two_sinh, ← mul_right_inj' (two_ne_zero' β„‚), mul_add, mul_left_comm, two_cosh, ← mul_assoc, two_cosh] exact sinh_add_aux #align complex.sinh_add Complex.sinh_add @[simp] theorem cosh_zero : cosh 0 = 1 := by simp [cosh] #align complex.cosh_zero Complex.cosh_zero @[simp] theorem cosh_neg : cosh (-x) = cosh x := by simp [add_comm, cosh, exp_neg] #align complex.cosh_neg Complex.cosh_neg private theorem cosh_add_aux {a b c d : β„‚} : (a + b) * (c + d) + (a - b) * (c - d) = 2 * (a * c + b * d) := by ring theorem cosh_add : cosh (x + y) = cosh x * cosh y + sinh x * sinh y := by rw [← mul_right_inj' (two_ne_zero' β„‚), two_cosh, exp_add, neg_add, exp_add, eq_comm, mul_add, ← mul_assoc, two_cosh, ← mul_assoc, two_sinh, ← mul_right_inj' (two_ne_zero' β„‚), mul_add, mul_left_comm, two_cosh, mul_left_comm, two_sinh] exact cosh_add_aux #align complex.cosh_add Complex.cosh_add theorem sinh_sub : sinh (x - y) = sinh x * cosh y - cosh x * sinh y := by simp [sub_eq_add_neg, sinh_add, sinh_neg, cosh_neg] #align complex.sinh_sub Complex.sinh_sub theorem cosh_sub : cosh (x - y) = cosh x * cosh y - sinh x * sinh y := by simp [sub_eq_add_neg, cosh_add, sinh_neg, cosh_neg] #align complex.cosh_sub Complex.cosh_sub theorem sinh_conj : sinh (conj x) = conj (sinh x) := by rw [sinh, ← RingHom.map_neg, exp_conj, exp_conj, ← RingHom.map_sub, sinh, map_divβ‚€] -- Porting note: not nice simp [← one_add_one_eq_two] #align complex.sinh_conj Complex.sinh_conj @[simp] theorem ofReal_sinh_ofReal_re (x : ℝ) : ((sinh x).re : β„‚) = sinh x := conj_eq_iff_re.1 <| by rw [← sinh_conj, conj_ofReal] #align complex.of_real_sinh_of_real_re Complex.ofReal_sinh_ofReal_re @[simp, norm_cast] theorem ofReal_sinh (x : ℝ) : (Real.sinh x : β„‚) = sinh x := ofReal_sinh_ofReal_re _ #align complex.of_real_sinh Complex.ofReal_sinh @[simp] theorem sinh_ofReal_im (x : ℝ) : (sinh x).im = 0 := by rw [← ofReal_sinh_ofReal_re, ofReal_im] #align complex.sinh_of_real_im Complex.sinh_ofReal_im theorem sinh_ofReal_re (x : ℝ) : (sinh x).re = Real.sinh x := rfl #align complex.sinh_of_real_re Complex.sinh_ofReal_re theorem cosh_conj : cosh (conj x) = conj (cosh x) := by rw [cosh, ← RingHom.map_neg, exp_conj, exp_conj, ← RingHom.map_add, cosh, map_divβ‚€] -- Porting note: not nice simp [← one_add_one_eq_two] #align complex.cosh_conj Complex.cosh_conj theorem ofReal_cosh_ofReal_re (x : ℝ) : ((cosh x).re : β„‚) = cosh x := conj_eq_iff_re.1 <| by rw [← cosh_conj, conj_ofReal] #align complex.of_real_cosh_of_real_re Complex.ofReal_cosh_ofReal_re @[simp, norm_cast] theorem ofReal_cosh (x : ℝ) : (Real.cosh x : β„‚) = cosh x := ofReal_cosh_ofReal_re _ #align complex.of_real_cosh Complex.ofReal_cosh @[simp] theorem cosh_ofReal_im (x : ℝ) : (cosh x).im = 0 := by rw [← ofReal_cosh_ofReal_re, ofReal_im] #align complex.cosh_of_real_im Complex.cosh_ofReal_im @[simp] theorem cosh_ofReal_re (x : ℝ) : (cosh x).re = Real.cosh x := rfl #align complex.cosh_of_real_re Complex.cosh_ofReal_re theorem tanh_eq_sinh_div_cosh : tanh x = sinh x / cosh x := rfl #align complex.tanh_eq_sinh_div_cosh Complex.tanh_eq_sinh_div_cosh @[simp] theorem tanh_zero : tanh 0 = 0 := by simp [tanh] #align complex.tanh_zero Complex.tanh_zero @[simp] theorem tanh_neg : tanh (-x) = -tanh x := by simp [tanh, neg_div] #align complex.tanh_neg Complex.tanh_neg theorem tanh_conj : tanh (conj x) = conj (tanh x) := by rw [tanh, sinh_conj, cosh_conj, ← map_divβ‚€, tanh] #align complex.tanh_conj Complex.tanh_conj @[simp] theorem ofReal_tanh_ofReal_re (x : ℝ) : ((tanh x).re : β„‚) = tanh x := conj_eq_iff_re.1 <| by rw [← tanh_conj, conj_ofReal] #align complex.of_real_tanh_of_real_re Complex.ofReal_tanh_ofReal_re @[simp, norm_cast] theorem ofReal_tanh (x : ℝ) : (Real.tanh x : β„‚) = tanh x := ofReal_tanh_ofReal_re _ #align complex.of_real_tanh Complex.ofReal_tanh @[simp] theorem tanh_ofReal_im (x : ℝ) : (tanh x).im = 0 := by rw [← ofReal_tanh_ofReal_re, ofReal_im] #align complex.tanh_of_real_im Complex.tanh_ofReal_im theorem tanh_ofReal_re (x : ℝ) : (tanh x).re = Real.tanh x := rfl #align complex.tanh_of_real_re Complex.tanh_ofReal_re @[simp] theorem cosh_add_sinh : cosh x + sinh x = exp x := by rw [← mul_right_inj' (two_ne_zero' β„‚), mul_add, two_cosh, two_sinh, add_add_sub_cancel, two_mul] #align complex.cosh_add_sinh Complex.cosh_add_sinh @[simp] theorem sinh_add_cosh : sinh x + cosh x = exp x := by rw [add_comm, cosh_add_sinh] #align complex.sinh_add_cosh Complex.sinh_add_cosh @[simp] theorem exp_sub_cosh : exp x - cosh x = sinh x := sub_eq_iff_eq_add.2 (sinh_add_cosh x).symm #align complex.exp_sub_cosh Complex.exp_sub_cosh @[simp] theorem exp_sub_sinh : exp x - sinh x = cosh x := sub_eq_iff_eq_add.2 (cosh_add_sinh x).symm #align complex.exp_sub_sinh Complex.exp_sub_sinh @[simp] theorem cosh_sub_sinh : cosh x - sinh x = exp (-x) := by rw [← mul_right_inj' (two_ne_zero' β„‚), mul_sub, two_cosh, two_sinh, add_sub_sub_cancel, two_mul] #align complex.cosh_sub_sinh Complex.cosh_sub_sinh @[simp] theorem sinh_sub_cosh : sinh x - cosh x = -exp (-x) := by rw [← neg_sub, cosh_sub_sinh] #align complex.sinh_sub_cosh Complex.sinh_sub_cosh @[simp] theorem cosh_sq_sub_sinh_sq : cosh x ^ 2 - sinh x ^ 2 = 1 := by rw [sq_sub_sq, cosh_add_sinh, cosh_sub_sinh, ← exp_add, add_neg_self, exp_zero] #align complex.cosh_sq_sub_sinh_sq Complex.cosh_sq_sub_sinh_sq theorem cosh_sq : cosh x ^ 2 = sinh x ^ 2 + 1 := by rw [← cosh_sq_sub_sinh_sq x] ring #align complex.cosh_sq Complex.cosh_sq
Mathlib/Data/Complex/Exponential.lean
453
455
theorem sinh_sq : sinh x ^ 2 = cosh x ^ 2 - 1 := by
rw [← cosh_sq_sub_sinh_sq x] ring