Context
stringlengths
57
85k
file_name
stringlengths
21
79
start
int64
14
2.42k
end
int64
18
2.43k
theorem
stringlengths
25
2.71k
proof
stringlengths
5
10.6k
import Mathlib.Analysis.InnerProductSpace.PiL2 import Mathlib.LinearAlgebra.Matrix.Block #align_import analysis.inner_product_space.gram_schmidt_ortho from "leanprover-community/mathlib"@"1a4df69ca1a9a0e5e26bfe12e2b92814216016d0" open Finset Submodule FiniteDimensional variable (𝕜 : Type*) {E : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] variable {ι : Type*} [LinearOrder ι] [LocallyFiniteOrderBot ι] [IsWellOrder ι (· < ·)] attribute [local instance] IsWellOrder.toHasWellFounded local notation "⟪" x ", " y "⟫" => @inner 𝕜 _ _ x y noncomputable def gramSchmidt [IsWellOrder ι (· < ·)] (f : ι → E) (n : ι) : E := f n - ∑ i : Iio n, orthogonalProjection (𝕜 ∙ gramSchmidt f i) (f n) termination_by n decreasing_by exact mem_Iio.1 i.2 #align gram_schmidt gramSchmidt theorem gramSchmidt_def (f : ι → E) (n : ι) : gramSchmidt 𝕜 f n = f n - ∑ i ∈ Iio n, orthogonalProjection (𝕜 ∙ gramSchmidt 𝕜 f i) (f n) := by rw [← sum_attach, attach_eq_univ, gramSchmidt] #align gram_schmidt_def gramSchmidt_def theorem gramSchmidt_def' (f : ι → E) (n : ι) : f n = gramSchmidt 𝕜 f n + ∑ i ∈ Iio n, orthogonalProjection (𝕜 ∙ gramSchmidt 𝕜 f i) (f n) := by rw [gramSchmidt_def, sub_add_cancel] #align gram_schmidt_def' gramSchmidt_def' theorem gramSchmidt_def'' (f : ι → E) (n : ι) : f n = gramSchmidt 𝕜 f n + ∑ i ∈ Iio n, (⟪gramSchmidt 𝕜 f i, f n⟫ / (‖gramSchmidt 𝕜 f i‖ : 𝕜) ^ 2) • gramSchmidt 𝕜 f i := by convert gramSchmidt_def' 𝕜 f n rw [orthogonalProjection_singleton, RCLike.ofReal_pow] #align gram_schmidt_def'' gramSchmidt_def'' @[simp] theorem gramSchmidt_zero {ι : Type*} [LinearOrder ι] [LocallyFiniteOrder ι] [OrderBot ι] [IsWellOrder ι (· < ·)] (f : ι → E) : gramSchmidt 𝕜 f ⊥ = f ⊥ := by rw [gramSchmidt_def, Iio_eq_Ico, Finset.Ico_self, Finset.sum_empty, sub_zero] #align gram_schmidt_zero gramSchmidt_zero theorem gramSchmidt_orthogonal (f : ι → E) {a b : ι} (h₀ : a ≠ b) : ⟪gramSchmidt 𝕜 f a, gramSchmidt 𝕜 f b⟫ = 0 := by suffices ∀ a b : ι, a < b → ⟪gramSchmidt 𝕜 f a, gramSchmidt 𝕜 f b⟫ = 0 by cases' h₀.lt_or_lt with ha hb · exact this _ _ ha · rw [inner_eq_zero_symm] exact this _ _ hb clear h₀ a b intro a b h₀ revert a apply wellFounded_lt.induction b intro b ih a h₀ simp only [gramSchmidt_def 𝕜 f b, inner_sub_right, inner_sum, orthogonalProjection_singleton, inner_smul_right] rw [Finset.sum_eq_single_of_mem a (Finset.mem_Iio.mpr h₀)] · by_cases h : gramSchmidt 𝕜 f a = 0 · simp only [h, inner_zero_left, zero_div, zero_mul, sub_zero] · rw [RCLike.ofReal_pow, ← inner_self_eq_norm_sq_to_K, div_mul_cancel₀, sub_self] rwa [inner_self_ne_zero] intro i hi hia simp only [mul_eq_zero, div_eq_zero_iff, inner_self_eq_zero] right cases' hia.lt_or_lt with hia₁ hia₂ · rw [inner_eq_zero_symm] exact ih a h₀ i hia₁ · exact ih i (mem_Iio.1 hi) a hia₂ #align gram_schmidt_orthogonal gramSchmidt_orthogonal theorem gramSchmidt_pairwise_orthogonal (f : ι → E) : Pairwise fun a b => ⟪gramSchmidt 𝕜 f a, gramSchmidt 𝕜 f b⟫ = 0 := fun _ _ => gramSchmidt_orthogonal 𝕜 f #align gram_schmidt_pairwise_orthogonal gramSchmidt_pairwise_orthogonal theorem gramSchmidt_inv_triangular (v : ι → E) {i j : ι} (hij : i < j) : ⟪gramSchmidt 𝕜 v j, v i⟫ = 0 := by rw [gramSchmidt_def'' 𝕜 v] simp only [inner_add_right, inner_sum, inner_smul_right] set b : ι → E := gramSchmidt 𝕜 v convert zero_add (0 : 𝕜) · exact gramSchmidt_orthogonal 𝕜 v hij.ne' apply Finset.sum_eq_zero rintro k hki' have hki : k < i := by simpa using hki' have : ⟪b j, b k⟫ = 0 := gramSchmidt_orthogonal 𝕜 v (hki.trans hij).ne' simp [this] #align gram_schmidt_inv_triangular gramSchmidt_inv_triangular open Submodule Set Order theorem mem_span_gramSchmidt (f : ι → E) {i j : ι} (hij : i ≤ j) : f i ∈ span 𝕜 (gramSchmidt 𝕜 f '' Set.Iic j) := by rw [gramSchmidt_def' 𝕜 f i] simp_rw [orthogonalProjection_singleton] exact Submodule.add_mem _ (subset_span <| mem_image_of_mem _ hij) (Submodule.sum_mem _ fun k hk => smul_mem (span 𝕜 (gramSchmidt 𝕜 f '' Set.Iic j)) _ <| subset_span <| mem_image_of_mem (gramSchmidt 𝕜 f) <| (Finset.mem_Iio.1 hk).le.trans hij) #align mem_span_gram_schmidt mem_span_gramSchmidt theorem gramSchmidt_mem_span (f : ι → E) : ∀ {j i}, i ≤ j → gramSchmidt 𝕜 f i ∈ span 𝕜 (f '' Set.Iic j) := by intro j i hij rw [gramSchmidt_def 𝕜 f i] simp_rw [orthogonalProjection_singleton] refine Submodule.sub_mem _ (subset_span (mem_image_of_mem _ hij)) (Submodule.sum_mem _ fun k hk => ?_) let hkj : k < j := (Finset.mem_Iio.1 hk).trans_le hij exact smul_mem _ _ (span_mono (image_subset f <| Iic_subset_Iic.2 hkj.le) <| gramSchmidt_mem_span _ le_rfl) termination_by j => j #align gram_schmidt_mem_span gramSchmidt_mem_span theorem span_gramSchmidt_Iic (f : ι → E) (c : ι) : span 𝕜 (gramSchmidt 𝕜 f '' Set.Iic c) = span 𝕜 (f '' Set.Iic c) := span_eq_span (Set.image_subset_iff.2 fun _ => gramSchmidt_mem_span _ _) <| Set.image_subset_iff.2 fun _ => mem_span_gramSchmidt _ _ #align span_gram_schmidt_Iic span_gramSchmidt_Iic theorem span_gramSchmidt_Iio (f : ι → E) (c : ι) : span 𝕜 (gramSchmidt 𝕜 f '' Set.Iio c) = span 𝕜 (f '' Set.Iio c) := span_eq_span (Set.image_subset_iff.2 fun _ hi => span_mono (image_subset _ <| Iic_subset_Iio.2 hi) <| gramSchmidt_mem_span _ _ le_rfl) <| Set.image_subset_iff.2 fun _ hi => span_mono (image_subset _ <| Iic_subset_Iio.2 hi) <| mem_span_gramSchmidt _ _ le_rfl #align span_gram_schmidt_Iio span_gramSchmidt_Iio theorem span_gramSchmidt (f : ι → E) : span 𝕜 (range (gramSchmidt 𝕜 f)) = span 𝕜 (range f) := span_eq_span (range_subset_iff.2 fun _ => span_mono (image_subset_range _ _) <| gramSchmidt_mem_span _ _ le_rfl) <| range_subset_iff.2 fun _ => span_mono (image_subset_range _ _) <| mem_span_gramSchmidt _ _ le_rfl #align span_gram_schmidt span_gramSchmidt theorem gramSchmidt_of_orthogonal {f : ι → E} (hf : Pairwise fun i j => ⟪f i, f j⟫ = 0) : gramSchmidt 𝕜 f = f := by ext i rw [gramSchmidt_def] trans f i - 0 · congr apply Finset.sum_eq_zero intro j hj rw [Submodule.coe_eq_zero] suffices span 𝕜 (f '' Set.Iic j) ⟂ 𝕜 ∙ f i by apply orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero rw [mem_orthogonal_singleton_iff_inner_left] rw [← mem_orthogonal_singleton_iff_inner_right] exact this (gramSchmidt_mem_span 𝕜 f (le_refl j)) rw [isOrtho_span] rintro u ⟨k, hk, rfl⟩ v (rfl : v = f i) apply hf exact (lt_of_le_of_lt hk (Finset.mem_Iio.mp hj)).ne · simp #align gram_schmidt_of_orthogonal gramSchmidt_of_orthogonal variable {𝕜} theorem gramSchmidt_ne_zero_coe {f : ι → E} (n : ι) (h₀ : LinearIndependent 𝕜 (f ∘ ((↑) : Set.Iic n → ι))) : gramSchmidt 𝕜 f n ≠ 0 := by by_contra h have h₁ : f n ∈ span 𝕜 (f '' Set.Iio n) := by rw [← span_gramSchmidt_Iio 𝕜 f n, gramSchmidt_def' 𝕜 f, h, zero_add] apply Submodule.sum_mem _ _ intro a ha simp only [Set.mem_image, Set.mem_Iio, orthogonalProjection_singleton] apply Submodule.smul_mem _ _ _ rw [Finset.mem_Iio] at ha exact subset_span ⟨a, ha, by rfl⟩ have h₂ : (f ∘ ((↑) : Set.Iic n → ι)) ⟨n, le_refl n⟩ ∈ span 𝕜 (f ∘ ((↑) : Set.Iic n → ι) '' Set.Iio ⟨n, le_refl n⟩) := by rw [image_comp] simpa using h₁ apply LinearIndependent.not_mem_span_image h₀ _ h₂ simp only [Set.mem_Iio, lt_self_iff_false, not_false_iff] #align gram_schmidt_ne_zero_coe gramSchmidt_ne_zero_coe theorem gramSchmidt_ne_zero {f : ι → E} (n : ι) (h₀ : LinearIndependent 𝕜 f) : gramSchmidt 𝕜 f n ≠ 0 := gramSchmidt_ne_zero_coe _ (LinearIndependent.comp h₀ _ Subtype.coe_injective) #align gram_schmidt_ne_zero gramSchmidt_ne_zero theorem gramSchmidt_triangular {i j : ι} (hij : i < j) (b : Basis ι 𝕜 E) : b.repr (gramSchmidt 𝕜 b i) j = 0 := by have : gramSchmidt 𝕜 b i ∈ span 𝕜 (gramSchmidt 𝕜 b '' Set.Iio j) := subset_span ((Set.mem_image _ _ _).2 ⟨i, hij, rfl⟩) have : gramSchmidt 𝕜 b i ∈ span 𝕜 (b '' Set.Iio j) := by rwa [← span_gramSchmidt_Iio 𝕜 b j] have : ↑(b.repr (gramSchmidt 𝕜 b i)).support ⊆ Set.Iio j := Basis.repr_support_subset_of_mem_span b (Set.Iio j) this exact (Finsupp.mem_supported' _ _).1 ((Finsupp.mem_supported 𝕜 _).2 this) j Set.not_mem_Iio_self #align gram_schmidt_triangular gramSchmidt_triangular theorem gramSchmidt_linearIndependent {f : ι → E} (h₀ : LinearIndependent 𝕜 f) : LinearIndependent 𝕜 (gramSchmidt 𝕜 f) := linearIndependent_of_ne_zero_of_inner_eq_zero (fun _ => gramSchmidt_ne_zero _ h₀) fun _ _ => gramSchmidt_orthogonal 𝕜 f #align gram_schmidt_linear_independent gramSchmidt_linearIndependent noncomputable def gramSchmidtBasis (b : Basis ι 𝕜 E) : Basis ι 𝕜 E := Basis.mk (gramSchmidt_linearIndependent b.linearIndependent) ((span_gramSchmidt 𝕜 b).trans b.span_eq).ge #align gram_schmidt_basis gramSchmidtBasis theorem coe_gramSchmidtBasis (b : Basis ι 𝕜 E) : (gramSchmidtBasis b : ι → E) = gramSchmidt 𝕜 b := Basis.coe_mk _ _ #align coe_gram_schmidt_basis coe_gramSchmidtBasis variable (𝕜) noncomputable def gramSchmidtNormed (f : ι → E) (n : ι) : E := (‖gramSchmidt 𝕜 f n‖ : 𝕜)⁻¹ • gramSchmidt 𝕜 f n #align gram_schmidt_normed gramSchmidtNormed variable {𝕜} theorem gramSchmidtNormed_unit_length_coe {f : ι → E} (n : ι) (h₀ : LinearIndependent 𝕜 (f ∘ ((↑) : Set.Iic n → ι))) : ‖gramSchmidtNormed 𝕜 f n‖ = 1 := by simp only [gramSchmidt_ne_zero_coe n h₀, gramSchmidtNormed, norm_smul_inv_norm, Ne, not_false_iff] #align gram_schmidt_normed_unit_length_coe gramSchmidtNormed_unit_length_coe theorem gramSchmidtNormed_unit_length {f : ι → E} (n : ι) (h₀ : LinearIndependent 𝕜 f) : ‖gramSchmidtNormed 𝕜 f n‖ = 1 := gramSchmidtNormed_unit_length_coe _ (LinearIndependent.comp h₀ _ Subtype.coe_injective) #align gram_schmidt_normed_unit_length gramSchmidtNormed_unit_length theorem gramSchmidtNormed_unit_length' {f : ι → E} {n : ι} (hn : gramSchmidtNormed 𝕜 f n ≠ 0) : ‖gramSchmidtNormed 𝕜 f n‖ = 1 := by rw [gramSchmidtNormed] at * rw [norm_smul_inv_norm] simpa using hn #align gram_schmidt_normed_unit_length' gramSchmidtNormed_unit_length' theorem gramSchmidt_orthonormal {f : ι → E} (h₀ : LinearIndependent 𝕜 f) : Orthonormal 𝕜 (gramSchmidtNormed 𝕜 f) := by unfold Orthonormal constructor · simp only [gramSchmidtNormed_unit_length, h₀, eq_self_iff_true, imp_true_iff] · intro i j hij simp only [gramSchmidtNormed, inner_smul_left, inner_smul_right, RCLike.conj_inv, RCLike.conj_ofReal, mul_eq_zero, inv_eq_zero, RCLike.ofReal_eq_zero, norm_eq_zero] repeat' right exact gramSchmidt_orthogonal 𝕜 f hij #align gram_schmidt_orthonormal gramSchmidt_orthonormal theorem gramSchmidt_orthonormal' (f : ι → E) : Orthonormal 𝕜 fun i : { i | gramSchmidtNormed 𝕜 f i ≠ 0 } => gramSchmidtNormed 𝕜 f i := by refine ⟨fun i => gramSchmidtNormed_unit_length' i.prop, ?_⟩ rintro i j (hij : ¬_) rw [Subtype.ext_iff] at hij simp [gramSchmidtNormed, inner_smul_left, inner_smul_right, gramSchmidt_orthogonal 𝕜 f hij] #align gram_schmidt_orthonormal' gramSchmidt_orthonormal' theorem span_gramSchmidtNormed (f : ι → E) (s : Set ι) : span 𝕜 (gramSchmidtNormed 𝕜 f '' s) = span 𝕜 (gramSchmidt 𝕜 f '' s) := by refine span_eq_span (Set.image_subset_iff.2 fun i hi => smul_mem _ _ <| subset_span <| mem_image_of_mem _ hi) (Set.image_subset_iff.2 fun i hi => span_mono (image_subset _ <| singleton_subset_set_iff.2 hi) ?_) simp only [coe_singleton, Set.image_singleton] by_cases h : gramSchmidt 𝕜 f i = 0 · simp [h] · refine mem_span_singleton.2 ⟨‖gramSchmidt 𝕜 f i‖, smul_inv_smul₀ ?_ _⟩ exact mod_cast norm_ne_zero_iff.2 h #align span_gram_schmidt_normed span_gramSchmidtNormed
Mathlib/Analysis/InnerProductSpace/GramSchmidtOrtho.lean
321
323
theorem span_gramSchmidtNormed_range (f : ι → E) : span 𝕜 (range (gramSchmidtNormed 𝕜 f)) = span 𝕜 (range (gramSchmidt 𝕜 f)) := by
simpa only [image_univ.symm] using span_gramSchmidtNormed f univ
import Mathlib.Algebra.Group.Basic import Mathlib.Algebra.Group.Pi.Basic import Mathlib.Order.Fin import Mathlib.Order.PiLex import Mathlib.Order.Interval.Set.Basic #align_import data.fin.tuple.basic from "leanprover-community/mathlib"@"ef997baa41b5c428be3fb50089a7139bf4ee886b" assert_not_exists MonoidWithZero universe u v namespace Fin variable {m n : ℕ} open Function section Tuple example (α : Fin 0 → Sort u) : Unique (∀ i : Fin 0, α i) := by infer_instance theorem tuple0_le {α : Fin 0 → Type*} [∀ i, Preorder (α i)] (f g : ∀ i, α i) : f ≤ g := finZeroElim #align fin.tuple0_le Fin.tuple0_le variable {α : Fin (n + 1) → Type u} (x : α 0) (q : ∀ i, α i) (p : ∀ i : Fin n, α i.succ) (i : Fin n) (y : α i.succ) (z : α 0) def tail (q : ∀ i, α i) : ∀ i : Fin n, α i.succ := fun i ↦ q i.succ #align fin.tail Fin.tail theorem tail_def {n : ℕ} {α : Fin (n + 1) → Type*} {q : ∀ i, α i} : (tail fun k : Fin (n + 1) ↦ q k) = fun k : Fin n ↦ q k.succ := rfl #align fin.tail_def Fin.tail_def def cons (x : α 0) (p : ∀ i : Fin n, α i.succ) : ∀ i, α i := fun j ↦ Fin.cases x p j #align fin.cons Fin.cons @[simp] theorem tail_cons : tail (cons x p) = p := by simp (config := { unfoldPartialApp := true }) [tail, cons] #align fin.tail_cons Fin.tail_cons @[simp] theorem cons_succ : cons x p i.succ = p i := by simp [cons] #align fin.cons_succ Fin.cons_succ @[simp] theorem cons_zero : cons x p 0 = x := by simp [cons] #align fin.cons_zero Fin.cons_zero @[simp] theorem cons_one {α : Fin (n + 2) → Type*} (x : α 0) (p : ∀ i : Fin n.succ, α i.succ) : cons x p 1 = p 0 := by rw [← cons_succ x p]; rfl @[simp] theorem cons_update : cons x (update p i y) = update (cons x p) i.succ y := by ext j by_cases h : j = 0 · rw [h] simp [Ne.symm (succ_ne_zero i)] · let j' := pred j h have : j'.succ = j := succ_pred j h rw [← this, cons_succ] by_cases h' : j' = i · rw [h'] simp · have : j'.succ ≠ i.succ := by rwa [Ne, succ_inj] rw [update_noteq h', update_noteq this, cons_succ] #align fin.cons_update Fin.cons_update theorem cons_injective2 : Function.Injective2 (@cons n α) := fun x₀ y₀ x y h ↦ ⟨congr_fun h 0, funext fun i ↦ by simpa using congr_fun h (Fin.succ i)⟩ #align fin.cons_injective2 Fin.cons_injective2 @[simp] theorem cons_eq_cons {x₀ y₀ : α 0} {x y : ∀ i : Fin n, α i.succ} : cons x₀ x = cons y₀ y ↔ x₀ = y₀ ∧ x = y := cons_injective2.eq_iff #align fin.cons_eq_cons Fin.cons_eq_cons theorem cons_left_injective (x : ∀ i : Fin n, α i.succ) : Function.Injective fun x₀ ↦ cons x₀ x := cons_injective2.left _ #align fin.cons_left_injective Fin.cons_left_injective theorem cons_right_injective (x₀ : α 0) : Function.Injective (cons x₀) := cons_injective2.right _ #align fin.cons_right_injective Fin.cons_right_injective
Mathlib/Data/Fin/Tuple/Basic.lean
128
136
theorem update_cons_zero : update (cons x p) 0 z = cons z p := by
ext j by_cases h : j = 0 · rw [h] simp · simp only [h, update_noteq, Ne, not_false_iff] let j' := pred j h have : j'.succ = j := succ_pred j h rw [← this, cons_succ, cons_succ]
import Mathlib.Combinatorics.SimpleGraph.Regularity.Bound import Mathlib.Combinatorics.SimpleGraph.Regularity.Equitabilise import Mathlib.Combinatorics.SimpleGraph.Regularity.Uniform #align_import combinatorics.simple_graph.regularity.chunk from "leanprover-community/mathlib"@"bf7ef0e83e5b7e6c1169e97f055e58a2e4e9d52d" open Finpartition Finset Fintype Rel Nat open scoped SzemerediRegularity.Positivity namespace SzemerediRegularity variable {α : Type*} [Fintype α] [DecidableEq α] {P : Finpartition (univ : Finset α)} (hP : P.IsEquipartition) (G : SimpleGraph α) [DecidableRel G.Adj] (ε : ℝ) {U : Finset α} (hU : U ∈ P.parts) (V : Finset α) local notation3 "m" => (card α / stepBound P.parts.card : ℕ) noncomputable def chunk : Finpartition U := if hUcard : U.card = m * 4 ^ P.parts.card + (card α / P.parts.card - m * 4 ^ P.parts.card) then (atomise U <| P.nonuniformWitnesses G ε U).equitabilise <| card_aux₁ hUcard else (atomise U <| P.nonuniformWitnesses G ε U).equitabilise <| card_aux₂ hP hU hUcard #align szemeredi_regularity.chunk SzemerediRegularity.chunk -- `hP` and `hU` are used to get that `U` has size -- `m * 4 ^ P.parts.card + a or m * 4 ^ P.parts.card + a + 1` noncomputable def star (V : Finset α) : Finset (Finset α) := (chunk hP G ε hU).parts.filter (· ⊆ G.nonuniformWitness ε U V) #align szemeredi_regularity.star SzemerediRegularity.star theorem biUnion_star_subset_nonuniformWitness : (star hP G ε hU V).biUnion id ⊆ G.nonuniformWitness ε U V := biUnion_subset_iff_forall_subset.2 fun _ hA => (mem_filter.1 hA).2 #align szemeredi_regularity.bUnion_star_subset_nonuniform_witness SzemerediRegularity.biUnion_star_subset_nonuniformWitness variable {hP G ε hU V} {𝒜 : Finset (Finset α)} {s : Finset α} theorem star_subset_chunk : star hP G ε hU V ⊆ (chunk hP G ε hU).parts := filter_subset _ _ #align szemeredi_regularity.star_subset_chunk SzemerediRegularity.star_subset_chunk private theorem card_nonuniformWitness_sdiff_biUnion_star (hV : V ∈ P.parts) (hUV : U ≠ V) (h₂ : ¬G.IsUniform ε U V) : (G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id).card ≤ 2 ^ (P.parts.card - 1) * m := by have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U := nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV have q : G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆ ((atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty).biUnion fun B => B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id := by intro x hx rw [← biUnion_filter_atomise hX (G.nonuniformWitness_subset h₂), star, mem_sdiff, mem_biUnion] at hx simp only [not_exists, mem_biUnion, and_imp, exists_prop, mem_filter, not_and, mem_sdiff, id, mem_sdiff] at hx ⊢ obtain ⟨⟨B, hB₁, hB₂⟩, hx⟩ := hx exact ⟨B, hB₁, hB₂, fun A hA AB => hx A hA <| AB.trans hB₁.2.1⟩ apply (card_le_card q).trans (card_biUnion_le.trans _) trans ∑ _i in (atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty, m · suffices ∀ B ∈ (atomise U <| P.nonuniformWitnesses G ε U).parts, (B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id).card ≤ m by exact sum_le_sum fun B hB => this B <| filter_subset _ _ hB intro B hB unfold chunk split_ifs with h₁ · convert card_parts_equitabilise_subset_le _ (card_aux₁ h₁) hB · convert card_parts_equitabilise_subset_le _ (card_aux₂ hP hU h₁) hB rw [sum_const] refine mul_le_mul_right' ?_ _ have t := card_filter_atomise_le_two_pow (s := U) hX refine t.trans (pow_le_pow_right (by norm_num) <| tsub_le_tsub_right ?_ _) exact card_image_le.trans (card_le_card <| filter_subset _ _) private theorem one_sub_eps_mul_card_nonuniformWitness_le_card_star (hV : V ∈ P.parts) (hUV : U ≠ V) (hunif : ¬G.IsUniform ε U V) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) : (1 - ε / 10) * (G.nonuniformWitness ε U V).card ≤ ((star hP G ε hU V).biUnion id).card := by have hP₁ : 0 < P.parts.card := Finset.card_pos.2 ⟨_, hU⟩ have : (↑2 ^ P.parts.card : ℝ) * m / (U.card * ε) ≤ ε / 10 := by rw [← div_div, div_le_iff'] swap · sz_positivity refine le_of_mul_le_mul_left ?_ (pow_pos zero_lt_two P.parts.card) calc ↑2 ^ P.parts.card * ((↑2 ^ P.parts.card * m : ℝ) / U.card) = ((2 : ℝ) * 2) ^ P.parts.card * m / U.card := by rw [mul_pow, ← mul_div_assoc, mul_assoc] _ = ↑4 ^ P.parts.card * m / U.card := by norm_num _ ≤ 1 := div_le_one_of_le (pow_mul_m_le_card_part hP hU) (cast_nonneg _) _ ≤ ↑2 ^ P.parts.card * ε ^ 2 / 10 := by refine (one_le_sq_iff <| by positivity).1 ?_ rw [div_pow, mul_pow, pow_right_comm, ← pow_mul ε, one_le_div (sq_pos_of_ne_zero <| by norm_num)] calc (↑10 ^ 2) = 100 := by norm_num _ ≤ ↑4 ^ P.parts.card * ε ^ 5 := hPε _ ≤ ↑4 ^ P.parts.card * ε ^ 4 := (mul_le_mul_of_nonneg_left (pow_le_pow_of_le_one (by sz_positivity) hε₁ <| le_succ _) (by positivity)) _ = (↑2 ^ 2) ^ P.parts.card * ε ^ (2 * 2) := by norm_num _ = ↑2 ^ P.parts.card * (ε * (ε / 10)) := by rw [mul_div_assoc, sq, mul_div_assoc] calc (↑1 - ε / 10) * (G.nonuniformWitness ε U V).card ≤ (↑1 - ↑2 ^ P.parts.card * m / (U.card * ε)) * (G.nonuniformWitness ε U V).card := mul_le_mul_of_nonneg_right (sub_le_sub_left this _) (cast_nonneg _) _ = (G.nonuniformWitness ε U V).card - ↑2 ^ P.parts.card * m / (U.card * ε) * (G.nonuniformWitness ε U V).card := by rw [sub_mul, one_mul] _ ≤ (G.nonuniformWitness ε U V).card - ↑2 ^ (P.parts.card - 1) * m := by refine sub_le_sub_left ?_ _ have : (2 : ℝ) ^ P.parts.card = ↑2 ^ (P.parts.card - 1) * 2 := by rw [← _root_.pow_succ, tsub_add_cancel_of_le (succ_le_iff.2 hP₁)] rw [← mul_div_right_comm, this, mul_right_comm _ (2 : ℝ), mul_assoc, le_div_iff] · refine mul_le_mul_of_nonneg_left ?_ (by positivity) exact (G.le_card_nonuniformWitness hunif).trans (le_mul_of_one_le_left (cast_nonneg _) one_le_two) have := Finset.card_pos.mpr (P.nonempty_of_mem_parts hU) sz_positivity _ ≤ ((star hP G ε hU V).biUnion id).card := by rw [sub_le_comm, ← cast_sub (card_le_card <| biUnion_star_subset_nonuniformWitness hP G ε hU V), ← card_sdiff (biUnion_star_subset_nonuniformWitness hP G ε hU V)] exact mod_cast card_nonuniformWitness_sdiff_biUnion_star hV hUV hunif theorem card_chunk (hm : m ≠ 0) : (chunk hP G ε hU).parts.card = 4 ^ P.parts.card := by unfold chunk split_ifs · rw [card_parts_equitabilise _ _ hm, tsub_add_cancel_of_le] exact le_of_lt a_add_one_le_four_pow_parts_card · rw [card_parts_equitabilise _ _ hm, tsub_add_cancel_of_le a_add_one_le_four_pow_parts_card] #align szemeredi_regularity.card_chunk SzemerediRegularity.card_chunk theorem card_eq_of_mem_parts_chunk (hs : s ∈ (chunk hP G ε hU).parts) : s.card = m ∨ s.card = m + 1 := by unfold chunk at hs split_ifs at hs <;> exact card_eq_of_mem_parts_equitabilise hs #align szemeredi_regularity.card_eq_of_mem_parts_chunk SzemerediRegularity.card_eq_of_mem_parts_chunk theorem m_le_card_of_mem_chunk_parts (hs : s ∈ (chunk hP G ε hU).parts) : m ≤ s.card := (card_eq_of_mem_parts_chunk hs).elim ge_of_eq fun i => by simp [i] #align szemeredi_regularity.m_le_card_of_mem_chunk_parts SzemerediRegularity.m_le_card_of_mem_chunk_parts theorem card_le_m_add_one_of_mem_chunk_parts (hs : s ∈ (chunk hP G ε hU).parts) : s.card ≤ m + 1 := (card_eq_of_mem_parts_chunk hs).elim (fun i => by simp [i]) fun i => i.le #align szemeredi_regularity.card_le_m_add_one_of_mem_chunk_parts SzemerediRegularity.card_le_m_add_one_of_mem_chunk_parts theorem card_biUnion_star_le_m_add_one_card_star_mul : (((star hP G ε hU V).biUnion id).card : ℝ) ≤ (star hP G ε hU V).card * (m + 1) := mod_cast card_biUnion_le_card_mul _ _ _ fun _ hs => card_le_m_add_one_of_mem_chunk_parts <| star_subset_chunk hs #align szemeredi_regularity.card_bUnion_star_le_m_add_one_card_star_mul SzemerediRegularity.card_biUnion_star_le_m_add_one_card_star_mul private theorem le_sum_card_subset_chunk_parts (h𝒜 : 𝒜 ⊆ (chunk hP G ε hU).parts) (hs : s ∈ 𝒜) : (𝒜.card : ℝ) * s.card * (m / (m + 1)) ≤ (𝒜.sup id).card := by rw [mul_div_assoc', div_le_iff coe_m_add_one_pos, mul_right_comm] refine mul_le_mul ?_ ?_ (cast_nonneg _) (cast_nonneg _) · rw [← (ofSubset _ h𝒜 rfl).sum_card_parts, ofSubset_parts, ← cast_mul, cast_le] exact card_nsmul_le_sum _ _ _ fun x hx => m_le_card_of_mem_chunk_parts <| h𝒜 hx · exact mod_cast card_le_m_add_one_of_mem_chunk_parts (h𝒜 hs) private theorem sum_card_subset_chunk_parts_le (m_pos : (0 : ℝ) < m) (h𝒜 : 𝒜 ⊆ (chunk hP G ε hU).parts) (hs : s ∈ 𝒜) : ((𝒜.sup id).card : ℝ) ≤ 𝒜.card * s.card * ((m + 1) / m) := by rw [sup_eq_biUnion, mul_div_assoc', le_div_iff m_pos, mul_right_comm] refine mul_le_mul ?_ ?_ (cast_nonneg _) (by positivity) · norm_cast refine card_biUnion_le_card_mul _ _ _ fun x hx => ?_ apply card_le_m_add_one_of_mem_chunk_parts (h𝒜 hx) · exact mod_cast m_le_card_of_mem_chunk_parts (h𝒜 hs) private theorem one_sub_le_m_div_m_add_one_sq [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) : ↑1 - ε ^ 5 / ↑50 ≤ (m / (m + 1 : ℝ)) ^ 2 := by have : (m : ℝ) / (m + 1) = 1 - 1 / (m + 1) := by rw [one_sub_div coe_m_add_one_pos.ne', add_sub_cancel_right] rw [this, sub_sq, one_pow, mul_one] refine le_trans ?_ (le_add_of_nonneg_right <| sq_nonneg _) rw [sub_le_sub_iff_left, ← le_div_iff' (show (0 : ℝ) < 2 by norm_num), div_div, one_div_le coe_m_add_one_pos, one_div_div] · refine le_trans ?_ (le_add_of_nonneg_right zero_le_one) set_option tactic.skipAssignedInstances false in norm_num apply hundred_div_ε_pow_five_le_m hPα hPε sz_positivity private theorem m_add_one_div_m_le_one_add [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) : ((m + 1 : ℝ) / m) ^ 2 ≤ ↑1 + ε ^ 5 / 49 := by rw [same_add_div] swap; · sz_positivity have : ↑1 + ↑1 / (m : ℝ) ≤ ↑1 + ε ^ 5 / 100 := by rw [add_le_add_iff_left, ← one_div_div (100 : ℝ)] exact one_div_le_one_div_of_le (by sz_positivity) (hundred_div_ε_pow_five_le_m hPα hPε) refine (pow_le_pow_left ?_ this 2).trans ?_ · positivity rw [add_sq, one_pow, add_assoc, add_le_add_iff_left, mul_one, ← le_sub_iff_add_le', div_eq_mul_one_div _ (49 : ℝ), mul_div_left_comm (2 : ℝ), ← mul_sub_left_distrib, div_pow, div_le_iff (show (0 : ℝ) < ↑100 ^ 2 by norm_num), mul_assoc, sq] refine mul_le_mul_of_nonneg_left ?_ (by sz_positivity) exact (pow_le_one 5 (by sz_positivity) hε₁).trans (by norm_num) private theorem density_sub_eps_le_sum_density_div_card [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) {hU : U ∈ P.parts} {hV : V ∈ P.parts} {A B : Finset (Finset α)} (hA : A ⊆ (chunk hP G ε hU).parts) (hB : B ⊆ (chunk hP G ε hV).parts) : (G.edgeDensity (A.biUnion id) (B.biUnion id)) - ε ^ 5 / 50 ≤ (∑ ab ∈ A.product B, (G.edgeDensity ab.1 ab.2 : ℝ)) / (A.card * B.card) := by have : ↑(G.edgeDensity (A.biUnion id) (B.biUnion id)) - ε ^ 5 / ↑50 ≤ (↑1 - ε ^ 5 / 50) * G.edgeDensity (A.biUnion id) (B.biUnion id) := by rw [sub_mul, one_mul, sub_le_sub_iff_left] refine mul_le_of_le_one_right (by sz_positivity) ?_ exact mod_cast G.edgeDensity_le_one _ _ refine this.trans ?_ conv_rhs => -- Porting note: LHS and RHS need separate treatment to get the desired form simp only [SimpleGraph.edgeDensity_def, sum_div, Rat.cast_div, div_div] conv_lhs => rw [SimpleGraph.edgeDensity_def, SimpleGraph.interedges, ← sup_eq_biUnion, ← sup_eq_biUnion, Rel.card_interedges_finpartition _ (ofSubset _ hA rfl) (ofSubset _ hB rfl), ofSubset_parts, ofSubset_parts] simp only [cast_sum, sum_div, mul_sum, Rat.cast_sum, Rat.cast_div, mul_div_left_comm ((1 : ℝ) - _)] push_cast apply sum_le_sum simp only [and_imp, Prod.forall, mem_product] rintro x y hx hy rw [mul_mul_mul_comm, mul_comm (x.card : ℝ), mul_comm (y.card : ℝ), le_div_iff, mul_assoc] · refine mul_le_of_le_one_right (cast_nonneg _) ?_ rw [div_mul_eq_mul_div, ← mul_assoc, mul_assoc] refine div_le_one_of_le ?_ (by positivity) refine (mul_le_mul_of_nonneg_right (one_sub_le_m_div_m_add_one_sq hPα hPε) ?_).trans ?_ · exact mod_cast _root_.zero_le _ rw [sq, mul_mul_mul_comm, mul_comm ((m : ℝ) / _), mul_comm ((m : ℝ) / _)] refine mul_le_mul ?_ ?_ ?_ (cast_nonneg _) · apply le_sum_card_subset_chunk_parts hA hx · apply le_sum_card_subset_chunk_parts hB hy · positivity refine mul_pos (mul_pos ?_ ?_) (mul_pos ?_ ?_) <;> rw [cast_pos, Finset.card_pos] exacts [⟨_, hx⟩, nonempty_of_mem_parts _ (hA hx), ⟨_, hy⟩, nonempty_of_mem_parts _ (hB hy)] private theorem sum_density_div_card_le_density_add_eps [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} {A B : Finset (Finset α)} (hA : A ⊆ (chunk hP G ε hU).parts) (hB : B ⊆ (chunk hP G ε hV).parts) : (∑ ab ∈ A.product B, G.edgeDensity ab.1 ab.2 : ℝ) / (A.card * B.card) ≤ G.edgeDensity (A.biUnion id) (B.biUnion id) + ε ^ 5 / 49 := by have : (↑1 + ε ^ 5 / ↑49) * G.edgeDensity (A.biUnion id) (B.biUnion id) ≤ G.edgeDensity (A.biUnion id) (B.biUnion id) + ε ^ 5 / 49 := by rw [add_mul, one_mul, add_le_add_iff_left] refine mul_le_of_le_one_right (by sz_positivity) ?_ exact mod_cast G.edgeDensity_le_one _ _ refine le_trans ?_ this conv_lhs => -- Porting note: LHS and RHS need separate treatment to get the desired form simp only [SimpleGraph.edgeDensity, edgeDensity, sum_div, Rat.cast_div, div_div] conv_rhs => rw [SimpleGraph.edgeDensity, edgeDensity, ← sup_eq_biUnion, ← sup_eq_biUnion, Rel.card_interedges_finpartition _ (ofSubset _ hA rfl) (ofSubset _ hB rfl)] simp only [cast_sum, mul_sum, sum_div, Rat.cast_sum, Rat.cast_div, mul_div_left_comm ((1 : ℝ) + _)] push_cast apply sum_le_sum simp only [and_imp, Prod.forall, mem_product, show A.product B = A ×ˢ B by rfl] intro x y hx hy rw [mul_mul_mul_comm, mul_comm (x.card : ℝ), mul_comm (y.card : ℝ), div_le_iff, mul_assoc] · refine le_mul_of_one_le_right (cast_nonneg _) ?_ rw [div_mul_eq_mul_div, one_le_div] · refine le_trans ?_ (mul_le_mul_of_nonneg_right (m_add_one_div_m_le_one_add hPα hPε hε₁) ?_) · rw [sq, mul_mul_mul_comm, mul_comm (_ / (m : ℝ)), mul_comm (_ / (m : ℝ))] exact mul_le_mul (sum_card_subset_chunk_parts_le (by sz_positivity) hA hx) (sum_card_subset_chunk_parts_le (by sz_positivity) hB hy) (by positivity) (by positivity) · exact mod_cast _root_.zero_le _ rw [← cast_mul, cast_pos] apply mul_pos <;> rw [Finset.card_pos, sup_eq_biUnion, biUnion_nonempty] · exact ⟨_, hx, nonempty_of_mem_parts _ (hA hx)⟩ · exact ⟨_, hy, nonempty_of_mem_parts _ (hB hy)⟩ refine mul_pos (mul_pos ?_ ?_) (mul_pos ?_ ?_) <;> rw [cast_pos, Finset.card_pos] exacts [⟨_, hx⟩, nonempty_of_mem_parts _ (hA hx), ⟨_, hy⟩, nonempty_of_mem_parts _ (hB hy)] private theorem average_density_near_total_density [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} {A B : Finset (Finset α)} (hA : A ⊆ (chunk hP G ε hU).parts) (hB : B ⊆ (chunk hP G ε hV).parts) : |(∑ ab ∈ A.product B, G.edgeDensity ab.1 ab.2 : ℝ) / (A.card * B.card) - G.edgeDensity (A.biUnion id) (B.biUnion id)| ≤ ε ^ 5 / 49 := by rw [abs_sub_le_iff] constructor · rw [sub_le_iff_le_add'] exact sum_density_div_card_le_density_add_eps hPα hPε hε₁ hA hB suffices (G.edgeDensity (A.biUnion id) (B.biUnion id) : ℝ) - (∑ ab ∈ A.product B, (G.edgeDensity ab.1 ab.2 : ℝ)) / (A.card * B.card) ≤ ε ^ 5 / 50 by apply this.trans gcongr <;> [sz_positivity; norm_num] rw [sub_le_iff_le_add, ← sub_le_iff_le_add'] apply density_sub_eps_le_sum_density_div_card hPα hPε hA hB private theorem edgeDensity_chunk_aux [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hU : U ∈ P.parts) (hV : V ∈ P.parts) : (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 ≤ ((∑ ab ∈ (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts, (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card) ^ 2 := by obtain hGε | hGε := le_total (G.edgeDensity U V : ℝ) (ε ^ 5 / 50) · refine (sub_nonpos_of_le <| (sq_le ?_ ?_).trans <| hGε.trans ?_).trans (sq_nonneg _) · exact mod_cast G.edgeDensity_nonneg _ _ · exact mod_cast G.edgeDensity_le_one _ _ · exact div_le_div_of_nonneg_left (by sz_positivity) (by norm_num) (by norm_num) rw [← sub_nonneg] at hGε have : ↑(G.edgeDensity U V) - ε ^ 5 / ↑50 ≤ (∑ ab ∈ (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts, (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card := by have rflU := Set.Subset.refl (chunk hP G ε hU).parts.toSet have rflV := Set.Subset.refl (chunk hP G ε hV).parts.toSet refine (le_trans ?_ <| density_sub_eps_le_sum_density_div_card hPα hPε rflU rflV).trans ?_ · rw [biUnion_parts, biUnion_parts] · rw [card_chunk (m_pos hPα).ne', card_chunk (m_pos hPα).ne', ← cast_mul, ← mul_pow, cast_pow] norm_cast refine le_trans ?_ (pow_le_pow_left hGε this 2) rw [sub_sq, sub_add, sub_le_sub_iff_left] refine (sub_le_self _ <| sq_nonneg <| ε ^ 5 / 50).trans ?_ rw [mul_right_comm, mul_div_left_comm, div_eq_mul_inv (ε ^ 5), show (2 : ℝ) / 50 = 25⁻¹ by norm_num] exact mul_le_of_le_one_right (by sz_positivity) (mod_cast G.edgeDensity_le_one _ _) private theorem abs_density_star_sub_density_le_eps (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} (hUV' : U ≠ V) (hUV : ¬G.IsUniform ε U V) : |(G.edgeDensity ((star hP G ε hU V).biUnion id) ((star hP G ε hV U).biUnion id) : ℝ) - G.edgeDensity (G.nonuniformWitness ε U V) (G.nonuniformWitness ε V U)| ≤ ε / 5 := by convert abs_edgeDensity_sub_edgeDensity_le_two_mul G.Adj (biUnion_star_subset_nonuniformWitness hP G ε hU V) (biUnion_star_subset_nonuniformWitness hP G ε hV U) (by sz_positivity) (one_sub_eps_mul_card_nonuniformWitness_le_card_star hV hUV' hUV hPε hε₁) (one_sub_eps_mul_card_nonuniformWitness_le_card_star hU hUV'.symm (fun hVU => hUV hVU.symm) hPε hε₁) using 1 linarith private theorem eps_le_card_star_div [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) (hU : U ∈ P.parts) (hV : V ∈ P.parts) (hUV : U ≠ V) (hunif : ¬G.IsUniform ε U V) : ↑4 / ↑5 * ε ≤ (star hP G ε hU V).card / ↑4 ^ P.parts.card := by have hm : (0 : ℝ) ≤ 1 - (↑m)⁻¹ := sub_nonneg_of_le (inv_le_one <| one_le_m_coe hPα) have hε : 0 ≤ 1 - ε / 10 := sub_nonneg_of_le (div_le_one_of_le (hε₁.trans <| by norm_num) <| by norm_num) have hε₀ : 0 < ε := by sz_positivity calc 4 / 5 * ε = (1 - 1 / 10) * (1 - 9⁻¹) * ε := by norm_num _ ≤ (1 - ε / 10) * (1 - (↑m)⁻¹) * ((G.nonuniformWitness ε U V).card / U.card) := by gcongr exacts [mod_cast (show 9 ≤ 100 by norm_num).trans (hundred_le_m hPα hPε hε₁), (le_div_iff' <| cast_pos.2 (P.nonempty_of_mem_parts hU).card_pos).2 <| G.le_card_nonuniformWitness hunif] _ = (1 - ε / 10) * (G.nonuniformWitness ε U V).card * ((1 - (↑m)⁻¹) / U.card) := by rw [mul_assoc, mul_assoc, mul_div_left_comm] _ ≤ ((star hP G ε hU V).biUnion id).card * ((1 - (↑m)⁻¹) / U.card) := (mul_le_mul_of_nonneg_right (one_sub_eps_mul_card_nonuniformWitness_le_card_star hV hUV hunif hPε hε₁) (by positivity)) _ ≤ (star hP G ε hU V).card * (m + 1) * ((1 - (↑m)⁻¹) / U.card) := (mul_le_mul_of_nonneg_right card_biUnion_star_le_m_add_one_card_star_mul (by positivity)) _ ≤ (star hP G ε hU V).card * (m + ↑1) * ((↑1 - (↑m)⁻¹) / (↑4 ^ P.parts.card * m)) := (mul_le_mul_of_nonneg_left (div_le_div_of_nonneg_left hm (by sz_positivity) <| pow_mul_m_le_card_part hP hU) (by positivity)) _ ≤ (star hP G ε hU V).card / ↑4 ^ P.parts.card := by rw [mul_assoc, mul_comm ((4 : ℝ) ^ P.parts.card), ← div_div, ← mul_div_assoc, ← mul_comm_div] refine mul_le_of_le_one_right (by positivity) ?_ have hm : (0 : ℝ) < m := by sz_positivity rw [mul_div_assoc', div_le_one hm, ← one_div, one_sub_div hm.ne', mul_div_assoc', div_le_iff hm] linarith private theorem edgeDensity_star_not_uniform [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} (hUVne : U ≠ V) (hUV : ¬G.IsUniform ε U V) : ↑3 / ↑4 * ε ≤ |(∑ ab ∈ (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) / ((star hP G ε hU V).card * (star hP G ε hV U).card) - (∑ ab ∈ (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts, (G.edgeDensity ab.1 ab.2 : ℝ)) / (16 : ℝ) ^ P.parts.card| := by rw [show (16 : ℝ) = ↑4 ^ 2 by norm_num, pow_right_comm, sq ((4 : ℝ) ^ _)] set p : ℝ := (∑ ab ∈ (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) / ((star hP G ε hU V).card * (star hP G ε hV U).card) set q : ℝ := (∑ ab ∈ (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts, (G.edgeDensity ab.1 ab.2 : ℝ)) / (↑4 ^ P.parts.card * ↑4 ^ P.parts.card) change _ ≤ |p - q| set r : ℝ := ↑(G.edgeDensity ((star hP G ε hU V).biUnion id) ((star hP G ε hV U).biUnion id)) set s : ℝ := ↑(G.edgeDensity (G.nonuniformWitness ε U V) (G.nonuniformWitness ε V U)) set t : ℝ := ↑(G.edgeDensity U V) have hrs : |r - s| ≤ ε / 5 := abs_density_star_sub_density_le_eps hPε hε₁ hUVne hUV have hst : ε ≤ |s - t| := by -- After leanprover/lean4#2734, we need to do the zeta reduction before `mod_cast`. unfold_let s t exact mod_cast G.nonuniformWitness_spec hUVne hUV have hpr : |p - r| ≤ ε ^ 5 / 49 := average_density_near_total_density hPα hPε hε₁ star_subset_chunk star_subset_chunk have hqt : |q - t| ≤ ε ^ 5 / 49 := by have := average_density_near_total_density hPα hPε hε₁ (Subset.refl (chunk hP G ε hU).parts) (Subset.refl (chunk hP G ε hV).parts) simp_rw [← sup_eq_biUnion, sup_parts, card_chunk (m_pos hPα).ne', cast_pow] at this set_option tactic.skipAssignedInstances false in norm_num at this exact this have hε' : ε ^ 5 ≤ ε := by simpa using pow_le_pow_of_le_one (by sz_positivity) hε₁ (show 1 ≤ 5 by norm_num) rw [abs_sub_le_iff] at hrs hpr hqt rw [le_abs] at hst ⊢ cases hst · left; linarith · right; linarith set_option tactic.skipAssignedInstances false in
Mathlib/Combinatorics/SimpleGraph/Regularity/Chunk.lean
473
521
theorem edgeDensity_chunk_not_uniform [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} (hUVne : U ≠ V) (hUV : ¬G.IsUniform ε U V) : (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 + ε ^ 4 / ↑3 ≤ (∑ ab ∈ (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts, (G.edgeDensity ab.1 ab.2 : ℝ) ^ 2) / ↑16 ^ P.parts.card := calc ↑(G.edgeDensity U V) ^ 2 - ε ^ 5 / 25 + ε ^ 4 / ↑3 ≤ ↑(G.edgeDensity U V) ^ 2 - ε ^ 5 / ↑25 + (star hP G ε hU V).card * (star hP G ε hV U).card / ↑16 ^ P.parts.card * (↑9 / ↑16) * ε ^ 2 := by
apply add_le_add_left have Ul : 4 / 5 * ε ≤ (star hP G ε hU V).card / _ := eps_le_card_star_div hPα hPε hε₁ hU hV hUVne hUV have Vl : 4 / 5 * ε ≤ (star hP G ε hV U).card / _ := eps_le_card_star_div hPα hPε hε₁ hV hU hUVne.symm fun h => hUV h.symm rw [show (16 : ℝ) = ↑4 ^ 2 by norm_num, pow_right_comm, sq ((4 : ℝ) ^ _), ← _root_.div_mul_div_comm, mul_assoc] have : 0 < ε := by sz_positivity have UVl := mul_le_mul Ul Vl (by positivity) ?_ swap · -- This seems faster than `exact div_nonneg (by positivity) (by positivity)` and *much* -- (tens of seconds) faster than `positivity` on its own. apply div_nonneg <;> positivity refine le_trans ?_ (mul_le_mul_of_nonneg_right UVl ?_) · norm_num nlinarith · norm_num positivity _ ≤ (∑ ab ∈ (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts, (G.edgeDensity ab.1 ab.2 : ℝ) ^ 2) / ↑16 ^ P.parts.card := by have t : (star hP G ε hU V).product (star hP G ε hV U) ⊆ (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts := product_subset_product star_subset_chunk star_subset_chunk have hε : 0 ≤ ε := by sz_positivity have sp : ∀ (a b : Finset (Finset α)), a.product b = a ×ˢ b := fun a b => rfl have := add_div_le_sum_sq_div_card t (fun x => (G.edgeDensity x.1 x.2 : ℝ)) ((G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25) (show 0 ≤ 3 / 4 * ε by linarith) ?_ ?_ · simp_rw [sp, card_product, card_chunk (m_pos hPα).ne', ← mul_pow, cast_pow, mul_pow, div_pow, ← mul_assoc] at this norm_num at this exact this · simp_rw [sp, card_product, card_chunk (m_pos hPα).ne', ← mul_pow] norm_num exact edgeDensity_star_not_uniform hPα hPε hε₁ hUVne hUV · rw [sp, card_product] apply (edgeDensity_chunk_aux hPα hPε hU hV).trans · rw [card_chunk (m_pos hPα).ne', card_chunk (m_pos hPα).ne', ← mul_pow] · norm_num rfl
import Mathlib.Order.Monotone.Odd import Mathlib.Analysis.SpecialFunctions.ExpDeriv import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic #align_import analysis.special_functions.trigonometric.deriv from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" noncomputable section open scoped Classical Topology Filter open Set Filter namespace Complex theorem hasStrictDerivAt_sin (x : ℂ) : HasStrictDerivAt sin (cos x) x := by simp only [cos, div_eq_mul_inv] convert ((((hasStrictDerivAt_id x).neg.mul_const I).cexp.sub ((hasStrictDerivAt_id x).mul_const I).cexp).mul_const I).mul_const (2 : ℂ)⁻¹ using 1 simp only [Function.comp, id] rw [sub_mul, mul_assoc, mul_assoc, I_mul_I, neg_one_mul, neg_neg, mul_one, one_mul, mul_assoc, I_mul_I, mul_neg_one, sub_neg_eq_add, add_comm] #align complex.has_strict_deriv_at_sin Complex.hasStrictDerivAt_sin theorem hasDerivAt_sin (x : ℂ) : HasDerivAt sin (cos x) x := (hasStrictDerivAt_sin x).hasDerivAt #align complex.has_deriv_at_sin Complex.hasDerivAt_sin theorem contDiff_sin {n} : ContDiff ℂ n sin := (((contDiff_neg.mul contDiff_const).cexp.sub (contDiff_id.mul contDiff_const).cexp).mul contDiff_const).div_const _ #align complex.cont_diff_sin Complex.contDiff_sin theorem differentiable_sin : Differentiable ℂ sin := fun x => (hasDerivAt_sin x).differentiableAt #align complex.differentiable_sin Complex.differentiable_sin theorem differentiableAt_sin {x : ℂ} : DifferentiableAt ℂ sin x := differentiable_sin x #align complex.differentiable_at_sin Complex.differentiableAt_sin @[simp] theorem deriv_sin : deriv sin = cos := funext fun x => (hasDerivAt_sin x).deriv #align complex.deriv_sin Complex.deriv_sin theorem hasStrictDerivAt_cos (x : ℂ) : HasStrictDerivAt cos (-sin x) x := by simp only [sin, div_eq_mul_inv, neg_mul_eq_neg_mul] convert (((hasStrictDerivAt_id x).mul_const I).cexp.add ((hasStrictDerivAt_id x).neg.mul_const I).cexp).mul_const (2 : ℂ)⁻¹ using 1 simp only [Function.comp, id] ring #align complex.has_strict_deriv_at_cos Complex.hasStrictDerivAt_cos theorem hasDerivAt_cos (x : ℂ) : HasDerivAt cos (-sin x) x := (hasStrictDerivAt_cos x).hasDerivAt #align complex.has_deriv_at_cos Complex.hasDerivAt_cos theorem contDiff_cos {n} : ContDiff ℂ n cos := ((contDiff_id.mul contDiff_const).cexp.add (contDiff_neg.mul contDiff_const).cexp).div_const _ #align complex.cont_diff_cos Complex.contDiff_cos theorem differentiable_cos : Differentiable ℂ cos := fun x => (hasDerivAt_cos x).differentiableAt #align complex.differentiable_cos Complex.differentiable_cos theorem differentiableAt_cos {x : ℂ} : DifferentiableAt ℂ cos x := differentiable_cos x #align complex.differentiable_at_cos Complex.differentiableAt_cos theorem deriv_cos {x : ℂ} : deriv cos x = -sin x := (hasDerivAt_cos x).deriv #align complex.deriv_cos Complex.deriv_cos @[simp] theorem deriv_cos' : deriv cos = fun x => -sin x := funext fun _ => deriv_cos #align complex.deriv_cos' Complex.deriv_cos' theorem hasStrictDerivAt_sinh (x : ℂ) : HasStrictDerivAt sinh (cosh x) x := by simp only [cosh, div_eq_mul_inv] convert ((hasStrictDerivAt_exp x).sub (hasStrictDerivAt_id x).neg.cexp).mul_const (2 : ℂ)⁻¹ using 1 rw [id, mul_neg_one, sub_eq_add_neg, neg_neg] #align complex.has_strict_deriv_at_sinh Complex.hasStrictDerivAt_sinh theorem hasDerivAt_sinh (x : ℂ) : HasDerivAt sinh (cosh x) x := (hasStrictDerivAt_sinh x).hasDerivAt #align complex.has_deriv_at_sinh Complex.hasDerivAt_sinh theorem contDiff_sinh {n} : ContDiff ℂ n sinh := (contDiff_exp.sub contDiff_neg.cexp).div_const _ #align complex.cont_diff_sinh Complex.contDiff_sinh theorem differentiable_sinh : Differentiable ℂ sinh := fun x => (hasDerivAt_sinh x).differentiableAt #align complex.differentiable_sinh Complex.differentiable_sinh theorem differentiableAt_sinh {x : ℂ} : DifferentiableAt ℂ sinh x := differentiable_sinh x #align complex.differentiable_at_sinh Complex.differentiableAt_sinh @[simp] theorem deriv_sinh : deriv sinh = cosh := funext fun x => (hasDerivAt_sinh x).deriv #align complex.deriv_sinh Complex.deriv_sinh
Mathlib/Analysis/SpecialFunctions/Trigonometric/Deriv.lean
134
138
theorem hasStrictDerivAt_cosh (x : ℂ) : HasStrictDerivAt cosh (sinh x) x := by
simp only [sinh, div_eq_mul_inv] convert ((hasStrictDerivAt_exp x).add (hasStrictDerivAt_id x).neg.cexp).mul_const (2 : ℂ)⁻¹ using 1 rw [id, mul_neg_one, sub_eq_add_neg]
import Mathlib.SetTheory.Ordinal.Basic import Mathlib.Data.Nat.SuccPred #align_import set_theory.ordinal.arithmetic from "leanprover-community/mathlib"@"31b269b60935483943542d547a6dd83a66b37dc7" assert_not_exists Field assert_not_exists Module noncomputable section open Function Cardinal Set Equiv Order open scoped Classical open Cardinal Ordinal universe u v w namespace Ordinal variable {α : Type*} {β : Type*} {γ : Type*} {r : α → α → Prop} {s : β → β → Prop} {t : γ → γ → Prop} @[simp] theorem lift_add (a b : Ordinal.{v}) : lift.{u} (a + b) = lift.{u} a + lift.{u} b := Quotient.inductionOn₂ a b fun ⟨_α, _r, _⟩ ⟨_β, _s, _⟩ => Quotient.sound ⟨(RelIso.preimage Equiv.ulift _).trans (RelIso.sumLexCongr (RelIso.preimage Equiv.ulift _) (RelIso.preimage Equiv.ulift _)).symm⟩ #align ordinal.lift_add Ordinal.lift_add @[simp] theorem lift_succ (a : Ordinal.{v}) : lift.{u} (succ a) = succ (lift.{u} a) := by rw [← add_one_eq_succ, lift_add, lift_one] rfl #align ordinal.lift_succ Ordinal.lift_succ instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) := ⟨fun a b c => inductionOn a fun α r hr => inductionOn b fun β₁ s₁ hs₁ => inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ => ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using @InitialSeg.eq _ _ _ _ _ ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by intro b; cases e : f (Sum.inr b) · rw [← fl] at e have := f.inj' e contradiction · exact ⟨_, rfl⟩ let g (b) := (this b).1 have fr : ∀ b, f (Sum.inr b) = Sum.inr (g b) := fun b => (this b).2 ⟨⟨⟨g, fun x y h => by injection f.inj' (by rw [fr, fr, h] : f (Sum.inr x) = f (Sum.inr y))⟩, @fun a b => by -- Porting note: -- `relEmbedding.coe_fn_to_embedding` & `initial_seg.coe_fn_to_rel_embedding` -- → `InitialSeg.coe_coe_fn` simpa only [Sum.lex_inr_inr, fr, InitialSeg.coe_coe_fn, Embedding.coeFn_mk] using @RelEmbedding.map_rel_iff _ _ _ _ f.toRelEmbedding (Sum.inr a) (Sum.inr b)⟩, fun a b H => by rcases f.init (by rw [fr] <;> exact Sum.lex_inr_inr.2 H) with ⟨a' | a', h⟩ · rw [fl] at h cases h · rw [fr] at h exact ⟨a', Sum.inr.inj h⟩⟩⟩⟩ #align ordinal.add_contravariant_class_le Ordinal.add_contravariantClass_le theorem add_left_cancel (a) {b c : Ordinal} : a + b = a + c ↔ b = c := by simp only [le_antisymm_iff, add_le_add_iff_left] #align ordinal.add_left_cancel Ordinal.add_left_cancel private theorem add_lt_add_iff_left' (a) {b c : Ordinal} : a + b < a + c ↔ b < c := by rw [← not_le, ← not_le, add_le_add_iff_left] instance add_covariantClass_lt : CovariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· < ·) := ⟨fun a _b _c => (add_lt_add_iff_left' a).2⟩ #align ordinal.add_covariant_class_lt Ordinal.add_covariantClass_lt instance add_contravariantClass_lt : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· < ·) := ⟨fun a _b _c => (add_lt_add_iff_left' a).1⟩ #align ordinal.add_contravariant_class_lt Ordinal.add_contravariantClass_lt instance add_swap_contravariantClass_lt : ContravariantClass Ordinal.{u} Ordinal.{u} (swap (· + ·)) (· < ·) := ⟨fun _a _b _c => lt_imp_lt_of_le_imp_le fun h => add_le_add_right h _⟩ #align ordinal.add_swap_contravariant_class_lt Ordinal.add_swap_contravariantClass_lt theorem add_le_add_iff_right {a b : Ordinal} : ∀ n : ℕ, a + n ≤ b + n ↔ a ≤ b | 0 => by simp | n + 1 => by simp only [natCast_succ, add_succ, add_succ, succ_le_succ_iff, add_le_add_iff_right] #align ordinal.add_le_add_iff_right Ordinal.add_le_add_iff_right theorem add_right_cancel {a b : Ordinal} (n : ℕ) : a + n = b + n ↔ a = b := by simp only [le_antisymm_iff, add_le_add_iff_right] #align ordinal.add_right_cancel Ordinal.add_right_cancel theorem add_eq_zero_iff {a b : Ordinal} : a + b = 0 ↔ a = 0 ∧ b = 0 := inductionOn a fun α r _ => inductionOn b fun β s _ => by simp_rw [← type_sum_lex, type_eq_zero_iff_isEmpty] exact isEmpty_sum #align ordinal.add_eq_zero_iff Ordinal.add_eq_zero_iff theorem left_eq_zero_of_add_eq_zero {a b : Ordinal} (h : a + b = 0) : a = 0 := (add_eq_zero_iff.1 h).1 #align ordinal.left_eq_zero_of_add_eq_zero Ordinal.left_eq_zero_of_add_eq_zero theorem right_eq_zero_of_add_eq_zero {a b : Ordinal} (h : a + b = 0) : b = 0 := (add_eq_zero_iff.1 h).2 #align ordinal.right_eq_zero_of_add_eq_zero Ordinal.right_eq_zero_of_add_eq_zero def pred (o : Ordinal) : Ordinal := if h : ∃ a, o = succ a then Classical.choose h else o #align ordinal.pred Ordinal.pred @[simp] theorem pred_succ (o) : pred (succ o) = o := by have h : ∃ a, succ o = succ a := ⟨_, rfl⟩; simpa only [pred, dif_pos h] using (succ_injective <| Classical.choose_spec h).symm #align ordinal.pred_succ Ordinal.pred_succ theorem pred_le_self (o) : pred o ≤ o := if h : ∃ a, o = succ a then by let ⟨a, e⟩ := h rw [e, pred_succ]; exact le_succ a else by rw [pred, dif_neg h] #align ordinal.pred_le_self Ordinal.pred_le_self theorem pred_eq_iff_not_succ {o} : pred o = o ↔ ¬∃ a, o = succ a := ⟨fun e ⟨a, e'⟩ => by rw [e', pred_succ] at e; exact (lt_succ a).ne e, fun h => dif_neg h⟩ #align ordinal.pred_eq_iff_not_succ Ordinal.pred_eq_iff_not_succ theorem pred_eq_iff_not_succ' {o} : pred o = o ↔ ∀ a, o ≠ succ a := by simpa using pred_eq_iff_not_succ #align ordinal.pred_eq_iff_not_succ' Ordinal.pred_eq_iff_not_succ' theorem pred_lt_iff_is_succ {o} : pred o < o ↔ ∃ a, o = succ a := Iff.trans (by simp only [le_antisymm_iff, pred_le_self, true_and_iff, not_le]) (iff_not_comm.1 pred_eq_iff_not_succ).symm #align ordinal.pred_lt_iff_is_succ Ordinal.pred_lt_iff_is_succ @[simp] theorem pred_zero : pred 0 = 0 := pred_eq_iff_not_succ'.2 fun a => (succ_ne_zero a).symm #align ordinal.pred_zero Ordinal.pred_zero theorem succ_pred_iff_is_succ {o} : succ (pred o) = o ↔ ∃ a, o = succ a := ⟨fun e => ⟨_, e.symm⟩, fun ⟨a, e⟩ => by simp only [e, pred_succ]⟩ #align ordinal.succ_pred_iff_is_succ Ordinal.succ_pred_iff_is_succ theorem succ_lt_of_not_succ {o b : Ordinal} (h : ¬∃ a, o = succ a) : succ b < o ↔ b < o := ⟨(lt_succ b).trans, fun l => lt_of_le_of_ne (succ_le_of_lt l) fun e => h ⟨_, e.symm⟩⟩ #align ordinal.succ_lt_of_not_succ Ordinal.succ_lt_of_not_succ theorem lt_pred {a b} : a < pred b ↔ succ a < b := if h : ∃ a, b = succ a then by let ⟨c, e⟩ := h rw [e, pred_succ, succ_lt_succ_iff] else by simp only [pred, dif_neg h, succ_lt_of_not_succ h] #align ordinal.lt_pred Ordinal.lt_pred theorem pred_le {a b} : pred a ≤ b ↔ a ≤ succ b := le_iff_le_iff_lt_iff_lt.2 lt_pred #align ordinal.pred_le Ordinal.pred_le @[simp] theorem lift_is_succ {o : Ordinal.{v}} : (∃ a, lift.{u} o = succ a) ↔ ∃ a, o = succ a := ⟨fun ⟨a, h⟩ => let ⟨b, e⟩ := lift_down <| show a ≤ lift.{u} o from le_of_lt <| h.symm ▸ lt_succ a ⟨b, lift_inj.1 <| by rw [h, ← e, lift_succ]⟩, fun ⟨a, h⟩ => ⟨lift.{u} a, by simp only [h, lift_succ]⟩⟩ #align ordinal.lift_is_succ Ordinal.lift_is_succ @[simp] theorem lift_pred (o : Ordinal.{v}) : lift.{u} (pred o) = pred (lift.{u} o) := if h : ∃ a, o = succ a then by cases' h with a e; simp only [e, pred_succ, lift_succ] else by rw [pred_eq_iff_not_succ.2 h, pred_eq_iff_not_succ.2 (mt lift_is_succ.1 h)] #align ordinal.lift_pred Ordinal.lift_pred def IsLimit (o : Ordinal) : Prop := o ≠ 0 ∧ ∀ a < o, succ a < o #align ordinal.is_limit Ordinal.IsLimit theorem IsLimit.isSuccLimit {o} (h : IsLimit o) : IsSuccLimit o := isSuccLimit_iff_succ_lt.mpr h.2 theorem IsLimit.succ_lt {o a : Ordinal} (h : IsLimit o) : a < o → succ a < o := h.2 a #align ordinal.is_limit.succ_lt Ordinal.IsLimit.succ_lt theorem isSuccLimit_zero : IsSuccLimit (0 : Ordinal) := isSuccLimit_bot theorem not_zero_isLimit : ¬IsLimit 0 | ⟨h, _⟩ => h rfl #align ordinal.not_zero_is_limit Ordinal.not_zero_isLimit theorem not_succ_isLimit (o) : ¬IsLimit (succ o) | ⟨_, h⟩ => lt_irrefl _ (h _ (lt_succ o)) #align ordinal.not_succ_is_limit Ordinal.not_succ_isLimit theorem not_succ_of_isLimit {o} (h : IsLimit o) : ¬∃ a, o = succ a | ⟨a, e⟩ => not_succ_isLimit a (e ▸ h) #align ordinal.not_succ_of_is_limit Ordinal.not_succ_of_isLimit theorem succ_lt_of_isLimit {o a : Ordinal} (h : IsLimit o) : succ a < o ↔ a < o := ⟨(lt_succ a).trans, h.2 _⟩ #align ordinal.succ_lt_of_is_limit Ordinal.succ_lt_of_isLimit theorem le_succ_of_isLimit {o} (h : IsLimit o) {a} : o ≤ succ a ↔ o ≤ a := le_iff_le_iff_lt_iff_lt.2 <| succ_lt_of_isLimit h #align ordinal.le_succ_of_is_limit Ordinal.le_succ_of_isLimit theorem limit_le {o} (h : IsLimit o) {a} : o ≤ a ↔ ∀ x < o, x ≤ a := ⟨fun h _x l => l.le.trans h, fun H => (le_succ_of_isLimit h).1 <| le_of_not_lt fun hn => not_lt_of_le (H _ hn) (lt_succ a)⟩ #align ordinal.limit_le Ordinal.limit_le theorem lt_limit {o} (h : IsLimit o) {a} : a < o ↔ ∃ x < o, a < x := by -- Porting note: `bex_def` is required. simpa only [not_forall₂, not_le, bex_def] using not_congr (@limit_le _ h a) #align ordinal.lt_limit Ordinal.lt_limit @[simp] theorem lift_isLimit (o) : IsLimit (lift o) ↔ IsLimit o := and_congr (not_congr <| by simpa only [lift_zero] using @lift_inj o 0) ⟨fun H a h => lift_lt.1 <| by simpa only [lift_succ] using H _ (lift_lt.2 h), fun H a h => by obtain ⟨a', rfl⟩ := lift_down h.le rw [← lift_succ, lift_lt] exact H a' (lift_lt.1 h)⟩ #align ordinal.lift_is_limit Ordinal.lift_isLimit theorem IsLimit.pos {o : Ordinal} (h : IsLimit o) : 0 < o := lt_of_le_of_ne (Ordinal.zero_le _) h.1.symm #align ordinal.is_limit.pos Ordinal.IsLimit.pos theorem IsLimit.one_lt {o : Ordinal} (h : IsLimit o) : 1 < o := by simpa only [succ_zero] using h.2 _ h.pos #align ordinal.is_limit.one_lt Ordinal.IsLimit.one_lt theorem IsLimit.nat_lt {o : Ordinal} (h : IsLimit o) : ∀ n : ℕ, (n : Ordinal) < o | 0 => h.pos | n + 1 => h.2 _ (IsLimit.nat_lt h n) #align ordinal.is_limit.nat_lt Ordinal.IsLimit.nat_lt theorem zero_or_succ_or_limit (o : Ordinal) : o = 0 ∨ (∃ a, o = succ a) ∨ IsLimit o := if o0 : o = 0 then Or.inl o0 else if h : ∃ a, o = succ a then Or.inr (Or.inl h) else Or.inr <| Or.inr ⟨o0, fun _a => (succ_lt_of_not_succ h).2⟩ #align ordinal.zero_or_succ_or_limit Ordinal.zero_or_succ_or_limit @[elab_as_elim] def limitRecOn {C : Ordinal → Sort*} (o : Ordinal) (H₁ : C 0) (H₂ : ∀ o, C o → C (succ o)) (H₃ : ∀ o, IsLimit o → (∀ o' < o, C o') → C o) : C o := SuccOrder.limitRecOn o (fun o _ ↦ H₂ o) fun o hl ↦ if h : o = 0 then fun _ ↦ h ▸ H₁ else H₃ o ⟨h, fun _ ↦ hl.succ_lt⟩ #align ordinal.limit_rec_on Ordinal.limitRecOn @[simp] theorem limitRecOn_zero {C} (H₁ H₂ H₃) : @limitRecOn C 0 H₁ H₂ H₃ = H₁ := by rw [limitRecOn, SuccOrder.limitRecOn_limit _ _ isSuccLimit_zero, dif_pos rfl] #align ordinal.limit_rec_on_zero Ordinal.limitRecOn_zero @[simp]
Mathlib/SetTheory/Ordinal/Arithmetic.lean
327
329
theorem limitRecOn_succ {C} (o H₁ H₂ H₃) : @limitRecOn C (succ o) H₁ H₂ H₃ = H₂ o (@limitRecOn C o H₁ H₂ H₃) := by
simp_rw [limitRecOn, SuccOrder.limitRecOn_succ _ _ (not_isMax _)]
import Mathlib.Algebra.Category.ModuleCat.Monoidal.Basic import Mathlib.CategoryTheory.Monoidal.Functorial import Mathlib.CategoryTheory.Monoidal.Types.Basic import Mathlib.LinearAlgebra.DirectSum.Finsupp import Mathlib.CategoryTheory.Linear.LinearFunctor #align_import algebra.category.Module.adjunctions from "leanprover-community/mathlib"@"95a87616d63b3cb49d3fe678d416fbe9c4217bf4" set_option linter.uppercaseLean3 false -- `Module` noncomputable section open CategoryTheory namespace ModuleCat universe u open scoped Classical variable (R : Type u) section variable [Ring R] @[simps] def free : Type u ⥤ ModuleCat R where obj X := ModuleCat.of R (X →₀ R) map {X Y} f := Finsupp.lmapDomain _ _ f map_id := by intros; exact Finsupp.lmapDomain_id _ _ map_comp := by intros; exact Finsupp.lmapDomain_comp _ _ _ _ #align Module.free ModuleCat.free def adj : free R ⊣ forget (ModuleCat.{u} R) := Adjunction.mkOfHomEquiv { homEquiv := fun X M => (Finsupp.lift M R X).toEquiv.symm homEquiv_naturality_left_symm := fun {_ _} M f g => Finsupp.lhom_ext' fun x => LinearMap.ext_ring (Finsupp.sum_mapDomain_index_addMonoidHom fun y => (smulAddHom R M).flip (g y)).symm } #align Module.adj ModuleCat.adj instance : (forget (ModuleCat.{u} R)).IsRightAdjoint := (adj R).isRightAdjoint end namespace Free open MonoidalCategory variable [CommRing R] attribute [local ext] TensorProduct.ext def ε : 𝟙_ (ModuleCat.{u} R) ⟶ (free R).obj (𝟙_ (Type u)) := Finsupp.lsingle PUnit.unit #align Module.free.ε ModuleCat.Free.ε -- This lemma has always been bad, but lean4#2644 made `simp` start noticing @[simp, nolint simpNF] theorem ε_apply (r : R) : ε R r = Finsupp.single PUnit.unit r := rfl #align Module.free.ε_apply ModuleCat.Free.ε_apply def μ (α β : Type u) : (free R).obj α ⊗ (free R).obj β ≅ (free R).obj (α ⊗ β) := (finsuppTensorFinsupp' R α β).toModuleIso #align Module.free.μ ModuleCat.Free.μ theorem μ_natural {X Y X' Y' : Type u} (f : X ⟶ Y) (g : X' ⟶ Y') : ((free R).map f ⊗ (free R).map g) ≫ (μ R Y Y').hom = (μ R X X').hom ≫ (free R).map (f ⊗ g) := by -- Porting note (#11041): broken ext apply TensorProduct.ext apply Finsupp.lhom_ext' intro x apply LinearMap.ext_ring apply Finsupp.lhom_ext' intro x' apply LinearMap.ext_ring apply Finsupp.ext intro ⟨y, y'⟩ -- Porting note (#10934): used to be dsimp [μ] change (finsuppTensorFinsupp' R Y Y') (Finsupp.mapDomain f (Finsupp.single x 1) ⊗ₜ[R] Finsupp.mapDomain g (Finsupp.single x' 1)) _ = (Finsupp.mapDomain (f ⊗ g) (finsuppTensorFinsupp' R X X' (Finsupp.single x 1 ⊗ₜ[R] Finsupp.single x' 1))) _ -- extra `rfl` after leanprover/lean4#2466 simp_rw [Finsupp.mapDomain_single, finsuppTensorFinsupp'_single_tmul_single, mul_one, Finsupp.mapDomain_single, CategoryTheory.tensor_apply]; rfl #align Module.free.μ_natural ModuleCat.Free.μ_natural theorem left_unitality (X : Type u) : (λ_ ((free R).obj X)).hom = (ε R ⊗ 𝟙 ((free R).obj X)) ≫ (μ R (𝟙_ (Type u)) X).hom ≫ map (free R).obj (λ_ X).hom := by -- Porting note (#11041): broken ext apply TensorProduct.ext apply LinearMap.ext_ring apply Finsupp.lhom_ext' intro x apply LinearMap.ext_ring apply Finsupp.ext intro x' -- Porting note (#10934): used to be dsimp [ε, μ] let q : X →₀ R := ((λ_ (of R (X →₀ R))).hom) (1 ⊗ₜ[R] Finsupp.single x 1) change q x' = Finsupp.mapDomain (λ_ X).hom (finsuppTensorFinsupp' R (𝟙_ (Type u)) X (Finsupp.single PUnit.unit 1 ⊗ₜ[R] Finsupp.single x 1)) x' simp_rw [q, finsuppTensorFinsupp'_single_tmul_single, ModuleCat.MonoidalCategory.leftUnitor_hom_apply, mul_one, Finsupp.mapDomain_single, CategoryTheory.leftUnitor_hom_apply, one_smul] #align Module.free.left_unitality ModuleCat.Free.left_unitality theorem right_unitality (X : Type u) : (ρ_ ((free R).obj X)).hom = (𝟙 ((free R).obj X) ⊗ ε R) ≫ (μ R X (𝟙_ (Type u))).hom ≫ map (free R).obj (ρ_ X).hom := by -- Porting note (#11041): broken ext apply TensorProduct.ext apply Finsupp.lhom_ext' intro x apply LinearMap.ext_ring apply LinearMap.ext_ring apply Finsupp.ext intro x' -- Porting note (#10934): used to be dsimp [ε, μ] let q : X →₀ R := ((ρ_ (of R (X →₀ R))).hom) (Finsupp.single x 1 ⊗ₜ[R] 1) change q x' = Finsupp.mapDomain (ρ_ X).hom (finsuppTensorFinsupp' R X (𝟙_ (Type u)) (Finsupp.single x 1 ⊗ₜ[R] Finsupp.single PUnit.unit 1)) x' simp_rw [q, finsuppTensorFinsupp'_single_tmul_single, ModuleCat.MonoidalCategory.rightUnitor_hom_apply, mul_one, Finsupp.mapDomain_single, CategoryTheory.rightUnitor_hom_apply, one_smul] #align Module.free.right_unitality ModuleCat.Free.right_unitality
Mathlib/Algebra/Category/ModuleCat/Adjunctions.lean
152
179
theorem associativity (X Y Z : Type u) : ((μ R X Y).hom ⊗ 𝟙 ((free R).obj Z)) ≫ (μ R (X ⊗ Y) Z).hom ≫ map (free R).obj (α_ X Y Z).hom = (α_ ((free R).obj X) ((free R).obj Y) ((free R).obj Z)).hom ≫ (𝟙 ((free R).obj X) ⊗ (μ R Y Z).hom) ≫ (μ R X (Y ⊗ Z)).hom := by
-- Porting note (#11041): broken ext apply TensorProduct.ext apply TensorProduct.ext apply Finsupp.lhom_ext' intro x apply LinearMap.ext_ring apply Finsupp.lhom_ext' intro y apply LinearMap.ext_ring apply Finsupp.lhom_ext' intro z apply LinearMap.ext_ring apply Finsupp.ext intro a -- Porting note (#10934): used to be dsimp [μ] change Finsupp.mapDomain (α_ X Y Z).hom (finsuppTensorFinsupp' R (X ⊗ Y) Z (finsuppTensorFinsupp' R X Y (Finsupp.single x 1 ⊗ₜ[R] Finsupp.single y 1) ⊗ₜ[R] Finsupp.single z 1)) a = finsuppTensorFinsupp' R X (Y ⊗ Z) (Finsupp.single x 1 ⊗ₜ[R] finsuppTensorFinsupp' R Y Z (Finsupp.single y 1 ⊗ₜ[R] Finsupp.single z 1)) a -- extra `rfl` after leanprover/lean4#2466 simp_rw [finsuppTensorFinsupp'_single_tmul_single, Finsupp.mapDomain_single, mul_one, CategoryTheory.associator_hom_apply]; rfl
import Mathlib.Analysis.Calculus.BumpFunction.FiniteDimension import Mathlib.Geometry.Manifold.ContMDiff.Atlas import Mathlib.Geometry.Manifold.ContMDiff.NormedSpace #align_import geometry.manifold.bump_function from "leanprover-community/mathlib"@"b018406ad2f2a73223a3a9e198ccae61e6f05318" universe uE uF uH uM variable {E : Type uE} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] {H : Type uH} [TopologicalSpace H] (I : ModelWithCorners ℝ E H) {M : Type uM} [TopologicalSpace M] [ChartedSpace H M] [SmoothManifoldWithCorners I M] open Function Filter FiniteDimensional Set Metric open scoped Topology Manifold Classical Filter noncomputable section structure SmoothBumpFunction (c : M) extends ContDiffBump (extChartAt I c c) where closedBall_subset : closedBall (extChartAt I c c) rOut ∩ range I ⊆ (extChartAt I c).target #align smooth_bump_function SmoothBumpFunction namespace SmoothBumpFunction variable {c : M} (f : SmoothBumpFunction I c) {x : M} {I} @[coe] def toFun : M → ℝ := indicator (chartAt H c).source (f.toContDiffBump ∘ extChartAt I c) #align smooth_bump_function.to_fun SmoothBumpFunction.toFun instance : CoeFun (SmoothBumpFunction I c) fun _ => M → ℝ := ⟨toFun⟩ theorem coe_def : ⇑f = indicator (chartAt H c).source (f.toContDiffBump ∘ extChartAt I c) := rfl #align smooth_bump_function.coe_def SmoothBumpFunction.coe_def theorem rOut_pos : 0 < f.rOut := f.toContDiffBump.rOut_pos set_option linter.uppercaseLean3 false in #align smooth_bump_function.R_pos SmoothBumpFunction.rOut_pos theorem ball_subset : ball (extChartAt I c c) f.rOut ∩ range I ⊆ (extChartAt I c).target := Subset.trans (inter_subset_inter_left _ ball_subset_closedBall) f.closedBall_subset #align smooth_bump_function.ball_subset SmoothBumpFunction.ball_subset theorem ball_inter_range_eq_ball_inter_target : ball (extChartAt I c c) f.rOut ∩ range I = ball (extChartAt I c c) f.rOut ∩ (extChartAt I c).target := (subset_inter inter_subset_left f.ball_subset).antisymm <| inter_subset_inter_right _ <| extChartAt_target_subset_range _ _ theorem eqOn_source : EqOn f (f.toContDiffBump ∘ extChartAt I c) (chartAt H c).source := eqOn_indicator #align smooth_bump_function.eq_on_source SmoothBumpFunction.eqOn_source theorem eventuallyEq_of_mem_source (hx : x ∈ (chartAt H c).source) : f =ᶠ[𝓝 x] f.toContDiffBump ∘ extChartAt I c := f.eqOn_source.eventuallyEq_of_mem <| (chartAt H c).open_source.mem_nhds hx #align smooth_bump_function.eventually_eq_of_mem_source SmoothBumpFunction.eventuallyEq_of_mem_source theorem one_of_dist_le (hs : x ∈ (chartAt H c).source) (hd : dist (extChartAt I c x) (extChartAt I c c) ≤ f.rIn) : f x = 1 := by simp only [f.eqOn_source hs, (· ∘ ·), f.one_of_mem_closedBall hd] #align smooth_bump_function.one_of_dist_le SmoothBumpFunction.one_of_dist_le theorem support_eq_inter_preimage : support f = (chartAt H c).source ∩ extChartAt I c ⁻¹' ball (extChartAt I c c) f.rOut := by rw [coe_def, support_indicator, support_comp_eq_preimage, ← extChartAt_source I, ← (extChartAt I c).symm_image_target_inter_eq', ← (extChartAt I c).symm_image_target_inter_eq', f.support_eq] #align smooth_bump_function.support_eq_inter_preimage SmoothBumpFunction.support_eq_inter_preimage theorem isOpen_support : IsOpen (support f) := by rw [support_eq_inter_preimage] exact isOpen_extChartAt_preimage I c isOpen_ball #align smooth_bump_function.is_open_support SmoothBumpFunction.isOpen_support theorem support_eq_symm_image : support f = (extChartAt I c).symm '' (ball (extChartAt I c c) f.rOut ∩ range I) := by rw [f.support_eq_inter_preimage, ← extChartAt_source I, ← (extChartAt I c).symm_image_target_inter_eq', inter_comm, ball_inter_range_eq_ball_inter_target] #align smooth_bump_function.support_eq_symm_image SmoothBumpFunction.support_eq_symm_image theorem support_subset_source : support f ⊆ (chartAt H c).source := by rw [f.support_eq_inter_preimage, ← extChartAt_source I]; exact inter_subset_left #align smooth_bump_function.support_subset_source SmoothBumpFunction.support_subset_source theorem image_eq_inter_preimage_of_subset_support {s : Set M} (hs : s ⊆ support f) : extChartAt I c '' s = closedBall (extChartAt I c c) f.rOut ∩ range I ∩ (extChartAt I c).symm ⁻¹' s := by rw [support_eq_inter_preimage, subset_inter_iff, ← extChartAt_source I, ← image_subset_iff] at hs cases' hs with hse hsf apply Subset.antisymm · refine subset_inter (subset_inter (hsf.trans ball_subset_closedBall) ?_) ?_ · rintro _ ⟨x, -, rfl⟩; exact mem_range_self _ · rw [(extChartAt I c).image_eq_target_inter_inv_preimage hse] exact inter_subset_right · refine Subset.trans (inter_subset_inter_left _ f.closedBall_subset) ?_ rw [(extChartAt I c).image_eq_target_inter_inv_preimage hse] #align smooth_bump_function.image_eq_inter_preimage_of_subset_support SmoothBumpFunction.image_eq_inter_preimage_of_subset_support theorem mem_Icc : f x ∈ Icc (0 : ℝ) 1 := by have : f x = 0 ∨ f x = _ := indicator_eq_zero_or_self _ _ _ cases' this with h h <;> rw [h] exacts [left_mem_Icc.2 zero_le_one, ⟨f.nonneg, f.le_one⟩] #align smooth_bump_function.mem_Icc SmoothBumpFunction.mem_Icc theorem nonneg : 0 ≤ f x := f.mem_Icc.1 #align smooth_bump_function.nonneg SmoothBumpFunction.nonneg theorem le_one : f x ≤ 1 := f.mem_Icc.2 #align smooth_bump_function.le_one SmoothBumpFunction.le_one theorem eventuallyEq_one_of_dist_lt (hs : x ∈ (chartAt H c).source) (hd : dist (extChartAt I c x) (extChartAt I c c) < f.rIn) : f =ᶠ[𝓝 x] 1 := by filter_upwards [IsOpen.mem_nhds (isOpen_extChartAt_preimage I c isOpen_ball) ⟨hs, hd⟩] rintro z ⟨hzs, hzd⟩ exact f.one_of_dist_le hzs <| le_of_lt hzd #align smooth_bump_function.eventually_eq_one_of_dist_lt SmoothBumpFunction.eventuallyEq_one_of_dist_lt theorem eventuallyEq_one : f =ᶠ[𝓝 c] 1 := f.eventuallyEq_one_of_dist_lt (mem_chart_source _ _) <| by rw [dist_self]; exact f.rIn_pos #align smooth_bump_function.eventually_eq_one SmoothBumpFunction.eventuallyEq_one @[simp] theorem eq_one : f c = 1 := f.eventuallyEq_one.eq_of_nhds #align smooth_bump_function.eq_one SmoothBumpFunction.eq_one theorem support_mem_nhds : support f ∈ 𝓝 c := f.eventuallyEq_one.mono fun x hx => by rw [hx]; exact one_ne_zero #align smooth_bump_function.support_mem_nhds SmoothBumpFunction.support_mem_nhds theorem tsupport_mem_nhds : tsupport f ∈ 𝓝 c := mem_of_superset f.support_mem_nhds subset_closure #align smooth_bump_function.tsupport_mem_nhds SmoothBumpFunction.tsupport_mem_nhds theorem c_mem_support : c ∈ support f := mem_of_mem_nhds f.support_mem_nhds #align smooth_bump_function.c_mem_support SmoothBumpFunction.c_mem_support theorem nonempty_support : (support f).Nonempty := ⟨c, f.c_mem_support⟩ #align smooth_bump_function.nonempty_support SmoothBumpFunction.nonempty_support theorem isCompact_symm_image_closedBall : IsCompact ((extChartAt I c).symm '' (closedBall (extChartAt I c c) f.rOut ∩ range I)) := ((isCompact_closedBall _ _).inter_right I.isClosed_range).image_of_continuousOn <| (continuousOn_extChartAt_symm _ _).mono f.closedBall_subset #align smooth_bump_function.is_compact_symm_image_closed_ball SmoothBumpFunction.isCompact_symm_image_closedBall theorem nhdsWithin_range_basis : (𝓝[range I] extChartAt I c c).HasBasis (fun _ : SmoothBumpFunction I c => True) fun f => closedBall (extChartAt I c c) f.rOut ∩ range I := by refine ((nhdsWithin_hasBasis nhds_basis_closedBall _).restrict_subset (extChartAt_target_mem_nhdsWithin _ _)).to_hasBasis' ?_ ?_ · rintro R ⟨hR0, hsub⟩ exact ⟨⟨⟨R / 2, R, half_pos hR0, half_lt_self hR0⟩, hsub⟩, trivial, Subset.rfl⟩ · exact fun f _ => inter_mem (mem_nhdsWithin_of_mem_nhds <| closedBall_mem_nhds _ f.rOut_pos) self_mem_nhdsWithin #align smooth_bump_function.nhds_within_range_basis SmoothBumpFunction.nhdsWithin_range_basis theorem isClosed_image_of_isClosed {s : Set M} (hsc : IsClosed s) (hs : s ⊆ support f) : IsClosed (extChartAt I c '' s) := by rw [f.image_eq_inter_preimage_of_subset_support hs] refine ContinuousOn.preimage_isClosed_of_isClosed ((continuousOn_extChartAt_symm _ _).mono f.closedBall_subset) ?_ hsc exact IsClosed.inter isClosed_ball I.isClosed_range #align smooth_bump_function.is_closed_image_of_is_closed SmoothBumpFunction.isClosed_image_of_isClosed theorem exists_r_pos_lt_subset_ball {s : Set M} (hsc : IsClosed s) (hs : s ⊆ support f) : ∃ r ∈ Ioo 0 f.rOut, s ⊆ (chartAt H c).source ∩ extChartAt I c ⁻¹' ball (extChartAt I c c) r := by set e := extChartAt I c have : IsClosed (e '' s) := f.isClosed_image_of_isClosed hsc hs rw [support_eq_inter_preimage, subset_inter_iff, ← image_subset_iff] at hs rcases exists_pos_lt_subset_ball f.rOut_pos this hs.2 with ⟨r, hrR, hr⟩ exact ⟨r, hrR, subset_inter hs.1 (image_subset_iff.1 hr)⟩ #align smooth_bump_function.exists_r_pos_lt_subset_ball SmoothBumpFunction.exists_r_pos_lt_subset_ball @[simps rOut rIn] def updateRIn (r : ℝ) (hr : r ∈ Ioo 0 f.rOut) : SmoothBumpFunction I c := ⟨⟨r, f.rOut, hr.1, hr.2⟩, f.closedBall_subset⟩ #align smooth_bump_function.update_r SmoothBumpFunction.updateRIn set_option linter.uppercaseLean3 false in #align smooth_bump_function.update_r_R SmoothBumpFunction.updateRIn_rOut #align smooth_bump_function.update_r_r SmoothBumpFunction.updateRIn_rIn @[simp] theorem support_updateRIn {r : ℝ} (hr : r ∈ Ioo 0 f.rOut) : support (f.updateRIn r hr) = support f := by simp only [support_eq_inter_preimage, updateRIn_rOut] #align smooth_bump_function.support_update_r SmoothBumpFunction.support_updateRIn -- Porting note: was an `Inhabited` instance instance : Nonempty (SmoothBumpFunction I c) := nhdsWithin_range_basis.nonempty variable [T2Space M] theorem isClosed_symm_image_closedBall : IsClosed ((extChartAt I c).symm '' (closedBall (extChartAt I c c) f.rOut ∩ range I)) := f.isCompact_symm_image_closedBall.isClosed #align smooth_bump_function.is_closed_symm_image_closed_ball SmoothBumpFunction.isClosed_symm_image_closedBall theorem tsupport_subset_symm_image_closedBall : tsupport f ⊆ (extChartAt I c).symm '' (closedBall (extChartAt I c c) f.rOut ∩ range I) := by rw [tsupport, support_eq_symm_image] exact closure_minimal (image_subset _ <| inter_subset_inter_left _ ball_subset_closedBall) f.isClosed_symm_image_closedBall #align smooth_bump_function.tsupport_subset_symm_image_closed_ball SmoothBumpFunction.tsupport_subset_symm_image_closedBall theorem tsupport_subset_extChartAt_source : tsupport f ⊆ (extChartAt I c).source := calc tsupport f ⊆ (extChartAt I c).symm '' (closedBall (extChartAt I c c) f.rOut ∩ range I) := f.tsupport_subset_symm_image_closedBall _ ⊆ (extChartAt I c).symm '' (extChartAt I c).target := image_subset _ f.closedBall_subset _ = (extChartAt I c).source := (extChartAt I c).symm_image_target_eq_source #align smooth_bump_function.tsupport_subset_ext_chart_at_source SmoothBumpFunction.tsupport_subset_extChartAt_source theorem tsupport_subset_chartAt_source : tsupport f ⊆ (chartAt H c).source := by simpa only [extChartAt_source] using f.tsupport_subset_extChartAt_source #align smooth_bump_function.tsupport_subset_chart_at_source SmoothBumpFunction.tsupport_subset_chartAt_source protected theorem hasCompactSupport : HasCompactSupport f := f.isCompact_symm_image_closedBall.of_isClosed_subset isClosed_closure f.tsupport_subset_symm_image_closedBall #align smooth_bump_function.has_compact_support SmoothBumpFunction.hasCompactSupport variable (I c)
Mathlib/Geometry/Manifold/BumpFunction.lean
290
298
theorem nhds_basis_tsupport : (𝓝 c).HasBasis (fun _ : SmoothBumpFunction I c => True) fun f => tsupport f := by
have : (𝓝 c).HasBasis (fun _ : SmoothBumpFunction I c => True) fun f => (extChartAt I c).symm '' (closedBall (extChartAt I c c) f.rOut ∩ range I) := by rw [← map_extChartAt_symm_nhdsWithin_range I c] exact nhdsWithin_range_basis.map _ exact this.to_hasBasis' (fun f _ => ⟨f, trivial, f.tsupport_subset_symm_image_closedBall⟩) fun f _ => f.tsupport_mem_nhds
import Aesop import Mathlib.Algebra.Group.Defs import Mathlib.Data.Nat.Defs import Mathlib.Data.Int.Defs import Mathlib.Logic.Function.Basic import Mathlib.Tactic.Cases import Mathlib.Tactic.SimpRw import Mathlib.Tactic.SplitIfs #align_import algebra.group.basic from "leanprover-community/mathlib"@"a07d750983b94c530ab69a726862c2ab6802b38c" assert_not_exists MonoidWithZero assert_not_exists DenselyOrdered open Function universe u variable {α β G M : Type*} section Semigroup variable [Semigroup α] @[to_additive] instance Semigroup.to_isAssociative : Std.Associative (α := α) (· * ·) := ⟨mul_assoc⟩ #align semigroup.to_is_associative Semigroup.to_isAssociative #align add_semigroup.to_is_associative AddSemigroup.to_isAssociative @[to_additive (attr := simp) "Composing two additions on the left by `y` then `x` is equal to an addition on the left by `x + y`."]
Mathlib/Algebra/Group/Basic.lean
117
119
theorem comp_mul_left (x y : α) : (x * ·) ∘ (y * ·) = (x * y * ·) := by
ext z simp [mul_assoc]
import Mathlib.Data.Opposite import Mathlib.Data.Set.Defs #align_import data.set.opposite from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" variable {α : Type*} open Opposite namespace Set protected def op (s : Set α) : Set αᵒᵖ := unop ⁻¹' s #align set.op Set.op protected def unop (s : Set αᵒᵖ) : Set α := op ⁻¹' s #align set.unop Set.unop @[simp] theorem mem_op {s : Set α} {a : αᵒᵖ} : a ∈ s.op ↔ unop a ∈ s := Iff.rfl #align set.mem_op Set.mem_op @[simp 1100] theorem op_mem_op {s : Set α} {a : α} : op a ∈ s.op ↔ a ∈ s := by rfl #align set.op_mem_op Set.op_mem_op @[simp] theorem mem_unop {s : Set αᵒᵖ} {a : α} : a ∈ s.unop ↔ op a ∈ s := Iff.rfl #align set.mem_unop Set.mem_unop @[simp 1100] theorem unop_mem_unop {s : Set αᵒᵖ} {a : αᵒᵖ} : unop a ∈ s.unop ↔ a ∈ s := by rfl #align set.unop_mem_unop Set.unop_mem_unop @[simp] theorem op_unop (s : Set α) : s.op.unop = s := rfl #align set.op_unop Set.op_unop @[simp] theorem unop_op (s : Set αᵒᵖ) : s.unop.op = s := rfl #align set.unop_op Set.unop_op @[simps] def opEquiv_self (s : Set α) : s.op ≃ s := ⟨fun x ↦ ⟨unop x, x.2⟩, fun x ↦ ⟨op x, x.2⟩, fun _ ↦ rfl, fun _ ↦ rfl⟩ #align set.op_equiv_self Set.opEquiv_self #align set.op_equiv_self_apply_coe Set.opEquiv_self_apply_coe #align set.op_equiv_self_symm_apply_coe Set.opEquiv_self_symm_apply_coe @[simps] def opEquiv : Set α ≃ Set αᵒᵖ := ⟨Set.op, Set.unop, op_unop, unop_op⟩ #align set.op_equiv Set.opEquiv #align set.op_equiv_symm_apply Set.opEquiv_symm_apply #align set.op_equiv_apply Set.opEquiv_apply @[simp] theorem singleton_op (x : α) : ({x} : Set α).op = {op x} := by ext constructor · apply unop_injective · apply op_injective #align set.singleton_op Set.singleton_op @[simp] theorem singleton_unop (x : αᵒᵖ) : ({x} : Set αᵒᵖ).unop = {unop x} := by ext constructor · apply op_injective · apply unop_injective #align set.singleton_unop Set.singleton_unop @[simp 1100] theorem singleton_op_unop (x : α) : ({op x} : Set αᵒᵖ).unop = {x} := by ext constructor · apply op_injective · apply unop_injective #align set.singleton_op_unop Set.singleton_op_unop @[simp 1100]
Mathlib/Data/Set/Opposite.lean
100
104
theorem singleton_unop_op (x : αᵒᵖ) : ({unop x} : Set α).op = {x} := by
ext constructor · apply unop_injective · apply op_injective
import Mathlib.Data.ENNReal.Operations #align_import data.real.ennreal from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" open Set NNReal namespace ENNReal noncomputable section Inv variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0} protected theorem div_eq_inv_mul : a / b = b⁻¹ * a := by rw [div_eq_mul_inv, mul_comm] #align ennreal.div_eq_inv_mul ENNReal.div_eq_inv_mul @[simp] theorem inv_zero : (0 : ℝ≥0∞)⁻¹ = ∞ := show sInf { b : ℝ≥0∞ | 1 ≤ 0 * b } = ∞ by simp #align ennreal.inv_zero ENNReal.inv_zero @[simp] theorem inv_top : ∞⁻¹ = 0 := bot_unique <| le_of_forall_le_of_dense fun a (h : 0 < a) => sInf_le <| by simp [*, h.ne', top_mul] #align ennreal.inv_top ENNReal.inv_top theorem coe_inv_le : (↑r⁻¹ : ℝ≥0∞) ≤ (↑r)⁻¹ := le_sInf fun b (hb : 1 ≤ ↑r * b) => coe_le_iff.2 <| by rintro b rfl apply NNReal.inv_le_of_le_mul rwa [← coe_mul, ← coe_one, coe_le_coe] at hb #align ennreal.coe_inv_le ENNReal.coe_inv_le @[simp, norm_cast] theorem coe_inv (hr : r ≠ 0) : (↑r⁻¹ : ℝ≥0∞) = (↑r)⁻¹ := coe_inv_le.antisymm <| sInf_le <| mem_setOf.2 <| by rw [← coe_mul, mul_inv_cancel hr, coe_one] #align ennreal.coe_inv ENNReal.coe_inv @[norm_cast] theorem coe_inv_two : ((2⁻¹ : ℝ≥0) : ℝ≥0∞) = 2⁻¹ := by rw [coe_inv _root_.two_ne_zero, coe_two] #align ennreal.coe_inv_two ENNReal.coe_inv_two @[simp, norm_cast] theorem coe_div (hr : r ≠ 0) : (↑(p / r) : ℝ≥0∞) = p / r := by rw [div_eq_mul_inv, div_eq_mul_inv, coe_mul, coe_inv hr] #align ennreal.coe_div ENNReal.coe_div lemma coe_div_le : ↑(p / r) ≤ (p / r : ℝ≥0∞) := by simpa only [div_eq_mul_inv, coe_mul] using mul_le_mul_left' coe_inv_le _ theorem div_zero (h : a ≠ 0) : a / 0 = ∞ := by simp [div_eq_mul_inv, h] #align ennreal.div_zero ENNReal.div_zero instance : DivInvOneMonoid ℝ≥0∞ := { inferInstanceAs (DivInvMonoid ℝ≥0∞) with inv_one := by simpa only [coe_inv one_ne_zero, coe_one] using coe_inj.2 inv_one } protected theorem inv_pow : ∀ {a : ℝ≥0∞} {n : ℕ}, (a ^ n)⁻¹ = a⁻¹ ^ n | _, 0 => by simp only [pow_zero, inv_one] | ⊤, n + 1 => by simp [top_pow] | (a : ℝ≥0), n + 1 => by rcases eq_or_ne a 0 with (rfl | ha) · simp [top_pow] · have := pow_ne_zero (n + 1) ha norm_cast rw [inv_pow] #align ennreal.inv_pow ENNReal.inv_pow protected theorem mul_inv_cancel (h0 : a ≠ 0) (ht : a ≠ ∞) : a * a⁻¹ = 1 := by lift a to ℝ≥0 using ht norm_cast at h0; norm_cast exact mul_inv_cancel h0 #align ennreal.mul_inv_cancel ENNReal.mul_inv_cancel protected theorem inv_mul_cancel (h0 : a ≠ 0) (ht : a ≠ ∞) : a⁻¹ * a = 1 := mul_comm a a⁻¹ ▸ ENNReal.mul_inv_cancel h0 ht #align ennreal.inv_mul_cancel ENNReal.inv_mul_cancel protected theorem div_mul_cancel (h0 : a ≠ 0) (hI : a ≠ ∞) : b / a * a = b := by rw [div_eq_mul_inv, mul_assoc, ENNReal.inv_mul_cancel h0 hI, mul_one] #align ennreal.div_mul_cancel ENNReal.div_mul_cancel protected theorem mul_div_cancel' (h0 : a ≠ 0) (hI : a ≠ ∞) : a * (b / a) = b := by rw [mul_comm, ENNReal.div_mul_cancel h0 hI] #align ennreal.mul_div_cancel' ENNReal.mul_div_cancel' -- Porting note: `simp only [div_eq_mul_inv, mul_comm, mul_assoc]` doesn't work in the following two protected theorem mul_comm_div : a / b * c = a * (c / b) := by simp only [div_eq_mul_inv, mul_right_comm, ← mul_assoc] #align ennreal.mul_comm_div ENNReal.mul_comm_div protected theorem mul_div_right_comm : a * b / c = a / c * b := by simp only [div_eq_mul_inv, mul_right_comm] #align ennreal.mul_div_right_comm ENNReal.mul_div_right_comm instance : InvolutiveInv ℝ≥0∞ where inv_inv a := by by_cases a = 0 <;> cases a <;> simp_all [none_eq_top, some_eq_coe, -coe_inv, (coe_inv _).symm] @[simp] protected lemma inv_eq_one : a⁻¹ = 1 ↔ a = 1 := by rw [← inv_inj, inv_inv, inv_one] @[simp] theorem inv_eq_top : a⁻¹ = ∞ ↔ a = 0 := inv_zero ▸ inv_inj #align ennreal.inv_eq_top ENNReal.inv_eq_top theorem inv_ne_top : a⁻¹ ≠ ∞ ↔ a ≠ 0 := by simp #align ennreal.inv_ne_top ENNReal.inv_ne_top @[simp]
Mathlib/Data/ENNReal/Inv.lean
137
138
theorem inv_lt_top {x : ℝ≥0∞} : x⁻¹ < ∞ ↔ 0 < x := by
simp only [lt_top_iff_ne_top, inv_ne_top, pos_iff_ne_zero]
import Mathlib.Probability.Notation import Mathlib.Probability.Integration import Mathlib.MeasureTheory.Function.L2Space #align_import probability.variance from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" open MeasureTheory Filter Finset noncomputable section open scoped MeasureTheory ProbabilityTheory ENNReal NNReal namespace ProbabilityTheory -- Porting note: this lemma replaces `ENNReal.toReal_bit0`, which does not exist in Lean 4 private lemma coe_two : ENNReal.toReal 2 = (2 : ℝ) := rfl -- Porting note: Consider if `evariance` or `eVariance` is better. Also, -- consider `eVariationOn` in `Mathlib.Analysis.BoundedVariation`. def evariance {Ω : Type*} {_ : MeasurableSpace Ω} (X : Ω → ℝ) (μ : Measure Ω) : ℝ≥0∞ := ∫⁻ ω, (‖X ω - μ[X]‖₊ : ℝ≥0∞) ^ 2 ∂μ #align probability_theory.evariance ProbabilityTheory.evariance def variance {Ω : Type*} {_ : MeasurableSpace Ω} (X : Ω → ℝ) (μ : Measure Ω) : ℝ := (evariance X μ).toReal #align probability_theory.variance ProbabilityTheory.variance variable {Ω : Type*} {m : MeasurableSpace Ω} {X : Ω → ℝ} {μ : Measure Ω} theorem _root_.MeasureTheory.Memℒp.evariance_lt_top [IsFiniteMeasure μ] (hX : Memℒp X 2 μ) : evariance X μ < ∞ := by have := ENNReal.pow_lt_top (hX.sub <| memℒp_const <| μ[X]).2 2 rw [snorm_eq_lintegral_rpow_nnnorm two_ne_zero ENNReal.two_ne_top, ← ENNReal.rpow_two] at this simp only [coe_two, Pi.sub_apply, ENNReal.one_toReal, one_div] at this rw [← ENNReal.rpow_mul, inv_mul_cancel (two_ne_zero : (2 : ℝ) ≠ 0), ENNReal.rpow_one] at this simp_rw [ENNReal.rpow_two] at this exact this #align measure_theory.mem_ℒp.evariance_lt_top MeasureTheory.Memℒp.evariance_lt_top theorem evariance_eq_top [IsFiniteMeasure μ] (hXm : AEStronglyMeasurable X μ) (hX : ¬Memℒp X 2 μ) : evariance X μ = ∞ := by by_contra h rw [← Ne, ← lt_top_iff_ne_top] at h have : Memℒp (fun ω => X ω - μ[X]) 2 μ := by refine ⟨hXm.sub aestronglyMeasurable_const, ?_⟩ rw [snorm_eq_lintegral_rpow_nnnorm two_ne_zero ENNReal.two_ne_top] simp only [coe_two, ENNReal.one_toReal, ENNReal.rpow_two, Ne] exact ENNReal.rpow_lt_top_of_nonneg (by linarith) h.ne refine hX ?_ -- Porting note: `μ[X]` without whitespace is ambiguous as it could be GetElem, -- and `convert` cannot disambiguate based on typeclass inference failure. convert this.add (memℒp_const <| μ [X]) ext ω rw [Pi.add_apply, sub_add_cancel] #align probability_theory.evariance_eq_top ProbabilityTheory.evariance_eq_top theorem evariance_lt_top_iff_memℒp [IsFiniteMeasure μ] (hX : AEStronglyMeasurable X μ) : evariance X μ < ∞ ↔ Memℒp X 2 μ := by refine ⟨?_, MeasureTheory.Memℒp.evariance_lt_top⟩ contrapose rw [not_lt, top_le_iff] exact evariance_eq_top hX #align probability_theory.evariance_lt_top_iff_mem_ℒp ProbabilityTheory.evariance_lt_top_iff_memℒp theorem _root_.MeasureTheory.Memℒp.ofReal_variance_eq [IsFiniteMeasure μ] (hX : Memℒp X 2 μ) : ENNReal.ofReal (variance X μ) = evariance X μ := by rw [variance, ENNReal.ofReal_toReal] exact hX.evariance_lt_top.ne #align measure_theory.mem_ℒp.of_real_variance_eq MeasureTheory.Memℒp.ofReal_variance_eq
Mathlib/Probability/Variance.lean
106
113
theorem evariance_eq_lintegral_ofReal (X : Ω → ℝ) (μ : Measure Ω) : evariance X μ = ∫⁻ ω, ENNReal.ofReal ((X ω - μ[X]) ^ 2) ∂μ := by
rw [evariance] congr ext1 ω rw [pow_two, ← ENNReal.coe_mul, ← nnnorm_mul, ← pow_two] congr exact (Real.toNNReal_eq_nnnorm_of_nonneg <| sq_nonneg _).symm
import Mathlib.Algebra.Order.Group.Instances import Mathlib.Algebra.Order.Group.OrderIso import Mathlib.Data.Set.Pointwise.SMul import Mathlib.Order.UpperLower.Basic #align_import algebra.order.upper_lower from "leanprover-community/mathlib"@"c0c52abb75074ed8b73a948341f50521fbf43b4c" open Function Set open Pointwise section OrderedCommGroup variable {α : Type*} [OrderedCommGroup α] {s t : Set α} {a : α} @[to_additive] theorem IsUpperSet.smul (hs : IsUpperSet s) : IsUpperSet (a • s) := hs.image <| OrderIso.mulLeft _ #align is_upper_set.smul IsUpperSet.smul #align is_upper_set.vadd IsUpperSet.vadd @[to_additive] theorem IsLowerSet.smul (hs : IsLowerSet s) : IsLowerSet (a • s) := hs.image <| OrderIso.mulLeft _ #align is_lower_set.smul IsLowerSet.smul #align is_lower_set.vadd IsLowerSet.vadd @[to_additive]
Mathlib/Algebra/Order/UpperLower.lean
56
58
theorem Set.OrdConnected.smul (hs : s.OrdConnected) : (a • s).OrdConnected := by
rw [← hs.upperClosure_inter_lowerClosure, smul_set_inter] exact (upperClosure _).upper.smul.ordConnected.inter (lowerClosure _).lower.smul.ordConnected
import Mathlib.Analysis.SpecialFunctions.Complex.Log #align_import analysis.special_functions.pow.complex from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" open scoped Classical open Real Topology Filter ComplexConjugate Finset Set namespace Complex noncomputable def cpow (x y : ℂ) : ℂ := if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) #align complex.cpow Complex.cpow noncomputable instance : Pow ℂ ℂ := ⟨cpow⟩ @[simp] theorem cpow_eq_pow (x y : ℂ) : cpow x y = x ^ y := rfl #align complex.cpow_eq_pow Complex.cpow_eq_pow theorem cpow_def (x y : ℂ) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) := rfl #align complex.cpow_def Complex.cpow_def theorem cpow_def_of_ne_zero {x : ℂ} (hx : x ≠ 0) (y : ℂ) : x ^ y = exp (log x * y) := if_neg hx #align complex.cpow_def_of_ne_zero Complex.cpow_def_of_ne_zero @[simp] theorem cpow_zero (x : ℂ) : x ^ (0 : ℂ) = 1 := by simp [cpow_def] #align complex.cpow_zero Complex.cpow_zero @[simp] theorem cpow_eq_zero_iff (x y : ℂ) : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by simp only [cpow_def] split_ifs <;> simp [*, exp_ne_zero] #align complex.cpow_eq_zero_iff Complex.cpow_eq_zero_iff @[simp]
Mathlib/Analysis/SpecialFunctions/Pow/Complex.lean
55
55
theorem zero_cpow {x : ℂ} (h : x ≠ 0) : (0 : ℂ) ^ x = 0 := by
simp [cpow_def, *]
import Mathlib.Algebra.Order.Field.Basic import Mathlib.Data.Nat.Cast.Order import Mathlib.Tactic.Common #align_import data.nat.cast.field from "leanprover-community/mathlib"@"acee671f47b8e7972a1eb6f4eed74b4b3abce829" namespace Nat variable {α : Type*} @[simp] theorem cast_div [DivisionSemiring α] {m n : ℕ} (n_dvd : n ∣ m) (hn : (n : α) ≠ 0) : ((m / n : ℕ) : α) = m / n := by rcases n_dvd with ⟨k, rfl⟩ have : n ≠ 0 := by rintro rfl; simp at hn rw [Nat.mul_div_cancel_left _ this.bot_lt, mul_comm n, cast_mul, mul_div_cancel_right₀ _ hn] #align nat.cast_div Nat.cast_div theorem cast_div_div_div_cancel_right [DivisionSemiring α] [CharZero α] {m n d : ℕ} (hn : d ∣ n) (hm : d ∣ m) : (↑(m / d) : α) / (↑(n / d) : α) = (m : α) / n := by rcases eq_or_ne d 0 with (rfl | hd); · simp [Nat.zero_dvd.1 hm] replace hd : (d : α) ≠ 0 := by norm_cast rw [cast_div hm, cast_div hn, div_div_div_cancel_right _ hd] <;> exact hd #align nat.cast_div_div_div_cancel_right Nat.cast_div_div_div_cancel_right section LinearOrderedSemifield variable [LinearOrderedSemifield α] lemma cast_inv_le_one : ∀ n : ℕ, (n⁻¹ : α) ≤ 1 | 0 => by simp | n + 1 => inv_le_one $ by simp [Nat.cast_nonneg] theorem cast_div_le {m n : ℕ} : ((m / n : ℕ) : α) ≤ m / n := by cases n · rw [cast_zero, div_zero, Nat.div_zero, cast_zero] rw [le_div_iff, ← Nat.cast_mul, @Nat.cast_le] · exact Nat.div_mul_le_self m _ · exact Nat.cast_pos.2 (Nat.succ_pos _) #align nat.cast_div_le Nat.cast_div_le theorem inv_pos_of_nat {n : ℕ} : 0 < ((n : α) + 1)⁻¹ := inv_pos.2 <| add_pos_of_nonneg_of_pos n.cast_nonneg zero_lt_one #align nat.inv_pos_of_nat Nat.inv_pos_of_nat theorem one_div_pos_of_nat {n : ℕ} : 0 < 1 / ((n : α) + 1) := by rw [one_div] exact inv_pos_of_nat #align nat.one_div_pos_of_nat Nat.one_div_pos_of_nat theorem one_div_le_one_div {n m : ℕ} (h : n ≤ m) : 1 / ((m : α) + 1) ≤ 1 / ((n : α) + 1) := by refine one_div_le_one_div_of_le ?_ ?_ · exact Nat.cast_add_one_pos _ · simpa #align nat.one_div_le_one_div Nat.one_div_le_one_div
Mathlib/Data/Nat/Cast/Field.lean
76
79
theorem one_div_lt_one_div {n m : ℕ} (h : n < m) : 1 / ((m : α) + 1) < 1 / ((n : α) + 1) := by
refine one_div_lt_one_div_of_lt ?_ ?_ · exact Nat.cast_add_one_pos _ · simpa
import Mathlib.Algebra.Lie.Abelian import Mathlib.Algebra.Lie.IdealOperations import Mathlib.Algebra.Lie.Quotient #align_import algebra.lie.normalizer from "leanprover-community/mathlib"@"938fead7abdc0cbbca8eba7a1052865a169dc102" variable {R L M M' : Type*} variable [CommRing R] [LieRing L] [LieAlgebra R L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] variable [AddCommGroup M'] [Module R M'] [LieRingModule L M'] [LieModule R L M'] namespace LieSubmodule variable (N : LieSubmodule R L M) {N₁ N₂ : LieSubmodule R L M} def normalizer : LieSubmodule R L M where carrier := {m | ∀ x : L, ⁅x, m⁆ ∈ N} add_mem' hm₁ hm₂ x := by rw [lie_add]; exact N.add_mem' (hm₁ x) (hm₂ x) zero_mem' x := by simp smul_mem' t m hm x := by rw [lie_smul]; exact N.smul_mem' t (hm x) lie_mem {x m} hm y := by rw [leibniz_lie]; exact N.add_mem' (hm ⁅y, x⁆) (N.lie_mem (hm y)) #align lie_submodule.normalizer LieSubmodule.normalizer @[simp] theorem mem_normalizer (m : M) : m ∈ N.normalizer ↔ ∀ x : L, ⁅x, m⁆ ∈ N := Iff.rfl #align lie_submodule.mem_normalizer LieSubmodule.mem_normalizer @[simp] theorem le_normalizer : N ≤ N.normalizer := by intro m hm rw [mem_normalizer] exact fun x => N.lie_mem hm #align lie_submodule.le_normalizer LieSubmodule.le_normalizer theorem normalizer_inf : (N₁ ⊓ N₂).normalizer = N₁.normalizer ⊓ N₂.normalizer := by ext; simp [← forall_and] #align lie_submodule.normalizer_inf LieSubmodule.normalizer_inf @[mono] theorem monotone_normalizer : Monotone (normalizer : LieSubmodule R L M → LieSubmodule R L M) := by intro N₁ N₂ h m hm rw [mem_normalizer] at hm ⊢ exact fun x => h (hm x) #align lie_submodule.monotone_normalizer LieSubmodule.monotone_normalizer @[simp]
Mathlib/Algebra/Lie/Normalizer.lean
82
83
theorem comap_normalizer (f : M' →ₗ⁅R,L⁆ M) : N.normalizer.comap f = (N.comap f).normalizer := by
ext; simp
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
Mathlib/Topology/Basic.lean
502
504
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]
import Mathlib.Algebra.QuadraticDiscriminant import Mathlib.Analysis.Convex.SpecificFunctions.Deriv import Mathlib.Analysis.SpecialFunctions.Pow.Complex #align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92" noncomputable section namespace Complex open Set Filter open scoped Real theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul, add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub] ring_nf rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm] refine exists_congr fun x => ?_ refine (iff_of_eq <| congr_arg _ ?_).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero) field_simp; ring #align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by rw [← not_exists, not_iff_not, cos_eq_zero_iff] #align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff] constructor · rintro ⟨k, hk⟩ use k + 1 field_simp [eq_add_of_sub_eq hk] ring · rintro ⟨k, rfl⟩ use k - 1 field_simp ring #align complex.sin_eq_zero_iff Complex.sin_eq_zero_iff theorem sin_ne_zero_iff {θ : ℂ} : sin θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π := by rw [← not_exists, not_iff_not, sin_eq_zero_iff] #align complex.sin_ne_zero_iff Complex.sin_ne_zero_iff theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, k * π / 2 = θ := by rw [tan, div_eq_zero_iff, ← mul_eq_zero, ← mul_right_inj' two_ne_zero, mul_zero, ← mul_assoc, ← sin_two_mul, sin_eq_zero_iff] field_simp [mul_comm, eq_comm] #align complex.tan_eq_zero_iff Complex.tan_eq_zero_iff theorem tan_ne_zero_iff {θ : ℂ} : tan θ ≠ 0 ↔ ∀ k : ℤ, (k * π / 2 : ℂ) ≠ θ := by rw [← not_exists, not_iff_not, tan_eq_zero_iff] #align complex.tan_ne_zero_iff Complex.tan_ne_zero_iff theorem tan_int_mul_pi_div_two (n : ℤ) : tan (n * π / 2) = 0 := tan_eq_zero_iff.mpr (by use n) #align complex.tan_int_mul_pi_div_two Complex.tan_int_mul_pi_div_two theorem tan_eq_zero_iff' {θ : ℂ} (hθ : cos θ ≠ 0) : tan θ = 0 ↔ ∃ k : ℤ, k * π = θ := by simp only [tan, hθ, div_eq_zero_iff, sin_eq_zero_iff]; simp [eq_comm] theorem cos_eq_cos_iff {x y : ℂ} : cos x = cos y ↔ ∃ k : ℤ, y = 2 * k * π + x ∨ y = 2 * k * π - x := calc cos x = cos y ↔ cos x - cos y = 0 := sub_eq_zero.symm _ ↔ -2 * sin ((x + y) / 2) * sin ((x - y) / 2) = 0 := by rw [cos_sub_cos] _ ↔ sin ((x + y) / 2) = 0 ∨ sin ((x - y) / 2) = 0 := by simp [(by norm_num : (2 : ℂ) ≠ 0)] _ ↔ sin ((x - y) / 2) = 0 ∨ sin ((x + y) / 2) = 0 := or_comm _ ↔ (∃ k : ℤ, y = 2 * k * π + x) ∨ ∃ k : ℤ, y = 2 * k * π - x := by apply or_congr <;> field_simp [sin_eq_zero_iff, (by norm_num : -(2 : ℂ) ≠ 0), eq_sub_iff_add_eq', sub_eq_iff_eq_add, mul_comm (2 : ℂ), mul_right_comm _ (2 : ℂ)] constructor <;> · rintro ⟨k, rfl⟩; use -k; simp _ ↔ ∃ k : ℤ, y = 2 * k * π + x ∨ y = 2 * k * π - x := exists_or.symm #align complex.cos_eq_cos_iff Complex.cos_eq_cos_iff theorem sin_eq_sin_iff {x y : ℂ} : sin x = sin y ↔ ∃ k : ℤ, y = 2 * k * π + x ∨ y = (2 * k + 1) * π - x := by simp only [← Complex.cos_sub_pi_div_two, cos_eq_cos_iff, sub_eq_iff_eq_add] refine exists_congr fun k => or_congr ?_ ?_ <;> refine Eq.congr rfl ?_ <;> field_simp <;> ring #align complex.sin_eq_sin_iff Complex.sin_eq_sin_iff theorem cos_eq_one_iff {x : ℂ} : cos x = 1 ↔ ∃ k : ℤ, k * (2 * π) = x := by rw [← cos_zero, eq_comm, cos_eq_cos_iff] simp [mul_assoc, mul_left_comm, eq_comm] theorem cos_eq_neg_one_iff {x : ℂ} : cos x = -1 ↔ ∃ k : ℤ, π + k * (2 * π) = x := by rw [← neg_eq_iff_eq_neg, ← cos_sub_pi, cos_eq_one_iff] simp only [eq_sub_iff_add_eq'] theorem sin_eq_one_iff {x : ℂ} : sin x = 1 ↔ ∃ k : ℤ, π / 2 + k * (2 * π) = x := by rw [← cos_sub_pi_div_two, cos_eq_one_iff] simp only [eq_sub_iff_add_eq'] theorem sin_eq_neg_one_iff {x : ℂ} : sin x = -1 ↔ ∃ k : ℤ, -(π / 2) + k * (2 * π) = x := by rw [← neg_eq_iff_eq_neg, ← cos_add_pi_div_two, cos_eq_one_iff] simp only [← sub_eq_neg_add, sub_eq_iff_eq_add] theorem tan_add {x y : ℂ} (h : ((∀ k : ℤ, x ≠ (2 * k + 1) * π / 2) ∧ ∀ l : ℤ, y ≠ (2 * l + 1) * π / 2) ∨ (∃ k : ℤ, x = (2 * k + 1) * π / 2) ∧ ∃ l : ℤ, y = (2 * l + 1) * π / 2) : tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) := by rcases h with (⟨h1, h2⟩ | ⟨⟨k, rfl⟩, ⟨l, rfl⟩⟩) · rw [tan, sin_add, cos_add, ← div_div_div_cancel_right (sin x * cos y + cos x * sin y) (mul_ne_zero (cos_ne_zero_iff.mpr h1) (cos_ne_zero_iff.mpr h2)), add_div, sub_div] simp only [← div_mul_div_comm, tan, mul_one, one_mul, div_self (cos_ne_zero_iff.mpr h1), div_self (cos_ne_zero_iff.mpr h2)] · haveI t := tan_int_mul_pi_div_two obtain ⟨hx, hy, hxy⟩ := t (2 * k + 1), t (2 * l + 1), t (2 * k + 1 + (2 * l + 1)) simp only [Int.cast_add, Int.cast_two, Int.cast_mul, Int.cast_one, hx, hy] at hx hy hxy rw [hx, hy, add_zero, zero_div, mul_div_assoc, mul_div_assoc, ← add_mul (2 * (k : ℂ) + 1) (2 * l + 1) (π / 2), ← mul_div_assoc, hxy] #align complex.tan_add Complex.tan_add theorem tan_add' {x y : ℂ} (h : (∀ k : ℤ, x ≠ (2 * k + 1) * π / 2) ∧ ∀ l : ℤ, y ≠ (2 * l + 1) * π / 2) : tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) := tan_add (Or.inl h) #align complex.tan_add' Complex.tan_add' theorem tan_two_mul {z : ℂ} : tan (2 * z) = (2 : ℂ) * tan z / ((1 : ℂ) - tan z ^ 2) := by by_cases h : ∀ k : ℤ, z ≠ (2 * k + 1) * π / 2 · rw [two_mul, two_mul, sq, tan_add (Or.inl ⟨h, h⟩)] · rw [not_forall_not] at h rw [two_mul, two_mul, sq, tan_add (Or.inr ⟨h, h⟩)] #align complex.tan_two_mul Complex.tan_two_mul theorem tan_add_mul_I {x y : ℂ} (h : ((∀ k : ℤ, x ≠ (2 * k + 1) * π / 2) ∧ ∀ l : ℤ, y * I ≠ (2 * l + 1) * π / 2) ∨ (∃ k : ℤ, x = (2 * k + 1) * π / 2) ∧ ∃ l : ℤ, y * I = (2 * l + 1) * π / 2) : tan (x + y * I) = (tan x + tanh y * I) / (1 - tan x * tanh y * I) := by rw [tan_add h, tan_mul_I, mul_assoc] set_option linter.uppercaseLean3 false in #align complex.tan_add_mul_I Complex.tan_add_mul_I theorem tan_eq {z : ℂ} (h : ((∀ k : ℤ, (z.re : ℂ) ≠ (2 * k + 1) * π / 2) ∧ ∀ l : ℤ, (z.im : ℂ) * I ≠ (2 * l + 1) * π / 2) ∨ (∃ k : ℤ, (z.re : ℂ) = (2 * k + 1) * π / 2) ∧ ∃ l : ℤ, (z.im : ℂ) * I = (2 * l + 1) * π / 2) : tan z = (tan z.re + tanh z.im * I) / (1 - tan z.re * tanh z.im * I) := by convert tan_add_mul_I h; exact (re_add_im z).symm #align complex.tan_eq Complex.tan_eq open scoped Topology theorem continuousOn_tan : ContinuousOn tan {x | cos x ≠ 0} := continuousOn_sin.div continuousOn_cos fun _x => id #align complex.continuous_on_tan Complex.continuousOn_tan @[continuity] theorem continuous_tan : Continuous fun x : {x | cos x ≠ 0} => tan x := continuousOn_iff_continuous_restrict.1 continuousOn_tan #align complex.continuous_tan Complex.continuous_tan theorem cos_eq_iff_quadratic {z w : ℂ} : cos z = w ↔ exp (z * I) ^ 2 - 2 * w * exp (z * I) + 1 = 0 := by rw [← sub_eq_zero] field_simp [cos, exp_neg, exp_ne_zero] refine Eq.congr ?_ rfl ring #align complex.cos_eq_iff_quadratic Complex.cos_eq_iff_quadratic theorem cos_surjective : Function.Surjective cos := by intro x obtain ⟨w, w₀, hw⟩ : ∃ w ≠ 0, 1 * w * w + -2 * x * w + 1 = 0 := by rcases exists_quadratic_eq_zero one_ne_zero ⟨_, (cpow_nat_inv_pow _ two_ne_zero).symm.trans <| pow_two _⟩ with ⟨w, hw⟩ refine ⟨w, ?_, hw⟩ rintro rfl simp only [zero_add, one_ne_zero, mul_zero] at hw refine ⟨log w / I, cos_eq_iff_quadratic.2 ?_⟩ rw [div_mul_cancel₀ _ I_ne_zero, exp_log w₀] convert hw using 1 ring #align complex.cos_surjective Complex.cos_surjective @[simp] theorem range_cos : Set.range cos = Set.univ := cos_surjective.range_eq #align complex.range_cos Complex.range_cos
Mathlib/Analysis/SpecialFunctions/Trigonometric/Complex.lean
215
218
theorem sin_surjective : Function.Surjective sin := by
intro x rcases cos_surjective x with ⟨z, rfl⟩ exact ⟨z + π / 2, sin_add_pi_div_two z⟩
import Mathlib.CategoryTheory.Subobject.MonoOver import Mathlib.CategoryTheory.Skeletal import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.Tactic.ApplyFun import Mathlib.Tactic.CategoryTheory.Elementwise #align_import category_theory.subobject.basic from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe v₁ v₂ u₁ u₂ noncomputable section namespace CategoryTheory open CategoryTheory CategoryTheory.Category CategoryTheory.Limits variable {C : Type u₁} [Category.{v₁} C] {X Y Z : C} variable {D : Type u₂} [Category.{v₂} D] def Subobject (X : C) := ThinSkeleton (MonoOver X) #align category_theory.subobject CategoryTheory.Subobject instance (X : C) : PartialOrder (Subobject X) := by dsimp only [Subobject] infer_instance namespace Subobject -- Porting note: made it a def rather than an abbreviation -- because Lean would make it too transparent def mk {X A : C} (f : A ⟶ X) [Mono f] : Subobject X := (toThinSkeleton _).obj (MonoOver.mk' f) #align category_theory.subobject.mk CategoryTheory.Subobject.mk section attribute [local ext] CategoryTheory.Comma protected theorem ind {X : C} (p : Subobject X → Prop) (h : ∀ ⦃A : C⦄ (f : A ⟶ X) [Mono f], p (Subobject.mk f)) (P : Subobject X) : p P := by apply Quotient.inductionOn' intro a exact h a.arrow #align category_theory.subobject.ind CategoryTheory.Subobject.ind protected theorem ind₂ {X : C} (p : Subobject X → Subobject X → Prop) (h : ∀ ⦃A B : C⦄ (f : A ⟶ X) (g : B ⟶ X) [Mono f] [Mono g], p (Subobject.mk f) (Subobject.mk g)) (P Q : Subobject X) : p P Q := by apply Quotient.inductionOn₂' intro a b exact h a.arrow b.arrow #align category_theory.subobject.ind₂ CategoryTheory.Subobject.ind₂ end protected def lift {α : Sort*} {X : C} (F : ∀ ⦃A : C⦄ (f : A ⟶ X) [Mono f], α) (h : ∀ ⦃A B : C⦄ (f : A ⟶ X) (g : B ⟶ X) [Mono f] [Mono g] (i : A ≅ B), i.hom ≫ g = f → F f = F g) : Subobject X → α := fun P => Quotient.liftOn' P (fun m => F m.arrow) fun m n ⟨i⟩ => h m.arrow n.arrow ((MonoOver.forget X ⋙ Over.forget X).mapIso i) (Over.w i.hom) #align category_theory.subobject.lift CategoryTheory.Subobject.lift @[simp] protected theorem lift_mk {α : Sort*} {X : C} (F : ∀ ⦃A : C⦄ (f : A ⟶ X) [Mono f], α) {h A} (f : A ⟶ X) [Mono f] : Subobject.lift F h (Subobject.mk f) = F f := rfl #align category_theory.subobject.lift_mk CategoryTheory.Subobject.lift_mk noncomputable def equivMonoOver (X : C) : Subobject X ≌ MonoOver X := ThinSkeleton.equivalence _ #align category_theory.subobject.equiv_mono_over CategoryTheory.Subobject.equivMonoOver noncomputable def representative {X : C} : Subobject X ⥤ MonoOver X := (equivMonoOver X).functor #align category_theory.subobject.representative CategoryTheory.Subobject.representative noncomputable def representativeIso {X : C} (A : MonoOver X) : representative.obj ((toThinSkeleton _).obj A) ≅ A := (equivMonoOver X).counitIso.app A #align category_theory.subobject.representative_iso CategoryTheory.Subobject.representativeIso noncomputable def underlying {X : C} : Subobject X ⥤ C := representative ⋙ MonoOver.forget _ ⋙ Over.forget _ #align category_theory.subobject.underlying CategoryTheory.Subobject.underlying instance : CoeOut (Subobject X) C where coe Y := underlying.obj Y -- Porting note: removed as it has become a syntactic tautology -- @[simp] -- theorem underlying_as_coe {X : C} (P : Subobject X) : underlying.obj P = P := -- rfl -- #align category_theory.subobject.underlying_as_coe CategoryTheory.Subobject.underlying_as_coe noncomputable def underlyingIso {X Y : C} (f : X ⟶ Y) [Mono f] : (Subobject.mk f : C) ≅ X := (MonoOver.forget _ ⋙ Over.forget _).mapIso (representativeIso (MonoOver.mk' f)) #align category_theory.subobject.underlying_iso CategoryTheory.Subobject.underlyingIso noncomputable def arrow {X : C} (Y : Subobject X) : (Y : C) ⟶ X := (representative.obj Y).obj.hom #align category_theory.subobject.arrow CategoryTheory.Subobject.arrow instance arrow_mono {X : C} (Y : Subobject X) : Mono Y.arrow := (representative.obj Y).property #align category_theory.subobject.arrow_mono CategoryTheory.Subobject.arrow_mono @[simp] theorem arrow_congr {A : C} (X Y : Subobject A) (h : X = Y) : eqToHom (congr_arg (fun X : Subobject A => (X : C)) h) ≫ Y.arrow = X.arrow := by induction h simp #align category_theory.subobject.arrow_congr CategoryTheory.Subobject.arrow_congr @[simp] theorem representative_coe (Y : Subobject X) : (representative.obj Y : C) = (Y : C) := rfl #align category_theory.subobject.representative_coe CategoryTheory.Subobject.representative_coe @[simp] theorem representative_arrow (Y : Subobject X) : (representative.obj Y).arrow = Y.arrow := rfl #align category_theory.subobject.representative_arrow CategoryTheory.Subobject.representative_arrow @[reassoc (attr := simp)] theorem underlying_arrow {X : C} {Y Z : Subobject X} (f : Y ⟶ Z) : underlying.map f ≫ arrow Z = arrow Y := Over.w (representative.map f) #align category_theory.subobject.underlying_arrow CategoryTheory.Subobject.underlying_arrow @[reassoc (attr := simp), elementwise (attr := simp)] theorem underlyingIso_arrow {X Y : C} (f : X ⟶ Y) [Mono f] : (underlyingIso f).inv ≫ (Subobject.mk f).arrow = f := Over.w _ #align category_theory.subobject.underlying_iso_arrow CategoryTheory.Subobject.underlyingIso_arrow @[reassoc (attr := simp)] theorem underlyingIso_hom_comp_eq_mk {X Y : C} (f : X ⟶ Y) [Mono f] : (underlyingIso f).hom ≫ f = (mk f).arrow := (Iso.eq_inv_comp _).1 (underlyingIso_arrow f).symm #align category_theory.subobject.underlying_iso_hom_comp_eq_mk CategoryTheory.Subobject.underlyingIso_hom_comp_eq_mk @[ext] theorem eq_of_comp_arrow_eq {X Y : C} {P : Subobject Y} {f g : X ⟶ P} (h : f ≫ P.arrow = g ≫ P.arrow) : f = g := (cancel_mono P.arrow).mp h #align category_theory.subobject.eq_of_comp_arrow_eq CategoryTheory.Subobject.eq_of_comp_arrow_eq theorem mk_le_mk_of_comm {B A₁ A₂ : C} {f₁ : A₁ ⟶ B} {f₂ : A₂ ⟶ B} [Mono f₁] [Mono f₂] (g : A₁ ⟶ A₂) (w : g ≫ f₂ = f₁) : mk f₁ ≤ mk f₂ := ⟨MonoOver.homMk _ w⟩ #align category_theory.subobject.mk_le_mk_of_comm CategoryTheory.Subobject.mk_le_mk_of_comm @[simp] theorem mk_arrow (P : Subobject X) : mk P.arrow = P := Quotient.inductionOn' P fun Q => by obtain ⟨e⟩ := @Quotient.mk_out' _ (isIsomorphicSetoid _) Q exact Quotient.sound' ⟨MonoOver.isoMk (Iso.refl _) ≪≫ e⟩ #align category_theory.subobject.mk_arrow CategoryTheory.Subobject.mk_arrow theorem le_of_comm {B : C} {X Y : Subobject B} (f : (X : C) ⟶ (Y : C)) (w : f ≫ Y.arrow = X.arrow) : X ≤ Y := by convert mk_le_mk_of_comm _ w <;> simp #align category_theory.subobject.le_of_comm CategoryTheory.Subobject.le_of_comm theorem le_mk_of_comm {B A : C} {X : Subobject B} {f : A ⟶ B} [Mono f] (g : (X : C) ⟶ A) (w : g ≫ f = X.arrow) : X ≤ mk f := le_of_comm (g ≫ (underlyingIso f).inv) <| by simp [w] #align category_theory.subobject.le_mk_of_comm CategoryTheory.Subobject.le_mk_of_comm theorem mk_le_of_comm {B A : C} {X : Subobject B} {f : A ⟶ B} [Mono f] (g : A ⟶ (X : C)) (w : g ≫ X.arrow = f) : mk f ≤ X := le_of_comm ((underlyingIso f).hom ≫ g) <| by simp [w] #align category_theory.subobject.mk_le_of_comm CategoryTheory.Subobject.mk_le_of_comm @[ext] theorem eq_of_comm {B : C} {X Y : Subobject B} (f : (X : C) ≅ (Y : C)) (w : f.hom ≫ Y.arrow = X.arrow) : X = Y := le_antisymm (le_of_comm f.hom w) <| le_of_comm f.inv <| f.inv_comp_eq.2 w.symm #align category_theory.subobject.eq_of_comm CategoryTheory.Subobject.eq_of_comm -- Porting note (#11182): removed @[ext] theorem eq_mk_of_comm {B A : C} {X : Subobject B} (f : A ⟶ B) [Mono f] (i : (X : C) ≅ A) (w : i.hom ≫ f = X.arrow) : X = mk f := eq_of_comm (i.trans (underlyingIso f).symm) <| by simp [w] #align category_theory.subobject.eq_mk_of_comm CategoryTheory.Subobject.eq_mk_of_comm -- Porting note (#11182): removed @[ext] theorem mk_eq_of_comm {B A : C} {X : Subobject B} (f : A ⟶ B) [Mono f] (i : A ≅ (X : C)) (w : i.hom ≫ X.arrow = f) : mk f = X := Eq.symm <| eq_mk_of_comm _ i.symm <| by rw [Iso.symm_hom, Iso.inv_comp_eq, w] #align category_theory.subobject.mk_eq_of_comm CategoryTheory.Subobject.mk_eq_of_comm -- Porting note (#11182): removed @[ext] theorem mk_eq_mk_of_comm {B A₁ A₂ : C} (f : A₁ ⟶ B) (g : A₂ ⟶ B) [Mono f] [Mono g] (i : A₁ ≅ A₂) (w : i.hom ≫ g = f) : mk f = mk g := eq_mk_of_comm _ ((underlyingIso f).trans i) <| by simp [w] #align category_theory.subobject.mk_eq_mk_of_comm CategoryTheory.Subobject.mk_eq_mk_of_comm -- We make `X` and `Y` explicit arguments here so that when `ofLE` appears in goal statements -- it is possible to see its source and target -- (`h` will just display as `_`, because it is in `Prop`). def ofLE {B : C} (X Y : Subobject B) (h : X ≤ Y) : (X : C) ⟶ (Y : C) := underlying.map <| h.hom #align category_theory.subobject.of_le CategoryTheory.Subobject.ofLE @[reassoc (attr := simp)] theorem ofLE_arrow {B : C} {X Y : Subobject B} (h : X ≤ Y) : ofLE X Y h ≫ Y.arrow = X.arrow := underlying_arrow _ #align category_theory.subobject.of_le_arrow CategoryTheory.Subobject.ofLE_arrow instance {B : C} (X Y : Subobject B) (h : X ≤ Y) : Mono (ofLE X Y h) := by fconstructor intro Z f g w replace w := w =≫ Y.arrow ext simpa using w theorem ofLE_mk_le_mk_of_comm {B A₁ A₂ : C} {f₁ : A₁ ⟶ B} {f₂ : A₂ ⟶ B} [Mono f₁] [Mono f₂] (g : A₁ ⟶ A₂) (w : g ≫ f₂ = f₁) : ofLE _ _ (mk_le_mk_of_comm g w) = (underlyingIso _).hom ≫ g ≫ (underlyingIso _).inv := by ext simp [w] #align category_theory.subobject.of_le_mk_le_mk_of_comm CategoryTheory.Subobject.ofLE_mk_le_mk_of_comm def ofLEMk {B A : C} (X : Subobject B) (f : A ⟶ B) [Mono f] (h : X ≤ mk f) : (X : C) ⟶ A := ofLE X (mk f) h ≫ (underlyingIso f).hom #align category_theory.subobject.of_le_mk CategoryTheory.Subobject.ofLEMk instance {B A : C} (X : Subobject B) (f : A ⟶ B) [Mono f] (h : X ≤ mk f) : Mono (ofLEMk X f h) := by dsimp only [ofLEMk] infer_instance @[simp] theorem ofLEMk_comp {B A : C} {X : Subobject B} {f : A ⟶ B} [Mono f] (h : X ≤ mk f) : ofLEMk X f h ≫ f = X.arrow := by simp [ofLEMk] #align category_theory.subobject.of_le_mk_comp CategoryTheory.Subobject.ofLEMk_comp def ofMkLE {B A : C} (f : A ⟶ B) [Mono f] (X : Subobject B) (h : mk f ≤ X) : A ⟶ (X : C) := (underlyingIso f).inv ≫ ofLE (mk f) X h #align category_theory.subobject.of_mk_le CategoryTheory.Subobject.ofMkLE instance {B A : C} (f : A ⟶ B) [Mono f] (X : Subobject B) (h : mk f ≤ X) : Mono (ofMkLE f X h) := by dsimp only [ofMkLE] infer_instance @[simp] theorem ofMkLE_arrow {B A : C} {f : A ⟶ B} [Mono f] {X : Subobject B} (h : mk f ≤ X) : ofMkLE f X h ≫ X.arrow = f := by simp [ofMkLE] #align category_theory.subobject.of_mk_le_arrow CategoryTheory.Subobject.ofMkLE_arrow def ofMkLEMk {B A₁ A₂ : C} (f : A₁ ⟶ B) (g : A₂ ⟶ B) [Mono f] [Mono g] (h : mk f ≤ mk g) : A₁ ⟶ A₂ := (underlyingIso f).inv ≫ ofLE (mk f) (mk g) h ≫ (underlyingIso g).hom #align category_theory.subobject.of_mk_le_mk CategoryTheory.Subobject.ofMkLEMk instance {B A₁ A₂ : C} (f : A₁ ⟶ B) (g : A₂ ⟶ B) [Mono f] [Mono g] (h : mk f ≤ mk g) : Mono (ofMkLEMk f g h) := by dsimp only [ofMkLEMk] infer_instance @[simp] theorem ofMkLEMk_comp {B A₁ A₂ : C} {f : A₁ ⟶ B} {g : A₂ ⟶ B} [Mono f] [Mono g] (h : mk f ≤ mk g) : ofMkLEMk f g h ≫ g = f := by simp [ofMkLEMk] #align category_theory.subobject.of_mk_le_mk_comp CategoryTheory.Subobject.ofMkLEMk_comp @[reassoc (attr := simp)] theorem ofLE_comp_ofLE {B : C} (X Y Z : Subobject B) (h₁ : X ≤ Y) (h₂ : Y ≤ Z) : ofLE X Y h₁ ≫ ofLE Y Z h₂ = ofLE X Z (h₁.trans h₂) := by simp only [ofLE, ← Functor.map_comp underlying] congr 1 #align category_theory.subobject.of_le_comp_of_le CategoryTheory.Subobject.ofLE_comp_ofLE @[reassoc (attr := simp)] theorem ofLE_comp_ofLEMk {B A : C} (X Y : Subobject B) (f : A ⟶ B) [Mono f] (h₁ : X ≤ Y) (h₂ : Y ≤ mk f) : ofLE X Y h₁ ≫ ofLEMk Y f h₂ = ofLEMk X f (h₁.trans h₂) := by simp only [ofMkLE, ofLEMk, ofLE, ← Functor.map_comp_assoc underlying] congr 1 #align category_theory.subobject.of_le_comp_of_le_mk CategoryTheory.Subobject.ofLE_comp_ofLEMk @[reassoc (attr := simp)] theorem ofLEMk_comp_ofMkLE {B A : C} (X : Subobject B) (f : A ⟶ B) [Mono f] (Y : Subobject B) (h₁ : X ≤ mk f) (h₂ : mk f ≤ Y) : ofLEMk X f h₁ ≫ ofMkLE f Y h₂ = ofLE X Y (h₁.trans h₂) := by simp only [ofMkLE, ofLEMk, ofLE, ← Functor.map_comp underlying, assoc, Iso.hom_inv_id_assoc] congr 1 #align category_theory.subobject.of_le_mk_comp_of_mk_le CategoryTheory.Subobject.ofLEMk_comp_ofMkLE @[reassoc (attr := simp)] theorem ofLEMk_comp_ofMkLEMk {B A₁ A₂ : C} (X : Subobject B) (f : A₁ ⟶ B) [Mono f] (g : A₂ ⟶ B) [Mono g] (h₁ : X ≤ mk f) (h₂ : mk f ≤ mk g) : ofLEMk X f h₁ ≫ ofMkLEMk f g h₂ = ofLEMk X g (h₁.trans h₂) := by simp only [ofMkLE, ofLEMk, ofLE, ofMkLEMk, ← Functor.map_comp_assoc underlying, assoc, Iso.hom_inv_id_assoc] congr 1 #align category_theory.subobject.of_le_mk_comp_of_mk_le_mk CategoryTheory.Subobject.ofLEMk_comp_ofMkLEMk @[reassoc (attr := simp)] theorem ofMkLE_comp_ofLE {B A₁ : C} (f : A₁ ⟶ B) [Mono f] (X Y : Subobject B) (h₁ : mk f ≤ X) (h₂ : X ≤ Y) : ofMkLE f X h₁ ≫ ofLE X Y h₂ = ofMkLE f Y (h₁.trans h₂) := by simp only [ofMkLE, ofLEMk, ofLE, ofMkLEMk, ← Functor.map_comp underlying, assoc] congr 1 #align category_theory.subobject.of_mk_le_comp_of_le CategoryTheory.Subobject.ofMkLE_comp_ofLE @[reassoc (attr := simp)] theorem ofMkLE_comp_ofLEMk {B A₁ A₂ : C} (f : A₁ ⟶ B) [Mono f] (X : Subobject B) (g : A₂ ⟶ B) [Mono g] (h₁ : mk f ≤ X) (h₂ : X ≤ mk g) : ofMkLE f X h₁ ≫ ofLEMk X g h₂ = ofMkLEMk f g (h₁.trans h₂) := by simp only [ofMkLE, ofLEMk, ofLE, ofMkLEMk, ← Functor.map_comp_assoc underlying, assoc] congr 1 #align category_theory.subobject.of_mk_le_comp_of_le_mk CategoryTheory.Subobject.ofMkLE_comp_ofLEMk @[reassoc (attr := simp)]
Mathlib/CategoryTheory/Subobject/Basic.lean
431
436
theorem ofMkLEMk_comp_ofMkLE {B A₁ A₂ : C} (f : A₁ ⟶ B) [Mono f] (g : A₂ ⟶ B) [Mono g] (X : Subobject B) (h₁ : mk f ≤ mk g) (h₂ : mk g ≤ X) : ofMkLEMk f g h₁ ≫ ofMkLE g X h₂ = ofMkLE f X (h₁.trans h₂) := by
simp only [ofMkLE, ofLEMk, ofLE, ofMkLEMk, ← Functor.map_comp underlying, assoc, Iso.hom_inv_id_assoc] congr 1
import Mathlib.Init.Algebra.Classes import Mathlib.Logic.Nontrivial.Basic import Mathlib.Order.BoundedOrder import Mathlib.Data.Option.NAry import Mathlib.Tactic.Lift import Mathlib.Data.Option.Basic #align_import order.with_bot from "leanprover-community/mathlib"@"0111834459f5d7400215223ea95ae38a1265a907" variable {α β γ δ : Type*} def WithBot (α : Type*) := Option α #align with_bot WithBot namespace WithBot variable {a b : α} instance [Repr α] : Repr (WithBot α) := ⟨fun o _ => match o with | none => "⊥" | some a => "↑" ++ repr a⟩ @[coe, match_pattern] def some : α → WithBot α := Option.some -- Porting note: changed this from `CoeTC` to `Coe` but I am not 100% confident that's correct. instance coe : Coe α (WithBot α) := ⟨some⟩ instance bot : Bot (WithBot α) := ⟨none⟩ instance inhabited : Inhabited (WithBot α) := ⟨⊥⟩ instance nontrivial [Nonempty α] : Nontrivial (WithBot α) := Option.nontrivial open Function theorem coe_injective : Injective ((↑) : α → WithBot α) := Option.some_injective _ #align with_bot.coe_injective WithBot.coe_injective @[simp, norm_cast] theorem coe_inj : (a : WithBot α) = b ↔ a = b := Option.some_inj #align with_bot.coe_inj WithBot.coe_inj protected theorem «forall» {p : WithBot α → Prop} : (∀ x, p x) ↔ p ⊥ ∧ ∀ x : α, p x := Option.forall #align with_bot.forall WithBot.forall protected theorem «exists» {p : WithBot α → Prop} : (∃ x, p x) ↔ p ⊥ ∨ ∃ x : α, p x := Option.exists #align with_bot.exists WithBot.exists theorem none_eq_bot : (none : WithBot α) = (⊥ : WithBot α) := rfl #align with_bot.none_eq_bot WithBot.none_eq_bot theorem some_eq_coe (a : α) : (Option.some a : WithBot α) = (↑a : WithBot α) := rfl #align with_bot.some_eq_coe WithBot.some_eq_coe @[simp] theorem bot_ne_coe : ⊥ ≠ (a : WithBot α) := nofun #align with_bot.bot_ne_coe WithBot.bot_ne_coe @[simp] theorem coe_ne_bot : (a : WithBot α) ≠ ⊥ := nofun #align with_bot.coe_ne_bot WithBot.coe_ne_bot @[elab_as_elim, induction_eliminator, cases_eliminator] def recBotCoe {C : WithBot α → Sort*} (bot : C ⊥) (coe : ∀ a : α, C a) : ∀ n : WithBot α, C n | ⊥ => bot | (a : α) => coe a #align with_bot.rec_bot_coe WithBot.recBotCoe @[simp] theorem recBotCoe_bot {C : WithBot α → Sort*} (d : C ⊥) (f : ∀ a : α, C a) : @recBotCoe _ C d f ⊥ = d := rfl #align with_bot.rec_bot_coe_bot WithBot.recBotCoe_bot @[simp] theorem recBotCoe_coe {C : WithBot α → Sort*} (d : C ⊥) (f : ∀ a : α, C a) (x : α) : @recBotCoe _ C d f ↑x = f x := rfl #align with_bot.rec_bot_coe_coe WithBot.recBotCoe_coe def unbot' (d : α) (x : WithBot α) : α := recBotCoe d id x #align with_bot.unbot' WithBot.unbot' @[simp] theorem unbot'_bot {α} (d : α) : unbot' d ⊥ = d := rfl #align with_bot.unbot'_bot WithBot.unbot'_bot @[simp] theorem unbot'_coe {α} (d x : α) : unbot' d x = x := rfl #align with_bot.unbot'_coe WithBot.unbot'_coe theorem coe_eq_coe : (a : WithBot α) = b ↔ a = b := coe_inj #align with_bot.coe_eq_coe WithBot.coe_eq_coe theorem unbot'_eq_iff {d y : α} {x : WithBot α} : unbot' d x = y ↔ x = y ∨ x = ⊥ ∧ y = d := by induction x <;> simp [@eq_comm _ d] #align with_bot.unbot'_eq_iff WithBot.unbot'_eq_iff @[simp] theorem unbot'_eq_self_iff {d : α} {x : WithBot α} : unbot' d x = d ↔ x = d ∨ x = ⊥ := by simp [unbot'_eq_iff] #align with_bot.unbot'_eq_self_iff WithBot.unbot'_eq_self_iff theorem unbot'_eq_unbot'_iff {d : α} {x y : WithBot α} : unbot' d x = unbot' d y ↔ x = y ∨ x = d ∧ y = ⊥ ∨ x = ⊥ ∧ y = d := by induction y <;> simp [unbot'_eq_iff, or_comm] #align with_bot.unbot'_eq_unbot'_iff WithBot.unbot'_eq_unbot'_iff def map (f : α → β) : WithBot α → WithBot β := Option.map f #align with_bot.map WithBot.map @[simp] theorem map_bot (f : α → β) : map f ⊥ = ⊥ := rfl #align with_bot.map_bot WithBot.map_bot @[simp] theorem map_coe (f : α → β) (a : α) : map f a = f a := rfl #align with_bot.map_coe WithBot.map_coe theorem map_comm {f₁ : α → β} {f₂ : α → γ} {g₁ : β → δ} {g₂ : γ → δ} (h : g₁ ∘ f₁ = g₂ ∘ f₂) (a : α) : map g₁ (map f₁ a) = map g₂ (map f₂ a) := Option.map_comm h _ #align with_bot.map_comm WithBot.map_comm def map₂ : (α → β → γ) → WithBot α → WithBot β → WithBot γ := Option.map₂ lemma map₂_coe_coe (f : α → β → γ) (a : α) (b : β) : map₂ f a b = f a b := rfl @[simp] lemma map₂_bot_left (f : α → β → γ) (b) : map₂ f ⊥ b = ⊥ := rfl @[simp] lemma map₂_bot_right (f : α → β → γ) (a) : map₂ f a ⊥ = ⊥ := by cases a <;> rfl @[simp] lemma map₂_coe_left (f : α → β → γ) (a : α) (b) : map₂ f a b = b.map fun b ↦ f a b := rfl @[simp] lemma map₂_coe_right (f : α → β → γ) (a) (b : β) : map₂ f a b = a.map (f · b) := by cases a <;> rfl @[simp] lemma map₂_eq_bot_iff {f : α → β → γ} {a : WithBot α} {b : WithBot β} : map₂ f a b = ⊥ ↔ a = ⊥ ∨ b = ⊥ := Option.map₂_eq_none_iff theorem ne_bot_iff_exists {x : WithBot α} : x ≠ ⊥ ↔ ∃ a : α, ↑a = x := Option.ne_none_iff_exists #align with_bot.ne_bot_iff_exists WithBot.ne_bot_iff_exists def unbot : ∀ x : WithBot α, x ≠ ⊥ → α | (x : α), _ => x #align with_bot.unbot WithBot.unbot @[simp] lemma coe_unbot : ∀ (x : WithBot α) hx, x.unbot hx = x | (x : α), _ => rfl #align with_bot.coe_unbot WithBot.coe_unbot @[simp] theorem unbot_coe (x : α) (h : (x : WithBot α) ≠ ⊥ := coe_ne_bot) : (x : WithBot α).unbot h = x := rfl #align with_bot.unbot_coe WithBot.unbot_coe instance canLift : CanLift (WithBot α) α (↑) fun r => r ≠ ⊥ where prf x h := ⟨x.unbot h, coe_unbot _ _⟩ #align with_bot.can_lift WithBot.canLift section LE variable [LE α] instance (priority := 10) le : LE (WithBot α) := ⟨fun o₁ o₂ => ∀ a : α, o₁ = ↑a → ∃ b : α, o₂ = ↑b ∧ a ≤ b⟩ @[simp, norm_cast] theorem coe_le_coe : (a : WithBot α) ≤ b ↔ a ≤ b := by simp [LE.le] #align with_bot.coe_le_coe WithBot.coe_le_coe instance orderBot : OrderBot (WithBot α) where bot_le _ := fun _ h => Option.noConfusion h @[simp, deprecated coe_le_coe "Don't mix Option and WithBot" (since := "2024-05-27")] theorem some_le_some : @LE.le (WithBot α) _ (Option.some a) (Option.some b) ↔ a ≤ b := coe_le_coe #align with_bot.some_le_some WithBot.some_le_some @[simp, deprecated bot_le "Don't mix Option and WithBot" (since := "2024-05-27")] theorem none_le {a : WithBot α} : @LE.le (WithBot α) _ none a := bot_le #align with_bot.none_le WithBot.none_le instance orderTop [OrderTop α] : OrderTop (WithBot α) where top := (⊤ : α) le_top o a ha := by cases ha; exact ⟨_, rfl, le_top⟩ instance instBoundedOrder [OrderTop α] : BoundedOrder (WithBot α) := { WithBot.orderBot, WithBot.orderTop with } theorem not_coe_le_bot (a : α) : ¬(a : WithBot α) ≤ ⊥ := fun h => let ⟨_, hb, _⟩ := h _ rfl Option.not_mem_none _ hb #align with_bot.not_coe_le_bot WithBot.not_coe_le_bot @[simp] protected theorem le_bot_iff : ∀ {a : WithBot α}, a ≤ ⊥ ↔ a = ⊥ | (a : α) => by simp [not_coe_le_bot _] | ⊥ => by simp theorem coe_le : ∀ {o : Option α}, b ∈ o → ((a : WithBot α) ≤ o ↔ a ≤ b) | _, rfl => coe_le_coe #align with_bot.coe_le WithBot.coe_le theorem coe_le_iff : ∀ {x : WithBot α}, (a : WithBot α) ≤ x ↔ ∃ b : α, x = b ∧ a ≤ b | (x : α) => by simp | ⊥ => iff_of_false (not_coe_le_bot _) <| by simp #align with_bot.coe_le_iff WithBot.coe_le_iff theorem le_coe_iff : ∀ {x : WithBot α}, x ≤ b ↔ ∀ a : α, x = ↑a → a ≤ b | (b : α) => by simp | ⊥ => by simp #align with_bot.le_coe_iff WithBot.le_coe_iff protected theorem _root_.IsMax.withBot (h : IsMax a) : IsMax (a : WithBot α) | ⊥, _ => bot_le | (_ : α), hb => coe_le_coe.2 <| h <| coe_le_coe.1 hb #align is_max.with_bot IsMax.withBot
Mathlib/Order/WithBot.lean
266
269
theorem le_unbot_iff {a : α} {b : WithBot α} (h : b ≠ ⊥) : a ≤ unbot b h ↔ (a : WithBot α) ≤ b := by
match b, h with | some _, _ => simp only [unbot_coe, coe_le_coe]
import Mathlib.Analysis.SpecialFunctions.Exp import Mathlib.Data.Nat.Factorization.Basic import Mathlib.Analysis.NormedSpace.Real #align_import analysis.special_functions.log.basic from "leanprover-community/mathlib"@"f23a09ce6d3f367220dc3cecad6b7eb69eb01690" open Set Filter Function open Topology noncomputable section namespace Real variable {x y : ℝ} -- @[pp_nodot] -- Porting note: removed noncomputable def log (x : ℝ) : ℝ := if hx : x = 0 then 0 else expOrderIso.symm ⟨|x|, abs_pos.2 hx⟩ #align real.log Real.log theorem log_of_ne_zero (hx : x ≠ 0) : log x = expOrderIso.symm ⟨|x|, abs_pos.2 hx⟩ := dif_neg hx #align real.log_of_ne_zero Real.log_of_ne_zero theorem log_of_pos (hx : 0 < x) : log x = expOrderIso.symm ⟨x, hx⟩ := by rw [log_of_ne_zero hx.ne'] congr exact abs_of_pos hx #align real.log_of_pos Real.log_of_pos theorem exp_log_eq_abs (hx : x ≠ 0) : exp (log x) = |x| := by rw [log_of_ne_zero hx, ← coe_expOrderIso_apply, OrderIso.apply_symm_apply, Subtype.coe_mk] #align real.exp_log_eq_abs Real.exp_log_eq_abs theorem exp_log (hx : 0 < x) : exp (log x) = x := by rw [exp_log_eq_abs hx.ne'] exact abs_of_pos hx #align real.exp_log Real.exp_log
Mathlib/Analysis/SpecialFunctions/Log/Basic.lean
64
66
theorem exp_log_of_neg (hx : x < 0) : exp (log x) = -x := by
rw [exp_log_eq_abs (ne_of_lt hx)] exact abs_of_neg hx
import Mathlib.Algebra.Category.Ring.Basic import Mathlib.CategoryTheory.Limits.HasLimits #align_import algebra.category.Ring.colimits from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe u v open CategoryTheory open CategoryTheory.Limits -- [ROBOT VOICE]: -- You should pretend for now that this file was automatically generated. -- It follows the same template as colimits in Mon. namespace CommRingCat.Colimits variable {J : Type v} [SmallCategory J] (F : J ⥤ CommRingCat.{v}) inductive Prequotient -- There's always `of` | of : ∀ (j : J) (_ : F.obj j), Prequotient -- Then one generator for each operation | zero : Prequotient | one : Prequotient | neg : Prequotient → Prequotient | add : Prequotient → Prequotient → Prequotient | mul : Prequotient → Prequotient → Prequotient set_option linter.uppercaseLean3 false #align CommRing.colimits.prequotient CommRingCat.Colimits.Prequotient instance : Inhabited (Prequotient F) := ⟨Prequotient.zero⟩ open Prequotient inductive Relation : Prequotient F → Prequotient F → Prop -- Make it an equivalence Relation: | refl : ∀ x, Relation x x | symm : ∀ (x y) (_ : Relation x y), Relation y x | trans : ∀ (x y z) (_ : Relation x y) (_ : Relation y z), Relation x z -- There's always a `map` Relation | map : ∀ (j j' : J) (f : j ⟶ j') (x : F.obj j), Relation (Prequotient.of j' (F.map f x)) (Prequotient.of j x) -- Then one Relation per operation, describing the interaction with `of` | zero : ∀ j, Relation (Prequotient.of j 0) zero | one : ∀ j, Relation (Prequotient.of j 1) one | neg : ∀ (j) (x : F.obj j), Relation (Prequotient.of j (-x)) (neg (Prequotient.of j x)) | add : ∀ (j) (x y : F.obj j), Relation (Prequotient.of j (x + y)) (add (Prequotient.of j x) (Prequotient.of j y)) | mul : ∀ (j) (x y : F.obj j), Relation (Prequotient.of j (x * y)) (mul (Prequotient.of j x) (Prequotient.of j y)) -- Then one Relation per argument of each operation | neg_1 : ∀ (x x') (_ : Relation x x'), Relation (neg x) (neg x') | add_1 : ∀ (x x' y) (_ : Relation x x'), Relation (add x y) (add x' y) | add_2 : ∀ (x y y') (_ : Relation y y'), Relation (add x y) (add x y') | mul_1 : ∀ (x x' y) (_ : Relation x x'), Relation (mul x y) (mul x' y) | mul_2 : ∀ (x y y') (_ : Relation y y'), Relation (mul x y) (mul x y') -- And one Relation per axiom | zero_add : ∀ x, Relation (add zero x) x | add_zero : ∀ x, Relation (add x zero) x | one_mul : ∀ x, Relation (mul one x) x | mul_one : ∀ x, Relation (mul x one) x | add_left_neg : ∀ x, Relation (add (neg x) x) zero | add_comm : ∀ x y, Relation (add x y) (add y x) | mul_comm : ∀ x y, Relation (mul x y) (mul y x) | add_assoc : ∀ x y z, Relation (add (add x y) z) (add x (add y z)) | mul_assoc : ∀ x y z, Relation (mul (mul x y) z) (mul x (mul y z)) | left_distrib : ∀ x y z, Relation (mul x (add y z)) (add (mul x y) (mul x z)) | right_distrib : ∀ x y z, Relation (mul (add x y) z) (add (mul x z) (mul y z)) | zero_mul : ∀ x, Relation (mul zero x) zero | mul_zero : ∀ x, Relation (mul x zero) zero #align CommRing.colimits.Relation CommRingCat.Colimits.Relation def colimitSetoid : Setoid (Prequotient F) where r := Relation F iseqv := ⟨Relation.refl, Relation.symm _ _, Relation.trans _ _ _⟩ #align CommRing.colimits.colimit_setoid CommRingCat.Colimits.colimitSetoid attribute [instance] colimitSetoid def ColimitType : Type v := Quotient (colimitSetoid F) #align CommRing.colimits.colimit_type CommRingCat.Colimits.ColimitType instance ColimitType.instZero : Zero (ColimitType F) where zero := Quotient.mk _ zero instance ColimitType.instAdd : Add (ColimitType F) where add := Quotient.map₂ add <| fun _x x' rx y _y' ry => Setoid.trans (Relation.add_1 _ _ y rx) (Relation.add_2 x' _ _ ry) instance ColimitType.instNeg : Neg (ColimitType F) where neg := Quotient.map neg Relation.neg_1 instance ColimitType.AddGroup : AddGroup (ColimitType F) where neg := Quotient.map neg Relation.neg_1 zero_add := Quotient.ind <| fun _ => Quotient.sound <| Relation.zero_add _ add_zero := Quotient.ind <| fun _ => Quotient.sound <| Relation.add_zero _ add_left_neg := Quotient.ind <| fun _ => Quotient.sound <| Relation.add_left_neg _ add_assoc := Quotient.ind <| fun _ => Quotient.ind₂ <| fun _ _ => Quotient.sound <| Relation.add_assoc _ _ _ nsmul := nsmulRec zsmul := zsmulRec -- Porting note: failed to derive `Inhabited` instance instance InhabitedColimitType : Inhabited <| ColimitType F where default := 0 instance ColimitType.AddGroupWithOne : AddGroupWithOne (ColimitType F) := { ColimitType.AddGroup F with one := Quotient.mk _ one } instance : CommRing (ColimitType.{v} F) := { ColimitType.AddGroupWithOne F with mul := Quot.map₂ Prequotient.mul Relation.mul_2 Relation.mul_1 one_mul := fun x => Quot.inductionOn x fun x => Quot.sound <| Relation.one_mul _ mul_one := fun x => Quot.inductionOn x fun x => Quot.sound <| Relation.mul_one _ add_comm := fun x y => Quot.induction_on₂ x y fun x y => Quot.sound <| Relation.add_comm _ _ mul_comm := fun x y => Quot.induction_on₂ x y fun x y => Quot.sound <| Relation.mul_comm _ _ mul_assoc := fun x y z => Quot.induction_on₃ x y z fun x y z => by simp only [(· * ·)] exact Quot.sound (Relation.mul_assoc _ _ _) mul_zero := fun x => Quot.inductionOn x fun x => Quot.sound <| Relation.mul_zero _ zero_mul := fun x => Quot.inductionOn x fun x => Quot.sound <| Relation.zero_mul _ left_distrib := fun x y z => Quot.induction_on₃ x y z fun x y z => by simp only [(· + ·), (· * ·), Add.add] exact Quot.sound (Relation.left_distrib _ _ _) right_distrib := fun x y z => Quot.induction_on₃ x y z fun x y z => by simp only [(· + ·), (· * ·), Add.add] exact Quot.sound (Relation.right_distrib _ _ _) } @[simp] theorem quot_zero : Quot.mk Setoid.r zero = (0 : ColimitType F) := rfl #align CommRing.colimits.quot_zero CommRingCat.Colimits.quot_zero @[simp] theorem quot_one : Quot.mk Setoid.r one = (1 : ColimitType F) := rfl #align CommRing.colimits.quot_one CommRingCat.Colimits.quot_one @[simp] theorem quot_neg (x : Prequotient F) : -- Porting note: Lean can't see `Quot.mk Setoid.r x` is a `ColimitType F` even with type -- annotation unless we use `by exact` to change the elaboration order. (by exact Quot.mk Setoid.r (neg x) : ColimitType F) = -(by exact Quot.mk Setoid.r x) := rfl #align CommRing.colimits.quot_neg CommRingCat.Colimits.quot_neg -- Porting note: Lean can't see `Quot.mk Setoid.r x` is a `ColimitType F` even with type annotation -- unless we use `by exact` to change the elaboration order. @[simp] theorem quot_add (x y) : (by exact Quot.mk Setoid.r (add x y) : ColimitType F) = (by exact Quot.mk _ x) + (by exact Quot.mk _ y) := rfl #align CommRing.colimits.quot_add CommRingCat.Colimits.quot_add -- Porting note: Lean can't see `Quot.mk Setoid.r x` is a `ColimitType F` even with type annotation -- unless we use `by exact` to change the elaboration order. @[simp] theorem quot_mul (x y) : (by exact Quot.mk Setoid.r (mul x y) : ColimitType F) = (by exact Quot.mk _ x) * (by exact Quot.mk _ y) := rfl #align CommRing.colimits.quot_mul CommRingCat.Colimits.quot_mul def colimit : CommRingCat := CommRingCat.of (ColimitType F) #align CommRing.colimits.colimit CommRingCat.Colimits.colimit def coconeFun (j : J) (x : F.obj j) : ColimitType F := Quot.mk _ (Prequotient.of j x) #align CommRing.colimits.cocone_fun CommRingCat.Colimits.coconeFun def coconeMorphism (j : J) : F.obj j ⟶ colimit F where toFun := coconeFun F j map_one' := by apply Quot.sound; apply Relation.one map_mul' := by intros; apply Quot.sound; apply Relation.mul map_zero' := by apply Quot.sound; apply Relation.zero map_add' := by intros; apply Quot.sound; apply Relation.add #align CommRing.colimits.cocone_morphism CommRingCat.Colimits.coconeMorphism @[simp] theorem cocone_naturality {j j' : J} (f : j ⟶ j') : F.map f ≫ coconeMorphism F j' = coconeMorphism F j := by ext apply Quot.sound apply Relation.map #align CommRing.colimits.cocone_naturality CommRingCat.Colimits.cocone_naturality @[simp]
Mathlib/Algebra/Category/Ring/Colimits.lean
253
255
theorem cocone_naturality_components (j j' : J) (f : j ⟶ j') (x : F.obj j) : (coconeMorphism F j') (F.map f x) = (coconeMorphism F j) x := by
rw [← cocone_naturality F f, comp_apply]
import Mathlib.Data.Real.Irrational import Mathlib.Data.Nat.Fib.Basic import Mathlib.Data.Fin.VecNotation import Mathlib.Algebra.LinearRecurrence import Mathlib.Tactic.NormNum.NatFib import Mathlib.Tactic.NormNum.Prime #align_import data.real.golden_ratio from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" noncomputable section open Polynomial abbrev goldenRatio : ℝ := (1 + √5) / 2 #align golden_ratio goldenRatio abbrev goldenConj : ℝ := (1 - √5) / 2 #align golden_conj goldenConj @[inherit_doc goldenRatio] scoped[goldenRatio] notation "φ" => goldenRatio @[inherit_doc goldenConj] scoped[goldenRatio] notation "ψ" => goldenConj open Real goldenRatio theorem inv_gold : φ⁻¹ = -ψ := by have : 1 + √5 ≠ 0 := ne_of_gt (add_pos (by norm_num) <| Real.sqrt_pos.mpr (by norm_num)) field_simp [sub_mul, mul_add] norm_num #align inv_gold inv_gold theorem inv_goldConj : ψ⁻¹ = -φ := by rw [inv_eq_iff_eq_inv, ← neg_inv, ← neg_eq_iff_eq_neg] exact inv_gold.symm #align inv_gold_conj inv_goldConj @[simp] theorem gold_mul_goldConj : φ * ψ = -1 := by field_simp rw [← sq_sub_sq] norm_num #align gold_mul_gold_conj gold_mul_goldConj @[simp] theorem goldConj_mul_gold : ψ * φ = -1 := by rw [mul_comm] exact gold_mul_goldConj #align gold_conj_mul_gold goldConj_mul_gold @[simp] theorem gold_add_goldConj : φ + ψ = 1 := by rw [goldenRatio, goldenConj] ring #align gold_add_gold_conj gold_add_goldConj theorem one_sub_goldConj : 1 - φ = ψ := by linarith [gold_add_goldConj] #align one_sub_gold_conj one_sub_goldConj theorem one_sub_gold : 1 - ψ = φ := by linarith [gold_add_goldConj] #align one_sub_gold one_sub_gold @[simp] theorem gold_sub_goldConj : φ - ψ = √5 := by ring #align gold_sub_gold_conj gold_sub_goldConj theorem gold_pow_sub_gold_pow (n : ℕ) : φ ^ (n + 2) - φ ^ (n + 1) = φ ^ n := by rw [goldenRatio]; ring_nf; norm_num; ring @[simp 1200] theorem gold_sq : φ ^ 2 = φ + 1 := by rw [goldenRatio, ← sub_eq_zero] ring_nf rw [Real.sq_sqrt] <;> norm_num #align gold_sq gold_sq @[simp 1200]
Mathlib/Data/Real/GoldenRatio.lean
98
101
theorem goldConj_sq : ψ ^ 2 = ψ + 1 := by
rw [goldenConj, ← sub_eq_zero] ring_nf rw [Real.sq_sqrt] <;> norm_num
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 section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine ((ordConnected_biInter ?_).inter (ordConnected_biInter ?_)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le
Mathlib/Topology/Order/Basic.lean
169
171
theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by
simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl
import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.FieldTheory.Minpoly.IsIntegrallyClosed import Mathlib.RingTheory.PowerBasis #align_import ring_theory.is_adjoin_root from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" open scoped Polynomial open Polynomial noncomputable section universe u v -- Porting note: this looks like something that should not be here -- -- This class doesn't really make sense on a predicate -- Porting note(#5171): this linter isn't ported yet. -- @[nolint has_nonempty_instance] structure IsAdjoinRoot {R : Type u} (S : Type v) [CommSemiring R] [Semiring S] [Algebra R S] (f : R[X]) : Type max u v where map : R[X] →+* S map_surjective : Function.Surjective map ker_map : RingHom.ker map = Ideal.span {f} algebraMap_eq : algebraMap R S = map.comp Polynomial.C #align is_adjoin_root IsAdjoinRoot -- This class doesn't really make sense on a predicate -- @[nolint has_nonempty_instance] -- Porting note: This linter does not exist yet. structure IsAdjoinRootMonic {R : Type u} (S : Type v) [CommSemiring R] [Semiring S] [Algebra R S] (f : R[X]) extends IsAdjoinRoot S f where Monic : Monic f #align is_adjoin_root_monic IsAdjoinRootMonic section Ring variable {R : Type u} {S : Type v} [CommRing R] [Ring S] {f : R[X]} [Algebra R S] namespace IsAdjoinRoot def root (h : IsAdjoinRoot S f) : S := h.map X #align is_adjoin_root.root IsAdjoinRoot.root theorem subsingleton (h : IsAdjoinRoot S f) [Subsingleton R] : Subsingleton S := h.map_surjective.subsingleton #align is_adjoin_root.subsingleton IsAdjoinRoot.subsingleton theorem algebraMap_apply (h : IsAdjoinRoot S f) (x : R) : algebraMap R S x = h.map (Polynomial.C x) := by rw [h.algebraMap_eq, RingHom.comp_apply] #align is_adjoin_root.algebra_map_apply IsAdjoinRoot.algebraMap_apply @[simp] theorem mem_ker_map (h : IsAdjoinRoot S f) {p} : p ∈ RingHom.ker h.map ↔ f ∣ p := by rw [h.ker_map, Ideal.mem_span_singleton] #align is_adjoin_root.mem_ker_map IsAdjoinRoot.mem_ker_map theorem map_eq_zero_iff (h : IsAdjoinRoot S f) {p} : h.map p = 0 ↔ f ∣ p := by rw [← h.mem_ker_map, RingHom.mem_ker] #align is_adjoin_root.map_eq_zero_iff IsAdjoinRoot.map_eq_zero_iff @[simp] theorem map_X (h : IsAdjoinRoot S f) : h.map X = h.root := rfl set_option linter.uppercaseLean3 false in #align is_adjoin_root.map_X IsAdjoinRoot.map_X @[simp] theorem map_self (h : IsAdjoinRoot S f) : h.map f = 0 := h.map_eq_zero_iff.mpr dvd_rfl #align is_adjoin_root.map_self IsAdjoinRoot.map_self @[simp] theorem aeval_eq (h : IsAdjoinRoot S f) (p : R[X]) : aeval h.root p = h.map p := Polynomial.induction_on p (fun x => by rw [aeval_C, h.algebraMap_apply]) (fun p q ihp ihq => by rw [AlgHom.map_add, RingHom.map_add, ihp, ihq]) fun n x _ => by rw [AlgHom.map_mul, aeval_C, AlgHom.map_pow, aeval_X, RingHom.map_mul, ← h.algebraMap_apply, RingHom.map_pow, map_X] #align is_adjoin_root.aeval_eq IsAdjoinRoot.aeval_eq -- @[simp] -- Porting note (#10618): simp can prove this theorem aeval_root (h : IsAdjoinRoot S f) : aeval h.root f = 0 := by rw [aeval_eq, map_self] #align is_adjoin_root.aeval_root IsAdjoinRoot.aeval_root def repr (h : IsAdjoinRoot S f) (x : S) : R[X] := (h.map_surjective x).choose #align is_adjoin_root.repr IsAdjoinRoot.repr theorem map_repr (h : IsAdjoinRoot S f) (x : S) : h.map (h.repr x) = x := (h.map_surjective x).choose_spec #align is_adjoin_root.map_repr IsAdjoinRoot.map_repr theorem repr_zero_mem_span (h : IsAdjoinRoot S f) : h.repr 0 ∈ Ideal.span ({f} : Set R[X]) := by rw [← h.ker_map, RingHom.mem_ker, h.map_repr] #align is_adjoin_root.repr_zero_mem_span IsAdjoinRoot.repr_zero_mem_span theorem repr_add_sub_repr_add_repr_mem_span (h : IsAdjoinRoot S f) (x y : S) : h.repr (x + y) - (h.repr x + h.repr y) ∈ Ideal.span ({f} : Set R[X]) := by rw [← h.ker_map, RingHom.mem_ker, map_sub, h.map_repr, map_add, h.map_repr, h.map_repr, sub_self] #align is_adjoin_root.repr_add_sub_repr_add_repr_mem_span IsAdjoinRoot.repr_add_sub_repr_add_repr_mem_span
Mathlib/RingTheory/IsAdjoinRoot.lean
186
188
theorem ext_map (h h' : IsAdjoinRoot S f) (eq : ∀ x, h.map x = h'.map x) : h = h' := by
cases h; cases h'; congr exact RingHom.ext eq
import Mathlib.Init.ZeroOne import Mathlib.Data.Set.Defs import Mathlib.Order.Basic import Mathlib.Order.SymmDiff import Mathlib.Tactic.Tauto import Mathlib.Tactic.ByContra import Mathlib.Util.Delaborators #align_import data.set.basic from "leanprover-community/mathlib"@"001ffdc42920050657fd45bd2b8bfbec8eaaeb29" open Function universe u v w x namespace Set variable {α : Type u} {s t : Set α} instance instBooleanAlgebraSet : BooleanAlgebra (Set α) := { (inferInstance : BooleanAlgebra (α → Prop)) with sup := (· ∪ ·), le := (· ≤ ·), lt := fun s t => s ⊆ t ∧ ¬t ⊆ s, inf := (· ∩ ·), bot := ∅, compl := (·ᶜ), top := univ, sdiff := (· \ ·) } instance : HasSSubset (Set α) := ⟨(· < ·)⟩ @[simp] theorem top_eq_univ : (⊤ : Set α) = univ := rfl #align set.top_eq_univ Set.top_eq_univ @[simp] theorem bot_eq_empty : (⊥ : Set α) = ∅ := rfl #align set.bot_eq_empty Set.bot_eq_empty @[simp] theorem sup_eq_union : ((· ⊔ ·) : Set α → Set α → Set α) = (· ∪ ·) := rfl #align set.sup_eq_union Set.sup_eq_union @[simp] theorem inf_eq_inter : ((· ⊓ ·) : Set α → Set α → Set α) = (· ∩ ·) := rfl #align set.inf_eq_inter Set.inf_eq_inter @[simp] theorem le_eq_subset : ((· ≤ ·) : Set α → Set α → Prop) = (· ⊆ ·) := rfl #align set.le_eq_subset Set.le_eq_subset @[simp] theorem lt_eq_ssubset : ((· < ·) : Set α → Set α → Prop) = (· ⊂ ·) := rfl #align set.lt_eq_ssubset Set.lt_eq_ssubset theorem le_iff_subset : s ≤ t ↔ s ⊆ t := Iff.rfl #align set.le_iff_subset Set.le_iff_subset theorem lt_iff_ssubset : s < t ↔ s ⊂ t := Iff.rfl #align set.lt_iff_ssubset Set.lt_iff_ssubset alias ⟨_root_.LE.le.subset, _root_.HasSubset.Subset.le⟩ := le_iff_subset #align has_subset.subset.le HasSubset.Subset.le alias ⟨_root_.LT.lt.ssubset, _root_.HasSSubset.SSubset.lt⟩ := lt_iff_ssubset #align has_ssubset.ssubset.lt HasSSubset.SSubset.lt instance PiSetCoe.canLift (ι : Type u) (α : ι → Type v) [∀ i, Nonempty (α i)] (s : Set ι) : CanLift (∀ i : s, α i) (∀ i, α i) (fun f i => f i) fun _ => True := PiSubtype.canLift ι α s #align set.pi_set_coe.can_lift Set.PiSetCoe.canLift instance PiSetCoe.canLift' (ι : Type u) (α : Type v) [Nonempty α] (s : Set ι) : CanLift (s → α) (ι → α) (fun f i => f i) fun _ => True := PiSetCoe.canLift ι (fun _ => α) s #align set.pi_set_coe.can_lift' Set.PiSetCoe.canLift' end Set theorem Subtype.mem {α : Type*} {s : Set α} (p : s) : (p : α) ∈ s := p.prop #align subtype.mem Subtype.mem theorem Eq.subset {α} {s t : Set α} : s = t → s ⊆ t := fun h₁ _ h₂ => by rw [← h₁]; exact h₂ #align eq.subset Eq.subset namespace Set variable {α : Type u} {β : Type v} {γ : Type w} {ι : Sort x} {a b : α} {s s₁ s₂ t t₁ t₂ u : Set α} instance : Inhabited (Set α) := ⟨∅⟩ theorem ext_iff {s t : Set α} : s = t ↔ ∀ x, x ∈ s ↔ x ∈ t := ⟨fun h x => by rw [h], ext⟩ #align set.ext_iff Set.ext_iff @[trans] theorem mem_of_mem_of_subset {x : α} {s t : Set α} (hx : x ∈ s) (h : s ⊆ t) : x ∈ t := h hx #align set.mem_of_mem_of_subset Set.mem_of_mem_of_subset theorem forall_in_swap {p : α → β → Prop} : (∀ a ∈ s, ∀ (b), p a b) ↔ ∀ (b), ∀ a ∈ s, p a b := by tauto #align set.forall_in_swap Set.forall_in_swap theorem mem_setOf {a : α} {p : α → Prop} : a ∈ { x | p x } ↔ p a := Iff.rfl #align set.mem_set_of Set.mem_setOf theorem _root_.Membership.mem.out {p : α → Prop} {a : α} (h : a ∈ { x | p x }) : p a := h #align has_mem.mem.out Membership.mem.out theorem nmem_setOf_iff {a : α} {p : α → Prop} : a ∉ { x | p x } ↔ ¬p a := Iff.rfl #align set.nmem_set_of_iff Set.nmem_setOf_iff @[simp] theorem setOf_mem_eq {s : Set α} : { x | x ∈ s } = s := rfl #align set.set_of_mem_eq Set.setOf_mem_eq theorem setOf_set {s : Set α} : setOf s = s := rfl #align set.set_of_set Set.setOf_set theorem setOf_app_iff {p : α → Prop} {x : α} : { x | p x } x ↔ p x := Iff.rfl #align set.set_of_app_iff Set.setOf_app_iff theorem mem_def {a : α} {s : Set α} : a ∈ s ↔ s a := Iff.rfl #align set.mem_def Set.mem_def theorem setOf_bijective : Bijective (setOf : (α → Prop) → Set α) := bijective_id #align set.set_of_bijective Set.setOf_bijective theorem subset_setOf {p : α → Prop} {s : Set α} : s ⊆ setOf p ↔ ∀ x, x ∈ s → p x := Iff.rfl theorem setOf_subset {p : α → Prop} {s : Set α} : setOf p ⊆ s ↔ ∀ x, p x → x ∈ s := Iff.rfl @[simp] theorem setOf_subset_setOf {p q : α → Prop} : { a | p a } ⊆ { a | q a } ↔ ∀ a, p a → q a := Iff.rfl #align set.set_of_subset_set_of Set.setOf_subset_setOf theorem setOf_and {p q : α → Prop} : { a | p a ∧ q a } = { a | p a } ∩ { a | q a } := rfl #align set.set_of_and Set.setOf_and theorem setOf_or {p q : α → Prop} : { a | p a ∨ q a } = { a | p a } ∪ { a | q a } := rfl #align set.set_of_or Set.setOf_or instance : IsRefl (Set α) (· ⊆ ·) := show IsRefl (Set α) (· ≤ ·) by infer_instance instance : IsTrans (Set α) (· ⊆ ·) := show IsTrans (Set α) (· ≤ ·) by infer_instance instance : Trans ((· ⊆ ·) : Set α → Set α → Prop) (· ⊆ ·) (· ⊆ ·) := show Trans (· ≤ ·) (· ≤ ·) (· ≤ ·) by infer_instance instance : IsAntisymm (Set α) (· ⊆ ·) := show IsAntisymm (Set α) (· ≤ ·) by infer_instance instance : IsIrrefl (Set α) (· ⊂ ·) := show IsIrrefl (Set α) (· < ·) by infer_instance instance : IsTrans (Set α) (· ⊂ ·) := show IsTrans (Set α) (· < ·) by infer_instance instance : Trans ((· ⊂ ·) : Set α → Set α → Prop) (· ⊂ ·) (· ⊂ ·) := show Trans (· < ·) (· < ·) (· < ·) by infer_instance instance : Trans ((· ⊂ ·) : Set α → Set α → Prop) (· ⊆ ·) (· ⊂ ·) := show Trans (· < ·) (· ≤ ·) (· < ·) by infer_instance instance : Trans ((· ⊆ ·) : Set α → Set α → Prop) (· ⊂ ·) (· ⊂ ·) := show Trans (· ≤ ·) (· < ·) (· < ·) by infer_instance instance : IsAsymm (Set α) (· ⊂ ·) := show IsAsymm (Set α) (· < ·) by infer_instance instance : IsNonstrictStrictOrder (Set α) (· ⊆ ·) (· ⊂ ·) := ⟨fun _ _ => Iff.rfl⟩ -- TODO(Jeremy): write a tactic to unfold specific instances of generic notation? theorem subset_def : (s ⊆ t) = ∀ x, x ∈ s → x ∈ t := rfl #align set.subset_def Set.subset_def theorem ssubset_def : (s ⊂ t) = (s ⊆ t ∧ ¬t ⊆ s) := rfl #align set.ssubset_def Set.ssubset_def @[refl] theorem Subset.refl (a : Set α) : a ⊆ a := fun _ => id #align set.subset.refl Set.Subset.refl theorem Subset.rfl {s : Set α} : s ⊆ s := Subset.refl s #align set.subset.rfl Set.Subset.rfl @[trans] theorem Subset.trans {a b c : Set α} (ab : a ⊆ b) (bc : b ⊆ c) : a ⊆ c := fun _ h => bc <| ab h #align set.subset.trans Set.Subset.trans @[trans] theorem mem_of_eq_of_mem {x y : α} {s : Set α} (hx : x = y) (h : y ∈ s) : x ∈ s := hx.symm ▸ h #align set.mem_of_eq_of_mem Set.mem_of_eq_of_mem theorem Subset.antisymm {a b : Set α} (h₁ : a ⊆ b) (h₂ : b ⊆ a) : a = b := Set.ext fun _ => ⟨@h₁ _, @h₂ _⟩ #align set.subset.antisymm Set.Subset.antisymm theorem Subset.antisymm_iff {a b : Set α} : a = b ↔ a ⊆ b ∧ b ⊆ a := ⟨fun e => ⟨e.subset, e.symm.subset⟩, fun ⟨h₁, h₂⟩ => Subset.antisymm h₁ h₂⟩ #align set.subset.antisymm_iff Set.Subset.antisymm_iff -- an alternative name theorem eq_of_subset_of_subset {a b : Set α} : a ⊆ b → b ⊆ a → a = b := Subset.antisymm #align set.eq_of_subset_of_subset Set.eq_of_subset_of_subset theorem mem_of_subset_of_mem {s₁ s₂ : Set α} {a : α} (h : s₁ ⊆ s₂) : a ∈ s₁ → a ∈ s₂ := @h _ #align set.mem_of_subset_of_mem Set.mem_of_subset_of_mem theorem not_mem_subset (h : s ⊆ t) : a ∉ t → a ∉ s := mt <| mem_of_subset_of_mem h #align set.not_mem_subset Set.not_mem_subset theorem not_subset : ¬s ⊆ t ↔ ∃ a ∈ s, a ∉ t := by simp only [subset_def, not_forall, exists_prop] #align set.not_subset Set.not_subset lemma eq_of_forall_subset_iff (h : ∀ u, s ⊆ u ↔ t ⊆ u) : s = t := eq_of_forall_ge_iff h protected theorem eq_or_ssubset_of_subset (h : s ⊆ t) : s = t ∨ s ⊂ t := eq_or_lt_of_le h #align set.eq_or_ssubset_of_subset Set.eq_or_ssubset_of_subset theorem exists_of_ssubset {s t : Set α} (h : s ⊂ t) : ∃ x ∈ t, x ∉ s := not_subset.1 h.2 #align set.exists_of_ssubset Set.exists_of_ssubset protected theorem ssubset_iff_subset_ne {s t : Set α} : s ⊂ t ↔ s ⊆ t ∧ s ≠ t := @lt_iff_le_and_ne (Set α) _ s t #align set.ssubset_iff_subset_ne Set.ssubset_iff_subset_ne theorem ssubset_iff_of_subset {s t : Set α} (h : s ⊆ t) : s ⊂ t ↔ ∃ x ∈ t, x ∉ s := ⟨exists_of_ssubset, fun ⟨_, hxt, hxs⟩ => ⟨h, fun h => hxs <| h hxt⟩⟩ #align set.ssubset_iff_of_subset Set.ssubset_iff_of_subset protected theorem ssubset_of_ssubset_of_subset {s₁ s₂ s₃ : Set α} (hs₁s₂ : s₁ ⊂ s₂) (hs₂s₃ : s₂ ⊆ s₃) : s₁ ⊂ s₃ := ⟨Subset.trans hs₁s₂.1 hs₂s₃, fun hs₃s₁ => hs₁s₂.2 (Subset.trans hs₂s₃ hs₃s₁)⟩ #align set.ssubset_of_ssubset_of_subset Set.ssubset_of_ssubset_of_subset protected theorem ssubset_of_subset_of_ssubset {s₁ s₂ s₃ : Set α} (hs₁s₂ : s₁ ⊆ s₂) (hs₂s₃ : s₂ ⊂ s₃) : s₁ ⊂ s₃ := ⟨Subset.trans hs₁s₂ hs₂s₃.1, fun hs₃s₁ => hs₂s₃.2 (Subset.trans hs₃s₁ hs₁s₂)⟩ #align set.ssubset_of_subset_of_ssubset Set.ssubset_of_subset_of_ssubset theorem not_mem_empty (x : α) : ¬x ∈ (∅ : Set α) := id #align set.not_mem_empty Set.not_mem_empty -- Porting note (#10618): removed `simp` because `simp` can prove it theorem not_not_mem : ¬a ∉ s ↔ a ∈ s := not_not #align set.not_not_mem Set.not_not_mem -- Porting note: we seem to need parentheses at `(↥s)`, -- even if we increase the right precedence of `↥` in `Mathlib.Tactic.Coe`. -- Porting note: removed `simp` as it is competing with `nonempty_subtype`. -- @[simp] theorem nonempty_coe_sort {s : Set α} : Nonempty (↥s) ↔ s.Nonempty := nonempty_subtype #align set.nonempty_coe_sort Set.nonempty_coe_sort alias ⟨_, Nonempty.coe_sort⟩ := nonempty_coe_sort #align set.nonempty.coe_sort Set.Nonempty.coe_sort theorem nonempty_def : s.Nonempty ↔ ∃ x, x ∈ s := Iff.rfl #align set.nonempty_def Set.nonempty_def theorem nonempty_of_mem {x} (h : x ∈ s) : s.Nonempty := ⟨x, h⟩ #align set.nonempty_of_mem Set.nonempty_of_mem theorem Nonempty.not_subset_empty : s.Nonempty → ¬s ⊆ ∅ | ⟨_, hx⟩, hs => hs hx #align set.nonempty.not_subset_empty Set.Nonempty.not_subset_empty protected noncomputable def Nonempty.some (h : s.Nonempty) : α := Classical.choose h #align set.nonempty.some Set.Nonempty.some protected theorem Nonempty.some_mem (h : s.Nonempty) : h.some ∈ s := Classical.choose_spec h #align set.nonempty.some_mem Set.Nonempty.some_mem theorem Nonempty.mono (ht : s ⊆ t) (hs : s.Nonempty) : t.Nonempty := hs.imp ht #align set.nonempty.mono Set.Nonempty.mono theorem nonempty_of_not_subset (h : ¬s ⊆ t) : (s \ t).Nonempty := let ⟨x, xs, xt⟩ := not_subset.1 h ⟨x, xs, xt⟩ #align set.nonempty_of_not_subset Set.nonempty_of_not_subset theorem nonempty_of_ssubset (ht : s ⊂ t) : (t \ s).Nonempty := nonempty_of_not_subset ht.2 #align set.nonempty_of_ssubset Set.nonempty_of_ssubset theorem Nonempty.of_diff (h : (s \ t).Nonempty) : s.Nonempty := h.imp fun _ => And.left #align set.nonempty.of_diff Set.Nonempty.of_diff theorem nonempty_of_ssubset' (ht : s ⊂ t) : t.Nonempty := (nonempty_of_ssubset ht).of_diff #align set.nonempty_of_ssubset' Set.nonempty_of_ssubset' theorem Nonempty.inl (hs : s.Nonempty) : (s ∪ t).Nonempty := hs.imp fun _ => Or.inl #align set.nonempty.inl Set.Nonempty.inl theorem Nonempty.inr (ht : t.Nonempty) : (s ∪ t).Nonempty := ht.imp fun _ => Or.inr #align set.nonempty.inr Set.Nonempty.inr @[simp] theorem union_nonempty : (s ∪ t).Nonempty ↔ s.Nonempty ∨ t.Nonempty := exists_or #align set.union_nonempty Set.union_nonempty theorem Nonempty.left (h : (s ∩ t).Nonempty) : s.Nonempty := h.imp fun _ => And.left #align set.nonempty.left Set.Nonempty.left theorem Nonempty.right (h : (s ∩ t).Nonempty) : t.Nonempty := h.imp fun _ => And.right #align set.nonempty.right Set.Nonempty.right theorem inter_nonempty : (s ∩ t).Nonempty ↔ ∃ x, x ∈ s ∧ x ∈ t := Iff.rfl #align set.inter_nonempty Set.inter_nonempty theorem inter_nonempty_iff_exists_left : (s ∩ t).Nonempty ↔ ∃ x ∈ s, x ∈ t := by simp_rw [inter_nonempty] #align set.inter_nonempty_iff_exists_left Set.inter_nonempty_iff_exists_left theorem inter_nonempty_iff_exists_right : (s ∩ t).Nonempty ↔ ∃ x ∈ t, x ∈ s := by simp_rw [inter_nonempty, and_comm] #align set.inter_nonempty_iff_exists_right Set.inter_nonempty_iff_exists_right theorem nonempty_iff_univ_nonempty : Nonempty α ↔ (univ : Set α).Nonempty := ⟨fun ⟨x⟩ => ⟨x, trivial⟩, fun ⟨x, _⟩ => ⟨x⟩⟩ #align set.nonempty_iff_univ_nonempty Set.nonempty_iff_univ_nonempty @[simp] theorem univ_nonempty : ∀ [Nonempty α], (univ : Set α).Nonempty | ⟨x⟩ => ⟨x, trivial⟩ #align set.univ_nonempty Set.univ_nonempty theorem Nonempty.to_subtype : s.Nonempty → Nonempty (↥s) := nonempty_subtype.2 #align set.nonempty.to_subtype Set.Nonempty.to_subtype theorem Nonempty.to_type : s.Nonempty → Nonempty α := fun ⟨x, _⟩ => ⟨x⟩ #align set.nonempty.to_type Set.Nonempty.to_type instance univ.nonempty [Nonempty α] : Nonempty (↥(Set.univ : Set α)) := Set.univ_nonempty.to_subtype #align set.univ.nonempty Set.univ.nonempty theorem nonempty_of_nonempty_subtype [Nonempty (↥s)] : s.Nonempty := nonempty_subtype.mp ‹_› #align set.nonempty_of_nonempty_subtype Set.nonempty_of_nonempty_subtype theorem empty_def : (∅ : Set α) = { _x : α | False } := rfl #align set.empty_def Set.empty_def @[simp] theorem mem_empty_iff_false (x : α) : x ∈ (∅ : Set α) ↔ False := Iff.rfl #align set.mem_empty_iff_false Set.mem_empty_iff_false @[simp] theorem setOf_false : { _a : α | False } = ∅ := rfl #align set.set_of_false Set.setOf_false @[simp] theorem setOf_bot : { _x : α | ⊥ } = ∅ := rfl @[simp] theorem empty_subset (s : Set α) : ∅ ⊆ s := nofun #align set.empty_subset Set.empty_subset theorem subset_empty_iff {s : Set α} : s ⊆ ∅ ↔ s = ∅ := (Subset.antisymm_iff.trans <| and_iff_left (empty_subset _)).symm #align set.subset_empty_iff Set.subset_empty_iff theorem eq_empty_iff_forall_not_mem {s : Set α} : s = ∅ ↔ ∀ x, x ∉ s := subset_empty_iff.symm #align set.eq_empty_iff_forall_not_mem Set.eq_empty_iff_forall_not_mem theorem eq_empty_of_forall_not_mem (h : ∀ x, x ∉ s) : s = ∅ := subset_empty_iff.1 h #align set.eq_empty_of_forall_not_mem Set.eq_empty_of_forall_not_mem theorem eq_empty_of_subset_empty {s : Set α} : s ⊆ ∅ → s = ∅ := subset_empty_iff.1 #align set.eq_empty_of_subset_empty Set.eq_empty_of_subset_empty theorem eq_empty_of_isEmpty [IsEmpty α] (s : Set α) : s = ∅ := eq_empty_of_subset_empty fun x _ => isEmptyElim x #align set.eq_empty_of_is_empty Set.eq_empty_of_isEmpty instance uniqueEmpty [IsEmpty α] : Unique (Set α) where default := ∅ uniq := eq_empty_of_isEmpty #align set.unique_empty Set.uniqueEmpty theorem not_nonempty_iff_eq_empty {s : Set α} : ¬s.Nonempty ↔ s = ∅ := by simp only [Set.Nonempty, not_exists, eq_empty_iff_forall_not_mem] #align set.not_nonempty_iff_eq_empty Set.not_nonempty_iff_eq_empty theorem nonempty_iff_ne_empty : s.Nonempty ↔ s ≠ ∅ := not_nonempty_iff_eq_empty.not_right #align set.nonempty_iff_ne_empty Set.nonempty_iff_ne_empty theorem not_nonempty_iff_eq_empty' : ¬Nonempty s ↔ s = ∅ := by rw [nonempty_subtype, not_exists, eq_empty_iff_forall_not_mem] theorem nonempty_iff_ne_empty' : Nonempty s ↔ s ≠ ∅ := not_nonempty_iff_eq_empty'.not_right alias ⟨Nonempty.ne_empty, _⟩ := nonempty_iff_ne_empty #align set.nonempty.ne_empty Set.Nonempty.ne_empty @[simp] theorem not_nonempty_empty : ¬(∅ : Set α).Nonempty := fun ⟨_, hx⟩ => hx #align set.not_nonempty_empty Set.not_nonempty_empty -- Porting note: removing `@[simp]` as it is competing with `isEmpty_subtype`. -- @[simp] theorem isEmpty_coe_sort {s : Set α} : IsEmpty (↥s) ↔ s = ∅ := not_iff_not.1 <| by simpa using nonempty_iff_ne_empty #align set.is_empty_coe_sort Set.isEmpty_coe_sort theorem eq_empty_or_nonempty (s : Set α) : s = ∅ ∨ s.Nonempty := or_iff_not_imp_left.2 nonempty_iff_ne_empty.2 #align set.eq_empty_or_nonempty Set.eq_empty_or_nonempty theorem subset_eq_empty {s t : Set α} (h : t ⊆ s) (e : s = ∅) : t = ∅ := subset_empty_iff.1 <| e ▸ h #align set.subset_eq_empty Set.subset_eq_empty theorem forall_mem_empty {p : α → Prop} : (∀ x ∈ (∅ : Set α), p x) ↔ True := iff_true_intro fun _ => False.elim #align set.ball_empty_iff Set.forall_mem_empty @[deprecated (since := "2024-03-23")] alias ball_empty_iff := forall_mem_empty instance (α : Type u) : IsEmpty.{u + 1} (↥(∅ : Set α)) := ⟨fun x => x.2⟩ @[simp] theorem empty_ssubset : ∅ ⊂ s ↔ s.Nonempty := (@bot_lt_iff_ne_bot (Set α) _ _ _).trans nonempty_iff_ne_empty.symm #align set.empty_ssubset Set.empty_ssubset alias ⟨_, Nonempty.empty_ssubset⟩ := empty_ssubset #align set.nonempty.empty_ssubset Set.Nonempty.empty_ssubset @[simp] theorem setOf_true : { _x : α | True } = univ := rfl #align set.set_of_true Set.setOf_true @[simp] theorem setOf_top : { _x : α | ⊤ } = univ := rfl @[simp] theorem univ_eq_empty_iff : (univ : Set α) = ∅ ↔ IsEmpty α := eq_empty_iff_forall_not_mem.trans ⟨fun H => ⟨fun x => H x trivial⟩, fun H x _ => @IsEmpty.false α H x⟩ #align set.univ_eq_empty_iff Set.univ_eq_empty_iff theorem empty_ne_univ [Nonempty α] : (∅ : Set α) ≠ univ := fun e => not_isEmpty_of_nonempty α <| univ_eq_empty_iff.1 e.symm #align set.empty_ne_univ Set.empty_ne_univ @[simp] theorem subset_univ (s : Set α) : s ⊆ univ := fun _ _ => trivial #align set.subset_univ Set.subset_univ @[simp] theorem univ_subset_iff {s : Set α} : univ ⊆ s ↔ s = univ := @top_le_iff _ _ _ s #align set.univ_subset_iff Set.univ_subset_iff alias ⟨eq_univ_of_univ_subset, _⟩ := univ_subset_iff #align set.eq_univ_of_univ_subset Set.eq_univ_of_univ_subset theorem eq_univ_iff_forall {s : Set α} : s = univ ↔ ∀ x, x ∈ s := univ_subset_iff.symm.trans <| forall_congr' fun _ => imp_iff_right trivial #align set.eq_univ_iff_forall Set.eq_univ_iff_forall theorem eq_univ_of_forall {s : Set α} : (∀ x, x ∈ s) → s = univ := eq_univ_iff_forall.2 #align set.eq_univ_of_forall Set.eq_univ_of_forall theorem Nonempty.eq_univ [Subsingleton α] : s.Nonempty → s = univ := by rintro ⟨x, hx⟩ exact eq_univ_of_forall fun y => by rwa [Subsingleton.elim y x] #align set.nonempty.eq_univ Set.Nonempty.eq_univ theorem eq_univ_of_subset {s t : Set α} (h : s ⊆ t) (hs : s = univ) : t = univ := eq_univ_of_univ_subset <| (hs ▸ h : univ ⊆ t) #align set.eq_univ_of_subset Set.eq_univ_of_subset theorem exists_mem_of_nonempty (α) : ∀ [Nonempty α], ∃ x : α, x ∈ (univ : Set α) | ⟨x⟩ => ⟨x, trivial⟩ #align set.exists_mem_of_nonempty Set.exists_mem_of_nonempty theorem ne_univ_iff_exists_not_mem {α : Type*} (s : Set α) : s ≠ univ ↔ ∃ a, a ∉ s := by rw [← not_forall, ← eq_univ_iff_forall] #align set.ne_univ_iff_exists_not_mem Set.ne_univ_iff_exists_not_mem theorem not_subset_iff_exists_mem_not_mem {α : Type*} {s t : Set α} : ¬s ⊆ t ↔ ∃ x, x ∈ s ∧ x ∉ t := by simp [subset_def] #align set.not_subset_iff_exists_mem_not_mem Set.not_subset_iff_exists_mem_not_mem theorem univ_unique [Unique α] : @Set.univ α = {default} := Set.ext fun x => iff_of_true trivial <| Subsingleton.elim x default #align set.univ_unique Set.univ_unique theorem ssubset_univ_iff : s ⊂ univ ↔ s ≠ univ := lt_top_iff_ne_top #align set.ssubset_univ_iff Set.ssubset_univ_iff instance nontrivial_of_nonempty [Nonempty α] : Nontrivial (Set α) := ⟨⟨∅, univ, empty_ne_univ⟩⟩ #align set.nontrivial_of_nonempty Set.nontrivial_of_nonempty theorem union_def {s₁ s₂ : Set α} : s₁ ∪ s₂ = { a | a ∈ s₁ ∨ a ∈ s₂ } := rfl #align set.union_def Set.union_def theorem mem_union_left {x : α} {a : Set α} (b : Set α) : x ∈ a → x ∈ a ∪ b := Or.inl #align set.mem_union_left Set.mem_union_left theorem mem_union_right {x : α} {b : Set α} (a : Set α) : x ∈ b → x ∈ a ∪ b := Or.inr #align set.mem_union_right Set.mem_union_right theorem mem_or_mem_of_mem_union {x : α} {a b : Set α} (H : x ∈ a ∪ b) : x ∈ a ∨ x ∈ b := H #align set.mem_or_mem_of_mem_union Set.mem_or_mem_of_mem_union theorem MemUnion.elim {x : α} {a b : Set α} {P : Prop} (H₁ : x ∈ a ∪ b) (H₂ : x ∈ a → P) (H₃ : x ∈ b → P) : P := Or.elim H₁ H₂ H₃ #align set.mem_union.elim Set.MemUnion.elim @[simp] theorem mem_union (x : α) (a b : Set α) : x ∈ a ∪ b ↔ x ∈ a ∨ x ∈ b := Iff.rfl #align set.mem_union Set.mem_union @[simp] theorem union_self (a : Set α) : a ∪ a = a := ext fun _ => or_self_iff #align set.union_self Set.union_self @[simp] theorem union_empty (a : Set α) : a ∪ ∅ = a := ext fun _ => or_false_iff _ #align set.union_empty Set.union_empty @[simp] theorem empty_union (a : Set α) : ∅ ∪ a = a := ext fun _ => false_or_iff _ #align set.empty_union Set.empty_union theorem union_comm (a b : Set α) : a ∪ b = b ∪ a := ext fun _ => or_comm #align set.union_comm Set.union_comm theorem union_assoc (a b c : Set α) : a ∪ b ∪ c = a ∪ (b ∪ c) := ext fun _ => or_assoc #align set.union_assoc Set.union_assoc instance union_isAssoc : Std.Associative (α := Set α) (· ∪ ·) := ⟨union_assoc⟩ #align set.union_is_assoc Set.union_isAssoc instance union_isComm : Std.Commutative (α := Set α) (· ∪ ·) := ⟨union_comm⟩ #align set.union_is_comm Set.union_isComm theorem union_left_comm (s₁ s₂ s₃ : Set α) : s₁ ∪ (s₂ ∪ s₃) = s₂ ∪ (s₁ ∪ s₃) := ext fun _ => or_left_comm #align set.union_left_comm Set.union_left_comm theorem union_right_comm (s₁ s₂ s₃ : Set α) : s₁ ∪ s₂ ∪ s₃ = s₁ ∪ s₃ ∪ s₂ := ext fun _ => or_right_comm #align set.union_right_comm Set.union_right_comm @[simp] theorem union_eq_left {s t : Set α} : s ∪ t = s ↔ t ⊆ s := sup_eq_left #align set.union_eq_left_iff_subset Set.union_eq_left @[simp] theorem union_eq_right {s t : Set α} : s ∪ t = t ↔ s ⊆ t := sup_eq_right #align set.union_eq_right_iff_subset Set.union_eq_right theorem union_eq_self_of_subset_left {s t : Set α} (h : s ⊆ t) : s ∪ t = t := union_eq_right.mpr h #align set.union_eq_self_of_subset_left Set.union_eq_self_of_subset_left theorem union_eq_self_of_subset_right {s t : Set α} (h : t ⊆ s) : s ∪ t = s := union_eq_left.mpr h #align set.union_eq_self_of_subset_right Set.union_eq_self_of_subset_right @[simp] theorem subset_union_left {s t : Set α} : s ⊆ s ∪ t := fun _ => Or.inl #align set.subset_union_left Set.subset_union_left @[simp] theorem subset_union_right {s t : Set α} : t ⊆ s ∪ t := fun _ => Or.inr #align set.subset_union_right Set.subset_union_right theorem union_subset {s t r : Set α} (sr : s ⊆ r) (tr : t ⊆ r) : s ∪ t ⊆ r := fun _ => Or.rec (@sr _) (@tr _) #align set.union_subset Set.union_subset @[simp] theorem union_subset_iff {s t u : Set α} : s ∪ t ⊆ u ↔ s ⊆ u ∧ t ⊆ u := (forall_congr' fun _ => or_imp).trans forall_and #align set.union_subset_iff Set.union_subset_iff @[gcongr] theorem union_subset_union {s₁ s₂ t₁ t₂ : Set α} (h₁ : s₁ ⊆ s₂) (h₂ : t₁ ⊆ t₂) : s₁ ∪ t₁ ⊆ s₂ ∪ t₂ := fun _ => Or.imp (@h₁ _) (@h₂ _) #align set.union_subset_union Set.union_subset_union @[gcongr] theorem union_subset_union_left {s₁ s₂ : Set α} (t) (h : s₁ ⊆ s₂) : s₁ ∪ t ⊆ s₂ ∪ t := union_subset_union h Subset.rfl #align set.union_subset_union_left Set.union_subset_union_left @[gcongr] theorem union_subset_union_right (s) {t₁ t₂ : Set α} (h : t₁ ⊆ t₂) : s ∪ t₁ ⊆ s ∪ t₂ := union_subset_union Subset.rfl h #align set.union_subset_union_right Set.union_subset_union_right theorem subset_union_of_subset_left {s t : Set α} (h : s ⊆ t) (u : Set α) : s ⊆ t ∪ u := h.trans subset_union_left #align set.subset_union_of_subset_left Set.subset_union_of_subset_left theorem subset_union_of_subset_right {s u : Set α} (h : s ⊆ u) (t : Set α) : s ⊆ t ∪ u := h.trans subset_union_right #align set.subset_union_of_subset_right Set.subset_union_of_subset_right -- Porting note: replaced `⊔` in RHS theorem union_congr_left (ht : t ⊆ s ∪ u) (hu : u ⊆ s ∪ t) : s ∪ t = s ∪ u := sup_congr_left ht hu #align set.union_congr_left Set.union_congr_left theorem union_congr_right (hs : s ⊆ t ∪ u) (ht : t ⊆ s ∪ u) : s ∪ u = t ∪ u := sup_congr_right hs ht #align set.union_congr_right Set.union_congr_right theorem union_eq_union_iff_left : s ∪ t = s ∪ u ↔ t ⊆ s ∪ u ∧ u ⊆ s ∪ t := sup_eq_sup_iff_left #align set.union_eq_union_iff_left Set.union_eq_union_iff_left theorem union_eq_union_iff_right : s ∪ u = t ∪ u ↔ s ⊆ t ∪ u ∧ t ⊆ s ∪ u := sup_eq_sup_iff_right #align set.union_eq_union_iff_right Set.union_eq_union_iff_right @[simp] theorem union_empty_iff {s t : Set α} : s ∪ t = ∅ ↔ s = ∅ ∧ t = ∅ := by simp only [← subset_empty_iff] exact union_subset_iff #align set.union_empty_iff Set.union_empty_iff @[simp] theorem union_univ (s : Set α) : s ∪ univ = univ := sup_top_eq _ #align set.union_univ Set.union_univ @[simp] theorem univ_union (s : Set α) : univ ∪ s = univ := top_sup_eq _ #align set.univ_union Set.univ_union theorem inter_def {s₁ s₂ : Set α} : s₁ ∩ s₂ = { a | a ∈ s₁ ∧ a ∈ s₂ } := rfl #align set.inter_def Set.inter_def @[simp, mfld_simps] theorem mem_inter_iff (x : α) (a b : Set α) : x ∈ a ∩ b ↔ x ∈ a ∧ x ∈ b := Iff.rfl #align set.mem_inter_iff Set.mem_inter_iff theorem mem_inter {x : α} {a b : Set α} (ha : x ∈ a) (hb : x ∈ b) : x ∈ a ∩ b := ⟨ha, hb⟩ #align set.mem_inter Set.mem_inter theorem mem_of_mem_inter_left {x : α} {a b : Set α} (h : x ∈ a ∩ b) : x ∈ a := h.left #align set.mem_of_mem_inter_left Set.mem_of_mem_inter_left theorem mem_of_mem_inter_right {x : α} {a b : Set α} (h : x ∈ a ∩ b) : x ∈ b := h.right #align set.mem_of_mem_inter_right Set.mem_of_mem_inter_right @[simp] theorem inter_self (a : Set α) : a ∩ a = a := ext fun _ => and_self_iff #align set.inter_self Set.inter_self @[simp] theorem inter_empty (a : Set α) : a ∩ ∅ = ∅ := ext fun _ => and_false_iff _ #align set.inter_empty Set.inter_empty @[simp] theorem empty_inter (a : Set α) : ∅ ∩ a = ∅ := ext fun _ => false_and_iff _ #align set.empty_inter Set.empty_inter theorem inter_comm (a b : Set α) : a ∩ b = b ∩ a := ext fun _ => and_comm #align set.inter_comm Set.inter_comm theorem inter_assoc (a b c : Set α) : a ∩ b ∩ c = a ∩ (b ∩ c) := ext fun _ => and_assoc #align set.inter_assoc Set.inter_assoc instance inter_isAssoc : Std.Associative (α := Set α) (· ∩ ·) := ⟨inter_assoc⟩ #align set.inter_is_assoc Set.inter_isAssoc instance inter_isComm : Std.Commutative (α := Set α) (· ∩ ·) := ⟨inter_comm⟩ #align set.inter_is_comm Set.inter_isComm theorem inter_left_comm (s₁ s₂ s₃ : Set α) : s₁ ∩ (s₂ ∩ s₃) = s₂ ∩ (s₁ ∩ s₃) := ext fun _ => and_left_comm #align set.inter_left_comm Set.inter_left_comm theorem inter_right_comm (s₁ s₂ s₃ : Set α) : s₁ ∩ s₂ ∩ s₃ = s₁ ∩ s₃ ∩ s₂ := ext fun _ => and_right_comm #align set.inter_right_comm Set.inter_right_comm @[simp, mfld_simps] theorem inter_subset_left {s t : Set α} : s ∩ t ⊆ s := fun _ => And.left #align set.inter_subset_left Set.inter_subset_left @[simp] theorem inter_subset_right {s t : Set α} : s ∩ t ⊆ t := fun _ => And.right #align set.inter_subset_right Set.inter_subset_right theorem subset_inter {s t r : Set α} (rs : r ⊆ s) (rt : r ⊆ t) : r ⊆ s ∩ t := fun _ h => ⟨rs h, rt h⟩ #align set.subset_inter Set.subset_inter @[simp] theorem subset_inter_iff {s t r : Set α} : r ⊆ s ∩ t ↔ r ⊆ s ∧ r ⊆ t := (forall_congr' fun _ => imp_and).trans forall_and #align set.subset_inter_iff Set.subset_inter_iff @[simp] lemma inter_eq_left : s ∩ t = s ↔ s ⊆ t := inf_eq_left #align set.inter_eq_left_iff_subset Set.inter_eq_left @[simp] lemma inter_eq_right : s ∩ t = t ↔ t ⊆ s := inf_eq_right #align set.inter_eq_right_iff_subset Set.inter_eq_right @[simp] lemma left_eq_inter : s = s ∩ t ↔ s ⊆ t := left_eq_inf @[simp] lemma right_eq_inter : t = s ∩ t ↔ t ⊆ s := right_eq_inf theorem inter_eq_self_of_subset_left {s t : Set α} : s ⊆ t → s ∩ t = s := inter_eq_left.mpr #align set.inter_eq_self_of_subset_left Set.inter_eq_self_of_subset_left theorem inter_eq_self_of_subset_right {s t : Set α} : t ⊆ s → s ∩ t = t := inter_eq_right.mpr #align set.inter_eq_self_of_subset_right Set.inter_eq_self_of_subset_right theorem inter_congr_left (ht : s ∩ u ⊆ t) (hu : s ∩ t ⊆ u) : s ∩ t = s ∩ u := inf_congr_left ht hu #align set.inter_congr_left Set.inter_congr_left theorem inter_congr_right (hs : t ∩ u ⊆ s) (ht : s ∩ u ⊆ t) : s ∩ u = t ∩ u := inf_congr_right hs ht #align set.inter_congr_right Set.inter_congr_right theorem inter_eq_inter_iff_left : s ∩ t = s ∩ u ↔ s ∩ u ⊆ t ∧ s ∩ t ⊆ u := inf_eq_inf_iff_left #align set.inter_eq_inter_iff_left Set.inter_eq_inter_iff_left theorem inter_eq_inter_iff_right : s ∩ u = t ∩ u ↔ t ∩ u ⊆ s ∧ s ∩ u ⊆ t := inf_eq_inf_iff_right #align set.inter_eq_inter_iff_right Set.inter_eq_inter_iff_right @[simp, mfld_simps] theorem inter_univ (a : Set α) : a ∩ univ = a := inf_top_eq _ #align set.inter_univ Set.inter_univ @[simp, mfld_simps] theorem univ_inter (a : Set α) : univ ∩ a = a := top_inf_eq _ #align set.univ_inter Set.univ_inter @[gcongr] theorem inter_subset_inter {s₁ s₂ t₁ t₂ : Set α} (h₁ : s₁ ⊆ t₁) (h₂ : s₂ ⊆ t₂) : s₁ ∩ s₂ ⊆ t₁ ∩ t₂ := fun _ => And.imp (@h₁ _) (@h₂ _) #align set.inter_subset_inter Set.inter_subset_inter @[gcongr] theorem inter_subset_inter_left {s t : Set α} (u : Set α) (H : s ⊆ t) : s ∩ u ⊆ t ∩ u := inter_subset_inter H Subset.rfl #align set.inter_subset_inter_left Set.inter_subset_inter_left @[gcongr] theorem inter_subset_inter_right {s t : Set α} (u : Set α) (H : s ⊆ t) : u ∩ s ⊆ u ∩ t := inter_subset_inter Subset.rfl H #align set.inter_subset_inter_right Set.inter_subset_inter_right theorem union_inter_cancel_left {s t : Set α} : (s ∪ t) ∩ s = s := inter_eq_self_of_subset_right subset_union_left #align set.union_inter_cancel_left Set.union_inter_cancel_left theorem union_inter_cancel_right {s t : Set α} : (s ∪ t) ∩ t = t := inter_eq_self_of_subset_right subset_union_right #align set.union_inter_cancel_right Set.union_inter_cancel_right theorem inter_setOf_eq_sep (s : Set α) (p : α → Prop) : s ∩ {a | p a} = {a ∈ s | p a} := rfl #align set.inter_set_of_eq_sep Set.inter_setOf_eq_sep theorem setOf_inter_eq_sep (p : α → Prop) (s : Set α) : {a | p a} ∩ s = {a ∈ s | p a} := inter_comm _ _ #align set.set_of_inter_eq_sep Set.setOf_inter_eq_sep theorem inter_union_distrib_left (s t u : Set α) : s ∩ (t ∪ u) = s ∩ t ∪ s ∩ u := inf_sup_left _ _ _ #align set.inter_distrib_left Set.inter_union_distrib_left theorem union_inter_distrib_right (s t u : Set α) : (s ∪ t) ∩ u = s ∩ u ∪ t ∩ u := inf_sup_right _ _ _ #align set.inter_distrib_right Set.union_inter_distrib_right theorem union_inter_distrib_left (s t u : Set α) : s ∪ t ∩ u = (s ∪ t) ∩ (s ∪ u) := sup_inf_left _ _ _ #align set.union_distrib_left Set.union_inter_distrib_left theorem inter_union_distrib_right (s t u : Set α) : s ∩ t ∪ u = (s ∪ u) ∩ (t ∪ u) := sup_inf_right _ _ _ #align set.union_distrib_right Set.inter_union_distrib_right -- 2024-03-22 @[deprecated] alias inter_distrib_left := inter_union_distrib_left @[deprecated] alias inter_distrib_right := union_inter_distrib_right @[deprecated] alias union_distrib_left := union_inter_distrib_left @[deprecated] alias union_distrib_right := inter_union_distrib_right theorem union_union_distrib_left (s t u : Set α) : s ∪ (t ∪ u) = s ∪ t ∪ (s ∪ u) := sup_sup_distrib_left _ _ _ #align set.union_union_distrib_left Set.union_union_distrib_left theorem union_union_distrib_right (s t u : Set α) : s ∪ t ∪ u = s ∪ u ∪ (t ∪ u) := sup_sup_distrib_right _ _ _ #align set.union_union_distrib_right Set.union_union_distrib_right theorem inter_inter_distrib_left (s t u : Set α) : s ∩ (t ∩ u) = s ∩ t ∩ (s ∩ u) := inf_inf_distrib_left _ _ _ #align set.inter_inter_distrib_left Set.inter_inter_distrib_left theorem inter_inter_distrib_right (s t u : Set α) : s ∩ t ∩ u = s ∩ u ∩ (t ∩ u) := inf_inf_distrib_right _ _ _ #align set.inter_inter_distrib_right Set.inter_inter_distrib_right theorem union_union_union_comm (s t u v : Set α) : s ∪ t ∪ (u ∪ v) = s ∪ u ∪ (t ∪ v) := sup_sup_sup_comm _ _ _ _ #align set.union_union_union_comm Set.union_union_union_comm theorem inter_inter_inter_comm (s t u v : Set α) : s ∩ t ∩ (u ∩ v) = s ∩ u ∩ (t ∩ v) := inf_inf_inf_comm _ _ _ _ #align set.inter_inter_inter_comm Set.inter_inter_inter_comm theorem insert_def (x : α) (s : Set α) : insert x s = { y | y = x ∨ y ∈ s } := rfl #align set.insert_def Set.insert_def @[simp] theorem subset_insert (x : α) (s : Set α) : s ⊆ insert x s := fun _ => Or.inr #align set.subset_insert Set.subset_insert theorem mem_insert (x : α) (s : Set α) : x ∈ insert x s := Or.inl rfl #align set.mem_insert Set.mem_insert theorem mem_insert_of_mem {x : α} {s : Set α} (y : α) : x ∈ s → x ∈ insert y s := Or.inr #align set.mem_insert_of_mem Set.mem_insert_of_mem theorem eq_or_mem_of_mem_insert {x a : α} {s : Set α} : x ∈ insert a s → x = a ∨ x ∈ s := id #align set.eq_or_mem_of_mem_insert Set.eq_or_mem_of_mem_insert theorem mem_of_mem_insert_of_ne : b ∈ insert a s → b ≠ a → b ∈ s := Or.resolve_left #align set.mem_of_mem_insert_of_ne Set.mem_of_mem_insert_of_ne theorem eq_of_not_mem_of_mem_insert : b ∈ insert a s → b ∉ s → b = a := Or.resolve_right #align set.eq_of_not_mem_of_mem_insert Set.eq_of_not_mem_of_mem_insert @[simp] theorem mem_insert_iff {x a : α} {s : Set α} : x ∈ insert a s ↔ x = a ∨ x ∈ s := Iff.rfl #align set.mem_insert_iff Set.mem_insert_iff @[simp] theorem insert_eq_of_mem {a : α} {s : Set α} (h : a ∈ s) : insert a s = s := ext fun _ => or_iff_right_of_imp fun e => e.symm ▸ h #align set.insert_eq_of_mem Set.insert_eq_of_mem theorem ne_insert_of_not_mem {s : Set α} (t : Set α) {a : α} : a ∉ s → s ≠ insert a t := mt fun e => e.symm ▸ mem_insert _ _ #align set.ne_insert_of_not_mem Set.ne_insert_of_not_mem @[simp] theorem insert_eq_self : insert a s = s ↔ a ∈ s := ⟨fun h => h ▸ mem_insert _ _, insert_eq_of_mem⟩ #align set.insert_eq_self Set.insert_eq_self theorem insert_ne_self : insert a s ≠ s ↔ a ∉ s := insert_eq_self.not #align set.insert_ne_self Set.insert_ne_self theorem insert_subset_iff : insert a s ⊆ t ↔ a ∈ t ∧ s ⊆ t := by simp only [subset_def, mem_insert_iff, or_imp, forall_and, forall_eq] #align set.insert_subset Set.insert_subset_iff theorem insert_subset (ha : a ∈ t) (hs : s ⊆ t) : insert a s ⊆ t := insert_subset_iff.mpr ⟨ha, hs⟩ theorem insert_subset_insert (h : s ⊆ t) : insert a s ⊆ insert a t := fun _ => Or.imp_right (@h _) #align set.insert_subset_insert Set.insert_subset_insert @[simp] theorem insert_subset_insert_iff (ha : a ∉ s) : insert a s ⊆ insert a t ↔ s ⊆ t := by refine ⟨fun h x hx => ?_, insert_subset_insert⟩ rcases h (subset_insert _ _ hx) with (rfl | hxt) exacts [(ha hx).elim, hxt] #align set.insert_subset_insert_iff Set.insert_subset_insert_iff theorem subset_insert_iff_of_not_mem (ha : a ∉ s) : s ⊆ insert a t ↔ s ⊆ t := forall₂_congr fun _ hb => or_iff_right <| ne_of_mem_of_not_mem hb ha #align set.subset_insert_iff_of_not_mem Set.subset_insert_iff_of_not_mem theorem ssubset_iff_insert {s t : Set α} : s ⊂ t ↔ ∃ a ∉ s, insert a s ⊆ t := by simp only [insert_subset_iff, exists_and_right, ssubset_def, not_subset] aesop #align set.ssubset_iff_insert Set.ssubset_iff_insert theorem ssubset_insert {s : Set α} {a : α} (h : a ∉ s) : s ⊂ insert a s := ssubset_iff_insert.2 ⟨a, h, Subset.rfl⟩ #align set.ssubset_insert Set.ssubset_insert theorem insert_comm (a b : α) (s : Set α) : insert a (insert b s) = insert b (insert a s) := ext fun _ => or_left_comm #align set.insert_comm Set.insert_comm -- Porting note (#10618): removing `simp` attribute because `simp` can prove it theorem insert_idem (a : α) (s : Set α) : insert a (insert a s) = insert a s := insert_eq_of_mem <| mem_insert _ _ #align set.insert_idem Set.insert_idem theorem insert_union : insert a s ∪ t = insert a (s ∪ t) := ext fun _ => or_assoc #align set.insert_union Set.insert_union @[simp] theorem union_insert : s ∪ insert a t = insert a (s ∪ t) := ext fun _ => or_left_comm #align set.union_insert Set.union_insert @[simp] theorem insert_nonempty (a : α) (s : Set α) : (insert a s).Nonempty := ⟨a, mem_insert a s⟩ #align set.insert_nonempty Set.insert_nonempty instance (a : α) (s : Set α) : Nonempty (insert a s : Set α) := (insert_nonempty a s).to_subtype theorem insert_inter_distrib (a : α) (s t : Set α) : insert a (s ∩ t) = insert a s ∩ insert a t := ext fun _ => or_and_left #align set.insert_inter_distrib Set.insert_inter_distrib theorem insert_union_distrib (a : α) (s t : Set α) : insert a (s ∪ t) = insert a s ∪ insert a t := ext fun _ => or_or_distrib_left #align set.insert_union_distrib Set.insert_union_distrib theorem insert_inj (ha : a ∉ s) : insert a s = insert b s ↔ a = b := ⟨fun h => eq_of_not_mem_of_mem_insert (h.subst <| mem_insert a s) ha, congr_arg (fun x => insert x s)⟩ #align set.insert_inj Set.insert_inj -- useful in proofs by induction theorem forall_of_forall_insert {P : α → Prop} {a : α} {s : Set α} (H : ∀ x, x ∈ insert a s → P x) (x) (h : x ∈ s) : P x := H _ (Or.inr h) #align set.forall_of_forall_insert Set.forall_of_forall_insert theorem forall_insert_of_forall {P : α → Prop} {a : α} {s : Set α} (H : ∀ x, x ∈ s → P x) (ha : P a) (x) (h : x ∈ insert a s) : P x := h.elim (fun e => e.symm ▸ ha) (H _) #align set.forall_insert_of_forall Set.forall_insert_of_forall theorem exists_mem_insert {P : α → Prop} {a : α} {s : Set α} : (∃ x ∈ insert a s, P x) ↔ (P a ∨ ∃ x ∈ s, P x) := by simp [mem_insert_iff, or_and_right, exists_and_left, exists_or] #align set.bex_insert_iff Set.exists_mem_insert @[deprecated (since := "2024-03-23")] alias bex_insert_iff := exists_mem_insert theorem forall_mem_insert {P : α → Prop} {a : α} {s : Set α} : (∀ x ∈ insert a s, P x) ↔ P a ∧ ∀ x ∈ s, P x := forall₂_or_left.trans <| and_congr_left' forall_eq #align set.ball_insert_iff Set.forall_mem_insert @[deprecated (since := "2024-03-23")] alias ball_insert_iff := forall_mem_insert instance : LawfulSingleton α (Set α) := ⟨fun x => Set.ext fun a => by simp only [mem_empty_iff_false, mem_insert_iff, or_false] exact Iff.rfl⟩ theorem singleton_def (a : α) : ({a} : Set α) = insert a ∅ := (insert_emptyc_eq a).symm #align set.singleton_def Set.singleton_def @[simp] theorem mem_singleton_iff {a b : α} : a ∈ ({b} : Set α) ↔ a = b := Iff.rfl #align set.mem_singleton_iff Set.mem_singleton_iff @[simp] theorem setOf_eq_eq_singleton {a : α} : { n | n = a } = {a} := rfl #align set.set_of_eq_eq_singleton Set.setOf_eq_eq_singleton @[simp] theorem setOf_eq_eq_singleton' {a : α} : { x | a = x } = {a} := ext fun _ => eq_comm #align set.set_of_eq_eq_singleton' Set.setOf_eq_eq_singleton' -- TODO: again, annotation needed --Porting note (#11119): removed `simp` attribute theorem mem_singleton (a : α) : a ∈ ({a} : Set α) := @rfl _ _ #align set.mem_singleton Set.mem_singleton theorem eq_of_mem_singleton {x y : α} (h : x ∈ ({y} : Set α)) : x = y := h #align set.eq_of_mem_singleton Set.eq_of_mem_singleton @[simp] theorem singleton_eq_singleton_iff {x y : α} : {x} = ({y} : Set α) ↔ x = y := ext_iff.trans eq_iff_eq_cancel_left #align set.singleton_eq_singleton_iff Set.singleton_eq_singleton_iff theorem singleton_injective : Injective (singleton : α → Set α) := fun _ _ => singleton_eq_singleton_iff.mp #align set.singleton_injective Set.singleton_injective theorem mem_singleton_of_eq {x y : α} (H : x = y) : x ∈ ({y} : Set α) := H #align set.mem_singleton_of_eq Set.mem_singleton_of_eq theorem insert_eq (x : α) (s : Set α) : insert x s = ({x} : Set α) ∪ s := rfl #align set.insert_eq Set.insert_eq @[simp] theorem singleton_nonempty (a : α) : ({a} : Set α).Nonempty := ⟨a, rfl⟩ #align set.singleton_nonempty Set.singleton_nonempty @[simp] theorem singleton_ne_empty (a : α) : ({a} : Set α) ≠ ∅ := (singleton_nonempty _).ne_empty #align set.singleton_ne_empty Set.singleton_ne_empty --Porting note (#10618): removed `simp` attribute because `simp` can prove it theorem empty_ssubset_singleton : (∅ : Set α) ⊂ {a} := (singleton_nonempty _).empty_ssubset #align set.empty_ssubset_singleton Set.empty_ssubset_singleton @[simp] theorem singleton_subset_iff {a : α} {s : Set α} : {a} ⊆ s ↔ a ∈ s := forall_eq #align set.singleton_subset_iff Set.singleton_subset_iff theorem singleton_subset_singleton : ({a} : Set α) ⊆ {b} ↔ a = b := by simp #align set.singleton_subset_singleton Set.singleton_subset_singleton theorem set_compr_eq_eq_singleton {a : α} : { b | b = a } = {a} := rfl #align set.set_compr_eq_eq_singleton Set.set_compr_eq_eq_singleton @[simp] theorem singleton_union : {a} ∪ s = insert a s := rfl #align set.singleton_union Set.singleton_union @[simp] theorem union_singleton : s ∪ {a} = insert a s := union_comm _ _ #align set.union_singleton Set.union_singleton @[simp] theorem singleton_inter_nonempty : ({a} ∩ s).Nonempty ↔ a ∈ s := by simp only [Set.Nonempty, mem_inter_iff, mem_singleton_iff, exists_eq_left] #align set.singleton_inter_nonempty Set.singleton_inter_nonempty @[simp] theorem inter_singleton_nonempty : (s ∩ {a}).Nonempty ↔ a ∈ s := by rw [inter_comm, singleton_inter_nonempty] #align set.inter_singleton_nonempty Set.inter_singleton_nonempty @[simp] theorem singleton_inter_eq_empty : {a} ∩ s = ∅ ↔ a ∉ s := not_nonempty_iff_eq_empty.symm.trans singleton_inter_nonempty.not #align set.singleton_inter_eq_empty Set.singleton_inter_eq_empty @[simp] theorem inter_singleton_eq_empty : s ∩ {a} = ∅ ↔ a ∉ s := by rw [inter_comm, singleton_inter_eq_empty] #align set.inter_singleton_eq_empty Set.inter_singleton_eq_empty theorem nmem_singleton_empty {s : Set α} : s ∉ ({∅} : Set (Set α)) ↔ s.Nonempty := nonempty_iff_ne_empty.symm #align set.nmem_singleton_empty Set.nmem_singleton_empty instance uniqueSingleton (a : α) : Unique (↥({a} : Set α)) := ⟨⟨⟨a, mem_singleton a⟩⟩, fun ⟨_, h⟩ => Subtype.eq h⟩ #align set.unique_singleton Set.uniqueSingleton theorem eq_singleton_iff_unique_mem : s = {a} ↔ a ∈ s ∧ ∀ x ∈ s, x = a := Subset.antisymm_iff.trans <| and_comm.trans <| and_congr_left' singleton_subset_iff #align set.eq_singleton_iff_unique_mem Set.eq_singleton_iff_unique_mem theorem eq_singleton_iff_nonempty_unique_mem : s = {a} ↔ s.Nonempty ∧ ∀ x ∈ s, x = a := eq_singleton_iff_unique_mem.trans <| and_congr_left fun H => ⟨fun h' => ⟨_, h'⟩, fun ⟨x, h⟩ => H x h ▸ h⟩ #align set.eq_singleton_iff_nonempty_unique_mem Set.eq_singleton_iff_nonempty_unique_mem set_option backward.synthInstance.canonInstances false in -- See https://github.com/leanprover-community/mathlib4/issues/12532 -- while `simp` is capable of proving this, it is not capable of turning the LHS into the RHS. @[simp] theorem default_coe_singleton (x : α) : (default : ({x} : Set α)) = ⟨x, rfl⟩ := rfl #align set.default_coe_singleton Set.default_coe_singleton @[simp] theorem subset_singleton_iff {α : Type*} {s : Set α} {x : α} : s ⊆ {x} ↔ ∀ y ∈ s, y = x := Iff.rfl #align set.subset_singleton_iff Set.subset_singleton_iff theorem subset_singleton_iff_eq {s : Set α} {x : α} : s ⊆ {x} ↔ s = ∅ ∨ s = {x} := by obtain rfl | hs := s.eq_empty_or_nonempty · exact ⟨fun _ => Or.inl rfl, fun _ => empty_subset _⟩ · simp [eq_singleton_iff_nonempty_unique_mem, hs, hs.ne_empty] #align set.subset_singleton_iff_eq Set.subset_singleton_iff_eq theorem Nonempty.subset_singleton_iff (h : s.Nonempty) : s ⊆ {a} ↔ s = {a} := subset_singleton_iff_eq.trans <| or_iff_right h.ne_empty #align set.nonempty.subset_singleton_iff Set.Nonempty.subset_singleton_iff theorem ssubset_singleton_iff {s : Set α} {x : α} : s ⊂ {x} ↔ s = ∅ := by rw [ssubset_iff_subset_ne, subset_singleton_iff_eq, or_and_right, and_not_self_iff, or_false_iff, and_iff_left_iff_imp] exact fun h => h ▸ (singleton_ne_empty _).symm #align set.ssubset_singleton_iff Set.ssubset_singleton_iff theorem eq_empty_of_ssubset_singleton {s : Set α} {x : α} (hs : s ⊂ {x}) : s = ∅ := ssubset_singleton_iff.1 hs #align set.eq_empty_of_ssubset_singleton Set.eq_empty_of_ssubset_singleton theorem eq_of_nonempty_of_subsingleton {α} [Subsingleton α] (s t : Set α) [Nonempty s] [Nonempty t] : s = t := nonempty_of_nonempty_subtype.eq_univ.trans nonempty_of_nonempty_subtype.eq_univ.symm theorem eq_of_nonempty_of_subsingleton' {α} [Subsingleton α] {s : Set α} (t : Set α) (hs : s.Nonempty) [Nonempty t] : s = t := have := hs.to_subtype; eq_of_nonempty_of_subsingleton s t set_option backward.synthInstance.canonInstances false in -- See https://github.com/leanprover-community/mathlib4/issues/12532 theorem Nonempty.eq_zero [Subsingleton α] [Zero α] {s : Set α} (h : s.Nonempty) : s = {0} := eq_of_nonempty_of_subsingleton' {0} h set_option backward.synthInstance.canonInstances false in -- See https://github.com/leanprover-community/mathlib4/issues/12532 theorem Nonempty.eq_one [Subsingleton α] [One α] {s : Set α} (h : s.Nonempty) : s = {1} := eq_of_nonempty_of_subsingleton' {1} h protected theorem disjoint_iff : Disjoint s t ↔ s ∩ t ⊆ ∅ := disjoint_iff_inf_le #align set.disjoint_iff Set.disjoint_iff theorem disjoint_iff_inter_eq_empty : Disjoint s t ↔ s ∩ t = ∅ := disjoint_iff #align set.disjoint_iff_inter_eq_empty Set.disjoint_iff_inter_eq_empty theorem _root_.Disjoint.inter_eq : Disjoint s t → s ∩ t = ∅ := Disjoint.eq_bot #align disjoint.inter_eq Disjoint.inter_eq theorem disjoint_left : Disjoint s t ↔ ∀ ⦃a⦄, a ∈ s → a ∉ t := disjoint_iff_inf_le.trans <| forall_congr' fun _ => not_and #align set.disjoint_left Set.disjoint_left theorem disjoint_right : Disjoint s t ↔ ∀ ⦃a⦄, a ∈ t → a ∉ s := by rw [disjoint_comm, disjoint_left] #align set.disjoint_right Set.disjoint_right lemma not_disjoint_iff : ¬Disjoint s t ↔ ∃ x, x ∈ s ∧ x ∈ t := Set.disjoint_iff.not.trans <| not_forall.trans <| exists_congr fun _ ↦ not_not #align set.not_disjoint_iff Set.not_disjoint_iff lemma not_disjoint_iff_nonempty_inter : ¬ Disjoint s t ↔ (s ∩ t).Nonempty := not_disjoint_iff #align set.not_disjoint_iff_nonempty_inter Set.not_disjoint_iff_nonempty_inter alias ⟨_, Nonempty.not_disjoint⟩ := not_disjoint_iff_nonempty_inter #align set.nonempty.not_disjoint Set.Nonempty.not_disjoint lemma disjoint_or_nonempty_inter (s t : Set α) : Disjoint s t ∨ (s ∩ t).Nonempty := (em _).imp_right not_disjoint_iff_nonempty_inter.1 #align set.disjoint_or_nonempty_inter Set.disjoint_or_nonempty_inter lemma disjoint_iff_forall_ne : Disjoint s t ↔ ∀ ⦃a⦄, a ∈ s → ∀ ⦃b⦄, b ∈ t → a ≠ b := by simp only [Ne, disjoint_left, @imp_not_comm _ (_ = _), forall_eq'] #align set.disjoint_iff_forall_ne Set.disjoint_iff_forall_ne alias ⟨_root_.Disjoint.ne_of_mem, _⟩ := disjoint_iff_forall_ne #align disjoint.ne_of_mem Disjoint.ne_of_mem lemma disjoint_of_subset_left (h : s ⊆ u) (d : Disjoint u t) : Disjoint s t := d.mono_left h #align set.disjoint_of_subset_left Set.disjoint_of_subset_left lemma disjoint_of_subset_right (h : t ⊆ u) (d : Disjoint s u) : Disjoint s t := d.mono_right h #align set.disjoint_of_subset_right Set.disjoint_of_subset_right lemma disjoint_of_subset (hs : s₁ ⊆ s₂) (ht : t₁ ⊆ t₂) (h : Disjoint s₂ t₂) : Disjoint s₁ t₁ := h.mono hs ht #align set.disjoint_of_subset Set.disjoint_of_subset @[simp] lemma disjoint_union_left : Disjoint (s ∪ t) u ↔ Disjoint s u ∧ Disjoint t u := disjoint_sup_left #align set.disjoint_union_left Set.disjoint_union_left @[simp] lemma disjoint_union_right : Disjoint s (t ∪ u) ↔ Disjoint s t ∧ Disjoint s u := disjoint_sup_right #align set.disjoint_union_right Set.disjoint_union_right @[simp] lemma disjoint_empty (s : Set α) : Disjoint s ∅ := disjoint_bot_right #align set.disjoint_empty Set.disjoint_empty @[simp] lemma empty_disjoint (s : Set α) : Disjoint ∅ s := disjoint_bot_left #align set.empty_disjoint Set.empty_disjoint @[simp] lemma univ_disjoint : Disjoint univ s ↔ s = ∅ := top_disjoint #align set.univ_disjoint Set.univ_disjoint @[simp] lemma disjoint_univ : Disjoint s univ ↔ s = ∅ := disjoint_top #align set.disjoint_univ Set.disjoint_univ lemma disjoint_sdiff_left : Disjoint (t \ s) s := disjoint_sdiff_self_left #align set.disjoint_sdiff_left Set.disjoint_sdiff_left lemma disjoint_sdiff_right : Disjoint s (t \ s) := disjoint_sdiff_self_right #align set.disjoint_sdiff_right Set.disjoint_sdiff_right -- TODO: prove this in terms of a lattice lemma theorem disjoint_sdiff_inter : Disjoint (s \ t) (s ∩ t) := disjoint_of_subset_right inter_subset_right disjoint_sdiff_left #align set.disjoint_sdiff_inter Set.disjoint_sdiff_inter theorem diff_union_diff_cancel (hts : t ⊆ s) (hut : u ⊆ t) : s \ t ∪ t \ u = s \ u := sdiff_sup_sdiff_cancel hts hut #align set.diff_union_diff_cancel Set.diff_union_diff_cancel theorem diff_diff_eq_sdiff_union (h : u ⊆ s) : s \ (t \ u) = s \ t ∪ u := sdiff_sdiff_eq_sdiff_sup h #align set.diff_diff_eq_sdiff_union Set.diff_diff_eq_sdiff_union @[simp default+1] lemma disjoint_singleton_left : Disjoint {a} s ↔ a ∉ s := by simp [Set.disjoint_iff, subset_def] #align set.disjoint_singleton_left Set.disjoint_singleton_left @[simp] lemma disjoint_singleton_right : Disjoint s {a} ↔ a ∉ s := disjoint_comm.trans disjoint_singleton_left #align set.disjoint_singleton_right Set.disjoint_singleton_right lemma disjoint_singleton : Disjoint ({a} : Set α) {b} ↔ a ≠ b := by simp #align set.disjoint_singleton Set.disjoint_singleton lemma subset_diff : s ⊆ t \ u ↔ s ⊆ t ∧ Disjoint s u := le_iff_subset.symm.trans le_sdiff #align set.subset_diff Set.subset_diff lemma ssubset_iff_sdiff_singleton : s ⊂ t ↔ ∃ a ∈ t, s ⊆ t \ {a} := by simp [ssubset_iff_insert, subset_diff, insert_subset_iff]; aesop theorem inter_diff_distrib_left (s t u : Set α) : s ∩ (t \ u) = (s ∩ t) \ (s ∩ u) := inf_sdiff_distrib_left _ _ _ #align set.inter_diff_distrib_left Set.inter_diff_distrib_left theorem inter_diff_distrib_right (s t u : Set α) : s \ t ∩ u = (s ∩ u) \ (t ∩ u) := inf_sdiff_distrib_right _ _ _ #align set.inter_diff_distrib_right Set.inter_diff_distrib_right theorem compl_def (s : Set α) : sᶜ = { x | x ∉ s } := rfl #align set.compl_def Set.compl_def theorem mem_compl {s : Set α} {x : α} (h : x ∉ s) : x ∈ sᶜ := h #align set.mem_compl Set.mem_compl theorem compl_setOf {α} (p : α → Prop) : { a | p a }ᶜ = { a | ¬p a } := rfl #align set.compl_set_of Set.compl_setOf theorem not_mem_of_mem_compl {s : Set α} {x : α} (h : x ∈ sᶜ) : x ∉ s := h #align set.not_mem_of_mem_compl Set.not_mem_of_mem_compl theorem not_mem_compl_iff {x : α} : x ∉ sᶜ ↔ x ∈ s := not_not #align set.not_mem_compl_iff Set.not_mem_compl_iff @[simp] theorem inter_compl_self (s : Set α) : s ∩ sᶜ = ∅ := inf_compl_eq_bot #align set.inter_compl_self Set.inter_compl_self @[simp] theorem compl_inter_self (s : Set α) : sᶜ ∩ s = ∅ := compl_inf_eq_bot #align set.compl_inter_self Set.compl_inter_self @[simp] theorem compl_empty : (∅ : Set α)ᶜ = univ := compl_bot #align set.compl_empty Set.compl_empty @[simp] theorem compl_union (s t : Set α) : (s ∪ t)ᶜ = sᶜ ∩ tᶜ := compl_sup #align set.compl_union Set.compl_union theorem compl_inter (s t : Set α) : (s ∩ t)ᶜ = sᶜ ∪ tᶜ := compl_inf #align set.compl_inter Set.compl_inter @[simp] theorem compl_univ : (univ : Set α)ᶜ = ∅ := compl_top #align set.compl_univ Set.compl_univ @[simp] theorem compl_empty_iff {s : Set α} : sᶜ = ∅ ↔ s = univ := compl_eq_bot #align set.compl_empty_iff Set.compl_empty_iff @[simp] theorem compl_univ_iff {s : Set α} : sᶜ = univ ↔ s = ∅ := compl_eq_top #align set.compl_univ_iff Set.compl_univ_iff theorem compl_ne_univ : sᶜ ≠ univ ↔ s.Nonempty := compl_univ_iff.not.trans nonempty_iff_ne_empty.symm #align set.compl_ne_univ Set.compl_ne_univ theorem nonempty_compl : sᶜ.Nonempty ↔ s ≠ univ := (ne_univ_iff_exists_not_mem s).symm #align set.nonempty_compl Set.nonempty_compl @[simp] lemma nonempty_compl_of_nontrivial [Nontrivial α] (x : α) : Set.Nonempty {x}ᶜ := by obtain ⟨y, hy⟩ := exists_ne x exact ⟨y, by simp [hy]⟩ theorem mem_compl_singleton_iff {a x : α} : x ∈ ({a} : Set α)ᶜ ↔ x ≠ a := Iff.rfl #align set.mem_compl_singleton_iff Set.mem_compl_singleton_iff theorem compl_singleton_eq (a : α) : ({a} : Set α)ᶜ = { x | x ≠ a } := rfl #align set.compl_singleton_eq Set.compl_singleton_eq @[simp] theorem compl_ne_eq_singleton (a : α) : ({ x | x ≠ a } : Set α)ᶜ = {a} := compl_compl _ #align set.compl_ne_eq_singleton Set.compl_ne_eq_singleton theorem union_eq_compl_compl_inter_compl (s t : Set α) : s ∪ t = (sᶜ ∩ tᶜ)ᶜ := ext fun _ => or_iff_not_and_not #align set.union_eq_compl_compl_inter_compl Set.union_eq_compl_compl_inter_compl theorem inter_eq_compl_compl_union_compl (s t : Set α) : s ∩ t = (sᶜ ∪ tᶜ)ᶜ := ext fun _ => and_iff_not_or_not #align set.inter_eq_compl_compl_union_compl Set.inter_eq_compl_compl_union_compl @[simp] theorem union_compl_self (s : Set α) : s ∪ sᶜ = univ := eq_univ_iff_forall.2 fun _ => em _ #align set.union_compl_self Set.union_compl_self @[simp] theorem compl_union_self (s : Set α) : sᶜ ∪ s = univ := by rw [union_comm, union_compl_self] #align set.compl_union_self Set.compl_union_self theorem compl_subset_comm : sᶜ ⊆ t ↔ tᶜ ⊆ s := @compl_le_iff_compl_le _ s _ _ #align set.compl_subset_comm Set.compl_subset_comm theorem subset_compl_comm : s ⊆ tᶜ ↔ t ⊆ sᶜ := @le_compl_iff_le_compl _ _ _ t #align set.subset_compl_comm Set.subset_compl_comm @[simp] theorem compl_subset_compl : sᶜ ⊆ tᶜ ↔ t ⊆ s := @compl_le_compl_iff_le (Set α) _ _ _ #align set.compl_subset_compl Set.compl_subset_compl @[gcongr] theorem compl_subset_compl_of_subset (h : t ⊆ s) : sᶜ ⊆ tᶜ := compl_subset_compl.2 h theorem subset_compl_iff_disjoint_left : s ⊆ tᶜ ↔ Disjoint t s := @le_compl_iff_disjoint_left (Set α) _ _ _ #align set.subset_compl_iff_disjoint_left Set.subset_compl_iff_disjoint_left theorem subset_compl_iff_disjoint_right : s ⊆ tᶜ ↔ Disjoint s t := @le_compl_iff_disjoint_right (Set α) _ _ _ #align set.subset_compl_iff_disjoint_right Set.subset_compl_iff_disjoint_right theorem disjoint_compl_left_iff_subset : Disjoint sᶜ t ↔ t ⊆ s := disjoint_compl_left_iff #align set.disjoint_compl_left_iff_subset Set.disjoint_compl_left_iff_subset theorem disjoint_compl_right_iff_subset : Disjoint s tᶜ ↔ s ⊆ t := disjoint_compl_right_iff #align set.disjoint_compl_right_iff_subset Set.disjoint_compl_right_iff_subset alias ⟨_, _root_.Disjoint.subset_compl_right⟩ := subset_compl_iff_disjoint_right #align disjoint.subset_compl_right Disjoint.subset_compl_right alias ⟨_, _root_.Disjoint.subset_compl_left⟩ := subset_compl_iff_disjoint_left #align disjoint.subset_compl_left Disjoint.subset_compl_left alias ⟨_, _root_.HasSubset.Subset.disjoint_compl_left⟩ := disjoint_compl_left_iff_subset #align has_subset.subset.disjoint_compl_left HasSubset.Subset.disjoint_compl_left alias ⟨_, _root_.HasSubset.Subset.disjoint_compl_right⟩ := disjoint_compl_right_iff_subset #align has_subset.subset.disjoint_compl_right HasSubset.Subset.disjoint_compl_right theorem subset_union_compl_iff_inter_subset {s t u : Set α} : s ⊆ t ∪ uᶜ ↔ s ∩ u ⊆ t := (@isCompl_compl _ u _).le_sup_right_iff_inf_left_le #align set.subset_union_compl_iff_inter_subset Set.subset_union_compl_iff_inter_subset theorem compl_subset_iff_union {s t : Set α} : sᶜ ⊆ t ↔ s ∪ t = univ := Iff.symm <| eq_univ_iff_forall.trans <| forall_congr' fun _ => or_iff_not_imp_left #align set.compl_subset_iff_union Set.compl_subset_iff_union @[simp] theorem subset_compl_singleton_iff {a : α} {s : Set α} : s ⊆ {a}ᶜ ↔ a ∉ s := subset_compl_comm.trans singleton_subset_iff #align set.subset_compl_singleton_iff Set.subset_compl_singleton_iff theorem inter_subset (a b c : Set α) : a ∩ b ⊆ c ↔ a ⊆ bᶜ ∪ c := forall_congr' fun _ => and_imp.trans <| imp_congr_right fun _ => imp_iff_not_or #align set.inter_subset Set.inter_subset theorem inter_compl_nonempty_iff {s t : Set α} : (s ∩ tᶜ).Nonempty ↔ ¬s ⊆ t := (not_subset.trans <| exists_congr fun x => by simp [mem_compl]).symm #align set.inter_compl_nonempty_iff Set.inter_compl_nonempty_iff theorem not_mem_diff_of_mem {s t : Set α} {x : α} (hx : x ∈ t) : x ∉ s \ t := fun h => h.2 hx #align set.not_mem_diff_of_mem Set.not_mem_diff_of_mem theorem mem_of_mem_diff {s t : Set α} {x : α} (h : x ∈ s \ t) : x ∈ s := h.left #align set.mem_of_mem_diff Set.mem_of_mem_diff theorem not_mem_of_mem_diff {s t : Set α} {x : α} (h : x ∈ s \ t) : x ∉ t := h.right #align set.not_mem_of_mem_diff Set.not_mem_of_mem_diff theorem diff_eq_compl_inter {s t : Set α} : s \ t = tᶜ ∩ s := by rw [diff_eq, inter_comm] #align set.diff_eq_compl_inter Set.diff_eq_compl_inter theorem nonempty_diff {s t : Set α} : (s \ t).Nonempty ↔ ¬s ⊆ t := inter_compl_nonempty_iff #align set.nonempty_diff Set.nonempty_diff theorem diff_subset {s t : Set α} : s \ t ⊆ s := show s \ t ≤ s from sdiff_le #align set.diff_subset Set.diff_subset theorem diff_subset_compl (s t : Set α) : s \ t ⊆ tᶜ := diff_eq_compl_inter ▸ inter_subset_left theorem union_diff_cancel' {s t u : Set α} (h₁ : s ⊆ t) (h₂ : t ⊆ u) : t ∪ u \ s = u := sup_sdiff_cancel' h₁ h₂ #align set.union_diff_cancel' Set.union_diff_cancel' theorem union_diff_cancel {s t : Set α} (h : s ⊆ t) : s ∪ t \ s = t := sup_sdiff_cancel_right h #align set.union_diff_cancel Set.union_diff_cancel theorem union_diff_cancel_left {s t : Set α} (h : s ∩ t ⊆ ∅) : (s ∪ t) \ s = t := Disjoint.sup_sdiff_cancel_left <| disjoint_iff_inf_le.2 h #align set.union_diff_cancel_left Set.union_diff_cancel_left theorem union_diff_cancel_right {s t : Set α} (h : s ∩ t ⊆ ∅) : (s ∪ t) \ t = s := Disjoint.sup_sdiff_cancel_right <| disjoint_iff_inf_le.2 h #align set.union_diff_cancel_right Set.union_diff_cancel_right @[simp] theorem union_diff_left {s t : Set α} : (s ∪ t) \ s = t \ s := sup_sdiff_left_self #align set.union_diff_left Set.union_diff_left @[simp] theorem union_diff_right {s t : Set α} : (s ∪ t) \ t = s \ t := sup_sdiff_right_self #align set.union_diff_right Set.union_diff_right theorem union_diff_distrib {s t u : Set α} : (s ∪ t) \ u = s \ u ∪ t \ u := sup_sdiff #align set.union_diff_distrib Set.union_diff_distrib theorem inter_diff_assoc (a b c : Set α) : (a ∩ b) \ c = a ∩ (b \ c) := inf_sdiff_assoc #align set.inter_diff_assoc Set.inter_diff_assoc @[simp] theorem inter_diff_self (a b : Set α) : a ∩ (b \ a) = ∅ := inf_sdiff_self_right #align set.inter_diff_self Set.inter_diff_self @[simp] theorem inter_union_diff (s t : Set α) : s ∩ t ∪ s \ t = s := sup_inf_sdiff s t #align set.inter_union_diff Set.inter_union_diff @[simp] theorem diff_union_inter (s t : Set α) : s \ t ∪ s ∩ t = s := by rw [union_comm] exact sup_inf_sdiff _ _ #align set.diff_union_inter Set.diff_union_inter @[simp] theorem inter_union_compl (s t : Set α) : s ∩ t ∪ s ∩ tᶜ = s := inter_union_diff _ _ #align set.inter_union_compl Set.inter_union_compl @[gcongr] theorem diff_subset_diff {s₁ s₂ t₁ t₂ : Set α} : s₁ ⊆ s₂ → t₂ ⊆ t₁ → s₁ \ t₁ ⊆ s₂ \ t₂ := show s₁ ≤ s₂ → t₂ ≤ t₁ → s₁ \ t₁ ≤ s₂ \ t₂ from sdiff_le_sdiff #align set.diff_subset_diff Set.diff_subset_diff @[gcongr] theorem diff_subset_diff_left {s₁ s₂ t : Set α} (h : s₁ ⊆ s₂) : s₁ \ t ⊆ s₂ \ t := sdiff_le_sdiff_right ‹s₁ ≤ s₂› #align set.diff_subset_diff_left Set.diff_subset_diff_left @[gcongr] theorem diff_subset_diff_right {s t u : Set α} (h : t ⊆ u) : s \ u ⊆ s \ t := sdiff_le_sdiff_left ‹t ≤ u› #align set.diff_subset_diff_right Set.diff_subset_diff_right theorem compl_eq_univ_diff (s : Set α) : sᶜ = univ \ s := top_sdiff.symm #align set.compl_eq_univ_diff Set.compl_eq_univ_diff @[simp] theorem empty_diff (s : Set α) : (∅ \ s : Set α) = ∅ := bot_sdiff #align set.empty_diff Set.empty_diff theorem diff_eq_empty {s t : Set α} : s \ t = ∅ ↔ s ⊆ t := sdiff_eq_bot_iff #align set.diff_eq_empty Set.diff_eq_empty @[simp] theorem diff_empty {s : Set α} : s \ ∅ = s := sdiff_bot #align set.diff_empty Set.diff_empty @[simp] theorem diff_univ (s : Set α) : s \ univ = ∅ := diff_eq_empty.2 (subset_univ s) #align set.diff_univ Set.diff_univ theorem diff_diff {u : Set α} : (s \ t) \ u = s \ (t ∪ u) := sdiff_sdiff_left #align set.diff_diff Set.diff_diff -- the following statement contains parentheses to help the reader theorem diff_diff_comm {s t u : Set α} : (s \ t) \ u = (s \ u) \ t := sdiff_sdiff_comm #align set.diff_diff_comm Set.diff_diff_comm theorem diff_subset_iff {s t u : Set α} : s \ t ⊆ u ↔ s ⊆ t ∪ u := show s \ t ≤ u ↔ s ≤ t ∪ u from sdiff_le_iff #align set.diff_subset_iff Set.diff_subset_iff theorem subset_diff_union (s t : Set α) : s ⊆ s \ t ∪ t := show s ≤ s \ t ∪ t from le_sdiff_sup #align set.subset_diff_union Set.subset_diff_union theorem diff_union_of_subset {s t : Set α} (h : t ⊆ s) : s \ t ∪ t = s := Subset.antisymm (union_subset diff_subset h) (subset_diff_union _ _) #align set.diff_union_of_subset Set.diff_union_of_subset @[simp] theorem diff_singleton_subset_iff {x : α} {s t : Set α} : s \ {x} ⊆ t ↔ s ⊆ insert x t := by rw [← union_singleton, union_comm] apply diff_subset_iff #align set.diff_singleton_subset_iff Set.diff_singleton_subset_iff theorem subset_diff_singleton {x : α} {s t : Set α} (h : s ⊆ t) (hx : x ∉ s) : s ⊆ t \ {x} := subset_inter h <| subset_compl_comm.1 <| singleton_subset_iff.2 hx #align set.subset_diff_singleton Set.subset_diff_singleton theorem subset_insert_diff_singleton (x : α) (s : Set α) : s ⊆ insert x (s \ {x}) := by rw [← diff_singleton_subset_iff] #align set.subset_insert_diff_singleton Set.subset_insert_diff_singleton theorem diff_subset_comm {s t u : Set α} : s \ t ⊆ u ↔ s \ u ⊆ t := show s \ t ≤ u ↔ s \ u ≤ t from sdiff_le_comm #align set.diff_subset_comm Set.diff_subset_comm theorem diff_inter {s t u : Set α} : s \ (t ∩ u) = s \ t ∪ s \ u := sdiff_inf #align set.diff_inter Set.diff_inter theorem diff_inter_diff {s t u : Set α} : s \ t ∩ (s \ u) = s \ (t ∪ u) := sdiff_sup.symm #align set.diff_inter_diff Set.diff_inter_diff theorem diff_compl : s \ tᶜ = s ∩ t := sdiff_compl #align set.diff_compl Set.diff_compl theorem diff_diff_right {s t u : Set α} : s \ (t \ u) = s \ t ∪ s ∩ u := sdiff_sdiff_right' #align set.diff_diff_right Set.diff_diff_right @[simp] theorem insert_diff_of_mem (s) (h : a ∈ t) : insert a s \ t = s \ t := by ext constructor <;> simp (config := { contextual := true }) [or_imp, h] #align set.insert_diff_of_mem Set.insert_diff_of_mem theorem insert_diff_of_not_mem (s) (h : a ∉ t) : insert a s \ t = insert a (s \ t) := by classical ext x by_cases h' : x ∈ t · have : x ≠ a := by intro H rw [H] at h' exact h h' simp [h, h', this] · simp [h, h'] #align set.insert_diff_of_not_mem Set.insert_diff_of_not_mem theorem insert_diff_self_of_not_mem {a : α} {s : Set α} (h : a ∉ s) : insert a s \ {a} = s := by ext x simp [and_iff_left_of_imp fun hx : x ∈ s => show x ≠ a from fun hxa => h <| hxa ▸ hx] #align set.insert_diff_self_of_not_mem Set.insert_diff_self_of_not_mem @[simp] theorem insert_diff_eq_singleton {a : α} {s : Set α} (h : a ∉ s) : insert a s \ s = {a} := by ext rw [Set.mem_diff, Set.mem_insert_iff, Set.mem_singleton_iff, or_and_right, and_not_self_iff, or_false_iff, and_iff_left_iff_imp] rintro rfl exact h #align set.insert_diff_eq_singleton Set.insert_diff_eq_singleton theorem inter_insert_of_mem (h : a ∈ s) : s ∩ insert a t = insert a (s ∩ t) := by rw [insert_inter_distrib, insert_eq_of_mem h] #align set.inter_insert_of_mem Set.inter_insert_of_mem theorem insert_inter_of_mem (h : a ∈ t) : insert a s ∩ t = insert a (s ∩ t) := by rw [insert_inter_distrib, insert_eq_of_mem h] #align set.insert_inter_of_mem Set.insert_inter_of_mem theorem inter_insert_of_not_mem (h : a ∉ s) : s ∩ insert a t = s ∩ t := ext fun _ => and_congr_right fun hx => or_iff_right <| ne_of_mem_of_not_mem hx h #align set.inter_insert_of_not_mem Set.inter_insert_of_not_mem theorem insert_inter_of_not_mem (h : a ∉ t) : insert a s ∩ t = s ∩ t := ext fun _ => and_congr_left fun hx => or_iff_right <| ne_of_mem_of_not_mem hx h #align set.insert_inter_of_not_mem Set.insert_inter_of_not_mem @[simp] theorem union_diff_self {s t : Set α} : s ∪ t \ s = s ∪ t := sup_sdiff_self _ _ #align set.union_diff_self Set.union_diff_self @[simp] theorem diff_union_self {s t : Set α} : s \ t ∪ t = s ∪ t := sdiff_sup_self _ _ #align set.diff_union_self Set.diff_union_self @[simp] theorem diff_inter_self {a b : Set α} : b \ a ∩ a = ∅ := inf_sdiff_self_left #align set.diff_inter_self Set.diff_inter_self @[simp] theorem diff_inter_self_eq_diff {s t : Set α} : s \ (t ∩ s) = s \ t := sdiff_inf_self_right _ _ #align set.diff_inter_self_eq_diff Set.diff_inter_self_eq_diff @[simp] theorem diff_self_inter {s t : Set α} : s \ (s ∩ t) = s \ t := sdiff_inf_self_left _ _ #align set.diff_self_inter Set.diff_self_inter @[simp] theorem diff_singleton_eq_self {a : α} {s : Set α} (h : a ∉ s) : s \ {a} = s := sdiff_eq_self_iff_disjoint.2 <| by simp [h] #align set.diff_singleton_eq_self Set.diff_singleton_eq_self @[simp] theorem diff_singleton_sSubset {s : Set α} {a : α} : s \ {a} ⊂ s ↔ a ∈ s := sdiff_le.lt_iff_ne.trans <| sdiff_eq_left.not.trans <| by simp #align set.diff_singleton_ssubset Set.diff_singleton_sSubset @[simp] theorem insert_diff_singleton {a : α} {s : Set α} : insert a (s \ {a}) = insert a s := by simp [insert_eq, union_diff_self, -union_singleton, -singleton_union] #align set.insert_diff_singleton Set.insert_diff_singleton theorem insert_diff_singleton_comm (hab : a ≠ b) (s : Set α) : insert a (s \ {b}) = insert a s \ {b} := by simp_rw [← union_singleton, union_diff_distrib, diff_singleton_eq_self (mem_singleton_iff.not.2 hab.symm)] #align set.insert_diff_singleton_comm Set.insert_diff_singleton_comm --Porting note (#10618): removed `simp` attribute because `simp` can prove it theorem diff_self {s : Set α} : s \ s = ∅ := sdiff_self #align set.diff_self Set.diff_self theorem diff_diff_right_self (s t : Set α) : s \ (s \ t) = s ∩ t := sdiff_sdiff_right_self #align set.diff_diff_right_self Set.diff_diff_right_self theorem diff_diff_cancel_left {s t : Set α} (h : s ⊆ t) : t \ (t \ s) = s := sdiff_sdiff_eq_self h #align set.diff_diff_cancel_left Set.diff_diff_cancel_left theorem mem_diff_singleton {x y : α} {s : Set α} : x ∈ s \ {y} ↔ x ∈ s ∧ x ≠ y := Iff.rfl #align set.mem_diff_singleton Set.mem_diff_singleton theorem mem_diff_singleton_empty {t : Set (Set α)} : s ∈ t \ {∅} ↔ s ∈ t ∧ s.Nonempty := mem_diff_singleton.trans <| and_congr_right' nonempty_iff_ne_empty.symm #align set.mem_diff_singleton_empty Set.mem_diff_singleton_empty theorem subset_insert_iff {s t : Set α} {x : α} : s ⊆ insert x t ↔ s ⊆ t ∨ (x ∈ s ∧ s \ {x} ⊆ t) := by rw [← diff_singleton_subset_iff] by_cases hx : x ∈ s · rw [and_iff_right hx, or_iff_right_of_imp diff_subset.trans] rw [diff_singleton_eq_self hx, or_iff_left_of_imp And.right] theorem union_eq_diff_union_diff_union_inter (s t : Set α) : s ∪ t = s \ t ∪ t \ s ∪ s ∩ t := sup_eq_sdiff_sup_sdiff_sup_inf #align set.union_eq_diff_union_diff_union_inter Set.union_eq_diff_union_diff_union_inter --Porting note (#10618): removed `simp` attribute because `simp` can prove it theorem pair_eq_singleton (a : α) : ({a, a} : Set α) = {a} := union_self _ #align set.pair_eq_singleton Set.pair_eq_singleton theorem pair_comm (a b : α) : ({a, b} : Set α) = {b, a} := union_comm _ _ #align set.pair_comm Set.pair_comm theorem pair_eq_pair_iff {x y z w : α} : ({x, y} : Set α) = {z, w} ↔ x = z ∧ y = w ∨ x = w ∧ y = z := by simp [subset_antisymm_iff, insert_subset_iff]; aesop #align set.pair_eq_pair_iff Set.pair_eq_pair_iff theorem pair_diff_left (hne : a ≠ b) : ({a, b} : Set α) \ {a} = {b} := by rw [insert_diff_of_mem _ (mem_singleton a), diff_singleton_eq_self (by simpa)] theorem pair_diff_right (hne : a ≠ b) : ({a, b} : Set α) \ {b} = {a} := by rw [pair_comm, pair_diff_left hne.symm] theorem pair_subset_iff : {a, b} ⊆ s ↔ a ∈ s ∧ b ∈ s := by rw [insert_subset_iff, singleton_subset_iff] theorem pair_subset (ha : a ∈ s) (hb : b ∈ s) : {a, b} ⊆ s := pair_subset_iff.2 ⟨ha,hb⟩ theorem subset_pair_iff : s ⊆ {a, b} ↔ ∀ x ∈ s, x = a ∨ x = b := by simp [subset_def] theorem subset_pair_iff_eq {x y : α} : s ⊆ {x, y} ↔ s = ∅ ∨ s = {x} ∨ s = {y} ∨ s = {x, y} := by refine ⟨?_, by rintro (rfl | rfl | rfl | rfl) <;> simp [pair_subset_iff]⟩ rw [subset_insert_iff, subset_singleton_iff_eq, subset_singleton_iff_eq, ← subset_empty_iff (s := s \ {x}), diff_subset_iff, union_empty, subset_singleton_iff_eq] have h : x ∈ s → {y} = s \ {x} → s = {x,y} := fun h₁ h₂ ↦ by simp [h₁, h₂] tauto theorem Nonempty.subset_pair_iff_eq (hs : s.Nonempty) : s ⊆ {a, b} ↔ s = {a} ∨ s = {b} ∨ s = {a, b} := by rw [Set.subset_pair_iff_eq, or_iff_right]; exact hs.ne_empty section open scoped symmDiff theorem mem_symmDiff : a ∈ s ∆ t ↔ a ∈ s ∧ a ∉ t ∨ a ∈ t ∧ a ∉ s := Iff.rfl #align set.mem_symm_diff Set.mem_symmDiff protected theorem symmDiff_def (s t : Set α) : s ∆ t = s \ t ∪ t \ s := rfl #align set.symm_diff_def Set.symmDiff_def theorem symmDiff_subset_union : s ∆ t ⊆ s ∪ t := @symmDiff_le_sup (Set α) _ _ _ #align set.symm_diff_subset_union Set.symmDiff_subset_union @[simp] theorem symmDiff_eq_empty : s ∆ t = ∅ ↔ s = t := symmDiff_eq_bot #align set.symm_diff_eq_empty Set.symmDiff_eq_empty @[simp] theorem symmDiff_nonempty : (s ∆ t).Nonempty ↔ s ≠ t := nonempty_iff_ne_empty.trans symmDiff_eq_empty.not #align set.symm_diff_nonempty Set.symmDiff_nonempty theorem inter_symmDiff_distrib_left (s t u : Set α) : s ∩ t ∆ u = (s ∩ t) ∆ (s ∩ u) := inf_symmDiff_distrib_left _ _ _ #align set.inter_symm_diff_distrib_left Set.inter_symmDiff_distrib_left theorem inter_symmDiff_distrib_right (s t u : Set α) : s ∆ t ∩ u = (s ∩ u) ∆ (t ∩ u) := inf_symmDiff_distrib_right _ _ _ #align set.inter_symm_diff_distrib_right Set.inter_symmDiff_distrib_right theorem subset_symmDiff_union_symmDiff_left (h : Disjoint s t) : u ⊆ s ∆ u ∪ t ∆ u := h.le_symmDiff_sup_symmDiff_left #align set.subset_symm_diff_union_symm_diff_left Set.subset_symmDiff_union_symmDiff_left theorem subset_symmDiff_union_symmDiff_right (h : Disjoint t u) : s ⊆ s ∆ t ∪ s ∆ u := h.le_symmDiff_sup_symmDiff_right #align set.subset_symm_diff_union_symm_diff_right Set.subset_symmDiff_union_symmDiff_right end #align set.powerset Set.powerset theorem mem_powerset {x s : Set α} (h : x ⊆ s) : x ∈ 𝒫 s := @h #align set.mem_powerset Set.mem_powerset theorem subset_of_mem_powerset {x s : Set α} (h : x ∈ 𝒫 s) : x ⊆ s := @h #align set.subset_of_mem_powerset Set.subset_of_mem_powerset @[simp] theorem mem_powerset_iff (x s : Set α) : x ∈ 𝒫 s ↔ x ⊆ s := Iff.rfl #align set.mem_powerset_iff Set.mem_powerset_iff theorem powerset_inter (s t : Set α) : 𝒫(s ∩ t) = 𝒫 s ∩ 𝒫 t := ext fun _ => subset_inter_iff #align set.powerset_inter Set.powerset_inter @[simp] theorem powerset_mono : 𝒫 s ⊆ 𝒫 t ↔ s ⊆ t := ⟨fun h => @h _ (fun _ h => h), fun h _ hu _ ha => h (hu ha)⟩ #align set.powerset_mono Set.powerset_mono theorem monotone_powerset : Monotone (powerset : Set α → Set (Set α)) := fun _ _ => powerset_mono.2 #align set.monotone_powerset Set.monotone_powerset @[simp] theorem powerset_nonempty : (𝒫 s).Nonempty := ⟨∅, fun _ h => empty_subset s h⟩ #align set.powerset_nonempty Set.powerset_nonempty @[simp] theorem powerset_empty : 𝒫(∅ : Set α) = {∅} := ext fun _ => subset_empty_iff #align set.powerset_empty Set.powerset_empty @[simp] theorem powerset_univ : 𝒫(univ : Set α) = univ := eq_univ_of_forall subset_univ #align set.powerset_univ Set.powerset_univ theorem powerset_singleton (x : α) : 𝒫({x} : Set α) = {∅, {x}} := by ext y rw [mem_powerset_iff, subset_singleton_iff_eq, mem_insert_iff, mem_singleton_iff] #align set.powerset_singleton Set.powerset_singleton theorem mem_dite (p : Prop) [Decidable p] (s : p → Set α) (t : ¬ p → Set α) (x : α) : (x ∈ if h : p then s h else t h) ↔ (∀ h : p, x ∈ s h) ∧ ∀ h : ¬p, x ∈ t h := by split_ifs with hp · exact ⟨fun hx => ⟨fun _ => hx, fun hnp => (hnp hp).elim⟩, fun hx => hx.1 hp⟩ · exact ⟨fun hx => ⟨fun h => (hp h).elim, fun _ => hx⟩, fun hx => hx.2 hp⟩ theorem mem_dite_univ_right (p : Prop) [Decidable p] (t : p → Set α) (x : α) : (x ∈ if h : p then t h else univ) ↔ ∀ h : p, x ∈ t h := by split_ifs <;> simp_all #align set.mem_dite_univ_right Set.mem_dite_univ_right @[simp] theorem mem_ite_univ_right (p : Prop) [Decidable p] (t : Set α) (x : α) : x ∈ ite p t Set.univ ↔ p → x ∈ t := mem_dite_univ_right p (fun _ => t) x #align set.mem_ite_univ_right Set.mem_ite_univ_right theorem mem_dite_univ_left (p : Prop) [Decidable p] (t : ¬p → Set α) (x : α) : (x ∈ if h : p then univ else t h) ↔ ∀ h : ¬p, x ∈ t h := by split_ifs <;> simp_all #align set.mem_dite_univ_left Set.mem_dite_univ_left @[simp] theorem mem_ite_univ_left (p : Prop) [Decidable p] (t : Set α) (x : α) : x ∈ ite p Set.univ t ↔ ¬p → x ∈ t := mem_dite_univ_left p (fun _ => t) x #align set.mem_ite_univ_left Set.mem_ite_univ_left theorem mem_dite_empty_right (p : Prop) [Decidable p] (t : p → Set α) (x : α) : (x ∈ if h : p then t h else ∅) ↔ ∃ h : p, x ∈ t h := by simp only [mem_dite, mem_empty_iff_false, imp_false, not_not] exact ⟨fun h => ⟨h.2, h.1 h.2⟩, fun ⟨h₁, h₂⟩ => ⟨fun _ => h₂, h₁⟩⟩ #align set.mem_dite_empty_right Set.mem_dite_empty_right @[simp] theorem mem_ite_empty_right (p : Prop) [Decidable p] (t : Set α) (x : α) : x ∈ ite p t ∅ ↔ p ∧ x ∈ t := (mem_dite_empty_right p (fun _ => t) x).trans (by simp) #align set.mem_ite_empty_right Set.mem_ite_empty_right theorem mem_dite_empty_left (p : Prop) [Decidable p] (t : ¬p → Set α) (x : α) : (x ∈ if h : p then ∅ else t h) ↔ ∃ h : ¬p, x ∈ t h := by simp only [mem_dite, mem_empty_iff_false, imp_false] exact ⟨fun h => ⟨h.1, h.2 h.1⟩, fun ⟨h₁, h₂⟩ => ⟨fun h => h₁ h, fun _ => h₂⟩⟩ #align set.mem_dite_empty_left Set.mem_dite_empty_left @[simp] theorem mem_ite_empty_left (p : Prop) [Decidable p] (t : Set α) (x : α) : x ∈ ite p ∅ t ↔ ¬p ∧ x ∈ t := (mem_dite_empty_left p (fun _ => t) x).trans (by simp) #align set.mem_ite_empty_left Set.mem_ite_empty_left protected def ite (t s s' : Set α) : Set α := s ∩ t ∪ s' \ t #align set.ite Set.ite @[simp] theorem ite_inter_self (t s s' : Set α) : t.ite s s' ∩ t = s ∩ t := by rw [Set.ite, union_inter_distrib_right, diff_inter_self, inter_assoc, inter_self, union_empty] #align set.ite_inter_self Set.ite_inter_self @[simp] theorem ite_compl (t s s' : Set α) : tᶜ.ite s s' = t.ite s' s := by rw [Set.ite, Set.ite, diff_compl, union_comm, diff_eq] #align set.ite_compl Set.ite_compl @[simp] theorem ite_inter_compl_self (t s s' : Set α) : t.ite s s' ∩ tᶜ = s' ∩ tᶜ := by rw [← ite_compl, ite_inter_self] #align set.ite_inter_compl_self Set.ite_inter_compl_self @[simp] theorem ite_diff_self (t s s' : Set α) : t.ite s s' \ t = s' \ t := ite_inter_compl_self t s s' #align set.ite_diff_self Set.ite_diff_self @[simp] theorem ite_same (t s : Set α) : t.ite s s = s := inter_union_diff _ _ #align set.ite_same Set.ite_same @[simp] theorem ite_left (s t : Set α) : s.ite s t = s ∪ t := by simp [Set.ite] #align set.ite_left Set.ite_left @[simp] theorem ite_right (s t : Set α) : s.ite t s = t ∩ s := by simp [Set.ite] #align set.ite_right Set.ite_right @[simp] theorem ite_empty (s s' : Set α) : Set.ite ∅ s s' = s' := by simp [Set.ite] #align set.ite_empty Set.ite_empty @[simp] theorem ite_univ (s s' : Set α) : Set.ite univ s s' = s := by simp [Set.ite] #align set.ite_univ Set.ite_univ @[simp] theorem ite_empty_left (t s : Set α) : t.ite ∅ s = s \ t := by simp [Set.ite] #align set.ite_empty_left Set.ite_empty_left @[simp] theorem ite_empty_right (t s : Set α) : t.ite s ∅ = s ∩ t := by simp [Set.ite] #align set.ite_empty_right Set.ite_empty_right theorem ite_mono (t : Set α) {s₁ s₁' s₂ s₂' : Set α} (h : s₁ ⊆ s₂) (h' : s₁' ⊆ s₂') : t.ite s₁ s₁' ⊆ t.ite s₂ s₂' := union_subset_union (inter_subset_inter_left _ h) (inter_subset_inter_left _ h') #align set.ite_mono Set.ite_mono theorem ite_subset_union (t s s' : Set α) : t.ite s s' ⊆ s ∪ s' := union_subset_union inter_subset_left diff_subset #align set.ite_subset_union Set.ite_subset_union theorem inter_subset_ite (t s s' : Set α) : s ∩ s' ⊆ t.ite s s' := ite_same t (s ∩ s') ▸ ite_mono _ inter_subset_left inter_subset_right #align set.inter_subset_ite Set.inter_subset_ite theorem ite_inter_inter (t s₁ s₂ s₁' s₂' : Set α) : t.ite (s₁ ∩ s₂) (s₁' ∩ s₂') = t.ite s₁ s₁' ∩ t.ite s₂ s₂' := by ext x simp only [Set.ite, Set.mem_inter_iff, Set.mem_diff, Set.mem_union] tauto #align set.ite_inter_inter Set.ite_inter_inter
Mathlib/Data/Set/Basic.lean
2,334
2,335
theorem ite_inter (t s₁ s₂ s : Set α) : t.ite (s₁ ∩ s) (s₂ ∩ s) = t.ite s₁ s₂ ∩ s := by
rw [ite_inter_inter, ite_same]
import Mathlib.Geometry.Manifold.Diffeomorph import Mathlib.Geometry.Manifold.Instances.Real import Mathlib.Geometry.Manifold.PartitionOfUnity #align_import geometry.manifold.whitney_embedding from "leanprover-community/mathlib"@"86c29aefdba50b3f33e86e52e3b2f51a0d8f0282" universe uι uE uH uM variable {ι : Type uι} {E : Type uE} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] {H : Type uH} [TopologicalSpace H] {I : ModelWithCorners ℝ E H} {M : Type uM} [TopologicalSpace M] [ChartedSpace H M] [SmoothManifoldWithCorners I M] open Function Filter FiniteDimensional Set open scoped Topology Manifold Classical Filter noncomputable section namespace SmoothBumpCovering variable [T2Space M] [hi : Fintype ι] {s : Set M} (f : SmoothBumpCovering ι I M s) def embeddingPiTangent : C^∞⟮I, M; 𝓘(ℝ, ι → E × ℝ), ι → E × ℝ⟯ where val x i := (f i x • extChartAt I (f.c i) x, f i x) property := contMDiff_pi_space.2 fun i => ((f i).smooth_smul contMDiffOn_extChartAt).prod_mk_space (f i).smooth #align smooth_bump_covering.embedding_pi_tangent SmoothBumpCovering.embeddingPiTangent @[local simp] theorem embeddingPiTangent_coe : ⇑f.embeddingPiTangent = fun x i => (f i x • extChartAt I (f.c i) x, f i x) := rfl #align smooth_bump_covering.embedding_pi_tangent_coe SmoothBumpCovering.embeddingPiTangent_coe
Mathlib/Geometry/Manifold/WhitneyEmbedding.lean
68
75
theorem embeddingPiTangent_injOn : InjOn f.embeddingPiTangent s := by
intro x hx y _ h simp only [embeddingPiTangent_coe, funext_iff] at h obtain ⟨h₁, h₂⟩ := Prod.mk.inj_iff.1 (h (f.ind x hx)) rw [f.apply_ind x hx] at h₂ rw [← h₂, f.apply_ind x hx, one_smul, one_smul] at h₁ have := f.mem_extChartAt_source_of_eq_one h₂.symm exact (extChartAt I (f.c _)).injOn (f.mem_extChartAt_ind_source x hx) this h₁
import Mathlib.Data.Fin.Fin2 import Mathlib.Logic.Function.Basic import Mathlib.Tactic.Common #align_import data.typevec from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" universe u v w @[pp_with_univ] def TypeVec (n : ℕ) := Fin2 n → Type* #align typevec TypeVec instance {n} : Inhabited (TypeVec.{u} n) := ⟨fun _ => PUnit⟩ namespace TypeVec variable {n : ℕ} def Arrow (α β : TypeVec n) := ∀ i : Fin2 n, α i → β i #align typevec.arrow TypeVec.Arrow @[inherit_doc] scoped[MvFunctor] infixl:40 " ⟹ " => TypeVec.Arrow open MvFunctor @[ext] theorem Arrow.ext {α β : TypeVec n} (f g : α ⟹ β) : (∀ i, f i = g i) → f = g := by intro h; funext i; apply h instance Arrow.inhabited (α β : TypeVec n) [∀ i, Inhabited (β i)] : Inhabited (α ⟹ β) := ⟨fun _ _ => default⟩ #align typevec.arrow.inhabited TypeVec.Arrow.inhabited def id {α : TypeVec n} : α ⟹ α := fun _ x => x #align typevec.id TypeVec.id def comp {α β γ : TypeVec n} (g : β ⟹ γ) (f : α ⟹ β) : α ⟹ γ := fun i x => g i (f i x) #align typevec.comp TypeVec.comp @[inherit_doc] scoped[MvFunctor] infixr:80 " ⊚ " => TypeVec.comp -- type as \oo @[simp] theorem id_comp {α β : TypeVec n} (f : α ⟹ β) : id ⊚ f = f := rfl #align typevec.id_comp TypeVec.id_comp @[simp] theorem comp_id {α β : TypeVec n} (f : α ⟹ β) : f ⊚ id = f := rfl #align typevec.comp_id TypeVec.comp_id theorem comp_assoc {α β γ δ : TypeVec n} (h : γ ⟹ δ) (g : β ⟹ γ) (f : α ⟹ β) : (h ⊚ g) ⊚ f = h ⊚ g ⊚ f := rfl #align typevec.comp_assoc TypeVec.comp_assoc def append1 (α : TypeVec n) (β : Type*) : TypeVec (n + 1) | Fin2.fs i => α i | Fin2.fz => β #align typevec.append1 TypeVec.append1 @[inherit_doc] infixl:67 " ::: " => append1 def drop (α : TypeVec.{u} (n + 1)) : TypeVec n := fun i => α i.fs #align typevec.drop TypeVec.drop def last (α : TypeVec.{u} (n + 1)) : Type _ := α Fin2.fz #align typevec.last TypeVec.last instance last.inhabited (α : TypeVec (n + 1)) [Inhabited (α Fin2.fz)] : Inhabited (last α) := ⟨show α Fin2.fz from default⟩ #align typevec.last.inhabited TypeVec.last.inhabited theorem drop_append1 {α : TypeVec n} {β : Type*} {i : Fin2 n} : drop (append1 α β) i = α i := rfl #align typevec.drop_append1 TypeVec.drop_append1 theorem drop_append1' {α : TypeVec n} {β : Type*} : drop (append1 α β) = α := funext fun _ => drop_append1 #align typevec.drop_append1' TypeVec.drop_append1' theorem last_append1 {α : TypeVec n} {β : Type*} : last (append1 α β) = β := rfl #align typevec.last_append1 TypeVec.last_append1 @[simp] theorem append1_drop_last (α : TypeVec (n + 1)) : append1 (drop α) (last α) = α := funext fun i => by cases i <;> rfl #align typevec.append1_drop_last TypeVec.append1_drop_last @[elab_as_elim] def append1Cases {C : TypeVec (n + 1) → Sort u} (H : ∀ α β, C (append1 α β)) (γ) : C γ := by rw [← @append1_drop_last _ γ]; apply H #align typevec.append1_cases TypeVec.append1Cases @[simp] theorem append1_cases_append1 {C : TypeVec (n + 1) → Sort u} (H : ∀ α β, C (append1 α β)) (α β) : @append1Cases _ C H (append1 α β) = H α β := rfl #align typevec.append1_cases_append1 TypeVec.append1_cases_append1 def splitFun {α α' : TypeVec (n + 1)} (f : drop α ⟹ drop α') (g : last α → last α') : α ⟹ α' | Fin2.fs i => f i | Fin2.fz => g #align typevec.split_fun TypeVec.splitFun def appendFun {α α' : TypeVec n} {β β' : Type*} (f : α ⟹ α') (g : β → β') : append1 α β ⟹ append1 α' β' := splitFun f g #align typevec.append_fun TypeVec.appendFun @[inherit_doc] infixl:0 " ::: " => appendFun def dropFun {α β : TypeVec (n + 1)} (f : α ⟹ β) : drop α ⟹ drop β := fun i => f i.fs #align typevec.drop_fun TypeVec.dropFun def lastFun {α β : TypeVec (n + 1)} (f : α ⟹ β) : last α → last β := f Fin2.fz #align typevec.last_fun TypeVec.lastFun -- Porting note: Lean wasn't able to infer the motive in term mode def nilFun {α : TypeVec 0} {β : TypeVec 0} : α ⟹ β := fun i => by apply Fin2.elim0 i #align typevec.nil_fun TypeVec.nilFun theorem eq_of_drop_last_eq {α β : TypeVec (n + 1)} {f g : α ⟹ β} (h₀ : dropFun f = dropFun g) (h₁ : lastFun f = lastFun g) : f = g := by -- Porting note: FIXME: congr_fun h₀ <;> ext1 ⟨⟩ <;> apply_assumption refine funext (fun x => ?_) cases x · apply h₁ · apply congr_fun h₀ #align typevec.eq_of_drop_last_eq TypeVec.eq_of_drop_last_eq @[simp] theorem dropFun_splitFun {α α' : TypeVec (n + 1)} (f : drop α ⟹ drop α') (g : last α → last α') : dropFun (splitFun f g) = f := rfl #align typevec.drop_fun_split_fun TypeVec.dropFun_splitFun def Arrow.mp {α β : TypeVec n} (h : α = β) : α ⟹ β | _ => Eq.mp (congr_fun h _) #align typevec.arrow.mp TypeVec.Arrow.mp def Arrow.mpr {α β : TypeVec n} (h : α = β) : β ⟹ α | _ => Eq.mpr (congr_fun h _) #align typevec.arrow.mpr TypeVec.Arrow.mpr def toAppend1DropLast {α : TypeVec (n + 1)} : α ⟹ (drop α ::: last α) := Arrow.mpr (append1_drop_last _) #align typevec.to_append1_drop_last TypeVec.toAppend1DropLast def fromAppend1DropLast {α : TypeVec (n + 1)} : (drop α ::: last α) ⟹ α := Arrow.mp (append1_drop_last _) #align typevec.from_append1_drop_last TypeVec.fromAppend1DropLast @[simp] theorem lastFun_splitFun {α α' : TypeVec (n + 1)} (f : drop α ⟹ drop α') (g : last α → last α') : lastFun (splitFun f g) = g := rfl #align typevec.last_fun_split_fun TypeVec.lastFun_splitFun @[simp] theorem dropFun_appendFun {α α' : TypeVec n} {β β' : Type*} (f : α ⟹ α') (g : β → β') : dropFun (f ::: g) = f := rfl #align typevec.drop_fun_append_fun TypeVec.dropFun_appendFun @[simp] theorem lastFun_appendFun {α α' : TypeVec n} {β β' : Type*} (f : α ⟹ α') (g : β → β') : lastFun (f ::: g) = g := rfl #align typevec.last_fun_append_fun TypeVec.lastFun_appendFun theorem split_dropFun_lastFun {α α' : TypeVec (n + 1)} (f : α ⟹ α') : splitFun (dropFun f) (lastFun f) = f := eq_of_drop_last_eq rfl rfl #align typevec.split_drop_fun_last_fun TypeVec.split_dropFun_lastFun theorem splitFun_inj {α α' : TypeVec (n + 1)} {f f' : drop α ⟹ drop α'} {g g' : last α → last α'} (H : splitFun f g = splitFun f' g') : f = f' ∧ g = g' := by rw [← dropFun_splitFun f g, H, ← lastFun_splitFun f g, H]; simp #align typevec.split_fun_inj TypeVec.splitFun_inj theorem appendFun_inj {α α' : TypeVec n} {β β' : Type*} {f f' : α ⟹ α'} {g g' : β → β'} : (f ::: g : (α ::: β) ⟹ _) = (f' ::: g' : (α ::: β) ⟹ _) → f = f' ∧ g = g' := splitFun_inj #align typevec.append_fun_inj TypeVec.appendFun_inj theorem splitFun_comp {α₀ α₁ α₂ : TypeVec (n + 1)} (f₀ : drop α₀ ⟹ drop α₁) (f₁ : drop α₁ ⟹ drop α₂) (g₀ : last α₀ → last α₁) (g₁ : last α₁ → last α₂) : splitFun (f₁ ⊚ f₀) (g₁ ∘ g₀) = splitFun f₁ g₁ ⊚ splitFun f₀ g₀ := eq_of_drop_last_eq rfl rfl #align typevec.split_fun_comp TypeVec.splitFun_comp theorem appendFun_comp_splitFun {α γ : TypeVec n} {β δ : Type*} {ε : TypeVec (n + 1)} (f₀ : drop ε ⟹ α) (f₁ : α ⟹ γ) (g₀ : last ε → β) (g₁ : β → δ) : appendFun f₁ g₁ ⊚ splitFun f₀ g₀ = splitFun (α' := γ.append1 δ) (f₁ ⊚ f₀) (g₁ ∘ g₀) := (splitFun_comp _ _ _ _).symm #align typevec.append_fun_comp_split_fun TypeVec.appendFun_comp_splitFun theorem appendFun_comp {α₀ α₁ α₂ : TypeVec n} {β₀ β₁ β₂ : Type*} (f₀ : α₀ ⟹ α₁) (f₁ : α₁ ⟹ α₂) (g₀ : β₀ → β₁) (g₁ : β₁ → β₂) : (f₁ ⊚ f₀ ::: g₁ ∘ g₀) = (f₁ ::: g₁) ⊚ (f₀ ::: g₀) := eq_of_drop_last_eq rfl rfl #align typevec.append_fun_comp TypeVec.appendFun_comp theorem appendFun_comp' {α₀ α₁ α₂ : TypeVec n} {β₀ β₁ β₂ : Type*} (f₀ : α₀ ⟹ α₁) (f₁ : α₁ ⟹ α₂) (g₀ : β₀ → β₁) (g₁ : β₁ → β₂) : (f₁ ::: g₁) ⊚ (f₀ ::: g₀) = (f₁ ⊚ f₀ ::: g₁ ∘ g₀) := eq_of_drop_last_eq rfl rfl #align typevec.append_fun_comp' TypeVec.appendFun_comp' theorem nilFun_comp {α₀ : TypeVec 0} (f₀ : α₀ ⟹ Fin2.elim0) : nilFun ⊚ f₀ = f₀ := funext fun x => by apply Fin2.elim0 x -- Porting note: `by apply` is necessary? #align typevec.nil_fun_comp TypeVec.nilFun_comp theorem appendFun_comp_id {α : TypeVec n} {β₀ β₁ β₂ : Type u} (g₀ : β₀ → β₁) (g₁ : β₁ → β₂) : (@id _ α ::: g₁ ∘ g₀) = (id ::: g₁) ⊚ (id ::: g₀) := eq_of_drop_last_eq rfl rfl #align typevec.append_fun_comp_id TypeVec.appendFun_comp_id @[simp] theorem dropFun_comp {α₀ α₁ α₂ : TypeVec (n + 1)} (f₀ : α₀ ⟹ α₁) (f₁ : α₁ ⟹ α₂) : dropFun (f₁ ⊚ f₀) = dropFun f₁ ⊚ dropFun f₀ := rfl #align typevec.drop_fun_comp TypeVec.dropFun_comp @[simp] theorem lastFun_comp {α₀ α₁ α₂ : TypeVec (n + 1)} (f₀ : α₀ ⟹ α₁) (f₁ : α₁ ⟹ α₂) : lastFun (f₁ ⊚ f₀) = lastFun f₁ ∘ lastFun f₀ := rfl #align typevec.last_fun_comp TypeVec.lastFun_comp theorem appendFun_aux {α α' : TypeVec n} {β β' : Type*} (f : (α ::: β) ⟹ (α' ::: β')) : (dropFun f ::: lastFun f) = f := eq_of_drop_last_eq rfl rfl #align typevec.append_fun_aux TypeVec.appendFun_aux theorem appendFun_id_id {α : TypeVec n} {β : Type*} : (@TypeVec.id n α ::: @_root_.id β) = TypeVec.id := eq_of_drop_last_eq rfl rfl #align typevec.append_fun_id_id TypeVec.appendFun_id_id instance subsingleton0 : Subsingleton (TypeVec 0) := ⟨fun a b => funext fun a => by apply Fin2.elim0 a⟩ -- Porting note: `by apply` necessary? #align typevec.subsingleton0 TypeVec.subsingleton0 -- Porting note: `simp` attribute `TypeVec` moved to file `Tactic/Attr/Register.lean` protected def casesNil {β : TypeVec 0 → Sort*} (f : β Fin2.elim0) : ∀ v, β v := fun v => cast (by congr; funext i; cases i) f #align typevec.cases_nil TypeVec.casesNil protected def casesCons (n : ℕ) {β : TypeVec (n + 1) → Sort*} (f : ∀ (t) (v : TypeVec n), β (v ::: t)) : ∀ v, β v := fun v : TypeVec (n + 1) => cast (by simp) (f v.last v.drop) #align typevec.cases_cons TypeVec.casesCons protected theorem casesNil_append1 {β : TypeVec 0 → Sort*} (f : β Fin2.elim0) : TypeVec.casesNil f Fin2.elim0 = f := rfl #align typevec.cases_nil_append1 TypeVec.casesNil_append1 protected theorem casesCons_append1 (n : ℕ) {β : TypeVec (n + 1) → Sort*} (f : ∀ (t) (v : TypeVec n), β (v ::: t)) (v : TypeVec n) (α) : TypeVec.casesCons n f (v ::: α) = f α v := rfl #align typevec.cases_cons_append1 TypeVec.casesCons_append1 def typevecCasesNil₃ {β : ∀ v v' : TypeVec 0, v ⟹ v' → Sort*} (f : β Fin2.elim0 Fin2.elim0 nilFun) : ∀ v v' fs, β v v' fs := fun v v' fs => by refine cast ?_ f have eq₁ : v = Fin2.elim0 := by funext i; contradiction have eq₂ : v' = Fin2.elim0 := by funext i; contradiction have eq₃ : fs = nilFun := by funext i; contradiction cases eq₁; cases eq₂; cases eq₃; rfl #align typevec.typevec_cases_nil₃ TypeVec.typevecCasesNil₃ def typevecCasesCons₃ (n : ℕ) {β : ∀ v v' : TypeVec (n + 1), v ⟹ v' → Sort*} (F : ∀ (t t') (f : t → t') (v v' : TypeVec n) (fs : v ⟹ v'), β (v ::: t) (v' ::: t') (fs ::: f)) : ∀ v v' fs, β v v' fs := by intro v v' rw [← append1_drop_last v, ← append1_drop_last v'] intro fs rw [← split_dropFun_lastFun fs] apply F #align typevec.typevec_cases_cons₃ TypeVec.typevecCasesCons₃ def typevecCasesNil₂ {β : Fin2.elim0 ⟹ Fin2.elim0 → Sort*} (f : β nilFun) : ∀ f, β f := by intro g suffices g = nilFun by rwa [this] ext ⟨⟩ #align typevec.typevec_cases_nil₂ TypeVec.typevecCasesNil₂ def typevecCasesCons₂ (n : ℕ) (t t' : Type*) (v v' : TypeVec n) {β : (v ::: t) ⟹ (v' ::: t') → Sort*} (F : ∀ (f : t → t') (fs : v ⟹ v'), β (fs ::: f)) : ∀ fs, β fs := by intro fs rw [← split_dropFun_lastFun fs] apply F #align typevec.typevec_cases_cons₂ TypeVec.typevecCasesCons₂ theorem typevecCasesNil₂_appendFun {β : Fin2.elim0 ⟹ Fin2.elim0 → Sort*} (f : β nilFun) : typevecCasesNil₂ f nilFun = f := rfl #align typevec.typevec_cases_nil₂_append_fun TypeVec.typevecCasesNil₂_appendFun theorem typevecCasesCons₂_appendFun (n : ℕ) (t t' : Type*) (v v' : TypeVec n) {β : (v ::: t) ⟹ (v' ::: t') → Sort*} (F : ∀ (f : t → t') (fs : v ⟹ v'), β (fs ::: f)) (f fs) : typevecCasesCons₂ n t t' v v' F (fs ::: f) = F f fs := rfl #align typevec.typevec_cases_cons₂_append_fun TypeVec.typevecCasesCons₂_appendFun -- for lifting predicates and relations def PredLast (α : TypeVec n) {β : Type*} (p : β → Prop) : ∀ ⦃i⦄, (α.append1 β) i → Prop | Fin2.fs _ => fun _ => True | Fin2.fz => p #align typevec.pred_last TypeVec.PredLast def RelLast (α : TypeVec n) {β γ : Type u} (r : β → γ → Prop) : ∀ ⦃i⦄, (α.append1 β) i → (α.append1 γ) i → Prop | Fin2.fs _ => Eq | Fin2.fz => r #align typevec.rel_last TypeVec.RelLast section Liftp' open Nat def «repeat» : ∀ (n : ℕ), Sort _ → TypeVec n | 0, _ => Fin2.elim0 | Nat.succ i, t => append1 («repeat» i t) t #align typevec.repeat TypeVec.repeat def prod : ∀ {n}, TypeVec.{u} n → TypeVec.{u} n → TypeVec n | 0, _, _ => Fin2.elim0 | n + 1, α, β => (@prod n (drop α) (drop β)) ::: (last α × last β) #align typevec.prod TypeVec.prod @[inherit_doc] scoped[MvFunctor] infixl:45 " ⊗ " => TypeVec.prod protected def const {β} (x : β) : ∀ {n} (α : TypeVec n), α ⟹ «repeat» _ β | succ _, α, Fin2.fs _ => TypeVec.const x (drop α) _ | succ _, _, Fin2.fz => fun _ => x #align typevec.const TypeVec.const open Function (uncurry) def repeatEq : ∀ {n} (α : TypeVec n), (α ⊗ α) ⟹ «repeat» _ Prop | 0, _ => nilFun | succ _, α => repeatEq (drop α) ::: uncurry Eq #align typevec.repeat_eq TypeVec.repeatEq theorem const_append1 {β γ} (x : γ) {n} (α : TypeVec n) : TypeVec.const x (α ::: β) = appendFun (TypeVec.const x α) fun _ => x := by ext i : 1; cases i <;> rfl #align typevec.const_append1 TypeVec.const_append1 theorem eq_nilFun {α β : TypeVec 0} (f : α ⟹ β) : f = nilFun := by ext x; cases x #align typevec.eq_nil_fun TypeVec.eq_nilFun theorem id_eq_nilFun {α : TypeVec 0} : @id _ α = nilFun := by ext x; cases x #align typevec.id_eq_nil_fun TypeVec.id_eq_nilFun theorem const_nil {β} (x : β) (α : TypeVec 0) : TypeVec.const x α = nilFun := by ext i : 1; cases i #align typevec.const_nil TypeVec.const_nil @[typevec] theorem repeat_eq_append1 {β} {n} (α : TypeVec n) : repeatEq (α ::: β) = splitFun (α := (α ⊗ α) ::: _ ) (α' := («repeat» n Prop) ::: _) (repeatEq α) (uncurry Eq) := by induction n <;> rfl #align typevec.repeat_eq_append1 TypeVec.repeat_eq_append1 @[typevec] theorem repeat_eq_nil (α : TypeVec 0) : repeatEq α = nilFun := by ext i; cases i #align typevec.repeat_eq_nil TypeVec.repeat_eq_nil def PredLast' (α : TypeVec n) {β : Type*} (p : β → Prop) : (α ::: β) ⟹ «repeat» (n + 1) Prop := splitFun (TypeVec.const True α) p #align typevec.pred_last' TypeVec.PredLast' def RelLast' (α : TypeVec n) {β : Type*} (p : β → β → Prop) : (α ::: β) ⊗ (α ::: β) ⟹ «repeat» (n + 1) Prop := splitFun (repeatEq α) (uncurry p) #align typevec.rel_last' TypeVec.RelLast' def Curry (F : TypeVec.{u} (n + 1) → Type*) (α : Type u) (β : TypeVec.{u} n) : Type _ := F (β ::: α) #align typevec.curry TypeVec.Curry instance Curry.inhabited (F : TypeVec.{u} (n + 1) → Type*) (α : Type u) (β : TypeVec.{u} n) [I : Inhabited (F <| (β ::: α))] : Inhabited (Curry F α β) := I #align typevec.curry.inhabited TypeVec.Curry.inhabited def dropRepeat (α : Type*) : ∀ {n}, drop («repeat» (succ n) α) ⟹ «repeat» n α | succ _, Fin2.fs i => dropRepeat α i | succ _, Fin2.fz => fun (a : α) => a #align typevec.drop_repeat TypeVec.dropRepeat def ofRepeat {α : Sort _} : ∀ {n i}, «repeat» n α i → α | _, Fin2.fz => fun (a : α) => a | _, Fin2.fs i => @ofRepeat _ _ i #align typevec.of_repeat TypeVec.ofRepeat theorem const_iff_true {α : TypeVec n} {i x p} : ofRepeat (TypeVec.const p α i x) ↔ p := by induction i with | fz => rfl | fs _ ih => erw [TypeVec.const, @ih (drop α) x] #align typevec.const_iff_true TypeVec.const_iff_true section variable {α β γ : TypeVec.{u} n} variable (p : α ⟹ «repeat» n Prop) (r : α ⊗ α ⟹ «repeat» n Prop) def prod.fst : ∀ {n} {α β : TypeVec.{u} n}, α ⊗ β ⟹ α | succ _, α, β, Fin2.fs i => @prod.fst _ (drop α) (drop β) i | succ _, _, _, Fin2.fz => Prod.fst #align typevec.prod.fst TypeVec.prod.fst def prod.snd : ∀ {n} {α β : TypeVec.{u} n}, α ⊗ β ⟹ β | succ _, α, β, Fin2.fs i => @prod.snd _ (drop α) (drop β) i | succ _, _, _, Fin2.fz => Prod.snd #align typevec.prod.snd TypeVec.prod.snd def prod.diag : ∀ {n} {α : TypeVec.{u} n}, α ⟹ α ⊗ α | succ _, α, Fin2.fs _, x => @prod.diag _ (drop α) _ x | succ _, _, Fin2.fz, x => (x, x) #align typevec.prod.diag TypeVec.prod.diag def prod.mk : ∀ {n} {α β : TypeVec.{u} n} (i : Fin2 n), α i → β i → (α ⊗ β) i | succ _, α, β, Fin2.fs i => mk (α := fun i => α i.fs) (β := fun i => β i.fs) i | succ _, _, _, Fin2.fz => Prod.mk #align typevec.prod.mk TypeVec.prod.mk end @[simp]
Mathlib/Data/TypeVec.lean
530
534
theorem prod_fst_mk {α β : TypeVec n} (i : Fin2 n) (a : α i) (b : β i) : TypeVec.prod.fst i (prod.mk i a b) = a := by
induction' i with _ _ _ i_ih · simp_all only [prod.fst, prod.mk] apply i_ih
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse #align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" open Filter Metric Set open scoped ComplexConjugate Real Topology namespace Complex variable {a x z : ℂ} noncomputable def arg (x : ℂ) : ℝ := if 0 ≤ x.re then Real.arcsin (x.im / abs x) else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π #align complex.arg Complex.arg theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by unfold arg; split_ifs <;> simp [sub_eq_add_neg, arg, Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2, Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg] #align complex.sin_arg Complex.sin_arg theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by rw [arg] split_ifs with h₁ h₂ · rw [Real.cos_arcsin] field_simp [Real.sqrt_sq, (abs.pos hx).le, *] · rw [Real.cos_add_pi, Real.cos_arcsin] field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs, _root_.abs_of_neg (not_le.1 h₁), *] · rw [Real.cos_sub_pi, Real.cos_arcsin] field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs, _root_.abs_of_neg (not_le.1 h₁), *] #align complex.cos_arg Complex.cos_arg @[simp] theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by rcases eq_or_ne x 0 with (rfl | hx) · simp · have : abs x ≠ 0 := abs.ne_zero hx apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)] set_option linter.uppercaseLean3 false in #align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I @[simp] theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by rw [← exp_mul_I, abs_mul_exp_arg_mul_I] set_option linter.uppercaseLean3 false in #align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I @[simp] lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x) @[simp] lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x) theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by refine ⟨fun hz => ⟨arg z, ?_⟩, ?_⟩ · calc exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul] _ = z := abs_mul_exp_arg_mul_I z · rintro ⟨θ, rfl⟩ exact Complex.abs_exp_ofReal_mul_I θ #align complex.abs_eq_one_iff Complex.abs_eq_one_iff @[simp] theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by ext x simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range] set_option linter.uppercaseLean3 false in #align complex.range_exp_mul_I Complex.range_exp_mul_I theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (r * (cos θ + sin θ * I)) = θ := by simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one] simp only [re_ofReal_mul, im_ofReal_mul, neg_im, ← ofReal_cos, ← ofReal_sin, ← mk_eq_add_mul_I, neg_div, mul_div_cancel_left₀ _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr] by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2) · rw [if_pos] exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁] · rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁ cases' h₁ with h₁ h₁ · replace hθ := hθ.1 have hcos : Real.cos θ < 0 := by rw [← neg_pos, ← Real.cos_add_pi] refine Real.cos_pos_of_mem_Ioo ⟨?_, ?_⟩ <;> linarith have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel_right] <;> [linarith; linarith; exact hsin.not_le; exact hcos.not_le] · replace hθ := hθ.2 have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith) have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩ rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith; linarith; exact hsin; exact hcos.not_le] set_option linter.uppercaseLean3 false in #align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ] set_option linter.uppercaseLean3 false in #align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I lemma arg_exp_mul_I (θ : ℝ) : arg (exp (θ * I)) = toIocMod (mul_pos two_pos Real.pi_pos) (-π) θ := by convert arg_cos_add_sin_mul_I (θ := toIocMod (mul_pos two_pos Real.pi_pos) (-π) θ) _ using 2 · rw [← exp_mul_I, eq_sub_of_add_eq $ toIocMod_add_toIocDiv_zsmul _ _ θ, ofReal_sub, ofReal_zsmul, ofReal_mul, ofReal_ofNat, exp_mul_I_periodic.sub_zsmul_eq] · convert toIocMod_mem_Ioc _ _ _ ring @[simp] theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl] #align complex.arg_zero Complex.arg_zero theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂] #align complex.ext_abs_arg Complex.ext_abs_arg theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y := ⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩ #align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by have hπ : 0 < π := Real.pi_pos rcases eq_or_ne z 0 with (rfl | hz) · simp [hπ, hπ.le] rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩ rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N] have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN push_cast at this rwa [this] #align complex.arg_mem_Ioc Complex.arg_mem_Ioc @[simp] theorem range_arg : Set.range arg = Set.Ioc (-π) π := (Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩ #align complex.range_arg Complex.range_arg theorem arg_le_pi (x : ℂ) : arg x ≤ π := (arg_mem_Ioc x).2 #align complex.arg_le_pi Complex.arg_le_pi theorem neg_pi_lt_arg (x : ℂ) : -π < arg x := (arg_mem_Ioc x).1 #align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π := abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩ #align complex.abs_arg_le_pi Complex.abs_arg_le_pi @[simp] theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by rcases eq_or_ne z 0 with (rfl | h₀); · simp calc 0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) := ⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by contrapose! intro h exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩ _ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul] #align complex.arg_nonneg_iff Complex.arg_nonneg_iff @[simp] theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 := lt_iff_lt_of_le_iff_le arg_nonneg_iff #align complex.arg_neg_iff Complex.arg_neg_iff theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero] conv_lhs => rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul, arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc] #align complex.arg_real_mul Complex.arg_real_mul theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x := mul_comm x r ▸ arg_real_mul x hr theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) : arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs, div_mul_cancel₀ _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff] rw [← ofReal_div, arg_real_mul] exact div_pos (abs.pos hy) (abs.pos hx) #align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff @[simp] theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one] #align complex.arg_one Complex.arg_one @[simp] theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)] #align complex.arg_neg_one Complex.arg_neg_one @[simp] theorem arg_I : arg I = π / 2 := by simp [arg, le_refl] set_option linter.uppercaseLean3 false in #align complex.arg_I Complex.arg_I @[simp] theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl] set_option linter.uppercaseLean3 false in #align complex.arg_neg_I Complex.arg_neg_I @[simp] theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by by_cases h : x = 0 · simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re] rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)] #align complex.tan_arg Complex.tan_arg
Mathlib/Analysis/SpecialFunctions/Complex/Arg.lean
233
233
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by
simp [arg, hx]
import Mathlib.Algebra.Module.Zlattice.Basic import Mathlib.NumberTheory.NumberField.Embeddings import Mathlib.NumberTheory.NumberField.FractionalIdeal #align_import number_theory.number_field.canonical_embedding from "leanprover-community/mathlib"@"60da01b41bbe4206f05d34fd70c8dd7498717a30" variable (K : Type*) [Field K] namespace NumberField.mixedEmbedding open NumberField NumberField.InfinitePlace FiniteDimensional Finset local notation "E" K => ({w : InfinitePlace K // IsReal w} → ℝ) × ({w : InfinitePlace K // IsComplex w} → ℂ) noncomputable def _root_.NumberField.mixedEmbedding : K →+* (E K) := RingHom.prod (Pi.ringHom fun w => embedding_of_isReal w.prop) (Pi.ringHom fun w => w.val.embedding) instance [NumberField K] : Nontrivial (E K) := by obtain ⟨w⟩ := (inferInstance : Nonempty (InfinitePlace K)) obtain hw | hw := w.isReal_or_isComplex · have : Nonempty {w : InfinitePlace K // IsReal w} := ⟨⟨w, hw⟩⟩ exact nontrivial_prod_left · have : Nonempty {w : InfinitePlace K // IsComplex w} := ⟨⟨w, hw⟩⟩ exact nontrivial_prod_right protected theorem finrank [NumberField K] : finrank ℝ (E K) = finrank ℚ K := by classical rw [finrank_prod, finrank_pi, finrank_pi_fintype, Complex.finrank_real_complex, sum_const, card_univ, ← NrRealPlaces, ← NrComplexPlaces, ← card_real_embeddings, Algebra.id.smul_eq_mul, mul_comm, ← card_complex_embeddings, ← NumberField.Embeddings.card K ℂ, Fintype.card_subtype_compl, Nat.add_sub_of_le (Fintype.card_subtype_le _)] theorem _root_.NumberField.mixedEmbedding_injective [NumberField K] : Function.Injective (NumberField.mixedEmbedding K) := by exact RingHom.injective _ noncomputable section norm open scoped Classical variable {K} def normAtPlace (w : InfinitePlace K) : (E K) →*₀ ℝ where toFun x := if hw : IsReal w then ‖x.1 ⟨w, hw⟩‖ else ‖x.2 ⟨w, not_isReal_iff_isComplex.mp hw⟩‖ map_zero' := by simp map_one' := by simp map_mul' x y := by split_ifs <;> simp theorem normAtPlace_nonneg (w : InfinitePlace K) (x : E K) : 0 ≤ normAtPlace w x := by rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk] split_ifs <;> exact norm_nonneg _ theorem normAtPlace_neg (w : InfinitePlace K) (x : E K) : normAtPlace w (- x) = normAtPlace w x := by rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk] split_ifs <;> simp theorem normAtPlace_add_le (w : InfinitePlace K) (x y : E K) : normAtPlace w (x + y) ≤ normAtPlace w x + normAtPlace w y := by rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk] split_ifs <;> exact norm_add_le _ _ theorem normAtPlace_smul (w : InfinitePlace K) (x : E K) (c : ℝ) : normAtPlace w (c • x) = |c| * normAtPlace w x := by rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk] split_ifs · rw [Prod.smul_fst, Pi.smul_apply, norm_smul, Real.norm_eq_abs] · rw [Prod.smul_snd, Pi.smul_apply, norm_smul, Real.norm_eq_abs, Complex.norm_eq_abs] theorem normAtPlace_real (w : InfinitePlace K) (c : ℝ) : normAtPlace w ((fun _ ↦ c, fun _ ↦ c) : (E K)) = |c| := by rw [show ((fun _ ↦ c, fun _ ↦ c) : (E K)) = c • 1 by ext <;> simp, normAtPlace_smul, map_one, mul_one] theorem normAtPlace_apply_isReal {w : InfinitePlace K} (hw : IsReal w) (x : E K): normAtPlace w x = ‖x.1 ⟨w, hw⟩‖ := by rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, dif_pos] theorem normAtPlace_apply_isComplex {w : InfinitePlace K} (hw : IsComplex w) (x : E K) : normAtPlace w x = ‖x.2 ⟨w, hw⟩‖ := by rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, dif_neg (not_isReal_iff_isComplex.mpr hw)] @[simp]
Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean
296
300
theorem normAtPlace_apply (w : InfinitePlace K) (x : K) : normAtPlace w (mixedEmbedding K x) = w x := by
simp_rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, mixedEmbedding, RingHom.prod_apply, Pi.ringHom_apply, norm_embedding_of_isReal, norm_embedding_eq, dite_eq_ite, ite_id]
import Mathlib.Analysis.Calculus.FDeriv.Basic import Mathlib.Analysis.NormedSpace.OperatorNorm.NormedSpace #align_import analysis.calculus.deriv.basic from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" universe u v w noncomputable section open scoped Classical Topology Filter ENNReal NNReal open Filter Asymptotics Set open ContinuousLinearMap (smulRight smulRight_one_eq_iff) variable {𝕜 : Type u} [NontriviallyNormedField 𝕜] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E] def HasDerivAtFilter (f : 𝕜 → F) (f' : F) (x : 𝕜) (L : Filter 𝕜) := HasFDerivAtFilter f (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') x L #align has_deriv_at_filter HasDerivAtFilter def HasDerivWithinAt (f : 𝕜 → F) (f' : F) (s : Set 𝕜) (x : 𝕜) := HasDerivAtFilter f f' x (𝓝[s] x) #align has_deriv_within_at HasDerivWithinAt def HasDerivAt (f : 𝕜 → F) (f' : F) (x : 𝕜) := HasDerivAtFilter f f' x (𝓝 x) #align has_deriv_at HasDerivAt def HasStrictDerivAt (f : 𝕜 → F) (f' : F) (x : 𝕜) := HasStrictFDerivAt f (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') x #align has_strict_deriv_at HasStrictDerivAt def derivWithin (f : 𝕜 → F) (s : Set 𝕜) (x : 𝕜) := fderivWithin 𝕜 f s x 1 #align deriv_within derivWithin def deriv (f : 𝕜 → F) (x : 𝕜) := fderiv 𝕜 f x 1 #align deriv deriv variable {f f₀ f₁ g : 𝕜 → F} variable {f' f₀' f₁' g' : F} variable {x : 𝕜} variable {s t : Set 𝕜} variable {L L₁ L₂ : Filter 𝕜} theorem hasFDerivAtFilter_iff_hasDerivAtFilter {f' : 𝕜 →L[𝕜] F} : HasFDerivAtFilter f f' x L ↔ HasDerivAtFilter f (f' 1) x L := by simp [HasDerivAtFilter] #align has_fderiv_at_filter_iff_has_deriv_at_filter hasFDerivAtFilter_iff_hasDerivAtFilter theorem HasFDerivAtFilter.hasDerivAtFilter {f' : 𝕜 →L[𝕜] F} : HasFDerivAtFilter f f' x L → HasDerivAtFilter f (f' 1) x L := hasFDerivAtFilter_iff_hasDerivAtFilter.mp #align has_fderiv_at_filter.has_deriv_at_filter HasFDerivAtFilter.hasDerivAtFilter theorem hasFDerivWithinAt_iff_hasDerivWithinAt {f' : 𝕜 →L[𝕜] F} : HasFDerivWithinAt f f' s x ↔ HasDerivWithinAt f (f' 1) s x := hasFDerivAtFilter_iff_hasDerivAtFilter #align has_fderiv_within_at_iff_has_deriv_within_at hasFDerivWithinAt_iff_hasDerivWithinAt theorem hasDerivWithinAt_iff_hasFDerivWithinAt {f' : F} : HasDerivWithinAt f f' s x ↔ HasFDerivWithinAt f (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') s x := Iff.rfl #align has_deriv_within_at_iff_has_fderiv_within_at hasDerivWithinAt_iff_hasFDerivWithinAt theorem HasFDerivWithinAt.hasDerivWithinAt {f' : 𝕜 →L[𝕜] F} : HasFDerivWithinAt f f' s x → HasDerivWithinAt f (f' 1) s x := hasFDerivWithinAt_iff_hasDerivWithinAt.mp #align has_fderiv_within_at.has_deriv_within_at HasFDerivWithinAt.hasDerivWithinAt theorem HasDerivWithinAt.hasFDerivWithinAt {f' : F} : HasDerivWithinAt f f' s x → HasFDerivWithinAt f (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') s x := hasDerivWithinAt_iff_hasFDerivWithinAt.mp #align has_deriv_within_at.has_fderiv_within_at HasDerivWithinAt.hasFDerivWithinAt theorem hasFDerivAt_iff_hasDerivAt {f' : 𝕜 →L[𝕜] F} : HasFDerivAt f f' x ↔ HasDerivAt f (f' 1) x := hasFDerivAtFilter_iff_hasDerivAtFilter #align has_fderiv_at_iff_has_deriv_at hasFDerivAt_iff_hasDerivAt theorem HasFDerivAt.hasDerivAt {f' : 𝕜 →L[𝕜] F} : HasFDerivAt f f' x → HasDerivAt f (f' 1) x := hasFDerivAt_iff_hasDerivAt.mp #align has_fderiv_at.has_deriv_at HasFDerivAt.hasDerivAt theorem hasStrictFDerivAt_iff_hasStrictDerivAt {f' : 𝕜 →L[𝕜] F} : HasStrictFDerivAt f f' x ↔ HasStrictDerivAt f (f' 1) x := by simp [HasStrictDerivAt, HasStrictFDerivAt] #align has_strict_fderiv_at_iff_has_strict_deriv_at hasStrictFDerivAt_iff_hasStrictDerivAt protected theorem HasStrictFDerivAt.hasStrictDerivAt {f' : 𝕜 →L[𝕜] F} : HasStrictFDerivAt f f' x → HasStrictDerivAt f (f' 1) x := hasStrictFDerivAt_iff_hasStrictDerivAt.mp #align has_strict_fderiv_at.has_strict_deriv_at HasStrictFDerivAt.hasStrictDerivAt theorem hasStrictDerivAt_iff_hasStrictFDerivAt : HasStrictDerivAt f f' x ↔ HasStrictFDerivAt f (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') x := Iff.rfl #align has_strict_deriv_at_iff_has_strict_fderiv_at hasStrictDerivAt_iff_hasStrictFDerivAt alias ⟨HasStrictDerivAt.hasStrictFDerivAt, _⟩ := hasStrictDerivAt_iff_hasStrictFDerivAt #align has_strict_deriv_at.has_strict_fderiv_at HasStrictDerivAt.hasStrictFDerivAt theorem hasDerivAt_iff_hasFDerivAt {f' : F} : HasDerivAt f f' x ↔ HasFDerivAt f (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') x := Iff.rfl #align has_deriv_at_iff_has_fderiv_at hasDerivAt_iff_hasFDerivAt alias ⟨HasDerivAt.hasFDerivAt, _⟩ := hasDerivAt_iff_hasFDerivAt #align has_deriv_at.has_fderiv_at HasDerivAt.hasFDerivAt theorem derivWithin_zero_of_not_differentiableWithinAt (h : ¬DifferentiableWithinAt 𝕜 f s x) : derivWithin f s x = 0 := by unfold derivWithin rw [fderivWithin_zero_of_not_differentiableWithinAt h] simp #align deriv_within_zero_of_not_differentiable_within_at derivWithin_zero_of_not_differentiableWithinAt theorem derivWithin_zero_of_isolated (h : 𝓝[s \ {x}] x = ⊥) : derivWithin f s x = 0 := by rw [derivWithin, fderivWithin_zero_of_isolated h, ContinuousLinearMap.zero_apply] theorem derivWithin_zero_of_nmem_closure (h : x ∉ closure s) : derivWithin f s x = 0 := by rw [derivWithin, fderivWithin_zero_of_nmem_closure h, ContinuousLinearMap.zero_apply] theorem differentiableWithinAt_of_derivWithin_ne_zero (h : derivWithin f s x ≠ 0) : DifferentiableWithinAt 𝕜 f s x := not_imp_comm.1 derivWithin_zero_of_not_differentiableWithinAt h #align differentiable_within_at_of_deriv_within_ne_zero differentiableWithinAt_of_derivWithin_ne_zero theorem deriv_zero_of_not_differentiableAt (h : ¬DifferentiableAt 𝕜 f x) : deriv f x = 0 := by unfold deriv rw [fderiv_zero_of_not_differentiableAt h] simp #align deriv_zero_of_not_differentiable_at deriv_zero_of_not_differentiableAt theorem differentiableAt_of_deriv_ne_zero (h : deriv f x ≠ 0) : DifferentiableAt 𝕜 f x := not_imp_comm.1 deriv_zero_of_not_differentiableAt h #align differentiable_at_of_deriv_ne_zero differentiableAt_of_deriv_ne_zero theorem UniqueDiffWithinAt.eq_deriv (s : Set 𝕜) (H : UniqueDiffWithinAt 𝕜 s x) (h : HasDerivWithinAt f f' s x) (h₁ : HasDerivWithinAt f f₁' s x) : f' = f₁' := smulRight_one_eq_iff.mp <| UniqueDiffWithinAt.eq H h h₁ #align unique_diff_within_at.eq_deriv UniqueDiffWithinAt.eq_deriv theorem hasDerivAtFilter_iff_isLittleO : HasDerivAtFilter f f' x L ↔ (fun x' : 𝕜 => f x' - f x - (x' - x) • f') =o[L] fun x' => x' - x := hasFDerivAtFilter_iff_isLittleO .. #align has_deriv_at_filter_iff_is_o hasDerivAtFilter_iff_isLittleO theorem hasDerivAtFilter_iff_tendsto : HasDerivAtFilter f f' x L ↔ Tendsto (fun x' : 𝕜 => ‖x' - x‖⁻¹ * ‖f x' - f x - (x' - x) • f'‖) L (𝓝 0) := hasFDerivAtFilter_iff_tendsto #align has_deriv_at_filter_iff_tendsto hasDerivAtFilter_iff_tendsto theorem hasDerivWithinAt_iff_isLittleO : HasDerivWithinAt f f' s x ↔ (fun x' : 𝕜 => f x' - f x - (x' - x) • f') =o[𝓝[s] x] fun x' => x' - x := hasFDerivAtFilter_iff_isLittleO .. #align has_deriv_within_at_iff_is_o hasDerivWithinAt_iff_isLittleO theorem hasDerivWithinAt_iff_tendsto : HasDerivWithinAt f f' s x ↔ Tendsto (fun x' => ‖x' - x‖⁻¹ * ‖f x' - f x - (x' - x) • f'‖) (𝓝[s] x) (𝓝 0) := hasFDerivAtFilter_iff_tendsto #align has_deriv_within_at_iff_tendsto hasDerivWithinAt_iff_tendsto theorem hasDerivAt_iff_isLittleO : HasDerivAt f f' x ↔ (fun x' : 𝕜 => f x' - f x - (x' - x) • f') =o[𝓝 x] fun x' => x' - x := hasFDerivAtFilter_iff_isLittleO .. #align has_deriv_at_iff_is_o hasDerivAt_iff_isLittleO theorem hasDerivAt_iff_tendsto : HasDerivAt f f' x ↔ Tendsto (fun x' => ‖x' - x‖⁻¹ * ‖f x' - f x - (x' - x) • f'‖) (𝓝 x) (𝓝 0) := hasFDerivAtFilter_iff_tendsto #align has_deriv_at_iff_tendsto hasDerivAt_iff_tendsto theorem HasDerivAtFilter.isBigO_sub (h : HasDerivAtFilter f f' x L) : (fun x' => f x' - f x) =O[L] fun x' => x' - x := HasFDerivAtFilter.isBigO_sub h set_option linter.uppercaseLean3 false in #align has_deriv_at_filter.is_O_sub HasDerivAtFilter.isBigO_sub nonrec theorem HasDerivAtFilter.isBigO_sub_rev (hf : HasDerivAtFilter f f' x L) (hf' : f' ≠ 0) : (fun x' => x' - x) =O[L] fun x' => f x' - f x := suffices AntilipschitzWith ‖f'‖₊⁻¹ (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') from hf.isBigO_sub_rev this AddMonoidHomClass.antilipschitz_of_bound (smulRight (1 : 𝕜 →L[𝕜] 𝕜) f') fun x => by simp [norm_smul, ← div_eq_inv_mul, mul_div_cancel_right₀ _ (mt norm_eq_zero.1 hf')] set_option linter.uppercaseLean3 false in #align has_deriv_at_filter.is_O_sub_rev HasDerivAtFilter.isBigO_sub_rev theorem HasStrictDerivAt.hasDerivAt (h : HasStrictDerivAt f f' x) : HasDerivAt f f' x := h.hasFDerivAt #align has_strict_deriv_at.has_deriv_at HasStrictDerivAt.hasDerivAt theorem hasDerivWithinAt_congr_set' {s t : Set 𝕜} (y : 𝕜) (h : s =ᶠ[𝓝[{y}ᶜ] x] t) : HasDerivWithinAt f f' s x ↔ HasDerivWithinAt f f' t x := hasFDerivWithinAt_congr_set' y h #align has_deriv_within_at_congr_set' hasDerivWithinAt_congr_set' theorem hasDerivWithinAt_congr_set {s t : Set 𝕜} (h : s =ᶠ[𝓝 x] t) : HasDerivWithinAt f f' s x ↔ HasDerivWithinAt f f' t x := hasFDerivWithinAt_congr_set h #align has_deriv_within_at_congr_set hasDerivWithinAt_congr_set alias ⟨HasDerivWithinAt.congr_set, _⟩ := hasDerivWithinAt_congr_set #align has_deriv_within_at.congr_set HasDerivWithinAt.congr_set @[simp] theorem hasDerivWithinAt_diff_singleton : HasDerivWithinAt f f' (s \ {x}) x ↔ HasDerivWithinAt f f' s x := hasFDerivWithinAt_diff_singleton _ #align has_deriv_within_at_diff_singleton hasDerivWithinAt_diff_singleton @[simp] theorem hasDerivWithinAt_Ioi_iff_Ici [PartialOrder 𝕜] : HasDerivWithinAt f f' (Ioi x) x ↔ HasDerivWithinAt f f' (Ici x) x := by rw [← Ici_diff_left, hasDerivWithinAt_diff_singleton] #align has_deriv_within_at_Ioi_iff_Ici hasDerivWithinAt_Ioi_iff_Ici alias ⟨HasDerivWithinAt.Ici_of_Ioi, HasDerivWithinAt.Ioi_of_Ici⟩ := hasDerivWithinAt_Ioi_iff_Ici #align has_deriv_within_at.Ici_of_Ioi HasDerivWithinAt.Ici_of_Ioi #align has_deriv_within_at.Ioi_of_Ici HasDerivWithinAt.Ioi_of_Ici @[simp] theorem hasDerivWithinAt_Iio_iff_Iic [PartialOrder 𝕜] : HasDerivWithinAt f f' (Iio x) x ↔ HasDerivWithinAt f f' (Iic x) x := by rw [← Iic_diff_right, hasDerivWithinAt_diff_singleton] #align has_deriv_within_at_Iio_iff_Iic hasDerivWithinAt_Iio_iff_Iic alias ⟨HasDerivWithinAt.Iic_of_Iio, HasDerivWithinAt.Iio_of_Iic⟩ := hasDerivWithinAt_Iio_iff_Iic #align has_deriv_within_at.Iic_of_Iio HasDerivWithinAt.Iic_of_Iio #align has_deriv_within_at.Iio_of_Iic HasDerivWithinAt.Iio_of_Iic theorem HasDerivWithinAt.Ioi_iff_Ioo [LinearOrder 𝕜] [OrderClosedTopology 𝕜] {x y : 𝕜} (h : x < y) : HasDerivWithinAt f f' (Ioo x y) x ↔ HasDerivWithinAt f f' (Ioi x) x := hasFDerivWithinAt_inter <| Iio_mem_nhds h #align has_deriv_within_at.Ioi_iff_Ioo HasDerivWithinAt.Ioi_iff_Ioo alias ⟨HasDerivWithinAt.Ioi_of_Ioo, HasDerivWithinAt.Ioo_of_Ioi⟩ := HasDerivWithinAt.Ioi_iff_Ioo #align has_deriv_within_at.Ioi_of_Ioo HasDerivWithinAt.Ioi_of_Ioo #align has_deriv_within_at.Ioo_of_Ioi HasDerivWithinAt.Ioo_of_Ioi theorem hasDerivAt_iff_isLittleO_nhds_zero : HasDerivAt f f' x ↔ (fun h => f (x + h) - f x - h • f') =o[𝓝 0] fun h => h := hasFDerivAt_iff_isLittleO_nhds_zero #align has_deriv_at_iff_is_o_nhds_zero hasDerivAt_iff_isLittleO_nhds_zero theorem HasDerivAtFilter.mono (h : HasDerivAtFilter f f' x L₂) (hst : L₁ ≤ L₂) : HasDerivAtFilter f f' x L₁ := HasFDerivAtFilter.mono h hst #align has_deriv_at_filter.mono HasDerivAtFilter.mono theorem HasDerivWithinAt.mono (h : HasDerivWithinAt f f' t x) (hst : s ⊆ t) : HasDerivWithinAt f f' s x := HasFDerivWithinAt.mono h hst #align has_deriv_within_at.mono HasDerivWithinAt.mono theorem HasDerivWithinAt.mono_of_mem (h : HasDerivWithinAt f f' t x) (hst : t ∈ 𝓝[s] x) : HasDerivWithinAt f f' s x := HasFDerivWithinAt.mono_of_mem h hst #align has_deriv_within_at.mono_of_mem HasDerivWithinAt.mono_of_mem #align has_deriv_within_at.nhds_within HasDerivWithinAt.mono_of_mem theorem HasDerivAt.hasDerivAtFilter (h : HasDerivAt f f' x) (hL : L ≤ 𝓝 x) : HasDerivAtFilter f f' x L := HasFDerivAt.hasFDerivAtFilter h hL #align has_deriv_at.has_deriv_at_filter HasDerivAt.hasDerivAtFilter theorem HasDerivAt.hasDerivWithinAt (h : HasDerivAt f f' x) : HasDerivWithinAt f f' s x := HasFDerivAt.hasFDerivWithinAt h #align has_deriv_at.has_deriv_within_at HasDerivAt.hasDerivWithinAt theorem HasDerivWithinAt.differentiableWithinAt (h : HasDerivWithinAt f f' s x) : DifferentiableWithinAt 𝕜 f s x := HasFDerivWithinAt.differentiableWithinAt h #align has_deriv_within_at.differentiable_within_at HasDerivWithinAt.differentiableWithinAt theorem HasDerivAt.differentiableAt (h : HasDerivAt f f' x) : DifferentiableAt 𝕜 f x := HasFDerivAt.differentiableAt h #align has_deriv_at.differentiable_at HasDerivAt.differentiableAt @[simp] theorem hasDerivWithinAt_univ : HasDerivWithinAt f f' univ x ↔ HasDerivAt f f' x := hasFDerivWithinAt_univ #align has_deriv_within_at_univ hasDerivWithinAt_univ theorem HasDerivAt.unique (h₀ : HasDerivAt f f₀' x) (h₁ : HasDerivAt f f₁' x) : f₀' = f₁' := smulRight_one_eq_iff.mp <| h₀.hasFDerivAt.unique h₁ #align has_deriv_at.unique HasDerivAt.unique theorem hasDerivWithinAt_inter' (h : t ∈ 𝓝[s] x) : HasDerivWithinAt f f' (s ∩ t) x ↔ HasDerivWithinAt f f' s x := hasFDerivWithinAt_inter' h #align has_deriv_within_at_inter' hasDerivWithinAt_inter' theorem hasDerivWithinAt_inter (h : t ∈ 𝓝 x) : HasDerivWithinAt f f' (s ∩ t) x ↔ HasDerivWithinAt f f' s x := hasFDerivWithinAt_inter h #align has_deriv_within_at_inter hasDerivWithinAt_inter theorem HasDerivWithinAt.union (hs : HasDerivWithinAt f f' s x) (ht : HasDerivWithinAt f f' t x) : HasDerivWithinAt f f' (s ∪ t) x := hs.hasFDerivWithinAt.union ht.hasFDerivWithinAt #align has_deriv_within_at.union HasDerivWithinAt.union theorem HasDerivWithinAt.hasDerivAt (h : HasDerivWithinAt f f' s x) (hs : s ∈ 𝓝 x) : HasDerivAt f f' x := HasFDerivWithinAt.hasFDerivAt h hs #align has_deriv_within_at.has_deriv_at HasDerivWithinAt.hasDerivAt theorem DifferentiableWithinAt.hasDerivWithinAt (h : DifferentiableWithinAt 𝕜 f s x) : HasDerivWithinAt f (derivWithin f s x) s x := h.hasFDerivWithinAt.hasDerivWithinAt #align differentiable_within_at.has_deriv_within_at DifferentiableWithinAt.hasDerivWithinAt theorem DifferentiableAt.hasDerivAt (h : DifferentiableAt 𝕜 f x) : HasDerivAt f (deriv f x) x := h.hasFDerivAt.hasDerivAt #align differentiable_at.has_deriv_at DifferentiableAt.hasDerivAt @[simp] theorem hasDerivAt_deriv_iff : HasDerivAt f (deriv f x) x ↔ DifferentiableAt 𝕜 f x := ⟨fun h => h.differentiableAt, fun h => h.hasDerivAt⟩ #align has_deriv_at_deriv_iff hasDerivAt_deriv_iff @[simp] theorem hasDerivWithinAt_derivWithin_iff : HasDerivWithinAt f (derivWithin f s x) s x ↔ DifferentiableWithinAt 𝕜 f s x := ⟨fun h => h.differentiableWithinAt, fun h => h.hasDerivWithinAt⟩ #align has_deriv_within_at_deriv_within_iff hasDerivWithinAt_derivWithin_iff theorem DifferentiableOn.hasDerivAt (h : DifferentiableOn 𝕜 f s) (hs : s ∈ 𝓝 x) : HasDerivAt f (deriv f x) x := (h.hasFDerivAt hs).hasDerivAt #align differentiable_on.has_deriv_at DifferentiableOn.hasDerivAt theorem HasDerivAt.deriv (h : HasDerivAt f f' x) : deriv f x = f' := h.differentiableAt.hasDerivAt.unique h #align has_deriv_at.deriv HasDerivAt.deriv theorem deriv_eq {f' : 𝕜 → F} (h : ∀ x, HasDerivAt f (f' x) x) : deriv f = f' := funext fun x => (h x).deriv #align deriv_eq deriv_eq theorem HasDerivWithinAt.derivWithin (h : HasDerivWithinAt f f' s x) (hxs : UniqueDiffWithinAt 𝕜 s x) : derivWithin f s x = f' := hxs.eq_deriv _ h.differentiableWithinAt.hasDerivWithinAt h #align has_deriv_within_at.deriv_within HasDerivWithinAt.derivWithin theorem fderivWithin_derivWithin : (fderivWithin 𝕜 f s x : 𝕜 → F) 1 = derivWithin f s x := rfl #align fderiv_within_deriv_within fderivWithin_derivWithin theorem derivWithin_fderivWithin : smulRight (1 : 𝕜 →L[𝕜] 𝕜) (derivWithin f s x) = fderivWithin 𝕜 f s x := by simp [derivWithin] #align deriv_within_fderiv_within derivWithin_fderivWithin theorem norm_derivWithin_eq_norm_fderivWithin : ‖derivWithin f s x‖ = ‖fderivWithin 𝕜 f s x‖ := by simp [← derivWithin_fderivWithin] theorem fderiv_deriv : (fderiv 𝕜 f x : 𝕜 → F) 1 = deriv f x := rfl #align fderiv_deriv fderiv_deriv theorem deriv_fderiv : smulRight (1 : 𝕜 →L[𝕜] 𝕜) (deriv f x) = fderiv 𝕜 f x := by simp [deriv] #align deriv_fderiv deriv_fderiv theorem norm_deriv_eq_norm_fderiv : ‖deriv f x‖ = ‖fderiv 𝕜 f x‖ := by simp [← deriv_fderiv] theorem DifferentiableAt.derivWithin (h : DifferentiableAt 𝕜 f x) (hxs : UniqueDiffWithinAt 𝕜 s x) : derivWithin f s x = deriv f x := by unfold derivWithin deriv rw [h.fderivWithin hxs] #align differentiable_at.deriv_within DifferentiableAt.derivWithin theorem HasDerivWithinAt.deriv_eq_zero (hd : HasDerivWithinAt f 0 s x) (H : UniqueDiffWithinAt 𝕜 s x) : deriv f x = 0 := (em' (DifferentiableAt 𝕜 f x)).elim deriv_zero_of_not_differentiableAt fun h => H.eq_deriv _ h.hasDerivAt.hasDerivWithinAt hd #align has_deriv_within_at.deriv_eq_zero HasDerivWithinAt.deriv_eq_zero theorem derivWithin_of_mem (st : t ∈ 𝓝[s] x) (ht : UniqueDiffWithinAt 𝕜 s x) (h : DifferentiableWithinAt 𝕜 f t x) : derivWithin f s x = derivWithin f t x := ((DifferentiableWithinAt.hasDerivWithinAt h).mono_of_mem st).derivWithin ht #align deriv_within_of_mem derivWithin_of_mem theorem derivWithin_subset (st : s ⊆ t) (ht : UniqueDiffWithinAt 𝕜 s x) (h : DifferentiableWithinAt 𝕜 f t x) : derivWithin f s x = derivWithin f t x := ((DifferentiableWithinAt.hasDerivWithinAt h).mono st).derivWithin ht #align deriv_within_subset derivWithin_subset theorem derivWithin_congr_set' (y : 𝕜) (h : s =ᶠ[𝓝[{y}ᶜ] x] t) : derivWithin f s x = derivWithin f t x := by simp only [derivWithin, fderivWithin_congr_set' y h] #align deriv_within_congr_set' derivWithin_congr_set' theorem derivWithin_congr_set (h : s =ᶠ[𝓝 x] t) : derivWithin f s x = derivWithin f t x := by simp only [derivWithin, fderivWithin_congr_set h] #align deriv_within_congr_set derivWithin_congr_set @[simp] theorem derivWithin_univ : derivWithin f univ = deriv f := by ext unfold derivWithin deriv rw [fderivWithin_univ] #align deriv_within_univ derivWithin_univ theorem derivWithin_inter (ht : t ∈ 𝓝 x) : derivWithin f (s ∩ t) x = derivWithin f s x := by unfold derivWithin rw [fderivWithin_inter ht] #align deriv_within_inter derivWithin_inter theorem derivWithin_of_mem_nhds (h : s ∈ 𝓝 x) : derivWithin f s x = deriv f x := by simp only [derivWithin, deriv, fderivWithin_of_mem_nhds h] theorem derivWithin_of_isOpen (hs : IsOpen s) (hx : x ∈ s) : derivWithin f s x = deriv f x := derivWithin_of_mem_nhds (hs.mem_nhds hx) #align deriv_within_of_open derivWithin_of_isOpen lemma deriv_eqOn {f' : 𝕜 → F} (hs : IsOpen s) (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) : s.EqOn (deriv f) f' := fun x hx ↦ by rw [← derivWithin_of_isOpen hs hx, (hf' _ hx).derivWithin <| hs.uniqueDiffWithinAt hx] theorem deriv_mem_iff {f : 𝕜 → F} {s : Set F} {x : 𝕜} : deriv f x ∈ s ↔ DifferentiableAt 𝕜 f x ∧ deriv f x ∈ s ∨ ¬DifferentiableAt 𝕜 f x ∧ (0 : F) ∈ s := by by_cases hx : DifferentiableAt 𝕜 f x <;> simp [deriv_zero_of_not_differentiableAt, *] #align deriv_mem_iff deriv_mem_iff theorem derivWithin_mem_iff {f : 𝕜 → F} {t : Set 𝕜} {s : Set F} {x : 𝕜} : derivWithin f t x ∈ s ↔ DifferentiableWithinAt 𝕜 f t x ∧ derivWithin f t x ∈ s ∨ ¬DifferentiableWithinAt 𝕜 f t x ∧ (0 : F) ∈ s := by by_cases hx : DifferentiableWithinAt 𝕜 f t x <;> simp [derivWithin_zero_of_not_differentiableWithinAt, *] #align deriv_within_mem_iff derivWithin_mem_iff theorem differentiableWithinAt_Ioi_iff_Ici [PartialOrder 𝕜] : DifferentiableWithinAt 𝕜 f (Ioi x) x ↔ DifferentiableWithinAt 𝕜 f (Ici x) x := ⟨fun h => h.hasDerivWithinAt.Ici_of_Ioi.differentiableWithinAt, fun h => h.hasDerivWithinAt.Ioi_of_Ici.differentiableWithinAt⟩ #align differentiable_within_at_Ioi_iff_Ici differentiableWithinAt_Ioi_iff_Ici -- Golfed while splitting the file theorem derivWithin_Ioi_eq_Ici {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] (f : ℝ → E) (x : ℝ) : derivWithin f (Ioi x) x = derivWithin f (Ici x) x := by by_cases H : DifferentiableWithinAt ℝ f (Ioi x) x · have A := H.hasDerivWithinAt.Ici_of_Ioi have B := (differentiableWithinAt_Ioi_iff_Ici.1 H).hasDerivWithinAt simpa using (uniqueDiffOn_Ici x).eq left_mem_Ici A B · rw [derivWithin_zero_of_not_differentiableWithinAt H, derivWithin_zero_of_not_differentiableWithinAt] rwa [differentiableWithinAt_Ioi_iff_Ici] at H #align deriv_within_Ioi_eq_Ici derivWithin_Ioi_eq_Ici theorem HasDerivAt.le_of_lip' {f : 𝕜 → F} {f' : F} {x₀ : 𝕜} (hf : HasDerivAt f f' x₀) {C : ℝ} (hC₀ : 0 ≤ C) (hlip : ∀ᶠ x in 𝓝 x₀, ‖f x - f x₀‖ ≤ C * ‖x - x₀‖) : ‖f'‖ ≤ C := by simpa using HasFDerivAt.le_of_lip' hf.hasFDerivAt hC₀ hlip theorem HasDerivAt.le_of_lipschitzOn {f : 𝕜 → F} {f' : F} {x₀ : 𝕜} (hf : HasDerivAt f f' x₀) {s : Set 𝕜} (hs : s ∈ 𝓝 x₀) {C : ℝ≥0} (hlip : LipschitzOnWith C f s) : ‖f'‖ ≤ C := by simpa using HasFDerivAt.le_of_lipschitzOn hf.hasFDerivAt hs hlip theorem HasDerivAt.le_of_lipschitz {f : 𝕜 → F} {f' : F} {x₀ : 𝕜} (hf : HasDerivAt f f' x₀) {C : ℝ≥0} (hlip : LipschitzWith C f) : ‖f'‖ ≤ C := by simpa using HasFDerivAt.le_of_lipschitz hf.hasFDerivAt hlip
Mathlib/Analysis/Calculus/Deriv/Basic.lean
792
795
theorem norm_deriv_le_of_lip' {f : 𝕜 → F} {x₀ : 𝕜} {C : ℝ} (hC₀ : 0 ≤ C) (hlip : ∀ᶠ x in 𝓝 x₀, ‖f x - f x₀‖ ≤ C * ‖x - x₀‖) : ‖deriv f x₀‖ ≤ C := by
simpa [norm_deriv_eq_norm_fderiv] using norm_fderiv_le_of_lip' 𝕜 hC₀ hlip
import Mathlib.Analysis.Calculus.TangentCone import Mathlib.Analysis.NormedSpace.OperatorNorm.Asymptotics #align_import analysis.calculus.fderiv.basic from "leanprover-community/mathlib"@"41bef4ae1254365bc190aee63b947674d2977f01" open Filter Asymptotics ContinuousLinearMap Set Metric open scoped Classical open Topology NNReal Filter Asymptotics ENNReal noncomputable section section variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] variable {G' : Type*} [NormedAddCommGroup G'] [NormedSpace 𝕜 G'] @[mk_iff hasFDerivAtFilter_iff_isLittleO] structure HasFDerivAtFilter (f : E → F) (f' : E →L[𝕜] F) (x : E) (L : Filter E) : Prop where of_isLittleO :: isLittleO : (fun x' => f x' - f x - f' (x' - x)) =o[L] fun x' => x' - x #align has_fderiv_at_filter HasFDerivAtFilter @[fun_prop] def HasFDerivWithinAt (f : E → F) (f' : E →L[𝕜] F) (s : Set E) (x : E) := HasFDerivAtFilter f f' x (𝓝[s] x) #align has_fderiv_within_at HasFDerivWithinAt @[fun_prop] def HasFDerivAt (f : E → F) (f' : E →L[𝕜] F) (x : E) := HasFDerivAtFilter f f' x (𝓝 x) #align has_fderiv_at HasFDerivAt @[fun_prop] def HasStrictFDerivAt (f : E → F) (f' : E →L[𝕜] F) (x : E) := (fun p : E × E => f p.1 - f p.2 - f' (p.1 - p.2)) =o[𝓝 (x, x)] fun p : E × E => p.1 - p.2 #align has_strict_fderiv_at HasStrictFDerivAt variable (𝕜) @[fun_prop] def DifferentiableWithinAt (f : E → F) (s : Set E) (x : E) := ∃ f' : E →L[𝕜] F, HasFDerivWithinAt f f' s x #align differentiable_within_at DifferentiableWithinAt @[fun_prop] def DifferentiableAt (f : E → F) (x : E) := ∃ f' : E →L[𝕜] F, HasFDerivAt f f' x #align differentiable_at DifferentiableAt irreducible_def fderivWithin (f : E → F) (s : Set E) (x : E) : E →L[𝕜] F := if 𝓝[s \ {x}] x = ⊥ then 0 else if h : ∃ f', HasFDerivWithinAt f f' s x then Classical.choose h else 0 #align fderiv_within fderivWithin irreducible_def fderiv (f : E → F) (x : E) : E →L[𝕜] F := if h : ∃ f', HasFDerivAt f f' x then Classical.choose h else 0 #align fderiv fderiv @[fun_prop] def DifferentiableOn (f : E → F) (s : Set E) := ∀ x ∈ s, DifferentiableWithinAt 𝕜 f s x #align differentiable_on DifferentiableOn @[fun_prop] def Differentiable (f : E → F) := ∀ x, DifferentiableAt 𝕜 f x #align differentiable Differentiable variable {𝕜} variable {f f₀ f₁ g : E → F} variable {f' f₀' f₁' g' : E →L[𝕜] F} variable (e : E →L[𝕜] F) variable {x : E} variable {s t : Set E} variable {L L₁ L₂ : Filter E} theorem fderivWithin_zero_of_isolated (h : 𝓝[s \ {x}] x = ⊥) : fderivWithin 𝕜 f s x = 0 := by rw [fderivWithin, if_pos h] theorem fderivWithin_zero_of_nmem_closure (h : x ∉ closure s) : fderivWithin 𝕜 f s x = 0 := by apply fderivWithin_zero_of_isolated simp only [mem_closure_iff_nhdsWithin_neBot, neBot_iff, Ne, Classical.not_not] at h rw [eq_bot_iff, ← h] exact nhdsWithin_mono _ diff_subset theorem fderivWithin_zero_of_not_differentiableWithinAt (h : ¬DifferentiableWithinAt 𝕜 f s x) : fderivWithin 𝕜 f s x = 0 := by have : ¬∃ f', HasFDerivWithinAt f f' s x := h simp [fderivWithin, this] #align fderiv_within_zero_of_not_differentiable_within_at fderivWithin_zero_of_not_differentiableWithinAt theorem fderiv_zero_of_not_differentiableAt (h : ¬DifferentiableAt 𝕜 f x) : fderiv 𝕜 f x = 0 := by have : ¬∃ f', HasFDerivAt f f' x := h simp [fderiv, this] #align fderiv_zero_of_not_differentiable_at fderiv_zero_of_not_differentiableAt section FDerivProperties theorem hasFDerivAtFilter_iff_tendsto : HasFDerivAtFilter f f' x L ↔ Tendsto (fun x' => ‖x' - x‖⁻¹ * ‖f x' - f x - f' (x' - x)‖) L (𝓝 0) := by have h : ∀ x', ‖x' - x‖ = 0 → ‖f x' - f x - f' (x' - x)‖ = 0 := fun x' hx' => by rw [sub_eq_zero.1 (norm_eq_zero.1 hx')] simp rw [hasFDerivAtFilter_iff_isLittleO, ← isLittleO_norm_left, ← isLittleO_norm_right, isLittleO_iff_tendsto h] exact tendsto_congr fun _ => div_eq_inv_mul _ _ #align has_fderiv_at_filter_iff_tendsto hasFDerivAtFilter_iff_tendsto theorem hasFDerivWithinAt_iff_tendsto : HasFDerivWithinAt f f' s x ↔ Tendsto (fun x' => ‖x' - x‖⁻¹ * ‖f x' - f x - f' (x' - x)‖) (𝓝[s] x) (𝓝 0) := hasFDerivAtFilter_iff_tendsto #align has_fderiv_within_at_iff_tendsto hasFDerivWithinAt_iff_tendsto theorem hasFDerivAt_iff_tendsto : HasFDerivAt f f' x ↔ Tendsto (fun x' => ‖x' - x‖⁻¹ * ‖f x' - f x - f' (x' - x)‖) (𝓝 x) (𝓝 0) := hasFDerivAtFilter_iff_tendsto #align has_fderiv_at_iff_tendsto hasFDerivAt_iff_tendsto theorem hasFDerivAt_iff_isLittleO_nhds_zero : HasFDerivAt f f' x ↔ (fun h : E => f (x + h) - f x - f' h) =o[𝓝 0] fun h => h := by rw [HasFDerivAt, hasFDerivAtFilter_iff_isLittleO, ← map_add_left_nhds_zero x, isLittleO_map] simp [(· ∘ ·)] #align has_fderiv_at_iff_is_o_nhds_zero hasFDerivAt_iff_isLittleO_nhds_zero theorem HasFDerivAt.le_of_lip' {f : E → F} {f' : E →L[𝕜] F} {x₀ : E} (hf : HasFDerivAt f f' x₀) {C : ℝ} (hC₀ : 0 ≤ C) (hlip : ∀ᶠ x in 𝓝 x₀, ‖f x - f x₀‖ ≤ C * ‖x - x₀‖) : ‖f'‖ ≤ C := by refine le_of_forall_pos_le_add fun ε ε0 => opNorm_le_of_nhds_zero ?_ ?_ · exact add_nonneg hC₀ ε0.le rw [← map_add_left_nhds_zero x₀, eventually_map] at hlip filter_upwards [isLittleO_iff.1 (hasFDerivAt_iff_isLittleO_nhds_zero.1 hf) ε0, hlip] with y hy hyC rw [add_sub_cancel_left] at hyC calc ‖f' y‖ ≤ ‖f (x₀ + y) - f x₀‖ + ‖f (x₀ + y) - f x₀ - f' y‖ := norm_le_insert _ _ _ ≤ C * ‖y‖ + ε * ‖y‖ := add_le_add hyC hy _ = (C + ε) * ‖y‖ := (add_mul _ _ _).symm #align has_fderiv_at.le_of_lip' HasFDerivAt.le_of_lip' theorem HasFDerivAt.le_of_lipschitzOn {f : E → F} {f' : E →L[𝕜] F} {x₀ : E} (hf : HasFDerivAt f f' x₀) {s : Set E} (hs : s ∈ 𝓝 x₀) {C : ℝ≥0} (hlip : LipschitzOnWith C f s) : ‖f'‖ ≤ C := by refine hf.le_of_lip' C.coe_nonneg ?_ filter_upwards [hs] with x hx using hlip.norm_sub_le hx (mem_of_mem_nhds hs) #align has_fderiv_at.le_of_lip HasFDerivAt.le_of_lipschitzOn theorem HasFDerivAt.le_of_lipschitz {f : E → F} {f' : E →L[𝕜] F} {x₀ : E} (hf : HasFDerivAt f f' x₀) {C : ℝ≥0} (hlip : LipschitzWith C f) : ‖f'‖ ≤ C := hf.le_of_lipschitzOn univ_mem (lipschitzOn_univ.2 hlip) nonrec theorem HasFDerivAtFilter.mono (h : HasFDerivAtFilter f f' x L₂) (hst : L₁ ≤ L₂) : HasFDerivAtFilter f f' x L₁ := .of_isLittleO <| h.isLittleO.mono hst #align has_fderiv_at_filter.mono HasFDerivAtFilter.mono theorem HasFDerivWithinAt.mono_of_mem (h : HasFDerivWithinAt f f' t x) (hst : t ∈ 𝓝[s] x) : HasFDerivWithinAt f f' s x := h.mono <| nhdsWithin_le_iff.mpr hst #align has_fderiv_within_at.mono_of_mem HasFDerivWithinAt.mono_of_mem #align has_fderiv_within_at.nhds_within HasFDerivWithinAt.mono_of_mem nonrec theorem HasFDerivWithinAt.mono (h : HasFDerivWithinAt f f' t x) (hst : s ⊆ t) : HasFDerivWithinAt f f' s x := h.mono <| nhdsWithin_mono _ hst #align has_fderiv_within_at.mono HasFDerivWithinAt.mono theorem HasFDerivAt.hasFDerivAtFilter (h : HasFDerivAt f f' x) (hL : L ≤ 𝓝 x) : HasFDerivAtFilter f f' x L := h.mono hL #align has_fderiv_at.has_fderiv_at_filter HasFDerivAt.hasFDerivAtFilter @[fun_prop] theorem HasFDerivAt.hasFDerivWithinAt (h : HasFDerivAt f f' x) : HasFDerivWithinAt f f' s x := h.hasFDerivAtFilter inf_le_left #align has_fderiv_at.has_fderiv_within_at HasFDerivAt.hasFDerivWithinAt @[fun_prop] theorem HasFDerivWithinAt.differentiableWithinAt (h : HasFDerivWithinAt f f' s x) : DifferentiableWithinAt 𝕜 f s x := ⟨f', h⟩ #align has_fderiv_within_at.differentiable_within_at HasFDerivWithinAt.differentiableWithinAt @[fun_prop] theorem HasFDerivAt.differentiableAt (h : HasFDerivAt f f' x) : DifferentiableAt 𝕜 f x := ⟨f', h⟩ #align has_fderiv_at.differentiable_at HasFDerivAt.differentiableAt @[simp]
Mathlib/Analysis/Calculus/FDeriv/Basic.lean
403
405
theorem hasFDerivWithinAt_univ : HasFDerivWithinAt f f' univ x ↔ HasFDerivAt f f' x := by
simp only [HasFDerivWithinAt, nhdsWithin_univ] rfl
import Mathlib.MeasureTheory.Integral.SetIntegral #align_import measure_theory.integral.average from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" open ENNReal MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSpace Function open scoped Topology ENNReal Convex variable {α E F : Type*} {m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {μ ν : Measure α} {s t : Set α} namespace MeasureTheory section ENNReal variable (μ) {f g : α → ℝ≥0∞} noncomputable def laverage (f : α → ℝ≥0∞) := ∫⁻ x, f x ∂(μ univ)⁻¹ • μ #align measure_theory.laverage MeasureTheory.laverage notation3 "⨍⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => laverage μ r notation3 "⨍⁻ "(...)", "r:60:(scoped f => laverage volume f) => r notation3 "⨍⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => laverage (Measure.restrict μ s) r notation3 (prettyPrint := false) "⨍⁻ "(...)" in "s", "r:60:(scoped f => laverage Measure.restrict volume s f) => r @[simp] theorem laverage_zero : ⨍⁻ _x, (0 : ℝ≥0∞) ∂μ = 0 := by rw [laverage, lintegral_zero] #align measure_theory.laverage_zero MeasureTheory.laverage_zero @[simp] theorem laverage_zero_measure (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂(0 : Measure α) = 0 := by simp [laverage] #align measure_theory.laverage_zero_measure MeasureTheory.laverage_zero_measure theorem laverage_eq' (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂(μ univ)⁻¹ • μ := rfl #align measure_theory.laverage_eq' MeasureTheory.laverage_eq' theorem laverage_eq (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = (∫⁻ x, f x ∂μ) / μ univ := by rw [laverage_eq', lintegral_smul_measure, ENNReal.div_eq_inv_mul] #align measure_theory.laverage_eq MeasureTheory.laverage_eq theorem laverage_eq_lintegral [IsProbabilityMeasure μ] (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ := by rw [laverage, measure_univ, inv_one, one_smul] #align measure_theory.laverage_eq_lintegral MeasureTheory.laverage_eq_lintegral @[simp] theorem measure_mul_laverage [IsFiniteMeasure μ] (f : α → ℝ≥0∞) : μ univ * ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ := by rcases eq_or_ne μ 0 with hμ | hμ · rw [hμ, lintegral_zero_measure, laverage_zero_measure, mul_zero] · rw [laverage_eq, ENNReal.mul_div_cancel' (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)] #align measure_theory.measure_mul_laverage MeasureTheory.measure_mul_laverage theorem setLaverage_eq (f : α → ℝ≥0∞) (s : Set α) : ⨍⁻ x in s, f x ∂μ = (∫⁻ x in s, f x ∂μ) / μ s := by rw [laverage_eq, restrict_apply_univ] #align measure_theory.set_laverage_eq MeasureTheory.setLaverage_eq theorem setLaverage_eq' (f : α → ℝ≥0∞) (s : Set α) : ⨍⁻ x in s, f x ∂μ = ∫⁻ x, f x ∂(μ s)⁻¹ • μ.restrict s := by simp only [laverage_eq', restrict_apply_univ] #align measure_theory.set_laverage_eq' MeasureTheory.setLaverage_eq' variable {μ} theorem laverage_congr {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) : ⨍⁻ x, f x ∂μ = ⨍⁻ x, g x ∂μ := by simp only [laverage_eq, lintegral_congr_ae h] #align measure_theory.laverage_congr MeasureTheory.laverage_congr theorem setLaverage_congr (h : s =ᵐ[μ] t) : ⨍⁻ x in s, f x ∂μ = ⨍⁻ x in t, f x ∂μ := by simp only [setLaverage_eq, set_lintegral_congr h, measure_congr h] #align measure_theory.set_laverage_congr MeasureTheory.setLaverage_congr theorem setLaverage_congr_fun (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) : ⨍⁻ x in s, f x ∂μ = ⨍⁻ x in s, g x ∂μ := by simp only [laverage_eq, set_lintegral_congr_fun hs h] #align measure_theory.set_laverage_congr_fun MeasureTheory.setLaverage_congr_fun theorem laverage_lt_top (hf : ∫⁻ x, f x ∂μ ≠ ∞) : ⨍⁻ x, f x ∂μ < ∞ := by obtain rfl | hμ := eq_or_ne μ 0 · simp · rw [laverage_eq] exact div_lt_top hf (measure_univ_ne_zero.2 hμ) #align measure_theory.laverage_lt_top MeasureTheory.laverage_lt_top theorem setLaverage_lt_top : ∫⁻ x in s, f x ∂μ ≠ ∞ → ⨍⁻ x in s, f x ∂μ < ∞ := laverage_lt_top #align measure_theory.set_laverage_lt_top MeasureTheory.setLaverage_lt_top theorem laverage_add_measure : ⨍⁻ x, f x ∂(μ + ν) = μ univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂μ + ν univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂ν := by by_cases hμ : IsFiniteMeasure μ; swap · rw [not_isFiniteMeasure_iff] at hμ simp [laverage_eq, hμ] by_cases hν : IsFiniteMeasure ν; swap · rw [not_isFiniteMeasure_iff] at hν simp [laverage_eq, hν] haveI := hμ; haveI := hν simp only [← ENNReal.mul_div_right_comm, measure_mul_laverage, ← ENNReal.add_div, ← lintegral_add_measure, ← Measure.add_apply, ← laverage_eq] #align measure_theory.laverage_add_measure MeasureTheory.laverage_add_measure
Mathlib/MeasureTheory/Integral/Average.lean
183
186
theorem measure_mul_setLaverage (f : α → ℝ≥0∞) (h : μ s ≠ ∞) : μ s * ⨍⁻ x in s, f x ∂μ = ∫⁻ x in s, f x ∂μ := by
have := Fact.mk h.lt_top rw [← measure_mul_laverage, restrict_apply_univ]
import Mathlib.RingTheory.Polynomial.Basic import Mathlib.RingTheory.Ideal.LocalRing #align_import data.polynomial.expand from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821" universe u v w open Polynomial open Finset namespace Polynomial section CommSemiring variable (R : Type u) [CommSemiring R] {S : Type v} [CommSemiring S] (p q : ℕ) noncomputable def expand : R[X] →ₐ[R] R[X] := { (eval₂RingHom C (X ^ p) : R[X] →+* R[X]) with commutes' := fun _ => eval₂_C _ _ } #align polynomial.expand Polynomial.expand theorem coe_expand : (expand R p : R[X] → R[X]) = eval₂ C (X ^ p) := rfl #align polynomial.coe_expand Polynomial.coe_expand variable {R} theorem expand_eq_comp_X_pow {f : R[X]} : expand R p f = f.comp (X ^ p) := rfl theorem expand_eq_sum {f : R[X]} : expand R p f = f.sum fun e a => C a * (X ^ p) ^ e := by simp [expand, eval₂] #align polynomial.expand_eq_sum Polynomial.expand_eq_sum @[simp] theorem expand_C (r : R) : expand R p (C r) = C r := eval₂_C _ _ set_option linter.uppercaseLean3 false in #align polynomial.expand_C Polynomial.expand_C @[simp] theorem expand_X : expand R p X = X ^ p := eval₂_X _ _ set_option linter.uppercaseLean3 false in #align polynomial.expand_X Polynomial.expand_X @[simp]
Mathlib/Algebra/Polynomial/Expand.lean
65
66
theorem expand_monomial (r : R) : expand R p (monomial q r) = monomial (q * p) r := by
simp_rw [← smul_X_eq_monomial, AlgHom.map_smul, AlgHom.map_pow, expand_X, mul_comm, pow_mul]
import Mathlib.Geometry.Euclidean.Circumcenter #align_import geometry.euclidean.monge_point from "leanprover-community/mathlib"@"1a4df69ca1a9a0e5e26bfe12e2b92814216016d0" noncomputable section open scoped Classical open scoped RealInnerProductSpace namespace Affine namespace Simplex open Finset AffineSubspace EuclideanGeometry PointsWithCircumcenterIndex variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P] def mongePoint {n : ℕ} (s : Simplex ℝ P n) : P := (((n + 1 : ℕ) : ℝ) / ((n - 1 : ℕ) : ℝ)) • ((univ : Finset (Fin (n + 1))).centroid ℝ s.points -ᵥ s.circumcenter) +ᵥ s.circumcenter #align affine.simplex.monge_point Affine.Simplex.mongePoint theorem mongePoint_eq_smul_vsub_vadd_circumcenter {n : ℕ} (s : Simplex ℝ P n) : s.mongePoint = (((n + 1 : ℕ) : ℝ) / ((n - 1 : ℕ) : ℝ)) • ((univ : Finset (Fin (n + 1))).centroid ℝ s.points -ᵥ s.circumcenter) +ᵥ s.circumcenter := rfl #align affine.simplex.monge_point_eq_smul_vsub_vadd_circumcenter Affine.Simplex.mongePoint_eq_smul_vsub_vadd_circumcenter theorem mongePoint_mem_affineSpan {n : ℕ} (s : Simplex ℝ P n) : s.mongePoint ∈ affineSpan ℝ (Set.range s.points) := smul_vsub_vadd_mem _ _ (centroid_mem_affineSpan_of_card_eq_add_one ℝ _ (card_fin (n + 1))) s.circumcenter_mem_affineSpan s.circumcenter_mem_affineSpan #align affine.simplex.monge_point_mem_affine_span Affine.Simplex.mongePoint_mem_affineSpan theorem mongePoint_eq_of_range_eq {n : ℕ} {s₁ s₂ : Simplex ℝ P n} (h : Set.range s₁.points = Set.range s₂.points) : s₁.mongePoint = s₂.mongePoint := by simp_rw [mongePoint_eq_smul_vsub_vadd_circumcenter, centroid_eq_of_range_eq h, circumcenter_eq_of_range_eq h] #align affine.simplex.monge_point_eq_of_range_eq Affine.Simplex.mongePoint_eq_of_range_eq def mongePointWeightsWithCircumcenter (n : ℕ) : PointsWithCircumcenterIndex (n + 2) → ℝ | pointIndex _ => ((n + 1 : ℕ) : ℝ)⁻¹ | circumcenterIndex => -2 / ((n + 1 : ℕ) : ℝ) #align affine.simplex.monge_point_weights_with_circumcenter Affine.Simplex.mongePointWeightsWithCircumcenter @[simp] theorem sum_mongePointWeightsWithCircumcenter (n : ℕ) : ∑ i, mongePointWeightsWithCircumcenter n i = 1 := by simp_rw [sum_pointsWithCircumcenter, mongePointWeightsWithCircumcenter, sum_const, card_fin, nsmul_eq_mul] -- Porting note: replaced -- have hn1 : (n + 1 : ℝ) ≠ 0 := mod_cast Nat.succ_ne_zero _ field_simp [n.cast_add_one_ne_zero] ring #align affine.simplex.sum_monge_point_weights_with_circumcenter Affine.Simplex.sum_mongePointWeightsWithCircumcenter theorem mongePoint_eq_affineCombination_of_pointsWithCircumcenter {n : ℕ} (s : Simplex ℝ P (n + 2)) : s.mongePoint = (univ : Finset (PointsWithCircumcenterIndex (n + 2))).affineCombination ℝ s.pointsWithCircumcenter (mongePointWeightsWithCircumcenter n) := by rw [mongePoint_eq_smul_vsub_vadd_circumcenter, centroid_eq_affineCombination_of_pointsWithCircumcenter, circumcenter_eq_affineCombination_of_pointsWithCircumcenter, affineCombination_vsub, ← LinearMap.map_smul, weightedVSub_vadd_affineCombination] congr with i rw [Pi.add_apply, Pi.smul_apply, smul_eq_mul, Pi.sub_apply] -- Porting note: replaced -- have hn1 : (n + 1 : ℝ) ≠ 0 := mod_cast Nat.succ_ne_zero _ have hn1 : (n + 1 : ℝ) ≠ 0 := n.cast_add_one_ne_zero cases i <;> simp_rw [centroidWeightsWithCircumcenter, circumcenterWeightsWithCircumcenter, mongePointWeightsWithCircumcenter] <;> rw [add_tsub_assoc_of_le (by decide : 1 ≤ 2), (by decide : 2 - 1 = 1)] · rw [if_pos (mem_univ _), sub_zero, add_zero, card_fin] -- Porting note: replaced -- have hn3 : (n + 2 + 1 : ℝ) ≠ 0 := mod_cast Nat.succ_ne_zero _ have hn3 : (n + 2 + 1 : ℝ) ≠ 0 := by norm_cast field_simp [hn1, hn3, mul_comm] · field_simp [hn1] ring #align affine.simplex.monge_point_eq_affine_combination_of_points_with_circumcenter Affine.Simplex.mongePoint_eq_affineCombination_of_pointsWithCircumcenter def mongePointVSubFaceCentroidWeightsWithCircumcenter {n : ℕ} (i₁ i₂ : Fin (n + 3)) : PointsWithCircumcenterIndex (n + 2) → ℝ | pointIndex i => if i = i₁ ∨ i = i₂ then ((n + 1 : ℕ) : ℝ)⁻¹ else 0 | circumcenterIndex => -2 / ((n + 1 : ℕ) : ℝ) #align affine.simplex.monge_point_vsub_face_centroid_weights_with_circumcenter Affine.Simplex.mongePointVSubFaceCentroidWeightsWithCircumcenter theorem mongePointVSubFaceCentroidWeightsWithCircumcenter_eq_sub {n : ℕ} {i₁ i₂ : Fin (n + 3)} (h : i₁ ≠ i₂) : mongePointVSubFaceCentroidWeightsWithCircumcenter i₁ i₂ = mongePointWeightsWithCircumcenter n - centroidWeightsWithCircumcenter {i₁, i₂}ᶜ := by ext i cases' i with i · rw [Pi.sub_apply, mongePointWeightsWithCircumcenter, centroidWeightsWithCircumcenter, mongePointVSubFaceCentroidWeightsWithCircumcenter] have hu : card ({i₁, i₂}ᶜ : Finset (Fin (n + 3))) = n + 1 := by simp [card_compl, Fintype.card_fin, h] rw [hu] by_cases hi : i = i₁ ∨ i = i₂ <;> simp [compl_eq_univ_sdiff, hi] · simp [mongePointWeightsWithCircumcenter, centroidWeightsWithCircumcenter, mongePointVSubFaceCentroidWeightsWithCircumcenter] #align affine.simplex.monge_point_vsub_face_centroid_weights_with_circumcenter_eq_sub Affine.Simplex.mongePointVSubFaceCentroidWeightsWithCircumcenter_eq_sub @[simp] theorem sum_mongePointVSubFaceCentroidWeightsWithCircumcenter {n : ℕ} {i₁ i₂ : Fin (n + 3)} (h : i₁ ≠ i₂) : ∑ i, mongePointVSubFaceCentroidWeightsWithCircumcenter i₁ i₂ i = 0 := by rw [mongePointVSubFaceCentroidWeightsWithCircumcenter_eq_sub h] simp_rw [Pi.sub_apply, sum_sub_distrib, sum_mongePointWeightsWithCircumcenter] rw [sum_centroidWeightsWithCircumcenter, sub_self] simp [← card_pos, card_compl, h] #align affine.simplex.sum_monge_point_vsub_face_centroid_weights_with_circumcenter Affine.Simplex.sum_mongePointVSubFaceCentroidWeightsWithCircumcenter theorem mongePoint_vsub_face_centroid_eq_weightedVSub_of_pointsWithCircumcenter {n : ℕ} (s : Simplex ℝ P (n + 2)) {i₁ i₂ : Fin (n + 3)} (h : i₁ ≠ i₂) : s.mongePoint -ᵥ ({i₁, i₂}ᶜ : Finset (Fin (n + 3))).centroid ℝ s.points = (univ : Finset (PointsWithCircumcenterIndex (n + 2))).weightedVSub s.pointsWithCircumcenter (mongePointVSubFaceCentroidWeightsWithCircumcenter i₁ i₂) := by simp_rw [mongePoint_eq_affineCombination_of_pointsWithCircumcenter, centroid_eq_affineCombination_of_pointsWithCircumcenter, affineCombination_vsub, mongePointVSubFaceCentroidWeightsWithCircumcenter_eq_sub h] #align affine.simplex.monge_point_vsub_face_centroid_eq_weighted_vsub_of_points_with_circumcenter Affine.Simplex.mongePoint_vsub_face_centroid_eq_weightedVSub_of_pointsWithCircumcenter
Mathlib/Geometry/Euclidean/MongePoint.lean
210
240
theorem inner_mongePoint_vsub_face_centroid_vsub {n : ℕ} (s : Simplex ℝ P (n + 2)) {i₁ i₂ : Fin (n + 3)} : ⟪s.mongePoint -ᵥ ({i₁, i₂}ᶜ : Finset (Fin (n + 3))).centroid ℝ s.points, s.points i₁ -ᵥ s.points i₂⟫ = 0 := by
by_cases h : i₁ = i₂ · simp [h] simp_rw [mongePoint_vsub_face_centroid_eq_weightedVSub_of_pointsWithCircumcenter s h, point_eq_affineCombination_of_pointsWithCircumcenter, affineCombination_vsub] have hs : ∑ i, (pointWeightsWithCircumcenter i₁ - pointWeightsWithCircumcenter i₂) i = 0 := by simp rw [inner_weightedVSub _ (sum_mongePointVSubFaceCentroidWeightsWithCircumcenter h) _ hs, sum_pointsWithCircumcenter, pointsWithCircumcenter_eq_circumcenter] simp only [mongePointVSubFaceCentroidWeightsWithCircumcenter, pointsWithCircumcenter_point] let fs : Finset (Fin (n + 3)) := {i₁, i₂} have hfs : ∀ i : Fin (n + 3), i ∉ fs → i ≠ i₁ ∧ i ≠ i₂ := by intro i hi constructor <;> · intro hj; simp [fs, ← hj] at hi rw [← sum_subset fs.subset_univ _] · simp_rw [sum_pointsWithCircumcenter, pointsWithCircumcenter_eq_circumcenter, pointsWithCircumcenter_point, Pi.sub_apply, pointWeightsWithCircumcenter] rw [← sum_subset fs.subset_univ _] · simp_rw [sum_insert (not_mem_singleton.2 h), sum_singleton] repeat rw [← sum_subset fs.subset_univ _] · simp_rw [sum_insert (not_mem_singleton.2 h), sum_singleton] simp [h, Ne.symm h, dist_comm (s.points i₁)] all_goals intro i _ hi; simp [hfs i hi] · intro i _ hi simp [hfs i hi, pointsWithCircumcenter] · intro i _ hi simp [hfs i hi]
import Mathlib.MeasureTheory.Function.LpSeminorm.Basic import Mathlib.MeasureTheory.Integral.MeanInequalities #align_import measure_theory.function.lp_seminorm from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9" open Filter open scoped ENNReal Topology namespace MeasureTheory section SameSpace variable {α E : Type*} {m : MeasurableSpace α} [NormedAddCommGroup E] {μ : Measure α} {f : α → E} theorem snorm'_le_snorm'_mul_rpow_measure_univ {p q : ℝ} (hp0_lt : 0 < p) (hpq : p ≤ q) (hf : AEStronglyMeasurable f μ) : snorm' f p μ ≤ snorm' f q μ * μ Set.univ ^ (1 / p - 1 / q) := by have hq0_lt : 0 < q := lt_of_lt_of_le hp0_lt hpq by_cases hpq_eq : p = q · rw [hpq_eq, sub_self, ENNReal.rpow_zero, mul_one] have hpq : p < q := lt_of_le_of_ne hpq hpq_eq let g := fun _ : α => (1 : ℝ≥0∞) have h_rw : (∫⁻ a, (‖f a‖₊ : ℝ≥0∞) ^ p ∂μ) = ∫⁻ a, ((‖f a‖₊ : ℝ≥0∞) * g a) ^ p ∂μ := lintegral_congr fun a => by simp [g] repeat' rw [snorm'] rw [h_rw] let r := p * q / (q - p) have hpqr : 1 / p = 1 / q + 1 / r := by field_simp [r, hp0_lt.ne', hq0_lt.ne'] calc (∫⁻ a : α, (↑‖f a‖₊ * g a) ^ p ∂μ) ^ (1 / p) ≤ (∫⁻ a : α, ↑‖f a‖₊ ^ q ∂μ) ^ (1 / q) * (∫⁻ a : α, g a ^ r ∂μ) ^ (1 / r) := ENNReal.lintegral_Lp_mul_le_Lq_mul_Lr hp0_lt hpq hpqr μ hf.ennnorm aemeasurable_const _ = (∫⁻ a : α, ↑‖f a‖₊ ^ q ∂μ) ^ (1 / q) * μ Set.univ ^ (1 / p - 1 / q) := by rw [hpqr]; simp [r, g] #align measure_theory.snorm'_le_snorm'_mul_rpow_measure_univ MeasureTheory.snorm'_le_snorm'_mul_rpow_measure_univ theorem snorm'_le_snormEssSup_mul_rpow_measure_univ {q : ℝ} (hq_pos : 0 < q) : snorm' f q μ ≤ snormEssSup f μ * μ Set.univ ^ (1 / q) := by have h_le : (∫⁻ a : α, (‖f a‖₊ : ℝ≥0∞) ^ q ∂μ) ≤ ∫⁻ _ : α, snormEssSup f μ ^ q ∂μ := by refine lintegral_mono_ae ?_ have h_nnnorm_le_snorm_ess_sup := coe_nnnorm_ae_le_snormEssSup f μ exact h_nnnorm_le_snorm_ess_sup.mono fun x hx => by gcongr rw [snorm', ← ENNReal.rpow_one (snormEssSup f μ)] nth_rw 2 [← mul_inv_cancel (ne_of_lt hq_pos).symm] rw [ENNReal.rpow_mul, one_div, ← ENNReal.mul_rpow_of_nonneg _ _ (by simp [hq_pos.le] : 0 ≤ q⁻¹)] gcongr rwa [lintegral_const] at h_le #align measure_theory.snorm'_le_snorm_ess_sup_mul_rpow_measure_univ MeasureTheory.snorm'_le_snormEssSup_mul_rpow_measure_univ theorem snorm_le_snorm_mul_rpow_measure_univ {p q : ℝ≥0∞} (hpq : p ≤ q) (hf : AEStronglyMeasurable f μ) : snorm f p μ ≤ snorm f q μ * μ Set.univ ^ (1 / p.toReal - 1 / q.toReal) := by by_cases hp0 : p = 0 · simp [hp0, zero_le] rw [← Ne] at hp0 have hp0_lt : 0 < p := lt_of_le_of_ne (zero_le _) hp0.symm have hq0_lt : 0 < q := lt_of_lt_of_le hp0_lt hpq by_cases hq_top : q = ∞ · simp only [hq_top, _root_.div_zero, one_div, ENNReal.top_toReal, sub_zero, snorm_exponent_top, GroupWithZero.inv_zero] by_cases hp_top : p = ∞ · simp only [hp_top, ENNReal.rpow_zero, mul_one, ENNReal.top_toReal, sub_zero, GroupWithZero.inv_zero, snorm_exponent_top] exact le_rfl rw [snorm_eq_snorm' hp0 hp_top] have hp_pos : 0 < p.toReal := ENNReal.toReal_pos hp0_lt.ne' hp_top refine (snorm'_le_snormEssSup_mul_rpow_measure_univ hp_pos).trans (le_of_eq ?_) congr exact one_div _ have hp_lt_top : p < ∞ := hpq.trans_lt (lt_top_iff_ne_top.mpr hq_top) have hp_pos : 0 < p.toReal := ENNReal.toReal_pos hp0_lt.ne' hp_lt_top.ne rw [snorm_eq_snorm' hp0_lt.ne.symm hp_lt_top.ne, snorm_eq_snorm' hq0_lt.ne.symm hq_top] have hpq_real : p.toReal ≤ q.toReal := by rwa [ENNReal.toReal_le_toReal hp_lt_top.ne hq_top] exact snorm'_le_snorm'_mul_rpow_measure_univ hp_pos hpq_real hf #align measure_theory.snorm_le_snorm_mul_rpow_measure_univ MeasureTheory.snorm_le_snorm_mul_rpow_measure_univ theorem snorm'_le_snorm'_of_exponent_le {p q : ℝ} (hp0_lt : 0 < p) (hpq : p ≤ q) (μ : Measure α) [IsProbabilityMeasure μ] (hf : AEStronglyMeasurable f μ) : snorm' f p μ ≤ snorm' f q μ := by have h_le_μ := snorm'_le_snorm'_mul_rpow_measure_univ hp0_lt hpq hf rwa [measure_univ, ENNReal.one_rpow, mul_one] at h_le_μ #align measure_theory.snorm'_le_snorm'_of_exponent_le MeasureTheory.snorm'_le_snorm'_of_exponent_le theorem snorm'_le_snormEssSup {q : ℝ} (hq_pos : 0 < q) [IsProbabilityMeasure μ] : snorm' f q μ ≤ snormEssSup f μ := le_trans (snorm'_le_snormEssSup_mul_rpow_measure_univ hq_pos) (le_of_eq (by simp [measure_univ])) #align measure_theory.snorm'_le_snorm_ess_sup MeasureTheory.snorm'_le_snormEssSup theorem snorm_le_snorm_of_exponent_le {p q : ℝ≥0∞} (hpq : p ≤ q) [IsProbabilityMeasure μ] (hf : AEStronglyMeasurable f μ) : snorm f p μ ≤ snorm f q μ := (snorm_le_snorm_mul_rpow_measure_univ hpq hf).trans (le_of_eq (by simp [measure_univ])) #align measure_theory.snorm_le_snorm_of_exponent_le MeasureTheory.snorm_le_snorm_of_exponent_le
Mathlib/MeasureTheory/Function/LpSeminorm/CompareExp.lean
105
118
theorem snorm'_lt_top_of_snorm'_lt_top_of_exponent_le {p q : ℝ} [IsFiniteMeasure μ] (hf : AEStronglyMeasurable f μ) (hfq_lt_top : snorm' f q μ < ∞) (hp_nonneg : 0 ≤ p) (hpq : p ≤ q) : snorm' f p μ < ∞ := by
rcases le_or_lt p 0 with hp_nonpos | hp_pos · rw [le_antisymm hp_nonpos hp_nonneg] simp have hq_pos : 0 < q := lt_of_lt_of_le hp_pos hpq calc snorm' f p μ ≤ snorm' f q μ * μ Set.univ ^ (1 / p - 1 / q) := snorm'_le_snorm'_mul_rpow_measure_univ hp_pos hpq hf _ < ∞ := by rw [ENNReal.mul_lt_top_iff] refine Or.inl ⟨hfq_lt_top, ENNReal.rpow_lt_top_of_nonneg ?_ (measure_ne_top μ Set.univ)⟩ rwa [le_sub_comm, sub_zero, one_div, one_div, inv_le_inv hq_pos hp_pos]
import Mathlib.Data.Finset.Lattice #align_import combinatorics.set_family.compression.down from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" variable {α : Type*} [DecidableEq α] {𝒜 ℬ : Finset (Finset α)} {s : Finset α} {a : α} namespace Finset def nonMemberSubfamily (a : α) (𝒜 : Finset (Finset α)) : Finset (Finset α) := 𝒜.filter fun s => a ∉ s #align finset.non_member_subfamily Finset.nonMemberSubfamily def memberSubfamily (a : α) (𝒜 : Finset (Finset α)) : Finset (Finset α) := (𝒜.filter fun s => a ∈ s).image fun s => erase s a #align finset.member_subfamily Finset.memberSubfamily @[simp]
Mathlib/Combinatorics/SetFamily/Compression/Down.lean
56
57
theorem mem_nonMemberSubfamily : s ∈ 𝒜.nonMemberSubfamily a ↔ s ∈ 𝒜 ∧ a ∉ s := by
simp [nonMemberSubfamily]
import Mathlib.Analysis.InnerProductSpace.Projection import Mathlib.Geometry.Euclidean.PerpBisector import Mathlib.Algebra.QuadraticDiscriminant #align_import geometry.euclidean.basic from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0" noncomputable section open scoped Classical open RealInnerProductSpace namespace EuclideanGeometry variable {V : Type*} {P : Type*} variable [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] variable [NormedAddTorsor V P] theorem dist_left_midpoint_eq_dist_right_midpoint (p1 p2 : P) : dist p1 (midpoint ℝ p1 p2) = dist p2 (midpoint ℝ p1 p2) := by rw [dist_left_midpoint (𝕜 := ℝ) p1 p2, dist_right_midpoint (𝕜 := ℝ) p1 p2] #align euclidean_geometry.dist_left_midpoint_eq_dist_right_midpoint EuclideanGeometry.dist_left_midpoint_eq_dist_right_midpoint theorem inner_weightedVSub {ι₁ : Type*} {s₁ : Finset ι₁} {w₁ : ι₁ → ℝ} (p₁ : ι₁ → P) (h₁ : ∑ i ∈ s₁, w₁ i = 0) {ι₂ : Type*} {s₂ : Finset ι₂} {w₂ : ι₂ → ℝ} (p₂ : ι₂ → P) (h₂ : ∑ i ∈ s₂, w₂ i = 0) : ⟪s₁.weightedVSub p₁ w₁, s₂.weightedVSub p₂ w₂⟫ = (-∑ i₁ ∈ s₁, ∑ i₂ ∈ s₂, w₁ i₁ * w₂ i₂ * (dist (p₁ i₁) (p₂ i₂) * dist (p₁ i₁) (p₂ i₂))) / 2 := by rw [Finset.weightedVSub_apply, Finset.weightedVSub_apply, inner_sum_smul_sum_smul_of_sum_eq_zero _ h₁ _ h₂] simp_rw [vsub_sub_vsub_cancel_right] rcongr (i₁ i₂) <;> rw [dist_eq_norm_vsub V (p₁ i₁) (p₂ i₂)] #align euclidean_geometry.inner_weighted_vsub EuclideanGeometry.inner_weightedVSub theorem dist_affineCombination {ι : Type*} {s : Finset ι} {w₁ w₂ : ι → ℝ} (p : ι → P) (h₁ : ∑ i ∈ s, w₁ i = 1) (h₂ : ∑ i ∈ s, w₂ i = 1) : by have a₁ := s.affineCombination ℝ p w₁ have a₂ := s.affineCombination ℝ p w₂ exact dist a₁ a₂ * dist a₁ a₂ = (-∑ i₁ ∈ s, ∑ i₂ ∈ s, (w₁ - w₂) i₁ * (w₁ - w₂) i₂ * (dist (p i₁) (p i₂) * dist (p i₁) (p i₂))) / 2 := by dsimp only rw [dist_eq_norm_vsub V (s.affineCombination ℝ p w₁) (s.affineCombination ℝ p w₂), ← @inner_self_eq_norm_mul_norm ℝ, Finset.affineCombination_vsub] have h : (∑ i ∈ s, (w₁ - w₂) i) = 0 := by simp_rw [Pi.sub_apply, Finset.sum_sub_distrib, h₁, h₂, sub_self] exact inner_weightedVSub p h p h #align euclidean_geometry.dist_affine_combination EuclideanGeometry.dist_affineCombination -- Porting note: `inner_vsub_vsub_of_dist_eq_of_dist_eq` moved to `PerpendicularBisector` theorem dist_smul_vadd_sq (r : ℝ) (v : V) (p₁ p₂ : P) : dist (r • v +ᵥ p₁) p₂ * dist (r • v +ᵥ p₁) p₂ = ⟪v, v⟫ * r * r + 2 * ⟪v, p₁ -ᵥ p₂⟫ * r + ⟪p₁ -ᵥ p₂, p₁ -ᵥ p₂⟫ := by rw [dist_eq_norm_vsub V _ p₂, ← real_inner_self_eq_norm_mul_norm, vadd_vsub_assoc, real_inner_add_add_self, real_inner_smul_left, real_inner_smul_left, real_inner_smul_right] ring #align euclidean_geometry.dist_smul_vadd_sq EuclideanGeometry.dist_smul_vadd_sq theorem dist_smul_vadd_eq_dist {v : V} (p₁ p₂ : P) (hv : v ≠ 0) (r : ℝ) : dist (r • v +ᵥ p₁) p₂ = dist p₁ p₂ ↔ r = 0 ∨ r = -2 * ⟪v, p₁ -ᵥ p₂⟫ / ⟪v, v⟫ := by conv_lhs => rw [← mul_self_inj_of_nonneg dist_nonneg dist_nonneg, dist_smul_vadd_sq, ← sub_eq_zero, add_sub_assoc, dist_eq_norm_vsub V p₁ p₂, ← real_inner_self_eq_norm_mul_norm, sub_self] have hvi : ⟪v, v⟫ ≠ 0 := by simpa using hv have hd : discrim ⟪v, v⟫ (2 * ⟪v, p₁ -ᵥ p₂⟫) 0 = 2 * ⟪v, p₁ -ᵥ p₂⟫ * (2 * ⟪v, p₁ -ᵥ p₂⟫) := by rw [discrim] ring rw [quadratic_eq_zero_iff hvi hd, add_left_neg, zero_div, neg_mul_eq_neg_mul, ← mul_sub_right_distrib, sub_eq_add_neg, ← mul_two, mul_assoc, mul_div_assoc, mul_div_mul_left, mul_div_assoc] norm_num #align euclidean_geometry.dist_smul_vadd_eq_dist EuclideanGeometry.dist_smul_vadd_eq_dist open AffineSubspace FiniteDimensional theorem eq_of_dist_eq_of_dist_eq_of_mem_of_finrank_eq_two {s : AffineSubspace ℝ P} [FiniteDimensional ℝ s.direction] (hd : finrank ℝ s.direction = 2) {c₁ c₂ p₁ p₂ p : P} (hc₁s : c₁ ∈ s) (hc₂s : c₂ ∈ s) (hp₁s : p₁ ∈ s) (hp₂s : p₂ ∈ s) (hps : p ∈ s) {r₁ r₂ : ℝ} (hc : c₁ ≠ c₂) (hp : p₁ ≠ p₂) (hp₁c₁ : dist p₁ c₁ = r₁) (hp₂c₁ : dist p₂ c₁ = r₁) (hpc₁ : dist p c₁ = r₁) (hp₁c₂ : dist p₁ c₂ = r₂) (hp₂c₂ : dist p₂ c₂ = r₂) (hpc₂ : dist p c₂ = r₂) : p = p₁ ∨ p = p₂ := by have ho : ⟪c₂ -ᵥ c₁, p₂ -ᵥ p₁⟫ = 0 := inner_vsub_vsub_of_dist_eq_of_dist_eq (hp₁c₁.trans hp₂c₁.symm) (hp₁c₂.trans hp₂c₂.symm) have hop : ⟪c₂ -ᵥ c₁, p -ᵥ p₁⟫ = 0 := inner_vsub_vsub_of_dist_eq_of_dist_eq (hp₁c₁.trans hpc₁.symm) (hp₁c₂.trans hpc₂.symm) let b : Fin 2 → V := ![c₂ -ᵥ c₁, p₂ -ᵥ p₁] have hb : LinearIndependent ℝ b := by refine linearIndependent_of_ne_zero_of_inner_eq_zero ?_ ?_ · intro i fin_cases i <;> simp [b, hc.symm, hp.symm] · intro i j hij fin_cases i <;> fin_cases j <;> try exact False.elim (hij rfl) · exact ho · rw [real_inner_comm] exact ho have hbs : Submodule.span ℝ (Set.range b) = s.direction := by refine eq_of_le_of_finrank_eq ?_ ?_ · rw [Submodule.span_le, Set.range_subset_iff] intro i fin_cases i · exact vsub_mem_direction hc₂s hc₁s · exact vsub_mem_direction hp₂s hp₁s · rw [finrank_span_eq_card hb, Fintype.card_fin, hd] have hv : ∀ v ∈ s.direction, ∃ t₁ t₂ : ℝ, v = t₁ • (c₂ -ᵥ c₁) + t₂ • (p₂ -ᵥ p₁) := by intro v hv have hr : Set.range b = {c₂ -ᵥ c₁, p₂ -ᵥ p₁} := by have hu : (Finset.univ : Finset (Fin 2)) = {0, 1} := by decide rw [← Fintype.coe_image_univ, hu] simp [b] rw [← hbs, hr, Submodule.mem_span_insert] at hv rcases hv with ⟨t₁, v', hv', hv⟩ rw [Submodule.mem_span_singleton] at hv' rcases hv' with ⟨t₂, rfl⟩ exact ⟨t₁, t₂, hv⟩ rcases hv (p -ᵥ p₁) (vsub_mem_direction hps hp₁s) with ⟨t₁, t₂, hpt⟩ simp only [hpt, inner_add_right, inner_smul_right, ho, mul_zero, add_zero, mul_eq_zero, inner_self_eq_zero, vsub_eq_zero_iff_eq, hc.symm, or_false_iff] at hop rw [hop, zero_smul, zero_add, ← eq_vadd_iff_vsub_eq] at hpt subst hpt have hp' : (p₂ -ᵥ p₁ : V) ≠ 0 := by simp [hp.symm] have hp₂ : dist ((1 : ℝ) • (p₂ -ᵥ p₁) +ᵥ p₁) c₁ = r₁ := by simp [hp₂c₁] rw [← hp₁c₁, dist_smul_vadd_eq_dist _ _ hp'] at hpc₁ hp₂ simp only [one_ne_zero, false_or_iff] at hp₂ rw [hp₂.symm] at hpc₁ cases' hpc₁ with hpc₁ hpc₁ <;> simp [hpc₁] #align euclidean_geometry.eq_of_dist_eq_of_dist_eq_of_mem_of_finrank_eq_two EuclideanGeometry.eq_of_dist_eq_of_dist_eq_of_mem_of_finrank_eq_two theorem eq_of_dist_eq_of_dist_eq_of_finrank_eq_two [FiniteDimensional ℝ V] (hd : finrank ℝ V = 2) {c₁ c₂ p₁ p₂ p : P} {r₁ r₂ : ℝ} (hc : c₁ ≠ c₂) (hp : p₁ ≠ p₂) (hp₁c₁ : dist p₁ c₁ = r₁) (hp₂c₁ : dist p₂ c₁ = r₁) (hpc₁ : dist p c₁ = r₁) (hp₁c₂ : dist p₁ c₂ = r₂) (hp₂c₂ : dist p₂ c₂ = r₂) (hpc₂ : dist p c₂ = r₂) : p = p₁ ∨ p = p₂ := haveI hd' : finrank ℝ (⊤ : AffineSubspace ℝ P).direction = 2 := by rw [direction_top, finrank_top] exact hd eq_of_dist_eq_of_dist_eq_of_mem_of_finrank_eq_two hd' (mem_top ℝ V _) (mem_top ℝ V _) (mem_top ℝ V _) (mem_top ℝ V _) (mem_top ℝ V _) hc hp hp₁c₁ hp₂c₁ hpc₁ hp₁c₂ hp₂c₂ hpc₂ #align euclidean_geometry.eq_of_dist_eq_of_dist_eq_of_finrank_eq_two EuclideanGeometry.eq_of_dist_eq_of_dist_eq_of_finrank_eq_two def orthogonalProjectionFn (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : P := Classical.choose <| inter_eq_singleton_of_nonempty_of_isCompl (nonempty_subtype.mp ‹_›) (mk'_nonempty p s.directionᗮ) (by rw [direction_mk' p s.directionᗮ] exact Submodule.isCompl_orthogonal_of_completeSpace) #align euclidean_geometry.orthogonal_projection_fn EuclideanGeometry.orthogonalProjectionFn theorem inter_eq_singleton_orthogonalProjectionFn {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : (s : Set P) ∩ mk' p s.directionᗮ = {orthogonalProjectionFn s p} := Classical.choose_spec <| inter_eq_singleton_of_nonempty_of_isCompl (nonempty_subtype.mp ‹_›) (mk'_nonempty p s.directionᗮ) (by rw [direction_mk' p s.directionᗮ] exact Submodule.isCompl_orthogonal_of_completeSpace) #align euclidean_geometry.inter_eq_singleton_orthogonal_projection_fn EuclideanGeometry.inter_eq_singleton_orthogonalProjectionFn theorem orthogonalProjectionFn_mem {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : orthogonalProjectionFn s p ∈ s := by rw [← mem_coe, ← Set.singleton_subset_iff, ← inter_eq_singleton_orthogonalProjectionFn] exact Set.inter_subset_left #align euclidean_geometry.orthogonal_projection_fn_mem EuclideanGeometry.orthogonalProjectionFn_mem theorem orthogonalProjectionFn_mem_orthogonal {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : orthogonalProjectionFn s p ∈ mk' p s.directionᗮ := by rw [← mem_coe, ← Set.singleton_subset_iff, ← inter_eq_singleton_orthogonalProjectionFn] exact Set.inter_subset_right #align euclidean_geometry.orthogonal_projection_fn_mem_orthogonal EuclideanGeometry.orthogonalProjectionFn_mem_orthogonal theorem orthogonalProjectionFn_vsub_mem_direction_orthogonal {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : orthogonalProjectionFn s p -ᵥ p ∈ s.directionᗮ := direction_mk' p s.directionᗮ ▸ vsub_mem_direction (orthogonalProjectionFn_mem_orthogonal p) (self_mem_mk' _ _) #align euclidean_geometry.orthogonal_projection_fn_vsub_mem_direction_orthogonal EuclideanGeometry.orthogonalProjectionFn_vsub_mem_direction_orthogonal attribute [local instance] AffineSubspace.toAddTorsor nonrec def orthogonalProjection (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] : P →ᵃ[ℝ] s where toFun p := ⟨orthogonalProjectionFn s p, orthogonalProjectionFn_mem p⟩ linear := orthogonalProjection s.direction map_vadd' p v := by have hs : ((orthogonalProjection s.direction) v : V) +ᵥ orthogonalProjectionFn s p ∈ s := vadd_mem_of_mem_direction (orthogonalProjection s.direction v).2 (orthogonalProjectionFn_mem p) have ho : ((orthogonalProjection s.direction) v : V) +ᵥ orthogonalProjectionFn s p ∈ mk' (v +ᵥ p) s.directionᗮ := by rw [← vsub_right_mem_direction_iff_mem (self_mem_mk' _ _) _, direction_mk', vsub_vadd_eq_vsub_sub, vadd_vsub_assoc, add_comm, add_sub_assoc] refine Submodule.add_mem _ (orthogonalProjectionFn_vsub_mem_direction_orthogonal p) ?_ rw [Submodule.mem_orthogonal'] intro w hw rw [← neg_sub, inner_neg_left, orthogonalProjection_inner_eq_zero _ w hw, neg_zero] have hm : ((orthogonalProjection s.direction) v : V) +ᵥ orthogonalProjectionFn s p ∈ ({orthogonalProjectionFn s (v +ᵥ p)} : Set P) := by rw [← inter_eq_singleton_orthogonalProjectionFn (v +ᵥ p)] exact Set.mem_inter hs ho rw [Set.mem_singleton_iff] at hm ext exact hm.symm #align euclidean_geometry.orthogonal_projection EuclideanGeometry.orthogonalProjection @[simp] theorem orthogonalProjectionFn_eq {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : orthogonalProjectionFn s p = orthogonalProjection s p := rfl #align euclidean_geometry.orthogonal_projection_fn_eq EuclideanGeometry.orthogonalProjectionFn_eq @[simp] theorem orthogonalProjection_linear {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] : (orthogonalProjection s).linear = _root_.orthogonalProjection s.direction := rfl #align euclidean_geometry.orthogonal_projection_linear EuclideanGeometry.orthogonalProjection_linear theorem inter_eq_singleton_orthogonalProjection {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : (s : Set P) ∩ mk' p s.directionᗮ = {↑(orthogonalProjection s p)} := by rw [← orthogonalProjectionFn_eq] exact inter_eq_singleton_orthogonalProjectionFn p #align euclidean_geometry.inter_eq_singleton_orthogonal_projection EuclideanGeometry.inter_eq_singleton_orthogonalProjection theorem orthogonalProjection_mem {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : ↑(orthogonalProjection s p) ∈ s := (orthogonalProjection s p).2 #align euclidean_geometry.orthogonal_projection_mem EuclideanGeometry.orthogonalProjection_mem theorem orthogonalProjection_mem_orthogonal (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : ↑(orthogonalProjection s p) ∈ mk' p s.directionᗮ := orthogonalProjectionFn_mem_orthogonal p #align euclidean_geometry.orthogonal_projection_mem_orthogonal EuclideanGeometry.orthogonalProjection_mem_orthogonal theorem orthogonalProjection_vsub_mem_direction {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {p1 : P} (p2 : P) (hp1 : p1 ∈ s) : ↑(orthogonalProjection s p2 -ᵥ ⟨p1, hp1⟩ : s.direction) ∈ s.direction := (orthogonalProjection s p2 -ᵥ ⟨p1, hp1⟩ : s.direction).2 #align euclidean_geometry.orthogonal_projection_vsub_mem_direction EuclideanGeometry.orthogonalProjection_vsub_mem_direction theorem vsub_orthogonalProjection_mem_direction {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {p1 : P} (p2 : P) (hp1 : p1 ∈ s) : ↑((⟨p1, hp1⟩ : s) -ᵥ orthogonalProjection s p2 : s.direction) ∈ s.direction := ((⟨p1, hp1⟩ : s) -ᵥ orthogonalProjection s p2 : s.direction).2 #align euclidean_geometry.vsub_orthogonal_projection_mem_direction EuclideanGeometry.vsub_orthogonalProjection_mem_direction theorem orthogonalProjection_eq_self_iff {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {p : P} : ↑(orthogonalProjection s p) = p ↔ p ∈ s := by constructor · exact fun h => h ▸ orthogonalProjection_mem p · intro h have hp : p ∈ (s : Set P) ∩ mk' p s.directionᗮ := ⟨h, self_mem_mk' p _⟩ rw [inter_eq_singleton_orthogonalProjection p] at hp symm exact hp #align euclidean_geometry.orthogonal_projection_eq_self_iff EuclideanGeometry.orthogonalProjection_eq_self_iff @[simp] theorem orthogonalProjection_mem_subspace_eq_self {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : s) : orthogonalProjection s p = p := by ext rw [orthogonalProjection_eq_self_iff] exact p.2 #align euclidean_geometry.orthogonal_projection_mem_subspace_eq_self EuclideanGeometry.orthogonalProjection_mem_subspace_eq_self -- @[simp] -- Porting note (#10618): simp can prove this theorem orthogonalProjection_orthogonalProjection (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : orthogonalProjection s (orthogonalProjection s p) = orthogonalProjection s p := by ext rw [orthogonalProjection_eq_self_iff] exact orthogonalProjection_mem p #align euclidean_geometry.orthogonal_projection_orthogonal_projection EuclideanGeometry.orthogonalProjection_orthogonalProjection theorem eq_orthogonalProjection_of_eq_subspace {s s' : AffineSubspace ℝ P} [Nonempty s] [Nonempty s'] [HasOrthogonalProjection s.direction] [HasOrthogonalProjection s'.direction] (h : s = s') (p : P) : (orthogonalProjection s p : P) = (orthogonalProjection s' p : P) := by subst h rfl #align euclidean_geometry.eq_orthogonal_projection_of_eq_subspace EuclideanGeometry.eq_orthogonalProjection_of_eq_subspace theorem dist_orthogonalProjection_eq_zero_iff {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {p : P} : dist p (orthogonalProjection s p) = 0 ↔ p ∈ s := by rw [dist_comm, dist_eq_zero, orthogonalProjection_eq_self_iff] #align euclidean_geometry.dist_orthogonal_projection_eq_zero_iff EuclideanGeometry.dist_orthogonalProjection_eq_zero_iff theorem dist_orthogonalProjection_ne_zero_of_not_mem {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {p : P} (hp : p ∉ s) : dist p (orthogonalProjection s p) ≠ 0 := mt dist_orthogonalProjection_eq_zero_iff.mp hp #align euclidean_geometry.dist_orthogonal_projection_ne_zero_of_not_mem EuclideanGeometry.dist_orthogonalProjection_ne_zero_of_not_mem theorem orthogonalProjection_vsub_mem_direction_orthogonal (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : (orthogonalProjection s p : P) -ᵥ p ∈ s.directionᗮ := orthogonalProjectionFn_vsub_mem_direction_orthogonal p #align euclidean_geometry.orthogonal_projection_vsub_mem_direction_orthogonal EuclideanGeometry.orthogonalProjection_vsub_mem_direction_orthogonal theorem vsub_orthogonalProjection_mem_direction_orthogonal (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : p -ᵥ orthogonalProjection s p ∈ s.directionᗮ := direction_mk' p s.directionᗮ ▸ vsub_mem_direction (self_mem_mk' _ _) (orthogonalProjection_mem_orthogonal s p) #align euclidean_geometry.vsub_orthogonal_projection_mem_direction_orthogonal EuclideanGeometry.vsub_orthogonalProjection_mem_direction_orthogonal theorem orthogonalProjection_vsub_orthogonalProjection (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : _root_.orthogonalProjection s.direction (p -ᵥ orthogonalProjection s p) = 0 := by apply orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero intro c hc rw [← neg_vsub_eq_vsub_rev, inner_neg_right, orthogonalProjection_vsub_mem_direction_orthogonal s p c hc, neg_zero] #align euclidean_geometry.orthogonal_projection_vsub_orthogonal_projection EuclideanGeometry.orthogonalProjection_vsub_orthogonalProjection theorem orthogonalProjection_vadd_eq_self {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {p : P} (hp : p ∈ s) {v : V} (hv : v ∈ s.directionᗮ) : orthogonalProjection s (v +ᵥ p) = ⟨p, hp⟩ := by have h := vsub_orthogonalProjection_mem_direction_orthogonal s (v +ᵥ p) rw [vadd_vsub_assoc, Submodule.add_mem_iff_right _ hv] at h refine (eq_of_vsub_eq_zero ?_).symm ext refine Submodule.disjoint_def.1 s.direction.orthogonal_disjoint _ ?_ h exact (_ : s.direction).2 #align euclidean_geometry.orthogonal_projection_vadd_eq_self EuclideanGeometry.orthogonalProjection_vadd_eq_self theorem orthogonalProjection_vadd_smul_vsub_orthogonalProjection {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {p1 : P} (p2 : P) (r : ℝ) (hp : p1 ∈ s) : orthogonalProjection s (r • (p2 -ᵥ orthogonalProjection s p2 : V) +ᵥ p1) = ⟨p1, hp⟩ := orthogonalProjection_vadd_eq_self hp (Submodule.smul_mem _ _ (vsub_orthogonalProjection_mem_direction_orthogonal s _)) #align euclidean_geometry.orthogonal_projection_vadd_smul_vsub_orthogonal_projection EuclideanGeometry.orthogonalProjection_vadd_smul_vsub_orthogonalProjection theorem dist_sq_eq_dist_orthogonalProjection_sq_add_dist_orthogonalProjection_sq {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {p1 : P} (p2 : P) (hp1 : p1 ∈ s) : dist p1 p2 * dist p1 p2 = dist p1 (orthogonalProjection s p2) * dist p1 (orthogonalProjection s p2) + dist p2 (orthogonalProjection s p2) * dist p2 (orthogonalProjection s p2) := by rw [dist_comm p2 _, dist_eq_norm_vsub V p1 _, dist_eq_norm_vsub V p1 _, dist_eq_norm_vsub V _ p2, ← vsub_add_vsub_cancel p1 (orthogonalProjection s p2) p2, norm_add_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero] exact Submodule.inner_right_of_mem_orthogonal (vsub_orthogonalProjection_mem_direction p2 hp1) (orthogonalProjection_vsub_mem_direction_orthogonal s p2) #align euclidean_geometry.dist_sq_eq_dist_orthogonal_projection_sq_add_dist_orthogonal_projection_sq EuclideanGeometry.dist_sq_eq_dist_orthogonalProjection_sq_add_dist_orthogonalProjection_sq theorem dist_sq_smul_orthogonal_vadd_smul_orthogonal_vadd {s : AffineSubspace ℝ P} {p1 p2 : P} (hp1 : p1 ∈ s) (hp2 : p2 ∈ s) (r1 r2 : ℝ) {v : V} (hv : v ∈ s.directionᗮ) : dist (r1 • v +ᵥ p1) (r2 • v +ᵥ p2) * dist (r1 • v +ᵥ p1) (r2 • v +ᵥ p2) = dist p1 p2 * dist p1 p2 + (r1 - r2) * (r1 - r2) * (‖v‖ * ‖v‖) := calc dist (r1 • v +ᵥ p1) (r2 • v +ᵥ p2) * dist (r1 • v +ᵥ p1) (r2 • v +ᵥ p2) = ‖p1 -ᵥ p2 + (r1 - r2) • v‖ * ‖p1 -ᵥ p2 + (r1 - r2) • v‖ := by rw [dist_eq_norm_vsub V (r1 • v +ᵥ p1), vsub_vadd_eq_vsub_sub, vadd_vsub_assoc, sub_smul, add_comm, add_sub_assoc] _ = ‖p1 -ᵥ p2‖ * ‖p1 -ᵥ p2‖ + ‖(r1 - r2) • v‖ * ‖(r1 - r2) • v‖ := (norm_add_sq_eq_norm_sq_add_norm_sq_real (Submodule.inner_right_of_mem_orthogonal (vsub_mem_direction hp1 hp2) (Submodule.smul_mem _ _ hv))) _ = ‖(p1 -ᵥ p2 : V)‖ * ‖(p1 -ᵥ p2 : V)‖ + |r1 - r2| * |r1 - r2| * ‖v‖ * ‖v‖ := by rw [norm_smul, Real.norm_eq_abs] ring _ = dist p1 p2 * dist p1 p2 + (r1 - r2) * (r1 - r2) * (‖v‖ * ‖v‖) := by rw [dist_eq_norm_vsub V p1, abs_mul_abs_self, mul_assoc] #align euclidean_geometry.dist_sq_smul_orthogonal_vadd_smul_orthogonal_vadd EuclideanGeometry.dist_sq_smul_orthogonal_vadd_smul_orthogonal_vadd def reflection (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] : P ≃ᵃⁱ[ℝ] P := AffineIsometryEquiv.mk' (fun p => ↑(orthogonalProjection s p) -ᵥ p +ᵥ (orthogonalProjection s p : P)) (_root_.reflection s.direction) (↑(Classical.arbitrary s)) (by intro p let v := p -ᵥ ↑(Classical.arbitrary s) let a : V := _root_.orthogonalProjection s.direction v let b : P := ↑(Classical.arbitrary s) have key : a +ᵥ b -ᵥ (v +ᵥ b) +ᵥ (a +ᵥ b) = a + a - v +ᵥ (b -ᵥ b +ᵥ b) := by rw [← add_vadd, vsub_vadd_eq_vsub_sub, vsub_vadd, vadd_vsub] congr 1 abel dsimp only rwa [reflection_apply, (vsub_vadd p b).symm, AffineMap.map_vadd, orthogonalProjection_linear, vadd_vsub, orthogonalProjection_mem_subspace_eq_self, two_smul]) #align euclidean_geometry.reflection EuclideanGeometry.reflection theorem reflection_apply (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : reflection s p = ↑(orthogonalProjection s p) -ᵥ p +ᵥ (orthogonalProjection s p : P) := rfl #align euclidean_geometry.reflection_apply EuclideanGeometry.reflection_apply theorem eq_reflection_of_eq_subspace {s s' : AffineSubspace ℝ P} [Nonempty s] [Nonempty s'] [HasOrthogonalProjection s.direction] [HasOrthogonalProjection s'.direction] (h : s = s') (p : P) : (reflection s p : P) = (reflection s' p : P) := by subst h rfl #align euclidean_geometry.eq_reflection_of_eq_subspace EuclideanGeometry.eq_reflection_of_eq_subspace @[simp] theorem reflection_reflection (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : reflection s (reflection s p) = p := by have : ∀ a : s, ∀ b : V, (_root_.orthogonalProjection s.direction) b = 0 → reflection s (reflection s (b +ᵥ (a : P))) = b +ᵥ (a : P) := by intro _ _ h simp [reflection, h] rw [← vsub_vadd p (orthogonalProjection s p)] exact this (orthogonalProjection s p) _ (orthogonalProjection_vsub_orthogonalProjection s p) #align euclidean_geometry.reflection_reflection EuclideanGeometry.reflection_reflection @[simp] theorem reflection_symm (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] : (reflection s).symm = reflection s := by ext rw [← (reflection s).injective.eq_iff] simp #align euclidean_geometry.reflection_symm EuclideanGeometry.reflection_symm theorem reflection_involutive (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] : Function.Involutive (reflection s) := reflection_reflection s #align euclidean_geometry.reflection_involutive EuclideanGeometry.reflection_involutive theorem reflection_eq_self_iff {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : reflection s p = p ↔ p ∈ s := by rw [← orthogonalProjection_eq_self_iff, reflection_apply] constructor · intro h rw [← @vsub_eq_zero_iff_eq V, vadd_vsub_assoc, ← two_smul ℝ (↑(orthogonalProjection s p) -ᵥ p), smul_eq_zero] at h norm_num at h exact h · intro h simp [h] #align euclidean_geometry.reflection_eq_self_iff EuclideanGeometry.reflection_eq_self_iff theorem reflection_eq_iff_orthogonalProjection_eq (s₁ s₂ : AffineSubspace ℝ P) [Nonempty s₁] [Nonempty s₂] [HasOrthogonalProjection s₁.direction] [HasOrthogonalProjection s₂.direction] (p : P) : reflection s₁ p = reflection s₂ p ↔ (orthogonalProjection s₁ p : P) = orthogonalProjection s₂ p := by rw [reflection_apply, reflection_apply] constructor · intro h rw [← @vsub_eq_zero_iff_eq V, vsub_vadd_eq_vsub_sub, vadd_vsub_assoc, add_comm, add_sub_assoc, vsub_sub_vsub_cancel_right, ← two_smul ℝ ((orthogonalProjection s₁ p : P) -ᵥ orthogonalProjection s₂ p), smul_eq_zero] at h norm_num at h exact h · intro h rw [h] #align euclidean_geometry.reflection_eq_iff_orthogonal_projection_eq EuclideanGeometry.reflection_eq_iff_orthogonalProjection_eq theorem dist_reflection (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] (p₁ p₂ : P) : dist p₁ (reflection s p₂) = dist (reflection s p₁) p₂ := by conv_lhs => rw [← reflection_reflection s p₁] exact (reflection s).dist_map _ _ #align euclidean_geometry.dist_reflection EuclideanGeometry.dist_reflection theorem dist_reflection_eq_of_mem (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] {p₁ : P} (hp₁ : p₁ ∈ s) (p₂ : P) : dist p₁ (reflection s p₂) = dist p₁ p₂ := by rw [← reflection_eq_self_iff p₁] at hp₁ convert (reflection s).dist_map p₁ p₂ rw [hp₁] #align euclidean_geometry.dist_reflection_eq_of_mem EuclideanGeometry.dist_reflection_eq_of_mem
Mathlib/Geometry/Euclidean/Basic.lean
622
627
theorem reflection_mem_of_le_of_mem {s₁ s₂ : AffineSubspace ℝ P} [Nonempty s₁] [HasOrthogonalProjection s₁.direction] (hle : s₁ ≤ s₂) {p : P} (hp : p ∈ s₂) : reflection s₁ p ∈ s₂ := by
rw [reflection_apply] have ho : ↑(orthogonalProjection s₁ p) ∈ s₂ := hle (orthogonalProjection_mem p) exact vadd_mem_of_mem_direction (vsub_mem_direction ho hp) ho
import Mathlib.Algebra.GroupWithZero.Hom import Mathlib.Algebra.Order.Group.Instances import Mathlib.Algebra.Order.GroupWithZero.Canonical import Mathlib.Order.Hom.Basic #align_import algebra.order.hom.monoid from "leanprover-community/mathlib"@"3342d1b2178381196f818146ff79bc0e7ccd9e2d" open Function variable {F α β γ δ : Type*} section OrderedAddCommGroup variable [OrderedAddCommGroup α] [OrderedAddCommMonoid β] [i : FunLike F α β] variable [iamhc : AddMonoidHomClass F α β] (f : F) theorem monotone_iff_map_nonneg : Monotone (f : α → β) ↔ ∀ a, 0 ≤ a → 0 ≤ f a := ⟨fun h a => by rw [← map_zero f] apply h, fun h a b hl => by rw [← sub_add_cancel b a, map_add f] exact le_add_of_nonneg_left (h _ <| sub_nonneg.2 hl)⟩ #align monotone_iff_map_nonneg monotone_iff_map_nonneg theorem antitone_iff_map_nonpos : Antitone (f : α → β) ↔ ∀ a, 0 ≤ a → f a ≤ 0 := monotone_toDual_comp_iff.symm.trans <| monotone_iff_map_nonneg (β := βᵒᵈ) (iamhc := iamhc) _ #align antitone_iff_map_nonpos antitone_iff_map_nonpos theorem monotone_iff_map_nonpos : Monotone (f : α → β) ↔ ∀ a ≤ 0, f a ≤ 0 := antitone_comp_ofDual_iff.symm.trans <| antitone_iff_map_nonpos (α := αᵒᵈ) (iamhc := iamhc) _ #align monotone_iff_map_nonpos monotone_iff_map_nonpos theorem antitone_iff_map_nonneg : Antitone (f : α → β) ↔ ∀ a ≤ 0, 0 ≤ f a := monotone_comp_ofDual_iff.symm.trans <| monotone_iff_map_nonneg (α := αᵒᵈ) (iamhc := iamhc) _ #align antitone_iff_map_nonneg antitone_iff_map_nonneg variable [CovariantClass β β (· + ·) (· < ·)]
Mathlib/Algebra/Order/Hom/Monoid.lean
216
221
theorem strictMono_iff_map_pos : StrictMono (f : α → β) ↔ ∀ a, 0 < a → 0 < f a := by
refine ⟨fun h a => ?_, fun h a b hl => ?_⟩ · rw [← map_zero f] apply h · rw [← sub_add_cancel b a, map_add f] exact lt_add_of_pos_left _ (h _ <| sub_pos.2 hl)
import Mathlib.Analysis.RCLike.Lemmas import Mathlib.MeasureTheory.Function.StronglyMeasurable.Inner import Mathlib.MeasureTheory.Integral.SetIntegral #align_import measure_theory.function.l2_space from "leanprover-community/mathlib"@"83a66c8775fa14ee5180c85cab98e970956401ad" set_option linter.uppercaseLean3 false noncomputable section open TopologicalSpace MeasureTheory MeasureTheory.Lp Filter open scoped NNReal ENNReal MeasureTheory namespace MeasureTheory section variable {α F : Type*} {m : MeasurableSpace α} {μ : Measure α} [NormedAddCommGroup F] theorem Memℒp.integrable_sq {f : α → ℝ} (h : Memℒp f 2 μ) : Integrable (fun x => f x ^ 2) μ := by simpa [← memℒp_one_iff_integrable] using h.norm_rpow two_ne_zero ENNReal.two_ne_top #align measure_theory.mem_ℒp.integrable_sq MeasureTheory.Memℒp.integrable_sq theorem memℒp_two_iff_integrable_sq_norm {f : α → F} (hf : AEStronglyMeasurable f μ) : Memℒp f 2 μ ↔ Integrable (fun x => ‖f x‖ ^ 2) μ := by rw [← memℒp_one_iff_integrable] convert (memℒp_norm_rpow_iff hf two_ne_zero ENNReal.two_ne_top).symm · simp · rw [div_eq_mul_inv, ENNReal.mul_inv_cancel two_ne_zero ENNReal.two_ne_top] #align measure_theory.mem_ℒp_two_iff_integrable_sq_norm MeasureTheory.memℒp_two_iff_integrable_sq_norm
Mathlib/MeasureTheory/Function/L2Space.lean
54
57
theorem memℒp_two_iff_integrable_sq {f : α → ℝ} (hf : AEStronglyMeasurable f μ) : Memℒp f 2 μ ↔ Integrable (fun x => f x ^ 2) μ := by
convert memℒp_two_iff_integrable_sq_norm hf using 3 simp
import Mathlib.Algebra.Module.Submodule.EqLocus import Mathlib.Algebra.Module.Submodule.RestrictScalars import Mathlib.Algebra.Ring.Idempotents import Mathlib.Data.Set.Pointwise.SMul import Mathlib.LinearAlgebra.Basic import Mathlib.Order.CompactlyGenerated.Basic import Mathlib.Order.OmegaCompletePartialOrder #align_import linear_algebra.span from "leanprover-community/mathlib"@"10878f6bf1dab863445907ab23fbfcefcb5845d0" variable {R R₂ K M M₂ V S : Type*} namespace Submodule open Function Set open Pointwise section AddCommMonoid variable [Semiring R] [AddCommMonoid M] [Module R M] variable {x : M} (p p' : Submodule R M) variable [Semiring R₂] {σ₁₂ : R →+* R₂} variable [AddCommMonoid M₂] [Module R₂ M₂] variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂] section variable (R) def span (s : Set M) : Submodule R M := sInf { p | s ⊆ p } #align submodule.span Submodule.span variable {R} -- Porting note: renamed field to `principal'` and added `principal` to fix explicit argument @[mk_iff] class IsPrincipal (S : Submodule R M) : Prop where principal' : ∃ a, S = span R {a} #align submodule.is_principal Submodule.IsPrincipal theorem IsPrincipal.principal (S : Submodule R M) [S.IsPrincipal] : ∃ a, S = span R {a} := Submodule.IsPrincipal.principal' #align submodule.is_principal.principal Submodule.IsPrincipal.principal end variable {s t : Set M} theorem mem_span : x ∈ span R s ↔ ∀ p : Submodule R M, s ⊆ p → x ∈ p := mem_iInter₂ #align submodule.mem_span Submodule.mem_span @[aesop safe 20 apply (rule_sets := [SetLike])] theorem subset_span : s ⊆ span R s := fun _ h => mem_span.2 fun _ hp => hp h #align submodule.subset_span Submodule.subset_span theorem span_le {p} : span R s ≤ p ↔ s ⊆ p := ⟨Subset.trans subset_span, fun ss _ h => mem_span.1 h _ ss⟩ #align submodule.span_le Submodule.span_le theorem span_mono (h : s ⊆ t) : span R s ≤ span R t := span_le.2 <| Subset.trans h subset_span #align submodule.span_mono Submodule.span_mono theorem span_monotone : Monotone (span R : Set M → Submodule R M) := fun _ _ => span_mono #align submodule.span_monotone Submodule.span_monotone theorem span_eq_of_le (h₁ : s ⊆ p) (h₂ : p ≤ span R s) : span R s = p := le_antisymm (span_le.2 h₁) h₂ #align submodule.span_eq_of_le Submodule.span_eq_of_le theorem span_eq : span R (p : Set M) = p := span_eq_of_le _ (Subset.refl _) subset_span #align submodule.span_eq Submodule.span_eq theorem span_eq_span (hs : s ⊆ span R t) (ht : t ⊆ span R s) : span R s = span R t := le_antisymm (span_le.2 hs) (span_le.2 ht) #align submodule.span_eq_span Submodule.span_eq_span lemma coe_span_eq_self [SetLike S M] [AddSubmonoidClass S M] [SMulMemClass S R M] (s : S) : (span R (s : Set M) : Set M) = s := by refine le_antisymm ?_ subset_span let s' : Submodule R M := { carrier := s add_mem' := add_mem zero_mem' := zero_mem _ smul_mem' := SMulMemClass.smul_mem } exact span_le (p := s') |>.mpr le_rfl @[simp] theorem span_coe_eq_restrictScalars [Semiring S] [SMul S R] [Module S M] [IsScalarTower S R M] : span S (p : Set M) = p.restrictScalars S := span_eq (p.restrictScalars S) #align submodule.span_coe_eq_restrict_scalars Submodule.span_coe_eq_restrictScalars theorem image_span_subset (f : F) (s : Set M) (N : Submodule R₂ M₂) : f '' span R s ⊆ N ↔ ∀ m ∈ s, f m ∈ N := image_subset_iff.trans <| span_le (p := N.comap f) theorem image_span_subset_span (f : F) (s : Set M) : f '' span R s ⊆ span R₂ (f '' s) := (image_span_subset f s _).2 fun x hx ↦ subset_span ⟨x, hx, rfl⟩ theorem map_span [RingHomSurjective σ₁₂] (f : F) (s : Set M) : (span R s).map f = span R₂ (f '' s) := Eq.symm <| span_eq_of_le _ (Set.image_subset f subset_span) (image_span_subset_span f s) #align submodule.map_span Submodule.map_span alias _root_.LinearMap.map_span := Submodule.map_span #align linear_map.map_span LinearMap.map_span theorem map_span_le [RingHomSurjective σ₁₂] (f : F) (s : Set M) (N : Submodule R₂ M₂) : map f (span R s) ≤ N ↔ ∀ m ∈ s, f m ∈ N := image_span_subset f s N #align submodule.map_span_le Submodule.map_span_le alias _root_.LinearMap.map_span_le := Submodule.map_span_le #align linear_map.map_span_le LinearMap.map_span_le @[simp] theorem span_insert_zero : span R (insert (0 : M) s) = span R s := by refine le_antisymm ?_ (Submodule.span_mono (Set.subset_insert 0 s)) rw [span_le, Set.insert_subset_iff] exact ⟨by simp only [SetLike.mem_coe, Submodule.zero_mem], Submodule.subset_span⟩ #align submodule.span_insert_zero Submodule.span_insert_zero -- See also `span_preimage_eq` below. theorem span_preimage_le (f : F) (s : Set M₂) : span R (f ⁻¹' s) ≤ (span R₂ s).comap f := by rw [span_le, comap_coe] exact preimage_mono subset_span #align submodule.span_preimage_le Submodule.span_preimage_le alias _root_.LinearMap.span_preimage_le := Submodule.span_preimage_le #align linear_map.span_preimage_le LinearMap.span_preimage_le theorem closure_subset_span {s : Set M} : (AddSubmonoid.closure s : Set M) ⊆ span R s := (@AddSubmonoid.closure_le _ _ _ (span R s).toAddSubmonoid).mpr subset_span #align submodule.closure_subset_span Submodule.closure_subset_span theorem closure_le_toAddSubmonoid_span {s : Set M} : AddSubmonoid.closure s ≤ (span R s).toAddSubmonoid := closure_subset_span #align submodule.closure_le_to_add_submonoid_span Submodule.closure_le_toAddSubmonoid_span @[simp] theorem span_closure {s : Set M} : span R (AddSubmonoid.closure s : Set M) = span R s := le_antisymm (span_le.mpr closure_subset_span) (span_mono AddSubmonoid.subset_closure) #align submodule.span_closure Submodule.span_closure @[elab_as_elim] theorem span_induction {p : M → Prop} (h : x ∈ span R s) (mem : ∀ x ∈ s, p x) (zero : p 0) (add : ∀ x y, p x → p y → p (x + y)) (smul : ∀ (a : R) (x), p x → p (a • x)) : p x := ((@span_le (p := ⟨⟨⟨p, by intros x y; exact add x y⟩, zero⟩, smul⟩)) s).2 mem h #align submodule.span_induction Submodule.span_induction theorem span_induction₂ {p : M → M → Prop} {a b : M} (ha : a ∈ Submodule.span R s) (hb : b ∈ Submodule.span R s) (mem_mem : ∀ x ∈ s, ∀ y ∈ s, p x y) (zero_left : ∀ y, p 0 y) (zero_right : ∀ x, p x 0) (add_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ + x₂) y) (add_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ + y₂)) (smul_left : ∀ (r : R) x y, p x y → p (r • x) y) (smul_right : ∀ (r : R) x y, p x y → p x (r • y)) : p a b := Submodule.span_induction ha (fun x hx => Submodule.span_induction hb (mem_mem x hx) (zero_right x) (add_right x) fun r => smul_right r x) (zero_left b) (fun x₁ x₂ => add_left x₁ x₂ b) fun r x => smul_left r x b @[elab_as_elim] theorem span_induction' {p : ∀ x, x ∈ span R s → Prop} (mem : ∀ (x) (h : x ∈ s), p x (subset_span h)) (zero : p 0 (Submodule.zero_mem _)) (add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›)) (smul : ∀ (a : R) (x hx), p x hx → p (a • x) (Submodule.smul_mem _ _ ‹_›)) {x} (hx : x ∈ span R s) : p x hx := by refine Exists.elim ?_ fun (hx : x ∈ span R s) (hc : p x hx) => hc refine span_induction hx (fun m hm => ⟨subset_span hm, mem m hm⟩) ⟨zero_mem _, zero⟩ (fun x y hx hy => Exists.elim hx fun hx' hx => Exists.elim hy fun hy' hy => ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩) fun r x hx => Exists.elim hx fun hx' hx => ⟨smul_mem _ _ hx', smul r _ _ hx⟩ #align submodule.span_induction' Submodule.span_induction' open AddSubmonoid in theorem span_eq_closure {s : Set M} : (span R s).toAddSubmonoid = closure (@univ R • s) := by refine le_antisymm (fun x hx ↦ span_induction hx (fun x hx ↦ subset_closure ⟨1, trivial, x, hx, one_smul R x⟩) (zero_mem _) (fun _ _ ↦ add_mem) fun r m hm ↦ closure_induction hm ?_ ?_ fun _ _ h h' ↦ ?_) (closure_le.2 ?_) · rintro _ ⟨r, -, m, hm, rfl⟩; exact smul_mem _ _ (subset_span hm) · rintro _ ⟨r', -, m, hm, rfl⟩; exact subset_closure ⟨r * r', trivial, m, hm, mul_smul r r' m⟩ · rw [smul_zero]; apply zero_mem · rw [smul_add]; exact add_mem h h' @[elab_as_elim] theorem closure_induction {p : M → Prop} (h : x ∈ span R s) (zero : p 0) (add : ∀ x y, p x → p y → p (x + y)) (smul_mem : ∀ r : R, ∀ x ∈ s, p (r • x)) : p x := by rw [← mem_toAddSubmonoid, span_eq_closure] at h refine AddSubmonoid.closure_induction h ?_ zero add rintro _ ⟨r, -, m, hm, rfl⟩ exact smul_mem r m hm @[elab_as_elim] theorem closure_induction' {p : ∀ x, x ∈ span R s → Prop} (zero : p 0 (Submodule.zero_mem _)) (add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›)) (smul_mem : ∀ (r x) (h : x ∈ s), p (r • x) (Submodule.smul_mem _ _ <| subset_span h)) {x} (hx : x ∈ span R s) : p x hx := by refine Exists.elim ?_ fun (hx : x ∈ span R s) (hc : p x hx) ↦ hc refine closure_induction hx ⟨zero_mem _, zero⟩ (fun x y hx hy ↦ Exists.elim hx fun hx' hx ↦ Exists.elim hy fun hy' hy ↦ ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩) fun r x hx ↦ ⟨Submodule.smul_mem _ _ (subset_span hx), smul_mem r x hx⟩ @[simp] theorem span_span_coe_preimage : span R (((↑) : span R s → M) ⁻¹' s) = ⊤ := eq_top_iff.2 fun x ↦ Subtype.recOn x fun x hx _ ↦ by refine span_induction' (p := fun x hx ↦ (⟨x, hx⟩ : span R s) ∈ span R (Subtype.val ⁻¹' s)) (fun x' hx' ↦ subset_span hx') ?_ (fun x _ y _ ↦ ?_) (fun r x _ ↦ ?_) hx · exact zero_mem _ · exact add_mem · exact smul_mem _ _ #align submodule.span_span_coe_preimage Submodule.span_span_coe_preimage @[simp] lemma span_setOf_mem_eq_top : span R {x : span R s | (x : M) ∈ s} = ⊤ := span_span_coe_preimage theorem span_nat_eq_addSubmonoid_closure (s : Set M) : (span ℕ s).toAddSubmonoid = AddSubmonoid.closure s := by refine Eq.symm (AddSubmonoid.closure_eq_of_le subset_span ?_) apply (OrderIso.to_galoisConnection (AddSubmonoid.toNatSubmodule (M := M)).symm).l_le (a := span ℕ s) (b := AddSubmonoid.closure s) rw [span_le] exact AddSubmonoid.subset_closure #align submodule.span_nat_eq_add_submonoid_closure Submodule.span_nat_eq_addSubmonoid_closure @[simp] theorem span_nat_eq (s : AddSubmonoid M) : (span ℕ (s : Set M)).toAddSubmonoid = s := by rw [span_nat_eq_addSubmonoid_closure, s.closure_eq] #align submodule.span_nat_eq Submodule.span_nat_eq theorem span_int_eq_addSubgroup_closure {M : Type*} [AddCommGroup M] (s : Set M) : (span ℤ s).toAddSubgroup = AddSubgroup.closure s := Eq.symm <| AddSubgroup.closure_eq_of_le _ subset_span fun x hx => span_induction hx (fun x hx => AddSubgroup.subset_closure hx) (AddSubgroup.zero_mem _) (fun _ _ => AddSubgroup.add_mem _) fun _ _ _ => AddSubgroup.zsmul_mem _ ‹_› _ #align submodule.span_int_eq_add_subgroup_closure Submodule.span_int_eq_addSubgroup_closure @[simp] theorem span_int_eq {M : Type*} [AddCommGroup M] (s : AddSubgroup M) : (span ℤ (s : Set M)).toAddSubgroup = s := by rw [span_int_eq_addSubgroup_closure, s.closure_eq] #align submodule.span_int_eq Submodule.span_int_eq section variable (R M) protected def gi : GaloisInsertion (@span R M _ _ _) (↑) where choice s _ := span R s gc _ _ := span_le le_l_u _ := subset_span choice_eq _ _ := rfl #align submodule.gi Submodule.gi end @[simp] theorem span_empty : span R (∅ : Set M) = ⊥ := (Submodule.gi R M).gc.l_bot #align submodule.span_empty Submodule.span_empty @[simp] theorem span_univ : span R (univ : Set M) = ⊤ := eq_top_iff.2 <| SetLike.le_def.2 <| subset_span #align submodule.span_univ Submodule.span_univ theorem span_union (s t : Set M) : span R (s ∪ t) = span R s ⊔ span R t := (Submodule.gi R M).gc.l_sup #align submodule.span_union Submodule.span_union theorem span_iUnion {ι} (s : ι → Set M) : span R (⋃ i, s i) = ⨆ i, span R (s i) := (Submodule.gi R M).gc.l_iSup #align submodule.span_Union Submodule.span_iUnion theorem span_iUnion₂ {ι} {κ : ι → Sort*} (s : ∀ i, κ i → Set M) : span R (⋃ (i) (j), s i j) = ⨆ (i) (j), span R (s i j) := (Submodule.gi R M).gc.l_iSup₂ #align submodule.span_Union₂ Submodule.span_iUnion₂ theorem span_attach_biUnion [DecidableEq M] {α : Type*} (s : Finset α) (f : s → Finset M) : span R (s.attach.biUnion f : Set M) = ⨆ x, span R (f x) := by simp [span_iUnion] #align submodule.span_attach_bUnion Submodule.span_attach_biUnion theorem sup_span : p ⊔ span R s = span R (p ∪ s) := by rw [Submodule.span_union, p.span_eq] #align submodule.sup_span Submodule.sup_span theorem span_sup : span R s ⊔ p = span R (s ∪ p) := by rw [Submodule.span_union, p.span_eq] #align submodule.span_sup Submodule.span_sup notation:1000 R " ∙ " x => span R (singleton x) theorem span_eq_iSup_of_singleton_spans (s : Set M) : span R s = ⨆ x ∈ s, R ∙ x := by simp only [← span_iUnion, Set.biUnion_of_singleton s] #align submodule.span_eq_supr_of_singleton_spans Submodule.span_eq_iSup_of_singleton_spans theorem span_range_eq_iSup {ι : Sort*} {v : ι → M} : span R (range v) = ⨆ i, R ∙ v i := by rw [span_eq_iSup_of_singleton_spans, iSup_range] #align submodule.span_range_eq_supr Submodule.span_range_eq_iSup theorem span_smul_le (s : Set M) (r : R) : span R (r • s) ≤ span R s := by rw [span_le] rintro _ ⟨x, hx, rfl⟩ exact smul_mem (span R s) r (subset_span hx) #align submodule.span_smul_le Submodule.span_smul_le theorem subset_span_trans {U V W : Set M} (hUV : U ⊆ Submodule.span R V) (hVW : V ⊆ Submodule.span R W) : U ⊆ Submodule.span R W := (Submodule.gi R M).gc.le_u_l_trans hUV hVW #align submodule.subset_span_trans Submodule.subset_span_trans theorem span_smul_eq_of_isUnit (s : Set M) (r : R) (hr : IsUnit r) : span R (r • s) = span R s := by apply le_antisymm · apply span_smul_le · convert span_smul_le (r • s) ((hr.unit⁻¹ : _) : R) rw [smul_smul] erw [hr.unit.inv_val] rw [one_smul] #align submodule.span_smul_eq_of_is_unit Submodule.span_smul_eq_of_isUnit @[simp] theorem coe_iSup_of_directed {ι} [Nonempty ι] (S : ι → Submodule R M) (H : Directed (· ≤ ·) S) : ((iSup S: Submodule R M) : Set M) = ⋃ i, S i := let s : Submodule R M := { __ := AddSubmonoid.copy _ _ (AddSubmonoid.coe_iSup_of_directed H).symm smul_mem' := fun r _ hx ↦ have ⟨i, hi⟩ := Set.mem_iUnion.mp hx Set.mem_iUnion.mpr ⟨i, (S i).smul_mem' r hi⟩ } have : iSup S = s := le_antisymm (iSup_le fun i ↦ le_iSup (fun i ↦ (S i : Set M)) i) (Set.iUnion_subset fun _ ↦ le_iSup S _) this.symm ▸ rfl #align submodule.coe_supr_of_directed Submodule.coe_iSup_of_directed @[simp] theorem mem_iSup_of_directed {ι} [Nonempty ι] (S : ι → Submodule R M) (H : Directed (· ≤ ·) S) {x} : x ∈ iSup S ↔ ∃ i, x ∈ S i := by rw [← SetLike.mem_coe, coe_iSup_of_directed S H, mem_iUnion] rfl #align submodule.mem_supr_of_directed Submodule.mem_iSup_of_directed theorem mem_sSup_of_directed {s : Set (Submodule R M)} {z} (hs : s.Nonempty) (hdir : DirectedOn (· ≤ ·) s) : z ∈ sSup s ↔ ∃ y ∈ s, z ∈ y := by have : Nonempty s := hs.to_subtype simp only [sSup_eq_iSup', mem_iSup_of_directed _ hdir.directed_val, SetCoe.exists, Subtype.coe_mk, exists_prop] #align submodule.mem_Sup_of_directed Submodule.mem_sSup_of_directed @[norm_cast, simp] theorem coe_iSup_of_chain (a : ℕ →o Submodule R M) : (↑(⨆ k, a k) : Set M) = ⋃ k, (a k : Set M) := coe_iSup_of_directed a a.monotone.directed_le #align submodule.coe_supr_of_chain Submodule.coe_iSup_of_chain theorem coe_scott_continuous : OmegaCompletePartialOrder.Continuous' ((↑) : Submodule R M → Set M) := ⟨SetLike.coe_mono, coe_iSup_of_chain⟩ #align submodule.coe_scott_continuous Submodule.coe_scott_continuous @[simp] theorem mem_iSup_of_chain (a : ℕ →o Submodule R M) (m : M) : (m ∈ ⨆ k, a k) ↔ ∃ k, m ∈ a k := mem_iSup_of_directed a a.monotone.directed_le #align submodule.mem_supr_of_chain Submodule.mem_iSup_of_chain section variable {p p'} theorem mem_sup : x ∈ p ⊔ p' ↔ ∃ y ∈ p, ∃ z ∈ p', y + z = x := ⟨fun h => by rw [← span_eq p, ← span_eq p', ← span_union] at h refine span_induction h ?_ ?_ ?_ ?_ · rintro y (h | h) · exact ⟨y, h, 0, by simp, by simp⟩ · exact ⟨0, by simp, y, h, by simp⟩ · exact ⟨0, by simp, 0, by simp⟩ · rintro _ _ ⟨y₁, hy₁, z₁, hz₁, rfl⟩ ⟨y₂, hy₂, z₂, hz₂, rfl⟩ exact ⟨_, add_mem hy₁ hy₂, _, add_mem hz₁ hz₂, by rw [add_assoc, add_assoc, ← add_assoc y₂, ← add_assoc z₁, add_comm y₂]⟩ · rintro a _ ⟨y, hy, z, hz, rfl⟩ exact ⟨_, smul_mem _ a hy, _, smul_mem _ a hz, by simp [smul_add]⟩, by rintro ⟨y, hy, z, hz, rfl⟩ exact add_mem ((le_sup_left : p ≤ p ⊔ p') hy) ((le_sup_right : p' ≤ p ⊔ p') hz)⟩ #align submodule.mem_sup Submodule.mem_sup theorem mem_sup' : x ∈ p ⊔ p' ↔ ∃ (y : p) (z : p'), (y : M) + z = x := mem_sup.trans <| by simp only [Subtype.exists, exists_prop] #align submodule.mem_sup' Submodule.mem_sup' lemma exists_add_eq_of_codisjoint (h : Codisjoint p p') (x : M) : ∃ y ∈ p, ∃ z ∈ p', y + z = x := by suffices x ∈ p ⊔ p' by exact Submodule.mem_sup.mp this simpa only [h.eq_top] using Submodule.mem_top variable (p p') theorem coe_sup : ↑(p ⊔ p') = (p + p' : Set M) := by ext rw [SetLike.mem_coe, mem_sup, Set.mem_add] simp #align submodule.coe_sup Submodule.coe_sup
Mathlib/LinearAlgebra/Span.lean
458
461
theorem sup_toAddSubmonoid : (p ⊔ p').toAddSubmonoid = p.toAddSubmonoid ⊔ p'.toAddSubmonoid := by
ext x rw [mem_toAddSubmonoid, mem_sup, AddSubmonoid.mem_sup] rfl
import Mathlib.Algebra.BigOperators.Module import Mathlib.Algebra.Order.Field.Basic import Mathlib.Order.Filter.ModEq import Mathlib.Analysis.Asymptotics.Asymptotics import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Data.List.TFAE import Mathlib.Analysis.NormedSpace.Basic #align_import analysis.specific_limits.normed from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" noncomputable section open scoped Classical open Set Function Filter Finset Metric Asymptotics open scoped Classical open Topology Nat uniformity NNReal ENNReal variable {α : Type*} {β : Type*} {ι : Type*} theorem tendsto_norm_atTop_atTop : Tendsto (norm : ℝ → ℝ) atTop atTop := tendsto_abs_atTop_atTop #align tendsto_norm_at_top_at_top tendsto_norm_atTop_atTop theorem summable_of_absolute_convergence_real {f : ℕ → ℝ} : (∃ r, Tendsto (fun n ↦ ∑ i ∈ range n, |f i|) atTop (𝓝 r)) → Summable f | ⟨r, hr⟩ => by refine .of_norm ⟨r, (hasSum_iff_tendsto_nat_of_nonneg ?_ _).2 ?_⟩ · exact fun i ↦ norm_nonneg _ · simpa only using hr #align summable_of_absolute_convergence_real summable_of_absolute_convergence_real theorem tendsto_norm_zero' {𝕜 : Type*} [NormedAddCommGroup 𝕜] : Tendsto (norm : 𝕜 → ℝ) (𝓝[≠] 0) (𝓝[>] 0) := tendsto_norm_zero.inf <| tendsto_principal_principal.2 fun _ hx ↦ norm_pos_iff.2 hx #align tendsto_norm_zero' tendsto_norm_zero' theorem isLittleO_pow_pow_of_lt_left {r₁ r₂ : ℝ} (h₁ : 0 ≤ r₁) (h₂ : r₁ < r₂) : (fun n : ℕ ↦ r₁ ^ n) =o[atTop] fun n ↦ r₂ ^ n := have H : 0 < r₂ := h₁.trans_lt h₂ (isLittleO_of_tendsto fun _ hn ↦ False.elim <| H.ne' <| pow_eq_zero hn) <| (tendsto_pow_atTop_nhds_zero_of_lt_one (div_nonneg h₁ (h₁.trans h₂.le)) ((div_lt_one H).2 h₂)).congr fun _ ↦ div_pow _ _ _ #align is_o_pow_pow_of_lt_left isLittleO_pow_pow_of_lt_left theorem isBigO_pow_pow_of_le_left {r₁ r₂ : ℝ} (h₁ : 0 ≤ r₁) (h₂ : r₁ ≤ r₂) : (fun n : ℕ ↦ r₁ ^ n) =O[atTop] fun n ↦ r₂ ^ n := h₂.eq_or_lt.elim (fun h ↦ h ▸ isBigO_refl _ _) fun h ↦ (isLittleO_pow_pow_of_lt_left h₁ h).isBigO set_option linter.uppercaseLean3 false in #align is_O_pow_pow_of_le_left isBigO_pow_pow_of_le_left theorem isLittleO_pow_pow_of_abs_lt_left {r₁ r₂ : ℝ} (h : |r₁| < |r₂|) : (fun n : ℕ ↦ r₁ ^ n) =o[atTop] fun n ↦ r₂ ^ n := by refine (IsLittleO.of_norm_left ?_).of_norm_right exact (isLittleO_pow_pow_of_lt_left (abs_nonneg r₁) h).congr (pow_abs r₁) (pow_abs r₂) #align is_o_pow_pow_of_abs_lt_left isLittleO_pow_pow_of_abs_lt_left open List in theorem TFAE_exists_lt_isLittleO_pow (f : ℕ → ℝ) (R : ℝ) : TFAE [∃ a ∈ Ioo (-R) R, f =o[atTop] (a ^ ·), ∃ a ∈ Ioo 0 R, f =o[atTop] (a ^ ·), ∃ a ∈ Ioo (-R) R, f =O[atTop] (a ^ ·), ∃ a ∈ Ioo 0 R, f =O[atTop] (a ^ ·), ∃ a < R, ∃ C : ℝ, (0 < C ∨ 0 < R) ∧ ∀ n, |f n| ≤ C * a ^ n, ∃ a ∈ Ioo 0 R, ∃ C > 0, ∀ n, |f n| ≤ C * a ^ n, ∃ a < R, ∀ᶠ n in atTop, |f n| ≤ a ^ n, ∃ a ∈ Ioo 0 R, ∀ᶠ n in atTop, |f n| ≤ a ^ n] := by have A : Ico 0 R ⊆ Ioo (-R) R := fun x hx ↦ ⟨(neg_lt_zero.2 (hx.1.trans_lt hx.2)).trans_le hx.1, hx.2⟩ have B : Ioo 0 R ⊆ Ioo (-R) R := Subset.trans Ioo_subset_Ico_self A -- First we prove that 1-4 are equivalent using 2 → 3 → 4, 1 → 3, and 2 → 1 tfae_have 1 → 3 · exact fun ⟨a, ha, H⟩ ↦ ⟨a, ha, H.isBigO⟩ tfae_have 2 → 1 · exact fun ⟨a, ha, H⟩ ↦ ⟨a, B ha, H⟩ tfae_have 3 → 2 · rintro ⟨a, ha, H⟩ rcases exists_between (abs_lt.2 ha) with ⟨b, hab, hbR⟩ exact ⟨b, ⟨(abs_nonneg a).trans_lt hab, hbR⟩, H.trans_isLittleO (isLittleO_pow_pow_of_abs_lt_left (hab.trans_le (le_abs_self b)))⟩ tfae_have 2 → 4 · exact fun ⟨a, ha, H⟩ ↦ ⟨a, ha, H.isBigO⟩ tfae_have 4 → 3 · exact fun ⟨a, ha, H⟩ ↦ ⟨a, B ha, H⟩ -- Add 5 and 6 using 4 → 6 → 5 → 3 tfae_have 4 → 6 · rintro ⟨a, ha, H⟩ rcases bound_of_isBigO_nat_atTop H with ⟨C, hC₀, hC⟩ refine ⟨a, ha, C, hC₀, fun n ↦ ?_⟩ simpa only [Real.norm_eq_abs, abs_pow, abs_of_nonneg ha.1.le] using hC (pow_ne_zero n ha.1.ne') tfae_have 6 → 5 · exact fun ⟨a, ha, C, H₀, H⟩ ↦ ⟨a, ha.2, C, Or.inl H₀, H⟩ tfae_have 5 → 3 · rintro ⟨a, ha, C, h₀, H⟩ rcases sign_cases_of_C_mul_pow_nonneg fun n ↦ (abs_nonneg _).trans (H n) with (rfl | ⟨hC₀, ha₀⟩) · obtain rfl : f = 0 := by ext n simpa using H n simp only [lt_irrefl, false_or_iff] at h₀ exact ⟨0, ⟨neg_lt_zero.2 h₀, h₀⟩, isBigO_zero _ _⟩ exact ⟨a, A ⟨ha₀, ha⟩, isBigO_of_le' _ fun n ↦ (H n).trans <| mul_le_mul_of_nonneg_left (le_abs_self _) hC₀.le⟩ -- Add 7 and 8 using 2 → 8 → 7 → 3 tfae_have 2 → 8 · rintro ⟨a, ha, H⟩ refine ⟨a, ha, (H.def zero_lt_one).mono fun n hn ↦ ?_⟩ rwa [Real.norm_eq_abs, Real.norm_eq_abs, one_mul, abs_pow, abs_of_pos ha.1] at hn tfae_have 8 → 7 · exact fun ⟨a, ha, H⟩ ↦ ⟨a, ha.2, H⟩ tfae_have 7 → 3 · rintro ⟨a, ha, H⟩ have : 0 ≤ a := nonneg_of_eventually_pow_nonneg (H.mono fun n ↦ (abs_nonneg _).trans) refine ⟨a, A ⟨this, ha⟩, IsBigO.of_bound 1 ?_⟩ simpa only [Real.norm_eq_abs, one_mul, abs_pow, abs_of_nonneg this] -- Porting note: used to work without explicitly having 6 → 7 tfae_have 6 → 7 · exact fun h ↦ tfae_8_to_7 <| tfae_2_to_8 <| tfae_3_to_2 <| tfae_5_to_3 <| tfae_6_to_5 h tfae_finish #align tfae_exists_lt_is_o_pow TFAE_exists_lt_isLittleO_pow theorem isLittleO_pow_const_const_pow_of_one_lt {R : Type*} [NormedRing R] (k : ℕ) {r : ℝ} (hr : 1 < r) : (fun n ↦ (n : R) ^ k : ℕ → R) =o[atTop] fun n ↦ r ^ n := by have : Tendsto (fun x : ℝ ↦ x ^ k) (𝓝[>] 1) (𝓝 1) := ((continuous_id.pow k).tendsto' (1 : ℝ) 1 (one_pow _)).mono_left inf_le_left obtain ⟨r' : ℝ, hr' : r' ^ k < r, h1 : 1 < r'⟩ := ((this.eventually (gt_mem_nhds hr)).and self_mem_nhdsWithin).exists have h0 : 0 ≤ r' := zero_le_one.trans h1.le suffices (fun n ↦ (n : R) ^ k : ℕ → R) =O[atTop] fun n : ℕ ↦ (r' ^ k) ^ n from this.trans_isLittleO (isLittleO_pow_pow_of_lt_left (pow_nonneg h0 _) hr') conv in (r' ^ _) ^ _ => rw [← pow_mul, mul_comm, pow_mul] suffices ∀ n : ℕ, ‖(n : R)‖ ≤ (r' - 1)⁻¹ * ‖(1 : R)‖ * ‖r' ^ n‖ from (isBigO_of_le' _ this).pow _ intro n rw [mul_right_comm] refine n.norm_cast_le.trans (mul_le_mul_of_nonneg_right ?_ (norm_nonneg _)) simpa [_root_.div_eq_inv_mul, Real.norm_eq_abs, abs_of_nonneg h0] using n.cast_le_pow_div_sub h1 #align is_o_pow_const_const_pow_of_one_lt isLittleO_pow_const_const_pow_of_one_lt theorem isLittleO_coe_const_pow_of_one_lt {R : Type*} [NormedRing R] {r : ℝ} (hr : 1 < r) : ((↑) : ℕ → R) =o[atTop] fun n ↦ r ^ n := by simpa only [pow_one] using @isLittleO_pow_const_const_pow_of_one_lt R _ 1 _ hr #align is_o_coe_const_pow_of_one_lt isLittleO_coe_const_pow_of_one_lt theorem isLittleO_pow_const_mul_const_pow_const_pow_of_norm_lt {R : Type*} [NormedRing R] (k : ℕ) {r₁ : R} {r₂ : ℝ} (h : ‖r₁‖ < r₂) : (fun n ↦ (n : R) ^ k * r₁ ^ n : ℕ → R) =o[atTop] fun n ↦ r₂ ^ n := by by_cases h0 : r₁ = 0 · refine (isLittleO_zero _ _).congr' (mem_atTop_sets.2 <| ⟨1, fun n hn ↦ ?_⟩) EventuallyEq.rfl simp [zero_pow (one_le_iff_ne_zero.1 hn), h0] rw [← Ne, ← norm_pos_iff] at h0 have A : (fun n ↦ (n : R) ^ k : ℕ → R) =o[atTop] fun n ↦ (r₂ / ‖r₁‖) ^ n := isLittleO_pow_const_const_pow_of_one_lt k ((one_lt_div h0).2 h) suffices (fun n ↦ r₁ ^ n) =O[atTop] fun n ↦ ‖r₁‖ ^ n by simpa [div_mul_cancel₀ _ (pow_pos h0 _).ne'] using A.mul_isBigO this exact IsBigO.of_bound 1 (by simpa using eventually_norm_pow_le r₁) #align is_o_pow_const_mul_const_pow_const_pow_of_norm_lt isLittleO_pow_const_mul_const_pow_const_pow_of_norm_lt theorem tendsto_pow_const_div_const_pow_of_one_lt (k : ℕ) {r : ℝ} (hr : 1 < r) : Tendsto (fun n ↦ (n : ℝ) ^ k / r ^ n : ℕ → ℝ) atTop (𝓝 0) := (isLittleO_pow_const_const_pow_of_one_lt k hr).tendsto_div_nhds_zero #align tendsto_pow_const_div_const_pow_of_one_lt tendsto_pow_const_div_const_pow_of_one_lt theorem tendsto_pow_const_mul_const_pow_of_abs_lt_one (k : ℕ) {r : ℝ} (hr : |r| < 1) : Tendsto (fun n ↦ (n : ℝ) ^ k * r ^ n : ℕ → ℝ) atTop (𝓝 0) := by by_cases h0 : r = 0 · exact tendsto_const_nhds.congr' (mem_atTop_sets.2 ⟨1, fun n hn ↦ by simp [zero_lt_one.trans_le hn |>.ne', h0]⟩) have hr' : 1 < |r|⁻¹ := one_lt_inv (abs_pos.2 h0) hr rw [tendsto_zero_iff_norm_tendsto_zero] simpa [div_eq_mul_inv] using tendsto_pow_const_div_const_pow_of_one_lt k hr' #align tendsto_pow_const_mul_const_pow_of_abs_lt_one tendsto_pow_const_mul_const_pow_of_abs_lt_one theorem tendsto_pow_const_mul_const_pow_of_lt_one (k : ℕ) {r : ℝ} (hr : 0 ≤ r) (h'r : r < 1) : Tendsto (fun n ↦ (n : ℝ) ^ k * r ^ n : ℕ → ℝ) atTop (𝓝 0) := tendsto_pow_const_mul_const_pow_of_abs_lt_one k (abs_lt.2 ⟨neg_one_lt_zero.trans_le hr, h'r⟩) #align tendsto_pow_const_mul_const_pow_of_lt_one tendsto_pow_const_mul_const_pow_of_lt_one theorem tendsto_self_mul_const_pow_of_abs_lt_one {r : ℝ} (hr : |r| < 1) : Tendsto (fun n ↦ n * r ^ n : ℕ → ℝ) atTop (𝓝 0) := by simpa only [pow_one] using tendsto_pow_const_mul_const_pow_of_abs_lt_one 1 hr #align tendsto_self_mul_const_pow_of_abs_lt_one tendsto_self_mul_const_pow_of_abs_lt_one theorem tendsto_self_mul_const_pow_of_lt_one {r : ℝ} (hr : 0 ≤ r) (h'r : r < 1) : Tendsto (fun n ↦ n * r ^ n : ℕ → ℝ) atTop (𝓝 0) := by simpa only [pow_one] using tendsto_pow_const_mul_const_pow_of_lt_one 1 hr h'r #align tendsto_self_mul_const_pow_of_lt_one tendsto_self_mul_const_pow_of_lt_one theorem tendsto_pow_atTop_nhds_zero_of_norm_lt_one {R : Type*} [NormedRing R] {x : R} (h : ‖x‖ < 1) : Tendsto (fun n : ℕ ↦ x ^ n) atTop (𝓝 0) := by apply squeeze_zero_norm' (eventually_norm_pow_le x) exact tendsto_pow_atTop_nhds_zero_of_lt_one (norm_nonneg _) h #align tendsto_pow_at_top_nhds_0_of_norm_lt_1 tendsto_pow_atTop_nhds_zero_of_norm_lt_one @[deprecated (since := "2024-01-31")] alias tendsto_pow_atTop_nhds_0_of_norm_lt_1 := tendsto_pow_atTop_nhds_zero_of_norm_lt_one theorem tendsto_pow_atTop_nhds_zero_of_abs_lt_one {r : ℝ} (h : |r| < 1) : Tendsto (fun n : ℕ ↦ r ^ n) atTop (𝓝 0) := tendsto_pow_atTop_nhds_zero_of_norm_lt_one h #align tendsto_pow_at_top_nhds_0_of_abs_lt_1 tendsto_pow_atTop_nhds_zero_of_abs_lt_one @[deprecated (since := "2024-01-31")] alias tendsto_pow_atTop_nhds_0_of_abs_lt_1 := tendsto_pow_atTop_nhds_zero_of_abs_lt_one section NormedRingGeometric variable {R : Type*} [NormedRing R] [CompleteSpace R] open NormedSpace theorem NormedRing.summable_geometric_of_norm_lt_one (x : R) (h : ‖x‖ < 1) : Summable fun n : ℕ ↦ x ^ n := have h1 : Summable fun n : ℕ ↦ ‖x‖ ^ n := summable_geometric_of_lt_one (norm_nonneg _) h h1.of_norm_bounded_eventually_nat _ (eventually_norm_pow_le x) #align normed_ring.summable_geometric_of_norm_lt_1 NormedRing.summable_geometric_of_norm_lt_one @[deprecated (since := "2024-01-31")] alias NormedRing.summable_geometric_of_norm_lt_1 := NormedRing.summable_geometric_of_norm_lt_one theorem NormedRing.tsum_geometric_of_norm_lt_one (x : R) (h : ‖x‖ < 1) : ‖∑' n : ℕ, x ^ n‖ ≤ ‖(1 : R)‖ - 1 + (1 - ‖x‖)⁻¹ := by rw [tsum_eq_zero_add (summable_geometric_of_norm_lt_one x h)] simp only [_root_.pow_zero] refine le_trans (norm_add_le _ _) ?_ have : ‖∑' b : ℕ, (fun n ↦ x ^ (n + 1)) b‖ ≤ (1 - ‖x‖)⁻¹ - 1 := by refine tsum_of_norm_bounded ?_ fun b ↦ norm_pow_le' _ (Nat.succ_pos b) convert (hasSum_nat_add_iff' 1).mpr (hasSum_geometric_of_lt_one (norm_nonneg x) h) simp linarith #align normed_ring.tsum_geometric_of_norm_lt_1 NormedRing.tsum_geometric_of_norm_lt_one @[deprecated (since := "2024-01-31")] alias NormedRing.tsum_geometric_of_norm_lt_1 := NormedRing.tsum_geometric_of_norm_lt_one theorem geom_series_mul_neg (x : R) (h : ‖x‖ < 1) : (∑' i : ℕ, x ^ i) * (1 - x) = 1 := by have := (NormedRing.summable_geometric_of_norm_lt_one x h).hasSum.mul_right (1 - x) refine tendsto_nhds_unique this.tendsto_sum_nat ?_ have : Tendsto (fun n : ℕ ↦ 1 - x ^ n) atTop (𝓝 1) := by simpa using tendsto_const_nhds.sub (tendsto_pow_atTop_nhds_zero_of_norm_lt_one h) convert← this rw [← geom_sum_mul_neg, Finset.sum_mul] #align geom_series_mul_neg geom_series_mul_neg theorem mul_neg_geom_series (x : R) (h : ‖x‖ < 1) : ((1 - x) * ∑' i : ℕ, x ^ i) = 1 := by have := (NormedRing.summable_geometric_of_norm_lt_one x h).hasSum.mul_left (1 - x) refine tendsto_nhds_unique this.tendsto_sum_nat ?_ have : Tendsto (fun n : ℕ ↦ 1 - x ^ n) atTop (𝓝 1) := by simpa using tendsto_const_nhds.sub (tendsto_pow_atTop_nhds_zero_of_norm_lt_one h) convert← this rw [← mul_neg_geom_sum, Finset.mul_sum] #align mul_neg_geom_series mul_neg_geom_series theorem geom_series_succ (x : R) (h : ‖x‖ < 1) : ∑' i : ℕ, x ^ (i + 1) = ∑' i : ℕ, x ^ i - 1 := by rw [eq_sub_iff_add_eq, tsum_eq_zero_add (NormedRing.summable_geometric_of_norm_lt_one x h), pow_zero, add_comm] theorem geom_series_mul_shift (x : R) (h : ‖x‖ < 1) : x * ∑' i : ℕ, x ^ i = ∑' i : ℕ, x ^ (i + 1) := by simp_rw [← (NormedRing.summable_geometric_of_norm_lt_one _ h).tsum_mul_left, ← _root_.pow_succ']
Mathlib/Analysis/SpecificLimits/Normed.lean
566
568
theorem geom_series_mul_one_add (x : R) (h : ‖x‖ < 1) : (1 + x) * ∑' i : ℕ, x ^ i = 2 * ∑' i : ℕ, x ^ i - 1 := by
rw [add_mul, one_mul, geom_series_mul_shift x h, geom_series_succ x h, two_mul, add_sub_assoc]
import Mathlib.Algebra.CharP.Two import Mathlib.Algebra.CharP.Reduced import Mathlib.Algebra.NeZero import Mathlib.Algebra.Polynomial.RingDivision import Mathlib.GroupTheory.SpecificGroups.Cyclic import Mathlib.NumberTheory.Divisors import Mathlib.RingTheory.IntegralDomain import Mathlib.Tactic.Zify #align_import ring_theory.roots_of_unity.basic from "leanprover-community/mathlib"@"7fdeecc0d03cd40f7a165e6cf00a4d2286db599f" open scoped Classical Polynomial noncomputable section open Polynomial open Finset variable {M N G R S F : Type*} variable [CommMonoid M] [CommMonoid N] [DivisionCommMonoid G] section rootsOfUnity variable {k l : ℕ+} def rootsOfUnity (k : ℕ+) (M : Type*) [CommMonoid M] : Subgroup Mˣ where carrier := {ζ | ζ ^ (k : ℕ) = 1} one_mem' := one_pow _ mul_mem' _ _ := by simp_all only [Set.mem_setOf_eq, mul_pow, one_mul] inv_mem' _ := by simp_all only [Set.mem_setOf_eq, inv_pow, inv_one] #align roots_of_unity rootsOfUnity @[simp] theorem mem_rootsOfUnity (k : ℕ+) (ζ : Mˣ) : ζ ∈ rootsOfUnity k M ↔ ζ ^ (k : ℕ) = 1 := Iff.rfl #align mem_roots_of_unity mem_rootsOfUnity theorem mem_rootsOfUnity' (k : ℕ+) (ζ : Mˣ) : ζ ∈ rootsOfUnity k M ↔ (ζ : M) ^ (k : ℕ) = 1 := by rw [mem_rootsOfUnity]; norm_cast #align mem_roots_of_unity' mem_rootsOfUnity' @[simp] theorem rootsOfUnity_one (M : Type*) [CommMonoid M] : rootsOfUnity 1 M = ⊥ := by ext; simp theorem rootsOfUnity.coe_injective {n : ℕ+} : Function.Injective (fun x : rootsOfUnity n M ↦ x.val.val) := Units.ext.comp fun _ _ => Subtype.eq #align roots_of_unity.coe_injective rootsOfUnity.coe_injective @[simps! coe_val] def rootsOfUnity.mkOfPowEq (ζ : M) {n : ℕ+} (h : ζ ^ (n : ℕ) = 1) : rootsOfUnity n M := ⟨Units.ofPowEqOne ζ n h n.ne_zero, Units.pow_ofPowEqOne _ _⟩ #align roots_of_unity.mk_of_pow_eq rootsOfUnity.mkOfPowEq #align roots_of_unity.mk_of_pow_eq_coe_coe rootsOfUnity.val_mkOfPowEq_coe @[simp] theorem rootsOfUnity.coe_mkOfPowEq {ζ : M} {n : ℕ+} (h : ζ ^ (n : ℕ) = 1) : ((rootsOfUnity.mkOfPowEq _ h : Mˣ) : M) = ζ := rfl #align roots_of_unity.coe_mk_of_pow_eq rootsOfUnity.coe_mkOfPowEq theorem rootsOfUnity_le_of_dvd (h : k ∣ l) : rootsOfUnity k M ≤ rootsOfUnity l M := by obtain ⟨d, rfl⟩ := h intro ζ h simp_all only [mem_rootsOfUnity, PNat.mul_coe, pow_mul, one_pow] #align roots_of_unity_le_of_dvd rootsOfUnity_le_of_dvd theorem map_rootsOfUnity (f : Mˣ →* Nˣ) (k : ℕ+) : (rootsOfUnity k M).map f ≤ rootsOfUnity k N := by rintro _ ⟨ζ, h, rfl⟩ simp_all only [← map_pow, mem_rootsOfUnity, SetLike.mem_coe, MonoidHom.map_one] #align map_roots_of_unity map_rootsOfUnity @[norm_cast] theorem rootsOfUnity.coe_pow [CommMonoid R] (ζ : rootsOfUnity k R) (m : ℕ) : (((ζ ^ m :) : Rˣ) : R) = ((ζ : Rˣ) : R) ^ m := by rw [Subgroup.coe_pow, Units.val_pow_eq_pow_val] #align roots_of_unity.coe_pow rootsOfUnity.coe_pow @[mk_iff IsPrimitiveRoot.iff_def] structure IsPrimitiveRoot (ζ : M) (k : ℕ) : Prop where pow_eq_one : ζ ^ (k : ℕ) = 1 dvd_of_pow_eq_one : ∀ l : ℕ, ζ ^ l = 1 → k ∣ l #align is_primitive_root IsPrimitiveRoot #align is_primitive_root.iff_def IsPrimitiveRoot.iff_def @[simps!] def IsPrimitiveRoot.toRootsOfUnity {μ : M} {n : ℕ+} (h : IsPrimitiveRoot μ n) : rootsOfUnity n M := rootsOfUnity.mkOfPowEq μ h.pow_eq_one #align is_primitive_root.to_roots_of_unity IsPrimitiveRoot.toRootsOfUnity #align is_primitive_root.coe_to_roots_of_unity_coe IsPrimitiveRoot.val_toRootsOfUnity_coe #align is_primitive_root.coe_inv_to_roots_of_unity_coe IsPrimitiveRoot.val_inv_toRootsOfUnity_coe namespace IsPrimitiveRoot variable {k l : ℕ} theorem mk_of_lt (ζ : M) (hk : 0 < k) (h1 : ζ ^ k = 1) (h : ∀ l : ℕ, 0 < l → l < k → ζ ^ l ≠ 1) : IsPrimitiveRoot ζ k := by refine ⟨h1, fun l hl => ?_⟩ suffices k.gcd l = k by exact this ▸ k.gcd_dvd_right l rw [eq_iff_le_not_lt] refine ⟨Nat.le_of_dvd hk (k.gcd_dvd_left l), ?_⟩ intro h'; apply h _ (Nat.gcd_pos_of_pos_left _ hk) h' exact pow_gcd_eq_one _ h1 hl #align is_primitive_root.mk_of_lt IsPrimitiveRoot.mk_of_lt section CommMonoid variable {ζ : M} {f : F} (h : IsPrimitiveRoot ζ k) @[nontriviality] theorem of_subsingleton [Subsingleton M] (x : M) : IsPrimitiveRoot x 1 := ⟨Subsingleton.elim _ _, fun _ _ => one_dvd _⟩ #align is_primitive_root.of_subsingleton IsPrimitiveRoot.of_subsingleton theorem pow_eq_one_iff_dvd (l : ℕ) : ζ ^ l = 1 ↔ k ∣ l := ⟨h.dvd_of_pow_eq_one l, by rintro ⟨i, rfl⟩; simp only [pow_mul, h.pow_eq_one, one_pow, PNat.mul_coe]⟩ #align is_primitive_root.pow_eq_one_iff_dvd IsPrimitiveRoot.pow_eq_one_iff_dvd theorem isUnit (h : IsPrimitiveRoot ζ k) (h0 : 0 < k) : IsUnit ζ := by apply isUnit_of_mul_eq_one ζ (ζ ^ (k - 1)) rw [← pow_succ', tsub_add_cancel_of_le h0.nat_succ_le, h.pow_eq_one] #align is_primitive_root.is_unit IsPrimitiveRoot.isUnit theorem pow_ne_one_of_pos_of_lt (h0 : 0 < l) (hl : l < k) : ζ ^ l ≠ 1 := mt (Nat.le_of_dvd h0 ∘ h.dvd_of_pow_eq_one _) <| not_le_of_lt hl #align is_primitive_root.pow_ne_one_of_pos_of_lt IsPrimitiveRoot.pow_ne_one_of_pos_of_lt theorem ne_one (hk : 1 < k) : ζ ≠ 1 := h.pow_ne_one_of_pos_of_lt zero_lt_one hk ∘ (pow_one ζ).trans #align is_primitive_root.ne_one IsPrimitiveRoot.ne_one theorem pow_inj (h : IsPrimitiveRoot ζ k) ⦃i j : ℕ⦄ (hi : i < k) (hj : j < k) (H : ζ ^ i = ζ ^ j) : i = j := by wlog hij : i ≤ j generalizing i j · exact (this hj hi H.symm (le_of_not_le hij)).symm apply le_antisymm hij rw [← tsub_eq_zero_iff_le] apply Nat.eq_zero_of_dvd_of_lt _ (lt_of_le_of_lt tsub_le_self hj) apply h.dvd_of_pow_eq_one rw [← ((h.isUnit (lt_of_le_of_lt (Nat.zero_le _) hi)).pow i).mul_left_inj, ← pow_add, tsub_add_cancel_of_le hij, H, one_mul] #align is_primitive_root.pow_inj IsPrimitiveRoot.pow_inj theorem one : IsPrimitiveRoot (1 : M) 1 := { pow_eq_one := pow_one _ dvd_of_pow_eq_one := fun _ _ => one_dvd _ } #align is_primitive_root.one IsPrimitiveRoot.one @[simp] theorem one_right_iff : IsPrimitiveRoot ζ 1 ↔ ζ = 1 := by clear h constructor · intro h; rw [← pow_one ζ, h.pow_eq_one] · rintro rfl; exact one #align is_primitive_root.one_right_iff IsPrimitiveRoot.one_right_iff @[simp] theorem coe_submonoidClass_iff {M B : Type*} [CommMonoid M] [SetLike B M] [SubmonoidClass B M] {N : B} {ζ : N} : IsPrimitiveRoot (ζ : M) k ↔ IsPrimitiveRoot ζ k := by simp_rw [iff_def] norm_cast #align is_primitive_root.coe_submonoid_class_iff IsPrimitiveRoot.coe_submonoidClass_iff @[simp] theorem coe_units_iff {ζ : Mˣ} : IsPrimitiveRoot (ζ : M) k ↔ IsPrimitiveRoot ζ k := by simp only [iff_def, Units.ext_iff, Units.val_pow_eq_pow_val, Units.val_one] #align is_primitive_root.coe_units_iff IsPrimitiveRoot.coe_units_iff lemma isUnit_unit {ζ : M} {n} (hn) (hζ : IsPrimitiveRoot ζ n) : IsPrimitiveRoot (hζ.isUnit hn).unit n := coe_units_iff.mp hζ lemma isUnit_unit' {ζ : G} {n} (hn) (hζ : IsPrimitiveRoot ζ n) : IsPrimitiveRoot (hζ.isUnit hn).unit' n := coe_units_iff.mp hζ -- Porting note `variable` above already contains `(h : IsPrimitiveRoot ζ k)` theorem pow_of_coprime (i : ℕ) (hi : i.Coprime k) : IsPrimitiveRoot (ζ ^ i) k := by by_cases h0 : k = 0 · subst k; simp_all only [pow_one, Nat.coprime_zero_right] rcases h.isUnit (Nat.pos_of_ne_zero h0) with ⟨ζ, rfl⟩ rw [← Units.val_pow_eq_pow_val] rw [coe_units_iff] at h ⊢ refine { pow_eq_one := by rw [← pow_mul', pow_mul, h.pow_eq_one, one_pow] dvd_of_pow_eq_one := ?_ } intro l hl apply h.dvd_of_pow_eq_one rw [← pow_one ζ, ← zpow_natCast ζ, ← hi.gcd_eq_one, Nat.gcd_eq_gcd_ab, zpow_add, mul_pow, ← zpow_natCast, ← zpow_mul, mul_right_comm] simp only [zpow_mul, hl, h.pow_eq_one, one_zpow, one_pow, one_mul, zpow_natCast] #align is_primitive_root.pow_of_coprime IsPrimitiveRoot.pow_of_coprime theorem pow_of_prime (h : IsPrimitiveRoot ζ k) {p : ℕ} (hprime : Nat.Prime p) (hdiv : ¬p ∣ k) : IsPrimitiveRoot (ζ ^ p) k := h.pow_of_coprime p (hprime.coprime_iff_not_dvd.2 hdiv) #align is_primitive_root.pow_of_prime IsPrimitiveRoot.pow_of_prime theorem pow_iff_coprime (h : IsPrimitiveRoot ζ k) (h0 : 0 < k) (i : ℕ) : IsPrimitiveRoot (ζ ^ i) k ↔ i.Coprime k := by refine ⟨?_, h.pow_of_coprime i⟩ intro hi obtain ⟨a, ha⟩ := i.gcd_dvd_left k obtain ⟨b, hb⟩ := i.gcd_dvd_right k suffices b = k by -- Porting note: was `rwa [this, ← one_mul k, mul_left_inj' h0.ne', eq_comm] at hb` rw [this, eq_comm, Nat.mul_left_eq_self_iff h0] at hb rwa [Nat.Coprime] rw [ha] at hi rw [mul_comm] at hb apply Nat.dvd_antisymm ⟨i.gcd k, hb⟩ (hi.dvd_of_pow_eq_one b _) rw [← pow_mul', ← mul_assoc, ← hb, pow_mul, h.pow_eq_one, one_pow] #align is_primitive_root.pow_iff_coprime IsPrimitiveRoot.pow_iff_coprime protected theorem orderOf (ζ : M) : IsPrimitiveRoot ζ (orderOf ζ) := ⟨pow_orderOf_eq_one ζ, fun _ => orderOf_dvd_of_pow_eq_one⟩ #align is_primitive_root.order_of IsPrimitiveRoot.orderOf theorem unique {ζ : M} (hk : IsPrimitiveRoot ζ k) (hl : IsPrimitiveRoot ζ l) : k = l := Nat.dvd_antisymm (hk.2 _ hl.1) (hl.2 _ hk.1) #align is_primitive_root.unique IsPrimitiveRoot.unique theorem eq_orderOf : k = orderOf ζ := h.unique (IsPrimitiveRoot.orderOf ζ) #align is_primitive_root.eq_order_of IsPrimitiveRoot.eq_orderOf protected theorem iff (hk : 0 < k) : IsPrimitiveRoot ζ k ↔ ζ ^ k = 1 ∧ ∀ l : ℕ, 0 < l → l < k → ζ ^ l ≠ 1 := by refine ⟨fun h => ⟨h.pow_eq_one, fun l hl' hl => ?_⟩, fun ⟨hζ, hl⟩ => IsPrimitiveRoot.mk_of_lt ζ hk hζ hl⟩ rw [h.eq_orderOf] at hl exact pow_ne_one_of_lt_orderOf' hl'.ne' hl #align is_primitive_root.iff IsPrimitiveRoot.iff protected theorem not_iff : ¬IsPrimitiveRoot ζ k ↔ orderOf ζ ≠ k := ⟨fun h hk => h <| hk ▸ IsPrimitiveRoot.orderOf ζ, fun h hk => h.symm <| hk.unique <| IsPrimitiveRoot.orderOf ζ⟩ #align is_primitive_root.not_iff IsPrimitiveRoot.not_iff theorem pow_mul_pow_lcm {ζ' : M} {k' : ℕ} (hζ : IsPrimitiveRoot ζ k) (hζ' : IsPrimitiveRoot ζ' k') (hk : k ≠ 0) (hk' : k' ≠ 0) : IsPrimitiveRoot (ζ ^ (k / Nat.factorizationLCMLeft k k') * ζ' ^ (k' / Nat.factorizationLCMRight k k')) (Nat.lcm k k') := by convert IsPrimitiveRoot.orderOf _ convert ((Commute.all ζ ζ').orderOf_mul_pow_eq_lcm (by simpa [← hζ.eq_orderOf]) (by simpa [← hζ'.eq_orderOf])).symm using 2 all_goals simp [hζ.eq_orderOf, hζ'.eq_orderOf] theorem pow_of_dvd (h : IsPrimitiveRoot ζ k) {p : ℕ} (hp : p ≠ 0) (hdiv : p ∣ k) : IsPrimitiveRoot (ζ ^ p) (k / p) := by suffices orderOf (ζ ^ p) = k / p by exact this ▸ IsPrimitiveRoot.orderOf (ζ ^ p) rw [orderOf_pow' _ hp, ← eq_orderOf h, Nat.gcd_eq_right hdiv] #align is_primitive_root.pow_of_dvd IsPrimitiveRoot.pow_of_dvd protected theorem mem_rootsOfUnity {ζ : Mˣ} {n : ℕ+} (h : IsPrimitiveRoot ζ n) : ζ ∈ rootsOfUnity n M := h.pow_eq_one #align is_primitive_root.mem_roots_of_unity IsPrimitiveRoot.mem_rootsOfUnity theorem pow {n : ℕ} {a b : ℕ} (hn : 0 < n) (h : IsPrimitiveRoot ζ n) (hprod : n = a * b) : IsPrimitiveRoot (ζ ^ a) b := by subst n simp only [iff_def, ← pow_mul, h.pow_eq_one, eq_self_iff_true, true_and_iff] intro l hl -- Porting note: was `by rintro rfl; simpa only [Nat.not_lt_zero, zero_mul] using hn` have ha0 : a ≠ 0 := left_ne_zero_of_mul hn.ne' rw [← mul_dvd_mul_iff_left ha0] exact h.dvd_of_pow_eq_one _ hl #align is_primitive_root.pow IsPrimitiveRoot.pow lemma injOn_pow {n : ℕ} {ζ : M} (hζ : IsPrimitiveRoot ζ n) : Set.InjOn (ζ ^ ·) (Finset.range n) := by obtain (rfl|hn) := n.eq_zero_or_pos; · simp intros i hi j hj e rw [Finset.coe_range, Set.mem_Iio] at hi hj have : (hζ.isUnit hn).unit ^ i = (hζ.isUnit hn).unit ^ j := Units.ext (by simpa using e) rw [pow_inj_mod, ← orderOf_injective ⟨⟨Units.val, Units.val_one⟩, Units.val_mul⟩ Units.ext (hζ.isUnit hn).unit] at this simpa [← hζ.eq_orderOf, Nat.mod_eq_of_lt, hi, hj] using this section IsDomain variable [CommRing R] variable {ζ : Rˣ} (h : IsPrimitiveRoot ζ k)
Mathlib/RingTheory/RootsOfUnity/Basic.lean
688
691
theorem eq_neg_one_of_two_right [NoZeroDivisors R] {ζ : R} (h : IsPrimitiveRoot ζ 2) : ζ = -1 := by
apply (eq_or_eq_neg_of_sq_eq_sq ζ 1 _).resolve_left · rw [← pow_one ζ]; apply h.pow_ne_one_of_pos_of_lt <;> decide · simp only [h.pow_eq_one, one_pow]
import Mathlib.SetTheory.Game.State #align_import set_theory.game.domineering from "leanprover-community/mathlib"@"b134b2f5cf6dd25d4bbfd3c498b6e36c11a17225" namespace SetTheory namespace PGame namespace Domineering open Function @[simps!] def shiftUp : ℤ × ℤ ≃ ℤ × ℤ := (Equiv.refl ℤ).prodCongr (Equiv.addRight (1 : ℤ)) #align pgame.domineering.shift_up SetTheory.PGame.Domineering.shiftUp @[simps!] def shiftRight : ℤ × ℤ ≃ ℤ × ℤ := (Equiv.addRight (1 : ℤ)).prodCongr (Equiv.refl ℤ) #align pgame.domineering.shift_right SetTheory.PGame.Domineering.shiftRight -- Porting note: reducibility cannot be `local`. For now there are no dependents of this file so -- being globally reducible is fine. abbrev Board := Finset (ℤ × ℤ) #align pgame.domineering.board SetTheory.PGame.Domineering.Board def left (b : Board) : Finset (ℤ × ℤ) := b ∩ b.map shiftUp #align pgame.domineering.left SetTheory.PGame.Domineering.left def right (b : Board) : Finset (ℤ × ℤ) := b ∩ b.map shiftRight #align pgame.domineering.right SetTheory.PGame.Domineering.right theorem mem_left {b : Board} (x : ℤ × ℤ) : x ∈ left b ↔ x ∈ b ∧ (x.1, x.2 - 1) ∈ b := Finset.mem_inter.trans (and_congr Iff.rfl Finset.mem_map_equiv) #align pgame.domineering.mem_left SetTheory.PGame.Domineering.mem_left theorem mem_right {b : Board} (x : ℤ × ℤ) : x ∈ right b ↔ x ∈ b ∧ (x.1 - 1, x.2) ∈ b := Finset.mem_inter.trans (and_congr Iff.rfl Finset.mem_map_equiv) #align pgame.domineering.mem_right SetTheory.PGame.Domineering.mem_right def moveLeft (b : Board) (m : ℤ × ℤ) : Board := (b.erase m).erase (m.1, m.2 - 1) #align pgame.domineering.move_left SetTheory.PGame.Domineering.moveLeft def moveRight (b : Board) (m : ℤ × ℤ) : Board := (b.erase m).erase (m.1 - 1, m.2) #align pgame.domineering.move_right SetTheory.PGame.Domineering.moveRight theorem fst_pred_mem_erase_of_mem_right {b : Board} {m : ℤ × ℤ} (h : m ∈ right b) : (m.1 - 1, m.2) ∈ b.erase m := by rw [mem_right] at h apply Finset.mem_erase_of_ne_of_mem _ h.2 exact ne_of_apply_ne Prod.fst (pred_ne_self m.1) #align pgame.domineering.fst_pred_mem_erase_of_mem_right SetTheory.PGame.Domineering.fst_pred_mem_erase_of_mem_right theorem snd_pred_mem_erase_of_mem_left {b : Board} {m : ℤ × ℤ} (h : m ∈ left b) : (m.1, m.2 - 1) ∈ b.erase m := by rw [mem_left] at h apply Finset.mem_erase_of_ne_of_mem _ h.2 exact ne_of_apply_ne Prod.snd (pred_ne_self m.2) #align pgame.domineering.snd_pred_mem_erase_of_mem_left SetTheory.PGame.Domineering.snd_pred_mem_erase_of_mem_left theorem card_of_mem_left {b : Board} {m : ℤ × ℤ} (h : m ∈ left b) : 2 ≤ Finset.card b := by have w₁ : m ∈ b := (Finset.mem_inter.1 h).1 have w₂ : (m.1, m.2 - 1) ∈ b.erase m := snd_pred_mem_erase_of_mem_left h have i₁ := Finset.card_erase_lt_of_mem w₁ have i₂ := Nat.lt_of_le_of_lt (Nat.zero_le _) (Finset.card_erase_lt_of_mem w₂) exact Nat.lt_of_le_of_lt i₂ i₁ #align pgame.domineering.card_of_mem_left SetTheory.PGame.Domineering.card_of_mem_left theorem card_of_mem_right {b : Board} {m : ℤ × ℤ} (h : m ∈ right b) : 2 ≤ Finset.card b := by have w₁ : m ∈ b := (Finset.mem_inter.1 h).1 have w₂ := fst_pred_mem_erase_of_mem_right h have i₁ := Finset.card_erase_lt_of_mem w₁ have i₂ := Nat.lt_of_le_of_lt (Nat.zero_le _) (Finset.card_erase_lt_of_mem w₂) exact Nat.lt_of_le_of_lt i₂ i₁ #align pgame.domineering.card_of_mem_right SetTheory.PGame.Domineering.card_of_mem_right theorem moveLeft_card {b : Board} {m : ℤ × ℤ} (h : m ∈ left b) : Finset.card (moveLeft b m) + 2 = Finset.card b := by dsimp [moveLeft] rw [Finset.card_erase_of_mem (snd_pred_mem_erase_of_mem_left h)] rw [Finset.card_erase_of_mem (Finset.mem_of_mem_inter_left h)] exact tsub_add_cancel_of_le (card_of_mem_left h) #align pgame.domineering.move_left_card SetTheory.PGame.Domineering.moveLeft_card theorem moveRight_card {b : Board} {m : ℤ × ℤ} (h : m ∈ right b) : Finset.card (moveRight b m) + 2 = Finset.card b := by dsimp [moveRight] rw [Finset.card_erase_of_mem (fst_pred_mem_erase_of_mem_right h)] rw [Finset.card_erase_of_mem (Finset.mem_of_mem_inter_left h)] exact tsub_add_cancel_of_le (card_of_mem_right h) #align pgame.domineering.move_right_card SetTheory.PGame.Domineering.moveRight_card
Mathlib/SetTheory/Game/Domineering.lean
125
126
theorem moveLeft_smaller {b : Board} {m : ℤ × ℤ} (h : m ∈ left b) : Finset.card (moveLeft b m) / 2 < Finset.card b / 2 := by
simp [← moveLeft_card h, lt_add_one]
import Mathlib.Analysis.Convex.Side import Mathlib.Geometry.Euclidean.Angle.Oriented.Rotation import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine #align_import geometry.euclidean.angle.oriented.affine from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" noncomputable section open FiniteDimensional Complex open scoped Affine EuclideanGeometry Real RealInnerProductSpace ComplexConjugate namespace EuclideanGeometry variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P] [hd2 : Fact (finrank ℝ V = 2)] [Module.Oriented ℝ V (Fin 2)] abbrev o := @Module.Oriented.positiveOrientation def oangle (p₁ p₂ p₃ : P) : Real.Angle := o.oangle (p₁ -ᵥ p₂) (p₃ -ᵥ p₂) #align euclidean_geometry.oangle EuclideanGeometry.oangle @[inherit_doc] scoped notation "∡" => EuclideanGeometry.oangle theorem continuousAt_oangle {x : P × P × P} (hx12 : x.1 ≠ x.2.1) (hx32 : x.2.2 ≠ x.2.1) : ContinuousAt (fun y : P × P × P => ∡ y.1 y.2.1 y.2.2) x := by let f : P × P × P → V × V := fun y => (y.1 -ᵥ y.2.1, y.2.2 -ᵥ y.2.1) have hf1 : (f x).1 ≠ 0 := by simp [hx12] have hf2 : (f x).2 ≠ 0 := by simp [hx32] exact (o.continuousAt_oangle hf1 hf2).comp ((continuous_fst.vsub continuous_snd.fst).prod_mk (continuous_snd.snd.vsub continuous_snd.fst)).continuousAt #align euclidean_geometry.continuous_at_oangle EuclideanGeometry.continuousAt_oangle @[simp] theorem oangle_self_left (p₁ p₂ : P) : ∡ p₁ p₁ p₂ = 0 := by simp [oangle] #align euclidean_geometry.oangle_self_left EuclideanGeometry.oangle_self_left @[simp] theorem oangle_self_right (p₁ p₂ : P) : ∡ p₁ p₂ p₂ = 0 := by simp [oangle] #align euclidean_geometry.oangle_self_right EuclideanGeometry.oangle_self_right @[simp] theorem oangle_self_left_right (p₁ p₂ : P) : ∡ p₁ p₂ p₁ = 0 := o.oangle_self _ #align euclidean_geometry.oangle_self_left_right EuclideanGeometry.oangle_self_left_right theorem left_ne_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₁ ≠ p₂ := by rw [← @vsub_ne_zero V]; exact o.left_ne_zero_of_oangle_ne_zero h #align euclidean_geometry.left_ne_of_oangle_ne_zero EuclideanGeometry.left_ne_of_oangle_ne_zero theorem right_ne_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₃ ≠ p₂ := by rw [← @vsub_ne_zero V]; exact o.right_ne_zero_of_oangle_ne_zero h #align euclidean_geometry.right_ne_of_oangle_ne_zero EuclideanGeometry.right_ne_of_oangle_ne_zero theorem left_ne_right_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₁ ≠ p₃ := by rw [← (vsub_left_injective p₂).ne_iff]; exact o.ne_of_oangle_ne_zero h #align euclidean_geometry.left_ne_right_of_oangle_ne_zero EuclideanGeometry.left_ne_right_of_oangle_ne_zero theorem left_ne_of_oangle_eq_pi {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = π) : p₁ ≠ p₂ := left_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_of_oangle_eq_pi EuclideanGeometry.left_ne_of_oangle_eq_pi theorem right_ne_of_oangle_eq_pi {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = π) : p₃ ≠ p₂ := right_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.right_ne_of_oangle_eq_pi EuclideanGeometry.right_ne_of_oangle_eq_pi theorem left_ne_right_of_oangle_eq_pi {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = π) : p₁ ≠ p₃ := left_ne_right_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_eq_pi EuclideanGeometry.left_ne_right_of_oangle_eq_pi theorem left_ne_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (π / 2 : ℝ)) : p₁ ≠ p₂ := left_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_of_oangle_eq_pi_div_two EuclideanGeometry.left_ne_of_oangle_eq_pi_div_two theorem right_ne_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (π / 2 : ℝ)) : p₃ ≠ p₂ := right_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.right_ne_of_oangle_eq_pi_div_two EuclideanGeometry.right_ne_of_oangle_eq_pi_div_two theorem left_ne_right_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (π / 2 : ℝ)) : p₁ ≠ p₃ := left_ne_right_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_eq_pi_div_two EuclideanGeometry.left_ne_right_of_oangle_eq_pi_div_two theorem left_ne_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (-π / 2 : ℝ)) : p₁ ≠ p₂ := left_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_of_oangle_eq_neg_pi_div_two EuclideanGeometry.left_ne_of_oangle_eq_neg_pi_div_two theorem right_ne_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (-π / 2 : ℝ)) : p₃ ≠ p₂ := right_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.right_ne_of_oangle_eq_neg_pi_div_two EuclideanGeometry.right_ne_of_oangle_eq_neg_pi_div_two theorem left_ne_right_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (-π / 2 : ℝ)) : p₁ ≠ p₃ := left_ne_right_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_eq_neg_pi_div_two EuclideanGeometry.left_ne_right_of_oangle_eq_neg_pi_div_two theorem left_ne_of_oangle_sign_ne_zero {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign ≠ 0) : p₁ ≠ p₂ := left_ne_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align euclidean_geometry.left_ne_of_oangle_sign_ne_zero EuclideanGeometry.left_ne_of_oangle_sign_ne_zero theorem right_ne_of_oangle_sign_ne_zero {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign ≠ 0) : p₃ ≠ p₂ := right_ne_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align euclidean_geometry.right_ne_of_oangle_sign_ne_zero EuclideanGeometry.right_ne_of_oangle_sign_ne_zero theorem left_ne_right_of_oangle_sign_ne_zero {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign ≠ 0) : p₁ ≠ p₃ := left_ne_right_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align euclidean_geometry.left_ne_right_of_oangle_sign_ne_zero EuclideanGeometry.left_ne_right_of_oangle_sign_ne_zero theorem left_ne_of_oangle_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) : p₁ ≠ p₂ := left_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.left_ne_of_oangle_sign_eq_one EuclideanGeometry.left_ne_of_oangle_sign_eq_one theorem right_ne_of_oangle_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) : p₃ ≠ p₂ := right_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.right_ne_of_oangle_sign_eq_one EuclideanGeometry.right_ne_of_oangle_sign_eq_one theorem left_ne_right_of_oangle_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) : p₁ ≠ p₃ := left_ne_right_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_sign_eq_one EuclideanGeometry.left_ne_right_of_oangle_sign_eq_one theorem left_ne_of_oangle_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) : p₁ ≠ p₂ := left_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.left_ne_of_oangle_sign_eq_neg_one EuclideanGeometry.left_ne_of_oangle_sign_eq_neg_one theorem right_ne_of_oangle_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) : p₃ ≠ p₂ := right_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.right_ne_of_oangle_sign_eq_neg_one EuclideanGeometry.right_ne_of_oangle_sign_eq_neg_one theorem left_ne_right_of_oangle_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) : p₁ ≠ p₃ := left_ne_right_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_sign_eq_neg_one EuclideanGeometry.left_ne_right_of_oangle_sign_eq_neg_one theorem oangle_rev (p₁ p₂ p₃ : P) : ∡ p₃ p₂ p₁ = -∡ p₁ p₂ p₃ := o.oangle_rev _ _ #align euclidean_geometry.oangle_rev EuclideanGeometry.oangle_rev @[simp] theorem oangle_add_oangle_rev (p₁ p₂ p₃ : P) : ∡ p₁ p₂ p₃ + ∡ p₃ p₂ p₁ = 0 := o.oangle_add_oangle_rev _ _ #align euclidean_geometry.oangle_add_oangle_rev EuclideanGeometry.oangle_add_oangle_rev theorem oangle_eq_zero_iff_oangle_rev_eq_zero {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = 0 ↔ ∡ p₃ p₂ p₁ = 0 := o.oangle_eq_zero_iff_oangle_rev_eq_zero #align euclidean_geometry.oangle_eq_zero_iff_oangle_rev_eq_zero EuclideanGeometry.oangle_eq_zero_iff_oangle_rev_eq_zero theorem oangle_eq_pi_iff_oangle_rev_eq_pi {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = π ↔ ∡ p₃ p₂ p₁ = π := o.oangle_eq_pi_iff_oangle_rev_eq_pi #align euclidean_geometry.oangle_eq_pi_iff_oangle_rev_eq_pi EuclideanGeometry.oangle_eq_pi_iff_oangle_rev_eq_pi theorem oangle_ne_zero_and_ne_pi_iff_affineIndependent {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ ≠ 0 ∧ ∡ p₁ p₂ p₃ ≠ π ↔ AffineIndependent ℝ ![p₁, p₂, p₃] := by rw [oangle, o.oangle_ne_zero_and_ne_pi_iff_linearIndependent, affineIndependent_iff_linearIndependent_vsub ℝ _ (1 : Fin 3), ← linearIndependent_equiv (finSuccAboveEquiv (1 : Fin 3)).toEquiv] convert Iff.rfl ext i fin_cases i <;> rfl #align euclidean_geometry.oangle_ne_zero_and_ne_pi_iff_affine_independent EuclideanGeometry.oangle_ne_zero_and_ne_pi_iff_affineIndependent theorem oangle_eq_zero_or_eq_pi_iff_collinear {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = 0 ∨ ∡ p₁ p₂ p₃ = π ↔ Collinear ℝ ({p₁, p₂, p₃} : Set P) := by rw [← not_iff_not, not_or, oangle_ne_zero_and_ne_pi_iff_affineIndependent, affineIndependent_iff_not_collinear_set] #align euclidean_geometry.oangle_eq_zero_or_eq_pi_iff_collinear EuclideanGeometry.oangle_eq_zero_or_eq_pi_iff_collinear theorem oangle_sign_eq_zero_iff_collinear {p₁ p₂ p₃ : P} : (∡ p₁ p₂ p₃).sign = 0 ↔ Collinear ℝ ({p₁, p₂, p₃} : Set P) := by rw [Real.Angle.sign_eq_zero_iff, oangle_eq_zero_or_eq_pi_iff_collinear] theorem affineIndependent_iff_of_two_zsmul_oangle_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (h : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆) : AffineIndependent ℝ ![p₁, p₂, p₃] ↔ AffineIndependent ℝ ![p₄, p₅, p₆] := by simp_rw [← oangle_ne_zero_and_ne_pi_iff_affineIndependent, ← Real.Angle.two_zsmul_ne_zero_iff, h] #align euclidean_geometry.affine_independent_iff_of_two_zsmul_oangle_eq EuclideanGeometry.affineIndependent_iff_of_two_zsmul_oangle_eq theorem collinear_iff_of_two_zsmul_oangle_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (h : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆) : Collinear ℝ ({p₁, p₂, p₃} : Set P) ↔ Collinear ℝ ({p₄, p₅, p₆} : Set P) := by simp_rw [← oangle_eq_zero_or_eq_pi_iff_collinear, ← Real.Angle.two_zsmul_eq_zero_iff, h] #align euclidean_geometry.collinear_iff_of_two_zsmul_oangle_eq EuclideanGeometry.collinear_iff_of_two_zsmul_oangle_eq
Mathlib/Geometry/Euclidean/Angle/Oriented/Affine.lean
258
263
theorem two_zsmul_oangle_of_vectorSpan_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (h₁₂₄₅ : vectorSpan ℝ ({p₁, p₂} : Set P) = vectorSpan ℝ ({p₄, p₅} : Set P)) (h₃₂₆₅ : vectorSpan ℝ ({p₃, p₂} : Set P) = vectorSpan ℝ ({p₆, p₅} : Set P)) : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆ := by
simp_rw [vectorSpan_pair] at h₁₂₄₅ h₃₂₆₅ exact o.two_zsmul_oangle_of_span_eq_of_span_eq h₁₂₄₅ h₃₂₆₅
import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics import Mathlib.NumberTheory.Liouville.Basic import Mathlib.Topology.Instances.Irrational #align_import number_theory.liouville.liouville_with from "leanprover-community/mathlib"@"0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8" open Filter Metric Real Set open scoped Filter Topology def LiouvilleWith (p x : ℝ) : Prop := ∃ C, ∃ᶠ n : ℕ in atTop, ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < C / n ^ p #align liouville_with LiouvilleWith theorem liouvilleWith_one (x : ℝ) : LiouvilleWith 1 x := by use 2 refine ((eventually_gt_atTop 0).mono fun n hn => ?_).frequently have hn' : (0 : ℝ) < n := by simpa have : x < ↑(⌊x * ↑n⌋ + 1) / ↑n := by rw [lt_div_iff hn', Int.cast_add, Int.cast_one]; exact Int.lt_floor_add_one _ refine ⟨⌊x * n⌋ + 1, this.ne, ?_⟩ rw [abs_sub_comm, abs_of_pos (sub_pos.2 this), rpow_one, sub_lt_iff_lt_add', add_div_eq_mul_add_div _ _ hn'.ne'] gcongr calc _ ≤ x * n + 1 := by push_cast; gcongr; apply Int.floor_le _ < x * n + 2 := by linarith #align liouville_with_one liouvilleWith_one namespace LiouvilleWith variable {p q x y : ℝ} {r : ℚ} {m : ℤ} {n : ℕ} theorem exists_pos (h : LiouvilleWith p x) : ∃ (C : ℝ) (_h₀ : 0 < C), ∃ᶠ n : ℕ in atTop, 1 ≤ n ∧ ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < C / n ^ p := by rcases h with ⟨C, hC⟩ refine ⟨max C 1, zero_lt_one.trans_le <| le_max_right _ _, ?_⟩ refine ((eventually_ge_atTop 1).and_frequently hC).mono ?_ rintro n ⟨hle, m, hne, hlt⟩ refine ⟨hle, m, hne, hlt.trans_le ?_⟩ gcongr apply le_max_left #align liouville_with.exists_pos LiouvilleWith.exists_pos theorem mono (h : LiouvilleWith p x) (hle : q ≤ p) : LiouvilleWith q x := by rcases h.exists_pos with ⟨C, hC₀, hC⟩ refine ⟨C, hC.mono ?_⟩; rintro n ⟨hn, m, hne, hlt⟩ refine ⟨m, hne, hlt.trans_le <| ?_⟩ gcongr exact_mod_cast hn #align liouville_with.mono LiouvilleWith.mono theorem frequently_lt_rpow_neg (h : LiouvilleWith p x) (hlt : q < p) : ∃ᶠ n : ℕ in atTop, ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < n ^ (-q) := by rcases h.exists_pos with ⟨C, _hC₀, hC⟩ have : ∀ᶠ n : ℕ in atTop, C < n ^ (p - q) := by simpa only [(· ∘ ·), neg_sub, one_div] using ((tendsto_rpow_atTop (sub_pos.2 hlt)).comp tendsto_natCast_atTop_atTop).eventually (eventually_gt_atTop C) refine (this.and_frequently hC).mono ?_ rintro n ⟨hnC, hn, m, hne, hlt⟩ replace hn : (0 : ℝ) < n := Nat.cast_pos.2 hn refine ⟨m, hne, hlt.trans <| (div_lt_iff <| rpow_pos_of_pos hn _).2 ?_⟩ rwa [mul_comm, ← rpow_add hn, ← sub_eq_add_neg] #align liouville_with.frequently_lt_rpow_neg LiouvilleWith.frequently_lt_rpow_neg theorem mul_rat (h : LiouvilleWith p x) (hr : r ≠ 0) : LiouvilleWith p (x * r) := by rcases h.exists_pos with ⟨C, _hC₀, hC⟩ refine ⟨r.den ^ p * (|r| * C), (tendsto_id.nsmul_atTop r.pos).frequently (hC.mono ?_)⟩ rintro n ⟨_hn, m, hne, hlt⟩ have A : (↑(r.num * m) : ℝ) / ↑(r.den • id n) = m / n * r := by simp [← div_mul_div_comm, ← r.cast_def, mul_comm] refine ⟨r.num * m, ?_, ?_⟩ · rw [A]; simp [hne, hr] · rw [A, ← sub_mul, abs_mul] simp only [smul_eq_mul, id, Nat.cast_mul] calc _ < C / ↑n ^ p * |↑r| := by gcongr _ = ↑r.den ^ p * (↑|r| * C) / (↑r.den * ↑n) ^ p := ?_ rw [mul_rpow, mul_div_mul_left, mul_comm, mul_div_assoc] · simp only [Rat.cast_abs, le_refl] all_goals positivity #align liouville_with.mul_rat LiouvilleWith.mul_rat theorem mul_rat_iff (hr : r ≠ 0) : LiouvilleWith p (x * r) ↔ LiouvilleWith p x := ⟨fun h => by simpa only [mul_assoc, ← Rat.cast_mul, mul_inv_cancel hr, Rat.cast_one, mul_one] using h.mul_rat (inv_ne_zero hr), fun h => h.mul_rat hr⟩ #align liouville_with.mul_rat_iff LiouvilleWith.mul_rat_iff theorem rat_mul_iff (hr : r ≠ 0) : LiouvilleWith p (r * x) ↔ LiouvilleWith p x := by rw [mul_comm, mul_rat_iff hr] #align liouville_with.rat_mul_iff LiouvilleWith.rat_mul_iff theorem rat_mul (h : LiouvilleWith p x) (hr : r ≠ 0) : LiouvilleWith p (r * x) := (rat_mul_iff hr).2 h #align liouville_with.rat_mul LiouvilleWith.rat_mul theorem mul_int_iff (hm : m ≠ 0) : LiouvilleWith p (x * m) ↔ LiouvilleWith p x := by rw [← Rat.cast_intCast, mul_rat_iff (Int.cast_ne_zero.2 hm)] #align liouville_with.mul_int_iff LiouvilleWith.mul_int_iff theorem mul_int (h : LiouvilleWith p x) (hm : m ≠ 0) : LiouvilleWith p (x * m) := (mul_int_iff hm).2 h #align liouville_with.mul_int LiouvilleWith.mul_int theorem int_mul_iff (hm : m ≠ 0) : LiouvilleWith p (m * x) ↔ LiouvilleWith p x := by rw [mul_comm, mul_int_iff hm] #align liouville_with.int_mul_iff LiouvilleWith.int_mul_iff theorem int_mul (h : LiouvilleWith p x) (hm : m ≠ 0) : LiouvilleWith p (m * x) := (int_mul_iff hm).2 h #align liouville_with.int_mul LiouvilleWith.int_mul
Mathlib/NumberTheory/Liouville/LiouvilleWith.lean
166
167
theorem mul_nat_iff (hn : n ≠ 0) : LiouvilleWith p (x * n) ↔ LiouvilleWith p x := by
rw [← Rat.cast_natCast, mul_rat_iff (Nat.cast_ne_zero.2 hn)]
import Mathlib.ModelTheory.Syntax import Mathlib.ModelTheory.Semantics import Mathlib.Algebra.Ring.Equiv variable {α : Type*} namespace FirstOrder open FirstOrder inductive ringFunc : ℕ → Type | add : ringFunc 2 | mul : ringFunc 2 | neg : ringFunc 1 | zero : ringFunc 0 | one : ringFunc 0 deriving DecidableEq def Language.ring : Language := { Functions := ringFunc Relations := fun _ => Empty } namespace Ring open ringFunc Language instance (n : ℕ) : DecidableEq (Language.ring.Functions n) := by dsimp [Language.ring]; infer_instance instance (n : ℕ) : DecidableEq (Language.ring.Relations n) := by dsimp [Language.ring]; infer_instance abbrev addFunc : Language.ring.Functions 2 := add abbrev mulFunc : Language.ring.Functions 2 := mul abbrev negFunc : Language.ring.Functions 1 := neg abbrev zeroFunc : Language.ring.Functions 0 := zero abbrev oneFunc : Language.ring.Functions 0 := one instance (α : Type*) : Zero (Language.ring.Term α) := { zero := Constants.term zeroFunc } theorem zero_def (α : Type*) : (0 : Language.ring.Term α) = Constants.term zeroFunc := rfl instance (α : Type*) : One (Language.ring.Term α) := { one := Constants.term oneFunc } theorem one_def (α : Type*) : (1 : Language.ring.Term α) = Constants.term oneFunc := rfl instance (α : Type*) : Add (Language.ring.Term α) := { add := addFunc.apply₂ } theorem add_def (α : Type*) (t₁ t₂ : Language.ring.Term α) : t₁ + t₂ = addFunc.apply₂ t₁ t₂ := rfl instance (α : Type*) : Mul (Language.ring.Term α) := { mul := mulFunc.apply₂ } theorem mul_def (α : Type*) (t₁ t₂ : Language.ring.Term α) : t₁ * t₂ = mulFunc.apply₂ t₁ t₂ := rfl instance (α : Type*) : Neg (Language.ring.Term α) := { neg := negFunc.apply₁ } theorem neg_def (α : Type*) (t : Language.ring.Term α) : -t = negFunc.apply₁ t := rfl instance : Fintype Language.ring.Symbols := ⟨⟨Multiset.ofList [Sum.inl ⟨2, .add⟩, Sum.inl ⟨2, .mul⟩, Sum.inl ⟨1, .neg⟩, Sum.inl ⟨0, .zero⟩, Sum.inl ⟨0, .one⟩], by dsimp [Language.Symbols]; decide⟩, by intro x dsimp [Language.Symbols] rcases x with ⟨_, f⟩ | ⟨_, f⟩ · cases f <;> decide · cases f ⟩ @[simp] theorem card_ring : card Language.ring = 5 := by have : Fintype.card Language.ring.Symbols = 5 := rfl simp [Language.card, this] open Language ring Structure class CompatibleRing (R : Type*) [Add R] [Mul R] [Neg R] [One R] [Zero R] extends Language.ring.Structure R where funMap_add : ∀ x, funMap addFunc x = x 0 + x 1 funMap_mul : ∀ x, funMap mulFunc x = x 0 * x 1 funMap_neg : ∀ x, funMap negFunc x = -x 0 funMap_zero : ∀ x, funMap (zeroFunc : Language.ring.Constants) x = 0 funMap_one : ∀ x, funMap (oneFunc : Language.ring.Constants) x = 1 open CompatibleRing attribute [simp] funMap_add funMap_mul funMap_neg funMap_zero funMap_one section variable {R : Type*} [Add R] [Mul R] [Neg R] [One R] [Zero R] [CompatibleRing R] @[simp]
Mathlib/ModelTheory/Algebra/Ring/Basic.lean
180
182
theorem realize_add (x y : ring.Term α) (v : α → R) : Term.realize v (x + y) = Term.realize v x + Term.realize v y := by
simp [add_def, funMap_add]
import Mathlib.SetTheory.Ordinal.Arithmetic #align_import set_theory.ordinal.exponential from "leanprover-community/mathlib"@"b67044ba53af18680e1dd246861d9584e968495d" noncomputable section open Function Cardinal Set Equiv Order open scoped Classical open Cardinal Ordinal universe u v w namespace Ordinal instance pow : Pow Ordinal Ordinal := ⟨fun a b => if a = 0 then 1 - b else limitRecOn b 1 (fun _ IH => IH * a) fun b _ => bsup.{u, u} b⟩ -- Porting note: Ambiguous notations. -- local infixr:0 "^" => @Pow.pow Ordinal Ordinal Ordinal.instPowOrdinalOrdinal theorem opow_def (a b : Ordinal) : a ^ b = if a = 0 then 1 - b else limitRecOn b 1 (fun _ IH => IH * a) fun b _ => bsup.{u, u} b := rfl #align ordinal.opow_def Ordinal.opow_def -- Porting note: `if_pos rfl` → `if_true` theorem zero_opow' (a : Ordinal) : 0 ^ a = 1 - a := by simp only [opow_def, if_true] #align ordinal.zero_opow' Ordinal.zero_opow' @[simp] theorem zero_opow {a : Ordinal} (a0 : a ≠ 0) : (0 : Ordinal) ^ a = 0 := by rwa [zero_opow', Ordinal.sub_eq_zero_iff_le, one_le_iff_ne_zero] #align ordinal.zero_opow Ordinal.zero_opow @[simp] theorem opow_zero (a : Ordinal) : a ^ (0 : Ordinal) = 1 := by by_cases h : a = 0 · simp only [opow_def, if_pos h, sub_zero] · simp only [opow_def, if_neg h, limitRecOn_zero] #align ordinal.opow_zero Ordinal.opow_zero @[simp] theorem opow_succ (a b : Ordinal) : a ^ succ b = a ^ b * a := if h : a = 0 then by subst a; simp only [zero_opow (succ_ne_zero _), mul_zero] else by simp only [opow_def, limitRecOn_succ, if_neg h] #align ordinal.opow_succ Ordinal.opow_succ theorem opow_limit {a b : Ordinal} (a0 : a ≠ 0) (h : IsLimit b) : a ^ b = bsup.{u, u} b fun c _ => a ^ c := by simp only [opow_def, if_neg a0]; rw [limitRecOn_limit _ _ _ _ h] #align ordinal.opow_limit Ordinal.opow_limit theorem opow_le_of_limit {a b c : Ordinal} (a0 : a ≠ 0) (h : IsLimit b) : a ^ b ≤ c ↔ ∀ b' < b, a ^ b' ≤ c := by rw [opow_limit a0 h, bsup_le_iff] #align ordinal.opow_le_of_limit Ordinal.opow_le_of_limit theorem lt_opow_of_limit {a b c : Ordinal} (b0 : b ≠ 0) (h : IsLimit c) : a < b ^ c ↔ ∃ c' < c, a < b ^ c' := by rw [← not_iff_not, not_exists]; simp only [not_lt, opow_le_of_limit b0 h, exists_prop, not_and] #align ordinal.lt_opow_of_limit Ordinal.lt_opow_of_limit @[simp] theorem opow_one (a : Ordinal) : a ^ (1 : Ordinal) = a := by rw [← succ_zero, opow_succ]; simp only [opow_zero, one_mul] #align ordinal.opow_one Ordinal.opow_one @[simp] theorem one_opow (a : Ordinal) : (1 : Ordinal) ^ a = 1 := by induction a using limitRecOn with | H₁ => simp only [opow_zero] | H₂ _ ih => simp only [opow_succ, ih, mul_one] | H₃ b l IH => refine eq_of_forall_ge_iff fun c => ?_ rw [opow_le_of_limit Ordinal.one_ne_zero l] exact ⟨fun H => by simpa only [opow_zero] using H 0 l.pos, fun H b' h => by rwa [IH _ h]⟩ #align ordinal.one_opow Ordinal.one_opow theorem opow_pos {a : Ordinal} (b : Ordinal) (a0 : 0 < a) : 0 < a ^ b := by have h0 : 0 < a ^ (0 : Ordinal) := by simp only [opow_zero, zero_lt_one] induction b using limitRecOn with | H₁ => exact h0 | H₂ b IH => rw [opow_succ] exact mul_pos IH a0 | H₃ b l _ => exact (lt_opow_of_limit (Ordinal.pos_iff_ne_zero.1 a0) l).2 ⟨0, l.pos, h0⟩ #align ordinal.opow_pos Ordinal.opow_pos theorem opow_ne_zero {a : Ordinal} (b : Ordinal) (a0 : a ≠ 0) : a ^ b ≠ 0 := Ordinal.pos_iff_ne_zero.1 <| opow_pos b <| Ordinal.pos_iff_ne_zero.2 a0 #align ordinal.opow_ne_zero Ordinal.opow_ne_zero theorem opow_isNormal {a : Ordinal} (h : 1 < a) : IsNormal (a ^ ·) := have a0 : 0 < a := zero_lt_one.trans h ⟨fun b => by simpa only [mul_one, opow_succ] using (mul_lt_mul_iff_left (opow_pos b a0)).2 h, fun b l c => opow_le_of_limit (ne_of_gt a0) l⟩ #align ordinal.opow_is_normal Ordinal.opow_isNormal theorem opow_lt_opow_iff_right {a b c : Ordinal} (a1 : 1 < a) : a ^ b < a ^ c ↔ b < c := (opow_isNormal a1).lt_iff #align ordinal.opow_lt_opow_iff_right Ordinal.opow_lt_opow_iff_right theorem opow_le_opow_iff_right {a b c : Ordinal} (a1 : 1 < a) : a ^ b ≤ a ^ c ↔ b ≤ c := (opow_isNormal a1).le_iff #align ordinal.opow_le_opow_iff_right Ordinal.opow_le_opow_iff_right theorem opow_right_inj {a b c : Ordinal} (a1 : 1 < a) : a ^ b = a ^ c ↔ b = c := (opow_isNormal a1).inj #align ordinal.opow_right_inj Ordinal.opow_right_inj theorem opow_isLimit {a b : Ordinal} (a1 : 1 < a) : IsLimit b → IsLimit (a ^ b) := (opow_isNormal a1).isLimit #align ordinal.opow_is_limit Ordinal.opow_isLimit
Mathlib/SetTheory/Ordinal/Exponential.lean
131
136
theorem opow_isLimit_left {a b : Ordinal} (l : IsLimit a) (hb : b ≠ 0) : IsLimit (a ^ b) := by
rcases zero_or_succ_or_limit b with (e | ⟨b, rfl⟩ | l') · exact absurd e hb · rw [opow_succ] exact mul_isLimit (opow_pos _ l.pos) l · exact opow_isLimit l.one_lt l'
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 TypeclassesLeftLT variable [LT α] [CovariantClass α α (· * ·) (· < ·)] {a b c : α} @[to_additive (attr := simp) Left.neg_pos_iff "Uses `left` co(ntra)variant."] theorem Left.one_lt_inv_iff : 1 < a⁻¹ ↔ a < 1 := by rw [← mul_lt_mul_iff_left a, mul_inv_self, mul_one] #align left.one_lt_inv_iff Left.one_lt_inv_iff #align left.neg_pos_iff Left.neg_pos_iff @[to_additive (attr := simp) "Uses `left` co(ntra)variant."] theorem Left.inv_lt_one_iff : a⁻¹ < 1 ↔ 1 < a := by rw [← mul_lt_mul_iff_left a, mul_inv_self, mul_one] #align left.inv_lt_one_iff Left.inv_lt_one_iff #align left.neg_neg_iff Left.neg_neg_iff @[to_additive (attr := simp)] theorem lt_inv_mul_iff_mul_lt : b < a⁻¹ * c ↔ a * b < c := by rw [← mul_lt_mul_iff_left a] simp #align lt_inv_mul_iff_mul_lt lt_inv_mul_iff_mul_lt #align lt_neg_add_iff_add_lt lt_neg_add_iff_add_lt @[to_additive (attr := simp)] theorem inv_mul_lt_iff_lt_mul : b⁻¹ * a < c ↔ a < b * c := by rw [← mul_lt_mul_iff_left b, mul_inv_cancel_left] #align inv_mul_lt_iff_lt_mul inv_mul_lt_iff_lt_mul #align neg_add_lt_iff_lt_add neg_add_lt_iff_lt_add @[to_additive] theorem inv_lt_iff_one_lt_mul' : a⁻¹ < b ↔ 1 < a * b := (mul_lt_mul_iff_left a).symm.trans <| by rw [mul_inv_self] #align inv_lt_iff_one_lt_mul' inv_lt_iff_one_lt_mul' #align neg_lt_iff_pos_add' neg_lt_iff_pos_add' @[to_additive] theorem lt_inv_iff_mul_lt_one' : a < b⁻¹ ↔ b * a < 1 := (mul_lt_mul_iff_left b).symm.trans <| by rw [mul_inv_self] #align lt_inv_iff_mul_lt_one' lt_inv_iff_mul_lt_one' #align lt_neg_iff_add_neg' lt_neg_iff_add_neg' @[to_additive]
Mathlib/Algebra/Order/Group/Defs.lean
196
197
theorem lt_inv_mul_iff_lt : 1 < b⁻¹ * a ↔ b < a := by
rw [← mul_lt_mul_iff_left b, mul_one, mul_inv_cancel_left]
import Mathlib.Order.Filter.EventuallyConst import Mathlib.Order.PartialSups import Mathlib.Algebra.Module.Submodule.IterateMapComap import Mathlib.RingTheory.OrzechProperty import Mathlib.RingTheory.Nilpotent.Lemmas #align_import ring_theory.noetherian from "leanprover-community/mathlib"@"210657c4ea4a4a7b234392f70a3a2a83346dfa90" open Set Filter Pointwise -- Porting note: should this be renamed to `Noetherian`? class IsNoetherian (R M) [Semiring R] [AddCommMonoid M] [Module R M] : Prop where noetherian : ∀ s : Submodule R M, s.FG #align is_noetherian IsNoetherian attribute [inherit_doc IsNoetherian] IsNoetherian.noetherian section variable {R : Type*} {M : Type*} {P : Type*} variable [Semiring R] [AddCommMonoid M] [AddCommMonoid P] variable [Module R M] [Module R P] open IsNoetherian theorem isNoetherian_def : IsNoetherian R M ↔ ∀ s : Submodule R M, s.FG := ⟨fun h => h.noetherian, IsNoetherian.mk⟩ #align is_noetherian_def isNoetherian_def theorem isNoetherian_submodule {N : Submodule R M} : IsNoetherian R N ↔ ∀ s : Submodule R M, s ≤ N → s.FG := by refine ⟨fun ⟨hn⟩ => fun s hs => have : s ≤ LinearMap.range N.subtype := N.range_subtype.symm ▸ hs Submodule.map_comap_eq_self this ▸ (hn _).map _, fun h => ⟨fun s => ?_⟩⟩ have f := (Submodule.equivMapOfInjective N.subtype Subtype.val_injective s).symm have h₁ := h (s.map N.subtype) (Submodule.map_subtype_le N s) have h₂ : (⊤ : Submodule R (s.map N.subtype)).map f = ⊤ := by simp have h₃ := ((Submodule.fg_top _).2 h₁).map (↑f : _ →ₗ[R] s) exact (Submodule.fg_top _).1 (h₂ ▸ h₃) #align is_noetherian_submodule isNoetherian_submodule theorem isNoetherian_submodule_left {N : Submodule R M} : IsNoetherian R N ↔ ∀ s : Submodule R M, (N ⊓ s).FG := isNoetherian_submodule.trans ⟨fun H _ => H _ inf_le_left, fun H _ hs => inf_of_le_right hs ▸ H _⟩ #align is_noetherian_submodule_left isNoetherian_submodule_left theorem isNoetherian_submodule_right {N : Submodule R M} : IsNoetherian R N ↔ ∀ s : Submodule R M, (s ⊓ N).FG := isNoetherian_submodule.trans ⟨fun H _ => H _ inf_le_right, fun H _ hs => inf_of_le_left hs ▸ H _⟩ #align is_noetherian_submodule_right isNoetherian_submodule_right instance isNoetherian_submodule' [IsNoetherian R M] (N : Submodule R M) : IsNoetherian R N := isNoetherian_submodule.2 fun _ _ => IsNoetherian.noetherian _ #align is_noetherian_submodule' isNoetherian_submodule' theorem isNoetherian_of_le {s t : Submodule R M} [ht : IsNoetherian R t] (h : s ≤ t) : IsNoetherian R s := isNoetherian_submodule.mpr fun _ hs' => isNoetherian_submodule.mp ht _ (le_trans hs' h) #align is_noetherian_of_le isNoetherian_of_le variable (M) theorem isNoetherian_of_surjective (f : M →ₗ[R] P) (hf : LinearMap.range f = ⊤) [IsNoetherian R M] : IsNoetherian R P := ⟨fun s => have : (s.comap f).map f = s := Submodule.map_comap_eq_self <| hf.symm ▸ le_top this ▸ (noetherian _).map _⟩ #align is_noetherian_of_surjective isNoetherian_of_surjective variable {M} instance isNoetherian_quotient {R} [Ring R] {M} [AddCommGroup M] [Module R M] (N : Submodule R M) [IsNoetherian R M] : IsNoetherian R (M ⧸ N) := isNoetherian_of_surjective _ _ (LinearMap.range_eq_top.mpr N.mkQ_surjective) #align submodule.quotient.is_noetherian isNoetherian_quotient @[deprecated (since := "2024-04-27"), nolint defLemma] alias Submodule.Quotient.isNoetherian := isNoetherian_quotient theorem isNoetherian_of_linearEquiv (f : M ≃ₗ[R] P) [IsNoetherian R M] : IsNoetherian R P := isNoetherian_of_surjective _ f.toLinearMap f.range #align is_noetherian_of_linear_equiv isNoetherian_of_linearEquiv theorem isNoetherian_top_iff : IsNoetherian R (⊤ : Submodule R M) ↔ IsNoetherian R M := by constructor <;> intro h · exact isNoetherian_of_linearEquiv (LinearEquiv.ofTop (⊤ : Submodule R M) rfl) · exact isNoetherian_of_linearEquiv (LinearEquiv.ofTop (⊤ : Submodule R M) rfl).symm #align is_noetherian_top_iff isNoetherian_top_iff theorem isNoetherian_of_injective [IsNoetherian R P] (f : M →ₗ[R] P) (hf : Function.Injective f) : IsNoetherian R M := isNoetherian_of_linearEquiv (LinearEquiv.ofInjective f hf).symm #align is_noetherian_of_injective isNoetherian_of_injective theorem fg_of_injective [IsNoetherian R P] {N : Submodule R M} (f : M →ₗ[R] P) (hf : Function.Injective f) : N.FG := haveI := isNoetherian_of_injective f hf IsNoetherian.noetherian N #align fg_of_injective fg_of_injective end section variable {R : Type*} {M : Type*} {P : Type*} variable [Ring R] [AddCommGroup M] [AddCommGroup P] variable [Module R M] [Module R P] open IsNoetherian theorem isNoetherian_of_ker_bot [IsNoetherian R P] (f : M →ₗ[R] P) (hf : LinearMap.ker f = ⊥) : IsNoetherian R M := isNoetherian_of_linearEquiv (LinearEquiv.ofInjective f <| LinearMap.ker_eq_bot.mp hf).symm #align is_noetherian_of_ker_bot isNoetherian_of_ker_bot theorem fg_of_ker_bot [IsNoetherian R P] {N : Submodule R M} (f : M →ₗ[R] P) (hf : LinearMap.ker f = ⊥) : N.FG := haveI := isNoetherian_of_ker_bot f hf IsNoetherian.noetherian N #align fg_of_ker_bot fg_of_ker_bot instance isNoetherian_prod [IsNoetherian R M] [IsNoetherian R P] : IsNoetherian R (M × P) := ⟨fun s => Submodule.fg_of_fg_map_of_fg_inf_ker (LinearMap.snd R M P) (noetherian _) <| have : s ⊓ LinearMap.ker (LinearMap.snd R M P) ≤ LinearMap.range (LinearMap.inl R M P) := fun x ⟨_, hx2⟩ => ⟨x.1, Prod.ext rfl <| Eq.symm <| LinearMap.mem_ker.1 hx2⟩ Submodule.map_comap_eq_self this ▸ (noetherian _).map _⟩ #align is_noetherian_prod isNoetherian_prod instance isNoetherian_pi {R ι : Type*} {M : ι → Type*} [Ring R] [∀ i, AddCommGroup (M i)] [∀ i, Module R (M i)] [Finite ι] [∀ i, IsNoetherian R (M i)] : IsNoetherian R (∀ i, M i) := by cases nonempty_fintype ι haveI := Classical.decEq ι suffices on_finset : ∀ s : Finset ι, IsNoetherian R (∀ i : s, M i) by let coe_e := Equiv.subtypeUnivEquiv <| @Finset.mem_univ ι _ letI : IsNoetherian R (∀ i : Finset.univ, M (coe_e i)) := on_finset Finset.univ exact isNoetherian_of_linearEquiv (LinearEquiv.piCongrLeft R M coe_e) intro s induction' s using Finset.induction with a s has ih · exact ⟨fun s => by have : s = ⊥ := by simp only [eq_iff_true_of_subsingleton] rw [this] apply Submodule.fg_bot⟩ refine @isNoetherian_of_linearEquiv R (M a × ((i : s) → M i)) _ _ _ _ _ _ ?_ <| @isNoetherian_prod R (M a) _ _ _ _ _ _ _ ih refine { toFun := fun f i => (Finset.mem_insert.1 i.2).by_cases (fun h : i.1 = a => show M i.1 from Eq.recOn h.symm f.1) (fun h : i.1 ∈ s => show M i.1 from f.2 ⟨i.1, h⟩), invFun := fun f => (f ⟨a, Finset.mem_insert_self _ _⟩, fun i => f ⟨i.1, Finset.mem_insert_of_mem i.2⟩), map_add' := ?_, map_smul' := ?_ left_inv := ?_, right_inv := ?_ } · intro f g ext i unfold Or.by_cases cases' i with i hi rcases Finset.mem_insert.1 hi with (rfl | h) · change _ = _ + _ simp only [dif_pos] rfl · change _ = _ + _ have : ¬i = a := by rintro rfl exact has h simp only [dif_neg this, dif_pos h] rfl · intro c f ext i unfold Or.by_cases cases' i with i hi rcases Finset.mem_insert.1 hi with (rfl | h) · dsimp simp only [dif_pos] · dsimp have : ¬i = a := by rintro rfl exact has h simp only [dif_neg this, dif_pos h] · intro f apply Prod.ext · simp only [Or.by_cases, dif_pos] · ext ⟨i, his⟩ have : ¬i = a := by rintro rfl exact has his simp only [Or.by_cases, this, not_false_iff, dif_neg] · intro f ext ⟨i, hi⟩ rcases Finset.mem_insert.1 hi with (rfl | h) · simp only [Or.by_cases, dif_pos] · have : ¬i = a := by rintro rfl exact has h simp only [Or.by_cases, dif_neg this, dif_pos h] #align is_noetherian_pi isNoetherian_pi instance isNoetherian_pi' {R ι M : Type*} [Ring R] [AddCommGroup M] [Module R M] [Finite ι] [IsNoetherian R M] : IsNoetherian R (ι → M) := isNoetherian_pi #align is_noetherian_pi' isNoetherian_pi' end open IsNoetherian Submodule Function section universe w variable {R M P : Type*} {N : Type w} [Semiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N] [AddCommMonoid P] [Module R P] theorem isNoetherian_iff_wellFounded : IsNoetherian R M ↔ WellFounded ((· > ·) : Submodule R M → Submodule R M → Prop) := by have := (CompleteLattice.wellFounded_characterisations <| Submodule R M).out 0 3 -- Porting note: inlining this makes rw complain about it being a metavariable rw [this] exact ⟨fun ⟨h⟩ => fun k => (fg_iff_compact k).mp (h k), fun h => ⟨fun k => (fg_iff_compact k).mpr (h k)⟩⟩ #align is_noetherian_iff_well_founded isNoetherian_iff_wellFounded theorem isNoetherian_iff_fg_wellFounded : IsNoetherian R M ↔ WellFounded ((· > ·) : { N : Submodule R M // N.FG } → { N : Submodule R M // N.FG } → Prop) := by let α := { N : Submodule R M // N.FG } constructor · intro H let f : α ↪o Submodule R M := OrderEmbedding.subtype _ exact OrderEmbedding.wellFounded f.dual (isNoetherian_iff_wellFounded.mp H) · intro H constructor intro N obtain ⟨⟨N₀, h₁⟩, e : N₀ ≤ N, h₂⟩ := WellFounded.has_min H { N' : α | N'.1 ≤ N } ⟨⟨⊥, Submodule.fg_bot⟩, @bot_le _ _ _ N⟩ convert h₁ refine (e.antisymm ?_).symm by_contra h₃ obtain ⟨x, hx₁ : x ∈ N, hx₂ : x ∉ N₀⟩ := Set.not_subset.mp h₃ apply hx₂ rw [eq_of_le_of_not_lt (le_sup_right : N₀ ≤ _) (h₂ ⟨_, Submodule.FG.sup ⟨{x}, by rw [Finset.coe_singleton]⟩ h₁⟩ <| sup_le ((Submodule.span_singleton_le_iff_mem _ _).mpr hx₁) e)] exact (le_sup_left : (R ∙ x) ≤ _) (Submodule.mem_span_singleton_self _) #align is_noetherian_iff_fg_well_founded isNoetherian_iff_fg_wellFounded variable (R M) theorem wellFounded_submodule_gt (R M) [Semiring R] [AddCommMonoid M] [Module R M] : ∀ [IsNoetherian R M], WellFounded ((· > ·) : Submodule R M → Submodule R M → Prop) := isNoetherian_iff_wellFounded.mp ‹_› #align well_founded_submodule_gt wellFounded_submodule_gt variable {R M} theorem set_has_maximal_iff_noetherian : (∀ a : Set <| Submodule R M, a.Nonempty → ∃ M' ∈ a, ∀ I ∈ a, ¬M' < I) ↔ IsNoetherian R M := by rw [isNoetherian_iff_wellFounded, WellFounded.wellFounded_iff_has_min] #align set_has_maximal_iff_noetherian set_has_maximal_iff_noetherian theorem monotone_stabilizes_iff_noetherian : (∀ f : ℕ →o Submodule R M, ∃ n, ∀ m, n ≤ m → f n = f m) ↔ IsNoetherian R M := by rw [isNoetherian_iff_wellFounded, WellFounded.monotone_chain_condition] #align monotone_stabilizes_iff_noetherian monotone_stabilizes_iff_noetherian theorem eventuallyConst_of_isNoetherian [IsNoetherian R M] (f : ℕ →o Submodule R M) : atTop.EventuallyConst f := by simp_rw [eventuallyConst_atTop, eq_comm] exact (monotone_stabilizes_iff_noetherian.mpr inferInstance) f theorem IsNoetherian.induction [IsNoetherian R M] {P : Submodule R M → Prop} (hgt : ∀ I, (∀ J > I, P J) → P I) (I : Submodule R M) : P I := WellFounded.recursion (wellFounded_submodule_gt R M) I hgt #align is_noetherian.induction IsNoetherian.induction end section universe w variable {R M P : Type*} {N : Type w} [Ring R] [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N] [AddCommGroup P] [Module R P] [IsNoetherian R M] lemma Submodule.finite_ne_bot_of_independent {ι : Type*} {N : ι → Submodule R M} (h : CompleteLattice.Independent N) : Set.Finite {i | N i ≠ ⊥} := CompleteLattice.WellFounded.finite_ne_bot_of_independent (isNoetherian_iff_wellFounded.mp inferInstance) h theorem LinearIndependent.finite_of_isNoetherian [Nontrivial R] {ι} {v : ι → M} (hv : LinearIndependent R v) : Finite ι := by have hwf := isNoetherian_iff_wellFounded.mp (by infer_instance : IsNoetherian R M) refine CompleteLattice.WellFounded.finite_of_independent hwf hv.independent_span_singleton fun i contra => ?_ apply hv.ne_zero i have : v i ∈ R ∙ v i := Submodule.mem_span_singleton_self (v i) rwa [contra, Submodule.mem_bot] at this #align linear_independent.finite_of_is_noetherian LinearIndependent.finite_of_isNoetherian theorem LinearIndependent.set_finite_of_isNoetherian [Nontrivial R] {s : Set M} (hi : LinearIndependent R ((↑) : s → M)) : s.Finite := @Set.toFinite _ _ hi.finite_of_isNoetherian #align linear_independent.set_finite_of_is_noetherian LinearIndependent.set_finite_of_isNoetherian @[deprecated] alias finite_of_linearIndependent := LinearIndependent.set_finite_of_isNoetherian #align finite_of_linear_independent LinearIndependent.set_finite_of_isNoetherian theorem isNoetherian_of_range_eq_ker [IsNoetherian R P] (f : M →ₗ[R] N) (g : N →ₗ[R] P) (h : LinearMap.range f = LinearMap.ker g) : IsNoetherian R N := isNoetherian_iff_wellFounded.2 <| wellFounded_gt_exact_sequence (wellFounded_submodule_gt R _) (wellFounded_submodule_gt R _) (LinearMap.range f) (Submodule.map (f.ker.liftQ f <| le_rfl)) (Submodule.comap (f.ker.liftQ f <| le_rfl)) (Submodule.comap g.rangeRestrict) (Submodule.map g.rangeRestrict) (Submodule.gciMapComap <| LinearMap.ker_eq_bot.mp <| Submodule.ker_liftQ_eq_bot _ _ _ (le_refl _)) (Submodule.giMapComap g.surjective_rangeRestrict) (by simp [Submodule.map_comap_eq, inf_comm, Submodule.range_liftQ]) (by simp [Submodule.comap_map_eq, h]) #align is_noetherian_of_range_eq_ker isNoetherian_of_range_eq_ker theorem LinearMap.eventually_disjoint_ker_pow_range_pow (f : M →ₗ[R] M) : ∀ᶠ n in atTop, Disjoint (LinearMap.ker (f ^ n)) (LinearMap.range (f ^ n)) := by obtain ⟨n, hn : ∀ m, n ≤ m → LinearMap.ker (f ^ n) = LinearMap.ker (f ^ m)⟩ := monotone_stabilizes_iff_noetherian.mpr inferInstance f.iterateKer refine eventually_atTop.mpr ⟨n, fun m hm ↦ disjoint_iff.mpr ?_⟩ rw [← hn _ hm, Submodule.eq_bot_iff] rintro - ⟨hx, ⟨x, rfl⟩⟩ apply LinearMap.pow_map_zero_of_le hm replace hx : x ∈ LinearMap.ker (f ^ (n + m)) := by simpa [f.pow_apply n, f.pow_apply m, ← f.pow_apply (n + m), ← iterate_add_apply] using hx rwa [← hn _ (n.le_add_right m)] at hx #align is_noetherian.exists_endomorphism_iterate_ker_inf_range_eq_bot LinearMap.eventually_disjoint_ker_pow_range_pow lemma LinearMap.eventually_iSup_ker_pow_eq (f : M →ₗ[R] M) : ∀ᶠ n in atTop, ⨆ m, LinearMap.ker (f ^ m) = LinearMap.ker (f ^ n) := by obtain ⟨n, hn : ∀ m, n ≤ m → ker (f ^ n) = ker (f ^ m)⟩ := monotone_stabilizes_iff_noetherian.mpr inferInstance f.iterateKer refine eventually_atTop.mpr ⟨n, fun m hm ↦ ?_⟩ refine le_antisymm (iSup_le fun l ↦ ?_) (le_iSup (fun i ↦ LinearMap.ker (f ^ i)) m) rcases le_or_lt m l with h | h · rw [← hn _ (hm.trans h), hn _ hm] · exact f.iterateKer.monotone h.le theorem IsNoetherian.injective_of_surjective_of_injective (i f : N →ₗ[R] M) (hi : Injective i) (hf : Surjective f) : Injective f := by haveI := isNoetherian_of_injective i hi obtain ⟨n, H⟩ := monotone_stabilizes_iff_noetherian.2 ‹_› ⟨_, monotone_nat_of_le_succ <| f.iterateMapComap_le_succ i ⊥ (by simp)⟩ exact LinearMap.ker_eq_bot.1 <| bot_unique <| f.ker_le_of_iterateMapComap_eq_succ i ⊥ n (H _ (Nat.le_succ _)) hf hi theorem IsNoetherian.injective_of_surjective_of_submodule {N : Submodule R M} (f : N →ₗ[R] M) (hf : Surjective f) : Injective f := IsNoetherian.injective_of_surjective_of_injective N.subtype f N.injective_subtype hf theorem IsNoetherian.injective_of_surjective_endomorphism (f : M →ₗ[R] M) (s : Surjective f) : Injective f := IsNoetherian.injective_of_surjective_of_injective _ f (LinearEquiv.refl _ _).injective s #align is_noetherian.injective_of_surjective_endomorphism IsNoetherian.injective_of_surjective_endomorphism theorem IsNoetherian.bijective_of_surjective_endomorphism (f : M →ₗ[R] M) (s : Surjective f) : Bijective f := ⟨IsNoetherian.injective_of_surjective_endomorphism f s, s⟩ #align is_noetherian.bijective_of_surjective_endomorphism IsNoetherian.bijective_of_surjective_endomorphism theorem IsNoetherian.disjoint_partialSups_eventually_bot (f : ℕ → Submodule R M) (h : ∀ n, Disjoint (partialSups f n) (f (n + 1))) : ∃ n : ℕ, ∀ m, n ≤ m → f m = ⊥ := by -- A little off-by-one cleanup first: suffices t : ∃ n : ℕ, ∀ m, n ≤ m → f (m + 1) = ⊥ by obtain ⟨n, w⟩ := t use n + 1 rintro (_ | m) p · cases p · apply w exact Nat.succ_le_succ_iff.mp p obtain ⟨n, w⟩ := monotone_stabilizes_iff_noetherian.mpr inferInstance (partialSups f) exact ⟨n, fun m p => (h m).eq_bot_of_ge <| sup_eq_left.1 <| (w (m + 1) <| le_add_right p).symm.trans <| w m p⟩ #align is_noetherian.disjoint_partial_sups_eventually_bot IsNoetherian.disjoint_partialSups_eventually_bot theorem IsNoetherian.subsingleton_of_prod_injective (f : M × N →ₗ[R] M) (i : Injective f) : Subsingleton N := .intro fun x y ↦ by have h := IsNoetherian.injective_of_surjective_of_injective f _ i LinearMap.fst_surjective simpa using h (show LinearMap.fst R M N (0, x) = LinearMap.fst R M N (0, y) from rfl) @[simps!] def IsNoetherian.equivPUnitOfProdInjective (f : M × N →ₗ[R] M) (i : Injective f) : N ≃ₗ[R] PUnit.{w + 1} := haveI := IsNoetherian.subsingleton_of_prod_injective f i .ofSubsingleton _ _ #align is_noetherian.equiv_punit_of_prod_injective IsNoetherian.equivPUnitOfProdInjective end abbrev IsNoetherianRing (R) [Semiring R] := IsNoetherian R R #align is_noetherian_ring IsNoetherianRing theorem isNoetherianRing_iff {R} [Semiring R] : IsNoetherianRing R ↔ IsNoetherian R R := Iff.rfl #align is_noetherian_ring_iff isNoetherianRing_iff theorem isNoetherianRing_iff_ideal_fg (R : Type*) [Semiring R] : IsNoetherianRing R ↔ ∀ I : Ideal R, I.FG := isNoetherianRing_iff.trans isNoetherian_def #align is_noetherian_ring_iff_ideal_fg isNoetherianRing_iff_ideal_fg -- see Note [lower instance priority] instance (priority := 80) isNoetherian_of_finite (R M) [Finite M] [Semiring R] [AddCommMonoid M] [Module R M] : IsNoetherian R M := ⟨fun s => ⟨(s : Set M).toFinite.toFinset, by rw [Set.Finite.coe_toFinset, Submodule.span_eq]⟩⟩ #align is_noetherian_of_finite isNoetherian_of_finite -- see Note [lower instance priority] instance (priority := 100) isNoetherian_of_subsingleton (R M) [Subsingleton R] [Semiring R] [AddCommMonoid M] [Module R M] : IsNoetherian R M := haveI := Module.subsingleton R M isNoetherian_of_finite R M #align is_noetherian_of_subsingleton isNoetherian_of_subsingleton theorem isNoetherian_of_submodule_of_noetherian (R M) [Semiring R] [AddCommMonoid M] [Module R M] (N : Submodule R M) (h : IsNoetherian R M) : IsNoetherian R N := by rw [isNoetherian_iff_wellFounded] at h ⊢ exact OrderEmbedding.wellFounded (Submodule.MapSubtype.orderEmbedding N).dual h #align is_noetherian_of_submodule_of_noetherian isNoetherian_of_submodule_of_noetherian theorem isNoetherian_of_tower (R) {S M} [Semiring R] [Semiring S] [AddCommMonoid M] [SMul R S] [Module S M] [Module R M] [IsScalarTower R S M] (h : IsNoetherian R M) : IsNoetherian S M := by rw [isNoetherian_iff_wellFounded] at h ⊢ exact (Submodule.restrictScalarsEmbedding R S M).dual.wellFounded h #align is_noetherian_of_tower isNoetherian_of_tower theorem isNoetherian_of_fg_of_noetherian {R M} [Ring R] [AddCommGroup M] [Module R M] (N : Submodule R M) [I : IsNoetherianRing R] (hN : N.FG) : IsNoetherian R N := by let ⟨s, hs⟩ := hN haveI := Classical.decEq M haveI := Classical.decEq R have : ∀ x ∈ s, x ∈ N := fun x hx => hs ▸ Submodule.subset_span hx refine @isNoetherian_of_surjective R ((↑s : Set M) → R) N _ _ _ (Pi.module _ _ _) _ ?_ ?_ isNoetherian_pi · fapply LinearMap.mk · fapply AddHom.mk · exact fun f => ⟨∑ i ∈ s.attach, f i • i.1, N.sum_mem fun c _ => N.smul_mem _ <| this _ c.2⟩ · intro f g apply Subtype.eq change (∑ i ∈ s.attach, (f i + g i) • _) = _ simp only [add_smul, Finset.sum_add_distrib] rfl · intro c f apply Subtype.eq change (∑ i ∈ s.attach, (c • f i) • _) = _ simp only [smul_eq_mul, mul_smul] exact Finset.smul_sum.symm · rw [LinearMap.range_eq_top] rintro ⟨n, hn⟩ change n ∈ N at hn rw [← hs, ← Set.image_id (s : Set M), Finsupp.mem_span_image_iff_total] at hn rcases hn with ⟨l, hl1, hl2⟩ refine ⟨fun x => l x, Subtype.ext ?_⟩ change (∑ i ∈ s.attach, l i • (i : M)) = n rw [s.sum_attach fun i ↦ l i • i, ← hl2, Finsupp.total_apply, Finsupp.sum, eq_comm] refine Finset.sum_subset hl1 fun x _ hx => ?_ rw [Finsupp.not_mem_support_iff.1 hx, zero_smul] #align is_noetherian_of_fg_of_noetherian isNoetherian_of_fg_of_noetherian instance isNoetherian_of_isNoetherianRing_of_finite (R M : Type*) [Ring R] [AddCommGroup M] [Module R M] [IsNoetherianRing R] [Module.Finite R M] : IsNoetherian R M := have : IsNoetherian R (⊤ : Submodule R M) := isNoetherian_of_fg_of_noetherian _ <| Module.finite_def.mp inferInstance isNoetherian_of_linearEquiv (LinearEquiv.ofTop (⊤ : Submodule R M) rfl) #align is_noetherian_of_fg_of_noetherian' isNoetherian_of_isNoetherianRing_of_finite theorem isNoetherian_span_of_finite (R) {M} [Ring R] [AddCommGroup M] [Module R M] [IsNoetherianRing R] {A : Set M} (hA : A.Finite) : IsNoetherian R (Submodule.span R A) := isNoetherian_of_fg_of_noetherian _ (Submodule.fg_def.mpr ⟨A, hA, rfl⟩) #align is_noetherian_span_of_finite isNoetherian_span_of_finite theorem isNoetherianRing_of_surjective (R) [Ring R] (S) [Ring S] (f : R →+* S) (hf : Function.Surjective f) [H : IsNoetherianRing R] : IsNoetherianRing S := by rw [isNoetherianRing_iff, isNoetherian_iff_wellFounded] at H ⊢ exact OrderEmbedding.wellFounded (Ideal.orderEmbeddingOfSurjective f hf).dual H #align is_noetherian_ring_of_surjective isNoetherianRing_of_surjective instance isNoetherianRing_range {R} [Ring R] {S} [Ring S] (f : R →+* S) [IsNoetherianRing R] : IsNoetherianRing f.range := isNoetherianRing_of_surjective R f.range f.rangeRestrict f.rangeRestrict_surjective #align is_noetherian_ring_range isNoetherianRing_range theorem isNoetherianRing_of_ringEquiv (R) [Ring R] {S} [Ring S] (f : R ≃+* S) [IsNoetherianRing R] : IsNoetherianRing S := isNoetherianRing_of_surjective R S f.toRingHom f.toEquiv.surjective #align is_noetherian_ring_of_ring_equiv isNoetherianRing_of_ringEquiv
Mathlib/RingTheory/Noetherian.lean
642
645
theorem IsNoetherianRing.isNilpotent_nilradical (R : Type*) [CommRing R] [IsNoetherianRing R] : IsNilpotent (nilradical R) := by
obtain ⟨n, hn⟩ := Ideal.exists_radical_pow_le_of_fg (⊥ : Ideal R) (IsNoetherian.noetherian _) exact ⟨n, eq_bot_iff.mpr hn⟩
import Mathlib.Data.Finset.Basic import Mathlib.ModelTheory.Syntax import Mathlib.Data.List.ProdSigma #align_import model_theory.semantics from "leanprover-community/mathlib"@"d565b3df44619c1498326936be16f1a935df0728" universe u v w u' v' namespace FirstOrder namespace Language variable {L : Language.{u, v}} {L' : Language} variable {M : Type w} {N P : Type*} [L.Structure M] [L.Structure N] [L.Structure P] variable {α : Type u'} {β : Type v'} {γ : Type*} open FirstOrder Cardinal open Structure Cardinal Fin namespace Term -- Porting note: universes in different order def realize (v : α → M) : ∀ _t : L.Term α, M | var k => v k | func f ts => funMap f fun i => (ts i).realize v #align first_order.language.term.realize FirstOrder.Language.Term.realize @[simp] theorem realize_var (v : α → M) (k) : realize v (var k : L.Term α) = v k := rfl @[simp] theorem realize_func (v : α → M) {n} (f : L.Functions n) (ts) : realize v (func f ts : L.Term α) = funMap f fun i => (ts i).realize v := rfl @[simp] theorem realize_relabel {t : L.Term α} {g : α → β} {v : β → M} : (t.relabel g).realize v = t.realize (v ∘ g) := by induction' t with _ n f ts ih · rfl · simp [ih] #align first_order.language.term.realize_relabel FirstOrder.Language.Term.realize_relabel @[simp] theorem realize_liftAt {n n' m : ℕ} {t : L.Term (Sum α (Fin n))} {v : Sum α (Fin (n + n')) → M} : (t.liftAt n' m).realize v = t.realize (v ∘ Sum.map id fun i : Fin _ => if ↑i < m then Fin.castAdd n' i else Fin.addNat i n') := realize_relabel #align first_order.language.term.realize_lift_at FirstOrder.Language.Term.realize_liftAt @[simp] theorem realize_constants {c : L.Constants} {v : α → M} : c.term.realize v = c := funMap_eq_coe_constants #align first_order.language.term.realize_constants FirstOrder.Language.Term.realize_constants @[simp]
Mathlib/ModelTheory/Semantics.lean
109
113
theorem realize_functions_apply₁ {f : L.Functions 1} {t : L.Term α} {v : α → M} : (f.apply₁ t).realize v = funMap f ![t.realize v] := by
rw [Functions.apply₁, Term.realize] refine congr rfl (funext fun i => ?_) simp only [Matrix.cons_val_fin_one]
import Mathlib.Data.List.Forall2 import Mathlib.Data.Set.Pairwise.Basic import Mathlib.Init.Data.Fin.Basic #align_import data.list.nodup from "leanprover-community/mathlib"@"c227d107bbada5d0d9d20287e3282c0a7f1651a0" universe u v open Nat Function variable {α : Type u} {β : Type v} {l l₁ l₂ : List α} {r : α → α → Prop} {a b : α} namespace List @[simp] theorem forall_mem_ne {a : α} {l : List α} : (∀ a' : α, a' ∈ l → ¬a = a') ↔ a ∉ l := ⟨fun h m => h _ m rfl, fun h _ m e => h (e.symm ▸ m)⟩ #align list.forall_mem_ne List.forall_mem_ne @[simp] theorem nodup_nil : @Nodup α [] := Pairwise.nil #align list.nodup_nil List.nodup_nil @[simp] theorem nodup_cons {a : α} {l : List α} : Nodup (a :: l) ↔ a ∉ l ∧ Nodup l := by simp only [Nodup, pairwise_cons, forall_mem_ne] #align list.nodup_cons List.nodup_cons protected theorem Pairwise.nodup {l : List α} {r : α → α → Prop} [IsIrrefl α r] (h : Pairwise r l) : Nodup l := h.imp ne_of_irrefl #align list.pairwise.nodup List.Pairwise.nodup theorem rel_nodup {r : α → β → Prop} (hr : Relator.BiUnique r) : (Forall₂ r ⇒ (· ↔ ·)) Nodup Nodup | _, _, Forall₂.nil => by simp only [nodup_nil] | _, _, Forall₂.cons hab h => by simpa only [nodup_cons] using Relator.rel_and (Relator.rel_not (rel_mem hr hab h)) (rel_nodup hr h) #align list.rel_nodup List.rel_nodup protected theorem Nodup.cons (ha : a ∉ l) (hl : Nodup l) : Nodup (a :: l) := nodup_cons.2 ⟨ha, hl⟩ #align list.nodup.cons List.Nodup.cons theorem nodup_singleton (a : α) : Nodup [a] := pairwise_singleton _ _ #align list.nodup_singleton List.nodup_singleton theorem Nodup.of_cons (h : Nodup (a :: l)) : Nodup l := (nodup_cons.1 h).2 #align list.nodup.of_cons List.Nodup.of_cons theorem Nodup.not_mem (h : (a :: l).Nodup) : a ∉ l := (nodup_cons.1 h).1 #align list.nodup.not_mem List.Nodup.not_mem theorem not_nodup_cons_of_mem : a ∈ l → ¬Nodup (a :: l) := imp_not_comm.1 Nodup.not_mem #align list.not_nodup_cons_of_mem List.not_nodup_cons_of_mem protected theorem Nodup.sublist : l₁ <+ l₂ → Nodup l₂ → Nodup l₁ := Pairwise.sublist #align list.nodup.sublist List.Nodup.sublist theorem not_nodup_pair (a : α) : ¬Nodup [a, a] := not_nodup_cons_of_mem <| mem_singleton_self _ #align list.not_nodup_pair List.not_nodup_pair theorem nodup_iff_sublist {l : List α} : Nodup l ↔ ∀ a, ¬[a, a] <+ l := ⟨fun d a h => not_nodup_pair a (d.sublist h), by induction' l with a l IH <;> intro h; · exact nodup_nil exact (IH fun a s => h a <| sublist_cons_of_sublist _ s).cons fun al => h a <| (singleton_sublist.2 al).cons_cons _⟩ #align list.nodup_iff_sublist List.nodup_iff_sublist -- Porting note (#10756): new theorem theorem nodup_iff_injective_get {l : List α} : Nodup l ↔ Function.Injective l.get := pairwise_iff_get.trans ⟨fun h i j hg => by cases' i with i hi; cases' j with j hj rcases lt_trichotomy i j with (hij | rfl | hji) · exact (h ⟨i, hi⟩ ⟨j, hj⟩ hij hg).elim · rfl · exact (h ⟨j, hj⟩ ⟨i, hi⟩ hji hg.symm).elim, fun hinj i j hij h => Nat.ne_of_lt hij (Fin.val_eq_of_eq (hinj h))⟩ set_option linter.deprecated false in @[deprecated nodup_iff_injective_get (since := "2023-01-10")] theorem nodup_iff_nthLe_inj {l : List α} : Nodup l ↔ ∀ i j h₁ h₂, nthLe l i h₁ = nthLe l j h₂ → i = j := nodup_iff_injective_get.trans ⟨fun hinj _ _ _ _ h => congr_arg Fin.val (hinj h), fun hinj i j h => Fin.eq_of_veq (hinj i j i.2 j.2 h)⟩ #align list.nodup_iff_nth_le_inj List.nodup_iff_nthLe_inj theorem Nodup.get_inj_iff {l : List α} (h : Nodup l) {i j : Fin l.length} : l.get i = l.get j ↔ i = j := (nodup_iff_injective_get.1 h).eq_iff set_option linter.deprecated false in @[deprecated Nodup.get_inj_iff (since := "2023-01-10")] theorem Nodup.nthLe_inj_iff {l : List α} (h : Nodup l) {i j : ℕ} (hi : i < l.length) (hj : j < l.length) : l.nthLe i hi = l.nthLe j hj ↔ i = j := ⟨nodup_iff_nthLe_inj.mp h _ _ _ _, by simp (config := { contextual := true })⟩ #align list.nodup.nth_le_inj_iff List.Nodup.nthLe_inj_iff theorem nodup_iff_get?_ne_get? {l : List α} : l.Nodup ↔ ∀ i j : ℕ, i < j → j < l.length → l.get? i ≠ l.get? j := by rw [Nodup, pairwise_iff_get] constructor · intro h i j hij hj rw [get?_eq_get (lt_trans hij hj), get?_eq_get hj, Ne, Option.some_inj] exact h _ _ hij · intro h i j hij rw [Ne, ← Option.some_inj, ← get?_eq_get, ← get?_eq_get] exact h i j hij j.2 #align list.nodup_iff_nth_ne_nth List.nodup_iff_get?_ne_get? theorem Nodup.ne_singleton_iff {l : List α} (h : Nodup l) (x : α) : l ≠ [x] ↔ l = [] ∨ ∃ y ∈ l, y ≠ x := by induction' l with hd tl hl · simp · specialize hl h.of_cons by_cases hx : tl = [x] · simpa [hx, and_comm, and_or_left] using h · rw [← Ne, hl] at hx rcases hx with (rfl | ⟨y, hy, hx⟩) · simp · suffices ∃ y ∈ hd :: tl, y ≠ x by simpa [ne_nil_of_mem hy] exact ⟨y, mem_cons_of_mem _ hy, hx⟩ #align list.nodup.ne_singleton_iff List.Nodup.ne_singleton_iff theorem not_nodup_of_get_eq_of_ne (xs : List α) (n m : Fin xs.length) (h : xs.get n = xs.get m) (hne : n ≠ m) : ¬Nodup xs := by rw [nodup_iff_injective_get] exact fun hinj => hne (hinj h) #align list.nth_le_eq_of_ne_imp_not_nodup List.not_nodup_of_get_eq_of_ne -- Porting note (#10756): new theorem theorem get_indexOf [DecidableEq α] {l : List α} (H : Nodup l) (i : Fin l.length) : indexOf (get l i) l = i := suffices (⟨indexOf (get l i) l, indexOf_lt_length.2 (get_mem _ _ _)⟩ : Fin l.length) = i from Fin.val_eq_of_eq this nodup_iff_injective_get.1 H (by simp) #align list.nth_le_index_of List.get_indexOf theorem nodup_iff_count_le_one [DecidableEq α] {l : List α} : Nodup l ↔ ∀ a, count a l ≤ 1 := nodup_iff_sublist.trans <| forall_congr' fun a => have : replicate 2 a <+ l ↔ 1 < count a l := (le_count_iff_replicate_sublist ..).symm (not_congr this).trans not_lt #align list.nodup_iff_count_le_one List.nodup_iff_count_le_one theorem nodup_iff_count_eq_one [DecidableEq α] : Nodup l ↔ ∀ a ∈ l, count a l = 1 := nodup_iff_count_le_one.trans <| forall_congr' fun _ => ⟨fun H h => H.antisymm (count_pos_iff_mem.mpr h), fun H => if h : _ then (H h).le else (count_eq_zero.mpr h).trans_le (Nat.zero_le 1)⟩ theorem nodup_replicate (a : α) : ∀ {n : ℕ}, Nodup (replicate n a) ↔ n ≤ 1 | 0 => by simp [Nat.zero_le] | 1 => by simp | n + 2 => iff_of_false (fun H => nodup_iff_sublist.1 H a ((replicate_sublist_replicate _).2 (Nat.le_add_left 2 n))) (not_le_of_lt <| Nat.le_add_left 2 n) #align list.nodup_replicate List.nodup_replicate @[simp] theorem count_eq_one_of_mem [DecidableEq α] {a : α} {l : List α} (d : Nodup l) (h : a ∈ l) : count a l = 1 := _root_.le_antisymm (nodup_iff_count_le_one.1 d a) (Nat.succ_le_of_lt (count_pos_iff_mem.2 h)) #align list.count_eq_one_of_mem List.count_eq_one_of_mem theorem count_eq_of_nodup [DecidableEq α] {a : α} {l : List α} (d : Nodup l) : count a l = if a ∈ l then 1 else 0 := by split_ifs with h · exact count_eq_one_of_mem d h · exact count_eq_zero_of_not_mem h #align list.count_eq_of_nodup List.count_eq_of_nodup theorem Nodup.of_append_left : Nodup (l₁ ++ l₂) → Nodup l₁ := Nodup.sublist (sublist_append_left l₁ l₂) #align list.nodup.of_append_left List.Nodup.of_append_left theorem Nodup.of_append_right : Nodup (l₁ ++ l₂) → Nodup l₂ := Nodup.sublist (sublist_append_right l₁ l₂) #align list.nodup.of_append_right List.Nodup.of_append_right theorem nodup_append {l₁ l₂ : List α} : Nodup (l₁ ++ l₂) ↔ Nodup l₁ ∧ Nodup l₂ ∧ Disjoint l₁ l₂ := by simp only [Nodup, pairwise_append, disjoint_iff_ne] #align list.nodup_append List.nodup_append theorem disjoint_of_nodup_append {l₁ l₂ : List α} (d : Nodup (l₁ ++ l₂)) : Disjoint l₁ l₂ := (nodup_append.1 d).2.2 #align list.disjoint_of_nodup_append List.disjoint_of_nodup_append theorem Nodup.append (d₁ : Nodup l₁) (d₂ : Nodup l₂) (dj : Disjoint l₁ l₂) : Nodup (l₁ ++ l₂) := nodup_append.2 ⟨d₁, d₂, dj⟩ #align list.nodup.append List.Nodup.append theorem nodup_append_comm {l₁ l₂ : List α} : Nodup (l₁ ++ l₂) ↔ Nodup (l₂ ++ l₁) := by simp only [nodup_append, and_left_comm, disjoint_comm] #align list.nodup_append_comm List.nodup_append_comm theorem nodup_middle {a : α} {l₁ l₂ : List α} : Nodup (l₁ ++ a :: l₂) ↔ Nodup (a :: (l₁ ++ l₂)) := by simp only [nodup_append, not_or, and_left_comm, and_assoc, nodup_cons, mem_append, disjoint_cons_right] #align list.nodup_middle List.nodup_middle theorem Nodup.of_map (f : α → β) {l : List α} : Nodup (map f l) → Nodup l := (Pairwise.of_map f) fun _ _ => mt <| congr_arg f #align list.nodup.of_map List.Nodup.of_mapₓ -- Porting note: different universe order theorem Nodup.map_on {f : α → β} (H : ∀ x ∈ l, ∀ y ∈ l, f x = f y → x = y) (d : Nodup l) : (map f l).Nodup := Pairwise.map _ (fun a b ⟨ma, mb, n⟩ e => n (H a ma b mb e)) (Pairwise.and_mem.1 d) #align list.nodup.map_on List.Nodup.map_onₓ -- Porting note: different universe order theorem inj_on_of_nodup_map {f : α → β} {l : List α} (d : Nodup (map f l)) : ∀ ⦃x⦄, x ∈ l → ∀ ⦃y⦄, y ∈ l → f x = f y → x = y := by induction' l with hd tl ih · simp · simp only [map, nodup_cons, mem_map, not_exists, not_and, ← Ne.eq_def] at d simp only [mem_cons] rintro _ (rfl | h₁) _ (rfl | h₂) h₃ · rfl · apply (d.1 _ h₂ h₃.symm).elim · apply (d.1 _ h₁ h₃).elim · apply ih d.2 h₁ h₂ h₃ #align list.inj_on_of_nodup_map List.inj_on_of_nodup_map theorem nodup_map_iff_inj_on {f : α → β} {l : List α} (d : Nodup l) : Nodup (map f l) ↔ ∀ x ∈ l, ∀ y ∈ l, f x = f y → x = y := ⟨inj_on_of_nodup_map, fun h => d.map_on h⟩ #align list.nodup_map_iff_inj_on List.nodup_map_iff_inj_on protected theorem Nodup.map {f : α → β} (hf : Injective f) : Nodup l → Nodup (map f l) := Nodup.map_on fun _ _ _ _ h => hf h #align list.nodup.map List.Nodup.map -- Porting note: different universe order theorem nodup_map_iff {f : α → β} {l : List α} (hf : Injective f) : Nodup (map f l) ↔ Nodup l := ⟨Nodup.of_map _, Nodup.map hf⟩ #align list.nodup_map_iff List.nodup_map_iff @[simp] theorem nodup_attach {l : List α} : Nodup (attach l) ↔ Nodup l := ⟨fun h => attach_map_val l ▸ h.map fun _ _ => Subtype.eq, fun h => Nodup.of_map Subtype.val ((attach_map_val l).symm ▸ h)⟩ #align list.nodup_attach List.nodup_attach alias ⟨Nodup.of_attach, Nodup.attach⟩ := nodup_attach #align list.nodup.attach List.Nodup.attach #align list.nodup.of_attach List.Nodup.of_attach -- Porting note: commented out --attribute [protected] nodup.attach theorem Nodup.pmap {p : α → Prop} {f : ∀ a, p a → β} {l : List α} {H} (hf : ∀ a ha b hb, f a ha = f b hb → a = b) (h : Nodup l) : Nodup (pmap f l H) := by rw [pmap_eq_map_attach] exact h.attach.map fun ⟨a, ha⟩ ⟨b, hb⟩ h => by congr; exact hf a (H _ ha) b (H _ hb) h #align list.nodup.pmap List.Nodup.pmap theorem Nodup.filter (p : α → Bool) {l} : Nodup l → Nodup (filter p l) := by simpa using Pairwise.filter (fun a ↦ p a) #align list.nodup.filter List.Nodup.filter @[simp] theorem nodup_reverse {l : List α} : Nodup (reverse l) ↔ Nodup l := pairwise_reverse.trans <| by simp only [Nodup, Ne, eq_comm] #align list.nodup_reverse List.nodup_reverse theorem Nodup.erase_eq_filter [DecidableEq α] {l} (d : Nodup l) (a : α) : l.erase a = l.filter (· ≠ a) := by induction' d with b l m _ IH; · rfl by_cases h : b = a · subst h rw [erase_cons_head, filter_cons_of_neg _ (by simp)] symm rw [filter_eq_self] simpa [@eq_comm α] using m · rw [erase_cons_tail _ (not_beq_of_ne h), filter_cons_of_pos, IH] simp [h] #align list.nodup.erase_eq_filter List.Nodup.erase_eq_filter theorem Nodup.erase [DecidableEq α] (a : α) : Nodup l → Nodup (l.erase a) := Nodup.sublist <| erase_sublist _ _ #align list.nodup.erase List.Nodup.erase theorem Nodup.erase_get [DecidableEq α] {l : List α} (hl : l.Nodup) : ∀ i : Fin l.length, l.erase (l.get i) = l.eraseIdx ↑i := by induction l with | nil => simp | cons a l IH => intro i cases i using Fin.cases with | zero => simp | succ i => rw [nodup_cons] at hl rw [erase_cons_tail] · simp [IH hl.2] · rw [beq_iff_eq, get_cons_succ'] exact mt (· ▸ l.get_mem i i.isLt) hl.1 theorem Nodup.diff [DecidableEq α] : l₁.Nodup → (l₁.diff l₂).Nodup := Nodup.sublist <| diff_sublist _ _ #align list.nodup.diff List.Nodup.diff theorem Nodup.mem_erase_iff [DecidableEq α] (d : Nodup l) : a ∈ l.erase b ↔ a ≠ b ∧ a ∈ l := by rw [d.erase_eq_filter, mem_filter, and_comm, decide_eq_true_iff] #align list.nodup.mem_erase_iff List.Nodup.mem_erase_iff theorem Nodup.not_mem_erase [DecidableEq α] (h : Nodup l) : a ∉ l.erase a := fun H => (h.mem_erase_iff.1 H).1 rfl #align list.nodup.not_mem_erase List.Nodup.not_mem_erase theorem nodup_join {L : List (List α)} : Nodup (join L) ↔ (∀ l ∈ L, Nodup l) ∧ Pairwise Disjoint L := by simp only [Nodup, pairwise_join, disjoint_left.symm, forall_mem_ne] #align list.nodup_join List.nodup_join theorem nodup_bind {l₁ : List α} {f : α → List β} : Nodup (l₁.bind f) ↔ (∀ x ∈ l₁, Nodup (f x)) ∧ Pairwise (fun a b : α => Disjoint (f a) (f b)) l₁ := by simp only [List.bind, nodup_join, pairwise_map, and_comm, and_left_comm, mem_map, exists_imp, and_imp] rw [show (∀ (l : List β) (x : α), f x = l → x ∈ l₁ → Nodup l) ↔ ∀ x : α, x ∈ l₁ → Nodup (f x) from forall_swap.trans <| forall_congr' fun _ => forall_eq'] #align list.nodup_bind List.nodup_bind protected theorem Nodup.product {l₂ : List β} (d₁ : l₁.Nodup) (d₂ : l₂.Nodup) : (l₁ ×ˢ l₂).Nodup := nodup_bind.2 ⟨fun a _ => d₂.map <| LeftInverse.injective fun b => (rfl : (a, b).2 = b), d₁.imp fun {a₁ a₂} n x h₁ h₂ => by rcases mem_map.1 h₁ with ⟨b₁, _, rfl⟩ rcases mem_map.1 h₂ with ⟨b₂, mb₂, ⟨⟩⟩ exact n rfl⟩ #align list.nodup.product List.Nodup.product theorem Nodup.sigma {σ : α → Type*} {l₂ : ∀ a , List (σ a)} (d₁ : Nodup l₁) (d₂ : ∀ a , Nodup (l₂ a)) : (l₁.sigma l₂).Nodup := nodup_bind.2 ⟨fun a _ => (d₂ a).map fun b b' h => by injection h with _ h, d₁.imp fun {a₁ a₂} n x h₁ h₂ => by rcases mem_map.1 h₁ with ⟨b₁, _, rfl⟩ rcases mem_map.1 h₂ with ⟨b₂, mb₂, ⟨⟩⟩ exact n rfl⟩ #align list.nodup.sigma List.Nodup.sigma protected theorem Nodup.filterMap {f : α → Option β} (h : ∀ a a' b, b ∈ f a → b ∈ f a' → a = a') : Nodup l → Nodup (filterMap f l) := (Pairwise.filter_map f) @fun a a' n b bm b' bm' e => n <| h a a' b' (by rw [← e]; exact bm) bm' #align list.nodup.filter_map List.Nodup.filterMap protected theorem Nodup.concat (h : a ∉ l) (h' : l.Nodup) : (l.concat a).Nodup := by rw [concat_eq_append]; exact h'.append (nodup_singleton _) (disjoint_singleton.2 h) #align list.nodup.concat List.Nodup.concat protected theorem Nodup.insert [DecidableEq α] (h : l.Nodup) : (l.insert a).Nodup := if h' : a ∈ l then by rw [insert_of_mem h']; exact h else by rw [insert_of_not_mem h', nodup_cons]; constructor <;> assumption #align list.nodup.insert List.Nodup.insert theorem Nodup.union [DecidableEq α] (l₁ : List α) (h : Nodup l₂) : (l₁ ∪ l₂).Nodup := by induction' l₁ with a l₁ ih generalizing l₂ · exact h · exact (ih h).insert #align list.nodup.union List.Nodup.union theorem Nodup.inter [DecidableEq α] (l₂ : List α) : Nodup l₁ → Nodup (l₁ ∩ l₂) := Nodup.filter _ #align list.nodup.inter List.Nodup.inter theorem Nodup.diff_eq_filter [DecidableEq α] : ∀ {l₁ l₂ : List α} (_ : l₁.Nodup), l₁.diff l₂ = l₁.filter (· ∉ l₂) | l₁, [], _ => by simp | l₁, a :: l₂, hl₁ => by rw [diff_cons, (hl₁.erase _).diff_eq_filter, hl₁.erase_eq_filter, filter_filter] simp only [decide_not, Bool.not_eq_true', decide_eq_false_iff_not, ne_eq, and_comm, Bool.decide_and, find?, mem_cons, not_or] #align list.nodup.diff_eq_filter List.Nodup.diff_eq_filter theorem Nodup.mem_diff_iff [DecidableEq α] (hl₁ : l₁.Nodup) : a ∈ l₁.diff l₂ ↔ a ∈ l₁ ∧ a ∉ l₂ := by rw [hl₁.diff_eq_filter, mem_filter, decide_eq_true_iff] #align list.nodup.mem_diff_iff List.Nodup.mem_diff_iff protected theorem Nodup.set : ∀ {l : List α} {n : ℕ} {a : α} (_ : l.Nodup) (_ : a ∉ l), (l.set n a).Nodup | [], _, _, _, _ => nodup_nil | _ :: _, 0, _, hl, ha => nodup_cons.2 ⟨mt (mem_cons_of_mem _) ha, (nodup_cons.1 hl).2⟩ | _ :: _, _ + 1, _, hl, ha => nodup_cons.2 ⟨fun h => (mem_or_eq_of_mem_set h).elim (nodup_cons.1 hl).1 fun hba => ha (hba ▸ mem_cons_self _ _), hl.of_cons.set (mt (mem_cons_of_mem _) ha)⟩ #align list.nodup.update_nth List.Nodup.set theorem Nodup.map_update [DecidableEq α] {l : List α} (hl : l.Nodup) (f : α → β) (x : α) (y : β) : l.map (Function.update f x y) = if x ∈ l then (l.map f).set (l.indexOf x) y else l.map f := by induction' l with hd tl ihl; · simp rw [nodup_cons] at hl simp only [mem_cons, map, ihl hl.2] by_cases H : hd = x · subst hd simp [set, hl.1] · simp [Ne.symm H, H, set, ← apply_ite (cons (f hd))] #align list.nodup.map_update List.Nodup.map_update
Mathlib/Data/List/Nodup.lean
430
438
theorem Nodup.pairwise_of_forall_ne {l : List α} {r : α → α → Prop} (hl : l.Nodup) (h : ∀ a ∈ l, ∀ b ∈ l, a ≠ b → r a b) : l.Pairwise r := by
rw [pairwise_iff_forall_sublist] intro a b hab if heq : a = b then cases heq; have := nodup_iff_sublist.mp hl _ hab; contradiction else apply h <;> try (apply hab.subset; simp) exact heq
import Mathlib.Topology.Order.IsLUB open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) variable {α β γ : Type*} section ConditionallyCompleteLinearOrder variable [ConditionallyCompleteLinearOrder α] [TopologicalSpace α] [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderClosedTopology β] [Nonempty γ] theorem Monotone.map_sSup_of_continuousAt' {f : α → β} {A : Set α} (Cf : ContinuousAt f (sSup A)) (Mf : Monotone f) (A_nonemp : A.Nonempty) (A_bdd : BddAbove A := by bddDefault) : f (sSup A) = sSup (f '' A) := --This is a particular case of the more general `IsLUB.isLUB_of_tendsto` .symm <| ((isLUB_csSup A_nonemp A_bdd).isLUB_of_tendsto (Mf.monotoneOn _) A_nonemp <| Cf.mono_left inf_le_left).csSup_eq (A_nonemp.image f) #align monotone.map_Sup_of_continuous_at' Monotone.map_sSup_of_continuousAt' theorem Monotone.map_iSup_of_continuousAt' {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α} (Cf : ContinuousAt f (iSup g)) (Mf : Monotone f) (bdd : BddAbove (range g) := by bddDefault) : f (⨆ i, g i) = ⨆ i, f (g i) := by rw [iSup, Monotone.map_sSup_of_continuousAt' Cf Mf (range_nonempty g) bdd, ← range_comp, iSup] rfl #align monotone.map_supr_of_continuous_at' Monotone.map_iSup_of_continuousAt' theorem Monotone.map_sInf_of_continuousAt' {f : α → β} {A : Set α} (Cf : ContinuousAt f (sInf A)) (Mf : Monotone f) (A_nonemp : A.Nonempty) (A_bdd : BddBelow A := by bddDefault) : f (sInf A) = sInf (f '' A) := Monotone.map_sSup_of_continuousAt' (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual A_nonemp A_bdd #align monotone.map_Inf_of_continuous_at' Monotone.map_sInf_of_continuousAt' theorem Monotone.map_iInf_of_continuousAt' {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α} (Cf : ContinuousAt f (iInf g)) (Mf : Monotone f) (bdd : BddBelow (range g) := by bddDefault) : f (⨅ i, g i) = ⨅ i, f (g i) := by rw [iInf, Monotone.map_sInf_of_continuousAt' Cf Mf (range_nonempty g) bdd, ← range_comp, iInf] rfl #align monotone.map_infi_of_continuous_at' Monotone.map_iInf_of_continuousAt' theorem Antitone.map_sInf_of_continuousAt' {f : α → β} {A : Set α} (Cf : ContinuousAt f (sInf A)) (Af : Antitone f) (A_nonemp : A.Nonempty) (A_bdd : BddBelow A := by bddDefault) : f (sInf A) = sSup (f '' A) := Monotone.map_sInf_of_continuousAt' (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd #align antitone.map_Inf_of_continuous_at' Antitone.map_sInf_of_continuousAt'
Mathlib/Topology/Order/Monotone.lean
75
79
theorem Antitone.map_iInf_of_continuousAt' {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α} (Cf : ContinuousAt f (iInf g)) (Af : Antitone f) (bdd : BddBelow (range g) := by
bddDefault) : f (⨅ i, g i) = ⨆ i, f (g i) := by rw [iInf, Antitone.map_sInf_of_continuousAt' Cf Af (range_nonempty g) bdd, ← range_comp, iSup] rfl
import Mathlib.Data.Nat.Choose.Central import Mathlib.Data.Nat.Factorization.Basic import Mathlib.Data.Nat.Multiplicity #align_import data.nat.choose.factorization from "leanprover-community/mathlib"@"dc9db541168768af03fe228703e758e649afdbfc" namespace Nat variable {p n k : ℕ} theorem factorization_choose_le_log : (choose n k).factorization p ≤ log p n := by by_cases h : (choose n k).factorization p = 0 · simp [h] have hp : p.Prime := Not.imp_symm (choose n k).factorization_eq_zero_of_non_prime h have hkn : k ≤ n := by refine le_of_not_lt fun hnk => h ?_ simp [choose_eq_zero_of_lt hnk] rw [factorization_def _ hp, @padicValNat_def _ ⟨hp⟩ _ (choose_pos hkn)] simp only [hp.multiplicity_choose hkn (lt_add_one _), PartENat.get_natCast] exact (Finset.card_filter_le _ _).trans (le_of_eq (Nat.card_Ico _ _)) #align nat.factorization_choose_le_log Nat.factorization_choose_le_log theorem pow_factorization_choose_le (hn : 0 < n) : p ^ (choose n k).factorization p ≤ n := pow_le_of_le_log hn.ne' factorization_choose_le_log #align nat.pow_factorization_choose_le Nat.pow_factorization_choose_le theorem factorization_choose_le_one (p_large : n < p ^ 2) : (choose n k).factorization p ≤ 1 := by apply factorization_choose_le_log.trans rcases eq_or_ne n 0 with (rfl | hn0); · simp exact Nat.lt_succ_iff.1 (log_lt_of_lt_pow hn0 p_large) #align nat.factorization_choose_le_one Nat.factorization_choose_le_one theorem factorization_choose_of_lt_three_mul (hp' : p ≠ 2) (hk : p ≤ k) (hk' : p ≤ n - k) (hn : n < 3 * p) : (choose n k).factorization p = 0 := by cases' em' p.Prime with hp hp · exact factorization_eq_zero_of_non_prime (choose n k) hp cases' lt_or_le n k with hnk hkn · simp [choose_eq_zero_of_lt hnk] rw [factorization_def _ hp, @padicValNat_def _ ⟨hp⟩ _ (choose_pos hkn)] simp only [hp.multiplicity_choose hkn (lt_add_one _), PartENat.get_natCast, Finset.card_eq_zero, Finset.filter_eq_empty_iff, not_le] intro i hi rcases eq_or_lt_of_le (Finset.mem_Ico.mp hi).1 with (rfl | hi) · rw [pow_one, ← add_lt_add_iff_left (2 * p), ← succ_mul, two_mul, add_add_add_comm] exact lt_of_le_of_lt (add_le_add (add_le_add_right (le_mul_of_one_le_right' ((one_le_div_iff hp.pos).mpr hk)) (k % p)) (add_le_add_right (le_mul_of_one_le_right' ((one_le_div_iff hp.pos).mpr hk')) ((n - k) % p))) (by rwa [div_add_mod, div_add_mod, add_tsub_cancel_of_le hkn]) · replace hn : n < p ^ i := by have : 3 ≤ p := lt_of_le_of_ne hp.two_le hp'.symm calc n < 3 * p := hn _ ≤ p * p := mul_le_mul_right' this p _ = p ^ 2 := (sq p).symm _ ≤ p ^ i := pow_le_pow_right hp.one_lt.le hi rwa [mod_eq_of_lt (lt_of_le_of_lt hkn hn), mod_eq_of_lt (lt_of_le_of_lt tsub_le_self hn), add_tsub_cancel_of_le hkn] #align nat.factorization_choose_of_lt_three_mul Nat.factorization_choose_of_lt_three_mul theorem factorization_centralBinom_of_two_mul_self_lt_three_mul (n_big : 2 < n) (p_le_n : p ≤ n) (big : 2 * n < 3 * p) : (centralBinom n).factorization p = 0 := by refine factorization_choose_of_lt_three_mul ?_ p_le_n (p_le_n.trans ?_) big · omega · rw [two_mul, add_tsub_cancel_left] #align nat.factorization_central_binom_of_two_mul_self_lt_three_mul Nat.factorization_centralBinom_of_two_mul_self_lt_three_mul theorem factorization_factorial_eq_zero_of_lt (h : n < p) : (factorial n).factorization p = 0 := by induction' n with n hn; · simp rw [factorial_succ, factorization_mul n.succ_ne_zero n.factorial_ne_zero, Finsupp.coe_add, Pi.add_apply, hn (lt_of_succ_lt h), add_zero, factorization_eq_zero_of_lt h] #align nat.factorization_factorial_eq_zero_of_lt Nat.factorization_factorial_eq_zero_of_lt theorem factorization_choose_eq_zero_of_lt (h : n < p) : (choose n k).factorization p = 0 := by by_cases hnk : n < k; · simp [choose_eq_zero_of_lt hnk] rw [choose_eq_factorial_div_factorial (le_of_not_lt hnk), factorization_div (factorial_mul_factorial_dvd_factorial (le_of_not_lt hnk)), Finsupp.coe_tsub, Pi.sub_apply, factorization_factorial_eq_zero_of_lt h, zero_tsub] #align nat.factorization_choose_eq_zero_of_lt Nat.factorization_choose_eq_zero_of_lt theorem factorization_centralBinom_eq_zero_of_two_mul_lt (h : 2 * n < p) : (centralBinom n).factorization p = 0 := factorization_choose_eq_zero_of_lt h #align nat.factorization_central_binom_eq_zero_of_two_mul_lt Nat.factorization_centralBinom_eq_zero_of_two_mul_lt theorem le_two_mul_of_factorization_centralBinom_pos (h_pos : 0 < (centralBinom n).factorization p) : p ≤ 2 * n := le_of_not_lt (pos_iff_ne_zero.mp h_pos ∘ factorization_centralBinom_eq_zero_of_two_mul_lt) #align nat.le_two_mul_of_factorization_central_binom_pos Nat.le_two_mul_of_factorization_centralBinom_pos
Mathlib/Data/Nat/Choose/Factorization.lean
127
139
theorem prod_pow_factorization_choose (n k : ℕ) (hkn : k ≤ n) : (∏ p ∈ Finset.range (n + 1), p ^ (Nat.choose n k).factorization p) = choose n k := by
conv => -- Porting note: was `nth_rw_rhs` rhs rw [← factorization_prod_pow_eq_self (choose_pos hkn).ne'] rw [eq_comm] apply Finset.prod_subset · intro p hp rw [Finset.mem_range] contrapose! hp rw [Finsupp.mem_support_iff, Classical.not_not, factorization_choose_eq_zero_of_lt hp] · intro p _ h2 simp [Classical.not_not.1 (mt Finsupp.mem_support_iff.2 h2)]
import Mathlib.Data.Multiset.FinsetOps import Mathlib.Data.Multiset.Fold #align_import data.multiset.lattice from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" namespace Multiset variable {α : Type*} section Inf -- can be defined with just `[Top α]` where some lemmas hold without requiring `[OrderTop α]` variable [SemilatticeInf α] [OrderTop α] def inf (s : Multiset α) : α := s.fold (· ⊓ ·) ⊤ #align multiset.inf Multiset.inf @[simp] theorem inf_coe (l : List α) : inf (l : Multiset α) = l.foldr (· ⊓ ·) ⊤ := rfl #align multiset.inf_coe Multiset.inf_coe @[simp] theorem inf_zero : (0 : Multiset α).inf = ⊤ := fold_zero _ _ #align multiset.inf_zero Multiset.inf_zero @[simp] theorem inf_cons (a : α) (s : Multiset α) : (a ::ₘ s).inf = a ⊓ s.inf := fold_cons_left _ _ _ _ #align multiset.inf_cons Multiset.inf_cons @[simp] theorem inf_singleton {a : α} : ({a} : Multiset α).inf = a := inf_top_eq _ #align multiset.inf_singleton Multiset.inf_singleton @[simp] theorem inf_add (s₁ s₂ : Multiset α) : (s₁ + s₂).inf = s₁.inf ⊓ s₂.inf := Eq.trans (by simp [inf]) (fold_add _ _ _ _ _) #align multiset.inf_add Multiset.inf_add @[simp] theorem le_inf {s : Multiset α} {a : α} : a ≤ s.inf ↔ ∀ b ∈ s, a ≤ b := Multiset.induction_on s (by simp) (by simp (config := { contextual := true }) [or_imp, forall_and]) #align multiset.le_inf Multiset.le_inf theorem inf_le {s : Multiset α} {a : α} (h : a ∈ s) : s.inf ≤ a := le_inf.1 le_rfl _ h #align multiset.inf_le Multiset.inf_le theorem inf_mono {s₁ s₂ : Multiset α} (h : s₁ ⊆ s₂) : s₂.inf ≤ s₁.inf := le_inf.2 fun _ hb => inf_le (h hb) #align multiset.inf_mono Multiset.inf_mono variable [DecidableEq α] @[simp] theorem inf_dedup (s : Multiset α) : (dedup s).inf = s.inf := fold_dedup_idem _ _ _ #align multiset.inf_dedup Multiset.inf_dedup @[simp] theorem inf_ndunion (s₁ s₂ : Multiset α) : (ndunion s₁ s₂).inf = s₁.inf ⊓ s₂.inf := by rw [← inf_dedup, dedup_ext.2, inf_dedup, inf_add]; simp #align multiset.inf_ndunion Multiset.inf_ndunion @[simp] theorem inf_union (s₁ s₂ : Multiset α) : (s₁ ∪ s₂).inf = s₁.inf ⊓ s₂.inf := by rw [← inf_dedup, dedup_ext.2, inf_dedup, inf_add]; simp #align multiset.inf_union Multiset.inf_union @[simp]
Mathlib/Data/Multiset/Lattice.lean
173
174
theorem inf_ndinsert (a : α) (s : Multiset α) : (ndinsert a s).inf = a ⊓ s.inf := by
rw [← inf_dedup, dedup_ext.2, inf_dedup, inf_cons]; simp
import Mathlib.Tactic.NormNum import Mathlib.Tactic.TryThis import Mathlib.Util.AtomM set_option autoImplicit true namespace Mathlib.Tactic.Abel open Lean Elab Meta Tactic Qq initialize registerTraceClass `abel initialize registerTraceClass `abel.detail structure Context where α : Expr univ : Level α0 : Expr isGroup : Bool inst : Expr def mkContext (e : Expr) : MetaM Context := do let α ← inferType e let c ← synthInstance (← mkAppM ``AddCommMonoid #[α]) let cg ← synthInstance? (← mkAppM ``AddCommGroup #[α]) let u ← mkFreshLevelMVar _ ← isDefEq (.sort (.succ u)) (← inferType α) let α0 ← Expr.ofNat α 0 match cg with | some cg => return ⟨α, u, α0, true, cg⟩ | _ => return ⟨α, u, α0, false, c⟩ abbrev M := ReaderT Context AtomM def Context.app (c : Context) (n : Name) (inst : Expr) : Array Expr → Expr := mkAppN (((@Expr.const n [c.univ]).app c.α).app inst) def Context.mkApp (c : Context) (n inst : Name) (l : Array Expr) : MetaM Expr := do return c.app n (← synthInstance ((Expr.const inst [c.univ]).app c.α)) l def addG : Name → Name | .str p s => .str p (s ++ "g") | n => n def iapp (n : Name) (xs : Array Expr) : M Expr := do let c ← read return c.app (if c.isGroup then addG n else n) c.inst xs def term {α} [AddCommMonoid α] (n : ℕ) (x a : α) : α := n • x + a def termg {α} [AddCommGroup α] (n : ℤ) (x a : α) : α := n • x + a def mkTerm (n x a : Expr) : M Expr := iapp ``term #[n, x, a] def intToExpr (n : ℤ) : M Expr := do Expr.ofInt (mkConst (if (← read).isGroup then ``Int else ``Nat) []) n inductive NormalExpr : Type | zero (e : Expr) : NormalExpr | nterm (e : Expr) (n : Expr × ℤ) (x : ℕ × Expr) (a : NormalExpr) : NormalExpr deriving Inhabited def NormalExpr.e : NormalExpr → Expr | .zero e => e | .nterm e .. => e instance : Coe NormalExpr Expr where coe := NormalExpr.e def NormalExpr.term' (n : Expr × ℤ) (x : ℕ × Expr) (a : NormalExpr) : M NormalExpr := return .nterm (← mkTerm n.1 x.2 a) n x a def NormalExpr.zero' : M NormalExpr := return NormalExpr.zero (← read).α0 open NormalExpr theorem const_add_term {α} [AddCommMonoid α] (k n x a a') (h : k + a = a') : k + @term α _ n x a = term n x a' := by simp [h.symm, term, add_comm, add_assoc] theorem const_add_termg {α} [AddCommGroup α] (k n x a a') (h : k + a = a') : k + @termg α _ n x a = termg n x a' := by simp [h.symm, termg, add_comm, add_assoc] theorem term_add_const {α} [AddCommMonoid α] (n x a k a') (h : a + k = a') : @term α _ n x a + k = term n x a' := by simp [h.symm, term, add_assoc] theorem term_add_constg {α} [AddCommGroup α] (n x a k a') (h : a + k = a') : @termg α _ n x a + k = termg n x a' := by simp [h.symm, termg, add_assoc] theorem term_add_term {α} [AddCommMonoid α] (n₁ x a₁ n₂ a₂ n' a') (h₁ : n₁ + n₂ = n') (h₂ : a₁ + a₂ = a') : @term α _ n₁ x a₁ + @term α _ n₂ x a₂ = term n' x a' := by simp [h₁.symm, h₂.symm, term, add_nsmul, add_assoc, add_left_comm] theorem term_add_termg {α} [AddCommGroup α] (n₁ x a₁ n₂ a₂ n' a') (h₁ : n₁ + n₂ = n') (h₂ : a₁ + a₂ = a') : @termg α _ n₁ x a₁ + @termg α _ n₂ x a₂ = termg n' x a' := by simp only [termg, h₁.symm, add_zsmul, h₂.symm] exact add_add_add_comm (n₁ • x) a₁ (n₂ • x) a₂
Mathlib/Tactic/Abel.lean
154
155
theorem zero_term {α} [AddCommMonoid α] (x a) : @term α _ 0 x a = a := by
simp [term, zero_nsmul, one_nsmul]
import Mathlib.Algebra.Module.BigOperators import Mathlib.Data.Fintype.Perm import Mathlib.GroupTheory.Perm.Finite import Mathlib.GroupTheory.Perm.List #align_import group_theory.perm.cycle.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" open Equiv Function Finset variable {ι α β : Type*} namespace Equiv.Perm section SameCycle variable {f g : Perm α} {p : α → Prop} {x y z : α} def SameCycle (f : Perm α) (x y : α) : Prop := ∃ i : ℤ, (f ^ i) x = y #align equiv.perm.same_cycle Equiv.Perm.SameCycle @[refl] theorem SameCycle.refl (f : Perm α) (x : α) : SameCycle f x x := ⟨0, rfl⟩ #align equiv.perm.same_cycle.refl Equiv.Perm.SameCycle.refl theorem SameCycle.rfl : SameCycle f x x := SameCycle.refl _ _ #align equiv.perm.same_cycle.rfl Equiv.Perm.SameCycle.rfl protected theorem _root_.Eq.sameCycle (h : x = y) (f : Perm α) : f.SameCycle x y := by rw [h] #align eq.same_cycle Eq.sameCycle @[symm] theorem SameCycle.symm : SameCycle f x y → SameCycle f y x := fun ⟨i, hi⟩ => ⟨-i, by rw [zpow_neg, ← hi, inv_apply_self]⟩ #align equiv.perm.same_cycle.symm Equiv.Perm.SameCycle.symm theorem sameCycle_comm : SameCycle f x y ↔ SameCycle f y x := ⟨SameCycle.symm, SameCycle.symm⟩ #align equiv.perm.same_cycle_comm Equiv.Perm.sameCycle_comm @[trans] theorem SameCycle.trans : SameCycle f x y → SameCycle f y z → SameCycle f x z := fun ⟨i, hi⟩ ⟨j, hj⟩ => ⟨j + i, by rw [zpow_add, mul_apply, hi, hj]⟩ #align equiv.perm.same_cycle.trans Equiv.Perm.SameCycle.trans variable (f) in theorem SameCycle.equivalence : Equivalence (SameCycle f) := ⟨SameCycle.refl f, SameCycle.symm, SameCycle.trans⟩ def SameCycle.setoid (f : Perm α) : Setoid α where iseqv := SameCycle.equivalence f @[simp] theorem sameCycle_one : SameCycle 1 x y ↔ x = y := by simp [SameCycle] #align equiv.perm.same_cycle_one Equiv.Perm.sameCycle_one @[simp] theorem sameCycle_inv : SameCycle f⁻¹ x y ↔ SameCycle f x y := (Equiv.neg _).exists_congr_left.trans <| by simp [SameCycle] #align equiv.perm.same_cycle_inv Equiv.Perm.sameCycle_inv alias ⟨SameCycle.of_inv, SameCycle.inv⟩ := sameCycle_inv #align equiv.perm.same_cycle.of_inv Equiv.Perm.SameCycle.of_inv #align equiv.perm.same_cycle.inv Equiv.Perm.SameCycle.inv @[simp] theorem sameCycle_conj : SameCycle (g * f * g⁻¹) x y ↔ SameCycle f (g⁻¹ x) (g⁻¹ y) := exists_congr fun i => by simp [conj_zpow, eq_inv_iff_eq] #align equiv.perm.same_cycle_conj Equiv.Perm.sameCycle_conj theorem SameCycle.conj : SameCycle f x y → SameCycle (g * f * g⁻¹) (g x) (g y) := by simp [sameCycle_conj] #align equiv.perm.same_cycle.conj Equiv.Perm.SameCycle.conj theorem SameCycle.apply_eq_self_iff : SameCycle f x y → (f x = x ↔ f y = y) := fun ⟨i, hi⟩ => by rw [← hi, ← mul_apply, ← zpow_one_add, add_comm, zpow_add_one, mul_apply, (f ^ i).injective.eq_iff] #align equiv.perm.same_cycle.apply_eq_self_iff Equiv.Perm.SameCycle.apply_eq_self_iff theorem SameCycle.eq_of_left (h : SameCycle f x y) (hx : IsFixedPt f x) : x = y := let ⟨_, hn⟩ := h (hx.perm_zpow _).eq.symm.trans hn #align equiv.perm.same_cycle.eq_of_left Equiv.Perm.SameCycle.eq_of_left theorem SameCycle.eq_of_right (h : SameCycle f x y) (hy : IsFixedPt f y) : x = y := h.eq_of_left <| h.apply_eq_self_iff.2 hy #align equiv.perm.same_cycle.eq_of_right Equiv.Perm.SameCycle.eq_of_right @[simp] theorem sameCycle_apply_left : SameCycle f (f x) y ↔ SameCycle f x y := (Equiv.addRight 1).exists_congr_left.trans <| by simp [zpow_sub, SameCycle, Int.add_neg_one, Function.comp] #align equiv.perm.same_cycle_apply_left Equiv.Perm.sameCycle_apply_left @[simp] theorem sameCycle_apply_right : SameCycle f x (f y) ↔ SameCycle f x y := by rw [sameCycle_comm, sameCycle_apply_left, sameCycle_comm] #align equiv.perm.same_cycle_apply_right Equiv.Perm.sameCycle_apply_right @[simp] theorem sameCycle_inv_apply_left : SameCycle f (f⁻¹ x) y ↔ SameCycle f x y := by rw [← sameCycle_apply_left, apply_inv_self] #align equiv.perm.same_cycle_inv_apply_left Equiv.Perm.sameCycle_inv_apply_left @[simp] theorem sameCycle_inv_apply_right : SameCycle f x (f⁻¹ y) ↔ SameCycle f x y := by rw [← sameCycle_apply_right, apply_inv_self] #align equiv.perm.same_cycle_inv_apply_right Equiv.Perm.sameCycle_inv_apply_right @[simp] theorem sameCycle_zpow_left {n : ℤ} : SameCycle f ((f ^ n) x) y ↔ SameCycle f x y := (Equiv.addRight (n : ℤ)).exists_congr_left.trans <| by simp [SameCycle, zpow_add] #align equiv.perm.same_cycle_zpow_left Equiv.Perm.sameCycle_zpow_left @[simp] theorem sameCycle_zpow_right {n : ℤ} : SameCycle f x ((f ^ n) y) ↔ SameCycle f x y := by rw [sameCycle_comm, sameCycle_zpow_left, sameCycle_comm] #align equiv.perm.same_cycle_zpow_right Equiv.Perm.sameCycle_zpow_right @[simp] theorem sameCycle_pow_left {n : ℕ} : SameCycle f ((f ^ n) x) y ↔ SameCycle f x y := by rw [← zpow_natCast, sameCycle_zpow_left] #align equiv.perm.same_cycle_pow_left Equiv.Perm.sameCycle_pow_left @[simp] theorem sameCycle_pow_right {n : ℕ} : SameCycle f x ((f ^ n) y) ↔ SameCycle f x y := by rw [← zpow_natCast, sameCycle_zpow_right] #align equiv.perm.same_cycle_pow_right Equiv.Perm.sameCycle_pow_right alias ⟨SameCycle.of_apply_left, SameCycle.apply_left⟩ := sameCycle_apply_left #align equiv.perm.same_cycle.of_apply_left Equiv.Perm.SameCycle.of_apply_left #align equiv.perm.same_cycle.apply_left Equiv.Perm.SameCycle.apply_left alias ⟨SameCycle.of_apply_right, SameCycle.apply_right⟩ := sameCycle_apply_right #align equiv.perm.same_cycle.of_apply_right Equiv.Perm.SameCycle.of_apply_right #align equiv.perm.same_cycle.apply_right Equiv.Perm.SameCycle.apply_right alias ⟨SameCycle.of_inv_apply_left, SameCycle.inv_apply_left⟩ := sameCycle_inv_apply_left #align equiv.perm.same_cycle.of_inv_apply_left Equiv.Perm.SameCycle.of_inv_apply_left #align equiv.perm.same_cycle.inv_apply_left Equiv.Perm.SameCycle.inv_apply_left alias ⟨SameCycle.of_inv_apply_right, SameCycle.inv_apply_right⟩ := sameCycle_inv_apply_right #align equiv.perm.same_cycle.of_inv_apply_right Equiv.Perm.SameCycle.of_inv_apply_right #align equiv.perm.same_cycle.inv_apply_right Equiv.Perm.SameCycle.inv_apply_right alias ⟨SameCycle.of_pow_left, SameCycle.pow_left⟩ := sameCycle_pow_left #align equiv.perm.same_cycle.of_pow_left Equiv.Perm.SameCycle.of_pow_left #align equiv.perm.same_cycle.pow_left Equiv.Perm.SameCycle.pow_left alias ⟨SameCycle.of_pow_right, SameCycle.pow_right⟩ := sameCycle_pow_right #align equiv.perm.same_cycle.of_pow_right Equiv.Perm.SameCycle.of_pow_right #align equiv.perm.same_cycle.pow_right Equiv.Perm.SameCycle.pow_right alias ⟨SameCycle.of_zpow_left, SameCycle.zpow_left⟩ := sameCycle_zpow_left #align equiv.perm.same_cycle.of_zpow_left Equiv.Perm.SameCycle.of_zpow_left #align equiv.perm.same_cycle.zpow_left Equiv.Perm.SameCycle.zpow_left alias ⟨SameCycle.of_zpow_right, SameCycle.zpow_right⟩ := sameCycle_zpow_right #align equiv.perm.same_cycle.of_zpow_right Equiv.Perm.SameCycle.of_zpow_right #align equiv.perm.same_cycle.zpow_right Equiv.Perm.SameCycle.zpow_right theorem SameCycle.of_pow {n : ℕ} : SameCycle (f ^ n) x y → SameCycle f x y := fun ⟨m, h⟩ => ⟨n * m, by simp [zpow_mul, h]⟩ #align equiv.perm.same_cycle.of_pow Equiv.Perm.SameCycle.of_pow theorem SameCycle.of_zpow {n : ℤ} : SameCycle (f ^ n) x y → SameCycle f x y := fun ⟨m, h⟩ => ⟨n * m, by simp [zpow_mul, h]⟩ #align equiv.perm.same_cycle.of_zpow Equiv.Perm.SameCycle.of_zpow @[simp] theorem sameCycle_subtypePerm {h} {x y : { x // p x }} : (f.subtypePerm h).SameCycle x y ↔ f.SameCycle x y := exists_congr fun n => by simp [Subtype.ext_iff] #align equiv.perm.same_cycle_subtype_perm Equiv.Perm.sameCycle_subtypePerm alias ⟨_, SameCycle.subtypePerm⟩ := sameCycle_subtypePerm #align equiv.perm.same_cycle.subtype_perm Equiv.Perm.SameCycle.subtypePerm @[simp] theorem sameCycle_extendDomain {p : β → Prop} [DecidablePred p] {f : α ≃ Subtype p} : SameCycle (g.extendDomain f) (f x) (f y) ↔ g.SameCycle x y := exists_congr fun n => by rw [← extendDomain_zpow, extendDomain_apply_image, Subtype.coe_inj, f.injective.eq_iff] #align equiv.perm.same_cycle_extend_domain Equiv.Perm.sameCycle_extendDomain alias ⟨_, SameCycle.extendDomain⟩ := sameCycle_extendDomain #align equiv.perm.same_cycle.extend_domain Equiv.Perm.SameCycle.extendDomain
Mathlib/GroupTheory/Perm/Cycle/Basic.lean
225
234
theorem SameCycle.exists_pow_eq' [Finite α] : SameCycle f x y → ∃ i < orderOf f, (f ^ i) x = y := by
classical rintro ⟨k, rfl⟩ use (k % orderOf f).natAbs have h₀ := Int.natCast_pos.mpr (orderOf_pos f) have h₁ := Int.emod_nonneg k h₀.ne' rw [← zpow_natCast, Int.natAbs_of_nonneg h₁, zpow_mod_orderOf] refine ⟨?_, by rfl⟩ rw [← Int.ofNat_lt, Int.natAbs_of_nonneg h₁] exact Int.emod_lt_of_pos _ h₀
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)]
Mathlib/LinearAlgebra/AffineSpace/Combination.lean
141
145
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]
import Mathlib.MeasureTheory.Integral.IntervalIntegral import Mathlib.Analysis.Calculus.Deriv.ZPow import Mathlib.Analysis.NormedSpace.Pointwise import Mathlib.Analysis.SpecialFunctions.NonIntegrable import Mathlib.Analysis.Analytic.Basic #align_import measure_theory.integral.circle_integral from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" variable {E : Type*} [NormedAddCommGroup E] noncomputable section open scoped Real NNReal Interval Pointwise Topology open Complex MeasureTheory TopologicalSpace Metric Function Set Filter Asymptotics def circleMap (c : ℂ) (R : ℝ) : ℝ → ℂ := fun θ => c + R * exp (θ * I) #align circle_map circleMap theorem periodic_circleMap (c : ℂ) (R : ℝ) : Periodic (circleMap c R) (2 * π) := fun θ => by simp [circleMap, add_mul, exp_periodic _] #align periodic_circle_map periodic_circleMap theorem Set.Countable.preimage_circleMap {s : Set ℂ} (hs : s.Countable) (c : ℂ) {R : ℝ} (hR : R ≠ 0) : (circleMap c R ⁻¹' s).Countable := show (((↑) : ℝ → ℂ) ⁻¹' ((· * I) ⁻¹' (exp ⁻¹' ((R * ·) ⁻¹' ((c + ·) ⁻¹' s))))).Countable from (((hs.preimage (add_right_injective _)).preimage <| mul_right_injective₀ <| ofReal_ne_zero.2 hR).preimage_cexp.preimage <| mul_left_injective₀ I_ne_zero).preimage ofReal_injective #align set.countable.preimage_circle_map Set.Countable.preimage_circleMap @[simp] theorem circleMap_sub_center (c : ℂ) (R : ℝ) (θ : ℝ) : circleMap c R θ - c = circleMap 0 R θ := by simp [circleMap] #align circle_map_sub_center circleMap_sub_center theorem circleMap_zero (R θ : ℝ) : circleMap 0 R θ = R * exp (θ * I) := zero_add _ #align circle_map_zero circleMap_zero @[simp] theorem abs_circleMap_zero (R : ℝ) (θ : ℝ) : abs (circleMap 0 R θ) = |R| := by simp [circleMap] #align abs_circle_map_zero abs_circleMap_zero theorem circleMap_mem_sphere' (c : ℂ) (R : ℝ) (θ : ℝ) : circleMap c R θ ∈ sphere c |R| := by simp #align circle_map_mem_sphere' circleMap_mem_sphere' theorem circleMap_mem_sphere (c : ℂ) {R : ℝ} (hR : 0 ≤ R) (θ : ℝ) : circleMap c R θ ∈ sphere c R := by simpa only [_root_.abs_of_nonneg hR] using circleMap_mem_sphere' c R θ #align circle_map_mem_sphere circleMap_mem_sphere theorem circleMap_mem_closedBall (c : ℂ) {R : ℝ} (hR : 0 ≤ R) (θ : ℝ) : circleMap c R θ ∈ closedBall c R := sphere_subset_closedBall (circleMap_mem_sphere c hR θ) #align circle_map_mem_closed_ball circleMap_mem_closedBall theorem circleMap_not_mem_ball (c : ℂ) (R : ℝ) (θ : ℝ) : circleMap c R θ ∉ ball c R := by simp [dist_eq, le_abs_self] #align circle_map_not_mem_ball circleMap_not_mem_ball theorem circleMap_ne_mem_ball {c : ℂ} {R : ℝ} {w : ℂ} (hw : w ∈ ball c R) (θ : ℝ) : circleMap c R θ ≠ w := (ne_of_mem_of_not_mem hw (circleMap_not_mem_ball _ _ _)).symm #align circle_map_ne_mem_ball circleMap_ne_mem_ball @[simp] theorem range_circleMap (c : ℂ) (R : ℝ) : range (circleMap c R) = sphere c |R| := calc range (circleMap c R) = c +ᵥ R • range fun θ : ℝ => exp (θ * I) := by simp (config := { unfoldPartialApp := true }) only [← image_vadd, ← image_smul, ← range_comp, vadd_eq_add, circleMap, Function.comp_def, real_smul] _ = sphere c |R| := by rw [Complex.range_exp_mul_I, smul_sphere R 0 zero_le_one] simp #align range_circle_map range_circleMap @[simp] theorem image_circleMap_Ioc (c : ℂ) (R : ℝ) : circleMap c R '' Ioc 0 (2 * π) = sphere c |R| := by rw [← range_circleMap, ← (periodic_circleMap c R).image_Ioc Real.two_pi_pos 0, zero_add] #align image_circle_map_Ioc image_circleMap_Ioc @[simp] theorem circleMap_eq_center_iff {c : ℂ} {R : ℝ} {θ : ℝ} : circleMap c R θ = c ↔ R = 0 := by simp [circleMap, exp_ne_zero] #align circle_map_eq_center_iff circleMap_eq_center_iff @[simp] theorem circleMap_zero_radius (c : ℂ) : circleMap c 0 = const ℝ c := funext fun _ => circleMap_eq_center_iff.2 rfl #align circle_map_zero_radius circleMap_zero_radius theorem circleMap_ne_center {c : ℂ} {R : ℝ} (hR : R ≠ 0) {θ : ℝ} : circleMap c R θ ≠ c := mt circleMap_eq_center_iff.1 hR #align circle_map_ne_center circleMap_ne_center theorem hasDerivAt_circleMap (c : ℂ) (R : ℝ) (θ : ℝ) : HasDerivAt (circleMap c R) (circleMap 0 R θ * I) θ := by simpa only [mul_assoc, one_mul, ofRealCLM_apply, circleMap, ofReal_one, zero_add] using (((ofRealCLM.hasDerivAt (x := θ)).mul_const I).cexp.const_mul (R : ℂ)).const_add c #align has_deriv_at_circle_map hasDerivAt_circleMap theorem differentiable_circleMap (c : ℂ) (R : ℝ) : Differentiable ℝ (circleMap c R) := fun θ => (hasDerivAt_circleMap c R θ).differentiableAt #align differentiable_circle_map differentiable_circleMap @[continuity] theorem continuous_circleMap (c : ℂ) (R : ℝ) : Continuous (circleMap c R) := (differentiable_circleMap c R).continuous #align continuous_circle_map continuous_circleMap @[measurability] theorem measurable_circleMap (c : ℂ) (R : ℝ) : Measurable (circleMap c R) := (continuous_circleMap c R).measurable #align measurable_circle_map measurable_circleMap @[simp] theorem deriv_circleMap (c : ℂ) (R : ℝ) (θ : ℝ) : deriv (circleMap c R) θ = circleMap 0 R θ * I := (hasDerivAt_circleMap _ _ _).deriv #align deriv_circle_map deriv_circleMap theorem deriv_circleMap_eq_zero_iff {c : ℂ} {R : ℝ} {θ : ℝ} : deriv (circleMap c R) θ = 0 ↔ R = 0 := by simp [I_ne_zero] #align deriv_circle_map_eq_zero_iff deriv_circleMap_eq_zero_iff theorem deriv_circleMap_ne_zero {c : ℂ} {R : ℝ} {θ : ℝ} (hR : R ≠ 0) : deriv (circleMap c R) θ ≠ 0 := mt deriv_circleMap_eq_zero_iff.1 hR #align deriv_circle_map_ne_zero deriv_circleMap_ne_zero theorem lipschitzWith_circleMap (c : ℂ) (R : ℝ) : LipschitzWith (Real.nnabs R) (circleMap c R) := lipschitzWith_of_nnnorm_deriv_le (differentiable_circleMap _ _) fun θ => NNReal.coe_le_coe.1 <| by simp #align lipschitz_with_circle_map lipschitzWith_circleMap theorem continuous_circleMap_inv {R : ℝ} {z w : ℂ} (hw : w ∈ ball z R) : Continuous fun θ => (circleMap z R θ - w)⁻¹ := by have : ∀ θ, circleMap z R θ - w ≠ 0 := by simp_rw [sub_ne_zero] exact fun θ => circleMap_ne_mem_ball hw θ -- Porting note: was `continuity` exact Continuous.inv₀ (by continuity) this #align continuous_circle_map_inv continuous_circleMap_inv def CircleIntegrable (f : ℂ → E) (c : ℂ) (R : ℝ) : Prop := IntervalIntegrable (fun θ : ℝ => f (circleMap c R θ)) volume 0 (2 * π) #align circle_integrable CircleIntegrable @[simp] theorem circleIntegrable_const (a : E) (c : ℂ) (R : ℝ) : CircleIntegrable (fun _ => a) c R := intervalIntegrable_const #align circle_integrable_const circleIntegrable_const @[simp]
Mathlib/MeasureTheory/Integral/CircleIntegral.lean
268
269
theorem circleIntegrable_zero_radius {f : ℂ → E} {c : ℂ} : CircleIntegrable f c 0 := by
simp [CircleIntegrable]
import Mathlib.GroupTheory.QuotientGroup import Mathlib.GroupTheory.Solvable import Mathlib.GroupTheory.PGroup import Mathlib.GroupTheory.Sylow import Mathlib.Data.Nat.Factorization.Basic import Mathlib.Tactic.TFAE #align_import group_theory.nilpotent from "leanprover-community/mathlib"@"2bbc7e3884ba234309d2a43b19144105a753292e" open Subgroup section WithGroup variable {G : Type*} [Group G] (H : Subgroup G) [Normal H] def upperCentralSeriesStep : Subgroup G where carrier := { x : G | ∀ y : G, x * y * x⁻¹ * y⁻¹ ∈ H } one_mem' y := by simp [Subgroup.one_mem] mul_mem' {a b ha hb y} := by convert Subgroup.mul_mem _ (ha (b * y * b⁻¹)) (hb y) using 1 group inv_mem' {x hx y} := by specialize hx y⁻¹ rw [mul_assoc, inv_inv] at hx ⊢ exact Subgroup.Normal.mem_comm inferInstance hx #align upper_central_series_step upperCentralSeriesStep theorem mem_upperCentralSeriesStep (x : G) : x ∈ upperCentralSeriesStep H ↔ ∀ y, x * y * x⁻¹ * y⁻¹ ∈ H := Iff.rfl #align mem_upper_central_series_step mem_upperCentralSeriesStep open QuotientGroup theorem upperCentralSeriesStep_eq_comap_center : upperCentralSeriesStep H = Subgroup.comap (mk' H) (center (G ⧸ H)) := by ext rw [mem_comap, mem_center_iff, forall_mk] apply forall_congr' intro y rw [coe_mk', ← QuotientGroup.mk_mul, ← QuotientGroup.mk_mul, eq_comm, eq_iff_div_mem, div_eq_mul_inv, mul_inv_rev, mul_assoc] #align upper_central_series_step_eq_comap_center upperCentralSeriesStep_eq_comap_center instance : Normal (upperCentralSeriesStep H) := by rw [upperCentralSeriesStep_eq_comap_center] infer_instance variable (G) def upperCentralSeriesAux : ℕ → Σ'H : Subgroup G, Normal H | 0 => ⟨⊥, inferInstance⟩ | n + 1 => let un := upperCentralSeriesAux n let _un_normal := un.2 ⟨upperCentralSeriesStep un.1, inferInstance⟩ #align upper_central_series_aux upperCentralSeriesAux def upperCentralSeries (n : ℕ) : Subgroup G := (upperCentralSeriesAux G n).1 #align upper_central_series upperCentralSeries instance upperCentralSeries_normal (n : ℕ) : Normal (upperCentralSeries G n) := (upperCentralSeriesAux G n).2 @[simp] theorem upperCentralSeries_zero : upperCentralSeries G 0 = ⊥ := rfl #align upper_central_series_zero upperCentralSeries_zero @[simp] theorem upperCentralSeries_one : upperCentralSeries G 1 = center G := by ext simp only [upperCentralSeries, upperCentralSeriesAux, upperCentralSeriesStep, Subgroup.mem_center_iff, mem_mk, mem_bot, Set.mem_setOf_eq] exact forall_congr' fun y => by rw [mul_inv_eq_one, mul_inv_eq_iff_eq_mul, eq_comm] #align upper_central_series_one upperCentralSeries_one theorem mem_upperCentralSeries_succ_iff (n : ℕ) (x : G) : x ∈ upperCentralSeries G (n + 1) ↔ ∀ y : G, x * y * x⁻¹ * y⁻¹ ∈ upperCentralSeries G n := Iff.rfl #align mem_upper_central_series_succ_iff mem_upperCentralSeries_succ_iff -- is_nilpotent is already defined in the root namespace (for elements of rings). class Group.IsNilpotent (G : Type*) [Group G] : Prop where nilpotent' : ∃ n : ℕ, upperCentralSeries G n = ⊤ #align group.is_nilpotent Group.IsNilpotent -- Porting note: add lemma since infer kinds are unsupported in the definition of `IsNilpotent` lemma Group.IsNilpotent.nilpotent (G : Type*) [Group G] [IsNilpotent G] : ∃ n : ℕ, upperCentralSeries G n = ⊤ := Group.IsNilpotent.nilpotent' open Group variable {G} def IsAscendingCentralSeries (H : ℕ → Subgroup G) : Prop := H 0 = ⊥ ∧ ∀ (x : G) (n : ℕ), x ∈ H (n + 1) → ∀ g, x * g * x⁻¹ * g⁻¹ ∈ H n #align is_ascending_central_series IsAscendingCentralSeries def IsDescendingCentralSeries (H : ℕ → Subgroup G) := H 0 = ⊤ ∧ ∀ (x : G) (n : ℕ), x ∈ H n → ∀ g, x * g * x⁻¹ * g⁻¹ ∈ H (n + 1) #align is_descending_central_series IsDescendingCentralSeries theorem ascending_central_series_le_upper (H : ℕ → Subgroup G) (hH : IsAscendingCentralSeries H) : ∀ n : ℕ, H n ≤ upperCentralSeries G n | 0 => hH.1.symm ▸ le_refl ⊥ | n + 1 => by intro x hx rw [mem_upperCentralSeries_succ_iff] exact fun y => ascending_central_series_le_upper H hH n (hH.2 x n hx y) #align ascending_central_series_le_upper ascending_central_series_le_upper variable (G) theorem upperCentralSeries_isAscendingCentralSeries : IsAscendingCentralSeries (upperCentralSeries G) := ⟨rfl, fun _x _n h => h⟩ #align upper_central_series_is_ascending_central_series upperCentralSeries_isAscendingCentralSeries theorem upperCentralSeries_mono : Monotone (upperCentralSeries G) := by refine monotone_nat_of_le_succ ?_ intro n x hx y rw [mul_assoc, mul_assoc, ← mul_assoc y x⁻¹ y⁻¹] exact mul_mem hx (Normal.conj_mem (upperCentralSeries_normal G n) x⁻¹ (inv_mem hx) y) #align upper_central_series_mono upperCentralSeries_mono theorem nilpotent_iff_finite_ascending_central_series : IsNilpotent G ↔ ∃ n : ℕ, ∃ H : ℕ → Subgroup G, IsAscendingCentralSeries H ∧ H n = ⊤ := by constructor · rintro ⟨n, nH⟩ exact ⟨_, _, upperCentralSeries_isAscendingCentralSeries G, nH⟩ · rintro ⟨n, H, hH, hn⟩ use n rw [eq_top_iff, ← hn] exact ascending_central_series_le_upper H hH n #align nilpotent_iff_finite_ascending_central_series nilpotent_iff_finite_ascending_central_series theorem is_decending_rev_series_of_is_ascending {H : ℕ → Subgroup G} {n : ℕ} (hn : H n = ⊤) (hasc : IsAscendingCentralSeries H) : IsDescendingCentralSeries fun m : ℕ => H (n - m) := by cases' hasc with h0 hH refine ⟨hn, fun x m hx g => ?_⟩ dsimp at hx by_cases hm : n ≤ m · rw [tsub_eq_zero_of_le hm, h0, Subgroup.mem_bot] at hx subst hx rw [show (1 : G) * g * (1⁻¹ : G) * g⁻¹ = 1 by group] exact Subgroup.one_mem _ · push_neg at hm apply hH convert hx using 1 rw [tsub_add_eq_add_tsub (Nat.succ_le_of_lt hm), Nat.succ_eq_add_one, Nat.add_sub_add_right] #align is_decending_rev_series_of_is_ascending is_decending_rev_series_of_is_ascending
Mathlib/GroupTheory/Nilpotent.lean
246
257
theorem is_ascending_rev_series_of_is_descending {H : ℕ → Subgroup G} {n : ℕ} (hn : H n = ⊥) (hdesc : IsDescendingCentralSeries H) : IsAscendingCentralSeries fun m : ℕ => H (n - m) := by
cases' hdesc with h0 hH refine ⟨hn, fun x m hx g => ?_⟩ dsimp only at hx ⊢ by_cases hm : n ≤ m · have hnm : n - m = 0 := tsub_eq_zero_iff_le.mpr hm rw [hnm, h0] exact mem_top _ · push_neg at hm convert hH x _ hx g using 1 rw [tsub_add_eq_add_tsub (Nat.succ_le_of_lt hm), Nat.succ_eq_add_one, Nat.add_sub_add_right]
import Mathlib.Analysis.SpecialFunctions.Pow.Real #align_import analysis.special_functions.pow.nnreal from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" noncomputable section open scoped Classical open Real NNReal ENNReal ComplexConjugate open Finset Function Set namespace NNReal variable {w x y z : ℝ} noncomputable def rpow (x : ℝ≥0) (y : ℝ) : ℝ≥0 := ⟨(x : ℝ) ^ y, Real.rpow_nonneg x.2 y⟩ #align nnreal.rpow NNReal.rpow noncomputable instance : Pow ℝ≥0 ℝ := ⟨rpow⟩ @[simp] theorem rpow_eq_pow (x : ℝ≥0) (y : ℝ) : rpow x y = x ^ y := rfl #align nnreal.rpow_eq_pow NNReal.rpow_eq_pow @[simp, norm_cast] theorem coe_rpow (x : ℝ≥0) (y : ℝ) : ((x ^ y : ℝ≥0) : ℝ) = (x : ℝ) ^ y := rfl #align nnreal.coe_rpow NNReal.coe_rpow @[simp] theorem rpow_zero (x : ℝ≥0) : x ^ (0 : ℝ) = 1 := NNReal.eq <| Real.rpow_zero _ #align nnreal.rpow_zero NNReal.rpow_zero @[simp] theorem rpow_eq_zero_iff {x : ℝ≥0} {y : ℝ} : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by rw [← NNReal.coe_inj, coe_rpow, ← NNReal.coe_eq_zero] exact Real.rpow_eq_zero_iff_of_nonneg x.2 #align nnreal.rpow_eq_zero_iff NNReal.rpow_eq_zero_iff @[simp] theorem zero_rpow {x : ℝ} (h : x ≠ 0) : (0 : ℝ≥0) ^ x = 0 := NNReal.eq <| Real.zero_rpow h #align nnreal.zero_rpow NNReal.zero_rpow @[simp] theorem rpow_one (x : ℝ≥0) : x ^ (1 : ℝ) = x := NNReal.eq <| Real.rpow_one _ #align nnreal.rpow_one NNReal.rpow_one @[simp] theorem one_rpow (x : ℝ) : (1 : ℝ≥0) ^ x = 1 := NNReal.eq <| Real.one_rpow _ #align nnreal.one_rpow NNReal.one_rpow theorem rpow_add {x : ℝ≥0} (hx : x ≠ 0) (y z : ℝ) : x ^ (y + z) = x ^ y * x ^ z := NNReal.eq <| Real.rpow_add (pos_iff_ne_zero.2 hx) _ _ #align nnreal.rpow_add NNReal.rpow_add theorem rpow_add' (x : ℝ≥0) {y z : ℝ} (h : y + z ≠ 0) : x ^ (y + z) = x ^ y * x ^ z := NNReal.eq <| Real.rpow_add' x.2 h #align nnreal.rpow_add' NNReal.rpow_add' lemma rpow_of_add_eq (x : ℝ≥0) (hw : w ≠ 0) (h : y + z = w) : x ^ w = x ^ y * x ^ z := by rw [← h, rpow_add']; rwa [h] theorem rpow_mul (x : ℝ≥0) (y z : ℝ) : x ^ (y * z) = (x ^ y) ^ z := NNReal.eq <| Real.rpow_mul x.2 y z #align nnreal.rpow_mul NNReal.rpow_mul theorem rpow_neg (x : ℝ≥0) (y : ℝ) : x ^ (-y) = (x ^ y)⁻¹ := NNReal.eq <| Real.rpow_neg x.2 _ #align nnreal.rpow_neg NNReal.rpow_neg theorem rpow_neg_one (x : ℝ≥0) : x ^ (-1 : ℝ) = x⁻¹ := by simp [rpow_neg] #align nnreal.rpow_neg_one NNReal.rpow_neg_one theorem rpow_sub {x : ℝ≥0} (hx : x ≠ 0) (y z : ℝ) : x ^ (y - z) = x ^ y / x ^ z := NNReal.eq <| Real.rpow_sub (pos_iff_ne_zero.2 hx) y z #align nnreal.rpow_sub NNReal.rpow_sub theorem rpow_sub' (x : ℝ≥0) {y z : ℝ} (h : y - z ≠ 0) : x ^ (y - z) = x ^ y / x ^ z := NNReal.eq <| Real.rpow_sub' x.2 h #align nnreal.rpow_sub' NNReal.rpow_sub' theorem rpow_inv_rpow_self {y : ℝ} (hy : y ≠ 0) (x : ℝ≥0) : (x ^ y) ^ (1 / y) = x := by field_simp [← rpow_mul] #align nnreal.rpow_inv_rpow_self NNReal.rpow_inv_rpow_self theorem rpow_self_rpow_inv {y : ℝ} (hy : y ≠ 0) (x : ℝ≥0) : (x ^ (1 / y)) ^ y = x := by field_simp [← rpow_mul] #align nnreal.rpow_self_rpow_inv NNReal.rpow_self_rpow_inv theorem inv_rpow (x : ℝ≥0) (y : ℝ) : x⁻¹ ^ y = (x ^ y)⁻¹ := NNReal.eq <| Real.inv_rpow x.2 y #align nnreal.inv_rpow NNReal.inv_rpow theorem div_rpow (x y : ℝ≥0) (z : ℝ) : (x / y) ^ z = x ^ z / y ^ z := NNReal.eq <| Real.div_rpow x.2 y.2 z #align nnreal.div_rpow NNReal.div_rpow
Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean
124
127
theorem sqrt_eq_rpow (x : ℝ≥0) : sqrt x = x ^ (1 / (2 : ℝ)) := by
refine NNReal.eq ?_ push_cast exact Real.sqrt_eq_rpow x.1
import Mathlib.Analysis.Complex.UpperHalfPlane.Topology import Mathlib.Analysis.SpecialFunctions.Arsinh import Mathlib.Geometry.Euclidean.Inversion.Basic #align_import analysis.complex.upper_half_plane.metric from "leanprover-community/mathlib"@"caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c" noncomputable section open scoped UpperHalfPlane ComplexConjugate NNReal Topology MatrixGroups open Set Metric Filter Real variable {z w : ℍ} {r R : ℝ} namespace UpperHalfPlane instance : Dist ℍ := ⟨fun z w => 2 * arsinh (dist (z : ℂ) w / (2 * √(z.im * w.im)))⟩ theorem dist_eq (z w : ℍ) : dist z w = 2 * arsinh (dist (z : ℂ) w / (2 * √(z.im * w.im))) := rfl #align upper_half_plane.dist_eq UpperHalfPlane.dist_eq theorem sinh_half_dist (z w : ℍ) : sinh (dist z w / 2) = dist (z : ℂ) w / (2 * √(z.im * w.im)) := by rw [dist_eq, mul_div_cancel_left₀ (arsinh _) two_ne_zero, sinh_arsinh] #align upper_half_plane.sinh_half_dist UpperHalfPlane.sinh_half_dist theorem cosh_half_dist (z w : ℍ) : cosh (dist z w / 2) = dist (z : ℂ) (conj (w : ℂ)) / (2 * √(z.im * w.im)) := by rw [← sq_eq_sq, cosh_sq', sinh_half_dist, div_pow, div_pow, one_add_div, mul_pow, sq_sqrt] · congr 1 simp only [Complex.dist_eq, Complex.sq_abs, Complex.normSq_sub, Complex.normSq_conj, Complex.conj_conj, Complex.mul_re, Complex.conj_re, Complex.conj_im, coe_im] ring all_goals positivity #align upper_half_plane.cosh_half_dist UpperHalfPlane.cosh_half_dist theorem tanh_half_dist (z w : ℍ) : tanh (dist z w / 2) = dist (z : ℂ) w / dist (z : ℂ) (conj ↑w) := by rw [tanh_eq_sinh_div_cosh, sinh_half_dist, cosh_half_dist, div_div_div_comm, div_self, div_one] positivity #align upper_half_plane.tanh_half_dist UpperHalfPlane.tanh_half_dist theorem exp_half_dist (z w : ℍ) : exp (dist z w / 2) = (dist (z : ℂ) w + dist (z : ℂ) (conj ↑w)) / (2 * √(z.im * w.im)) := by rw [← sinh_add_cosh, sinh_half_dist, cosh_half_dist, add_div] #align upper_half_plane.exp_half_dist UpperHalfPlane.exp_half_dist theorem cosh_dist (z w : ℍ) : cosh (dist z w) = 1 + dist (z : ℂ) w ^ 2 / (2 * z.im * w.im) := by rw [dist_eq, cosh_two_mul, cosh_sq', add_assoc, ← two_mul, sinh_arsinh, div_pow, mul_pow, sq_sqrt, sq (2 : ℝ), mul_assoc, ← mul_div_assoc, mul_assoc, mul_div_mul_left] <;> positivity #align upper_half_plane.cosh_dist UpperHalfPlane.cosh_dist theorem sinh_half_dist_add_dist (a b c : ℍ) : sinh ((dist a b + dist b c) / 2) = (dist (a : ℂ) b * dist (c : ℂ) (conj ↑b) + dist (b : ℂ) c * dist (a : ℂ) (conj ↑b)) / (2 * √(a.im * c.im) * dist (b : ℂ) (conj ↑b)) := by simp only [add_div _ _ (2 : ℝ), sinh_add, sinh_half_dist, cosh_half_dist, div_mul_div_comm] rw [← add_div, Complex.dist_self_conj, coe_im, abs_of_pos b.im_pos, mul_comm (dist (b : ℂ) _), dist_comm (b : ℂ), Complex.dist_conj_comm, mul_mul_mul_comm, mul_mul_mul_comm _ _ _ b.im] congr 2 rw [sqrt_mul, sqrt_mul, sqrt_mul, mul_comm (√a.im), mul_mul_mul_comm, mul_self_sqrt, mul_comm] <;> exact (im_pos _).le #align upper_half_plane.sinh_half_dist_add_dist UpperHalfPlane.sinh_half_dist_add_dist protected theorem dist_comm (z w : ℍ) : dist z w = dist w z := by simp only [dist_eq, dist_comm (z : ℂ), mul_comm] #align upper_half_plane.dist_comm UpperHalfPlane.dist_comm theorem dist_le_iff_le_sinh : dist z w ≤ r ↔ dist (z : ℂ) w / (2 * √(z.im * w.im)) ≤ sinh (r / 2) := by rw [← div_le_div_right (zero_lt_two' ℝ), ← sinh_le_sinh, sinh_half_dist] #align upper_half_plane.dist_le_iff_le_sinh UpperHalfPlane.dist_le_iff_le_sinh
Mathlib/Analysis/Complex/UpperHalfPlane/Metric.lean
96
98
theorem dist_eq_iff_eq_sinh : dist z w = r ↔ dist (z : ℂ) w / (2 * √(z.im * w.im)) = sinh (r / 2) := by
rw [← div_left_inj' (two_ne_zero' ℝ), ← sinh_inj, sinh_half_dist]
import Mathlib.Analysis.Normed.Field.Basic #align_import topology.metric_space.cau_seq_filter from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" universe u v open Set Filter open scoped Classical open Topology variable {β : Type v} theorem CauSeq.tendsto_limit [NormedRing β] [hn : IsAbsoluteValue (norm : β → ℝ)] (f : CauSeq β norm) [CauSeq.IsComplete β norm] : Tendsto f atTop (𝓝 f.lim) := tendsto_nhds.mpr (by intro s os lfs suffices ∃ a : ℕ, ∀ b : ℕ, b ≥ a → f b ∈ s by simpa using this rcases Metric.isOpen_iff.1 os _ lfs with ⟨ε, ⟨hε, hεs⟩⟩ cases' Setoid.symm (CauSeq.equiv_lim f) _ hε with N hN exists N intro b hb apply hεs dsimp [Metric.ball] rw [dist_comm, dist_eq_norm] solve_by_elim) #align cau_seq.tendsto_limit CauSeq.tendsto_limit variable [NormedField β] open Metric
Mathlib/Topology/MetricSpace/CauSeqFilter.lean
55
64
theorem CauchySeq.isCauSeq {f : ℕ → β} (hf : CauchySeq f) : IsCauSeq norm f := by
cases' cauchy_iff.1 hf with hf1 hf2 intro ε hε rcases hf2 { x | dist x.1 x.2 < ε } (dist_mem_uniformity hε) with ⟨t, ⟨ht, htsub⟩⟩ simp only [mem_map, mem_atTop_sets, ge_iff_le, mem_preimage] at ht; cases' ht with N hN exists N intro j hj rw [← dist_eq_norm] apply @htsub (f j, f N) apply Set.mk_mem_prod <;> solve_by_elim [le_refl]
import Mathlib.Data.List.Nodup import Mathlib.Data.List.Zip import Mathlib.Data.Nat.Defs import Mathlib.Data.List.Infix #align_import data.list.rotate from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" universe u variable {α : Type u} open Nat Function namespace List theorem rotate_mod (l : List α) (n : ℕ) : l.rotate (n % l.length) = l.rotate n := by simp [rotate] #align list.rotate_mod List.rotate_mod @[simp] theorem rotate_nil (n : ℕ) : ([] : List α).rotate n = [] := by simp [rotate] #align list.rotate_nil List.rotate_nil @[simp] theorem rotate_zero (l : List α) : l.rotate 0 = l := by simp [rotate] #align list.rotate_zero List.rotate_zero -- Porting note: removing simp, simp can prove it theorem rotate'_nil (n : ℕ) : ([] : List α).rotate' n = [] := by cases n <;> rfl #align list.rotate'_nil List.rotate'_nil @[simp] theorem rotate'_zero (l : List α) : l.rotate' 0 = l := by cases l <;> rfl #align list.rotate'_zero List.rotate'_zero theorem rotate'_cons_succ (l : List α) (a : α) (n : ℕ) : (a :: l : List α).rotate' n.succ = (l ++ [a]).rotate' n := by simp [rotate'] #align list.rotate'_cons_succ List.rotate'_cons_succ @[simp] theorem length_rotate' : ∀ (l : List α) (n : ℕ), (l.rotate' n).length = l.length | [], _ => by simp | a :: l, 0 => rfl | a :: l, n + 1 => by rw [List.rotate', length_rotate' (l ++ [a]) n]; simp #align list.length_rotate' List.length_rotate' theorem rotate'_eq_drop_append_take : ∀ {l : List α} {n : ℕ}, n ≤ l.length → l.rotate' n = l.drop n ++ l.take n | [], n, h => by simp [drop_append_of_le_length h] | l, 0, h => by simp [take_append_of_le_length h] | a :: l, n + 1, h => by have hnl : n ≤ l.length := le_of_succ_le_succ h have hnl' : n ≤ (l ++ [a]).length := by rw [length_append, length_cons, List.length]; exact le_of_succ_le h rw [rotate'_cons_succ, rotate'_eq_drop_append_take hnl', drop, take, drop_append_of_le_length hnl, take_append_of_le_length hnl]; simp #align list.rotate'_eq_drop_append_take List.rotate'_eq_drop_append_take theorem rotate'_rotate' : ∀ (l : List α) (n m : ℕ), (l.rotate' n).rotate' m = l.rotate' (n + m) | a :: l, 0, m => by simp | [], n, m => by simp | a :: l, n + 1, m => by rw [rotate'_cons_succ, rotate'_rotate' _ n, Nat.add_right_comm, ← rotate'_cons_succ, Nat.succ_eq_add_one] #align list.rotate'_rotate' List.rotate'_rotate' @[simp] theorem rotate'_length (l : List α) : rotate' l l.length = l := by rw [rotate'_eq_drop_append_take le_rfl]; simp #align list.rotate'_length List.rotate'_length @[simp] theorem rotate'_length_mul (l : List α) : ∀ n : ℕ, l.rotate' (l.length * n) = l | 0 => by simp | n + 1 => calc l.rotate' (l.length * (n + 1)) = (l.rotate' (l.length * n)).rotate' (l.rotate' (l.length * n)).length := by simp [-rotate'_length, Nat.mul_succ, rotate'_rotate'] _ = l := by rw [rotate'_length, rotate'_length_mul l n] #align list.rotate'_length_mul List.rotate'_length_mul theorem rotate'_mod (l : List α) (n : ℕ) : l.rotate' (n % l.length) = l.rotate' n := calc l.rotate' (n % l.length) = (l.rotate' (n % l.length)).rotate' ((l.rotate' (n % l.length)).length * (n / l.length)) := by rw [rotate'_length_mul] _ = l.rotate' n := by rw [rotate'_rotate', length_rotate', Nat.mod_add_div] #align list.rotate'_mod List.rotate'_mod theorem rotate_eq_rotate' (l : List α) (n : ℕ) : l.rotate n = l.rotate' n := if h : l.length = 0 then by simp_all [length_eq_zero] else by rw [← rotate'_mod, rotate'_eq_drop_append_take (le_of_lt (Nat.mod_lt _ (Nat.pos_of_ne_zero h)))]; simp [rotate] #align list.rotate_eq_rotate' List.rotate_eq_rotate' theorem rotate_cons_succ (l : List α) (a : α) (n : ℕ) : (a :: l : List α).rotate (n + 1) = (l ++ [a]).rotate n := by rw [rotate_eq_rotate', rotate_eq_rotate', rotate'_cons_succ] #align list.rotate_cons_succ List.rotate_cons_succ @[simp] theorem mem_rotate : ∀ {l : List α} {a : α} {n : ℕ}, a ∈ l.rotate n ↔ a ∈ l | [], _, n => by simp | a :: l, _, 0 => by simp | a :: l, _, n + 1 => by simp [rotate_cons_succ, mem_rotate, or_comm] #align list.mem_rotate List.mem_rotate @[simp] theorem length_rotate (l : List α) (n : ℕ) : (l.rotate n).length = l.length := by rw [rotate_eq_rotate', length_rotate'] #align list.length_rotate List.length_rotate @[simp] theorem rotate_replicate (a : α) (n : ℕ) (k : ℕ) : (replicate n a).rotate k = replicate n a := eq_replicate.2 ⟨by rw [length_rotate, length_replicate], fun b hb => eq_of_mem_replicate <| mem_rotate.1 hb⟩ #align list.rotate_replicate List.rotate_replicate theorem rotate_eq_drop_append_take {l : List α} {n : ℕ} : n ≤ l.length → l.rotate n = l.drop n ++ l.take n := by rw [rotate_eq_rotate']; exact rotate'_eq_drop_append_take #align list.rotate_eq_drop_append_take List.rotate_eq_drop_append_take theorem rotate_eq_drop_append_take_mod {l : List α} {n : ℕ} : l.rotate n = l.drop (n % l.length) ++ l.take (n % l.length) := by rcases l.length.zero_le.eq_or_lt with hl | hl · simp [eq_nil_of_length_eq_zero hl.symm] rw [← rotate_eq_drop_append_take (n.mod_lt hl).le, rotate_mod] #align list.rotate_eq_drop_append_take_mod List.rotate_eq_drop_append_take_mod @[simp] theorem rotate_append_length_eq (l l' : List α) : (l ++ l').rotate l.length = l' ++ l := by rw [rotate_eq_rotate'] induction l generalizing l' · simp · simp_all [rotate'] #align list.rotate_append_length_eq List.rotate_append_length_eq theorem rotate_rotate (l : List α) (n m : ℕ) : (l.rotate n).rotate m = l.rotate (n + m) := by rw [rotate_eq_rotate', rotate_eq_rotate', rotate_eq_rotate', rotate'_rotate'] #align list.rotate_rotate List.rotate_rotate @[simp] theorem rotate_length (l : List α) : rotate l l.length = l := by rw [rotate_eq_rotate', rotate'_length] #align list.rotate_length List.rotate_length @[simp] theorem rotate_length_mul (l : List α) (n : ℕ) : l.rotate (l.length * n) = l := by rw [rotate_eq_rotate', rotate'_length_mul] #align list.rotate_length_mul List.rotate_length_mul theorem rotate_perm (l : List α) (n : ℕ) : l.rotate n ~ l := by rw [rotate_eq_rotate'] induction' n with n hn generalizing l · simp · cases' l with hd tl · simp · rw [rotate'_cons_succ] exact (hn _).trans (perm_append_singleton _ _) #align list.rotate_perm List.rotate_perm @[simp] theorem nodup_rotate {l : List α} {n : ℕ} : Nodup (l.rotate n) ↔ Nodup l := (rotate_perm l n).nodup_iff #align list.nodup_rotate List.nodup_rotate @[simp] theorem rotate_eq_nil_iff {l : List α} {n : ℕ} : l.rotate n = [] ↔ l = [] := by induction' n with n hn generalizing l · simp · cases' l with hd tl · simp · simp [rotate_cons_succ, hn] #align list.rotate_eq_nil_iff List.rotate_eq_nil_iff @[simp]
Mathlib/Data/List/Rotate.lean
201
202
theorem nil_eq_rotate_iff {l : List α} {n : ℕ} : [] = l.rotate n ↔ [] = l := by
rw [eq_comm, rotate_eq_nil_iff, eq_comm]
import Mathlib.Algebra.Module.Submodule.EqLocus import Mathlib.Algebra.Module.Submodule.RestrictScalars import Mathlib.Algebra.Ring.Idempotents import Mathlib.Data.Set.Pointwise.SMul import Mathlib.LinearAlgebra.Basic import Mathlib.Order.CompactlyGenerated.Basic import Mathlib.Order.OmegaCompletePartialOrder #align_import linear_algebra.span from "leanprover-community/mathlib"@"10878f6bf1dab863445907ab23fbfcefcb5845d0" variable {R R₂ K M M₂ V S : Type*} namespace Submodule open Function Set open Pointwise section AddCommMonoid variable [Semiring R] [AddCommMonoid M] [Module R M] variable {x : M} (p p' : Submodule R M) variable [Semiring R₂] {σ₁₂ : R →+* R₂} variable [AddCommMonoid M₂] [Module R₂ M₂] variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂] section variable (R) def span (s : Set M) : Submodule R M := sInf { p | s ⊆ p } #align submodule.span Submodule.span variable {R} -- Porting note: renamed field to `principal'` and added `principal` to fix explicit argument @[mk_iff] class IsPrincipal (S : Submodule R M) : Prop where principal' : ∃ a, S = span R {a} #align submodule.is_principal Submodule.IsPrincipal theorem IsPrincipal.principal (S : Submodule R M) [S.IsPrincipal] : ∃ a, S = span R {a} := Submodule.IsPrincipal.principal' #align submodule.is_principal.principal Submodule.IsPrincipal.principal end variable {s t : Set M} theorem mem_span : x ∈ span R s ↔ ∀ p : Submodule R M, s ⊆ p → x ∈ p := mem_iInter₂ #align submodule.mem_span Submodule.mem_span @[aesop safe 20 apply (rule_sets := [SetLike])] theorem subset_span : s ⊆ span R s := fun _ h => mem_span.2 fun _ hp => hp h #align submodule.subset_span Submodule.subset_span theorem span_le {p} : span R s ≤ p ↔ s ⊆ p := ⟨Subset.trans subset_span, fun ss _ h => mem_span.1 h _ ss⟩ #align submodule.span_le Submodule.span_le theorem span_mono (h : s ⊆ t) : span R s ≤ span R t := span_le.2 <| Subset.trans h subset_span #align submodule.span_mono Submodule.span_mono theorem span_monotone : Monotone (span R : Set M → Submodule R M) := fun _ _ => span_mono #align submodule.span_monotone Submodule.span_monotone theorem span_eq_of_le (h₁ : s ⊆ p) (h₂ : p ≤ span R s) : span R s = p := le_antisymm (span_le.2 h₁) h₂ #align submodule.span_eq_of_le Submodule.span_eq_of_le theorem span_eq : span R (p : Set M) = p := span_eq_of_le _ (Subset.refl _) subset_span #align submodule.span_eq Submodule.span_eq theorem span_eq_span (hs : s ⊆ span R t) (ht : t ⊆ span R s) : span R s = span R t := le_antisymm (span_le.2 hs) (span_le.2 ht) #align submodule.span_eq_span Submodule.span_eq_span lemma coe_span_eq_self [SetLike S M] [AddSubmonoidClass S M] [SMulMemClass S R M] (s : S) : (span R (s : Set M) : Set M) = s := by refine le_antisymm ?_ subset_span let s' : Submodule R M := { carrier := s add_mem' := add_mem zero_mem' := zero_mem _ smul_mem' := SMulMemClass.smul_mem } exact span_le (p := s') |>.mpr le_rfl @[simp] theorem span_coe_eq_restrictScalars [Semiring S] [SMul S R] [Module S M] [IsScalarTower S R M] : span S (p : Set M) = p.restrictScalars S := span_eq (p.restrictScalars S) #align submodule.span_coe_eq_restrict_scalars Submodule.span_coe_eq_restrictScalars theorem image_span_subset (f : F) (s : Set M) (N : Submodule R₂ M₂) : f '' span R s ⊆ N ↔ ∀ m ∈ s, f m ∈ N := image_subset_iff.trans <| span_le (p := N.comap f) theorem image_span_subset_span (f : F) (s : Set M) : f '' span R s ⊆ span R₂ (f '' s) := (image_span_subset f s _).2 fun x hx ↦ subset_span ⟨x, hx, rfl⟩ theorem map_span [RingHomSurjective σ₁₂] (f : F) (s : Set M) : (span R s).map f = span R₂ (f '' s) := Eq.symm <| span_eq_of_le _ (Set.image_subset f subset_span) (image_span_subset_span f s) #align submodule.map_span Submodule.map_span alias _root_.LinearMap.map_span := Submodule.map_span #align linear_map.map_span LinearMap.map_span theorem map_span_le [RingHomSurjective σ₁₂] (f : F) (s : Set M) (N : Submodule R₂ M₂) : map f (span R s) ≤ N ↔ ∀ m ∈ s, f m ∈ N := image_span_subset f s N #align submodule.map_span_le Submodule.map_span_le alias _root_.LinearMap.map_span_le := Submodule.map_span_le #align linear_map.map_span_le LinearMap.map_span_le @[simp] theorem span_insert_zero : span R (insert (0 : M) s) = span R s := by refine le_antisymm ?_ (Submodule.span_mono (Set.subset_insert 0 s)) rw [span_le, Set.insert_subset_iff] exact ⟨by simp only [SetLike.mem_coe, Submodule.zero_mem], Submodule.subset_span⟩ #align submodule.span_insert_zero Submodule.span_insert_zero -- See also `span_preimage_eq` below. theorem span_preimage_le (f : F) (s : Set M₂) : span R (f ⁻¹' s) ≤ (span R₂ s).comap f := by rw [span_le, comap_coe] exact preimage_mono subset_span #align submodule.span_preimage_le Submodule.span_preimage_le alias _root_.LinearMap.span_preimage_le := Submodule.span_preimage_le #align linear_map.span_preimage_le LinearMap.span_preimage_le theorem closure_subset_span {s : Set M} : (AddSubmonoid.closure s : Set M) ⊆ span R s := (@AddSubmonoid.closure_le _ _ _ (span R s).toAddSubmonoid).mpr subset_span #align submodule.closure_subset_span Submodule.closure_subset_span theorem closure_le_toAddSubmonoid_span {s : Set M} : AddSubmonoid.closure s ≤ (span R s).toAddSubmonoid := closure_subset_span #align submodule.closure_le_to_add_submonoid_span Submodule.closure_le_toAddSubmonoid_span @[simp] theorem span_closure {s : Set M} : span R (AddSubmonoid.closure s : Set M) = span R s := le_antisymm (span_le.mpr closure_subset_span) (span_mono AddSubmonoid.subset_closure) #align submodule.span_closure Submodule.span_closure @[elab_as_elim] theorem span_induction {p : M → Prop} (h : x ∈ span R s) (mem : ∀ x ∈ s, p x) (zero : p 0) (add : ∀ x y, p x → p y → p (x + y)) (smul : ∀ (a : R) (x), p x → p (a • x)) : p x := ((@span_le (p := ⟨⟨⟨p, by intros x y; exact add x y⟩, zero⟩, smul⟩)) s).2 mem h #align submodule.span_induction Submodule.span_induction theorem span_induction₂ {p : M → M → Prop} {a b : M} (ha : a ∈ Submodule.span R s) (hb : b ∈ Submodule.span R s) (mem_mem : ∀ x ∈ s, ∀ y ∈ s, p x y) (zero_left : ∀ y, p 0 y) (zero_right : ∀ x, p x 0) (add_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ + x₂) y) (add_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ + y₂)) (smul_left : ∀ (r : R) x y, p x y → p (r • x) y) (smul_right : ∀ (r : R) x y, p x y → p x (r • y)) : p a b := Submodule.span_induction ha (fun x hx => Submodule.span_induction hb (mem_mem x hx) (zero_right x) (add_right x) fun r => smul_right r x) (zero_left b) (fun x₁ x₂ => add_left x₁ x₂ b) fun r x => smul_left r x b @[elab_as_elim]
Mathlib/LinearAlgebra/Span.lean
202
214
theorem span_induction' {p : ∀ x, x ∈ span R s → Prop} (mem : ∀ (x) (h : x ∈ s), p x (subset_span h)) (zero : p 0 (Submodule.zero_mem _)) (add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›)) (smul : ∀ (a : R) (x hx), p x hx → p (a • x) (Submodule.smul_mem _ _ ‹_›)) {x} (hx : x ∈ span R s) : p x hx := by
refine Exists.elim ?_ fun (hx : x ∈ span R s) (hc : p x hx) => hc refine span_induction hx (fun m hm => ⟨subset_span hm, mem m hm⟩) ⟨zero_mem _, zero⟩ (fun x y hx hy => Exists.elim hx fun hx' hx => Exists.elim hy fun hy' hy => ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩) fun r x hx => Exists.elim hx fun hx' hx => ⟨smul_mem _ _ hx', smul r _ _ hx⟩
import Mathlib.Analysis.Analytic.Basic import Mathlib.Analysis.Analytic.CPolynomial import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.ContDiff.Defs import Mathlib.Analysis.Calculus.FDeriv.Add #align_import analysis.calculus.fderiv_analytic from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" open Filter Asymptotics open scoped ENNReal universe u v variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {E : Type u} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F] section fderiv variable {p : FormalMultilinearSeries 𝕜 E F} {r : ℝ≥0∞} variable {f : E → F} {x : E} {s : Set E} theorem HasFPowerSeriesAt.hasStrictFDerivAt (h : HasFPowerSeriesAt f p x) : HasStrictFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p 1)) x := by refine h.isBigO_image_sub_norm_mul_norm_sub.trans_isLittleO (IsLittleO.of_norm_right ?_) refine isLittleO_iff_exists_eq_mul.2 ⟨fun y => ‖y - (x, x)‖, ?_, EventuallyEq.rfl⟩ refine (continuous_id.sub continuous_const).norm.tendsto' _ _ ?_ rw [_root_.id, sub_self, norm_zero] #align has_fpower_series_at.has_strict_fderiv_at HasFPowerSeriesAt.hasStrictFDerivAt theorem HasFPowerSeriesAt.hasFDerivAt (h : HasFPowerSeriesAt f p x) : HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p 1)) x := h.hasStrictFDerivAt.hasFDerivAt #align has_fpower_series_at.has_fderiv_at HasFPowerSeriesAt.hasFDerivAt theorem HasFPowerSeriesAt.differentiableAt (h : HasFPowerSeriesAt f p x) : DifferentiableAt 𝕜 f x := h.hasFDerivAt.differentiableAt #align has_fpower_series_at.differentiable_at HasFPowerSeriesAt.differentiableAt theorem AnalyticAt.differentiableAt : AnalyticAt 𝕜 f x → DifferentiableAt 𝕜 f x | ⟨_, hp⟩ => hp.differentiableAt #align analytic_at.differentiable_at AnalyticAt.differentiableAt theorem AnalyticAt.differentiableWithinAt (h : AnalyticAt 𝕜 f x) : DifferentiableWithinAt 𝕜 f s x := h.differentiableAt.differentiableWithinAt #align analytic_at.differentiable_within_at AnalyticAt.differentiableWithinAt theorem HasFPowerSeriesAt.fderiv_eq (h : HasFPowerSeriesAt f p x) : fderiv 𝕜 f x = continuousMultilinearCurryFin1 𝕜 E F (p 1) := h.hasFDerivAt.fderiv #align has_fpower_series_at.fderiv_eq HasFPowerSeriesAt.fderiv_eq theorem HasFPowerSeriesOnBall.differentiableOn [CompleteSpace F] (h : HasFPowerSeriesOnBall f p x r) : DifferentiableOn 𝕜 f (EMetric.ball x r) := fun _ hy => (h.analyticAt_of_mem hy).differentiableWithinAt #align has_fpower_series_on_ball.differentiable_on HasFPowerSeriesOnBall.differentiableOn theorem AnalyticOn.differentiableOn (h : AnalyticOn 𝕜 f s) : DifferentiableOn 𝕜 f s := fun y hy => (h y hy).differentiableWithinAt #align analytic_on.differentiable_on AnalyticOn.differentiableOn theorem HasFPowerSeriesOnBall.hasFDerivAt [CompleteSpace F] (h : HasFPowerSeriesOnBall f p x r) {y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) : HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1)) (x + y) := (h.changeOrigin hy).hasFPowerSeriesAt.hasFDerivAt #align has_fpower_series_on_ball.has_fderiv_at HasFPowerSeriesOnBall.hasFDerivAt theorem HasFPowerSeriesOnBall.fderiv_eq [CompleteSpace F] (h : HasFPowerSeriesOnBall f p x r) {y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) : fderiv 𝕜 f (x + y) = continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1) := (h.hasFDerivAt hy).fderiv #align has_fpower_series_on_ball.fderiv_eq HasFPowerSeriesOnBall.fderiv_eq theorem HasFPowerSeriesOnBall.fderiv [CompleteSpace F] (h : HasFPowerSeriesOnBall f p x r) : HasFPowerSeriesOnBall (fderiv 𝕜 f) p.derivSeries x r := by refine .congr (f := fun z ↦ continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin (z - x) 1)) ?_ fun z hz ↦ ?_ · refine continuousMultilinearCurryFin1 𝕜 E F |>.toContinuousLinearEquiv.toContinuousLinearMap.comp_hasFPowerSeriesOnBall ?_ simpa using ((p.hasFPowerSeriesOnBall_changeOrigin 1 (h.r_pos.trans_le h.r_le)).mono h.r_pos h.r_le).comp_sub x dsimp only rw [← h.fderiv_eq, add_sub_cancel] simpa only [edist_eq_coe_nnnorm_sub, EMetric.mem_ball] using hz #align has_fpower_series_on_ball.fderiv HasFPowerSeriesOnBall.fderiv theorem AnalyticOn.fderiv [CompleteSpace F] (h : AnalyticOn 𝕜 f s) : AnalyticOn 𝕜 (fderiv 𝕜 f) s := by intro y hy rcases h y hy with ⟨p, r, hp⟩ exact hp.fderiv.analyticAt #align analytic_on.fderiv AnalyticOn.fderiv
Mathlib/Analysis/Calculus/FDeriv/Analytic.lean
113
122
theorem AnalyticOn.iteratedFDeriv [CompleteSpace F] (h : AnalyticOn 𝕜 f s) (n : ℕ) : AnalyticOn 𝕜 (iteratedFDeriv 𝕜 n f) s := by
induction' n with n IH · rw [iteratedFDeriv_zero_eq_comp] exact ((continuousMultilinearCurryFin0 𝕜 E F).symm : F →L[𝕜] E[×0]→L[𝕜] F).comp_analyticOn h · rw [iteratedFDeriv_succ_eq_comp_left] -- Porting note: for reasons that I do not understand at all, `?g` cannot be inlined. convert ContinuousLinearMap.comp_analyticOn ?g IH.fderiv case g => exact ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (n + 1) ↦ E) F) simp
import Mathlib.Algebra.Order.Ring.Nat #align_import data.nat.dist from "leanprover-community/mathlib"@"d50b12ae8e2bd910d08a94823976adae9825718b" namespace Nat def dist (n m : ℕ) := n - m + (m - n) #align nat.dist Nat.dist -- Should be aligned to `Nat.dist.eq_def`, but that is generated on demand and isn't present yet. #noalign nat.dist.def theorem dist_comm (n m : ℕ) : dist n m = dist m n := by simp [dist, add_comm] #align nat.dist_comm Nat.dist_comm @[simp] theorem dist_self (n : ℕ) : dist n n = 0 := by simp [dist, tsub_self] #align nat.dist_self Nat.dist_self theorem eq_of_dist_eq_zero {n m : ℕ} (h : dist n m = 0) : n = m := have : n - m = 0 := Nat.eq_zero_of_add_eq_zero_right h have : n ≤ m := tsub_eq_zero_iff_le.mp this have : m - n = 0 := Nat.eq_zero_of_add_eq_zero_left h have : m ≤ n := tsub_eq_zero_iff_le.mp this le_antisymm ‹n ≤ m› ‹m ≤ n› #align nat.eq_of_dist_eq_zero Nat.eq_of_dist_eq_zero theorem dist_eq_zero {n m : ℕ} (h : n = m) : dist n m = 0 := by rw [h, dist_self] #align nat.dist_eq_zero Nat.dist_eq_zero theorem dist_eq_sub_of_le {n m : ℕ} (h : n ≤ m) : dist n m = m - n := by rw [dist, tsub_eq_zero_iff_le.mpr h, zero_add] #align nat.dist_eq_sub_of_le Nat.dist_eq_sub_of_le theorem dist_eq_sub_of_le_right {n m : ℕ} (h : m ≤ n) : dist n m = n - m := by rw [dist_comm]; apply dist_eq_sub_of_le h #align nat.dist_eq_sub_of_le_right Nat.dist_eq_sub_of_le_right theorem dist_tri_left (n m : ℕ) : m ≤ dist n m + n := le_trans le_tsub_add (add_le_add_right (Nat.le_add_left _ _) _) #align nat.dist_tri_left Nat.dist_tri_left theorem dist_tri_right (n m : ℕ) : m ≤ n + dist n m := by rw [add_comm]; apply dist_tri_left #align nat.dist_tri_right Nat.dist_tri_right theorem dist_tri_left' (n m : ℕ) : n ≤ dist n m + m := by rw [dist_comm]; apply dist_tri_left #align nat.dist_tri_left' Nat.dist_tri_left' theorem dist_tri_right' (n m : ℕ) : n ≤ m + dist n m := by rw [dist_comm]; apply dist_tri_right #align nat.dist_tri_right' Nat.dist_tri_right' theorem dist_zero_right (n : ℕ) : dist n 0 = n := Eq.trans (dist_eq_sub_of_le_right (zero_le n)) (tsub_zero n) #align nat.dist_zero_right Nat.dist_zero_right theorem dist_zero_left (n : ℕ) : dist 0 n = n := Eq.trans (dist_eq_sub_of_le (zero_le n)) (tsub_zero n) #align nat.dist_zero_left Nat.dist_zero_left theorem dist_add_add_right (n k m : ℕ) : dist (n + k) (m + k) = dist n m := calc dist (n + k) (m + k) = n + k - (m + k) + (m + k - (n + k)) := rfl _ = n - m + (m + k - (n + k)) := by rw [@add_tsub_add_eq_tsub_right] _ = n - m + (m - n) := by rw [@add_tsub_add_eq_tsub_right] #align nat.dist_add_add_right Nat.dist_add_add_right theorem dist_add_add_left (k n m : ℕ) : dist (k + n) (k + m) = dist n m := by rw [add_comm k n, add_comm k m]; apply dist_add_add_right #align nat.dist_add_add_left Nat.dist_add_add_left theorem dist_eq_intro {n m k l : ℕ} (h : n + m = k + l) : dist n k = dist l m := calc dist n k = dist (n + m) (k + m) := by rw [dist_add_add_right] _ = dist (k + l) (k + m) := by rw [h] _ = dist l m := by rw [dist_add_add_left] #align nat.dist_eq_intro Nat.dist_eq_intro theorem dist.triangle_inequality (n m k : ℕ) : dist n k ≤ dist n m + dist m k := by have : dist n m + dist m k = n - m + (m - k) + (k - m + (m - n)) := by simp [dist, add_comm, add_left_comm, add_assoc] rw [this, dist] exact add_le_add tsub_le_tsub_add_tsub tsub_le_tsub_add_tsub #align nat.dist.triangle_inequality Nat.dist.triangle_inequality
Mathlib/Data/Nat/Dist.lean
99
100
theorem dist_mul_right (n k m : ℕ) : dist (n * k) (m * k) = dist n m * k := by
rw [dist, dist, right_distrib, tsub_mul n, tsub_mul m]
import Mathlib.Order.Interval.Set.Disjoint import Mathlib.MeasureTheory.Integral.SetIntegral import Mathlib.MeasureTheory.Measure.Lebesgue.Basic #align_import measure_theory.integral.interval_integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" noncomputable section open scoped Classical open MeasureTheory Set Filter Function open scoped Classical Topology Filter ENNReal Interval NNReal variable {ι 𝕜 E F A : Type*} [NormedAddCommGroup E] def IntervalIntegrable (f : ℝ → E) (μ : Measure ℝ) (a b : ℝ) : Prop := IntegrableOn f (Ioc a b) μ ∧ IntegrableOn f (Ioc b a) μ #align interval_integrable IntervalIntegrable section variable {f : ℝ → E} {a b : ℝ} {μ : Measure ℝ} theorem intervalIntegrable_iff : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ι a b) μ := by rw [uIoc_eq_union, integrableOn_union, IntervalIntegrable] #align interval_integrable_iff intervalIntegrable_iff theorem IntervalIntegrable.def' (h : IntervalIntegrable f μ a b) : IntegrableOn f (Ι a b) μ := intervalIntegrable_iff.mp h #align interval_integrable.def IntervalIntegrable.def' theorem intervalIntegrable_iff_integrableOn_Ioc_of_le (hab : a ≤ b) : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ioc a b) μ := by rw [intervalIntegrable_iff, uIoc_of_le hab] #align interval_integrable_iff_integrable_Ioc_of_le intervalIntegrable_iff_integrableOn_Ioc_of_le theorem intervalIntegrable_iff' [NoAtoms μ] : IntervalIntegrable f μ a b ↔ IntegrableOn f (uIcc a b) μ := by rw [intervalIntegrable_iff, ← Icc_min_max, uIoc, integrableOn_Icc_iff_integrableOn_Ioc] #align interval_integrable_iff' intervalIntegrable_iff' theorem intervalIntegrable_iff_integrableOn_Icc_of_le {f : ℝ → E} {a b : ℝ} (hab : a ≤ b) {μ : Measure ℝ} [NoAtoms μ] : IntervalIntegrable f μ a b ↔ IntegrableOn f (Icc a b) μ := by rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hab, integrableOn_Icc_iff_integrableOn_Ioc] #align interval_integrable_iff_integrable_Icc_of_le intervalIntegrable_iff_integrableOn_Icc_of_le theorem intervalIntegrable_iff_integrableOn_Ico_of_le [NoAtoms μ] (hab : a ≤ b) : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ico a b) μ := by rw [intervalIntegrable_iff_integrableOn_Icc_of_le hab, integrableOn_Icc_iff_integrableOn_Ico] theorem intervalIntegrable_iff_integrableOn_Ioo_of_le [NoAtoms μ] (hab : a ≤ b) : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ioo a b) μ := by rw [intervalIntegrable_iff_integrableOn_Icc_of_le hab, integrableOn_Icc_iff_integrableOn_Ioo] theorem MeasureTheory.Integrable.intervalIntegrable (hf : Integrable f μ) : IntervalIntegrable f μ a b := ⟨hf.integrableOn, hf.integrableOn⟩ #align measure_theory.integrable.interval_integrable MeasureTheory.Integrable.intervalIntegrable theorem MeasureTheory.IntegrableOn.intervalIntegrable (hf : IntegrableOn f [[a, b]] μ) : IntervalIntegrable f μ a b := ⟨MeasureTheory.IntegrableOn.mono_set hf (Ioc_subset_Icc_self.trans Icc_subset_uIcc), MeasureTheory.IntegrableOn.mono_set hf (Ioc_subset_Icc_self.trans Icc_subset_uIcc')⟩ #align measure_theory.integrable_on.interval_integrable MeasureTheory.IntegrableOn.intervalIntegrable theorem intervalIntegrable_const_iff {c : E} : IntervalIntegrable (fun _ => c) μ a b ↔ c = 0 ∨ μ (Ι a b) < ∞ := by simp only [intervalIntegrable_iff, integrableOn_const] #align interval_integrable_const_iff intervalIntegrable_const_iff @[simp] theorem intervalIntegrable_const [IsLocallyFiniteMeasure μ] {c : E} : IntervalIntegrable (fun _ => c) μ a b := intervalIntegrable_const_iff.2 <| Or.inr measure_Ioc_lt_top #align interval_integrable_const intervalIntegrable_const end namespace IntervalIntegrable section variable {f : ℝ → E} {a b c d : ℝ} {μ ν : Measure ℝ} @[symm] nonrec theorem symm (h : IntervalIntegrable f μ a b) : IntervalIntegrable f μ b a := h.symm #align interval_integrable.symm IntervalIntegrable.symm @[refl, simp] -- Porting note: added `simp` theorem refl : IntervalIntegrable f μ a a := by constructor <;> simp #align interval_integrable.refl IntervalIntegrable.refl @[trans] theorem trans {a b c : ℝ} (hab : IntervalIntegrable f μ a b) (hbc : IntervalIntegrable f μ b c) : IntervalIntegrable f μ a c := ⟨(hab.1.union hbc.1).mono_set Ioc_subset_Ioc_union_Ioc, (hbc.2.union hab.2).mono_set Ioc_subset_Ioc_union_Ioc⟩ #align interval_integrable.trans IntervalIntegrable.trans theorem trans_iterate_Ico {a : ℕ → ℝ} {m n : ℕ} (hmn : m ≤ n) (hint : ∀ k ∈ Ico m n, IntervalIntegrable f μ (a k) (a <| k + 1)) : IntervalIntegrable f μ (a m) (a n) := by revert hint refine Nat.le_induction ?_ ?_ n hmn · simp · intro p hp IH h exact (IH fun k hk => h k (Ico_subset_Ico_right p.le_succ hk)).trans (h p (by simp [hp])) #align interval_integrable.trans_iterate_Ico IntervalIntegrable.trans_iterate_Ico theorem trans_iterate {a : ℕ → ℝ} {n : ℕ} (hint : ∀ k < n, IntervalIntegrable f μ (a k) (a <| k + 1)) : IntervalIntegrable f μ (a 0) (a n) := trans_iterate_Ico bot_le fun k hk => hint k hk.2 #align interval_integrable.trans_iterate IntervalIntegrable.trans_iterate theorem neg (h : IntervalIntegrable f μ a b) : IntervalIntegrable (-f) μ a b := ⟨h.1.neg, h.2.neg⟩ #align interval_integrable.neg IntervalIntegrable.neg theorem norm (h : IntervalIntegrable f μ a b) : IntervalIntegrable (fun x => ‖f x‖) μ a b := ⟨h.1.norm, h.2.norm⟩ #align interval_integrable.norm IntervalIntegrable.norm theorem intervalIntegrable_norm_iff {f : ℝ → E} {μ : Measure ℝ} {a b : ℝ} (hf : AEStronglyMeasurable f (μ.restrict (Ι a b))) : IntervalIntegrable (fun t => ‖f t‖) μ a b ↔ IntervalIntegrable f μ a b := by simp_rw [intervalIntegrable_iff, IntegrableOn]; exact integrable_norm_iff hf #align interval_integrable.interval_integrable_norm_iff IntervalIntegrable.intervalIntegrable_norm_iff theorem abs {f : ℝ → ℝ} (h : IntervalIntegrable f μ a b) : IntervalIntegrable (fun x => |f x|) μ a b := h.norm #align interval_integrable.abs IntervalIntegrable.abs theorem mono (hf : IntervalIntegrable f ν a b) (h1 : [[c, d]] ⊆ [[a, b]]) (h2 : μ ≤ ν) : IntervalIntegrable f μ c d := intervalIntegrable_iff.mpr <| hf.def'.mono (uIoc_subset_uIoc_of_uIcc_subset_uIcc h1) h2 #align interval_integrable.mono IntervalIntegrable.mono theorem mono_measure (hf : IntervalIntegrable f ν a b) (h : μ ≤ ν) : IntervalIntegrable f μ a b := hf.mono Subset.rfl h #align interval_integrable.mono_measure IntervalIntegrable.mono_measure theorem mono_set (hf : IntervalIntegrable f μ a b) (h : [[c, d]] ⊆ [[a, b]]) : IntervalIntegrable f μ c d := hf.mono h le_rfl #align interval_integrable.mono_set IntervalIntegrable.mono_set theorem mono_set_ae (hf : IntervalIntegrable f μ a b) (h : Ι c d ≤ᵐ[μ] Ι a b) : IntervalIntegrable f μ c d := intervalIntegrable_iff.mpr <| hf.def'.mono_set_ae h #align interval_integrable.mono_set_ae IntervalIntegrable.mono_set_ae theorem mono_set' (hf : IntervalIntegrable f μ a b) (hsub : Ι c d ⊆ Ι a b) : IntervalIntegrable f μ c d := hf.mono_set_ae <| eventually_of_forall hsub #align interval_integrable.mono_set' IntervalIntegrable.mono_set' theorem mono_fun [NormedAddCommGroup F] {g : ℝ → F} (hf : IntervalIntegrable f μ a b) (hgm : AEStronglyMeasurable g (μ.restrict (Ι a b))) (hle : (fun x => ‖g x‖) ≤ᵐ[μ.restrict (Ι a b)] fun x => ‖f x‖) : IntervalIntegrable g μ a b := intervalIntegrable_iff.2 <| hf.def'.integrable.mono hgm hle #align interval_integrable.mono_fun IntervalIntegrable.mono_fun theorem mono_fun' {g : ℝ → ℝ} (hg : IntervalIntegrable g μ a b) (hfm : AEStronglyMeasurable f (μ.restrict (Ι a b))) (hle : (fun x => ‖f x‖) ≤ᵐ[μ.restrict (Ι a b)] g) : IntervalIntegrable f μ a b := intervalIntegrable_iff.2 <| hg.def'.integrable.mono' hfm hle #align interval_integrable.mono_fun' IntervalIntegrable.mono_fun' protected theorem aestronglyMeasurable (h : IntervalIntegrable f μ a b) : AEStronglyMeasurable f (μ.restrict (Ioc a b)) := h.1.aestronglyMeasurable #align interval_integrable.ae_strongly_measurable IntervalIntegrable.aestronglyMeasurable protected theorem aestronglyMeasurable' (h : IntervalIntegrable f μ a b) : AEStronglyMeasurable f (μ.restrict (Ioc b a)) := h.2.aestronglyMeasurable #align interval_integrable.ae_strongly_measurable' IntervalIntegrable.aestronglyMeasurable' end variable [NormedRing A] {f g : ℝ → E} {a b : ℝ} {μ : Measure ℝ} theorem smul [NormedField 𝕜] [NormedSpace 𝕜 E] {f : ℝ → E} {a b : ℝ} {μ : Measure ℝ} (h : IntervalIntegrable f μ a b) (r : 𝕜) : IntervalIntegrable (r • f) μ a b := ⟨h.1.smul r, h.2.smul r⟩ #align interval_integrable.smul IntervalIntegrable.smul @[simp] theorem add (hf : IntervalIntegrable f μ a b) (hg : IntervalIntegrable g μ a b) : IntervalIntegrable (fun x => f x + g x) μ a b := ⟨hf.1.add hg.1, hf.2.add hg.2⟩ #align interval_integrable.add IntervalIntegrable.add @[simp] theorem sub (hf : IntervalIntegrable f μ a b) (hg : IntervalIntegrable g μ a b) : IntervalIntegrable (fun x => f x - g x) μ a b := ⟨hf.1.sub hg.1, hf.2.sub hg.2⟩ #align interval_integrable.sub IntervalIntegrable.sub theorem sum (s : Finset ι) {f : ι → ℝ → E} (h : ∀ i ∈ s, IntervalIntegrable (f i) μ a b) : IntervalIntegrable (∑ i ∈ s, f i) μ a b := ⟨integrable_finset_sum' s fun i hi => (h i hi).1, integrable_finset_sum' s fun i hi => (h i hi).2⟩ #align interval_integrable.sum IntervalIntegrable.sum
Mathlib/MeasureTheory/Integral/IntervalIntegral.lean
278
281
theorem mul_continuousOn {f g : ℝ → A} (hf : IntervalIntegrable f μ a b) (hg : ContinuousOn g [[a, b]]) : IntervalIntegrable (fun x => f x * g x) μ a b := by
rw [intervalIntegrable_iff] at hf ⊢ exact hf.mul_continuousOn_of_subset hg measurableSet_Ioc isCompact_uIcc Ioc_subset_Icc_self
import Mathlib.MeasureTheory.Integral.Lebesgue import Mathlib.Analysis.MeanInequalities import Mathlib.Analysis.MeanInequalitiesPow import Mathlib.MeasureTheory.Function.SpecialFunctions.Basic #align_import measure_theory.integral.mean_inequalities from "leanprover-community/mathlib"@"13bf7613c96a9fd66a81b9020a82cad9a6ea1fcf" section LIntegral noncomputable section open scoped Classical open NNReal ENNReal MeasureTheory Finset set_option linter.uppercaseLean3 false variable {α : Type*} [MeasurableSpace α] {μ : Measure α} namespace ENNReal theorem lintegral_mul_le_one_of_lintegral_rpow_eq_one {p q : ℝ} (hpq : p.IsConjExponent q) {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf_norm : ∫⁻ a, f a ^ p ∂μ = 1) (hg_norm : ∫⁻ a, g a ^ q ∂μ = 1) : (∫⁻ a, (f * g) a ∂μ) ≤ 1 := by calc (∫⁻ a : α, (f * g) a ∂μ) ≤ ∫⁻ a : α, f a ^ p / ENNReal.ofReal p + g a ^ q / ENNReal.ofReal q ∂μ := lintegral_mono fun a => young_inequality (f a) (g a) hpq _ = 1 := by simp only [div_eq_mul_inv] rw [lintegral_add_left'] · rw [lintegral_mul_const'' _ (hf.pow_const p), lintegral_mul_const', hf_norm, hg_norm, one_mul, one_mul, hpq.inv_add_inv_conj_ennreal] simp [hpq.symm.pos] · exact (hf.pow_const _).mul_const _ #align ennreal.lintegral_mul_le_one_of_lintegral_rpow_eq_one ENNReal.lintegral_mul_le_one_of_lintegral_rpow_eq_one def funMulInvSnorm (f : α → ℝ≥0∞) (p : ℝ) (μ : Measure α) : α → ℝ≥0∞ := fun a => f a * ((∫⁻ c, f c ^ p ∂μ) ^ (1 / p))⁻¹ #align ennreal.fun_mul_inv_snorm ENNReal.funMulInvSnorm theorem fun_eq_funMulInvSnorm_mul_snorm {p : ℝ} (f : α → ℝ≥0∞) (hf_nonzero : (∫⁻ a, f a ^ p ∂μ) ≠ 0) (hf_top : (∫⁻ a, f a ^ p ∂μ) ≠ ⊤) {a : α} : f a = funMulInvSnorm f p μ a * (∫⁻ c, f c ^ p ∂μ) ^ (1 / p) := by simp [funMulInvSnorm, mul_assoc, ENNReal.inv_mul_cancel, hf_nonzero, hf_top] #align ennreal.fun_eq_fun_mul_inv_snorm_mul_snorm ENNReal.fun_eq_funMulInvSnorm_mul_snorm theorem funMulInvSnorm_rpow {p : ℝ} (hp0 : 0 < p) {f : α → ℝ≥0∞} {a : α} : funMulInvSnorm f p μ a ^ p = f a ^ p * (∫⁻ c, f c ^ p ∂μ)⁻¹ := by rw [funMulInvSnorm, mul_rpow_of_nonneg _ _ (le_of_lt hp0)] suffices h_inv_rpow : ((∫⁻ c : α, f c ^ p ∂μ) ^ (1 / p))⁻¹ ^ p = (∫⁻ c : α, f c ^ p ∂μ)⁻¹ by rw [h_inv_rpow] rw [inv_rpow, ← rpow_mul, one_div_mul_cancel hp0.ne', rpow_one] #align ennreal.fun_mul_inv_snorm_rpow ENNReal.funMulInvSnorm_rpow theorem lintegral_rpow_funMulInvSnorm_eq_one {p : ℝ} (hp0_lt : 0 < p) {f : α → ℝ≥0∞} (hf_nonzero : (∫⁻ a, f a ^ p ∂μ) ≠ 0) (hf_top : (∫⁻ a, f a ^ p ∂μ) ≠ ⊤) : ∫⁻ c, funMulInvSnorm f p μ c ^ p ∂μ = 1 := by simp_rw [funMulInvSnorm_rpow hp0_lt] rw [lintegral_mul_const', ENNReal.mul_inv_cancel hf_nonzero hf_top] rwa [inv_ne_top] #align ennreal.lintegral_rpow_fun_mul_inv_snorm_eq_one ENNReal.lintegral_rpow_funMulInvSnorm_eq_one theorem lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_ne_top {p q : ℝ} (hpq : p.IsConjExponent q) {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf_nontop : (∫⁻ a, f a ^ p ∂μ) ≠ ⊤) (hg_nontop : (∫⁻ a, g a ^ q ∂μ) ≠ ⊤) (hf_nonzero : (∫⁻ a, f a ^ p ∂μ) ≠ 0) (hg_nonzero : (∫⁻ a, g a ^ q ∂μ) ≠ 0) : (∫⁻ a, (f * g) a ∂μ) ≤ (∫⁻ a, f a ^ p ∂μ) ^ (1 / p) * (∫⁻ a, g a ^ q ∂μ) ^ (1 / q) := by let npf := (∫⁻ c : α, f c ^ p ∂μ) ^ (1 / p) let nqg := (∫⁻ c : α, g c ^ q ∂μ) ^ (1 / q) calc (∫⁻ a : α, (f * g) a ∂μ) = ∫⁻ a : α, (funMulInvSnorm f p μ * funMulInvSnorm g q μ) a * (npf * nqg) ∂μ := by refine lintegral_congr fun a => ?_ rw [Pi.mul_apply, fun_eq_funMulInvSnorm_mul_snorm f hf_nonzero hf_nontop, fun_eq_funMulInvSnorm_mul_snorm g hg_nonzero hg_nontop, Pi.mul_apply] ring _ ≤ npf * nqg := by rw [lintegral_mul_const' (npf * nqg) _ (by simp [npf, nqg, hf_nontop, hg_nontop, hf_nonzero, hg_nonzero, ENNReal.mul_eq_top])] refine mul_le_of_le_one_left' ?_ have hf1 := lintegral_rpow_funMulInvSnorm_eq_one hpq.pos hf_nonzero hf_nontop have hg1 := lintegral_rpow_funMulInvSnorm_eq_one hpq.symm.pos hg_nonzero hg_nontop exact lintegral_mul_le_one_of_lintegral_rpow_eq_one hpq (hf.mul_const _) hf1 hg1 #align ennreal.lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_ne_top ENNReal.lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_ne_top theorem ae_eq_zero_of_lintegral_rpow_eq_zero {p : ℝ} (hp0 : 0 ≤ p) {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf_zero : ∫⁻ a, f a ^ p ∂μ = 0) : f =ᵐ[μ] 0 := by rw [lintegral_eq_zero_iff' (hf.pow_const p)] at hf_zero filter_upwards [hf_zero] with x rw [Pi.zero_apply, ← not_imp_not] exact fun hx => (rpow_pos_of_nonneg (pos_iff_ne_zero.2 hx) hp0).ne' #align ennreal.ae_eq_zero_of_lintegral_rpow_eq_zero ENNReal.ae_eq_zero_of_lintegral_rpow_eq_zero theorem lintegral_mul_eq_zero_of_lintegral_rpow_eq_zero {p : ℝ} (hp0 : 0 ≤ p) {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf_zero : ∫⁻ a, f a ^ p ∂μ = 0) : (∫⁻ a, (f * g) a ∂μ) = 0 := by rw [← @lintegral_zero_fun α _ μ] refine lintegral_congr_ae ?_ suffices h_mul_zero : f * g =ᵐ[μ] 0 * g by rwa [zero_mul] at h_mul_zero have hf_eq_zero : f =ᵐ[μ] 0 := ae_eq_zero_of_lintegral_rpow_eq_zero hp0 hf hf_zero exact hf_eq_zero.mul (ae_eq_refl g) #align ennreal.lintegral_mul_eq_zero_of_lintegral_rpow_eq_zero ENNReal.lintegral_mul_eq_zero_of_lintegral_rpow_eq_zero theorem lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_eq_top {p q : ℝ} (hp0_lt : 0 < p) (hq0 : 0 ≤ q) {f g : α → ℝ≥0∞} (hf_top : ∫⁻ a, f a ^ p ∂μ = ⊤) (hg_nonzero : (∫⁻ a, g a ^ q ∂μ) ≠ 0) : (∫⁻ a, (f * g) a ∂μ) ≤ (∫⁻ a, f a ^ p ∂μ) ^ (1 / p) * (∫⁻ a, g a ^ q ∂μ) ^ (1 / q) := by refine le_trans le_top (le_of_eq ?_) have hp0_inv_lt : 0 < 1 / p := by simp [hp0_lt] rw [hf_top, ENNReal.top_rpow_of_pos hp0_inv_lt] simp [hq0, hg_nonzero] #align ennreal.lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_eq_top ENNReal.lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_eq_top theorem lintegral_mul_le_Lp_mul_Lq (μ : Measure α) {p q : ℝ} (hpq : p.IsConjExponent q) {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : (∫⁻ a, (f * g) a ∂μ) ≤ (∫⁻ a, f a ^ p ∂μ) ^ (1 / p) * (∫⁻ a, g a ^ q ∂μ) ^ (1 / q) := by by_cases hf_zero : ∫⁻ a, f a ^ p ∂μ = 0 · refine Eq.trans_le ?_ (zero_le _) exact lintegral_mul_eq_zero_of_lintegral_rpow_eq_zero hpq.nonneg hf hf_zero by_cases hg_zero : ∫⁻ a, g a ^ q ∂μ = 0 · refine Eq.trans_le ?_ (zero_le _) rw [mul_comm] exact lintegral_mul_eq_zero_of_lintegral_rpow_eq_zero hpq.symm.nonneg hg hg_zero by_cases hf_top : ∫⁻ a, f a ^ p ∂μ = ⊤ · exact lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_eq_top hpq.pos hpq.symm.nonneg hf_top hg_zero by_cases hg_top : ∫⁻ a, g a ^ q ∂μ = ⊤ · rw [mul_comm, mul_comm ((∫⁻ a : α, f a ^ p ∂μ) ^ (1 / p))] exact lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_eq_top hpq.symm.pos hpq.nonneg hg_top hf_zero -- non-⊤ non-zero case exact ENNReal.lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_ne_top hpq hf hf_top hg_top hf_zero hg_zero #align ennreal.lintegral_mul_le_Lp_mul_Lq ENNReal.lintegral_mul_le_Lp_mul_Lq
Mathlib/MeasureTheory/Integral/MeanInequalities.lean
183
199
theorem lintegral_mul_norm_pow_le {α} [MeasurableSpace α] {μ : Measure α} {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) {p q : ℝ} (hp : 0 ≤ p) (hq : 0 ≤ q) (hpq : p + q = 1) : ∫⁻ a, f a ^ p * g a ^ q ∂μ ≤ (∫⁻ a, f a ∂μ) ^ p * (∫⁻ a, g a ∂μ) ^ q := by
rcases hp.eq_or_lt with rfl|hp · rw [zero_add] at hpq simp [hpq] rcases hq.eq_or_lt with rfl|hq · rw [add_zero] at hpq simp [hpq] have h2p : 1 < 1 / p := by rw [one_div] apply one_lt_inv hp linarith have h2pq : (1 / p)⁻¹ + (1 / q)⁻¹ = 1 := by simp [hp.ne', hq.ne', hpq] have := ENNReal.lintegral_mul_le_Lp_mul_Lq μ ⟨h2p, h2pq⟩ (hf.pow_const p) (hg.pow_const q) simpa [← ENNReal.rpow_mul, hp.ne', hq.ne'] using this
import Mathlib.MeasureTheory.OuterMeasure.Operations import Mathlib.Analysis.SpecificLimits.Basic #align_import measure_theory.measure.outer_measure from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55" noncomputable section open Set Function Filter open scoped Classical NNReal Topology ENNReal namespace MeasureTheory namespace OuterMeasure section OfFunction -- Porting note: "set_option eqn_compiler.zeta true" removed variable {α : Type*} (m : Set α → ℝ≥0∞) (m_empty : m ∅ = 0) protected def ofFunction : OuterMeasure α := let μ s := ⨅ (f : ℕ → Set α) (_ : s ⊆ ⋃ i, f i), ∑' i, m (f i) { measureOf := μ empty := le_antisymm ((iInf_le_of_le fun _ => ∅) <| iInf_le_of_le (empty_subset _) <| by simp [m_empty]) (zero_le _) mono := fun {s₁ s₂} hs => iInf_mono fun f => iInf_mono' fun hb => ⟨hs.trans hb, le_rfl⟩ iUnion_nat := fun s _ => ENNReal.le_of_forall_pos_le_add <| by intro ε hε (hb : (∑' i, μ (s i)) < ∞) rcases ENNReal.exists_pos_sum_of_countable (ENNReal.coe_pos.2 hε).ne' ℕ with ⟨ε', hε', hl⟩ refine le_trans ?_ (add_le_add_left (le_of_lt hl) _) rw [← ENNReal.tsum_add] choose f hf using show ∀ i, ∃ f : ℕ → Set α, (s i ⊆ ⋃ i, f i) ∧ (∑' i, m (f i)) < μ (s i) + ε' i by intro i have : μ (s i) < μ (s i) + ε' i := ENNReal.lt_add_right (ne_top_of_le_ne_top hb.ne <| ENNReal.le_tsum _) (by simpa using (hε' i).ne') rcases iInf_lt_iff.mp this with ⟨t, ht⟩ exists t contrapose! ht exact le_iInf ht refine le_trans ?_ (ENNReal.tsum_le_tsum fun i => le_of_lt (hf i).2) rw [← ENNReal.tsum_prod, ← Nat.pairEquiv.symm.tsum_eq] refine iInf_le_of_le _ (iInf_le _ ?_) apply iUnion_subset intro i apply Subset.trans (hf i).1 apply iUnion_subset simp only [Nat.pairEquiv_symm_apply] rw [iUnion_unpair] intro j apply subset_iUnion₂ i } #align measure_theory.outer_measure.of_function MeasureTheory.OuterMeasure.ofFunction theorem ofFunction_apply (s : Set α) : OuterMeasure.ofFunction m m_empty s = ⨅ (t : ℕ → Set α) (_ : s ⊆ iUnion t), ∑' n, m (t n) := rfl #align measure_theory.outer_measure.of_function_apply MeasureTheory.OuterMeasure.ofFunction_apply variable {m m_empty} theorem ofFunction_le (s : Set α) : OuterMeasure.ofFunction m m_empty s ≤ m s := let f : ℕ → Set α := fun i => Nat.casesOn i s fun _ => ∅ iInf_le_of_le f <| iInf_le_of_le (subset_iUnion f 0) <| le_of_eq <| tsum_eq_single 0 <| by rintro (_ | i) · simp · simp [m_empty] #align measure_theory.outer_measure.of_function_le MeasureTheory.OuterMeasure.ofFunction_le theorem ofFunction_eq (s : Set α) (m_mono : ∀ ⦃t : Set α⦄, s ⊆ t → m s ≤ m t) (m_subadd : ∀ s : ℕ → Set α, m (⋃ i, s i) ≤ ∑' i, m (s i)) : OuterMeasure.ofFunction m m_empty s = m s := le_antisymm (ofFunction_le s) <| le_iInf fun f => le_iInf fun hf => le_trans (m_mono hf) (m_subadd f) #align measure_theory.outer_measure.of_function_eq MeasureTheory.OuterMeasure.ofFunction_eq theorem le_ofFunction {μ : OuterMeasure α} : μ ≤ OuterMeasure.ofFunction m m_empty ↔ ∀ s, μ s ≤ m s := ⟨fun H s => le_trans (H s) (ofFunction_le s), fun H _ => le_iInf fun f => le_iInf fun hs => le_trans (μ.mono hs) <| le_trans (measure_iUnion_le f) <| ENNReal.tsum_le_tsum fun _ => H _⟩ #align measure_theory.outer_measure.le_of_function MeasureTheory.OuterMeasure.le_ofFunction theorem isGreatest_ofFunction : IsGreatest { μ : OuterMeasure α | ∀ s, μ s ≤ m s } (OuterMeasure.ofFunction m m_empty) := ⟨fun _ => ofFunction_le _, fun _ => le_ofFunction.2⟩ #align measure_theory.outer_measure.is_greatest_of_function MeasureTheory.OuterMeasure.isGreatest_ofFunction theorem ofFunction_eq_sSup : OuterMeasure.ofFunction m m_empty = sSup { μ | ∀ s, μ s ≤ m s } := (@isGreatest_ofFunction α m m_empty).isLUB.sSup_eq.symm #align measure_theory.outer_measure.of_function_eq_Sup MeasureTheory.OuterMeasure.ofFunction_eq_sSup
Mathlib/MeasureTheory/OuterMeasure/OfFunction.lean
139
169
theorem ofFunction_union_of_top_of_nonempty_inter {s t : Set α} (h : ∀ u, (s ∩ u).Nonempty → (t ∩ u).Nonempty → m u = ∞) : OuterMeasure.ofFunction m m_empty (s ∪ t) = OuterMeasure.ofFunction m m_empty s + OuterMeasure.ofFunction m m_empty t := by
refine le_antisymm (measure_union_le _ _) (le_iInf₂ fun f hf ↦ ?_) set μ := OuterMeasure.ofFunction m m_empty rcases Classical.em (∃ i, (s ∩ f i).Nonempty ∧ (t ∩ f i).Nonempty) with (⟨i, hs, ht⟩ | he) · calc μ s + μ t ≤ ∞ := le_top _ = m (f i) := (h (f i) hs ht).symm _ ≤ ∑' i, m (f i) := ENNReal.le_tsum i set I := fun s => { i : ℕ | (s ∩ f i).Nonempty } have hd : Disjoint (I s) (I t) := disjoint_iff_inf_le.mpr fun i hi => he ⟨i, hi⟩ have hI : ∀ u ⊆ s ∪ t, μ u ≤ ∑' i : I u, μ (f i) := fun u hu => calc μ u ≤ μ (⋃ i : I u, f i) := μ.mono fun x hx => let ⟨i, hi⟩ := mem_iUnion.1 (hf (hu hx)) mem_iUnion.2 ⟨⟨i, ⟨x, hx, hi⟩⟩, hi⟩ _ ≤ ∑' i : I u, μ (f i) := measure_iUnion_le _ calc μ s + μ t ≤ (∑' i : I s, μ (f i)) + ∑' i : I t, μ (f i) := add_le_add (hI _ subset_union_left) (hI _ subset_union_right) _ = ∑' i : ↑(I s ∪ I t), μ (f i) := (tsum_union_disjoint (f := fun i => μ (f i)) hd ENNReal.summable ENNReal.summable).symm _ ≤ ∑' i, μ (f i) := (tsum_le_tsum_of_inj (↑) Subtype.coe_injective (fun _ _ => zero_le _) (fun _ => le_rfl) ENNReal.summable ENNReal.summable) _ ≤ ∑' i, m (f i) := ENNReal.tsum_le_tsum fun i => ofFunction_le _
import Mathlib.MeasureTheory.Integral.Bochner open MeasureTheory Filter open scoped ENNReal NNReal BoundedContinuousFunction Topology namespace BoundedContinuousFunction section NNRealValued lemma apply_le_nndist_zero {X : Type*} [TopologicalSpace X] (f : X →ᵇ ℝ≥0) (x : X) : f x ≤ nndist 0 f := by convert nndist_coe_le_nndist x simp only [coe_zero, Pi.zero_apply, NNReal.nndist_zero_eq_val] variable {X : Type*} [MeasurableSpace X] [TopologicalSpace X] [OpensMeasurableSpace X] lemma lintegral_le_edist_mul (f : X →ᵇ ℝ≥0) (μ : Measure X) : (∫⁻ x, f x ∂μ) ≤ edist 0 f * (μ Set.univ) := le_trans (lintegral_mono (fun x ↦ ENNReal.coe_le_coe.mpr (f.apply_le_nndist_zero x))) (by simp) theorem measurable_coe_ennreal_comp (f : X →ᵇ ℝ≥0) : Measurable fun x ↦ (f x : ℝ≥0∞) := measurable_coe_nnreal_ennreal.comp f.continuous.measurable #align bounded_continuous_function.nnreal.to_ennreal_comp_measurable BoundedContinuousFunction.measurable_coe_ennreal_comp variable (μ : Measure X) [IsFiniteMeasure μ] theorem lintegral_lt_top_of_nnreal (f : X →ᵇ ℝ≥0) : ∫⁻ x, f x ∂μ < ∞ := by apply IsFiniteMeasure.lintegral_lt_top_of_bounded_to_ennreal refine ⟨nndist f 0, fun x ↦ ?_⟩ have key := BoundedContinuousFunction.NNReal.upper_bound f x rwa [ENNReal.coe_le_coe] #align measure_theory.lintegral_lt_top_of_bounded_continuous_to_nnreal BoundedContinuousFunction.lintegral_lt_top_of_nnreal theorem integrable_of_nnreal (f : X →ᵇ ℝ≥0) : Integrable (((↑) : ℝ≥0 → ℝ) ∘ ⇑f) μ := by refine ⟨(NNReal.continuous_coe.comp f.continuous).measurable.aestronglyMeasurable, ?_⟩ simp only [HasFiniteIntegral, Function.comp_apply, NNReal.nnnorm_eq] exact lintegral_lt_top_of_nnreal _ f #align measure_theory.finite_measure.integrable_of_bounded_continuous_to_nnreal BoundedContinuousFunction.integrable_of_nnreal
Mathlib/MeasureTheory/Integral/BoundedContinuousFunction.lean
55
59
theorem integral_eq_integral_nnrealPart_sub (f : X →ᵇ ℝ) : ∫ x, f x ∂μ = (∫ x, (f.nnrealPart x : ℝ) ∂μ) - ∫ x, ((-f).nnrealPart x : ℝ) ∂μ := by
simp only [f.self_eq_nnrealPart_sub_nnrealPart_neg, Pi.sub_apply, integral_sub, integrable_of_nnreal] simp only [Function.comp_apply]
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 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⟩ #align power_basis.exists_eq_aeval' PowerBasis.exists_eq_aeval' theorem algHom_ext {S' : Type*} [Semiring S'] [Algebra R S'] (pb : PowerBasis R S) ⦃f g : S →ₐ[R] S'⦄ (h : f pb.gen = g pb.gen) : f = g := by ext x obtain ⟨f, rfl⟩ := pb.exists_eq_aeval' x rw [← Polynomial.aeval_algHom_apply, ← Polynomial.aeval_algHom_apply, h] #align power_basis.alg_hom_ext PowerBasis.algHom_ext open PowerBasis
Mathlib/RingTheory/PowerBasis.lean
425
438
theorem linearIndependent_pow [Algebra K S] (x : S) : LinearIndependent K fun i : Fin (minpoly K x).natDegree => x ^ (i : ℕ) := by
by_cases h : IsIntegral K x; swap · rw [minpoly.eq_zero h, natDegree_zero] exact linearIndependent_empty_type refine Fintype.linearIndependent_iff.2 fun g hg i => ?_ simp only at hg simp_rw [Algebra.smul_def, ← aeval_monomial, ← map_sum] at hg apply (fun hn0 => (minpoly.degree_le_of_ne_zero K x (mt (fun h0 => ?_) hn0) hg).not_lt).mtr · simp_rw [← C_mul_X_pow_eq_monomial] exact (degree_eq_natDegree <| minpoly.ne_zero h).symm ▸ degree_sum_fin_lt _ · apply_fun lcoeff K i at h0 simp_rw [map_sum, lcoeff_apply, coeff_monomial, Fin.val_eq_val, Finset.sum_ite_eq'] at h0 exact (if_pos <| Finset.mem_univ _).symm.trans h0
import Mathlib.Analysis.Calculus.FDeriv.Equiv import Mathlib.Analysis.Calculus.FormalMultilinearSeries #align_import analysis.calculus.cont_diff_def from "leanprover-community/mathlib"@"3a69562db5a458db8322b190ec8d9a8bbd8a5b14" noncomputable section open scoped Classical open NNReal Topology Filter local notation "∞" => (⊤ : ℕ∞) open Set Fin Filter Function universe u uE uF uG uX variable {𝕜 : Type u} [NontriviallyNormedField 𝕜] {E : Type uE} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type uF} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type uG} [NormedAddCommGroup G] [NormedSpace 𝕜 G] {X : Type uX} [NormedAddCommGroup X] [NormedSpace 𝕜 X] {s s₁ t u : Set E} {f f₁ : E → F} {g : F → G} {x x₀ : E} {c : F} {m n : ℕ∞} {p : E → FormalMultilinearSeries 𝕜 E F} structure HasFTaylorSeriesUpToOn (n : ℕ∞) (f : E → F) (p : E → FormalMultilinearSeries 𝕜 E F) (s : Set E) : Prop where zero_eq : ∀ x ∈ s, (p x 0).uncurry0 = f x protected fderivWithin : ∀ m : ℕ, (m : ℕ∞) < n → ∀ x ∈ s, HasFDerivWithinAt (p · m) (p x m.succ).curryLeft s x cont : ∀ m : ℕ, (m : ℕ∞) ≤ n → ContinuousOn (p · m) s #align has_ftaylor_series_up_to_on HasFTaylorSeriesUpToOn theorem HasFTaylorSeriesUpToOn.zero_eq' (h : HasFTaylorSeriesUpToOn n f p s) {x : E} (hx : x ∈ s) : p x 0 = (continuousMultilinearCurryFin0 𝕜 E F).symm (f x) := by rw [← h.zero_eq x hx] exact (p x 0).uncurry0_curry0.symm #align has_ftaylor_series_up_to_on.zero_eq' HasFTaylorSeriesUpToOn.zero_eq' theorem HasFTaylorSeriesUpToOn.congr (h : HasFTaylorSeriesUpToOn n f p s) (h₁ : ∀ x ∈ s, f₁ x = f x) : HasFTaylorSeriesUpToOn n f₁ p s := by refine ⟨fun x hx => ?_, h.fderivWithin, h.cont⟩ rw [h₁ x hx] exact h.zero_eq x hx #align has_ftaylor_series_up_to_on.congr HasFTaylorSeriesUpToOn.congr theorem HasFTaylorSeriesUpToOn.mono (h : HasFTaylorSeriesUpToOn n f p s) {t : Set E} (hst : t ⊆ s) : HasFTaylorSeriesUpToOn n f p t := ⟨fun x hx => h.zero_eq x (hst hx), fun m hm x hx => (h.fderivWithin m hm x (hst hx)).mono hst, fun m hm => (h.cont m hm).mono hst⟩ #align has_ftaylor_series_up_to_on.mono HasFTaylorSeriesUpToOn.mono theorem HasFTaylorSeriesUpToOn.of_le (h : HasFTaylorSeriesUpToOn n f p s) (hmn : m ≤ n) : HasFTaylorSeriesUpToOn m f p s := ⟨h.zero_eq, fun k hk x hx => h.fderivWithin k (lt_of_lt_of_le hk hmn) x hx, fun k hk => h.cont k (le_trans hk hmn)⟩ #align has_ftaylor_series_up_to_on.of_le HasFTaylorSeriesUpToOn.of_le theorem HasFTaylorSeriesUpToOn.continuousOn (h : HasFTaylorSeriesUpToOn n f p s) : ContinuousOn f s := by have := (h.cont 0 bot_le).congr fun x hx => (h.zero_eq' hx).symm rwa [← (continuousMultilinearCurryFin0 𝕜 E F).symm.comp_continuousOn_iff] #align has_ftaylor_series_up_to_on.continuous_on HasFTaylorSeriesUpToOn.continuousOn theorem hasFTaylorSeriesUpToOn_zero_iff : HasFTaylorSeriesUpToOn 0 f p s ↔ ContinuousOn f s ∧ ∀ x ∈ s, (p x 0).uncurry0 = f x := by refine ⟨fun H => ⟨H.continuousOn, H.zero_eq⟩, fun H => ⟨H.2, fun m hm => False.elim (not_le.2 hm bot_le), fun m hm ↦ ?_⟩⟩ obtain rfl : m = 0 := mod_cast hm.antisymm (zero_le _) have : EqOn (p · 0) ((continuousMultilinearCurryFin0 𝕜 E F).symm ∘ f) s := fun x hx ↦ (continuousMultilinearCurryFin0 𝕜 E F).eq_symm_apply.2 (H.2 x hx) rw [continuousOn_congr this, LinearIsometryEquiv.comp_continuousOn_iff] exact H.1 #align has_ftaylor_series_up_to_on_zero_iff hasFTaylorSeriesUpToOn_zero_iff theorem hasFTaylorSeriesUpToOn_top_iff : HasFTaylorSeriesUpToOn ∞ f p s ↔ ∀ n : ℕ, HasFTaylorSeriesUpToOn n f p s := by constructor · intro H n; exact H.of_le le_top · intro H constructor · exact (H 0).zero_eq · intro m _ apply (H m.succ).fderivWithin m (WithTop.coe_lt_coe.2 (lt_add_one m)) · intro m _ apply (H m).cont m le_rfl #align has_ftaylor_series_up_to_on_top_iff hasFTaylorSeriesUpToOn_top_iff theorem hasFTaylorSeriesUpToOn_top_iff' : HasFTaylorSeriesUpToOn ∞ f p s ↔ (∀ x ∈ s, (p x 0).uncurry0 = f x) ∧ ∀ m : ℕ, ∀ x ∈ s, HasFDerivWithinAt (fun y => p y m) (p x m.succ).curryLeft s x := -- Everything except for the continuity is trivial: ⟨fun h => ⟨h.1, fun m => h.2 m (WithTop.coe_lt_top m)⟩, fun h => ⟨h.1, fun m _ => h.2 m, fun m _ x hx => -- The continuity follows from the existence of a derivative: (h.2 m x hx).continuousWithinAt⟩⟩ #align has_ftaylor_series_up_to_on_top_iff' hasFTaylorSeriesUpToOn_top_iff' theorem HasFTaylorSeriesUpToOn.hasFDerivWithinAt (h : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≤ n) (hx : x ∈ s) : HasFDerivWithinAt f (continuousMultilinearCurryFin1 𝕜 E F (p x 1)) s x := by have A : ∀ y ∈ s, f y = (continuousMultilinearCurryFin0 𝕜 E F) (p y 0) := fun y hy ↦ (h.zero_eq y hy).symm suffices H : HasFDerivWithinAt (continuousMultilinearCurryFin0 𝕜 E F ∘ (p · 0)) (continuousMultilinearCurryFin1 𝕜 E F (p x 1)) s x from H.congr A (A x hx) rw [LinearIsometryEquiv.comp_hasFDerivWithinAt_iff'] have : ((0 : ℕ) : ℕ∞) < n := zero_lt_one.trans_le hn convert h.fderivWithin _ this x hx ext y v change (p x 1) (snoc 0 y) = (p x 1) (cons y v) congr with i rw [Unique.eq_default (α := Fin 1) i] rfl #align has_ftaylor_series_up_to_on.has_fderiv_within_at HasFTaylorSeriesUpToOn.hasFDerivWithinAt theorem HasFTaylorSeriesUpToOn.differentiableOn (h : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≤ n) : DifferentiableOn 𝕜 f s := fun _x hx => (h.hasFDerivWithinAt hn hx).differentiableWithinAt #align has_ftaylor_series_up_to_on.differentiable_on HasFTaylorSeriesUpToOn.differentiableOn theorem HasFTaylorSeriesUpToOn.hasFDerivAt (h : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≤ n) (hx : s ∈ 𝓝 x) : HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p x 1)) x := (h.hasFDerivWithinAt hn (mem_of_mem_nhds hx)).hasFDerivAt hx #align has_ftaylor_series_up_to_on.has_fderiv_at HasFTaylorSeriesUpToOn.hasFDerivAt theorem HasFTaylorSeriesUpToOn.eventually_hasFDerivAt (h : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≤ n) (hx : s ∈ 𝓝 x) : ∀ᶠ y in 𝓝 x, HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p y 1)) y := (eventually_eventually_nhds.2 hx).mono fun _y hy => h.hasFDerivAt hn hy #align has_ftaylor_series_up_to_on.eventually_has_fderiv_at HasFTaylorSeriesUpToOn.eventually_hasFDerivAt theorem HasFTaylorSeriesUpToOn.differentiableAt (h : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≤ n) (hx : s ∈ 𝓝 x) : DifferentiableAt 𝕜 f x := (h.hasFDerivAt hn hx).differentiableAt #align has_ftaylor_series_up_to_on.differentiable_at HasFTaylorSeriesUpToOn.differentiableAt
Mathlib/Analysis/Calculus/ContDiff/Defs.lean
312
334
theorem hasFTaylorSeriesUpToOn_succ_iff_left {n : ℕ} : HasFTaylorSeriesUpToOn (n + 1) f p s ↔ HasFTaylorSeriesUpToOn n f p s ∧ (∀ x ∈ s, HasFDerivWithinAt (fun y => p y n) (p x n.succ).curryLeft s x) ∧ ContinuousOn (fun x => p x (n + 1)) s := by
constructor · exact fun h ↦ ⟨h.of_le (WithTop.coe_le_coe.2 (Nat.le_succ n)), h.fderivWithin _ (WithTop.coe_lt_coe.2 (lt_add_one n)), h.cont (n + 1) le_rfl⟩ · intro h constructor · exact h.1.zero_eq · intro m hm by_cases h' : m < n · exact h.1.fderivWithin m (WithTop.coe_lt_coe.2 h') · have : m = n := Nat.eq_of_lt_succ_of_not_lt (WithTop.coe_lt_coe.1 hm) h' rw [this] exact h.2.1 · intro m hm by_cases h' : m ≤ n · apply h.1.cont m (WithTop.coe_le_coe.2 h') · have : m = n + 1 := le_antisymm (WithTop.coe_le_coe.1 hm) (not_le.1 h') rw [this] exact h.2.2
import Mathlib.Algebra.BigOperators.Ring.List import Mathlib.Data.Nat.Prime import Mathlib.Data.List.Prime import Mathlib.Data.List.Sort import Mathlib.Data.List.Chain #align_import data.nat.factors from "leanprover-community/mathlib"@"008205aa645b3f194c1da47025c5f110c8406eab" open Bool Subtype open Nat namespace Nat attribute [instance 0] instBEqNat def factors : ℕ → List ℕ | 0 => [] | 1 => [] | k + 2 => let m := minFac (k + 2) m :: factors ((k + 2) / m) decreasing_by show (k + 2) / m < (k + 2); exact factors_lemma #align nat.factors Nat.factors @[simp] theorem factors_zero : factors 0 = [] := by rw [factors] #align nat.factors_zero Nat.factors_zero @[simp] theorem factors_one : factors 1 = [] := by rw [factors] #align nat.factors_one Nat.factors_one @[simp] theorem factors_two : factors 2 = [2] := by simp [factors] theorem prime_of_mem_factors {n : ℕ} : ∀ {p : ℕ}, (h : p ∈ factors n) → Prime p := by match n with | 0 => simp | 1 => simp | k + 2 => intro p h let m := minFac (k + 2) have : (k + 2) / m < (k + 2) := factors_lemma have h₁ : p = m ∨ p ∈ factors ((k + 2) / m) := List.mem_cons.1 (by rwa [factors] at h) exact Or.casesOn h₁ (fun h₂ => h₂.symm ▸ minFac_prime (by simp)) prime_of_mem_factors #align nat.prime_of_mem_factors Nat.prime_of_mem_factors theorem pos_of_mem_factors {n p : ℕ} (h : p ∈ factors n) : 0 < p := Prime.pos (prime_of_mem_factors h) #align nat.pos_of_mem_factors Nat.pos_of_mem_factors theorem prod_factors : ∀ {n}, n ≠ 0 → List.prod (factors n) = n | 0 => by simp | 1 => by simp | k + 2 => fun _ => let m := minFac (k + 2) have : (k + 2) / m < (k + 2) := factors_lemma show (factors (k + 2)).prod = (k + 2) by have h₁ : (k + 2) / m ≠ 0 := fun h => by have : (k + 2) = 0 * m := (Nat.div_eq_iff_eq_mul_left (minFac_pos _) (minFac_dvd _)).1 h rw [zero_mul] at this; exact (show k + 2 ≠ 0 by simp) this rw [factors, List.prod_cons, prod_factors h₁, Nat.mul_div_cancel' (minFac_dvd _)] #align nat.prod_factors Nat.prod_factors theorem factors_prime {p : ℕ} (hp : Nat.Prime p) : p.factors = [p] := by have : p = p - 2 + 2 := (tsub_eq_iff_eq_add_of_le hp.two_le).mp rfl rw [this, Nat.factors] simp only [Eq.symm this] have : Nat.minFac p = p := (Nat.prime_def_minFac.mp hp).2 simp only [this, Nat.factors, Nat.div_self (Nat.Prime.pos hp)] #align nat.factors_prime Nat.factors_prime theorem factors_chain {n : ℕ} : ∀ {a}, (∀ p, Prime p → p ∣ n → a ≤ p) → List.Chain (· ≤ ·) a (factors n) := by match n with | 0 => simp | 1 => simp | k + 2 => intro a h let m := minFac (k + 2) have : (k + 2) / m < (k + 2) := factors_lemma rw [factors] refine List.Chain.cons ((le_minFac.2 h).resolve_left (by simp)) (factors_chain ?_) exact fun p pp d => minFac_le_of_dvd pp.two_le (d.trans <| div_dvd_of_dvd <| minFac_dvd _) #align nat.factors_chain Nat.factors_chain theorem factors_chain_2 (n) : List.Chain (· ≤ ·) 2 (factors n) := factors_chain fun _ pp _ => pp.two_le #align nat.factors_chain_2 Nat.factors_chain_2 theorem factors_chain' (n) : List.Chain' (· ≤ ·) (factors n) := @List.Chain'.tail _ _ (_ :: _) (factors_chain_2 _) #align nat.factors_chain' Nat.factors_chain' theorem factors_sorted (n : ℕ) : List.Sorted (· ≤ ·) (factors n) := List.chain'_iff_pairwise.1 (factors_chain' _) #align nat.factors_sorted Nat.factors_sorted theorem factors_add_two (n : ℕ) : factors (n + 2) = minFac (n + 2) :: factors ((n + 2) / minFac (n + 2)) := by rw [factors] #align nat.factors_add_two Nat.factors_add_two @[simp] theorem factors_eq_nil (n : ℕ) : n.factors = [] ↔ n = 0 ∨ n = 1 := by constructor <;> intro h · rcases n with (_ | _ | n) · exact Or.inl rfl · exact Or.inr rfl · rw [factors] at h injection h · rcases h with (rfl | rfl) · exact factors_zero · exact factors_one #align nat.factors_eq_nil Nat.factors_eq_nil open scoped List in theorem eq_of_perm_factors {a b : ℕ} (ha : a ≠ 0) (hb : b ≠ 0) (h : a.factors ~ b.factors) : a = b := by simpa [prod_factors ha, prod_factors hb] using List.Perm.prod_eq h #align nat.eq_of_perm_factors Nat.eq_of_perm_factors section open List theorem mem_factors_iff_dvd {n p : ℕ} (hn : n ≠ 0) (hp : Prime p) : p ∈ factors n ↔ p ∣ n := ⟨fun h => prod_factors hn ▸ List.dvd_prod h, fun h => mem_list_primes_of_dvd_prod (prime_iff.mp hp) (fun _ h => prime_iff.mp (prime_of_mem_factors h)) ((prod_factors hn).symm ▸ h)⟩ #align nat.mem_factors_iff_dvd Nat.mem_factors_iff_dvd theorem dvd_of_mem_factors {n p : ℕ} (h : p ∈ n.factors) : p ∣ n := by rcases n.eq_zero_or_pos with (rfl | hn) · exact dvd_zero p · rwa [← mem_factors_iff_dvd hn.ne' (prime_of_mem_factors h)] #align nat.dvd_of_mem_factors Nat.dvd_of_mem_factors theorem mem_factors {n p} (hn : n ≠ 0) : p ∈ factors n ↔ Prime p ∧ p ∣ n := ⟨fun h => ⟨prime_of_mem_factors h, dvd_of_mem_factors h⟩, fun ⟨hprime, hdvd⟩ => (mem_factors_iff_dvd hn hprime).mpr hdvd⟩ #align nat.mem_factors Nat.mem_factors @[simp] lemma mem_factors' {n p} : p ∈ n.factors ↔ p.Prime ∧ p ∣ n ∧ n ≠ 0 := by cases n <;> simp [mem_factors, *] theorem le_of_mem_factors {n p : ℕ} (h : p ∈ n.factors) : p ≤ n := by rcases n.eq_zero_or_pos with (rfl | hn) · rw [factors_zero] at h cases h · exact le_of_dvd hn (dvd_of_mem_factors h) #align nat.le_of_mem_factors Nat.le_of_mem_factors theorem factors_unique {n : ℕ} {l : List ℕ} (h₁ : prod l = n) (h₂ : ∀ p ∈ l, Prime p) : l ~ factors n := by refine perm_of_prod_eq_prod ?_ ?_ ?_ · rw [h₁] refine (prod_factors ?_).symm rintro rfl rw [prod_eq_zero_iff] at h₁ exact Prime.ne_zero (h₂ 0 h₁) rfl · simp_rw [← prime_iff] exact h₂ · simp_rw [← prime_iff] exact fun p => prime_of_mem_factors #align nat.factors_unique Nat.factors_unique theorem Prime.factors_pow {p : ℕ} (hp : p.Prime) (n : ℕ) : (p ^ n).factors = List.replicate n p := by symm rw [← List.replicate_perm] apply Nat.factors_unique (List.prod_replicate n p) intro q hq rwa [eq_of_mem_replicate hq] #align nat.prime.factors_pow Nat.Prime.factors_pow theorem eq_prime_pow_of_unique_prime_dvd {n p : ℕ} (hpos : n ≠ 0) (h : ∀ {d}, Nat.Prime d → d ∣ n → d = p) : n = p ^ n.factors.length := by set k := n.factors.length rw [← prod_factors hpos, ← prod_replicate k p, eq_replicate_of_mem fun d hd => h (prime_of_mem_factors hd) (dvd_of_mem_factors hd)] #align nat.eq_prime_pow_of_unique_prime_dvd Nat.eq_prime_pow_of_unique_prime_dvd
Mathlib/Data/Nat/Factors.lean
205
211
theorem perm_factors_mul {a b : ℕ} (ha : a ≠ 0) (hb : b ≠ 0) : (a * b).factors ~ a.factors ++ b.factors := by
refine (factors_unique ?_ ?_).symm · rw [List.prod_append, prod_factors ha, prod_factors hb] · intro p hp rw [List.mem_append] at hp cases' hp with hp' hp' <;> exact prime_of_mem_factors hp'
import Mathlib.Algebra.Homology.Linear import Mathlib.Algebra.Homology.ShortComplex.HomologicalComplex import Mathlib.Tactic.Abel #align_import algebra.homology.homotopy from "leanprover-community/mathlib"@"618ea3d5c99240cd7000d8376924906a148bf9ff" universe v u open scoped Classical noncomputable section open CategoryTheory Category Limits HomologicalComplex variable {ι : Type*} variable {V : Type u} [Category.{v} V] [Preadditive V] variable {c : ComplexShape ι} {C D E : HomologicalComplex V c} variable (f g : C ⟶ D) (h k : D ⟶ E) (i : ι) section def dNext (i : ι) : (∀ i j, C.X i ⟶ D.X j) →+ (C.X i ⟶ D.X i) := AddMonoidHom.mk' (fun f => C.d i (c.next i) ≫ f (c.next i) i) fun _ _ => Preadditive.comp_add _ _ _ _ _ _ #align d_next dNext def fromNext (i : ι) : (∀ i j, C.X i ⟶ D.X j) →+ (C.xNext i ⟶ D.X i) := AddMonoidHom.mk' (fun f => f (c.next i) i) fun _ _ => rfl #align from_next fromNext @[simp] theorem dNext_eq_dFrom_fromNext (f : ∀ i j, C.X i ⟶ D.X j) (i : ι) : dNext i f = C.dFrom i ≫ fromNext i f := rfl #align d_next_eq_d_from_from_next dNext_eq_dFrom_fromNext theorem dNext_eq (f : ∀ i j, C.X i ⟶ D.X j) {i i' : ι} (w : c.Rel i i') : dNext i f = C.d i i' ≫ f i' i := by obtain rfl := c.next_eq' w rfl #align d_next_eq dNext_eq lemma dNext_eq_zero (f : ∀ i j, C.X i ⟶ D.X j) (i : ι) (hi : ¬ c.Rel i (c.next i)) : dNext i f = 0 := by dsimp [dNext] rw [shape _ _ _ hi, zero_comp] @[simp 1100] theorem dNext_comp_left (f : C ⟶ D) (g : ∀ i j, D.X i ⟶ E.X j) (i : ι) : (dNext i fun i j => f.f i ≫ g i j) = f.f i ≫ dNext i g := (f.comm_assoc _ _ _).symm #align d_next_comp_left dNext_comp_left @[simp 1100] theorem dNext_comp_right (f : ∀ i j, C.X i ⟶ D.X j) (g : D ⟶ E) (i : ι) : (dNext i fun i j => f i j ≫ g.f j) = dNext i f ≫ g.f i := (assoc _ _ _).symm #align d_next_comp_right dNext_comp_right def prevD (j : ι) : (∀ i j, C.X i ⟶ D.X j) →+ (C.X j ⟶ D.X j) := AddMonoidHom.mk' (fun f => f j (c.prev j) ≫ D.d (c.prev j) j) fun _ _ => Preadditive.add_comp _ _ _ _ _ _ #align prev_d prevD lemma prevD_eq_zero (f : ∀ i j, C.X i ⟶ D.X j) (i : ι) (hi : ¬ c.Rel (c.prev i) i) : prevD i f = 0 := by dsimp [prevD] rw [shape _ _ _ hi, comp_zero] def toPrev (j : ι) : (∀ i j, C.X i ⟶ D.X j) →+ (C.X j ⟶ D.xPrev j) := AddMonoidHom.mk' (fun f => f j (c.prev j)) fun _ _ => rfl #align to_prev toPrev @[simp] theorem prevD_eq_toPrev_dTo (f : ∀ i j, C.X i ⟶ D.X j) (j : ι) : prevD j f = toPrev j f ≫ D.dTo j := rfl #align prev_d_eq_to_prev_d_to prevD_eq_toPrev_dTo theorem prevD_eq (f : ∀ i j, C.X i ⟶ D.X j) {j j' : ι} (w : c.Rel j' j) : prevD j f = f j j' ≫ D.d j' j := by obtain rfl := c.prev_eq' w rfl #align prev_d_eq prevD_eq @[simp 1100] theorem prevD_comp_left (f : C ⟶ D) (g : ∀ i j, D.X i ⟶ E.X j) (j : ι) : (prevD j fun i j => f.f i ≫ g i j) = f.f j ≫ prevD j g := assoc _ _ _ #align prev_d_comp_left prevD_comp_left @[simp 1100] theorem prevD_comp_right (f : ∀ i j, C.X i ⟶ D.X j) (g : D ⟶ E) (j : ι) : (prevD j fun i j => f i j ≫ g.f j) = prevD j f ≫ g.f j := by dsimp [prevD] simp only [assoc, g.comm] #align prev_d_comp_right prevD_comp_right theorem dNext_nat (C D : ChainComplex V ℕ) (i : ℕ) (f : ∀ i j, C.X i ⟶ D.X j) : dNext i f = C.d i (i - 1) ≫ f (i - 1) i := by dsimp [dNext] cases i · simp only [shape, ChainComplex.next_nat_zero, ComplexShape.down_Rel, Nat.one_ne_zero, not_false_iff, zero_comp] · congr <;> simp #align d_next_nat dNext_nat theorem prevD_nat (C D : CochainComplex V ℕ) (i : ℕ) (f : ∀ i j, C.X i ⟶ D.X j) : prevD i f = f i (i - 1) ≫ D.d (i - 1) i := by dsimp [prevD] cases i · simp only [shape, CochainComplex.prev_nat_zero, ComplexShape.up_Rel, Nat.one_ne_zero, not_false_iff, comp_zero] · congr <;> simp #align prev_d_nat prevD_nat -- Porting note(#5171): removed @[has_nonempty_instance] @[ext] structure Homotopy (f g : C ⟶ D) where hom : ∀ i j, C.X i ⟶ D.X j zero : ∀ i j, ¬c.Rel j i → hom i j = 0 := by aesop_cat comm : ∀ i, f.f i = dNext i hom + prevD i hom + g.f i := by aesop_cat #align homotopy Homotopy variable {f g} namespace Homotopy def equivSubZero : Homotopy f g ≃ Homotopy (f - g) 0 where toFun h := { hom := fun i j => h.hom i j zero := fun i j w => h.zero _ _ w comm := fun i => by simp [h.comm] } invFun h := { hom := fun i j => h.hom i j zero := fun i j w => h.zero _ _ w comm := fun i => by simpa [sub_eq_iff_eq_add] using h.comm i } left_inv := by aesop_cat right_inv := by aesop_cat #align homotopy.equiv_sub_zero Homotopy.equivSubZero @[simps] def ofEq (h : f = g) : Homotopy f g where hom := 0 zero _ _ _ := rfl #align homotopy.of_eq Homotopy.ofEq @[simps!, refl] def refl (f : C ⟶ D) : Homotopy f f := ofEq (rfl : f = f) #align homotopy.refl Homotopy.refl @[simps!, symm] def symm {f g : C ⟶ D} (h : Homotopy f g) : Homotopy g f where hom := -h.hom zero i j w := by rw [Pi.neg_apply, Pi.neg_apply, h.zero i j w, neg_zero] comm i := by rw [AddMonoidHom.map_neg, AddMonoidHom.map_neg, h.comm, ← neg_add, ← add_assoc, neg_add_self, zero_add] #align homotopy.symm Homotopy.symm @[simps!, trans] def trans {e f g : C ⟶ D} (h : Homotopy e f) (k : Homotopy f g) : Homotopy e g where hom := h.hom + k.hom zero i j w := by rw [Pi.add_apply, Pi.add_apply, h.zero i j w, k.zero i j w, zero_add] comm i := by rw [AddMonoidHom.map_add, AddMonoidHom.map_add, h.comm, k.comm] abel #align homotopy.trans Homotopy.trans @[simps!] def add {f₁ g₁ f₂ g₂ : C ⟶ D} (h₁ : Homotopy f₁ g₁) (h₂ : Homotopy f₂ g₂) : Homotopy (f₁ + f₂) (g₁ + g₂) where hom := h₁.hom + h₂.hom zero i j hij := by rw [Pi.add_apply, Pi.add_apply, h₁.zero i j hij, h₂.zero i j hij, add_zero] comm i := by simp only [HomologicalComplex.add_f_apply, h₁.comm, h₂.comm, AddMonoidHom.map_add] abel #align homotopy.add Homotopy.add @[simps!] def smul {R : Type*} [Semiring R] [Linear R V] (h : Homotopy f g) (a : R) : Homotopy (a • f) (a • g) where hom i j := a • h.hom i j zero i j hij := by dsimp rw [h.zero i j hij, smul_zero] comm i := by dsimp rw [h.comm] dsimp [fromNext, toPrev] simp only [smul_add, Linear.comp_smul, Linear.smul_comp] @[simps] def compRight {e f : C ⟶ D} (h : Homotopy e f) (g : D ⟶ E) : Homotopy (e ≫ g) (f ≫ g) where hom i j := h.hom i j ≫ g.f j zero i j w := by dsimp; rw [h.zero i j w, zero_comp] comm i := by rw [comp_f, h.comm i, dNext_comp_right, prevD_comp_right, Preadditive.add_comp, comp_f, Preadditive.add_comp] #align homotopy.comp_right Homotopy.compRight @[simps] def compLeft {f g : D ⟶ E} (h : Homotopy f g) (e : C ⟶ D) : Homotopy (e ≫ f) (e ≫ g) where hom i j := e.f i ≫ h.hom i j zero i j w := by dsimp; rw [h.zero i j w, comp_zero] comm i := by rw [comp_f, h.comm i, dNext_comp_left, prevD_comp_left, comp_f, Preadditive.comp_add, Preadditive.comp_add] #align homotopy.comp_left Homotopy.compLeft @[simps!] def comp {C₁ C₂ C₃ : HomologicalComplex V c} {f₁ g₁ : C₁ ⟶ C₂} {f₂ g₂ : C₂ ⟶ C₃} (h₁ : Homotopy f₁ g₁) (h₂ : Homotopy f₂ g₂) : Homotopy (f₁ ≫ f₂) (g₁ ≫ g₂) := (h₁.compRight _).trans (h₂.compLeft _) #align homotopy.comp Homotopy.comp @[simps!] def compRightId {f : C ⟶ C} (h : Homotopy f (𝟙 C)) (g : C ⟶ D) : Homotopy (f ≫ g) g := (h.compRight g).trans (ofEq <| id_comp _) #align homotopy.comp_right_id Homotopy.compRightId @[simps!] def compLeftId {f : D ⟶ D} (h : Homotopy f (𝟙 D)) (g : C ⟶ D) : Homotopy (g ≫ f) g := (h.compLeft g).trans (ofEq <| comp_id _) #align homotopy.comp_left_id Homotopy.compLeftId def nullHomotopicMap (hom : ∀ i j, C.X i ⟶ D.X j) : C ⟶ D where f i := dNext i hom + prevD i hom comm' i j hij := by have eq1 : prevD i hom ≫ D.d i j = 0 := by simp only [prevD, AddMonoidHom.mk'_apply, assoc, d_comp_d, comp_zero] have eq2 : C.d i j ≫ dNext j hom = 0 := by simp only [dNext, AddMonoidHom.mk'_apply, d_comp_d_assoc, zero_comp] dsimp only rw [dNext_eq hom hij, prevD_eq hom hij, Preadditive.comp_add, Preadditive.add_comp, eq1, eq2, add_zero, zero_add, assoc] #align homotopy.null_homotopic_map Homotopy.nullHomotopicMap def nullHomotopicMap' (h : ∀ i j, c.Rel j i → (C.X i ⟶ D.X j)) : C ⟶ D := nullHomotopicMap fun i j => dite (c.Rel j i) (h i j) fun _ => 0 #align homotopy.null_homotopic_map' Homotopy.nullHomotopicMap' theorem nullHomotopicMap_comp (hom : ∀ i j, C.X i ⟶ D.X j) (g : D ⟶ E) : nullHomotopicMap hom ≫ g = nullHomotopicMap fun i j => hom i j ≫ g.f j := by ext n dsimp [nullHomotopicMap, fromNext, toPrev, AddMonoidHom.mk'_apply] simp only [Preadditive.add_comp, assoc, g.comm] #align homotopy.null_homotopic_map_comp Homotopy.nullHomotopicMap_comp
Mathlib/Algebra/Homology/Homotopy.lean
299
307
theorem nullHomotopicMap'_comp (hom : ∀ i j, c.Rel j i → (C.X i ⟶ D.X j)) (g : D ⟶ E) : nullHomotopicMap' hom ≫ g = nullHomotopicMap' fun i j hij => hom i j hij ≫ g.f j := by
ext n erw [nullHomotopicMap_comp] congr ext i j split_ifs · rfl · rw [zero_comp]
import Mathlib.Data.ENNReal.Inv #align_import data.real.ennreal from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" open Set NNReal ENNReal namespace ENNReal section Real variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0} theorem toReal_add (ha : a ≠ ∞) (hb : b ≠ ∞) : (a + b).toReal = a.toReal + b.toReal := by lift a to ℝ≥0 using ha lift b to ℝ≥0 using hb rfl #align ennreal.to_real_add ENNReal.toReal_add theorem toReal_sub_of_le {a b : ℝ≥0∞} (h : b ≤ a) (ha : a ≠ ∞) : (a - b).toReal = a.toReal - b.toReal := by lift b to ℝ≥0 using ne_top_of_le_ne_top ha h lift a to ℝ≥0 using ha simp only [← ENNReal.coe_sub, ENNReal.coe_toReal, NNReal.coe_sub (ENNReal.coe_le_coe.mp h)] #align ennreal.to_real_sub_of_le ENNReal.toReal_sub_of_le theorem le_toReal_sub {a b : ℝ≥0∞} (hb : b ≠ ∞) : a.toReal - b.toReal ≤ (a - b).toReal := by lift b to ℝ≥0 using hb induction a · simp · simp only [← coe_sub, NNReal.sub_def, Real.coe_toNNReal', coe_toReal] exact le_max_left _ _ #align ennreal.le_to_real_sub ENNReal.le_toReal_sub theorem toReal_add_le : (a + b).toReal ≤ a.toReal + b.toReal := if ha : a = ∞ then by simp only [ha, top_add, top_toReal, zero_add, toReal_nonneg] else if hb : b = ∞ then by simp only [hb, add_top, top_toReal, add_zero, toReal_nonneg] else le_of_eq (toReal_add ha hb) #align ennreal.to_real_add_le ENNReal.toReal_add_le theorem ofReal_add {p q : ℝ} (hp : 0 ≤ p) (hq : 0 ≤ q) : ENNReal.ofReal (p + q) = ENNReal.ofReal p + ENNReal.ofReal q := by rw [ENNReal.ofReal, ENNReal.ofReal, ENNReal.ofReal, ← coe_add, coe_inj, Real.toNNReal_add hp hq] #align ennreal.of_real_add ENNReal.ofReal_add theorem ofReal_add_le {p q : ℝ} : ENNReal.ofReal (p + q) ≤ ENNReal.ofReal p + ENNReal.ofReal q := coe_le_coe.2 Real.toNNReal_add_le #align ennreal.of_real_add_le ENNReal.ofReal_add_le @[simp] theorem toReal_le_toReal (ha : a ≠ ∞) (hb : b ≠ ∞) : a.toReal ≤ b.toReal ↔ a ≤ b := by lift a to ℝ≥0 using ha lift b to ℝ≥0 using hb norm_cast #align ennreal.to_real_le_to_real ENNReal.toReal_le_toReal @[gcongr] theorem toReal_mono (hb : b ≠ ∞) (h : a ≤ b) : a.toReal ≤ b.toReal := (toReal_le_toReal (ne_top_of_le_ne_top hb h) hb).2 h #align ennreal.to_real_mono ENNReal.toReal_mono -- Porting note (#10756): new lemma theorem toReal_mono' (h : a ≤ b) (ht : b = ∞ → a = ∞) : a.toReal ≤ b.toReal := by rcases eq_or_ne a ∞ with rfl | ha · exact toReal_nonneg · exact toReal_mono (mt ht ha) h @[simp] theorem toReal_lt_toReal (ha : a ≠ ∞) (hb : b ≠ ∞) : a.toReal < b.toReal ↔ a < b := by lift a to ℝ≥0 using ha lift b to ℝ≥0 using hb norm_cast #align ennreal.to_real_lt_to_real ENNReal.toReal_lt_toReal @[gcongr] theorem toReal_strict_mono (hb : b ≠ ∞) (h : a < b) : a.toReal < b.toReal := (toReal_lt_toReal h.ne_top hb).2 h #align ennreal.to_real_strict_mono ENNReal.toReal_strict_mono @[gcongr] theorem toNNReal_mono (hb : b ≠ ∞) (h : a ≤ b) : a.toNNReal ≤ b.toNNReal := toReal_mono hb h #align ennreal.to_nnreal_mono ENNReal.toNNReal_mono -- Porting note (#10756): new lemma theorem toReal_le_add' (hle : a ≤ b + c) (hb : b = ∞ → a = ∞) (hc : c = ∞ → a = ∞) : a.toReal ≤ b.toReal + c.toReal := by refine le_trans (toReal_mono' hle ?_) toReal_add_le simpa only [add_eq_top, or_imp] using And.intro hb hc -- Porting note (#10756): new lemma theorem toReal_le_add (hle : a ≤ b + c) (hb : b ≠ ∞) (hc : c ≠ ∞) : a.toReal ≤ b.toReal + c.toReal := toReal_le_add' hle (flip absurd hb) (flip absurd hc) @[simp] theorem toNNReal_le_toNNReal (ha : a ≠ ∞) (hb : b ≠ ∞) : a.toNNReal ≤ b.toNNReal ↔ a ≤ b := ⟨fun h => by rwa [← coe_toNNReal ha, ← coe_toNNReal hb, coe_le_coe], toNNReal_mono hb⟩ #align ennreal.to_nnreal_le_to_nnreal ENNReal.toNNReal_le_toNNReal theorem toNNReal_strict_mono (hb : b ≠ ∞) (h : a < b) : a.toNNReal < b.toNNReal := by simpa [← ENNReal.coe_lt_coe, hb, h.ne_top] #align ennreal.to_nnreal_strict_mono ENNReal.toNNReal_strict_mono @[simp] theorem toNNReal_lt_toNNReal (ha : a ≠ ∞) (hb : b ≠ ∞) : a.toNNReal < b.toNNReal ↔ a < b := ⟨fun h => by rwa [← coe_toNNReal ha, ← coe_toNNReal hb, coe_lt_coe], toNNReal_strict_mono hb⟩ #align ennreal.to_nnreal_lt_to_nnreal ENNReal.toNNReal_lt_toNNReal theorem toReal_max (hr : a ≠ ∞) (hp : b ≠ ∞) : ENNReal.toReal (max a b) = max (ENNReal.toReal a) (ENNReal.toReal b) := (le_total a b).elim (fun h => by simp only [h, (ENNReal.toReal_le_toReal hr hp).2 h, max_eq_right]) fun h => by simp only [h, (ENNReal.toReal_le_toReal hp hr).2 h, max_eq_left] #align ennreal.to_real_max ENNReal.toReal_max theorem toReal_min {a b : ℝ≥0∞} (hr : a ≠ ∞) (hp : b ≠ ∞) : ENNReal.toReal (min a b) = min (ENNReal.toReal a) (ENNReal.toReal b) := (le_total a b).elim (fun h => by simp only [h, (ENNReal.toReal_le_toReal hr hp).2 h, min_eq_left]) fun h => by simp only [h, (ENNReal.toReal_le_toReal hp hr).2 h, min_eq_right] #align ennreal.to_real_min ENNReal.toReal_min theorem toReal_sup {a b : ℝ≥0∞} : a ≠ ∞ → b ≠ ∞ → (a ⊔ b).toReal = a.toReal ⊔ b.toReal := toReal_max #align ennreal.to_real_sup ENNReal.toReal_sup theorem toReal_inf {a b : ℝ≥0∞} : a ≠ ∞ → b ≠ ∞ → (a ⊓ b).toReal = a.toReal ⊓ b.toReal := toReal_min #align ennreal.to_real_inf ENNReal.toReal_inf theorem toNNReal_pos_iff : 0 < a.toNNReal ↔ 0 < a ∧ a < ∞ := by induction a <;> simp #align ennreal.to_nnreal_pos_iff ENNReal.toNNReal_pos_iff theorem toNNReal_pos {a : ℝ≥0∞} (ha₀ : a ≠ 0) (ha_top : a ≠ ∞) : 0 < a.toNNReal := toNNReal_pos_iff.mpr ⟨bot_lt_iff_ne_bot.mpr ha₀, lt_top_iff_ne_top.mpr ha_top⟩ #align ennreal.to_nnreal_pos ENNReal.toNNReal_pos theorem toReal_pos_iff : 0 < a.toReal ↔ 0 < a ∧ a < ∞ := NNReal.coe_pos.trans toNNReal_pos_iff #align ennreal.to_real_pos_iff ENNReal.toReal_pos_iff theorem toReal_pos {a : ℝ≥0∞} (ha₀ : a ≠ 0) (ha_top : a ≠ ∞) : 0 < a.toReal := toReal_pos_iff.mpr ⟨bot_lt_iff_ne_bot.mpr ha₀, lt_top_iff_ne_top.mpr ha_top⟩ #align ennreal.to_real_pos ENNReal.toReal_pos @[gcongr] theorem ofReal_le_ofReal {p q : ℝ} (h : p ≤ q) : ENNReal.ofReal p ≤ ENNReal.ofReal q := by simp [ENNReal.ofReal, Real.toNNReal_le_toNNReal h] #align ennreal.of_real_le_of_real ENNReal.ofReal_le_ofReal theorem ofReal_le_of_le_toReal {a : ℝ} {b : ℝ≥0∞} (h : a ≤ ENNReal.toReal b) : ENNReal.ofReal a ≤ b := (ofReal_le_ofReal h).trans ofReal_toReal_le #align ennreal.of_real_le_of_le_to_real ENNReal.ofReal_le_of_le_toReal @[simp] theorem ofReal_le_ofReal_iff {p q : ℝ} (h : 0 ≤ q) : ENNReal.ofReal p ≤ ENNReal.ofReal q ↔ p ≤ q := by rw [ENNReal.ofReal, ENNReal.ofReal, coe_le_coe, Real.toNNReal_le_toNNReal_iff h] #align ennreal.of_real_le_of_real_iff ENNReal.ofReal_le_ofReal_iff lemma ofReal_le_ofReal_iff' {p q : ℝ} : ENNReal.ofReal p ≤ .ofReal q ↔ p ≤ q ∨ p ≤ 0 := coe_le_coe.trans Real.toNNReal_le_toNNReal_iff' lemma ofReal_lt_ofReal_iff' {p q : ℝ} : ENNReal.ofReal p < .ofReal q ↔ p < q ∧ 0 < q := coe_lt_coe.trans Real.toNNReal_lt_toNNReal_iff' @[simp] theorem ofReal_eq_ofReal_iff {p q : ℝ} (hp : 0 ≤ p) (hq : 0 ≤ q) : ENNReal.ofReal p = ENNReal.ofReal q ↔ p = q := by rw [ENNReal.ofReal, ENNReal.ofReal, coe_inj, Real.toNNReal_eq_toNNReal_iff hp hq] #align ennreal.of_real_eq_of_real_iff ENNReal.ofReal_eq_ofReal_iff @[simp]
Mathlib/Data/ENNReal/Real.lean
207
209
theorem ofReal_lt_ofReal_iff {p q : ℝ} (h : 0 < q) : ENNReal.ofReal p < ENNReal.ofReal q ↔ p < q := by
rw [ENNReal.ofReal, ENNReal.ofReal, coe_lt_coe, Real.toNNReal_lt_toNNReal_iff h]
import Mathlib.Algebra.MvPolynomial.PDeriv import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Data.Nat.Choose.Sum import Mathlib.LinearAlgebra.LinearIndependent import Mathlib.RingTheory.Polynomial.Pochhammer #align_import ring_theory.polynomial.bernstein from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821" noncomputable section open Nat (choose) open Polynomial (X) open scoped Polynomial variable (R : Type*) [CommRing R] def bernsteinPolynomial (n ν : ℕ) : R[X] := (choose n ν : R[X]) * X ^ ν * (1 - X) ^ (n - ν) #align bernstein_polynomial bernsteinPolynomial example : bernsteinPolynomial ℤ 3 2 = 3 * X ^ 2 - 3 * X ^ 3 := by norm_num [bernsteinPolynomial, choose] ring namespace bernsteinPolynomial theorem eq_zero_of_lt {n ν : ℕ} (h : n < ν) : bernsteinPolynomial R n ν = 0 := by simp [bernsteinPolynomial, Nat.choose_eq_zero_of_lt h] #align bernstein_polynomial.eq_zero_of_lt bernsteinPolynomial.eq_zero_of_lt section variable {R} {S : Type*} [CommRing S] @[simp] theorem map (f : R →+* S) (n ν : ℕ) : (bernsteinPolynomial R n ν).map f = bernsteinPolynomial S n ν := by simp [bernsteinPolynomial] #align bernstein_polynomial.map bernsteinPolynomial.map end theorem flip (n ν : ℕ) (h : ν ≤ n) : (bernsteinPolynomial R n ν).comp (1 - X) = bernsteinPolynomial R n (n - ν) := by simp [bernsteinPolynomial, h, tsub_tsub_assoc, mul_right_comm] #align bernstein_polynomial.flip bernsteinPolynomial.flip theorem flip' (n ν : ℕ) (h : ν ≤ n) : bernsteinPolynomial R n ν = (bernsteinPolynomial R n (n - ν)).comp (1 - X) := by simp [← flip _ _ _ h, Polynomial.comp_assoc] #align bernstein_polynomial.flip' bernsteinPolynomial.flip' theorem eval_at_0 (n ν : ℕ) : (bernsteinPolynomial R n ν).eval 0 = if ν = 0 then 1 else 0 := by rw [bernsteinPolynomial] split_ifs with h · subst h; simp · simp [zero_pow h] #align bernstein_polynomial.eval_at_0 bernsteinPolynomial.eval_at_0 theorem eval_at_1 (n ν : ℕ) : (bernsteinPolynomial R n ν).eval 1 = if ν = n then 1 else 0 := by rw [bernsteinPolynomial] split_ifs with h · subst h; simp · obtain hνn | hnν := Ne.lt_or_lt h · simp [zero_pow $ Nat.sub_ne_zero_of_lt hνn] · simp [Nat.choose_eq_zero_of_lt hnν] #align bernstein_polynomial.eval_at_1 bernsteinPolynomial.eval_at_1 theorem derivative_succ_aux (n ν : ℕ) : Polynomial.derivative (bernsteinPolynomial R (n + 1) (ν + 1)) = (n + 1) * (bernsteinPolynomial R n ν - bernsteinPolynomial R n (ν + 1)) := by rw [bernsteinPolynomial] suffices ((n + 1).choose (ν + 1) : R[X]) * ((↑(ν + 1 : ℕ) : R[X]) * X ^ ν) * (1 - X) ^ (n - ν) - ((n + 1).choose (ν + 1) : R[X]) * X ^ (ν + 1) * ((↑(n - ν) : R[X]) * (1 - X) ^ (n - ν - 1)) = (↑(n + 1) : R[X]) * ((n.choose ν : R[X]) * X ^ ν * (1 - X) ^ (n - ν) - (n.choose (ν + 1) : R[X]) * X ^ (ν + 1) * (1 - X) ^ (n - (ν + 1))) by simpa [Polynomial.derivative_pow, ← sub_eq_add_neg, Nat.succ_sub_succ_eq_sub, Polynomial.derivative_mul, Polynomial.derivative_natCast, zero_mul, Nat.cast_add, algebraMap.coe_one, Polynomial.derivative_X, mul_one, zero_add, Polynomial.derivative_sub, Polynomial.derivative_one, zero_sub, mul_neg, Nat.sub_zero, bernsteinPolynomial, map_add, map_natCast, Nat.cast_one] conv_rhs => rw [mul_sub] -- We'll prove the two terms match up separately. refine congr (congr_arg Sub.sub ?_) ?_ · simp only [← mul_assoc] apply congr (congr_arg (· * ·) (congr (congr_arg (· * ·) _) rfl)) rfl -- Now it's just about binomial coefficients exact mod_cast congr_arg (fun m : ℕ => (m : R[X])) (Nat.succ_mul_choose_eq n ν).symm · rw [← tsub_add_eq_tsub_tsub, ← mul_assoc, ← mul_assoc]; congr 1 rw [mul_comm, ← mul_assoc, ← mul_assoc]; congr 1 norm_cast congr 1 convert (Nat.choose_mul_succ_eq n (ν + 1)).symm using 1 · -- Porting note: was -- convert mul_comm _ _ using 2 -- simp rw [mul_comm, Nat.succ_sub_succ_eq_sub] · apply mul_comm #align bernstein_polynomial.derivative_succ_aux bernsteinPolynomial.derivative_succ_aux theorem derivative_succ (n ν : ℕ) : Polynomial.derivative (bernsteinPolynomial R n (ν + 1)) = n * (bernsteinPolynomial R (n - 1) ν - bernsteinPolynomial R (n - 1) (ν + 1)) := by cases n · simp [bernsteinPolynomial] · rw [Nat.cast_succ]; apply derivative_succ_aux #align bernstein_polynomial.derivative_succ bernsteinPolynomial.derivative_succ theorem derivative_zero (n : ℕ) : Polynomial.derivative (bernsteinPolynomial R n 0) = -n * bernsteinPolynomial R (n - 1) 0 := by simp [bernsteinPolynomial, Polynomial.derivative_pow] #align bernstein_polynomial.derivative_zero bernsteinPolynomial.derivative_zero theorem iterate_derivative_at_0_eq_zero_of_lt (n : ℕ) {ν k : ℕ} : k < ν → (Polynomial.derivative^[k] (bernsteinPolynomial R n ν)).eval 0 = 0 := by cases' ν with ν · rintro ⟨⟩ · rw [Nat.lt_succ_iff] induction' k with k ih generalizing n ν · simp [eval_at_0] · simp only [derivative_succ, Int.natCast_eq_zero, mul_eq_zero, Function.comp_apply, Function.iterate_succ, Polynomial.iterate_derivative_sub, Polynomial.iterate_derivative_natCast_mul, Polynomial.eval_mul, Polynomial.eval_natCast, Polynomial.eval_sub] intro h apply mul_eq_zero_of_right rw [ih _ _ (Nat.le_of_succ_le h), sub_zero] convert ih _ _ (Nat.pred_le_pred h) exact (Nat.succ_pred_eq_of_pos (k.succ_pos.trans_le h)).symm #align bernstein_polynomial.iterate_derivative_at_0_eq_zero_of_lt bernsteinPolynomial.iterate_derivative_at_0_eq_zero_of_lt @[simp] theorem iterate_derivative_succ_at_0_eq_zero (n ν : ℕ) : (Polynomial.derivative^[ν] (bernsteinPolynomial R n (ν + 1))).eval 0 = 0 := iterate_derivative_at_0_eq_zero_of_lt R n (lt_add_one ν) #align bernstein_polynomial.iterate_derivative_succ_at_0_eq_zero bernsteinPolynomial.iterate_derivative_succ_at_0_eq_zero open Polynomial @[simp] theorem iterate_derivative_at_0 (n ν : ℕ) : (Polynomial.derivative^[ν] (bernsteinPolynomial R n ν)).eval 0 = (ascPochhammer R ν).eval ((n - (ν - 1) : ℕ) : R) := by by_cases h : ν ≤ n · induction' ν with ν ih generalizing n · simp [eval_at_0] · have h' : ν ≤ n - 1 := le_tsub_of_add_le_right h simp only [derivative_succ, ih (n - 1) h', iterate_derivative_succ_at_0_eq_zero, Nat.succ_sub_succ_eq_sub, tsub_zero, sub_zero, iterate_derivative_sub, iterate_derivative_natCast_mul, eval_one, eval_mul, eval_add, eval_sub, eval_X, eval_comp, eval_natCast, Function.comp_apply, Function.iterate_succ, ascPochhammer_succ_left] obtain rfl | h'' := ν.eq_zero_or_pos · simp · have : n - 1 - (ν - 1) = n - ν := by rw [gt_iff_lt, ← Nat.succ_le_iff] at h'' rw [← tsub_add_eq_tsub_tsub, add_comm, tsub_add_cancel_of_le h''] rw [this, ascPochhammer_eval_succ] rw_mod_cast [tsub_add_cancel_of_le (h'.trans n.pred_le)] · simp only [not_le] at h rw [tsub_eq_zero_iff_le.mpr (Nat.le_sub_one_of_lt h), eq_zero_of_lt R h] simp [pos_iff_ne_zero.mp (pos_of_gt h)] #align bernstein_polynomial.iterate_derivative_at_0 bernsteinPolynomial.iterate_derivative_at_0 theorem iterate_derivative_at_0_ne_zero [CharZero R] (n ν : ℕ) (h : ν ≤ n) : (Polynomial.derivative^[ν] (bernsteinPolynomial R n ν)).eval 0 ≠ 0 := by simp only [Int.natCast_eq_zero, bernsteinPolynomial.iterate_derivative_at_0, Ne, Nat.cast_eq_zero] simp only [← ascPochhammer_eval_cast] norm_cast apply ne_of_gt obtain rfl | h' := Nat.eq_zero_or_pos ν · simp · rw [← Nat.succ_pred_eq_of_pos h'] at h exact ascPochhammer_pos _ _ (tsub_pos_of_lt (Nat.lt_of_succ_le h)) #align bernstein_polynomial.iterate_derivative_at_0_ne_zero bernsteinPolynomial.iterate_derivative_at_0_ne_zero theorem iterate_derivative_at_1_eq_zero_of_lt (n : ℕ) {ν k : ℕ} : k < n - ν → (Polynomial.derivative^[k] (bernsteinPolynomial R n ν)).eval 1 = 0 := by intro w rw [flip' _ _ _ (tsub_pos_iff_lt.mp (pos_of_gt w)).le] simp [Polynomial.eval_comp, iterate_derivative_at_0_eq_zero_of_lt R n w] #align bernstein_polynomial.iterate_derivative_at_1_eq_zero_of_lt bernsteinPolynomial.iterate_derivative_at_1_eq_zero_of_lt @[simp] theorem iterate_derivative_at_1 (n ν : ℕ) (h : ν ≤ n) : (Polynomial.derivative^[n - ν] (bernsteinPolynomial R n ν)).eval 1 = (-1) ^ (n - ν) * (ascPochhammer R (n - ν)).eval (ν + 1 : R) := by rw [flip' _ _ _ h] simp [Polynomial.eval_comp, h] obtain rfl | h' := h.eq_or_lt · simp · norm_cast congr omega #align bernstein_polynomial.iterate_derivative_at_1 bernsteinPolynomial.iterate_derivative_at_1 theorem iterate_derivative_at_1_ne_zero [CharZero R] (n ν : ℕ) (h : ν ≤ n) : (Polynomial.derivative^[n - ν] (bernsteinPolynomial R n ν)).eval 1 ≠ 0 := by rw [bernsteinPolynomial.iterate_derivative_at_1 _ _ _ h, Ne, neg_one_pow_mul_eq_zero_iff, ← Nat.cast_succ, ← ascPochhammer_eval_cast, ← Nat.cast_zero, Nat.cast_inj] exact (ascPochhammer_pos _ _ (Nat.succ_pos ν)).ne' #align bernstein_polynomial.iterate_derivative_at_1_ne_zero bernsteinPolynomial.iterate_derivative_at_1_ne_zero open Submodule theorem linearIndependent_aux (n k : ℕ) (h : k ≤ n + 1) : LinearIndependent ℚ fun ν : Fin k => bernsteinPolynomial ℚ n ν := by induction' k with k ih · apply linearIndependent_empty_type · apply linearIndependent_fin_succ'.mpr fconstructor · exact ih (le_of_lt h) · -- The actual work! -- We show that the (n-k)-th derivative at 1 doesn't vanish, -- but vanishes for everything in the span. clear ih simp only [Nat.succ_eq_add_one, add_le_add_iff_right] at h simp only [Fin.val_last, Fin.init_def] dsimp apply not_mem_span_of_apply_not_mem_span_image (@Polynomial.derivative ℚ _ ^ (n - k)) -- Note: #8386 had to change `span_image` into `span_image _` simp only [not_exists, not_and, Submodule.mem_map, Submodule.span_image _] intro p m apply_fun Polynomial.eval (1 : ℚ) simp only [LinearMap.pow_apply] -- The right hand side is nonzero, -- so it will suffice to show the left hand side is always zero. suffices (Polynomial.derivative^[n - k] p).eval 1 = 0 by rw [this] exact (iterate_derivative_at_1_ne_zero ℚ n k h).symm refine span_induction m ?_ ?_ ?_ ?_ · simp rintro ⟨a, w⟩; simp only [Fin.val_mk] rw [iterate_derivative_at_1_eq_zero_of_lt ℚ n ((tsub_lt_tsub_iff_left_of_le h).mpr w)] · simp · intro x y hx hy; simp [hx, hy] · intro a x h; simp [h] #align bernstein_polynomial.linear_independent_aux bernsteinPolynomial.linearIndependent_aux theorem linearIndependent (n : ℕ) : LinearIndependent ℚ fun ν : Fin (n + 1) => bernsteinPolynomial ℚ n ν := linearIndependent_aux n (n + 1) le_rfl #align bernstein_polynomial.linear_independent bernsteinPolynomial.linearIndependent theorem sum (n : ℕ) : (∑ ν ∈ Finset.range (n + 1), bernsteinPolynomial R n ν) = 1 := calc (∑ ν ∈ Finset.range (n + 1), bernsteinPolynomial R n ν) = (X + (1 - X)) ^ n := by rw [add_pow] simp only [bernsteinPolynomial, mul_comm, mul_assoc, mul_left_comm] _ = 1 := by simp #align bernstein_polynomial.sum bernsteinPolynomial.sum open Polynomial open MvPolynomial hiding X
Mathlib/RingTheory/Polynomial/Bernstein.lean
301
335
theorem sum_smul (n : ℕ) : (∑ ν ∈ Finset.range (n + 1), ν • bernsteinPolynomial R n ν) = n • X := by
-- We calculate the `x`-derivative of `(x+y)^n`, evaluated at `y=(1-x)`, -- either directly or by using the binomial theorem. -- We'll work in `MvPolynomial Bool R`. let x : MvPolynomial Bool R := MvPolynomial.X true let y : MvPolynomial Bool R := MvPolynomial.X false have pderiv_true_x : pderiv true x = 1 := by rw [pderiv_X]; rfl have pderiv_true_y : pderiv true y = 0 := by rw [pderiv_X]; rfl let e : Bool → R[X] := fun i => cond i X (1 - X) -- Start with `(x+y)^n = (x+y)^n`, -- take the `x`-derivative, evaluate at `x=X, y=1-X`, and multiply by `X`: trans MvPolynomial.aeval e (pderiv true ((x + y) ^ n)) * X -- On the left hand side we'll use the binomial theorem, then simplify. · -- We first prepare a tedious rewrite: have w : ∀ k : ℕ, k • bernsteinPolynomial R n k = (k : R[X]) * Polynomial.X ^ (k - 1) * (1 - Polynomial.X) ^ (n - k) * (n.choose k : R[X]) * Polynomial.X := by rintro (_ | k) · simp · rw [bernsteinPolynomial] simp only [← natCast_mul, Nat.succ_eq_add_one, Nat.add_succ_sub_one, add_zero, pow_succ] push_cast ring rw [add_pow, map_sum (pderiv true), map_sum (MvPolynomial.aeval e), Finset.sum_mul] -- Step inside the sum: refine Finset.sum_congr rfl fun k _ => (w k).trans ?_ simp only [x, y, e, pderiv_true_x, pderiv_true_y, Algebra.id.smul_eq_mul, nsmul_eq_mul, Bool.cond_true, Bool.cond_false, add_zero, mul_one, mul_zero, smul_zero, MvPolynomial.aeval_X, MvPolynomial.pderiv_mul, Derivation.leibniz_pow, Derivation.map_natCast, map_natCast, map_pow, map_mul] · rw [(pderiv true).leibniz_pow, (pderiv true).map_add, pderiv_true_x, pderiv_true_y] simp only [x, y, e, Algebra.id.smul_eq_mul, nsmul_eq_mul, map_natCast, map_pow, map_add, map_mul, Bool.cond_true, Bool.cond_false, MvPolynomial.aeval_X, add_sub_cancel, one_pow, add_zero, mul_one]
import Mathlib.Data.Set.Image import Mathlib.Order.SuccPred.Relation import Mathlib.Topology.Clopen import Mathlib.Topology.Irreducible #align_import topology.connected from "leanprover-community/mathlib"@"d101e93197bb5f6ea89bd7ba386b7f7dff1f3903" open Set Function Topology TopologicalSpace Relation open scoped Classical universe u v variable {α : Type u} {β : Type v} {ι : Type*} {π : ι → Type*} [TopologicalSpace α] {s t u v : Set α} section Preconnected def IsPreconnected (s : Set α) : Prop := ∀ u v : Set α, IsOpen u → IsOpen v → s ⊆ u ∪ v → (s ∩ u).Nonempty → (s ∩ v).Nonempty → (s ∩ (u ∩ v)).Nonempty #align is_preconnected IsPreconnected def IsConnected (s : Set α) : Prop := s.Nonempty ∧ IsPreconnected s #align is_connected IsConnected theorem IsConnected.nonempty {s : Set α} (h : IsConnected s) : s.Nonempty := h.1 #align is_connected.nonempty IsConnected.nonempty theorem IsConnected.isPreconnected {s : Set α} (h : IsConnected s) : IsPreconnected s := h.2 #align is_connected.is_preconnected IsConnected.isPreconnected theorem IsPreirreducible.isPreconnected {s : Set α} (H : IsPreirreducible s) : IsPreconnected s := fun _ _ hu hv _ => H _ _ hu hv #align is_preirreducible.is_preconnected IsPreirreducible.isPreconnected theorem IsIrreducible.isConnected {s : Set α} (H : IsIrreducible s) : IsConnected s := ⟨H.nonempty, H.isPreirreducible.isPreconnected⟩ #align is_irreducible.is_connected IsIrreducible.isConnected theorem isPreconnected_empty : IsPreconnected (∅ : Set α) := isPreirreducible_empty.isPreconnected #align is_preconnected_empty isPreconnected_empty theorem isConnected_singleton {x} : IsConnected ({x} : Set α) := isIrreducible_singleton.isConnected #align is_connected_singleton isConnected_singleton theorem isPreconnected_singleton {x} : IsPreconnected ({x} : Set α) := isConnected_singleton.isPreconnected #align is_preconnected_singleton isPreconnected_singleton theorem Set.Subsingleton.isPreconnected {s : Set α} (hs : s.Subsingleton) : IsPreconnected s := hs.induction_on isPreconnected_empty fun _ => isPreconnected_singleton #align set.subsingleton.is_preconnected Set.Subsingleton.isPreconnected theorem isPreconnected_of_forall {s : Set α} (x : α) (H : ∀ y ∈ s, ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t) : IsPreconnected s := by rintro u v hu hv hs ⟨z, zs, zu⟩ ⟨y, ys, yv⟩ have xs : x ∈ s := by rcases H y ys with ⟨t, ts, xt, -, -⟩ exact ts xt -- Porting note (#11215): TODO: use `wlog xu : x ∈ u := hs xs using u v y z, v u z y` cases hs xs with | inl xu => rcases H y ys with ⟨t, ts, xt, yt, ht⟩ have := ht u v hu hv (ts.trans hs) ⟨x, xt, xu⟩ ⟨y, yt, yv⟩ exact this.imp fun z hz => ⟨ts hz.1, hz.2⟩ | inr xv => rcases H z zs with ⟨t, ts, xt, zt, ht⟩ have := ht v u hv hu (ts.trans <| by rwa [union_comm]) ⟨x, xt, xv⟩ ⟨z, zt, zu⟩ exact this.imp fun _ h => ⟨ts h.1, h.2.2, h.2.1⟩ #align is_preconnected_of_forall isPreconnected_of_forall theorem isPreconnected_of_forall_pair {s : Set α} (H : ∀ x ∈ s, ∀ y ∈ s, ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t) : IsPreconnected s := by rcases eq_empty_or_nonempty s with (rfl | ⟨x, hx⟩) exacts [isPreconnected_empty, isPreconnected_of_forall x fun y => H x hx y] #align is_preconnected_of_forall_pair isPreconnected_of_forall_pair theorem isPreconnected_sUnion (x : α) (c : Set (Set α)) (H1 : ∀ s ∈ c, x ∈ s) (H2 : ∀ s ∈ c, IsPreconnected s) : IsPreconnected (⋃₀ c) := by apply isPreconnected_of_forall x rintro y ⟨s, sc, ys⟩ exact ⟨s, subset_sUnion_of_mem sc, H1 s sc, ys, H2 s sc⟩ #align is_preconnected_sUnion isPreconnected_sUnion theorem isPreconnected_iUnion {ι : Sort*} {s : ι → Set α} (h₁ : (⋂ i, s i).Nonempty) (h₂ : ∀ i, IsPreconnected (s i)) : IsPreconnected (⋃ i, s i) := Exists.elim h₁ fun f hf => isPreconnected_sUnion f _ hf (forall_mem_range.2 h₂) #align is_preconnected_Union isPreconnected_iUnion theorem IsPreconnected.union (x : α) {s t : Set α} (H1 : x ∈ s) (H2 : x ∈ t) (H3 : IsPreconnected s) (H4 : IsPreconnected t) : IsPreconnected (s ∪ t) := sUnion_pair s t ▸ isPreconnected_sUnion x {s, t} (by rintro r (rfl | rfl | h) <;> assumption) (by rintro r (rfl | rfl | h) <;> assumption) #align is_preconnected.union IsPreconnected.union theorem IsPreconnected.union' {s t : Set α} (H : (s ∩ t).Nonempty) (hs : IsPreconnected s) (ht : IsPreconnected t) : IsPreconnected (s ∪ t) := by rcases H with ⟨x, hxs, hxt⟩ exact hs.union x hxs hxt ht #align is_preconnected.union' IsPreconnected.union' theorem IsConnected.union {s t : Set α} (H : (s ∩ t).Nonempty) (Hs : IsConnected s) (Ht : IsConnected t) : IsConnected (s ∪ t) := by rcases H with ⟨x, hx⟩ refine ⟨⟨x, mem_union_left t (mem_of_mem_inter_left hx)⟩, ?_⟩ exact Hs.isPreconnected.union x (mem_of_mem_inter_left hx) (mem_of_mem_inter_right hx) Ht.isPreconnected #align is_connected.union IsConnected.union theorem IsPreconnected.sUnion_directed {S : Set (Set α)} (K : DirectedOn (· ⊆ ·) S) (H : ∀ s ∈ S, IsPreconnected s) : IsPreconnected (⋃₀ S) := by rintro u v hu hv Huv ⟨a, ⟨s, hsS, has⟩, hau⟩ ⟨b, ⟨t, htS, hbt⟩, hbv⟩ obtain ⟨r, hrS, hsr, htr⟩ : ∃ r ∈ S, s ⊆ r ∧ t ⊆ r := K s hsS t htS have Hnuv : (r ∩ (u ∩ v)).Nonempty := H _ hrS u v hu hv ((subset_sUnion_of_mem hrS).trans Huv) ⟨a, hsr has, hau⟩ ⟨b, htr hbt, hbv⟩ have Kruv : r ∩ (u ∩ v) ⊆ ⋃₀ S ∩ (u ∩ v) := inter_subset_inter_left _ (subset_sUnion_of_mem hrS) exact Hnuv.mono Kruv #align is_preconnected.sUnion_directed IsPreconnected.sUnion_directed theorem IsPreconnected.biUnion_of_reflTransGen {ι : Type*} {t : Set ι} {s : ι → Set α} (H : ∀ i ∈ t, IsPreconnected (s i)) (K : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen (fun i j => (s i ∩ s j).Nonempty ∧ i ∈ t) i j) : IsPreconnected (⋃ n ∈ t, s n) := by let R := fun i j : ι => (s i ∩ s j).Nonempty ∧ i ∈ t have P : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen R i j → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ j ∈ p, s j) := fun i hi j hj h => by induction h with | refl => refine ⟨{i}, singleton_subset_iff.mpr hi, mem_singleton i, mem_singleton i, ?_⟩ rw [biUnion_singleton] exact H i hi | @tail j k _ hjk ih => obtain ⟨p, hpt, hip, hjp, hp⟩ := ih hjk.2 refine ⟨insert k p, insert_subset_iff.mpr ⟨hj, hpt⟩, mem_insert_of_mem k hip, mem_insert k p, ?_⟩ rw [biUnion_insert] refine (H k hj).union' (hjk.1.mono ?_) hp rw [inter_comm] exact inter_subset_inter_right _ (subset_biUnion_of_mem hjp) refine isPreconnected_of_forall_pair ?_ intro x hx y hy obtain ⟨i : ι, hi : i ∈ t, hxi : x ∈ s i⟩ := mem_iUnion₂.1 hx obtain ⟨j : ι, hj : j ∈ t, hyj : y ∈ s j⟩ := mem_iUnion₂.1 hy obtain ⟨p, hpt, hip, hjp, hp⟩ := P i hi j hj (K i hi j hj) exact ⟨⋃ j ∈ p, s j, biUnion_subset_biUnion_left hpt, mem_biUnion hip hxi, mem_biUnion hjp hyj, hp⟩ #align is_preconnected.bUnion_of_refl_trans_gen IsPreconnected.biUnion_of_reflTransGen theorem IsConnected.biUnion_of_reflTransGen {ι : Type*} {t : Set ι} {s : ι → Set α} (ht : t.Nonempty) (H : ∀ i ∈ t, IsConnected (s i)) (K : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty ∧ i ∈ t) i j) : IsConnected (⋃ n ∈ t, s n) := ⟨nonempty_biUnion.2 <| ⟨ht.some, ht.some_mem, (H _ ht.some_mem).nonempty⟩, IsPreconnected.biUnion_of_reflTransGen (fun i hi => (H i hi).isPreconnected) K⟩ #align is_connected.bUnion_of_refl_trans_gen IsConnected.biUnion_of_reflTransGen theorem IsPreconnected.iUnion_of_reflTransGen {ι : Type*} {s : ι → Set α} (H : ∀ i, IsPreconnected (s i)) (K : ∀ i j, ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty) i j) : IsPreconnected (⋃ n, s n) := by rw [← biUnion_univ] exact IsPreconnected.biUnion_of_reflTransGen (fun i _ => H i) fun i _ j _ => by simpa [mem_univ] using K i j #align is_preconnected.Union_of_refl_trans_gen IsPreconnected.iUnion_of_reflTransGen theorem IsConnected.iUnion_of_reflTransGen {ι : Type*} [Nonempty ι] {s : ι → Set α} (H : ∀ i, IsConnected (s i)) (K : ∀ i j, ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty) i j) : IsConnected (⋃ n, s n) := ⟨nonempty_iUnion.2 <| Nonempty.elim ‹_› fun i : ι => ⟨i, (H _).nonempty⟩, IsPreconnected.iUnion_of_reflTransGen (fun i => (H i).isPreconnected) K⟩ #align is_connected.Union_of_refl_trans_gen IsConnected.iUnion_of_reflTransGen protected theorem IsPreconnected.subset_closure {s : Set α} {t : Set α} (H : IsPreconnected s) (Kst : s ⊆ t) (Ktcs : t ⊆ closure s) : IsPreconnected t := fun u v hu hv htuv ⟨_y, hyt, hyu⟩ ⟨_z, hzt, hzv⟩ => let ⟨p, hpu, hps⟩ := mem_closure_iff.1 (Ktcs hyt) u hu hyu let ⟨q, hqv, hqs⟩ := mem_closure_iff.1 (Ktcs hzt) v hv hzv let ⟨r, hrs, hruv⟩ := H u v hu hv (Subset.trans Kst htuv) ⟨p, hps, hpu⟩ ⟨q, hqs, hqv⟩ ⟨r, Kst hrs, hruv⟩ #align is_preconnected.subset_closure IsPreconnected.subset_closure protected theorem IsConnected.subset_closure {s : Set α} {t : Set α} (H : IsConnected s) (Kst : s ⊆ t) (Ktcs : t ⊆ closure s) : IsConnected t := ⟨Nonempty.mono Kst H.left, IsPreconnected.subset_closure H.right Kst Ktcs⟩ #align is_connected.subset_closure IsConnected.subset_closure protected theorem IsPreconnected.closure {s : Set α} (H : IsPreconnected s) : IsPreconnected (closure s) := IsPreconnected.subset_closure H subset_closure Subset.rfl #align is_preconnected.closure IsPreconnected.closure protected theorem IsConnected.closure {s : Set α} (H : IsConnected s) : IsConnected (closure s) := IsConnected.subset_closure H subset_closure <| Subset.rfl #align is_connected.closure IsConnected.closure protected theorem IsPreconnected.image [TopologicalSpace β] {s : Set α} (H : IsPreconnected s) (f : α → β) (hf : ContinuousOn f s) : IsPreconnected (f '' s) := by -- Unfold/destruct definitions in hypotheses rintro u v hu hv huv ⟨_, ⟨x, xs, rfl⟩, xu⟩ ⟨_, ⟨y, ys, rfl⟩, yv⟩ rcases continuousOn_iff'.1 hf u hu with ⟨u', hu', u'_eq⟩ rcases continuousOn_iff'.1 hf v hv with ⟨v', hv', v'_eq⟩ -- Reformulate `huv : f '' s ⊆ u ∪ v` in terms of `u'` and `v'` replace huv : s ⊆ u' ∪ v' := by rw [image_subset_iff, preimage_union] at huv replace huv := subset_inter huv Subset.rfl rw [union_inter_distrib_right, u'_eq, v'_eq, ← union_inter_distrib_right] at huv exact (subset_inter_iff.1 huv).1 -- Now `s ⊆ u' ∪ v'`, so we can apply `‹IsPreconnected s›` obtain ⟨z, hz⟩ : (s ∩ (u' ∩ v')).Nonempty := by refine H u' v' hu' hv' huv ⟨x, ?_⟩ ⟨y, ?_⟩ <;> rw [inter_comm] exacts [u'_eq ▸ ⟨xu, xs⟩, v'_eq ▸ ⟨yv, ys⟩] rw [← inter_self s, inter_assoc, inter_left_comm s u', ← inter_assoc, inter_comm s, inter_comm s, ← u'_eq, ← v'_eq] at hz exact ⟨f z, ⟨z, hz.1.2, rfl⟩, hz.1.1, hz.2.1⟩ #align is_preconnected.image IsPreconnected.image protected theorem IsConnected.image [TopologicalSpace β] {s : Set α} (H : IsConnected s) (f : α → β) (hf : ContinuousOn f s) : IsConnected (f '' s) := ⟨image_nonempty.mpr H.nonempty, H.isPreconnected.image f hf⟩ #align is_connected.image IsConnected.image theorem isPreconnected_closed_iff {s : Set α} : IsPreconnected s ↔ ∀ t t', IsClosed t → IsClosed t' → s ⊆ t ∪ t' → (s ∩ t).Nonempty → (s ∩ t').Nonempty → (s ∩ (t ∩ t')).Nonempty := ⟨by rintro h t t' ht ht' htt' ⟨x, xs, xt⟩ ⟨y, ys, yt'⟩ rw [← not_disjoint_iff_nonempty_inter, ← subset_compl_iff_disjoint_right, compl_inter] intro h' have xt' : x ∉ t' := (h' xs).resolve_left (absurd xt) have yt : y ∉ t := (h' ys).resolve_right (absurd yt') have := h _ _ ht.isOpen_compl ht'.isOpen_compl h' ⟨y, ys, yt⟩ ⟨x, xs, xt'⟩ rw [← compl_union] at this exact this.ne_empty htt'.disjoint_compl_right.inter_eq, by rintro h u v hu hv huv ⟨x, xs, xu⟩ ⟨y, ys, yv⟩ rw [← not_disjoint_iff_nonempty_inter, ← subset_compl_iff_disjoint_right, compl_inter] intro h' have xv : x ∉ v := (h' xs).elim (absurd xu) id have yu : y ∉ u := (h' ys).elim id (absurd yv) have := h _ _ hu.isClosed_compl hv.isClosed_compl h' ⟨y, ys, yu⟩ ⟨x, xs, xv⟩ rw [← compl_union] at this exact this.ne_empty huv.disjoint_compl_right.inter_eq⟩ #align is_preconnected_closed_iff isPreconnected_closed_iff theorem Inducing.isPreconnected_image [TopologicalSpace β] {s : Set α} {f : α → β} (hf : Inducing f) : IsPreconnected (f '' s) ↔ IsPreconnected s := by refine ⟨fun h => ?_, fun h => h.image _ hf.continuous.continuousOn⟩ rintro u v hu' hv' huv ⟨x, hxs, hxu⟩ ⟨y, hys, hyv⟩ rcases hf.isOpen_iff.1 hu' with ⟨u, hu, rfl⟩ rcases hf.isOpen_iff.1 hv' with ⟨v, hv, rfl⟩ replace huv : f '' s ⊆ u ∪ v := by rwa [image_subset_iff] rcases h u v hu hv huv ⟨f x, mem_image_of_mem _ hxs, hxu⟩ ⟨f y, mem_image_of_mem _ hys, hyv⟩ with ⟨_, ⟨z, hzs, rfl⟩, hzuv⟩ exact ⟨z, hzs, hzuv⟩ #align inducing.is_preconnected_image Inducing.isPreconnected_image theorem IsPreconnected.preimage_of_isOpenMap [TopologicalSpace β] {f : α → β} {s : Set β} (hs : IsPreconnected s) (hinj : Function.Injective f) (hf : IsOpenMap f) (hsf : s ⊆ range f) : IsPreconnected (f ⁻¹' s) := fun u v hu hv hsuv hsu hsv => by replace hsf : f '' (f ⁻¹' s) = s := image_preimage_eq_of_subset hsf obtain ⟨_, has, ⟨a, hau, rfl⟩, hav⟩ : (s ∩ (f '' u ∩ f '' v)).Nonempty := by refine hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_ · simpa only [hsf, image_union] using image_subset f hsuv · simpa only [image_preimage_inter] using hsu.image f · simpa only [image_preimage_inter] using hsv.image f · exact ⟨a, has, hau, hinj.mem_set_image.1 hav⟩ #align is_preconnected.preimage_of_open_map IsPreconnected.preimage_of_isOpenMap theorem IsPreconnected.preimage_of_isClosedMap [TopologicalSpace β] {s : Set β} (hs : IsPreconnected s) {f : α → β} (hinj : Function.Injective f) (hf : IsClosedMap f) (hsf : s ⊆ range f) : IsPreconnected (f ⁻¹' s) := isPreconnected_closed_iff.2 fun u v hu hv hsuv hsu hsv => by replace hsf : f '' (f ⁻¹' s) = s := image_preimage_eq_of_subset hsf obtain ⟨_, has, ⟨a, hau, rfl⟩, hav⟩ : (s ∩ (f '' u ∩ f '' v)).Nonempty := by refine isPreconnected_closed_iff.1 hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_ · simpa only [hsf, image_union] using image_subset f hsuv · simpa only [image_preimage_inter] using hsu.image f · simpa only [image_preimage_inter] using hsv.image f · exact ⟨a, has, hau, hinj.mem_set_image.1 hav⟩ #align is_preconnected.preimage_of_closed_map IsPreconnected.preimage_of_isClosedMap theorem IsConnected.preimage_of_isOpenMap [TopologicalSpace β] {s : Set β} (hs : IsConnected s) {f : α → β} (hinj : Function.Injective f) (hf : IsOpenMap f) (hsf : s ⊆ range f) : IsConnected (f ⁻¹' s) := ⟨hs.nonempty.preimage' hsf, hs.isPreconnected.preimage_of_isOpenMap hinj hf hsf⟩ #align is_connected.preimage_of_open_map IsConnected.preimage_of_isOpenMap theorem IsConnected.preimage_of_isClosedMap [TopologicalSpace β] {s : Set β} (hs : IsConnected s) {f : α → β} (hinj : Function.Injective f) (hf : IsClosedMap f) (hsf : s ⊆ range f) : IsConnected (f ⁻¹' s) := ⟨hs.nonempty.preimage' hsf, hs.isPreconnected.preimage_of_isClosedMap hinj hf hsf⟩ #align is_connected.preimage_of_closed_map IsConnected.preimage_of_isClosedMap theorem IsPreconnected.subset_or_subset (hu : IsOpen u) (hv : IsOpen v) (huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hs : IsPreconnected s) : s ⊆ u ∨ s ⊆ v := by specialize hs u v hu hv hsuv obtain hsu | hsu := (s ∩ u).eq_empty_or_nonempty · exact Or.inr ((Set.disjoint_iff_inter_eq_empty.2 hsu).subset_right_of_subset_union hsuv) · replace hs := mt (hs hsu) simp_rw [Set.not_nonempty_iff_eq_empty, ← Set.disjoint_iff_inter_eq_empty, disjoint_iff_inter_eq_empty.1 huv] at hs exact Or.inl ((hs s.disjoint_empty).subset_left_of_subset_union hsuv) #align is_preconnected.subset_or_subset IsPreconnected.subset_or_subset theorem IsPreconnected.subset_left_of_subset_union (hu : IsOpen u) (hv : IsOpen v) (huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hsu : (s ∩ u).Nonempty) (hs : IsPreconnected s) : s ⊆ u := Disjoint.subset_left_of_subset_union hsuv (by by_contra hsv rw [not_disjoint_iff_nonempty_inter] at hsv obtain ⟨x, _, hx⟩ := hs u v hu hv hsuv hsu hsv exact Set.disjoint_iff.1 huv hx) #align is_preconnected.subset_left_of_subset_union IsPreconnected.subset_left_of_subset_union theorem IsPreconnected.subset_right_of_subset_union (hu : IsOpen u) (hv : IsOpen v) (huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hsv : (s ∩ v).Nonempty) (hs : IsPreconnected s) : s ⊆ v := hs.subset_left_of_subset_union hv hu huv.symm (union_comm u v ▸ hsuv) hsv #align is_preconnected.subset_right_of_subset_union IsPreconnected.subset_right_of_subset_union -- Porting note: moved up theorem IsPreconnected.subset_isClopen {s t : Set α} (hs : IsPreconnected s) (ht : IsClopen t) (hne : (s ∩ t).Nonempty) : s ⊆ t := hs.subset_left_of_subset_union ht.isOpen ht.compl.isOpen disjoint_compl_right (by simp) hne #align is_preconnected.subset_clopen IsPreconnected.subset_isClopen theorem IsPreconnected.subset_of_closure_inter_subset (hs : IsPreconnected s) (hu : IsOpen u) (h'u : (s ∩ u).Nonempty) (h : closure u ∩ s ⊆ u) : s ⊆ u := by have A : s ⊆ u ∪ (closure u)ᶜ := by intro x hx by_cases xu : x ∈ u · exact Or.inl xu · right intro h'x exact xu (h (mem_inter h'x hx)) apply hs.subset_left_of_subset_union hu isClosed_closure.isOpen_compl _ A h'u exact disjoint_compl_right.mono_right (compl_subset_compl.2 subset_closure) #align is_preconnected.subset_of_closure_inter_subset IsPreconnected.subset_of_closure_inter_subset theorem IsPreconnected.prod [TopologicalSpace β] {s : Set α} {t : Set β} (hs : IsPreconnected s) (ht : IsPreconnected t) : IsPreconnected (s ×ˢ t) := by apply isPreconnected_of_forall_pair rintro ⟨a₁, b₁⟩ ⟨ha₁, hb₁⟩ ⟨a₂, b₂⟩ ⟨ha₂, hb₂⟩ refine ⟨Prod.mk a₁ '' t ∪ flip Prod.mk b₂ '' s, ?_, .inl ⟨b₁, hb₁, rfl⟩, .inr ⟨a₂, ha₂, rfl⟩, ?_⟩ · rintro _ (⟨y, hy, rfl⟩ | ⟨x, hx, rfl⟩) exacts [⟨ha₁, hy⟩, ⟨hx, hb₂⟩] · exact (ht.image _ (Continuous.Prod.mk _).continuousOn).union (a₁, b₂) ⟨b₂, hb₂, rfl⟩ ⟨a₁, ha₁, rfl⟩ (hs.image _ (continuous_id.prod_mk continuous_const).continuousOn) #align is_preconnected.prod IsPreconnected.prod theorem IsConnected.prod [TopologicalSpace β] {s : Set α} {t : Set β} (hs : IsConnected s) (ht : IsConnected t) : IsConnected (s ×ˢ t) := ⟨hs.1.prod ht.1, hs.2.prod ht.2⟩ #align is_connected.prod IsConnected.prod theorem isPreconnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)} (hs : ∀ i, IsPreconnected (s i)) : IsPreconnected (pi univ s) := by rintro u v uo vo hsuv ⟨f, hfs, hfu⟩ ⟨g, hgs, hgv⟩ rcases exists_finset_piecewise_mem_of_mem_nhds (uo.mem_nhds hfu) g with ⟨I, hI⟩ induction' I using Finset.induction_on with i I _ ihI · refine ⟨g, hgs, ⟨?_, hgv⟩⟩ simpa using hI · rw [Finset.piecewise_insert] at hI have := I.piecewise_mem_set_pi hfs hgs refine (hsuv this).elim ihI fun h => ?_ set S := update (I.piecewise f g) i '' s i have hsub : S ⊆ pi univ s := by refine image_subset_iff.2 fun z hz => ?_ rwa [update_preimage_univ_pi] exact fun j _ => this j trivial have hconn : IsPreconnected S := (hs i).image _ (continuous_const.update i continuous_id).continuousOn have hSu : (S ∩ u).Nonempty := ⟨_, mem_image_of_mem _ (hfs _ trivial), hI⟩ have hSv : (S ∩ v).Nonempty := ⟨_, ⟨_, this _ trivial, update_eq_self _ _⟩, h⟩ refine (hconn u v uo vo (hsub.trans hsuv) hSu hSv).mono ?_ exact inter_subset_inter_left _ hsub #align is_preconnected_univ_pi isPreconnected_univ_pi @[simp] theorem isConnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)} : IsConnected (pi univ s) ↔ ∀ i, IsConnected (s i) := by simp only [IsConnected, ← univ_pi_nonempty_iff, forall_and, and_congr_right_iff] refine fun hne => ⟨fun hc i => ?_, isPreconnected_univ_pi⟩ rw [← eval_image_univ_pi hne] exact hc.image _ (continuous_apply _).continuousOn #align is_connected_univ_pi isConnected_univ_pi theorem Sigma.isConnected_iff [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} : IsConnected s ↔ ∃ i t, IsConnected t ∧ s = Sigma.mk i '' t := by refine ⟨fun hs => ?_, ?_⟩ · obtain ⟨⟨i, x⟩, hx⟩ := hs.nonempty have : s ⊆ range (Sigma.mk i) := hs.isPreconnected.subset_isClopen isClopen_range_sigmaMk ⟨⟨i, x⟩, hx, x, rfl⟩ exact ⟨i, Sigma.mk i ⁻¹' s, hs.preimage_of_isOpenMap sigma_mk_injective isOpenMap_sigmaMk this, (Set.image_preimage_eq_of_subset this).symm⟩ · rintro ⟨i, t, ht, rfl⟩ exact ht.image _ continuous_sigmaMk.continuousOn #align sigma.is_connected_iff Sigma.isConnected_iff
Mathlib/Topology/Connected/Basic.lean
523
531
theorem Sigma.isPreconnected_iff [hι : Nonempty ι] [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} : IsPreconnected s ↔ ∃ i t, IsPreconnected t ∧ s = Sigma.mk i '' t := by
refine ⟨fun hs => ?_, ?_⟩ · obtain rfl | h := s.eq_empty_or_nonempty · exact ⟨Classical.choice hι, ∅, isPreconnected_empty, (Set.image_empty _).symm⟩ · obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩ exact ⟨a, t, ht.isPreconnected, rfl⟩ · rintro ⟨a, t, ht, rfl⟩ exact ht.image _ continuous_sigmaMk.continuousOn
import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation import Mathlib.LinearAlgebra.CliffordAlgebra.Even import Mathlib.LinearAlgebra.QuadraticForm.Prod import Mathlib.Tactic.LiftLets #align_import linear_algebra.clifford_algebra.even_equiv from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" namespace CliffordAlgebra variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] variable (Q : QuadraticForm R M) namespace EquivEven abbrev Q' : QuadraticForm R (M × R) := Q.prod <| -@QuadraticForm.sq R _ set_option linter.uppercaseLean3 false in #align clifford_algebra.equiv_even.Q' CliffordAlgebra.EquivEven.Q' theorem Q'_apply (m : M × R) : Q' Q m = Q m.1 - m.2 * m.2 := (sub_eq_add_neg _ _).symm set_option linter.uppercaseLean3 false in #align clifford_algebra.equiv_even.Q'_apply CliffordAlgebra.EquivEven.Q'_apply def e0 : CliffordAlgebra (Q' Q) := ι (Q' Q) (0, 1) #align clifford_algebra.equiv_even.e0 CliffordAlgebra.EquivEven.e0 def v : M →ₗ[R] CliffordAlgebra (Q' Q) := ι (Q' Q) ∘ₗ LinearMap.inl _ _ _ #align clifford_algebra.equiv_even.v CliffordAlgebra.EquivEven.v theorem ι_eq_v_add_smul_e0 (m : M) (r : R) : ι (Q' Q) (m, r) = v Q m + r • e0 Q := by rw [e0, v, LinearMap.comp_apply, LinearMap.inl_apply, ← LinearMap.map_smul, Prod.smul_mk, smul_zero, smul_eq_mul, mul_one, ← LinearMap.map_add, Prod.mk_add_mk, zero_add, add_zero] #align clifford_algebra.equiv_even.ι_eq_v_add_smul_e0 CliffordAlgebra.EquivEven.ι_eq_v_add_smul_e0 theorem e0_mul_e0 : e0 Q * e0 Q = -1 := (ι_sq_scalar _ _).trans <| by simp #align clifford_algebra.equiv_even.e0_mul_e0 CliffordAlgebra.EquivEven.e0_mul_e0 theorem v_sq_scalar (m : M) : v Q m * v Q m = algebraMap _ _ (Q m) := (ι_sq_scalar _ _).trans <| by simp #align clifford_algebra.equiv_even.v_sq_scalar CliffordAlgebra.EquivEven.v_sq_scalar theorem neg_e0_mul_v (m : M) : -(e0 Q * v Q m) = v Q m * e0 Q := by refine neg_eq_of_add_eq_zero_right ((ι_mul_ι_add_swap _ _).trans ?_) dsimp [QuadraticForm.polar] simp only [add_zero, mul_zero, mul_one, zero_add, neg_zero, QuadraticForm.map_zero, add_sub_cancel_right, sub_self, map_zero, zero_sub] #align clifford_algebra.equiv_even.neg_e0_mul_v CliffordAlgebra.EquivEven.neg_e0_mul_v theorem neg_v_mul_e0 (m : M) : -(v Q m * e0 Q) = e0 Q * v Q m := by rw [neg_eq_iff_eq_neg] exact (neg_e0_mul_v _ m).symm #align clifford_algebra.equiv_even.neg_v_mul_e0 CliffordAlgebra.EquivEven.neg_v_mul_e0 @[simp]
Mathlib/LinearAlgebra/CliffordAlgebra/EvenEquiv.lean
95
96
theorem e0_mul_v_mul_e0 (m : M) : e0 Q * v Q m * e0 Q = v Q m := by
rw [← neg_v_mul_e0, ← neg_mul, mul_assoc, e0_mul_e0, mul_neg_one, neg_neg]
import Mathlib.Data.Int.ModEq import Mathlib.GroupTheory.QuotientGroup #align_import algebra.modeq from "leanprover-community/mathlib"@"a07d750983b94c530ab69a726862c2ab6802b38c" namespace AddCommGroup variable {α : Type*} section AddCommGroup variable [AddCommGroup α] {p a a₁ a₂ b b₁ b₂ c : α} {n : ℕ} {z : ℤ} def ModEq (p a b : α) : Prop := ∃ z : ℤ, b - a = z • p #align add_comm_group.modeq AddCommGroup.ModEq @[inherit_doc] notation:50 a " ≡ " b " [PMOD " p "]" => ModEq p a b @[refl, simp] theorem modEq_refl (a : α) : a ≡ a [PMOD p] := ⟨0, by simp⟩ #align add_comm_group.modeq_refl AddCommGroup.modEq_refl theorem modEq_rfl : a ≡ a [PMOD p] := modEq_refl _ #align add_comm_group.modeq_rfl AddCommGroup.modEq_rfl theorem modEq_comm : a ≡ b [PMOD p] ↔ b ≡ a [PMOD p] := (Equiv.neg _).exists_congr_left.trans <| by simp [ModEq, ← neg_eq_iff_eq_neg] #align add_comm_group.modeq_comm AddCommGroup.modEq_comm alias ⟨ModEq.symm, _⟩ := modEq_comm #align add_comm_group.modeq.symm AddCommGroup.ModEq.symm attribute [symm] ModEq.symm @[trans] theorem ModEq.trans : a ≡ b [PMOD p] → b ≡ c [PMOD p] → a ≡ c [PMOD p] := fun ⟨m, hm⟩ ⟨n, hn⟩ => ⟨m + n, by simp [add_smul, ← hm, ← hn]⟩ #align add_comm_group.modeq.trans AddCommGroup.ModEq.trans instance : IsRefl _ (ModEq p) := ⟨modEq_refl⟩ @[simp] theorem neg_modEq_neg : -a ≡ -b [PMOD p] ↔ a ≡ b [PMOD p] := modEq_comm.trans <| by simp [ModEq, neg_add_eq_sub] #align add_comm_group.neg_modeq_neg AddCommGroup.neg_modEq_neg alias ⟨ModEq.of_neg, ModEq.neg⟩ := neg_modEq_neg #align add_comm_group.modeq.of_neg AddCommGroup.ModEq.of_neg #align add_comm_group.modeq.neg AddCommGroup.ModEq.neg @[simp] theorem modEq_neg : a ≡ b [PMOD -p] ↔ a ≡ b [PMOD p] := modEq_comm.trans <| by simp [ModEq, ← neg_eq_iff_eq_neg] #align add_comm_group.modeq_neg AddCommGroup.modEq_neg alias ⟨ModEq.of_neg', ModEq.neg'⟩ := modEq_neg #align add_comm_group.modeq.of_neg' AddCommGroup.ModEq.of_neg' #align add_comm_group.modeq.neg' AddCommGroup.ModEq.neg' theorem modEq_sub (a b : α) : a ≡ b [PMOD b - a] := ⟨1, (one_smul _ _).symm⟩ #align add_comm_group.modeq_sub AddCommGroup.modEq_sub @[simp] theorem modEq_zero : a ≡ b [PMOD 0] ↔ a = b := by simp [ModEq, sub_eq_zero, eq_comm] #align add_comm_group.modeq_zero AddCommGroup.modEq_zero @[simp] theorem self_modEq_zero : p ≡ 0 [PMOD p] := ⟨-1, by simp⟩ #align add_comm_group.self_modeq_zero AddCommGroup.self_modEq_zero @[simp] theorem zsmul_modEq_zero (z : ℤ) : z • p ≡ 0 [PMOD p] := ⟨-z, by simp⟩ #align add_comm_group.zsmul_modeq_zero AddCommGroup.zsmul_modEq_zero theorem add_zsmul_modEq (z : ℤ) : a + z • p ≡ a [PMOD p] := ⟨-z, by simp⟩ #align add_comm_group.add_zsmul_modeq AddCommGroup.add_zsmul_modEq theorem zsmul_add_modEq (z : ℤ) : z • p + a ≡ a [PMOD p] := ⟨-z, by simp [← sub_sub]⟩ #align add_comm_group.zsmul_add_modeq AddCommGroup.zsmul_add_modEq theorem add_nsmul_modEq (n : ℕ) : a + n • p ≡ a [PMOD p] := ⟨-n, by simp⟩ #align add_comm_group.add_nsmul_modeq AddCommGroup.add_nsmul_modEq theorem nsmul_add_modEq (n : ℕ) : n • p + a ≡ a [PMOD p] := ⟨-n, by simp [← sub_sub]⟩ #align add_comm_group.nsmul_add_modeq AddCommGroup.nsmul_add_modEq
Mathlib/Algebra/ModEq.lean
262
263
theorem modEq_sub_iff_add_modEq' : a ≡ b - c [PMOD p] ↔ c + a ≡ b [PMOD p] := by
simp [ModEq, sub_sub]
import Mathlib.Order.Interval.Set.Disjoint import Mathlib.MeasureTheory.Integral.SetIntegral import Mathlib.MeasureTheory.Measure.Lebesgue.Basic #align_import measure_theory.integral.interval_integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" noncomputable section open scoped Classical open MeasureTheory Set Filter Function open scoped Classical Topology Filter ENNReal Interval NNReal variable {ι 𝕜 E F A : Type*} [NormedAddCommGroup E] def IntervalIntegrable (f : ℝ → E) (μ : Measure ℝ) (a b : ℝ) : Prop := IntegrableOn f (Ioc a b) μ ∧ IntegrableOn f (Ioc b a) μ #align interval_integrable IntervalIntegrable section variable {f : ℝ → E} {a b : ℝ} {μ : Measure ℝ} theorem intervalIntegrable_iff : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ι a b) μ := by rw [uIoc_eq_union, integrableOn_union, IntervalIntegrable] #align interval_integrable_iff intervalIntegrable_iff theorem IntervalIntegrable.def' (h : IntervalIntegrable f μ a b) : IntegrableOn f (Ι a b) μ := intervalIntegrable_iff.mp h #align interval_integrable.def IntervalIntegrable.def' theorem intervalIntegrable_iff_integrableOn_Ioc_of_le (hab : a ≤ b) : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ioc a b) μ := by rw [intervalIntegrable_iff, uIoc_of_le hab] #align interval_integrable_iff_integrable_Ioc_of_le intervalIntegrable_iff_integrableOn_Ioc_of_le theorem intervalIntegrable_iff' [NoAtoms μ] : IntervalIntegrable f μ a b ↔ IntegrableOn f (uIcc a b) μ := by rw [intervalIntegrable_iff, ← Icc_min_max, uIoc, integrableOn_Icc_iff_integrableOn_Ioc] #align interval_integrable_iff' intervalIntegrable_iff' theorem intervalIntegrable_iff_integrableOn_Icc_of_le {f : ℝ → E} {a b : ℝ} (hab : a ≤ b) {μ : Measure ℝ} [NoAtoms μ] : IntervalIntegrable f μ a b ↔ IntegrableOn f (Icc a b) μ := by rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hab, integrableOn_Icc_iff_integrableOn_Ioc] #align interval_integrable_iff_integrable_Icc_of_le intervalIntegrable_iff_integrableOn_Icc_of_le theorem intervalIntegrable_iff_integrableOn_Ico_of_le [NoAtoms μ] (hab : a ≤ b) : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ico a b) μ := by rw [intervalIntegrable_iff_integrableOn_Icc_of_le hab, integrableOn_Icc_iff_integrableOn_Ico] theorem intervalIntegrable_iff_integrableOn_Ioo_of_le [NoAtoms μ] (hab : a ≤ b) : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ioo a b) μ := by rw [intervalIntegrable_iff_integrableOn_Icc_of_le hab, integrableOn_Icc_iff_integrableOn_Ioo] theorem MeasureTheory.Integrable.intervalIntegrable (hf : Integrable f μ) : IntervalIntegrable f μ a b := ⟨hf.integrableOn, hf.integrableOn⟩ #align measure_theory.integrable.interval_integrable MeasureTheory.Integrable.intervalIntegrable theorem MeasureTheory.IntegrableOn.intervalIntegrable (hf : IntegrableOn f [[a, b]] μ) : IntervalIntegrable f μ a b := ⟨MeasureTheory.IntegrableOn.mono_set hf (Ioc_subset_Icc_self.trans Icc_subset_uIcc), MeasureTheory.IntegrableOn.mono_set hf (Ioc_subset_Icc_self.trans Icc_subset_uIcc')⟩ #align measure_theory.integrable_on.interval_integrable MeasureTheory.IntegrableOn.intervalIntegrable theorem intervalIntegrable_const_iff {c : E} : IntervalIntegrable (fun _ => c) μ a b ↔ c = 0 ∨ μ (Ι a b) < ∞ := by simp only [intervalIntegrable_iff, integrableOn_const] #align interval_integrable_const_iff intervalIntegrable_const_iff @[simp] theorem intervalIntegrable_const [IsLocallyFiniteMeasure μ] {c : E} : IntervalIntegrable (fun _ => c) μ a b := intervalIntegrable_const_iff.2 <| Or.inr measure_Ioc_lt_top #align interval_integrable_const intervalIntegrable_const end section variable {μ : Measure ℝ} [IsLocallyFiniteMeasure μ] theorem ContinuousOn.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : ContinuousOn u (uIcc a b)) : IntervalIntegrable u μ a b := (ContinuousOn.integrableOn_Icc hu).intervalIntegrable #align continuous_on.interval_integrable ContinuousOn.intervalIntegrable theorem ContinuousOn.intervalIntegrable_of_Icc {u : ℝ → E} {a b : ℝ} (h : a ≤ b) (hu : ContinuousOn u (Icc a b)) : IntervalIntegrable u μ a b := ContinuousOn.intervalIntegrable ((uIcc_of_le h).symm ▸ hu) #align continuous_on.interval_integrable_of_Icc ContinuousOn.intervalIntegrable_of_Icc theorem Continuous.intervalIntegrable {u : ℝ → E} (hu : Continuous u) (a b : ℝ) : IntervalIntegrable u μ a b := hu.continuousOn.intervalIntegrable #align continuous.interval_integrable Continuous.intervalIntegrable end section variable {μ : Measure ℝ} [IsLocallyFiniteMeasure μ] [ConditionallyCompleteLinearOrder E] [OrderTopology E] [SecondCountableTopology E] theorem MonotoneOn.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : MonotoneOn u (uIcc a b)) : IntervalIntegrable u μ a b := by rw [intervalIntegrable_iff] exact (hu.integrableOn_isCompact isCompact_uIcc).mono_set Ioc_subset_Icc_self #align monotone_on.interval_integrable MonotoneOn.intervalIntegrable theorem AntitoneOn.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : AntitoneOn u (uIcc a b)) : IntervalIntegrable u μ a b := hu.dual_right.intervalIntegrable #align antitone_on.interval_integrable AntitoneOn.intervalIntegrable theorem Monotone.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : Monotone u) : IntervalIntegrable u μ a b := (hu.monotoneOn _).intervalIntegrable #align monotone.interval_integrable Monotone.intervalIntegrable theorem Antitone.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : Antitone u) : IntervalIntegrable u μ a b := (hu.antitoneOn _).intervalIntegrable #align antitone.interval_integrable Antitone.intervalIntegrable end theorem Filter.Tendsto.eventually_intervalIntegrable_ae {f : ℝ → E} {μ : Measure ℝ} {l l' : Filter ℝ} (hfm : StronglyMeasurableAtFilter f l' μ) [TendstoIxxClass Ioc l l'] [IsMeasurablyGenerated l'] (hμ : μ.FiniteAtFilter l') {c : E} (hf : Tendsto f (l' ⊓ ae μ) (𝓝 c)) {u v : ι → ℝ} {lt : Filter ι} (hu : Tendsto u lt l) (hv : Tendsto v lt l) : ∀ᶠ t in lt, IntervalIntegrable f μ (u t) (v t) := have := (hf.integrableAtFilter_ae hfm hμ).eventually ((hu.Ioc hv).eventually this).and <| (hv.Ioc hu).eventually this #align filter.tendsto.eventually_interval_integrable_ae Filter.Tendsto.eventually_intervalIntegrable_ae theorem Filter.Tendsto.eventually_intervalIntegrable {f : ℝ → E} {μ : Measure ℝ} {l l' : Filter ℝ} (hfm : StronglyMeasurableAtFilter f l' μ) [TendstoIxxClass Ioc l l'] [IsMeasurablyGenerated l'] (hμ : μ.FiniteAtFilter l') {c : E} (hf : Tendsto f l' (𝓝 c)) {u v : ι → ℝ} {lt : Filter ι} (hu : Tendsto u lt l) (hv : Tendsto v lt l) : ∀ᶠ t in lt, IntervalIntegrable f μ (u t) (v t) := (hf.mono_left inf_le_left).eventually_intervalIntegrable_ae hfm hμ hu hv #align filter.tendsto.eventually_interval_integrable Filter.Tendsto.eventually_intervalIntegrable variable [CompleteSpace E] [NormedSpace ℝ E] def intervalIntegral (f : ℝ → E) (a b : ℝ) (μ : Measure ℝ) : E := (∫ x in Ioc a b, f x ∂μ) - ∫ x in Ioc b a, f x ∂μ #align interval_integral intervalIntegral notation3"∫ "(...)" in "a".."b", "r:60:(scoped f => f)" ∂"μ:70 => intervalIntegral r a b μ notation3"∫ "(...)" in "a".."b", "r:60:(scoped f => intervalIntegral f a b volume) => r namespace intervalIntegral section Basic variable {a b : ℝ} {f g : ℝ → E} {μ : Measure ℝ} @[simp] theorem integral_zero : (∫ _ in a..b, (0 : E) ∂μ) = 0 := by simp [intervalIntegral] #align interval_integral.integral_zero intervalIntegral.integral_zero theorem integral_of_le (h : a ≤ b) : ∫ x in a..b, f x ∂μ = ∫ x in Ioc a b, f x ∂μ := by simp [intervalIntegral, h] #align interval_integral.integral_of_le intervalIntegral.integral_of_le @[simp] theorem integral_same : ∫ x in a..a, f x ∂μ = 0 := sub_self _ #align interval_integral.integral_same intervalIntegral.integral_same
Mathlib/MeasureTheory/Integral/IntervalIntegral.lean
497
498
theorem integral_symm (a b) : ∫ x in b..a, f x ∂μ = -∫ x in a..b, f x ∂μ := by
simp only [intervalIntegral, neg_sub]
import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.LinearAlgebra.AffineSpace.Slope #align_import analysis.calculus.deriv.slope from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" universe u v w noncomputable section open Topology Filter TopologicalSpace open Filter Set section NormedField variable {𝕜 : Type u} [NontriviallyNormedField 𝕜] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {f f₀ f₁ g : 𝕜 → F} variable {f' f₀' f₁' g' : F} variable {x : 𝕜} variable {s t : Set 𝕜} variable {L L₁ L₂ : Filter 𝕜} theorem hasDerivAtFilter_iff_tendsto_slope {x : 𝕜} {L : Filter 𝕜} : HasDerivAtFilter f f' x L ↔ Tendsto (slope f x) (L ⊓ 𝓟 {x}ᶜ) (𝓝 f') := calc HasDerivAtFilter f f' x L ↔ Tendsto (fun y ↦ slope f x y - (y - x)⁻¹ • (y - x) • f') L (𝓝 0) := by simp only [hasDerivAtFilter_iff_tendsto, ← norm_inv, ← norm_smul, ← tendsto_zero_iff_norm_tendsto_zero, slope_def_module, smul_sub] _ ↔ Tendsto (fun y ↦ slope f x y - (y - x)⁻¹ • (y - x) • f') (L ⊓ 𝓟 {x}ᶜ) (𝓝 0) := .symm <| tendsto_inf_principal_nhds_iff_of_forall_eq <| by simp _ ↔ Tendsto (fun y ↦ slope f x y - f') (L ⊓ 𝓟 {x}ᶜ) (𝓝 0) := tendsto_congr' <| by refine (EqOn.eventuallyEq fun y hy ↦ ?_).filter_mono inf_le_right rw [inv_smul_smul₀ (sub_ne_zero.2 hy) f'] _ ↔ Tendsto (slope f x) (L ⊓ 𝓟 {x}ᶜ) (𝓝 f') := by rw [← nhds_translation_sub f', tendsto_comap_iff]; rfl #align has_deriv_at_filter_iff_tendsto_slope hasDerivAtFilter_iff_tendsto_slope theorem hasDerivWithinAt_iff_tendsto_slope : HasDerivWithinAt f f' s x ↔ Tendsto (slope f x) (𝓝[s \ {x}] x) (𝓝 f') := by simp only [HasDerivWithinAt, nhdsWithin, diff_eq, ← inf_assoc, inf_principal.symm] exact hasDerivAtFilter_iff_tendsto_slope #align has_deriv_within_at_iff_tendsto_slope hasDerivWithinAt_iff_tendsto_slope
Mathlib/Analysis/Calculus/Deriv/Slope.lean
72
74
theorem hasDerivWithinAt_iff_tendsto_slope' (hs : x ∉ s) : HasDerivWithinAt f f' s x ↔ Tendsto (slope f x) (𝓝[s] x) (𝓝 f') := by
rw [hasDerivWithinAt_iff_tendsto_slope, diff_singleton_eq_self hs]
import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Topology.Algebra.InfiniteSum.Order import Mathlib.Topology.Instances.Real import Mathlib.Topology.Instances.ENNReal #align_import topology.algebra.infinite_sum.real from "leanprover-community/mathlib"@"9a59dcb7a2d06bf55da57b9030169219980660cd" open Filter Finset NNReal Topology variable {α β : Type*} [PseudoMetricSpace α] {f : ℕ → α} {a : α} theorem cauchySeq_of_dist_le_of_summable (d : ℕ → ℝ) (hf : ∀ n, dist (f n) (f n.succ) ≤ d n) (hd : Summable d) : CauchySeq f := by lift d to ℕ → ℝ≥0 using fun n ↦ dist_nonneg.trans (hf n) apply cauchySeq_of_edist_le_of_summable d (α := α) (f := f) · exact_mod_cast hf · exact_mod_cast hd #align cauchy_seq_of_dist_le_of_summable cauchySeq_of_dist_le_of_summable theorem cauchySeq_of_summable_dist (h : Summable fun n ↦ dist (f n) (f n.succ)) : CauchySeq f := cauchySeq_of_dist_le_of_summable _ (fun _ ↦ le_rfl) h #align cauchy_seq_of_summable_dist cauchySeq_of_summable_dist
Mathlib/Topology/Algebra/InfiniteSum/Real.lean
39
46
theorem dist_le_tsum_of_dist_le_of_tendsto (d : ℕ → ℝ) (hf : ∀ n, dist (f n) (f n.succ) ≤ d n) (hd : Summable d) {a : α} (ha : Tendsto f atTop (𝓝 a)) (n : ℕ) : dist (f n) a ≤ ∑' m, d (n + m) := by
refine le_of_tendsto (tendsto_const_nhds.dist ha) (eventually_atTop.2 ⟨n, fun m hnm ↦ ?_⟩) refine le_trans (dist_le_Ico_sum_of_dist_le hnm fun _ _ ↦ hf _) ?_ rw [sum_Ico_eq_sum_range] refine sum_le_tsum (range _) (fun _ _ ↦ le_trans dist_nonneg (hf _)) ?_ exact hd.comp_injective (add_right_injective n)
import Mathlib.SetTheory.Cardinal.Ordinal #align_import set_theory.cardinal.continuum from "leanprover-community/mathlib"@"e08a42b2dd544cf11eba72e5fc7bf199d4349925" namespace Cardinal universe u v open Cardinal def continuum : Cardinal.{u} := 2 ^ ℵ₀ #align cardinal.continuum Cardinal.continuum scoped notation "𝔠" => Cardinal.continuum @[simp] theorem two_power_aleph0 : 2 ^ aleph0.{u} = continuum.{u} := rfl #align cardinal.two_power_aleph_0 Cardinal.two_power_aleph0 @[simp]
Mathlib/SetTheory/Cardinal/Continuum.lean
41
42
theorem lift_continuum : lift.{v} 𝔠 = 𝔠 := by
rw [← two_power_aleph0, lift_two_power, lift_aleph0, two_power_aleph0]
import Mathlib.Topology.Algebra.InfiniteSum.Order import Mathlib.Topology.Algebra.InfiniteSum.Ring import Mathlib.Topology.Instances.Real import Mathlib.Topology.MetricSpace.Isometry #align_import topology.instances.nnreal from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514" noncomputable section open Set TopologicalSpace Metric Filter open Topology namespace NNReal open NNReal Filter instance : TopologicalSpace ℝ≥0 := inferInstance -- short-circuit type class inference instance : TopologicalSemiring ℝ≥0 where toContinuousAdd := continuousAdd_induced toRealHom toContinuousMul := continuousMul_induced toRealHom instance : SecondCountableTopology ℝ≥0 := inferInstanceAs (SecondCountableTopology { x : ℝ | 0 ≤ x }) instance : OrderTopology ℝ≥0 := orderTopology_of_ordConnected (t := Ici 0) instance : CompleteSpace ℝ≥0 := isClosed_Ici.completeSpace_coe instance : ContinuousStar ℝ≥0 where continuous_star := continuous_id section coe variable {α : Type*} open Filter Finset theorem _root_.continuous_real_toNNReal : Continuous Real.toNNReal := (continuous_id.max continuous_const).subtype_mk _ #align continuous_real_to_nnreal continuous_real_toNNReal @[simps (config := .asFn)] noncomputable def _root_.ContinuousMap.realToNNReal : C(ℝ, ℝ≥0) := .mk Real.toNNReal continuous_real_toNNReal theorem continuous_coe : Continuous ((↑) : ℝ≥0 → ℝ) := continuous_subtype_val #align nnreal.continuous_coe NNReal.continuous_coe @[simps (config := .asFn)] def _root_.ContinuousMap.coeNNRealReal : C(ℝ≥0, ℝ) := ⟨(↑), continuous_coe⟩ #align continuous_map.coe_nnreal_real ContinuousMap.coeNNRealReal #align continuous_map.coe_nnreal_real_apply ContinuousMap.coeNNRealReal_apply instance ContinuousMap.canLift {X : Type*} [TopologicalSpace X] : CanLift C(X, ℝ) C(X, ℝ≥0) ContinuousMap.coeNNRealReal.comp fun f => ∀ x, 0 ≤ f x where prf f hf := ⟨⟨fun x => ⟨f x, hf x⟩, f.2.subtype_mk _⟩, DFunLike.ext' rfl⟩ #align nnreal.continuous_map.can_lift NNReal.ContinuousMap.canLift @[simp, norm_cast] theorem tendsto_coe {f : Filter α} {m : α → ℝ≥0} {x : ℝ≥0} : Tendsto (fun a => (m a : ℝ)) f (𝓝 (x : ℝ)) ↔ Tendsto m f (𝓝 x) := tendsto_subtype_rng.symm #align nnreal.tendsto_coe NNReal.tendsto_coe theorem tendsto_coe' {f : Filter α} [NeBot f] {m : α → ℝ≥0} {x : ℝ} : Tendsto (fun a => m a : α → ℝ) f (𝓝 x) ↔ ∃ hx : 0 ≤ x, Tendsto m f (𝓝 ⟨x, hx⟩) := ⟨fun h => ⟨ge_of_tendsto' h fun c => (m c).2, tendsto_coe.1 h⟩, fun ⟨_, hm⟩ => tendsto_coe.2 hm⟩ #align nnreal.tendsto_coe' NNReal.tendsto_coe' @[simp] theorem map_coe_atTop : map toReal atTop = atTop := map_val_Ici_atTop 0 #align nnreal.map_coe_at_top NNReal.map_coe_atTop theorem comap_coe_atTop : comap toReal atTop = atTop := (atTop_Ici_eq 0).symm #align nnreal.comap_coe_at_top NNReal.comap_coe_atTop @[simp, norm_cast] theorem tendsto_coe_atTop {f : Filter α} {m : α → ℝ≥0} : Tendsto (fun a => (m a : ℝ)) f atTop ↔ Tendsto m f atTop := tendsto_Ici_atTop.symm #align nnreal.tendsto_coe_at_top NNReal.tendsto_coe_atTop theorem _root_.tendsto_real_toNNReal {f : Filter α} {m : α → ℝ} {x : ℝ} (h : Tendsto m f (𝓝 x)) : Tendsto (fun a => Real.toNNReal (m a)) f (𝓝 (Real.toNNReal x)) := (continuous_real_toNNReal.tendsto _).comp h #align tendsto_real_to_nnreal tendsto_real_toNNReal
Mathlib/Topology/Instances/NNReal.lean
140
142
theorem _root_.tendsto_real_toNNReal_atTop : Tendsto Real.toNNReal atTop atTop := by
rw [← tendsto_coe_atTop] exact tendsto_atTop_mono Real.le_coe_toNNReal tendsto_id
import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.Order.Sub.WithTop import Mathlib.Data.Real.NNReal import Mathlib.Order.Interval.Set.WithBotTop #align_import data.real.ennreal from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" open Function Set NNReal variable {α : Type*} def ENNReal := WithTop ℝ≥0 deriving Zero, AddCommMonoidWithOne, SemilatticeSup, DistribLattice, Nontrivial #align ennreal ENNReal @[inherit_doc] scoped[ENNReal] notation "ℝ≥0∞" => ENNReal scoped[ENNReal] notation "∞" => (⊤ : ENNReal) namespace ENNReal instance : OrderBot ℝ≥0∞ := inferInstanceAs (OrderBot (WithTop ℝ≥0)) instance : BoundedOrder ℝ≥0∞ := inferInstanceAs (BoundedOrder (WithTop ℝ≥0)) instance : CharZero ℝ≥0∞ := inferInstanceAs (CharZero (WithTop ℝ≥0)) noncomputable instance : CanonicallyOrderedCommSemiring ℝ≥0∞ := inferInstanceAs (CanonicallyOrderedCommSemiring (WithTop ℝ≥0)) noncomputable instance : CompleteLinearOrder ℝ≥0∞ := inferInstanceAs (CompleteLinearOrder (WithTop ℝ≥0)) instance : DenselyOrdered ℝ≥0∞ := inferInstanceAs (DenselyOrdered (WithTop ℝ≥0)) noncomputable instance : CanonicallyLinearOrderedAddCommMonoid ℝ≥0∞ := inferInstanceAs (CanonicallyLinearOrderedAddCommMonoid (WithTop ℝ≥0)) noncomputable instance instSub : Sub ℝ≥0∞ := inferInstanceAs (Sub (WithTop ℝ≥0)) noncomputable instance : OrderedSub ℝ≥0∞ := inferInstanceAs (OrderedSub (WithTop ℝ≥0)) noncomputable instance : LinearOrderedAddCommMonoidWithTop ℝ≥0∞ := inferInstanceAs (LinearOrderedAddCommMonoidWithTop (WithTop ℝ≥0)) -- Porting note: rfc: redefine using pattern matching? noncomputable instance : Inv ℝ≥0∞ := ⟨fun a => sInf { b | 1 ≤ a * b }⟩ noncomputable instance : DivInvMonoid ℝ≥0∞ where variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0} -- Porting note: are these 2 instances still required in Lean 4? instance covariantClass_mul_le : CovariantClass ℝ≥0∞ ℝ≥0∞ (· * ·) (· ≤ ·) := inferInstance #align ennreal.covariant_class_mul_le ENNReal.covariantClass_mul_le instance covariantClass_add_le : CovariantClass ℝ≥0∞ ℝ≥0∞ (· + ·) (· ≤ ·) := inferInstance #align ennreal.covariant_class_add_le ENNReal.covariantClass_add_le -- Porting note (#11215): TODO: add a `WithTop` instance and use it here noncomputable instance : LinearOrderedCommMonoidWithZero ℝ≥0∞ := { inferInstanceAs (LinearOrderedAddCommMonoidWithTop ℝ≥0∞), inferInstanceAs (CommSemiring ℝ≥0∞) with mul_le_mul_left := fun _ _ => mul_le_mul_left' zero_le_one := zero_le 1 } noncomputable instance : Unique (AddUnits ℝ≥0∞) where default := 0 uniq a := AddUnits.ext <| le_zero_iff.1 <| by rw [← a.add_neg]; exact le_self_add instance : Inhabited ℝ≥0∞ := ⟨0⟩ @[coe, match_pattern] def ofNNReal : ℝ≥0 → ℝ≥0∞ := WithTop.some instance : Coe ℝ≥0 ℝ≥0∞ := ⟨ofNNReal⟩ @[elab_as_elim, induction_eliminator, cases_eliminator] def recTopCoe {C : ℝ≥0∞ → Sort*} (top : C ∞) (coe : ∀ x : ℝ≥0, C x) (x : ℝ≥0∞) : C x := WithTop.recTopCoe top coe x instance canLift : CanLift ℝ≥0∞ ℝ≥0 ofNNReal (· ≠ ∞) := WithTop.canLift #align ennreal.can_lift ENNReal.canLift @[simp] theorem none_eq_top : (none : ℝ≥0∞) = ∞ := rfl #align ennreal.none_eq_top ENNReal.none_eq_top @[simp] theorem some_eq_coe (a : ℝ≥0) : (Option.some a : ℝ≥0∞) = (↑a : ℝ≥0∞) := rfl #align ennreal.some_eq_coe ENNReal.some_eq_coe @[simp] theorem some_eq_coe' (a : ℝ≥0) : (WithTop.some a : ℝ≥0∞) = (↑a : ℝ≥0∞) := rfl lemma coe_injective : Injective ((↑) : ℝ≥0 → ℝ≥0∞) := WithTop.coe_injective @[simp, norm_cast] lemma coe_inj : (p : ℝ≥0∞) = q ↔ p = q := coe_injective.eq_iff #align ennreal.coe_eq_coe ENNReal.coe_inj lemma coe_ne_coe : (p : ℝ≥0∞) ≠ q ↔ p ≠ q := coe_inj.not theorem range_coe' : range ofNNReal = Iio ∞ := WithTop.range_coe theorem range_coe : range ofNNReal = {∞}ᶜ := (isCompl_range_some_none ℝ≥0).symm.compl_eq.symm protected def toNNReal : ℝ≥0∞ → ℝ≥0 := WithTop.untop' 0 #align ennreal.to_nnreal ENNReal.toNNReal protected def toReal (a : ℝ≥0∞) : Real := a.toNNReal #align ennreal.to_real ENNReal.toReal protected noncomputable def ofReal (r : Real) : ℝ≥0∞ := r.toNNReal #align ennreal.of_real ENNReal.ofReal @[simp, norm_cast] theorem toNNReal_coe : (r : ℝ≥0∞).toNNReal = r := rfl #align ennreal.to_nnreal_coe ENNReal.toNNReal_coe @[simp] theorem coe_toNNReal : ∀ {a : ℝ≥0∞}, a ≠ ∞ → ↑a.toNNReal = a | ofNNReal _, _ => rfl | ⊤, h => (h rfl).elim #align ennreal.coe_to_nnreal ENNReal.coe_toNNReal @[simp] theorem ofReal_toReal {a : ℝ≥0∞} (h : a ≠ ∞) : ENNReal.ofReal a.toReal = a := by simp [ENNReal.toReal, ENNReal.ofReal, h] #align ennreal.of_real_to_real ENNReal.ofReal_toReal @[simp] theorem toReal_ofReal {r : ℝ} (h : 0 ≤ r) : (ENNReal.ofReal r).toReal = r := max_eq_left h #align ennreal.to_real_of_real ENNReal.toReal_ofReal theorem toReal_ofReal' {r : ℝ} : (ENNReal.ofReal r).toReal = max r 0 := rfl #align ennreal.to_real_of_real' ENNReal.toReal_ofReal' theorem coe_toNNReal_le_self : ∀ {a : ℝ≥0∞}, ↑a.toNNReal ≤ a | ofNNReal r => by rw [toNNReal_coe] | ⊤ => le_top #align ennreal.coe_to_nnreal_le_self ENNReal.coe_toNNReal_le_self theorem coe_nnreal_eq (r : ℝ≥0) : (r : ℝ≥0∞) = ENNReal.ofReal r := by rw [ENNReal.ofReal, Real.toNNReal_coe] #align ennreal.coe_nnreal_eq ENNReal.coe_nnreal_eq theorem ofReal_eq_coe_nnreal {x : ℝ} (h : 0 ≤ x) : ENNReal.ofReal x = ofNNReal ⟨x, h⟩ := (coe_nnreal_eq ⟨x, h⟩).symm #align ennreal.of_real_eq_coe_nnreal ENNReal.ofReal_eq_coe_nnreal @[simp] theorem ofReal_coe_nnreal : ENNReal.ofReal p = p := (coe_nnreal_eq p).symm #align ennreal.of_real_coe_nnreal ENNReal.ofReal_coe_nnreal @[simp, norm_cast] theorem coe_zero : ↑(0 : ℝ≥0) = (0 : ℝ≥0∞) := rfl #align ennreal.coe_zero ENNReal.coe_zero @[simp, norm_cast] theorem coe_one : ↑(1 : ℝ≥0) = (1 : ℝ≥0∞) := rfl #align ennreal.coe_one ENNReal.coe_one @[simp] theorem toReal_nonneg {a : ℝ≥0∞} : 0 ≤ a.toReal := a.toNNReal.2 #align ennreal.to_real_nonneg ENNReal.toReal_nonneg @[simp] theorem top_toNNReal : ∞.toNNReal = 0 := rfl #align ennreal.top_to_nnreal ENNReal.top_toNNReal @[simp] theorem top_toReal : ∞.toReal = 0 := rfl #align ennreal.top_to_real ENNReal.top_toReal @[simp] theorem one_toReal : (1 : ℝ≥0∞).toReal = 1 := rfl #align ennreal.one_to_real ENNReal.one_toReal @[simp] theorem one_toNNReal : (1 : ℝ≥0∞).toNNReal = 1 := rfl #align ennreal.one_to_nnreal ENNReal.one_toNNReal @[simp] theorem coe_toReal (r : ℝ≥0) : (r : ℝ≥0∞).toReal = r := rfl #align ennreal.coe_to_real ENNReal.coe_toReal @[simp] theorem zero_toNNReal : (0 : ℝ≥0∞).toNNReal = 0 := rfl #align ennreal.zero_to_nnreal ENNReal.zero_toNNReal @[simp] theorem zero_toReal : (0 : ℝ≥0∞).toReal = 0 := rfl #align ennreal.zero_to_real ENNReal.zero_toReal @[simp] theorem ofReal_zero : ENNReal.ofReal (0 : ℝ) = 0 := by simp [ENNReal.ofReal] #align ennreal.of_real_zero ENNReal.ofReal_zero @[simp] theorem ofReal_one : ENNReal.ofReal (1 : ℝ) = (1 : ℝ≥0∞) := by simp [ENNReal.ofReal] #align ennreal.of_real_one ENNReal.ofReal_one theorem ofReal_toReal_le {a : ℝ≥0∞} : ENNReal.ofReal a.toReal ≤ a := if ha : a = ∞ then ha.symm ▸ le_top else le_of_eq (ofReal_toReal ha) #align ennreal.of_real_to_real_le ENNReal.ofReal_toReal_le theorem forall_ennreal {p : ℝ≥0∞ → Prop} : (∀ a, p a) ↔ (∀ r : ℝ≥0, p r) ∧ p ∞ := Option.forall.trans and_comm #align ennreal.forall_ennreal ENNReal.forall_ennreal theorem forall_ne_top {p : ℝ≥0∞ → Prop} : (∀ a, a ≠ ∞ → p a) ↔ ∀ r : ℝ≥0, p r := Option.ball_ne_none #align ennreal.forall_ne_top ENNReal.forall_ne_top theorem exists_ne_top {p : ℝ≥0∞ → Prop} : (∃ a ≠ ∞, p a) ↔ ∃ r : ℝ≥0, p r := Option.exists_ne_none #align ennreal.exists_ne_top ENNReal.exists_ne_top theorem toNNReal_eq_zero_iff (x : ℝ≥0∞) : x.toNNReal = 0 ↔ x = 0 ∨ x = ∞ := WithTop.untop'_eq_self_iff #align ennreal.to_nnreal_eq_zero_iff ENNReal.toNNReal_eq_zero_iff theorem toReal_eq_zero_iff (x : ℝ≥0∞) : x.toReal = 0 ↔ x = 0 ∨ x = ∞ := by simp [ENNReal.toReal, toNNReal_eq_zero_iff] #align ennreal.to_real_eq_zero_iff ENNReal.toReal_eq_zero_iff theorem toNNReal_ne_zero : a.toNNReal ≠ 0 ↔ a ≠ 0 ∧ a ≠ ∞ := a.toNNReal_eq_zero_iff.not.trans not_or #align ennreal.to_nnreal_ne_zero ENNReal.toNNReal_ne_zero theorem toReal_ne_zero : a.toReal ≠ 0 ↔ a ≠ 0 ∧ a ≠ ∞ := a.toReal_eq_zero_iff.not.trans not_or #align ennreal.to_real_ne_zero ENNReal.toReal_ne_zero theorem toNNReal_eq_one_iff (x : ℝ≥0∞) : x.toNNReal = 1 ↔ x = 1 := WithTop.untop'_eq_iff.trans <| by simp #align ennreal.to_nnreal_eq_one_iff ENNReal.toNNReal_eq_one_iff theorem toReal_eq_one_iff (x : ℝ≥0∞) : x.toReal = 1 ↔ x = 1 := by rw [ENNReal.toReal, NNReal.coe_eq_one, ENNReal.toNNReal_eq_one_iff] #align ennreal.to_real_eq_one_iff ENNReal.toReal_eq_one_iff theorem toNNReal_ne_one : a.toNNReal ≠ 1 ↔ a ≠ 1 := a.toNNReal_eq_one_iff.not #align ennreal.to_nnreal_ne_one ENNReal.toNNReal_ne_one theorem toReal_ne_one : a.toReal ≠ 1 ↔ a ≠ 1 := a.toReal_eq_one_iff.not #align ennreal.to_real_ne_one ENNReal.toReal_ne_one @[simp] theorem coe_ne_top : (r : ℝ≥0∞) ≠ ∞ := WithTop.coe_ne_top #align ennreal.coe_ne_top ENNReal.coe_ne_top @[simp] theorem top_ne_coe : ∞ ≠ (r : ℝ≥0∞) := WithTop.top_ne_coe #align ennreal.top_ne_coe ENNReal.top_ne_coe @[simp] theorem coe_lt_top : (r : ℝ≥0∞) < ∞ := WithTop.coe_lt_top r #align ennreal.coe_lt_top ENNReal.coe_lt_top @[simp] theorem ofReal_ne_top {r : ℝ} : ENNReal.ofReal r ≠ ∞ := coe_ne_top #align ennreal.of_real_ne_top ENNReal.ofReal_ne_top @[simp] theorem ofReal_lt_top {r : ℝ} : ENNReal.ofReal r < ∞ := coe_lt_top #align ennreal.of_real_lt_top ENNReal.ofReal_lt_top @[simp] theorem top_ne_ofReal {r : ℝ} : ∞ ≠ ENNReal.ofReal r := top_ne_coe #align ennreal.top_ne_of_real ENNReal.top_ne_ofReal @[simp] theorem ofReal_toReal_eq_iff : ENNReal.ofReal a.toReal = a ↔ a ≠ ⊤ := ⟨fun h => by rw [← h] exact ofReal_ne_top, ofReal_toReal⟩ #align ennreal.of_real_to_real_eq_iff ENNReal.ofReal_toReal_eq_iff @[simp] theorem toReal_ofReal_eq_iff {a : ℝ} : (ENNReal.ofReal a).toReal = a ↔ 0 ≤ a := ⟨fun h => by rw [← h] exact toReal_nonneg, toReal_ofReal⟩ #align ennreal.to_real_of_real_eq_iff ENNReal.toReal_ofReal_eq_iff @[simp] theorem zero_ne_top : 0 ≠ ∞ := coe_ne_top #align ennreal.zero_ne_top ENNReal.zero_ne_top @[simp] theorem top_ne_zero : ∞ ≠ 0 := top_ne_coe #align ennreal.top_ne_zero ENNReal.top_ne_zero @[simp] theorem one_ne_top : 1 ≠ ∞ := coe_ne_top #align ennreal.one_ne_top ENNReal.one_ne_top @[simp] theorem top_ne_one : ∞ ≠ 1 := top_ne_coe #align ennreal.top_ne_one ENNReal.top_ne_one @[simp] theorem zero_lt_top : 0 < ∞ := coe_lt_top @[simp, norm_cast] theorem coe_le_coe : (↑r : ℝ≥0∞) ≤ ↑q ↔ r ≤ q := WithTop.coe_le_coe #align ennreal.coe_le_coe ENNReal.coe_le_coe @[simp, norm_cast] theorem coe_lt_coe : (↑r : ℝ≥0∞) < ↑q ↔ r < q := WithTop.coe_lt_coe #align ennreal.coe_lt_coe ENNReal.coe_lt_coe -- Needed until `@[gcongr]` accepts iff statements alias ⟨_, coe_le_coe_of_le⟩ := coe_le_coe attribute [gcongr] ENNReal.coe_le_coe_of_le -- Needed until `@[gcongr]` accepts iff statements alias ⟨_, coe_lt_coe_of_lt⟩ := coe_lt_coe attribute [gcongr] ENNReal.coe_lt_coe_of_lt theorem coe_mono : Monotone ofNNReal := fun _ _ => coe_le_coe.2 #align ennreal.coe_mono ENNReal.coe_mono theorem coe_strictMono : StrictMono ofNNReal := fun _ _ => coe_lt_coe.2 @[simp, norm_cast] theorem coe_eq_zero : (↑r : ℝ≥0∞) = 0 ↔ r = 0 := coe_inj #align ennreal.coe_eq_zero ENNReal.coe_eq_zero @[simp, norm_cast] theorem zero_eq_coe : 0 = (↑r : ℝ≥0∞) ↔ 0 = r := coe_inj #align ennreal.zero_eq_coe ENNReal.zero_eq_coe @[simp, norm_cast] theorem coe_eq_one : (↑r : ℝ≥0∞) = 1 ↔ r = 1 := coe_inj #align ennreal.coe_eq_one ENNReal.coe_eq_one @[simp, norm_cast] theorem one_eq_coe : 1 = (↑r : ℝ≥0∞) ↔ 1 = r := coe_inj #align ennreal.one_eq_coe ENNReal.one_eq_coe @[simp, norm_cast] theorem coe_pos : 0 < (r : ℝ≥0∞) ↔ 0 < r := coe_lt_coe #align ennreal.coe_pos ENNReal.coe_pos theorem coe_ne_zero : (r : ℝ≥0∞) ≠ 0 ↔ r ≠ 0 := coe_eq_zero.not #align ennreal.coe_ne_zero ENNReal.coe_ne_zero lemma coe_ne_one : (r : ℝ≥0∞) ≠ 1 ↔ r ≠ 1 := coe_eq_one.not @[simp, norm_cast] lemma coe_add (x y : ℝ≥0) : (↑(x + y) : ℝ≥0∞) = x + y := rfl #align ennreal.coe_add ENNReal.coe_add @[simp, norm_cast] lemma coe_mul (x y : ℝ≥0) : (↑(x * y) : ℝ≥0∞) = x * y := rfl #align ennreal.coe_mul ENNReal.coe_mul @[norm_cast] lemma coe_nsmul (n : ℕ) (x : ℝ≥0) : (↑(n • x) : ℝ≥0∞) = n • x := rfl @[simp, norm_cast] lemma coe_pow (x : ℝ≥0) (n : ℕ) : (↑(x ^ n) : ℝ≥0∞) = x ^ n := rfl #noalign ennreal.coe_bit0 #noalign ennreal.coe_bit1 -- See note [no_index around OfNat.ofNat] @[simp, norm_cast] -- Porting note (#10756): new theorem theorem coe_ofNat (n : ℕ) [n.AtLeastTwo] : ((no_index (OfNat.ofNat n) : ℝ≥0) : ℝ≥0∞) = OfNat.ofNat n := rfl -- Porting note (#11215): TODO: add lemmas about `OfNat.ofNat` and `<`/`≤` theorem coe_two : ((2 : ℝ≥0) : ℝ≥0∞) = 2 := rfl #align ennreal.coe_two ENNReal.coe_two theorem toNNReal_eq_toNNReal_iff (x y : ℝ≥0∞) : x.toNNReal = y.toNNReal ↔ x = y ∨ x = 0 ∧ y = ⊤ ∨ x = ⊤ ∧ y = 0 := WithTop.untop'_eq_untop'_iff #align ennreal.to_nnreal_eq_to_nnreal_iff ENNReal.toNNReal_eq_toNNReal_iff theorem toReal_eq_toReal_iff (x y : ℝ≥0∞) : x.toReal = y.toReal ↔ x = y ∨ x = 0 ∧ y = ⊤ ∨ x = ⊤ ∧ y = 0 := by simp only [ENNReal.toReal, NNReal.coe_inj, toNNReal_eq_toNNReal_iff] #align ennreal.to_real_eq_to_real_iff ENNReal.toReal_eq_toReal_iff
Mathlib/Data/ENNReal/Basic.lean
443
445
theorem toNNReal_eq_toNNReal_iff' {x y : ℝ≥0∞} (hx : x ≠ ⊤) (hy : y ≠ ⊤) : x.toNNReal = y.toNNReal ↔ x = y := by
simp only [ENNReal.toNNReal_eq_toNNReal_iff x y, hx, hy, and_false, false_and, or_false]
import Mathlib.Geometry.Euclidean.Angle.Oriented.Affine import Mathlib.Geometry.Euclidean.Angle.Unoriented.RightAngle #align_import geometry.euclidean.angle.oriented.right_angle from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" noncomputable section open scoped EuclideanGeometry open scoped Real open scoped RealInnerProductSpace namespace Orientation open FiniteDimensional variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] variable [hd2 : Fact (finrank ℝ V = 2)] (o : Orientation ℝ V (Fin 2)) theorem oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle x (x + y) = Real.arccos (‖x‖ / ‖x + y‖) := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, InnerProductGeometry.angle_add_eq_arccos_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)] #align orientation.oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two Orientation.oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two theorem oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle (x + y) y = Real.arccos (‖y‖ / ‖x + y‖) := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two h #align orientation.oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two Orientation.oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two theorem oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle x (x + y) = Real.arcsin (‖y‖ / ‖x + y‖) := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, InnerProductGeometry.angle_add_eq_arcsin_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h) (Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))] #align orientation.oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two Orientation.oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two theorem oangle_add_left_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle (x + y) y = Real.arcsin (‖x‖ / ‖x + y‖) := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two h #align orientation.oangle_add_left_eq_arcsin_of_oangle_eq_pi_div_two Orientation.oangle_add_left_eq_arcsin_of_oangle_eq_pi_div_two theorem oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle x (x + y) = Real.arctan (‖y‖ / ‖x‖) := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, InnerProductGeometry.angle_add_eq_arctan_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h) (o.left_ne_zero_of_oangle_eq_pi_div_two h)] #align orientation.oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two Orientation.oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two theorem oangle_add_left_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle (x + y) y = Real.arctan (‖x‖ / ‖y‖) := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two h #align orientation.oangle_add_left_eq_arctan_of_oangle_eq_pi_div_two Orientation.oangle_add_left_eq_arctan_of_oangle_eq_pi_div_two theorem cos_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle x (x + y)) = ‖x‖ / ‖x + y‖ := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe, InnerProductGeometry.cos_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)] #align orientation.cos_oangle_add_right_of_oangle_eq_pi_div_two Orientation.cos_oangle_add_right_of_oangle_eq_pi_div_two theorem cos_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle (x + y) y) = ‖y‖ / ‖x + y‖ := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).cos_oangle_add_right_of_oangle_eq_pi_div_two h #align orientation.cos_oangle_add_left_of_oangle_eq_pi_div_two Orientation.cos_oangle_add_left_of_oangle_eq_pi_div_two theorem sin_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle x (x + y)) = ‖y‖ / ‖x + y‖ := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe, InnerProductGeometry.sin_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h) (Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))] #align orientation.sin_oangle_add_right_of_oangle_eq_pi_div_two Orientation.sin_oangle_add_right_of_oangle_eq_pi_div_two theorem sin_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle (x + y) y) = ‖x‖ / ‖x + y‖ := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).sin_oangle_add_right_of_oangle_eq_pi_div_two h #align orientation.sin_oangle_add_left_of_oangle_eq_pi_div_two Orientation.sin_oangle_add_left_of_oangle_eq_pi_div_two theorem tan_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle x (x + y)) = ‖y‖ / ‖x‖ := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe, InnerProductGeometry.tan_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)] #align orientation.tan_oangle_add_right_of_oangle_eq_pi_div_two Orientation.tan_oangle_add_right_of_oangle_eq_pi_div_two theorem tan_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle (x + y) y) = ‖x‖ / ‖y‖ := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).tan_oangle_add_right_of_oangle_eq_pi_div_two h #align orientation.tan_oangle_add_left_of_oangle_eq_pi_div_two Orientation.tan_oangle_add_left_of_oangle_eq_pi_div_two theorem cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle x (x + y)) * ‖x + y‖ = ‖x‖ := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe, InnerProductGeometry.cos_angle_add_mul_norm_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)] #align orientation.cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two Orientation.cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two theorem cos_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle (x + y) y) * ‖x + y‖ = ‖y‖ := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two h #align orientation.cos_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two Orientation.cos_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two theorem sin_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle x (x + y)) * ‖x + y‖ = ‖y‖ := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe, InnerProductGeometry.sin_angle_add_mul_norm_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)] #align orientation.sin_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two Orientation.sin_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two theorem sin_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle (x + y) y) * ‖x + y‖ = ‖x‖ := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).sin_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two h #align orientation.sin_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two Orientation.sin_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two theorem tan_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle x (x + y)) * ‖x‖ = ‖y‖ := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe, InnerProductGeometry.tan_angle_add_mul_norm_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h) (Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))] #align orientation.tan_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two Orientation.tan_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two theorem tan_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle (x + y) y) * ‖y‖ = ‖x‖ := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).tan_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two h #align orientation.tan_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two Orientation.tan_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two theorem norm_div_cos_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.cos (o.oangle x (x + y)) = ‖x + y‖ := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe, InnerProductGeometry.norm_div_cos_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h) (Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))] #align orientation.norm_div_cos_oangle_add_right_of_oangle_eq_pi_div_two Orientation.norm_div_cos_oangle_add_right_of_oangle_eq_pi_div_two theorem norm_div_cos_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.cos (o.oangle (x + y) y) = ‖x + y‖ := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).norm_div_cos_oangle_add_right_of_oangle_eq_pi_div_two h #align orientation.norm_div_cos_oangle_add_left_of_oangle_eq_pi_div_two Orientation.norm_div_cos_oangle_add_left_of_oangle_eq_pi_div_two
Mathlib/Geometry/Euclidean/Angle/Oriented/RightAngle.lean
226
233
theorem norm_div_sin_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.sin (o.oangle x (x + y)) = ‖x + y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe, InnerProductGeometry.norm_div_sin_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h) (Or.inr (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
import Mathlib.Probability.Independence.Basic import Mathlib.Probability.Independence.Conditional #align_import probability.independence.zero_one from "leanprover-community/mathlib"@"2f8347015b12b0864dfaf366ec4909eb70c78740" open MeasureTheory MeasurableSpace open scoped MeasureTheory ENNReal namespace ProbabilityTheory variable {α Ω ι : Type*} {_mα : MeasurableSpace α} {s : ι → MeasurableSpace Ω} {m m0 : MeasurableSpace Ω} {κ : kernel α Ω} {μα : Measure α} {μ : Measure Ω} theorem kernel.measure_eq_zero_or_one_or_top_of_indepSet_self {t : Set Ω} (h_indep : kernel.IndepSet t t κ μα) : ∀ᵐ a ∂μα, κ a t = 0 ∨ κ a t = 1 ∨ κ a t = ∞ := by specialize h_indep t t (measurableSet_generateFrom (Set.mem_singleton t)) (measurableSet_generateFrom (Set.mem_singleton t)) filter_upwards [h_indep] with a ha by_cases h0 : κ a t = 0 · exact Or.inl h0 by_cases h_top : κ a t = ∞ · exact Or.inr (Or.inr h_top) rw [← one_mul (κ a (t ∩ t)), Set.inter_self, ENNReal.mul_eq_mul_right h0 h_top] at ha exact Or.inr (Or.inl ha.symm) theorem measure_eq_zero_or_one_or_top_of_indepSet_self {t : Set Ω} (h_indep : IndepSet t t μ) : μ t = 0 ∨ μ t = 1 ∨ μ t = ∞ := by simpa only [ae_dirac_eq, Filter.eventually_pure] using kernel.measure_eq_zero_or_one_or_top_of_indepSet_self h_indep #align probability_theory.measure_eq_zero_or_one_or_top_of_indep_set_self ProbabilityTheory.measure_eq_zero_or_one_or_top_of_indepSet_self theorem kernel.measure_eq_zero_or_one_of_indepSet_self [∀ a, IsFiniteMeasure (κ a)] {t : Set Ω} (h_indep : IndepSet t t κ μα) : ∀ᵐ a ∂μα, κ a t = 0 ∨ κ a t = 1 := by filter_upwards [measure_eq_zero_or_one_or_top_of_indepSet_self h_indep] with a h_0_1_top simpa only [measure_ne_top (κ a), or_false] using h_0_1_top
Mathlib/Probability/Independence/ZeroOne.lean
58
61
theorem measure_eq_zero_or_one_of_indepSet_self [IsFiniteMeasure μ] {t : Set Ω} (h_indep : IndepSet t t μ) : μ t = 0 ∨ μ t = 1 := by
simpa only [ae_dirac_eq, Filter.eventually_pure] using kernel.measure_eq_zero_or_one_of_indepSet_self h_indep
import Mathlib.Algebra.Polynomial.Degree.TrailingDegree import Mathlib.Algebra.Polynomial.EraseLead import Mathlib.Algebra.Polynomial.Eval #align_import data.polynomial.reverse from "leanprover-community/mathlib"@"44de64f183393284a16016dfb2a48ac97382f2bd" namespace Polynomial open Polynomial Finsupp Finset open Polynomial section Semiring variable {R : Type*} [Semiring R] {f : R[X]} def revAtFun (N i : ℕ) : ℕ := ite (i ≤ N) (N - i) i #align polynomial.rev_at_fun Polynomial.revAtFun theorem revAtFun_invol {N i : ℕ} : revAtFun N (revAtFun N i) = i := by unfold revAtFun split_ifs with h j · exact tsub_tsub_cancel_of_le h · exfalso apply j exact Nat.sub_le N i · rfl #align polynomial.rev_at_fun_invol Polynomial.revAtFun_invol theorem revAtFun_inj {N : ℕ} : Function.Injective (revAtFun N) := by intro a b hab rw [← @revAtFun_invol N a, hab, revAtFun_invol] #align polynomial.rev_at_fun_inj Polynomial.revAtFun_inj def revAt (N : ℕ) : Function.Embedding ℕ ℕ where toFun i := ite (i ≤ N) (N - i) i inj' := revAtFun_inj #align polynomial.rev_at Polynomial.revAt @[simp] theorem revAtFun_eq (N i : ℕ) : revAtFun N i = revAt N i := rfl #align polynomial.rev_at_fun_eq Polynomial.revAtFun_eq @[simp] theorem revAt_invol {N i : ℕ} : (revAt N) (revAt N i) = i := revAtFun_invol #align polynomial.rev_at_invol Polynomial.revAt_invol @[simp] theorem revAt_le {N i : ℕ} (H : i ≤ N) : revAt N i = N - i := if_pos H #align polynomial.rev_at_le Polynomial.revAt_le lemma revAt_eq_self_of_lt {N i : ℕ} (h : N < i) : revAt N i = i := by simp [revAt, Nat.not_le.mpr h] theorem revAt_add {N O n o : ℕ} (hn : n ≤ N) (ho : o ≤ O) : revAt (N + O) (n + o) = revAt N n + revAt O o := by rcases Nat.le.dest hn with ⟨n', rfl⟩ rcases Nat.le.dest ho with ⟨o', rfl⟩ repeat' rw [revAt_le (le_add_right rfl.le)] rw [add_assoc, add_left_comm n' o, ← add_assoc, revAt_le (le_add_right rfl.le)] repeat' rw [add_tsub_cancel_left] #align polynomial.rev_at_add Polynomial.revAt_add -- @[simp] -- Porting note (#10618): simp can prove this theorem revAt_zero (N : ℕ) : revAt N 0 = N := by simp #align polynomial.rev_at_zero Polynomial.revAt_zero noncomputable def reflect (N : ℕ) : R[X] → R[X] | ⟨f⟩ => ⟨Finsupp.embDomain (revAt N) f⟩ #align polynomial.reflect Polynomial.reflect theorem reflect_support (N : ℕ) (f : R[X]) : (reflect N f).support = Finset.image (revAt N) f.support := by rcases f with ⟨⟩ ext1 simp only [reflect, support_ofFinsupp, support_embDomain, Finset.mem_map, Finset.mem_image] #align polynomial.reflect_support Polynomial.reflect_support @[simp] theorem coeff_reflect (N : ℕ) (f : R[X]) (i : ℕ) : coeff (reflect N f) i = f.coeff (revAt N i) := by rcases f with ⟨f⟩ simp only [reflect, coeff] calc Finsupp.embDomain (revAt N) f i = Finsupp.embDomain (revAt N) f (revAt N (revAt N i)) := by rw [revAt_invol] _ = f (revAt N i) := Finsupp.embDomain_apply _ _ _ #align polynomial.coeff_reflect Polynomial.coeff_reflect @[simp] theorem reflect_zero {N : ℕ} : reflect N (0 : R[X]) = 0 := rfl #align polynomial.reflect_zero Polynomial.reflect_zero @[simp] theorem reflect_eq_zero_iff {N : ℕ} {f : R[X]} : reflect N (f : R[X]) = 0 ↔ f = 0 := by rw [ofFinsupp_eq_zero, reflect, embDomain_eq_zero, ofFinsupp_eq_zero] #align polynomial.reflect_eq_zero_iff Polynomial.reflect_eq_zero_iff @[simp] theorem reflect_add (f g : R[X]) (N : ℕ) : reflect N (f + g) = reflect N f + reflect N g := by ext simp only [coeff_add, coeff_reflect] #align polynomial.reflect_add Polynomial.reflect_add @[simp] theorem reflect_C_mul (f : R[X]) (r : R) (N : ℕ) : reflect N (C r * f) = C r * reflect N f := by ext simp only [coeff_reflect, coeff_C_mul] set_option linter.uppercaseLean3 false in #align polynomial.reflect_C_mul Polynomial.reflect_C_mul -- @[simp] -- Porting note (#10618): simp can prove this (once `reflect_monomial` is in simp scope) theorem reflect_C_mul_X_pow (N n : ℕ) {c : R} : reflect N (C c * X ^ n) = C c * X ^ revAt N n := by ext rw [reflect_C_mul, coeff_C_mul, coeff_C_mul, coeff_X_pow, coeff_reflect] split_ifs with h · rw [h, revAt_invol, coeff_X_pow_self] · rw [not_mem_support_iff.mp] intro a rw [← one_mul (X ^ n), ← C_1] at a apply h rw [← mem_support_C_mul_X_pow a, revAt_invol] set_option linter.uppercaseLean3 false in #align polynomial.reflect_C_mul_X_pow Polynomial.reflect_C_mul_X_pow @[simp] theorem reflect_C (r : R) (N : ℕ) : reflect N (C r) = C r * X ^ N := by conv_lhs => rw [← mul_one (C r), ← pow_zero X, reflect_C_mul_X_pow, revAt_zero] set_option linter.uppercaseLean3 false in #align polynomial.reflect_C Polynomial.reflect_C @[simp] theorem reflect_monomial (N n : ℕ) : reflect N ((X : R[X]) ^ n) = X ^ revAt N n := by rw [← one_mul (X ^ n), ← one_mul (X ^ revAt N n), ← C_1, reflect_C_mul_X_pow] #align polynomial.reflect_monomial Polynomial.reflect_monomial @[simp] lemma reflect_one_X : reflect 1 (X : R[X]) = 1 := by simpa using reflect_monomial 1 1 (R := R) theorem reflect_mul_induction (cf cg : ℕ) : ∀ N O : ℕ, ∀ f g : R[X], f.support.card ≤ cf.succ → g.support.card ≤ cg.succ → f.natDegree ≤ N → g.natDegree ≤ O → reflect (N + O) (f * g) = reflect N f * reflect O g := by induction' cf with cf hcf --first induction (left): base case · induction' cg with cg hcg -- second induction (right): base case · intro N O f g Cf Cg Nf Og rw [← C_mul_X_pow_eq_self Cf, ← C_mul_X_pow_eq_self Cg] simp_rw [mul_assoc, X_pow_mul, mul_assoc, ← pow_add (X : R[X]), reflect_C_mul, reflect_monomial, add_comm, revAt_add Nf Og, mul_assoc, X_pow_mul, mul_assoc, ← pow_add (X : R[X]), add_comm] -- second induction (right): induction step · intro N O f g Cf Cg Nf Og by_cases g0 : g = 0 · rw [g0, reflect_zero, mul_zero, mul_zero, reflect_zero] rw [← eraseLead_add_C_mul_X_pow g, mul_add, reflect_add, reflect_add, mul_add, hcg, hcg] <;> try assumption · exact le_add_left card_support_C_mul_X_pow_le_one · exact le_trans (natDegree_C_mul_X_pow_le g.leadingCoeff g.natDegree) Og · exact Nat.lt_succ_iff.mp (gt_of_ge_of_gt Cg (eraseLead_support_card_lt g0)) · exact le_trans eraseLead_natDegree_le_aux Og --first induction (left): induction step · intro N O f g Cf Cg Nf Og by_cases f0 : f = 0 · rw [f0, reflect_zero, zero_mul, zero_mul, reflect_zero] rw [← eraseLead_add_C_mul_X_pow f, add_mul, reflect_add, reflect_add, add_mul, hcf, hcf] <;> try assumption · exact le_add_left card_support_C_mul_X_pow_le_one · exact le_trans (natDegree_C_mul_X_pow_le f.leadingCoeff f.natDegree) Nf · exact Nat.lt_succ_iff.mp (gt_of_ge_of_gt Cf (eraseLead_support_card_lt f0)) · exact le_trans eraseLead_natDegree_le_aux Nf #align polynomial.reflect_mul_induction Polynomial.reflect_mul_induction @[simp] theorem reflect_mul (f g : R[X]) {F G : ℕ} (Ff : f.natDegree ≤ F) (Gg : g.natDegree ≤ G) : reflect (F + G) (f * g) = reflect F f * reflect G g := reflect_mul_induction _ _ F G f g f.support.card.le_succ g.support.card.le_succ Ff Gg #align polynomial.reflect_mul Polynomial.reflect_mul noncomputable def reverse (f : R[X]) : R[X] := reflect f.natDegree f #align polynomial.reverse Polynomial.reverse theorem coeff_reverse (f : R[X]) (n : ℕ) : f.reverse.coeff n = f.coeff (revAt f.natDegree n) := by rw [reverse, coeff_reflect] #align polynomial.coeff_reverse Polynomial.coeff_reverse @[simp] theorem coeff_zero_reverse (f : R[X]) : coeff (reverse f) 0 = leadingCoeff f := by rw [coeff_reverse, revAt_le (zero_le f.natDegree), tsub_zero, leadingCoeff] #align polynomial.coeff_zero_reverse Polynomial.coeff_zero_reverse @[simp] theorem reverse_zero : reverse (0 : R[X]) = 0 := rfl #align polynomial.reverse_zero Polynomial.reverse_zero @[simp] theorem reverse_eq_zero : f.reverse = 0 ↔ f = 0 := by simp [reverse] #align polynomial.reverse_eq_zero Polynomial.reverse_eq_zero theorem reverse_natDegree_le (f : R[X]) : f.reverse.natDegree ≤ f.natDegree := by rw [natDegree_le_iff_degree_le, degree_le_iff_coeff_zero] intro n hn rw [Nat.cast_lt] at hn rw [coeff_reverse, revAt, Function.Embedding.coeFn_mk, if_neg (not_le_of_gt hn), coeff_eq_zero_of_natDegree_lt hn] #align polynomial.reverse_nat_degree_le Polynomial.reverse_natDegree_le theorem natDegree_eq_reverse_natDegree_add_natTrailingDegree (f : R[X]) : f.natDegree = f.reverse.natDegree + f.natTrailingDegree := by by_cases hf : f = 0 · rw [hf, reverse_zero, natDegree_zero, natTrailingDegree_zero] apply le_antisymm · refine tsub_le_iff_right.mp ?_ apply le_natDegree_of_ne_zero rw [reverse, coeff_reflect, ← revAt_le f.natTrailingDegree_le_natDegree, revAt_invol] exact trailingCoeff_nonzero_iff_nonzero.mpr hf · rw [← le_tsub_iff_left f.reverse_natDegree_le] apply natTrailingDegree_le_of_ne_zero have key := mt leadingCoeff_eq_zero.mp (mt reverse_eq_zero.mp hf) rwa [leadingCoeff, coeff_reverse, revAt_le f.reverse_natDegree_le] at key #align polynomial.nat_degree_eq_reverse_nat_degree_add_nat_trailing_degree Polynomial.natDegree_eq_reverse_natDegree_add_natTrailingDegree theorem reverse_natDegree (f : R[X]) : f.reverse.natDegree = f.natDegree - f.natTrailingDegree := by rw [f.natDegree_eq_reverse_natDegree_add_natTrailingDegree, add_tsub_cancel_right] #align polynomial.reverse_nat_degree Polynomial.reverse_natDegree theorem reverse_leadingCoeff (f : R[X]) : f.reverse.leadingCoeff = f.trailingCoeff := by rw [leadingCoeff, reverse_natDegree, ← revAt_le f.natTrailingDegree_le_natDegree, coeff_reverse, revAt_invol, trailingCoeff] #align polynomial.reverse_leading_coeff Polynomial.reverse_leadingCoeff
Mathlib/Algebra/Polynomial/Reverse.lean
304
306
theorem natTrailingDegree_reverse (f : R[X]) : f.reverse.natTrailingDegree = 0 := by
rw [natTrailingDegree_eq_zero, reverse_eq_zero, coeff_zero_reverse, leadingCoeff_ne_zero] exact eq_or_ne _ _
import Mathlib.Algebra.Group.Basic import Mathlib.Algebra.Group.Pi.Basic import Mathlib.Order.Fin import Mathlib.Order.PiLex import Mathlib.Order.Interval.Set.Basic #align_import data.fin.tuple.basic from "leanprover-community/mathlib"@"ef997baa41b5c428be3fb50089a7139bf4ee886b" assert_not_exists MonoidWithZero universe u v namespace Fin variable {m n : ℕ} open Function section Tuple example (α : Fin 0 → Sort u) : Unique (∀ i : Fin 0, α i) := by infer_instance theorem tuple0_le {α : Fin 0 → Type*} [∀ i, Preorder (α i)] (f g : ∀ i, α i) : f ≤ g := finZeroElim #align fin.tuple0_le Fin.tuple0_le variable {α : Fin (n + 1) → Type u} (x : α 0) (q : ∀ i, α i) (p : ∀ i : Fin n, α i.succ) (i : Fin n) (y : α i.succ) (z : α 0) def tail (q : ∀ i, α i) : ∀ i : Fin n, α i.succ := fun i ↦ q i.succ #align fin.tail Fin.tail theorem tail_def {n : ℕ} {α : Fin (n + 1) → Type*} {q : ∀ i, α i} : (tail fun k : Fin (n + 1) ↦ q k) = fun k : Fin n ↦ q k.succ := rfl #align fin.tail_def Fin.tail_def def cons (x : α 0) (p : ∀ i : Fin n, α i.succ) : ∀ i, α i := fun j ↦ Fin.cases x p j #align fin.cons Fin.cons @[simp] theorem tail_cons : tail (cons x p) = p := by simp (config := { unfoldPartialApp := true }) [tail, cons] #align fin.tail_cons Fin.tail_cons @[simp] theorem cons_succ : cons x p i.succ = p i := by simp [cons] #align fin.cons_succ Fin.cons_succ @[simp] theorem cons_zero : cons x p 0 = x := by simp [cons] #align fin.cons_zero Fin.cons_zero @[simp] theorem cons_one {α : Fin (n + 2) → Type*} (x : α 0) (p : ∀ i : Fin n.succ, α i.succ) : cons x p 1 = p 0 := by rw [← cons_succ x p]; rfl @[simp] theorem cons_update : cons x (update p i y) = update (cons x p) i.succ y := by ext j by_cases h : j = 0 · rw [h] simp [Ne.symm (succ_ne_zero i)] · let j' := pred j h have : j'.succ = j := succ_pred j h rw [← this, cons_succ] by_cases h' : j' = i · rw [h'] simp · have : j'.succ ≠ i.succ := by rwa [Ne, succ_inj] rw [update_noteq h', update_noteq this, cons_succ] #align fin.cons_update Fin.cons_update theorem cons_injective2 : Function.Injective2 (@cons n α) := fun x₀ y₀ x y h ↦ ⟨congr_fun h 0, funext fun i ↦ by simpa using congr_fun h (Fin.succ i)⟩ #align fin.cons_injective2 Fin.cons_injective2 @[simp] theorem cons_eq_cons {x₀ y₀ : α 0} {x y : ∀ i : Fin n, α i.succ} : cons x₀ x = cons y₀ y ↔ x₀ = y₀ ∧ x = y := cons_injective2.eq_iff #align fin.cons_eq_cons Fin.cons_eq_cons theorem cons_left_injective (x : ∀ i : Fin n, α i.succ) : Function.Injective fun x₀ ↦ cons x₀ x := cons_injective2.left _ #align fin.cons_left_injective Fin.cons_left_injective theorem cons_right_injective (x₀ : α 0) : Function.Injective (cons x₀) := cons_injective2.right _ #align fin.cons_right_injective Fin.cons_right_injective theorem update_cons_zero : update (cons x p) 0 z = cons z p := by ext j by_cases h : j = 0 · rw [h] simp · simp only [h, update_noteq, Ne, not_false_iff] let j' := pred j h have : j'.succ = j := succ_pred j h rw [← this, cons_succ, cons_succ] #align fin.update_cons_zero Fin.update_cons_zero @[simp, nolint simpNF] -- Porting note: linter claims LHS doesn't simplify theorem cons_self_tail : cons (q 0) (tail q) = q := by ext j by_cases h : j = 0 · rw [h] simp · let j' := pred j h have : j'.succ = j := succ_pred j h rw [← this] unfold tail rw [cons_succ] #align fin.cons_self_tail Fin.cons_self_tail -- Porting note: Mathport removes `_root_`? @[elab_as_elim] def consCases {P : (∀ i : Fin n.succ, α i) → Sort v} (h : ∀ x₀ x, P (Fin.cons x₀ x)) (x : ∀ i : Fin n.succ, α i) : P x := _root_.cast (by rw [cons_self_tail]) <| h (x 0) (tail x) #align fin.cons_cases Fin.consCases @[simp] theorem consCases_cons {P : (∀ i : Fin n.succ, α i) → Sort v} (h : ∀ x₀ x, P (Fin.cons x₀ x)) (x₀ : α 0) (x : ∀ i : Fin n, α i.succ) : @consCases _ _ _ h (cons x₀ x) = h x₀ x := by rw [consCases, cast_eq] congr #align fin.cons_cases_cons Fin.consCases_cons @[elab_as_elim] def consInduction {α : Type*} {P : ∀ {n : ℕ}, (Fin n → α) → Sort v} (h0 : P Fin.elim0) (h : ∀ {n} (x₀) (x : Fin n → α), P x → P (Fin.cons x₀ x)) : ∀ {n : ℕ} (x : Fin n → α), P x | 0, x => by convert h0 | n + 1, x => consCases (fun x₀ x ↦ h _ _ <| consInduction h0 h _) x #align fin.cons_induction Fin.consInductionₓ -- Porting note: universes theorem cons_injective_of_injective {α} {x₀ : α} {x : Fin n → α} (hx₀ : x₀ ∉ Set.range x) (hx : Function.Injective x) : Function.Injective (cons x₀ x : Fin n.succ → α) := by refine Fin.cases ?_ ?_ · refine Fin.cases ?_ ?_ · intro rfl · intro j h rw [cons_zero, cons_succ] at h exact hx₀.elim ⟨_, h.symm⟩ · intro i refine Fin.cases ?_ ?_ · intro h rw [cons_zero, cons_succ] at h exact hx₀.elim ⟨_, h⟩ · intro j h rw [cons_succ, cons_succ] at h exact congr_arg _ (hx h) #align fin.cons_injective_of_injective Fin.cons_injective_of_injective theorem cons_injective_iff {α} {x₀ : α} {x : Fin n → α} : Function.Injective (cons x₀ x : Fin n.succ → α) ↔ x₀ ∉ Set.range x ∧ Function.Injective x := by refine ⟨fun h ↦ ⟨?_, ?_⟩, fun h ↦ cons_injective_of_injective h.1 h.2⟩ · rintro ⟨i, hi⟩ replace h := @h i.succ 0 simp [hi, succ_ne_zero] at h · simpa [Function.comp] using h.comp (Fin.succ_injective _) #align fin.cons_injective_iff Fin.cons_injective_iff @[simp] theorem forall_fin_zero_pi {α : Fin 0 → Sort*} {P : (∀ i, α i) → Prop} : (∀ x, P x) ↔ P finZeroElim := ⟨fun h ↦ h _, fun h x ↦ Subsingleton.elim finZeroElim x ▸ h⟩ #align fin.forall_fin_zero_pi Fin.forall_fin_zero_pi @[simp] theorem exists_fin_zero_pi {α : Fin 0 → Sort*} {P : (∀ i, α i) → Prop} : (∃ x, P x) ↔ P finZeroElim := ⟨fun ⟨x, h⟩ ↦ Subsingleton.elim x finZeroElim ▸ h, fun h ↦ ⟨_, h⟩⟩ #align fin.exists_fin_zero_pi Fin.exists_fin_zero_pi theorem forall_fin_succ_pi {P : (∀ i, α i) → Prop} : (∀ x, P x) ↔ ∀ a v, P (Fin.cons a v) := ⟨fun h a v ↦ h (Fin.cons a v), consCases⟩ #align fin.forall_fin_succ_pi Fin.forall_fin_succ_pi theorem exists_fin_succ_pi {P : (∀ i, α i) → Prop} : (∃ x, P x) ↔ ∃ a v, P (Fin.cons a v) := ⟨fun ⟨x, h⟩ ↦ ⟨x 0, tail x, (cons_self_tail x).symm ▸ h⟩, fun ⟨_, _, h⟩ ↦ ⟨_, h⟩⟩ #align fin.exists_fin_succ_pi Fin.exists_fin_succ_pi @[simp] theorem tail_update_zero : tail (update q 0 z) = tail q := by ext j simp [tail, Fin.succ_ne_zero] #align fin.tail_update_zero Fin.tail_update_zero @[simp] theorem tail_update_succ : tail (update q i.succ y) = update (tail q) i y := by ext j by_cases h : j = i · rw [h] simp [tail] · simp [tail, (Fin.succ_injective n).ne h, h] #align fin.tail_update_succ Fin.tail_update_succ
Mathlib/Data/Fin/Tuple/Basic.lean
241
249
theorem comp_cons {α : Type*} {β : Type*} (g : α → β) (y : α) (q : Fin n → α) : g ∘ cons y q = cons (g y) (g ∘ q) := by
ext j by_cases h : j = 0 · rw [h] rfl · let j' := pred j h have : j'.succ = j := succ_pred j h rw [← this, cons_succ, comp_apply, comp_apply, cons_succ]
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 TypeclassesRightLT variable [LT α] [CovariantClass α α (swap (· * ·)) (· < ·)] {a b c : α} @[to_additive (attr := simp) "Uses `right` co(ntra)variant."] theorem Right.inv_lt_one_iff : a⁻¹ < 1 ↔ 1 < a := by rw [← mul_lt_mul_iff_right a, inv_mul_self, one_mul] #align right.inv_lt_one_iff Right.inv_lt_one_iff #align right.neg_neg_iff Right.neg_neg_iff @[to_additive (attr := simp) Right.neg_pos_iff "Uses `right` co(ntra)variant."] theorem Right.one_lt_inv_iff : 1 < a⁻¹ ↔ a < 1 := by rw [← mul_lt_mul_iff_right a, inv_mul_self, one_mul] #align right.one_lt_inv_iff Right.one_lt_inv_iff #align right.neg_pos_iff Right.neg_pos_iff @[to_additive] theorem inv_lt_iff_one_lt_mul : a⁻¹ < b ↔ 1 < b * a := (mul_lt_mul_iff_right a).symm.trans <| by rw [inv_mul_self] #align inv_lt_iff_one_lt_mul inv_lt_iff_one_lt_mul #align neg_lt_iff_pos_add neg_lt_iff_pos_add @[to_additive] theorem lt_inv_iff_mul_lt_one : a < b⁻¹ ↔ a * b < 1 := (mul_lt_mul_iff_right b).symm.trans <| by rw [inv_mul_self] #align lt_inv_iff_mul_lt_one lt_inv_iff_mul_lt_one #align lt_neg_iff_add_neg lt_neg_iff_add_neg @[to_additive (attr := simp)]
Mathlib/Algebra/Order/Group/Defs.lean
305
306
theorem mul_inv_lt_iff_lt_mul : a * b⁻¹ < c ↔ a < c * b := by
rw [← mul_lt_mul_iff_right b, inv_mul_cancel_right]
import Mathlib.MeasureTheory.Measure.GiryMonad import Mathlib.Dynamics.Ergodic.MeasurePreserving import Mathlib.MeasureTheory.Integral.Lebesgue import Mathlib.MeasureTheory.Measure.OpenPos #align_import measure_theory.constructions.prod.basic from "leanprover-community/mathlib"@"00abe0695d8767201e6d008afa22393978bb324d" noncomputable section open scoped Classical open Topology ENNReal MeasureTheory open Set Function Real ENNReal open MeasureTheory MeasurableSpace MeasureTheory.Measure open TopologicalSpace hiding generateFrom open Filter hiding prod_eq map variable {α α' β β' γ E : Type*} theorem IsPiSystem.prod {C : Set (Set α)} {D : Set (Set β)} (hC : IsPiSystem C) (hD : IsPiSystem D) : IsPiSystem (image2 (· ×ˢ ·) C D) := by rintro _ ⟨s₁, hs₁, t₁, ht₁, rfl⟩ _ ⟨s₂, hs₂, t₂, ht₂, rfl⟩ hst rw [prod_inter_prod] at hst ⊢; rw [prod_nonempty_iff] at hst exact mem_image2_of_mem (hC _ hs₁ _ hs₂ hst.1) (hD _ ht₁ _ ht₂ hst.2) #align is_pi_system.prod IsPiSystem.prod theorem IsCountablySpanning.prod {C : Set (Set α)} {D : Set (Set β)} (hC : IsCountablySpanning C) (hD : IsCountablySpanning D) : IsCountablySpanning (image2 (· ×ˢ ·) C D) := by rcases hC, hD with ⟨⟨s, h1s, h2s⟩, t, h1t, h2t⟩ refine ⟨fun n => s n.unpair.1 ×ˢ t n.unpair.2, fun n => mem_image2_of_mem (h1s _) (h1t _), ?_⟩ rw [iUnion_unpair_prod, h2s, h2t, univ_prod_univ] #align is_countably_spanning.prod IsCountablySpanning.prod variable [MeasurableSpace α] [MeasurableSpace α'] [MeasurableSpace β] [MeasurableSpace β'] variable [MeasurableSpace γ] variable {μ μ' : Measure α} {ν ν' : Measure β} {τ : Measure γ} variable [NormedAddCommGroup E] theorem generateFrom_prod_eq {α β} {C : Set (Set α)} {D : Set (Set β)} (hC : IsCountablySpanning C) (hD : IsCountablySpanning D) : @Prod.instMeasurableSpace _ _ (generateFrom C) (generateFrom D) = generateFrom (image2 (· ×ˢ ·) C D) := by apply le_antisymm · refine sup_le ?_ ?_ <;> rw [comap_generateFrom] <;> apply generateFrom_le <;> rintro _ ⟨s, hs, rfl⟩ · rcases hD with ⟨t, h1t, h2t⟩ rw [← prod_univ, ← h2t, prod_iUnion] apply MeasurableSet.iUnion intro n apply measurableSet_generateFrom exact ⟨s, hs, t n, h1t n, rfl⟩ · rcases hC with ⟨t, h1t, h2t⟩ rw [← univ_prod, ← h2t, iUnion_prod_const] apply MeasurableSet.iUnion rintro n apply measurableSet_generateFrom exact mem_image2_of_mem (h1t n) hs · apply generateFrom_le rintro _ ⟨s, hs, t, ht, rfl⟩ dsimp only rw [prod_eq] apply (measurable_fst _).inter (measurable_snd _) · exact measurableSet_generateFrom hs · exact measurableSet_generateFrom ht #align generate_from_prod_eq generateFrom_prod_eq theorem generateFrom_eq_prod {C : Set (Set α)} {D : Set (Set β)} (hC : generateFrom C = ‹_›) (hD : generateFrom D = ‹_›) (h2C : IsCountablySpanning C) (h2D : IsCountablySpanning D) : generateFrom (image2 (· ×ˢ ·) C D) = Prod.instMeasurableSpace := by rw [← hC, ← hD, generateFrom_prod_eq h2C h2D] #align generate_from_eq_prod generateFrom_eq_prod theorem generateFrom_prod : generateFrom (image2 (· ×ˢ ·) { s : Set α | MeasurableSet s } { t : Set β | MeasurableSet t }) = Prod.instMeasurableSpace := generateFrom_eq_prod generateFrom_measurableSet generateFrom_measurableSet isCountablySpanning_measurableSet isCountablySpanning_measurableSet #align generate_from_prod generateFrom_prod theorem isPiSystem_prod : IsPiSystem (image2 (· ×ˢ ·) { s : Set α | MeasurableSet s } { t : Set β | MeasurableSet t }) := isPiSystem_measurableSet.prod isPiSystem_measurableSet #align is_pi_system_prod isPiSystem_prod theorem measurable_measure_prod_mk_left_finite [IsFiniteMeasure ν] {s : Set (α × β)} (hs : MeasurableSet s) : Measurable fun x => ν (Prod.mk x ⁻¹' s) := by refine induction_on_inter (C := fun s => Measurable fun x => ν (Prod.mk x ⁻¹' s)) generateFrom_prod.symm isPiSystem_prod ?_ ?_ ?_ ?_ hs · simp · rintro _ ⟨s, hs, t, _, rfl⟩ simp only [mk_preimage_prod_right_eq_if, measure_if] exact measurable_const.indicator hs · intro t ht h2t simp_rw [preimage_compl, measure_compl (measurable_prod_mk_left ht) (measure_ne_top ν _)] exact h2t.const_sub _ · intro f h1f h2f h3f simp_rw [preimage_iUnion] have : ∀ b, ν (⋃ i, Prod.mk b ⁻¹' f i) = ∑' i, ν (Prod.mk b ⁻¹' f i) := fun b => measure_iUnion (fun i j hij => Disjoint.preimage _ (h1f hij)) fun i => measurable_prod_mk_left (h2f i) simp_rw [this] apply Measurable.ennreal_tsum h3f #align measurable_measure_prod_mk_left_finite measurable_measure_prod_mk_left_finite theorem measurable_measure_prod_mk_left [SFinite ν] {s : Set (α × β)} (hs : MeasurableSet s) : Measurable fun x => ν (Prod.mk x ⁻¹' s) := by rw [← sum_sFiniteSeq ν] simp_rw [Measure.sum_apply_of_countable] exact Measurable.ennreal_tsum (fun i ↦ measurable_measure_prod_mk_left_finite hs) #align measurable_measure_prod_mk_left measurable_measure_prod_mk_left theorem measurable_measure_prod_mk_right {μ : Measure α} [SFinite μ] {s : Set (α × β)} (hs : MeasurableSet s) : Measurable fun y => μ ((fun x => (x, y)) ⁻¹' s) := measurable_measure_prod_mk_left (measurableSet_swap_iff.mpr hs) #align measurable_measure_prod_mk_right measurable_measure_prod_mk_right theorem Measurable.map_prod_mk_left [SFinite ν] : Measurable fun x : α => map (Prod.mk x) ν := by apply measurable_of_measurable_coe; intro s hs simp_rw [map_apply measurable_prod_mk_left hs] exact measurable_measure_prod_mk_left hs #align measurable.map_prod_mk_left Measurable.map_prod_mk_left theorem Measurable.map_prod_mk_right {μ : Measure α} [SFinite μ] : Measurable fun y : β => map (fun x : α => (x, y)) μ := by apply measurable_of_measurable_coe; intro s hs simp_rw [map_apply measurable_prod_mk_right hs] exact measurable_measure_prod_mk_right hs #align measurable.map_prod_mk_right Measurable.map_prod_mk_right theorem MeasurableEmbedding.prod_mk {α β γ δ : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ} {mδ : MeasurableSpace δ} {f : α → β} {g : γ → δ} (hg : MeasurableEmbedding g) (hf : MeasurableEmbedding f) : MeasurableEmbedding fun x : γ × α => (g x.1, f x.2) := by have h_inj : Function.Injective fun x : γ × α => (g x.fst, f x.snd) := by intro x y hxy rw [← @Prod.mk.eta _ _ x, ← @Prod.mk.eta _ _ y] simp only [Prod.mk.inj_iff] at hxy ⊢ exact ⟨hg.injective hxy.1, hf.injective hxy.2⟩ refine ⟨h_inj, ?_, ?_⟩ · exact (hg.measurable.comp measurable_fst).prod_mk (hf.measurable.comp measurable_snd) · -- Induction using the π-system of rectangles refine fun s hs => @MeasurableSpace.induction_on_inter _ (fun s => MeasurableSet ((fun x : γ × α => (g x.fst, f x.snd)) '' s)) _ _ generateFrom_prod.symm isPiSystem_prod ?_ ?_ ?_ ?_ _ hs · simp only [Set.image_empty, MeasurableSet.empty] · rintro t ⟨t₁, ht₁, t₂, ht₂, rfl⟩ rw [← Set.prod_image_image_eq] exact (hg.measurableSet_image.mpr ht₁).prod (hf.measurableSet_image.mpr ht₂) · intro t _ ht_m rw [← Set.range_diff_image h_inj, ← Set.prod_range_range_eq] exact MeasurableSet.diff (MeasurableSet.prod hg.measurableSet_range hf.measurableSet_range) ht_m · intro g _ _ hg simp_rw [Set.image_iUnion] exact MeasurableSet.iUnion hg #align measurable_embedding.prod_mk MeasurableEmbedding.prod_mk lemma MeasurableEmbedding.prod_mk_left {β γ : Type*} [MeasurableSingletonClass α] {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ} (x : α) {f : γ → β} (hf : MeasurableEmbedding f) : MeasurableEmbedding (fun y ↦ (x, f y)) where injective := by intro y y' simp only [Prod.mk.injEq, true_and] exact fun h ↦ hf.injective h measurable := Measurable.prod_mk measurable_const hf.measurable measurableSet_image' := by intro s hs convert (MeasurableSet.singleton x).prod (hf.measurableSet_image.mpr hs) ext x simp lemma measurableEmbedding_prod_mk_left [MeasurableSingletonClass α] (x : α) : MeasurableEmbedding (Prod.mk x : β → α × β) := MeasurableEmbedding.prod_mk_left x MeasurableEmbedding.id lemma MeasurableEmbedding.prod_mk_right {β γ : Type*} [MeasurableSingletonClass α] {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ} {f : γ → β} (hf : MeasurableEmbedding f) (x : α) : MeasurableEmbedding (fun y ↦ (f y, x)) where injective := by intro y y' simp only [Prod.mk.injEq, and_true] exact fun h ↦ hf.injective h measurable := Measurable.prod_mk hf.measurable measurable_const measurableSet_image' := by intro s hs convert (hf.measurableSet_image.mpr hs).prod (MeasurableSet.singleton x) ext x simp lemma measurableEmbedding_prod_mk_right [MeasurableSingletonClass α] (x : α) : MeasurableEmbedding (fun y ↦ (y, x) : β → β × α) := MeasurableEmbedding.prod_mk_right MeasurableEmbedding.id x theorem Measurable.lintegral_prod_right' [SFinite ν] : ∀ {f : α × β → ℝ≥0∞}, Measurable f → Measurable fun x => ∫⁻ y, f (x, y) ∂ν := by have m := @measurable_prod_mk_left refine Measurable.ennreal_induction (P := fun f => Measurable fun (x : α) => ∫⁻ y, f (x, y) ∂ν) ?_ ?_ ?_ · intro c s hs simp only [← indicator_comp_right] suffices Measurable fun x => c * ν (Prod.mk x ⁻¹' s) by simpa [lintegral_indicator _ (m hs)] exact (measurable_measure_prod_mk_left hs).const_mul _ · rintro f g - hf - h2f h2g simp only [Pi.add_apply] conv => enter [1, x]; erw [lintegral_add_left (hf.comp m)] exact h2f.add h2g · intro f hf h2f h3f have := measurable_iSup h3f have : ∀ x, Monotone fun n y => f n (x, y) := fun x i j hij y => h2f hij (x, y) conv => enter [1, x]; erw [lintegral_iSup (fun n => (hf n).comp m) (this x)] assumption #align measurable.lintegral_prod_right' Measurable.lintegral_prod_right' theorem Measurable.lintegral_prod_right [SFinite ν] {f : α → β → ℝ≥0∞} (hf : Measurable (uncurry f)) : Measurable fun x => ∫⁻ y, f x y ∂ν := hf.lintegral_prod_right' #align measurable.lintegral_prod_right Measurable.lintegral_prod_right theorem Measurable.lintegral_prod_left' [SFinite μ] {f : α × β → ℝ≥0∞} (hf : Measurable f) : Measurable fun y => ∫⁻ x, f (x, y) ∂μ := (measurable_swap_iff.mpr hf).lintegral_prod_right' #align measurable.lintegral_prod_left' Measurable.lintegral_prod_left' theorem Measurable.lintegral_prod_left [SFinite μ] {f : α → β → ℝ≥0∞} (hf : Measurable (uncurry f)) : Measurable fun y => ∫⁻ x, f x y ∂μ := hf.lintegral_prod_left' #align measurable.lintegral_prod_left Measurable.lintegral_prod_left namespace MeasureTheory namespace Measure protected irreducible_def prod (μ : Measure α) (ν : Measure β) : Measure (α × β) := bind μ fun x : α => map (Prod.mk x) ν #align measure_theory.measure.prod MeasureTheory.Measure.prod instance prod.measureSpace {α β} [MeasureSpace α] [MeasureSpace β] : MeasureSpace (α × β) where volume := volume.prod volume #align measure_theory.measure.prod.measure_space MeasureTheory.Measure.prod.measureSpace theorem volume_eq_prod (α β) [MeasureSpace α] [MeasureSpace β] : (volume : Measure (α × β)) = (volume : Measure α).prod (volume : Measure β) := rfl #align measure_theory.measure.volume_eq_prod MeasureTheory.Measure.volume_eq_prod variable [SFinite ν] theorem prod_apply {s : Set (α × β)} (hs : MeasurableSet s) : μ.prod ν s = ∫⁻ x, ν (Prod.mk x ⁻¹' s) ∂μ := by simp_rw [Measure.prod, bind_apply hs (Measurable.map_prod_mk_left (ν := ν)), map_apply measurable_prod_mk_left hs] #align measure_theory.measure.prod_apply MeasureTheory.Measure.prod_apply @[simp] theorem prod_prod (s : Set α) (t : Set β) : μ.prod ν (s ×ˢ t) = μ s * ν t := by apply le_antisymm · set S := toMeasurable μ s set T := toMeasurable ν t have hSTm : MeasurableSet (S ×ˢ T) := (measurableSet_toMeasurable _ _).prod (measurableSet_toMeasurable _ _) calc μ.prod ν (s ×ˢ t) ≤ μ.prod ν (S ×ˢ T) := by gcongr <;> apply subset_toMeasurable _ = μ S * ν T := by rw [prod_apply hSTm] simp_rw [mk_preimage_prod_right_eq_if, measure_if, lintegral_indicator _ (measurableSet_toMeasurable _ _), lintegral_const, restrict_apply_univ, mul_comm] _ = μ s * ν t := by rw [measure_toMeasurable, measure_toMeasurable] · -- Formalization is based on https://mathoverflow.net/a/254134/136589 set ST := toMeasurable (μ.prod ν) (s ×ˢ t) have hSTm : MeasurableSet ST := measurableSet_toMeasurable _ _ have hST : s ×ˢ t ⊆ ST := subset_toMeasurable _ _ set f : α → ℝ≥0∞ := fun x => ν (Prod.mk x ⁻¹' ST) have hfm : Measurable f := measurable_measure_prod_mk_left hSTm set s' : Set α := { x | ν t ≤ f x } have hss' : s ⊆ s' := fun x hx => measure_mono fun y hy => hST <| mk_mem_prod hx hy calc μ s * ν t ≤ μ s' * ν t := by gcongr _ = ∫⁻ _ in s', ν t ∂μ := by rw [set_lintegral_const, mul_comm] _ ≤ ∫⁻ x in s', f x ∂μ := set_lintegral_mono measurable_const hfm fun x => id _ ≤ ∫⁻ x, f x ∂μ := lintegral_mono' restrict_le_self le_rfl _ = μ.prod ν ST := (prod_apply hSTm).symm _ = μ.prod ν (s ×ˢ t) := measure_toMeasurable _ #align measure_theory.measure.prod_prod MeasureTheory.Measure.prod_prod @[simp] lemma map_fst_prod : Measure.map Prod.fst (μ.prod ν) = (ν univ) • μ := by ext s hs simp [Measure.map_apply measurable_fst hs, ← prod_univ, mul_comm] @[simp] lemma map_snd_prod : Measure.map Prod.snd (μ.prod ν) = (μ univ) • ν := by ext s hs simp [Measure.map_apply measurable_snd hs, ← univ_prod] instance prod.instIsOpenPosMeasure {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] {m : MeasurableSpace X} {μ : Measure X} [IsOpenPosMeasure μ] {m' : MeasurableSpace Y} {ν : Measure Y} [IsOpenPosMeasure ν] [SFinite ν] : IsOpenPosMeasure (μ.prod ν) := by constructor rintro U U_open ⟨⟨x, y⟩, hxy⟩ rcases isOpen_prod_iff.1 U_open x y hxy with ⟨u, v, u_open, v_open, xu, yv, huv⟩ refine ne_of_gt (lt_of_lt_of_le ?_ (measure_mono huv)) simp only [prod_prod, CanonicallyOrderedCommSemiring.mul_pos] constructor · exact u_open.measure_pos μ ⟨x, xu⟩ · exact v_open.measure_pos ν ⟨y, yv⟩ #align measure_theory.measure.prod.is_open_pos_measure MeasureTheory.Measure.prod.instIsOpenPosMeasure instance {X Y : Type*} [TopologicalSpace X] [MeasureSpace X] [IsOpenPosMeasure (volume : Measure X)] [TopologicalSpace Y] [MeasureSpace Y] [IsOpenPosMeasure (volume : Measure Y)] [SFinite (volume : Measure Y)] : IsOpenPosMeasure (volume : Measure (X × Y)) := prod.instIsOpenPosMeasure instance prod.instIsFiniteMeasure {α β : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} (μ : Measure α) (ν : Measure β) [IsFiniteMeasure μ] [IsFiniteMeasure ν] : IsFiniteMeasure (μ.prod ν) := by constructor rw [← univ_prod_univ, prod_prod] exact mul_lt_top (measure_lt_top _ _).ne (measure_lt_top _ _).ne #align measure_theory.measure.prod.measure_theory.is_finite_measure MeasureTheory.Measure.prod.instIsFiniteMeasure instance {α β : Type*} [MeasureSpace α] [MeasureSpace β] [IsFiniteMeasure (volume : Measure α)] [IsFiniteMeasure (volume : Measure β)] : IsFiniteMeasure (volume : Measure (α × β)) := prod.instIsFiniteMeasure _ _ instance prod.instIsProbabilityMeasure {α β : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} (μ : Measure α) (ν : Measure β) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] : IsProbabilityMeasure (μ.prod ν) := ⟨by rw [← univ_prod_univ, prod_prod, measure_univ, measure_univ, mul_one]⟩ #align measure_theory.measure.prod.measure_theory.is_probability_measure MeasureTheory.Measure.prod.instIsProbabilityMeasure instance {α β : Type*} [MeasureSpace α] [MeasureSpace β] [IsProbabilityMeasure (volume : Measure α)] [IsProbabilityMeasure (volume : Measure β)] : IsProbabilityMeasure (volume : Measure (α × β)) := prod.instIsProbabilityMeasure _ _ instance prod.instIsFiniteMeasureOnCompacts {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] {mα : MeasurableSpace α} {mβ : MeasurableSpace β} (μ : Measure α) (ν : Measure β) [IsFiniteMeasureOnCompacts μ] [IsFiniteMeasureOnCompacts ν] [SFinite ν] : IsFiniteMeasureOnCompacts (μ.prod ν) := by refine ⟨fun K hK => ?_⟩ set L := (Prod.fst '' K) ×ˢ (Prod.snd '' K) with hL have : K ⊆ L := by rintro ⟨x, y⟩ hxy simp only [L, prod_mk_mem_set_prod_eq, mem_image, Prod.exists, exists_and_right, exists_eq_right] exact ⟨⟨y, hxy⟩, ⟨x, hxy⟩⟩ apply lt_of_le_of_lt (measure_mono this) rw [hL, prod_prod] exact mul_lt_top (IsCompact.measure_lt_top (hK.image continuous_fst)).ne (IsCompact.measure_lt_top (hK.image continuous_snd)).ne #align measure_theory.measure.prod.measure_theory.is_finite_measure_on_compacts MeasureTheory.Measure.prod.instIsFiniteMeasureOnCompacts instance {X Y : Type*} [TopologicalSpace X] [MeasureSpace X] [IsFiniteMeasureOnCompacts (volume : Measure X)] [TopologicalSpace Y] [MeasureSpace Y] [IsFiniteMeasureOnCompacts (volume : Measure Y)] [SFinite (volume : Measure Y)] : IsFiniteMeasureOnCompacts (volume : Measure (X × Y)) := prod.instIsFiniteMeasureOnCompacts _ _ instance prod.instNoAtoms_fst [NoAtoms μ] : NoAtoms (Measure.prod μ ν) := by refine NoAtoms.mk (fun x => ?_) rw [← Set.singleton_prod_singleton, Measure.prod_prod, measure_singleton, zero_mul] instance prod.instNoAtoms_snd [NoAtoms ν] : NoAtoms (Measure.prod μ ν) := by refine NoAtoms.mk (fun x => ?_) rw [← Set.singleton_prod_singleton, Measure.prod_prod, measure_singleton (μ := ν), mul_zero] theorem ae_measure_lt_top {s : Set (α × β)} (hs : MeasurableSet s) (h2s : (μ.prod ν) s ≠ ∞) : ∀ᵐ x ∂μ, ν (Prod.mk x ⁻¹' s) < ∞ := by rw [prod_apply hs] at h2s exact ae_lt_top (measurable_measure_prod_mk_left hs) h2s #align measure_theory.measure.ae_measure_lt_top MeasureTheory.Measure.ae_measure_lt_top theorem measure_prod_null {s : Set (α × β)} (hs : MeasurableSet s) : μ.prod ν s = 0 ↔ (fun x => ν (Prod.mk x ⁻¹' s)) =ᵐ[μ] 0 := by rw [prod_apply hs, lintegral_eq_zero_iff (measurable_measure_prod_mk_left hs)] #align measure_theory.measure.measure_prod_null MeasureTheory.Measure.measure_prod_null
Mathlib/MeasureTheory/Constructions/Prod/Basic.lean
480
488
theorem measure_ae_null_of_prod_null {s : Set (α × β)} (h : μ.prod ν s = 0) : (fun x => ν (Prod.mk x ⁻¹' s)) =ᵐ[μ] 0 := by
obtain ⟨t, hst, mt, ht⟩ := exists_measurable_superset_of_null h rw [measure_prod_null mt] at ht rw [eventuallyLE_antisymm_iff] exact ⟨EventuallyLE.trans_eq (eventually_of_forall fun x => (measure_mono (preimage_mono hst) : _)) ht, eventually_of_forall fun x => zero_le _⟩
import Batteries.Data.Rat.Basic import Batteries.Tactic.SeqFocus namespace Rat theorem ext : {p q : Rat} → p.num = q.num → p.den = q.den → p = q | ⟨_,_,_,_⟩, ⟨_,_,_,_⟩, rfl, rfl => rfl @[simp] theorem mk_den_one {r : Int} : ⟨r, 1, Nat.one_ne_zero, (Nat.coprime_one_right _)⟩ = (r : Rat) := rfl @[simp] theorem zero_num : (0 : Rat).num = 0 := rfl @[simp] theorem zero_den : (0 : Rat).den = 1 := rfl @[simp] theorem one_num : (1 : Rat).num = 1 := rfl @[simp] theorem one_den : (1 : Rat).den = 1 := rfl @[simp] theorem maybeNormalize_eq {num den g} (den_nz reduced) : maybeNormalize num den g den_nz reduced = { num := num.div g, den := den / g, den_nz, reduced } := by unfold maybeNormalize; split · subst g; simp · rfl theorem normalize.reduced' {num : Int} {den g : Nat} (den_nz : den ≠ 0) (e : g = num.natAbs.gcd den) : (num / g).natAbs.Coprime (den / g) := by rw [← Int.div_eq_ediv_of_dvd (e ▸ Int.ofNat_dvd_left.2 (Nat.gcd_dvd_left ..))] exact normalize.reduced den_nz e theorem normalize_eq {num den} (den_nz) : normalize num den den_nz = { num := num / num.natAbs.gcd den den := den / num.natAbs.gcd den den_nz := normalize.den_nz den_nz rfl reduced := normalize.reduced' den_nz rfl } := by simp only [normalize, maybeNormalize_eq, Int.div_eq_ediv_of_dvd (Int.ofNat_dvd_left.2 (Nat.gcd_dvd_left ..))] @[simp] theorem normalize_zero (nz) : normalize 0 d nz = 0 := by simp [normalize, Int.zero_div, Int.natAbs_zero, Nat.div_self (Nat.pos_of_ne_zero nz)]; rfl
.lake/packages/batteries/Batteries/Data/Rat/Lemmas.lean
47
48
theorem mk_eq_normalize (num den nz c) : ⟨num, den, nz, c⟩ = normalize num den nz := by
simp [normalize_eq, c.gcd_eq_one]
import Mathlib.Data.ENNReal.Inv #align_import data.real.ennreal from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" open Set NNReal ENNReal namespace ENNReal section iInf variable {ι : Sort*} {f g : ι → ℝ≥0∞} variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0} theorem toNNReal_iInf (hf : ∀ i, f i ≠ ∞) : (iInf f).toNNReal = ⨅ i, (f i).toNNReal := by cases isEmpty_or_nonempty ι · rw [iInf_of_empty, top_toNNReal, NNReal.iInf_empty] · lift f to ι → ℝ≥0 using hf simp_rw [← coe_iInf, toNNReal_coe] #align ennreal.to_nnreal_infi ENNReal.toNNReal_iInf theorem toNNReal_sInf (s : Set ℝ≥0∞) (hs : ∀ r ∈ s, r ≠ ∞) : (sInf s).toNNReal = sInf (ENNReal.toNNReal '' s) := by have hf : ∀ i, ((↑) : s → ℝ≥0∞) i ≠ ∞ := fun ⟨r, rs⟩ => hs r rs -- Porting note: `← sInf_image'` had to be replaced by `← image_eq_range` as the lemmas are used -- in a different order. simpa only [← sInf_range, ← image_eq_range, Subtype.range_coe_subtype] using (toNNReal_iInf hf) #align ennreal.to_nnreal_Inf ENNReal.toNNReal_sInf theorem toNNReal_iSup (hf : ∀ i, f i ≠ ∞) : (iSup f).toNNReal = ⨆ i, (f i).toNNReal := by lift f to ι → ℝ≥0 using hf simp_rw [toNNReal_coe] by_cases h : BddAbove (range f) · rw [← coe_iSup h, toNNReal_coe] · rw [NNReal.iSup_of_not_bddAbove h, iSup_coe_eq_top.2 h, top_toNNReal] #align ennreal.to_nnreal_supr ENNReal.toNNReal_iSup theorem toNNReal_sSup (s : Set ℝ≥0∞) (hs : ∀ r ∈ s, r ≠ ∞) : (sSup s).toNNReal = sSup (ENNReal.toNNReal '' s) := by have hf : ∀ i, ((↑) : s → ℝ≥0∞) i ≠ ∞ := fun ⟨r, rs⟩ => hs r rs -- Porting note: `← sSup_image'` had to be replaced by `← image_eq_range` as the lemmas are used -- in a different order. simpa only [← sSup_range, ← image_eq_range, Subtype.range_coe_subtype] using (toNNReal_iSup hf) #align ennreal.to_nnreal_Sup ENNReal.toNNReal_sSup theorem toReal_iInf (hf : ∀ i, f i ≠ ∞) : (iInf f).toReal = ⨅ i, (f i).toReal := by simp only [ENNReal.toReal, toNNReal_iInf hf, NNReal.coe_iInf] #align ennreal.to_real_infi ENNReal.toReal_iInf theorem toReal_sInf (s : Set ℝ≥0∞) (hf : ∀ r ∈ s, r ≠ ∞) : (sInf s).toReal = sInf (ENNReal.toReal '' s) := by simp only [ENNReal.toReal, toNNReal_sInf s hf, NNReal.coe_sInf, Set.image_image] #align ennreal.to_real_Inf ENNReal.toReal_sInf theorem toReal_iSup (hf : ∀ i, f i ≠ ∞) : (iSup f).toReal = ⨆ i, (f i).toReal := by simp only [ENNReal.toReal, toNNReal_iSup hf, NNReal.coe_iSup] #align ennreal.to_real_supr ENNReal.toReal_iSup theorem toReal_sSup (s : Set ℝ≥0∞) (hf : ∀ r ∈ s, r ≠ ∞) : (sSup s).toReal = sSup (ENNReal.toReal '' s) := by simp only [ENNReal.toReal, toNNReal_sSup s hf, NNReal.coe_sSup, Set.image_image] #align ennreal.to_real_Sup ENNReal.toReal_sSup theorem iInf_add : iInf f + a = ⨅ i, f i + a := le_antisymm (le_iInf fun _ => add_le_add (iInf_le _ _) <| le_rfl) (tsub_le_iff_right.1 <| le_iInf fun _ => tsub_le_iff_right.2 <| iInf_le _ _) #align ennreal.infi_add ENNReal.iInf_add theorem iSup_sub : (⨆ i, f i) - a = ⨆ i, f i - a := le_antisymm (tsub_le_iff_right.2 <| iSup_le fun i => tsub_le_iff_right.1 <| le_iSup (f · - a) i) (iSup_le fun _ => tsub_le_tsub (le_iSup _ _) (le_refl a)) #align ennreal.supr_sub ENNReal.iSup_sub theorem sub_iInf : (a - ⨅ i, f i) = ⨆ i, a - f i := by refine eq_of_forall_ge_iff fun c => ?_ rw [tsub_le_iff_right, add_comm, iInf_add] simp [tsub_le_iff_right, sub_eq_add_neg, add_comm] #align ennreal.sub_infi ENNReal.sub_iInf theorem sInf_add {s : Set ℝ≥0∞} : sInf s + a = ⨅ b ∈ s, b + a := by simp [sInf_eq_iInf, iInf_add] #align ennreal.Inf_add ENNReal.sInf_add theorem add_iInf {a : ℝ≥0∞} : a + iInf f = ⨅ b, a + f b := by rw [add_comm, iInf_add]; simp [add_comm] #align ennreal.add_infi ENNReal.add_iInf
Mathlib/Data/ENNReal/Real.lean
613
619
theorem iInf_add_iInf (h : ∀ i j, ∃ k, f k + g k ≤ f i + g j) : iInf f + iInf g = ⨅ a, f a + g a := suffices ⨅ a, f a + g a ≤ iInf f + iInf g from le_antisymm (le_iInf fun a => add_le_add (iInf_le _ _) (iInf_le _ _)) this calc ⨅ a, f a + g a ≤ ⨅ (a) (a'), f a + g a' := le_iInf₂ fun a a' => let ⟨k, h⟩ := h a a'; iInf_le_of_le k h _ = iInf f + iInf g := by
simp_rw [iInf_add, add_iInf]
import Mathlib.Data.Set.Image import Mathlib.Order.SuccPred.Relation import Mathlib.Topology.Clopen import Mathlib.Topology.Irreducible #align_import topology.connected from "leanprover-community/mathlib"@"d101e93197bb5f6ea89bd7ba386b7f7dff1f3903" open Set Function Topology TopologicalSpace Relation open scoped Classical universe u v variable {α : Type u} {β : Type v} {ι : Type*} {π : ι → Type*} [TopologicalSpace α] {s t u v : Set α} section Preconnected def IsPreconnected (s : Set α) : Prop := ∀ u v : Set α, IsOpen u → IsOpen v → s ⊆ u ∪ v → (s ∩ u).Nonempty → (s ∩ v).Nonempty → (s ∩ (u ∩ v)).Nonempty #align is_preconnected IsPreconnected def IsConnected (s : Set α) : Prop := s.Nonempty ∧ IsPreconnected s #align is_connected IsConnected theorem IsConnected.nonempty {s : Set α} (h : IsConnected s) : s.Nonempty := h.1 #align is_connected.nonempty IsConnected.nonempty theorem IsConnected.isPreconnected {s : Set α} (h : IsConnected s) : IsPreconnected s := h.2 #align is_connected.is_preconnected IsConnected.isPreconnected theorem IsPreirreducible.isPreconnected {s : Set α} (H : IsPreirreducible s) : IsPreconnected s := fun _ _ hu hv _ => H _ _ hu hv #align is_preirreducible.is_preconnected IsPreirreducible.isPreconnected theorem IsIrreducible.isConnected {s : Set α} (H : IsIrreducible s) : IsConnected s := ⟨H.nonempty, H.isPreirreducible.isPreconnected⟩ #align is_irreducible.is_connected IsIrreducible.isConnected theorem isPreconnected_empty : IsPreconnected (∅ : Set α) := isPreirreducible_empty.isPreconnected #align is_preconnected_empty isPreconnected_empty theorem isConnected_singleton {x} : IsConnected ({x} : Set α) := isIrreducible_singleton.isConnected #align is_connected_singleton isConnected_singleton theorem isPreconnected_singleton {x} : IsPreconnected ({x} : Set α) := isConnected_singleton.isPreconnected #align is_preconnected_singleton isPreconnected_singleton theorem Set.Subsingleton.isPreconnected {s : Set α} (hs : s.Subsingleton) : IsPreconnected s := hs.induction_on isPreconnected_empty fun _ => isPreconnected_singleton #align set.subsingleton.is_preconnected Set.Subsingleton.isPreconnected theorem isPreconnected_of_forall {s : Set α} (x : α) (H : ∀ y ∈ s, ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t) : IsPreconnected s := by rintro u v hu hv hs ⟨z, zs, zu⟩ ⟨y, ys, yv⟩ have xs : x ∈ s := by rcases H y ys with ⟨t, ts, xt, -, -⟩ exact ts xt -- Porting note (#11215): TODO: use `wlog xu : x ∈ u := hs xs using u v y z, v u z y` cases hs xs with | inl xu => rcases H y ys with ⟨t, ts, xt, yt, ht⟩ have := ht u v hu hv (ts.trans hs) ⟨x, xt, xu⟩ ⟨y, yt, yv⟩ exact this.imp fun z hz => ⟨ts hz.1, hz.2⟩ | inr xv => rcases H z zs with ⟨t, ts, xt, zt, ht⟩ have := ht v u hv hu (ts.trans <| by rwa [union_comm]) ⟨x, xt, xv⟩ ⟨z, zt, zu⟩ exact this.imp fun _ h => ⟨ts h.1, h.2.2, h.2.1⟩ #align is_preconnected_of_forall isPreconnected_of_forall theorem isPreconnected_of_forall_pair {s : Set α} (H : ∀ x ∈ s, ∀ y ∈ s, ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t) : IsPreconnected s := by rcases eq_empty_or_nonempty s with (rfl | ⟨x, hx⟩) exacts [isPreconnected_empty, isPreconnected_of_forall x fun y => H x hx y] #align is_preconnected_of_forall_pair isPreconnected_of_forall_pair theorem isPreconnected_sUnion (x : α) (c : Set (Set α)) (H1 : ∀ s ∈ c, x ∈ s) (H2 : ∀ s ∈ c, IsPreconnected s) : IsPreconnected (⋃₀ c) := by apply isPreconnected_of_forall x rintro y ⟨s, sc, ys⟩ exact ⟨s, subset_sUnion_of_mem sc, H1 s sc, ys, H2 s sc⟩ #align is_preconnected_sUnion isPreconnected_sUnion theorem isPreconnected_iUnion {ι : Sort*} {s : ι → Set α} (h₁ : (⋂ i, s i).Nonempty) (h₂ : ∀ i, IsPreconnected (s i)) : IsPreconnected (⋃ i, s i) := Exists.elim h₁ fun f hf => isPreconnected_sUnion f _ hf (forall_mem_range.2 h₂) #align is_preconnected_Union isPreconnected_iUnion theorem IsPreconnected.union (x : α) {s t : Set α} (H1 : x ∈ s) (H2 : x ∈ t) (H3 : IsPreconnected s) (H4 : IsPreconnected t) : IsPreconnected (s ∪ t) := sUnion_pair s t ▸ isPreconnected_sUnion x {s, t} (by rintro r (rfl | rfl | h) <;> assumption) (by rintro r (rfl | rfl | h) <;> assumption) #align is_preconnected.union IsPreconnected.union theorem IsPreconnected.union' {s t : Set α} (H : (s ∩ t).Nonempty) (hs : IsPreconnected s) (ht : IsPreconnected t) : IsPreconnected (s ∪ t) := by rcases H with ⟨x, hxs, hxt⟩ exact hs.union x hxs hxt ht #align is_preconnected.union' IsPreconnected.union' theorem IsConnected.union {s t : Set α} (H : (s ∩ t).Nonempty) (Hs : IsConnected s) (Ht : IsConnected t) : IsConnected (s ∪ t) := by rcases H with ⟨x, hx⟩ refine ⟨⟨x, mem_union_left t (mem_of_mem_inter_left hx)⟩, ?_⟩ exact Hs.isPreconnected.union x (mem_of_mem_inter_left hx) (mem_of_mem_inter_right hx) Ht.isPreconnected #align is_connected.union IsConnected.union theorem IsPreconnected.sUnion_directed {S : Set (Set α)} (K : DirectedOn (· ⊆ ·) S) (H : ∀ s ∈ S, IsPreconnected s) : IsPreconnected (⋃₀ S) := by rintro u v hu hv Huv ⟨a, ⟨s, hsS, has⟩, hau⟩ ⟨b, ⟨t, htS, hbt⟩, hbv⟩ obtain ⟨r, hrS, hsr, htr⟩ : ∃ r ∈ S, s ⊆ r ∧ t ⊆ r := K s hsS t htS have Hnuv : (r ∩ (u ∩ v)).Nonempty := H _ hrS u v hu hv ((subset_sUnion_of_mem hrS).trans Huv) ⟨a, hsr has, hau⟩ ⟨b, htr hbt, hbv⟩ have Kruv : r ∩ (u ∩ v) ⊆ ⋃₀ S ∩ (u ∩ v) := inter_subset_inter_left _ (subset_sUnion_of_mem hrS) exact Hnuv.mono Kruv #align is_preconnected.sUnion_directed IsPreconnected.sUnion_directed theorem IsPreconnected.biUnion_of_reflTransGen {ι : Type*} {t : Set ι} {s : ι → Set α} (H : ∀ i ∈ t, IsPreconnected (s i)) (K : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen (fun i j => (s i ∩ s j).Nonempty ∧ i ∈ t) i j) : IsPreconnected (⋃ n ∈ t, s n) := by let R := fun i j : ι => (s i ∩ s j).Nonempty ∧ i ∈ t have P : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen R i j → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ j ∈ p, s j) := fun i hi j hj h => by induction h with | refl => refine ⟨{i}, singleton_subset_iff.mpr hi, mem_singleton i, mem_singleton i, ?_⟩ rw [biUnion_singleton] exact H i hi | @tail j k _ hjk ih => obtain ⟨p, hpt, hip, hjp, hp⟩ := ih hjk.2 refine ⟨insert k p, insert_subset_iff.mpr ⟨hj, hpt⟩, mem_insert_of_mem k hip, mem_insert k p, ?_⟩ rw [biUnion_insert] refine (H k hj).union' (hjk.1.mono ?_) hp rw [inter_comm] exact inter_subset_inter_right _ (subset_biUnion_of_mem hjp) refine isPreconnected_of_forall_pair ?_ intro x hx y hy obtain ⟨i : ι, hi : i ∈ t, hxi : x ∈ s i⟩ := mem_iUnion₂.1 hx obtain ⟨j : ι, hj : j ∈ t, hyj : y ∈ s j⟩ := mem_iUnion₂.1 hy obtain ⟨p, hpt, hip, hjp, hp⟩ := P i hi j hj (K i hi j hj) exact ⟨⋃ j ∈ p, s j, biUnion_subset_biUnion_left hpt, mem_biUnion hip hxi, mem_biUnion hjp hyj, hp⟩ #align is_preconnected.bUnion_of_refl_trans_gen IsPreconnected.biUnion_of_reflTransGen theorem IsConnected.biUnion_of_reflTransGen {ι : Type*} {t : Set ι} {s : ι → Set α} (ht : t.Nonempty) (H : ∀ i ∈ t, IsConnected (s i)) (K : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty ∧ i ∈ t) i j) : IsConnected (⋃ n ∈ t, s n) := ⟨nonempty_biUnion.2 <| ⟨ht.some, ht.some_mem, (H _ ht.some_mem).nonempty⟩, IsPreconnected.biUnion_of_reflTransGen (fun i hi => (H i hi).isPreconnected) K⟩ #align is_connected.bUnion_of_refl_trans_gen IsConnected.biUnion_of_reflTransGen theorem IsPreconnected.iUnion_of_reflTransGen {ι : Type*} {s : ι → Set α} (H : ∀ i, IsPreconnected (s i)) (K : ∀ i j, ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty) i j) : IsPreconnected (⋃ n, s n) := by rw [← biUnion_univ] exact IsPreconnected.biUnion_of_reflTransGen (fun i _ => H i) fun i _ j _ => by simpa [mem_univ] using K i j #align is_preconnected.Union_of_refl_trans_gen IsPreconnected.iUnion_of_reflTransGen theorem IsConnected.iUnion_of_reflTransGen {ι : Type*} [Nonempty ι] {s : ι → Set α} (H : ∀ i, IsConnected (s i)) (K : ∀ i j, ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty) i j) : IsConnected (⋃ n, s n) := ⟨nonempty_iUnion.2 <| Nonempty.elim ‹_› fun i : ι => ⟨i, (H _).nonempty⟩, IsPreconnected.iUnion_of_reflTransGen (fun i => (H i).isPreconnected) K⟩ #align is_connected.Union_of_refl_trans_gen IsConnected.iUnion_of_reflTransGen protected theorem IsPreconnected.subset_closure {s : Set α} {t : Set α} (H : IsPreconnected s) (Kst : s ⊆ t) (Ktcs : t ⊆ closure s) : IsPreconnected t := fun u v hu hv htuv ⟨_y, hyt, hyu⟩ ⟨_z, hzt, hzv⟩ => let ⟨p, hpu, hps⟩ := mem_closure_iff.1 (Ktcs hyt) u hu hyu let ⟨q, hqv, hqs⟩ := mem_closure_iff.1 (Ktcs hzt) v hv hzv let ⟨r, hrs, hruv⟩ := H u v hu hv (Subset.trans Kst htuv) ⟨p, hps, hpu⟩ ⟨q, hqs, hqv⟩ ⟨r, Kst hrs, hruv⟩ #align is_preconnected.subset_closure IsPreconnected.subset_closure protected theorem IsConnected.subset_closure {s : Set α} {t : Set α} (H : IsConnected s) (Kst : s ⊆ t) (Ktcs : t ⊆ closure s) : IsConnected t := ⟨Nonempty.mono Kst H.left, IsPreconnected.subset_closure H.right Kst Ktcs⟩ #align is_connected.subset_closure IsConnected.subset_closure protected theorem IsPreconnected.closure {s : Set α} (H : IsPreconnected s) : IsPreconnected (closure s) := IsPreconnected.subset_closure H subset_closure Subset.rfl #align is_preconnected.closure IsPreconnected.closure protected theorem IsConnected.closure {s : Set α} (H : IsConnected s) : IsConnected (closure s) := IsConnected.subset_closure H subset_closure <| Subset.rfl #align is_connected.closure IsConnected.closure protected theorem IsPreconnected.image [TopologicalSpace β] {s : Set α} (H : IsPreconnected s) (f : α → β) (hf : ContinuousOn f s) : IsPreconnected (f '' s) := by -- Unfold/destruct definitions in hypotheses rintro u v hu hv huv ⟨_, ⟨x, xs, rfl⟩, xu⟩ ⟨_, ⟨y, ys, rfl⟩, yv⟩ rcases continuousOn_iff'.1 hf u hu with ⟨u', hu', u'_eq⟩ rcases continuousOn_iff'.1 hf v hv with ⟨v', hv', v'_eq⟩ -- Reformulate `huv : f '' s ⊆ u ∪ v` in terms of `u'` and `v'` replace huv : s ⊆ u' ∪ v' := by rw [image_subset_iff, preimage_union] at huv replace huv := subset_inter huv Subset.rfl rw [union_inter_distrib_right, u'_eq, v'_eq, ← union_inter_distrib_right] at huv exact (subset_inter_iff.1 huv).1 -- Now `s ⊆ u' ∪ v'`, so we can apply `‹IsPreconnected s›` obtain ⟨z, hz⟩ : (s ∩ (u' ∩ v')).Nonempty := by refine H u' v' hu' hv' huv ⟨x, ?_⟩ ⟨y, ?_⟩ <;> rw [inter_comm] exacts [u'_eq ▸ ⟨xu, xs⟩, v'_eq ▸ ⟨yv, ys⟩] rw [← inter_self s, inter_assoc, inter_left_comm s u', ← inter_assoc, inter_comm s, inter_comm s, ← u'_eq, ← v'_eq] at hz exact ⟨f z, ⟨z, hz.1.2, rfl⟩, hz.1.1, hz.2.1⟩ #align is_preconnected.image IsPreconnected.image protected theorem IsConnected.image [TopologicalSpace β] {s : Set α} (H : IsConnected s) (f : α → β) (hf : ContinuousOn f s) : IsConnected (f '' s) := ⟨image_nonempty.mpr H.nonempty, H.isPreconnected.image f hf⟩ #align is_connected.image IsConnected.image theorem isPreconnected_closed_iff {s : Set α} : IsPreconnected s ↔ ∀ t t', IsClosed t → IsClosed t' → s ⊆ t ∪ t' → (s ∩ t).Nonempty → (s ∩ t').Nonempty → (s ∩ (t ∩ t')).Nonempty := ⟨by rintro h t t' ht ht' htt' ⟨x, xs, xt⟩ ⟨y, ys, yt'⟩ rw [← not_disjoint_iff_nonempty_inter, ← subset_compl_iff_disjoint_right, compl_inter] intro h' have xt' : x ∉ t' := (h' xs).resolve_left (absurd xt) have yt : y ∉ t := (h' ys).resolve_right (absurd yt') have := h _ _ ht.isOpen_compl ht'.isOpen_compl h' ⟨y, ys, yt⟩ ⟨x, xs, xt'⟩ rw [← compl_union] at this exact this.ne_empty htt'.disjoint_compl_right.inter_eq, by rintro h u v hu hv huv ⟨x, xs, xu⟩ ⟨y, ys, yv⟩ rw [← not_disjoint_iff_nonempty_inter, ← subset_compl_iff_disjoint_right, compl_inter] intro h' have xv : x ∉ v := (h' xs).elim (absurd xu) id have yu : y ∉ u := (h' ys).elim id (absurd yv) have := h _ _ hu.isClosed_compl hv.isClosed_compl h' ⟨y, ys, yu⟩ ⟨x, xs, xv⟩ rw [← compl_union] at this exact this.ne_empty huv.disjoint_compl_right.inter_eq⟩ #align is_preconnected_closed_iff isPreconnected_closed_iff theorem Inducing.isPreconnected_image [TopologicalSpace β] {s : Set α} {f : α → β} (hf : Inducing f) : IsPreconnected (f '' s) ↔ IsPreconnected s := by refine ⟨fun h => ?_, fun h => h.image _ hf.continuous.continuousOn⟩ rintro u v hu' hv' huv ⟨x, hxs, hxu⟩ ⟨y, hys, hyv⟩ rcases hf.isOpen_iff.1 hu' with ⟨u, hu, rfl⟩ rcases hf.isOpen_iff.1 hv' with ⟨v, hv, rfl⟩ replace huv : f '' s ⊆ u ∪ v := by rwa [image_subset_iff] rcases h u v hu hv huv ⟨f x, mem_image_of_mem _ hxs, hxu⟩ ⟨f y, mem_image_of_mem _ hys, hyv⟩ with ⟨_, ⟨z, hzs, rfl⟩, hzuv⟩ exact ⟨z, hzs, hzuv⟩ #align inducing.is_preconnected_image Inducing.isPreconnected_image theorem IsPreconnected.preimage_of_isOpenMap [TopologicalSpace β] {f : α → β} {s : Set β} (hs : IsPreconnected s) (hinj : Function.Injective f) (hf : IsOpenMap f) (hsf : s ⊆ range f) : IsPreconnected (f ⁻¹' s) := fun u v hu hv hsuv hsu hsv => by replace hsf : f '' (f ⁻¹' s) = s := image_preimage_eq_of_subset hsf obtain ⟨_, has, ⟨a, hau, rfl⟩, hav⟩ : (s ∩ (f '' u ∩ f '' v)).Nonempty := by refine hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_ · simpa only [hsf, image_union] using image_subset f hsuv · simpa only [image_preimage_inter] using hsu.image f · simpa only [image_preimage_inter] using hsv.image f · exact ⟨a, has, hau, hinj.mem_set_image.1 hav⟩ #align is_preconnected.preimage_of_open_map IsPreconnected.preimage_of_isOpenMap theorem IsPreconnected.preimage_of_isClosedMap [TopologicalSpace β] {s : Set β} (hs : IsPreconnected s) {f : α → β} (hinj : Function.Injective f) (hf : IsClosedMap f) (hsf : s ⊆ range f) : IsPreconnected (f ⁻¹' s) := isPreconnected_closed_iff.2 fun u v hu hv hsuv hsu hsv => by replace hsf : f '' (f ⁻¹' s) = s := image_preimage_eq_of_subset hsf obtain ⟨_, has, ⟨a, hau, rfl⟩, hav⟩ : (s ∩ (f '' u ∩ f '' v)).Nonempty := by refine isPreconnected_closed_iff.1 hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_ · simpa only [hsf, image_union] using image_subset f hsuv · simpa only [image_preimage_inter] using hsu.image f · simpa only [image_preimage_inter] using hsv.image f · exact ⟨a, has, hau, hinj.mem_set_image.1 hav⟩ #align is_preconnected.preimage_of_closed_map IsPreconnected.preimage_of_isClosedMap theorem IsConnected.preimage_of_isOpenMap [TopologicalSpace β] {s : Set β} (hs : IsConnected s) {f : α → β} (hinj : Function.Injective f) (hf : IsOpenMap f) (hsf : s ⊆ range f) : IsConnected (f ⁻¹' s) := ⟨hs.nonempty.preimage' hsf, hs.isPreconnected.preimage_of_isOpenMap hinj hf hsf⟩ #align is_connected.preimage_of_open_map IsConnected.preimage_of_isOpenMap theorem IsConnected.preimage_of_isClosedMap [TopologicalSpace β] {s : Set β} (hs : IsConnected s) {f : α → β} (hinj : Function.Injective f) (hf : IsClosedMap f) (hsf : s ⊆ range f) : IsConnected (f ⁻¹' s) := ⟨hs.nonempty.preimage' hsf, hs.isPreconnected.preimage_of_isClosedMap hinj hf hsf⟩ #align is_connected.preimage_of_closed_map IsConnected.preimage_of_isClosedMap theorem IsPreconnected.subset_or_subset (hu : IsOpen u) (hv : IsOpen v) (huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hs : IsPreconnected s) : s ⊆ u ∨ s ⊆ v := by specialize hs u v hu hv hsuv obtain hsu | hsu := (s ∩ u).eq_empty_or_nonempty · exact Or.inr ((Set.disjoint_iff_inter_eq_empty.2 hsu).subset_right_of_subset_union hsuv) · replace hs := mt (hs hsu) simp_rw [Set.not_nonempty_iff_eq_empty, ← Set.disjoint_iff_inter_eq_empty, disjoint_iff_inter_eq_empty.1 huv] at hs exact Or.inl ((hs s.disjoint_empty).subset_left_of_subset_union hsuv) #align is_preconnected.subset_or_subset IsPreconnected.subset_or_subset theorem IsPreconnected.subset_left_of_subset_union (hu : IsOpen u) (hv : IsOpen v) (huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hsu : (s ∩ u).Nonempty) (hs : IsPreconnected s) : s ⊆ u := Disjoint.subset_left_of_subset_union hsuv (by by_contra hsv rw [not_disjoint_iff_nonempty_inter] at hsv obtain ⟨x, _, hx⟩ := hs u v hu hv hsuv hsu hsv exact Set.disjoint_iff.1 huv hx) #align is_preconnected.subset_left_of_subset_union IsPreconnected.subset_left_of_subset_union theorem IsPreconnected.subset_right_of_subset_union (hu : IsOpen u) (hv : IsOpen v) (huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hsv : (s ∩ v).Nonempty) (hs : IsPreconnected s) : s ⊆ v := hs.subset_left_of_subset_union hv hu huv.symm (union_comm u v ▸ hsuv) hsv #align is_preconnected.subset_right_of_subset_union IsPreconnected.subset_right_of_subset_union -- Porting note: moved up theorem IsPreconnected.subset_isClopen {s t : Set α} (hs : IsPreconnected s) (ht : IsClopen t) (hne : (s ∩ t).Nonempty) : s ⊆ t := hs.subset_left_of_subset_union ht.isOpen ht.compl.isOpen disjoint_compl_right (by simp) hne #align is_preconnected.subset_clopen IsPreconnected.subset_isClopen theorem IsPreconnected.subset_of_closure_inter_subset (hs : IsPreconnected s) (hu : IsOpen u) (h'u : (s ∩ u).Nonempty) (h : closure u ∩ s ⊆ u) : s ⊆ u := by have A : s ⊆ u ∪ (closure u)ᶜ := by intro x hx by_cases xu : x ∈ u · exact Or.inl xu · right intro h'x exact xu (h (mem_inter h'x hx)) apply hs.subset_left_of_subset_union hu isClosed_closure.isOpen_compl _ A h'u exact disjoint_compl_right.mono_right (compl_subset_compl.2 subset_closure) #align is_preconnected.subset_of_closure_inter_subset IsPreconnected.subset_of_closure_inter_subset theorem IsPreconnected.prod [TopologicalSpace β] {s : Set α} {t : Set β} (hs : IsPreconnected s) (ht : IsPreconnected t) : IsPreconnected (s ×ˢ t) := by apply isPreconnected_of_forall_pair rintro ⟨a₁, b₁⟩ ⟨ha₁, hb₁⟩ ⟨a₂, b₂⟩ ⟨ha₂, hb₂⟩ refine ⟨Prod.mk a₁ '' t ∪ flip Prod.mk b₂ '' s, ?_, .inl ⟨b₁, hb₁, rfl⟩, .inr ⟨a₂, ha₂, rfl⟩, ?_⟩ · rintro _ (⟨y, hy, rfl⟩ | ⟨x, hx, rfl⟩) exacts [⟨ha₁, hy⟩, ⟨hx, hb₂⟩] · exact (ht.image _ (Continuous.Prod.mk _).continuousOn).union (a₁, b₂) ⟨b₂, hb₂, rfl⟩ ⟨a₁, ha₁, rfl⟩ (hs.image _ (continuous_id.prod_mk continuous_const).continuousOn) #align is_preconnected.prod IsPreconnected.prod theorem IsConnected.prod [TopologicalSpace β] {s : Set α} {t : Set β} (hs : IsConnected s) (ht : IsConnected t) : IsConnected (s ×ˢ t) := ⟨hs.1.prod ht.1, hs.2.prod ht.2⟩ #align is_connected.prod IsConnected.prod theorem isPreconnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)} (hs : ∀ i, IsPreconnected (s i)) : IsPreconnected (pi univ s) := by rintro u v uo vo hsuv ⟨f, hfs, hfu⟩ ⟨g, hgs, hgv⟩ rcases exists_finset_piecewise_mem_of_mem_nhds (uo.mem_nhds hfu) g with ⟨I, hI⟩ induction' I using Finset.induction_on with i I _ ihI · refine ⟨g, hgs, ⟨?_, hgv⟩⟩ simpa using hI · rw [Finset.piecewise_insert] at hI have := I.piecewise_mem_set_pi hfs hgs refine (hsuv this).elim ihI fun h => ?_ set S := update (I.piecewise f g) i '' s i have hsub : S ⊆ pi univ s := by refine image_subset_iff.2 fun z hz => ?_ rwa [update_preimage_univ_pi] exact fun j _ => this j trivial have hconn : IsPreconnected S := (hs i).image _ (continuous_const.update i continuous_id).continuousOn have hSu : (S ∩ u).Nonempty := ⟨_, mem_image_of_mem _ (hfs _ trivial), hI⟩ have hSv : (S ∩ v).Nonempty := ⟨_, ⟨_, this _ trivial, update_eq_self _ _⟩, h⟩ refine (hconn u v uo vo (hsub.trans hsuv) hSu hSv).mono ?_ exact inter_subset_inter_left _ hsub #align is_preconnected_univ_pi isPreconnected_univ_pi @[simp] theorem isConnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)} : IsConnected (pi univ s) ↔ ∀ i, IsConnected (s i) := by simp only [IsConnected, ← univ_pi_nonempty_iff, forall_and, and_congr_right_iff] refine fun hne => ⟨fun hc i => ?_, isPreconnected_univ_pi⟩ rw [← eval_image_univ_pi hne] exact hc.image _ (continuous_apply _).continuousOn #align is_connected_univ_pi isConnected_univ_pi theorem Sigma.isConnected_iff [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} : IsConnected s ↔ ∃ i t, IsConnected t ∧ s = Sigma.mk i '' t := by refine ⟨fun hs => ?_, ?_⟩ · obtain ⟨⟨i, x⟩, hx⟩ := hs.nonempty have : s ⊆ range (Sigma.mk i) := hs.isPreconnected.subset_isClopen isClopen_range_sigmaMk ⟨⟨i, x⟩, hx, x, rfl⟩ exact ⟨i, Sigma.mk i ⁻¹' s, hs.preimage_of_isOpenMap sigma_mk_injective isOpenMap_sigmaMk this, (Set.image_preimage_eq_of_subset this).symm⟩ · rintro ⟨i, t, ht, rfl⟩ exact ht.image _ continuous_sigmaMk.continuousOn #align sigma.is_connected_iff Sigma.isConnected_iff theorem Sigma.isPreconnected_iff [hι : Nonempty ι] [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} : IsPreconnected s ↔ ∃ i t, IsPreconnected t ∧ s = Sigma.mk i '' t := by refine ⟨fun hs => ?_, ?_⟩ · obtain rfl | h := s.eq_empty_or_nonempty · exact ⟨Classical.choice hι, ∅, isPreconnected_empty, (Set.image_empty _).symm⟩ · obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩ exact ⟨a, t, ht.isPreconnected, rfl⟩ · rintro ⟨a, t, ht, rfl⟩ exact ht.image _ continuous_sigmaMk.continuousOn #align sigma.is_preconnected_iff Sigma.isPreconnected_iff theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} : IsConnected s ↔ (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by refine ⟨fun hs => ?_, ?_⟩ · obtain ⟨x | x, hx⟩ := hs.nonempty · have h : s ⊆ range Sum.inl := hs.isPreconnected.subset_isClopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩ refine Or.inl ⟨Sum.inl ⁻¹' s, ?_, ?_⟩ · exact hs.preimage_of_isOpenMap Sum.inl_injective isOpenMap_inl h · exact (image_preimage_eq_of_subset h).symm · have h : s ⊆ range Sum.inr := hs.isPreconnected.subset_isClopen isClopen_range_inr ⟨.inr x, hx, x, rfl⟩ refine Or.inr ⟨Sum.inr ⁻¹' s, ?_, ?_⟩ · exact hs.preimage_of_isOpenMap Sum.inr_injective isOpenMap_inr h · exact (image_preimage_eq_of_subset h).symm · rintro (⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩) · exact ht.image _ continuous_inl.continuousOn · exact ht.image _ continuous_inr.continuousOn #align sum.is_connected_iff Sum.isConnected_iff theorem Sum.isPreconnected_iff [TopologicalSpace β] {s : Set (Sum α β)} : IsPreconnected s ↔ (∃ t, IsPreconnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsPreconnected t ∧ s = Sum.inr '' t := by refine ⟨fun hs => ?_, ?_⟩ · obtain rfl | h := s.eq_empty_or_nonempty · exact Or.inl ⟨∅, isPreconnected_empty, (Set.image_empty _).symm⟩ obtain ⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩ := Sum.isConnected_iff.1 ⟨h, hs⟩ · exact Or.inl ⟨t, ht.isPreconnected, rfl⟩ · exact Or.inr ⟨t, ht.isPreconnected, rfl⟩ · rintro (⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩) · exact ht.image _ continuous_inl.continuousOn · exact ht.image _ continuous_inr.continuousOn #align sum.is_preconnected_iff Sum.isPreconnected_iff def connectedComponent (x : α) : Set α := ⋃₀ { s : Set α | IsPreconnected s ∧ x ∈ s } #align connected_component connectedComponent def connectedComponentIn (F : Set α) (x : α) : Set α := if h : x ∈ F then (↑) '' connectedComponent (⟨x, h⟩ : F) else ∅ #align connected_component_in connectedComponentIn theorem connectedComponentIn_eq_image {F : Set α} {x : α} (h : x ∈ F) : connectedComponentIn F x = (↑) '' connectedComponent (⟨x, h⟩ : F) := dif_pos h #align connected_component_in_eq_image connectedComponentIn_eq_image theorem connectedComponentIn_eq_empty {F : Set α} {x : α} (h : x ∉ F) : connectedComponentIn F x = ∅ := dif_neg h #align connected_component_in_eq_empty connectedComponentIn_eq_empty theorem mem_connectedComponent {x : α} : x ∈ connectedComponent x := mem_sUnion_of_mem (mem_singleton x) ⟨isPreconnected_singleton, mem_singleton x⟩ #align mem_connected_component mem_connectedComponent theorem mem_connectedComponentIn {x : α} {F : Set α} (hx : x ∈ F) : x ∈ connectedComponentIn F x := by simp [connectedComponentIn_eq_image hx, mem_connectedComponent, hx] #align mem_connected_component_in mem_connectedComponentIn theorem connectedComponent_nonempty {x : α} : (connectedComponent x).Nonempty := ⟨x, mem_connectedComponent⟩ #align connected_component_nonempty connectedComponent_nonempty theorem connectedComponentIn_nonempty_iff {x : α} {F : Set α} : (connectedComponentIn F x).Nonempty ↔ x ∈ F := by rw [connectedComponentIn] split_ifs <;> simp [connectedComponent_nonempty, *] #align connected_component_in_nonempty_iff connectedComponentIn_nonempty_iff theorem connectedComponentIn_subset (F : Set α) (x : α) : connectedComponentIn F x ⊆ F := by rw [connectedComponentIn] split_ifs <;> simp #align connected_component_in_subset connectedComponentIn_subset theorem isPreconnected_connectedComponent {x : α} : IsPreconnected (connectedComponent x) := isPreconnected_sUnion x _ (fun _ => And.right) fun _ => And.left #align is_preconnected_connected_component isPreconnected_connectedComponent theorem isPreconnected_connectedComponentIn {x : α} {F : Set α} : IsPreconnected (connectedComponentIn F x) := by rw [connectedComponentIn]; split_ifs · exact inducing_subtype_val.isPreconnected_image.mpr isPreconnected_connectedComponent · exact isPreconnected_empty #align is_preconnected_connected_component_in isPreconnected_connectedComponentIn theorem isConnected_connectedComponent {x : α} : IsConnected (connectedComponent x) := ⟨⟨x, mem_connectedComponent⟩, isPreconnected_connectedComponent⟩ #align is_connected_connected_component isConnected_connectedComponent theorem isConnected_connectedComponentIn_iff {x : α} {F : Set α} : IsConnected (connectedComponentIn F x) ↔ x ∈ F := by simp_rw [← connectedComponentIn_nonempty_iff, IsConnected, isPreconnected_connectedComponentIn, and_true_iff] #align is_connected_connected_component_in_iff isConnected_connectedComponentIn_iff theorem IsPreconnected.subset_connectedComponent {x : α} {s : Set α} (H1 : IsPreconnected s) (H2 : x ∈ s) : s ⊆ connectedComponent x := fun _z hz => mem_sUnion_of_mem hz ⟨H1, H2⟩ #align is_preconnected.subset_connected_component IsPreconnected.subset_connectedComponent theorem IsPreconnected.subset_connectedComponentIn {x : α} {F : Set α} (hs : IsPreconnected s) (hxs : x ∈ s) (hsF : s ⊆ F) : s ⊆ connectedComponentIn F x := by have : IsPreconnected (((↑) : F → α) ⁻¹' s) := by refine inducing_subtype_val.isPreconnected_image.mp ?_ rwa [Subtype.image_preimage_coe, inter_eq_right.mpr hsF] have h2xs : (⟨x, hsF hxs⟩ : F) ∈ (↑) ⁻¹' s := by rw [mem_preimage] exact hxs have := this.subset_connectedComponent h2xs rw [connectedComponentIn_eq_image (hsF hxs)] refine Subset.trans ?_ (image_subset _ this) rw [Subtype.image_preimage_coe, inter_eq_right.mpr hsF] #align is_preconnected.subset_connected_component_in IsPreconnected.subset_connectedComponentIn theorem IsConnected.subset_connectedComponent {x : α} {s : Set α} (H1 : IsConnected s) (H2 : x ∈ s) : s ⊆ connectedComponent x := H1.2.subset_connectedComponent H2 #align is_connected.subset_connected_component IsConnected.subset_connectedComponent theorem IsPreconnected.connectedComponentIn {x : α} {F : Set α} (h : IsPreconnected F) (hx : x ∈ F) : connectedComponentIn F x = F := (connectedComponentIn_subset F x).antisymm (h.subset_connectedComponentIn hx subset_rfl) #align is_preconnected.connected_component_in IsPreconnected.connectedComponentIn theorem connectedComponent_eq {x y : α} (h : y ∈ connectedComponent x) : connectedComponent x = connectedComponent y := eq_of_subset_of_subset (isConnected_connectedComponent.subset_connectedComponent h) (isConnected_connectedComponent.subset_connectedComponent (Set.mem_of_mem_of_subset mem_connectedComponent (isConnected_connectedComponent.subset_connectedComponent h))) #align connected_component_eq connectedComponent_eq theorem connectedComponent_eq_iff_mem {x y : α} : connectedComponent x = connectedComponent y ↔ x ∈ connectedComponent y := ⟨fun h => h ▸ mem_connectedComponent, fun h => (connectedComponent_eq h).symm⟩ #align connected_component_eq_iff_mem connectedComponent_eq_iff_mem theorem connectedComponentIn_eq {x y : α} {F : Set α} (h : y ∈ connectedComponentIn F x) : connectedComponentIn F x = connectedComponentIn F y := by have hx : x ∈ F := connectedComponentIn_nonempty_iff.mp ⟨y, h⟩ simp_rw [connectedComponentIn_eq_image hx] at h ⊢ obtain ⟨⟨y, hy⟩, h2y, rfl⟩ := h simp_rw [connectedComponentIn_eq_image hy, connectedComponent_eq h2y] #align connected_component_in_eq connectedComponentIn_eq theorem connectedComponentIn_univ (x : α) : connectedComponentIn univ x = connectedComponent x := subset_antisymm (isPreconnected_connectedComponentIn.subset_connectedComponent <| mem_connectedComponentIn trivial) (isPreconnected_connectedComponent.subset_connectedComponentIn mem_connectedComponent <| subset_univ _) #align connected_component_in_univ connectedComponentIn_univ theorem connectedComponent_disjoint {x y : α} (h : connectedComponent x ≠ connectedComponent y) : Disjoint (connectedComponent x) (connectedComponent y) := Set.disjoint_left.2 fun _ h1 h2 => h ((connectedComponent_eq h1).trans (connectedComponent_eq h2).symm) #align connected_component_disjoint connectedComponent_disjoint theorem isClosed_connectedComponent {x : α} : IsClosed (connectedComponent x) := closure_subset_iff_isClosed.1 <| isConnected_connectedComponent.closure.subset_connectedComponent <| subset_closure mem_connectedComponent #align is_closed_connected_component isClosed_connectedComponent theorem Continuous.image_connectedComponent_subset [TopologicalSpace β] {f : α → β} (h : Continuous f) (a : α) : f '' connectedComponent a ⊆ connectedComponent (f a) := (isConnected_connectedComponent.image f h.continuousOn).subset_connectedComponent ((mem_image f (connectedComponent a) (f a)).2 ⟨a, mem_connectedComponent, rfl⟩) #align continuous.image_connected_component_subset Continuous.image_connectedComponent_subset theorem Continuous.image_connectedComponentIn_subset [TopologicalSpace β] {f : α → β} {s : Set α} {a : α} (hf : Continuous f) (hx : a ∈ s) : f '' connectedComponentIn s a ⊆ connectedComponentIn (f '' s) (f a) := (isPreconnected_connectedComponentIn.image _ hf.continuousOn).subset_connectedComponentIn (mem_image_of_mem _ <| mem_connectedComponentIn hx) (image_subset _ <| connectedComponentIn_subset _ _) theorem Continuous.mapsTo_connectedComponent [TopologicalSpace β] {f : α → β} (h : Continuous f) (a : α) : MapsTo f (connectedComponent a) (connectedComponent (f a)) := mapsTo'.2 <| h.image_connectedComponent_subset a #align continuous.maps_to_connected_component Continuous.mapsTo_connectedComponent theorem Continuous.mapsTo_connectedComponentIn [TopologicalSpace β] {f : α → β} {s : Set α} (h : Continuous f) {a : α} (hx : a ∈ s) : MapsTo f (connectedComponentIn s a) (connectedComponentIn (f '' s) (f a)) := mapsTo'.2 <| image_connectedComponentIn_subset h hx theorem irreducibleComponent_subset_connectedComponent {x : α} : irreducibleComponent x ⊆ connectedComponent x := isIrreducible_irreducibleComponent.isConnected.subset_connectedComponent mem_irreducibleComponent #align irreducible_component_subset_connected_component irreducibleComponent_subset_connectedComponent @[mono] theorem connectedComponentIn_mono (x : α) {F G : Set α} (h : F ⊆ G) : connectedComponentIn F x ⊆ connectedComponentIn G x := by by_cases hx : x ∈ F · rw [connectedComponentIn_eq_image hx, connectedComponentIn_eq_image (h hx), ← show ((↑) : G → α) ∘ inclusion h = (↑) from rfl, image_comp] exact image_subset _ ((continuous_inclusion h).image_connectedComponent_subset ⟨x, hx⟩) · rw [connectedComponentIn_eq_empty hx] exact Set.empty_subset _ #align connected_component_in_mono connectedComponentIn_mono class PreconnectedSpace (α : Type u) [TopologicalSpace α] : Prop where isPreconnected_univ : IsPreconnected (univ : Set α) #align preconnected_space PreconnectedSpace export PreconnectedSpace (isPreconnected_univ) class ConnectedSpace (α : Type u) [TopologicalSpace α] extends PreconnectedSpace α : Prop where toNonempty : Nonempty α #align connected_space ConnectedSpace attribute [instance 50] ConnectedSpace.toNonempty -- see Note [lower instance priority] -- see Note [lower instance priority] theorem isConnected_univ [ConnectedSpace α] : IsConnected (univ : Set α) := ⟨univ_nonempty, isPreconnected_univ⟩ #align is_connected_univ isConnected_univ lemma preconnectedSpace_iff_univ : PreconnectedSpace α ↔ IsPreconnected (univ : Set α) := ⟨fun h ↦ h.1, fun h ↦ ⟨h⟩⟩ lemma connectedSpace_iff_univ : ConnectedSpace α ↔ IsConnected (univ : Set α) := ⟨fun h ↦ ⟨univ_nonempty, h.1.1⟩, fun h ↦ ConnectedSpace.mk (toPreconnectedSpace := ⟨h.2⟩) ⟨h.1.some⟩⟩ theorem isPreconnected_range [TopologicalSpace β] [PreconnectedSpace α] {f : α → β} (h : Continuous f) : IsPreconnected (range f) := @image_univ _ _ f ▸ isPreconnected_univ.image _ h.continuousOn #align is_preconnected_range isPreconnected_range theorem isConnected_range [TopologicalSpace β] [ConnectedSpace α] {f : α → β} (h : Continuous f) : IsConnected (range f) := ⟨range_nonempty f, isPreconnected_range h⟩ #align is_connected_range isConnected_range theorem Function.Surjective.connectedSpace [ConnectedSpace α] [TopologicalSpace β] {f : α → β} (hf : Surjective f) (hf' : Continuous f) : ConnectedSpace β := by rw [connectedSpace_iff_univ, ← hf.range_eq] exact isConnected_range hf' instance Quotient.instConnectedSpace {s : Setoid α} [ConnectedSpace α] : ConnectedSpace (Quotient s) := (surjective_quotient_mk' _).connectedSpace continuous_coinduced_rng theorem DenseRange.preconnectedSpace [TopologicalSpace β] [PreconnectedSpace α] {f : α → β} (hf : DenseRange f) (hc : Continuous f) : PreconnectedSpace β := ⟨hf.closure_eq ▸ (isPreconnected_range hc).closure⟩ #align dense_range.preconnected_space DenseRange.preconnectedSpace theorem connectedSpace_iff_connectedComponent : ConnectedSpace α ↔ ∃ x : α, connectedComponent x = univ := by constructor · rintro ⟨⟨x⟩⟩ exact ⟨x, eq_univ_of_univ_subset <| isPreconnected_univ.subset_connectedComponent (mem_univ x)⟩ · rintro ⟨x, h⟩ haveI : PreconnectedSpace α := ⟨by rw [← h]; exact isPreconnected_connectedComponent⟩ exact ⟨⟨x⟩⟩ #align connected_space_iff_connected_component connectedSpace_iff_connectedComponent theorem preconnectedSpace_iff_connectedComponent : PreconnectedSpace α ↔ ∀ x : α, connectedComponent x = univ := by constructor · intro h x exact eq_univ_of_univ_subset <| isPreconnected_univ.subset_connectedComponent (mem_univ x) · intro h cases' isEmpty_or_nonempty α with hα hα · exact ⟨by rw [univ_eq_empty_iff.mpr hα]; exact isPreconnected_empty⟩ · exact ⟨by rw [← h (Classical.choice hα)]; exact isPreconnected_connectedComponent⟩ #align preconnected_space_iff_connected_component preconnectedSpace_iff_connectedComponent @[simp] theorem PreconnectedSpace.connectedComponent_eq_univ {X : Type*} [TopologicalSpace X] [h : PreconnectedSpace X] (x : X) : connectedComponent x = univ := preconnectedSpace_iff_connectedComponent.mp h x #align preconnected_space.connected_component_eq_univ PreconnectedSpace.connectedComponent_eq_univ instance [TopologicalSpace β] [PreconnectedSpace α] [PreconnectedSpace β] : PreconnectedSpace (α × β) := ⟨by rw [← univ_prod_univ] exact isPreconnected_univ.prod isPreconnected_univ⟩ instance [TopologicalSpace β] [ConnectedSpace α] [ConnectedSpace β] : ConnectedSpace (α × β) := ⟨inferInstance⟩ instance [∀ i, TopologicalSpace (π i)] [∀ i, PreconnectedSpace (π i)] : PreconnectedSpace (∀ i, π i) := ⟨by rw [← pi_univ univ]; exact isPreconnected_univ_pi fun i => isPreconnected_univ⟩ instance [∀ i, TopologicalSpace (π i)] [∀ i, ConnectedSpace (π i)] : ConnectedSpace (∀ i, π i) := ⟨inferInstance⟩ -- see Note [lower instance priority] instance (priority := 100) PreirreducibleSpace.preconnectedSpace (α : Type u) [TopologicalSpace α] [PreirreducibleSpace α] : PreconnectedSpace α := ⟨isPreirreducible_univ.isPreconnected⟩ #align preirreducible_space.preconnected_space PreirreducibleSpace.preconnectedSpace -- see Note [lower instance priority] instance (priority := 100) IrreducibleSpace.connectedSpace (α : Type u) [TopologicalSpace α] [IrreducibleSpace α] : ConnectedSpace α where toNonempty := IrreducibleSpace.toNonempty #align irreducible_space.connected_space IrreducibleSpace.connectedSpace theorem Continuous.exists_lift_sigma [ConnectedSpace α] [∀ i, TopologicalSpace (π i)] {f : α → Σ i, π i} (hf : Continuous f) : ∃ (i : ι) (g : α → π i), Continuous g ∧ f = Sigma.mk i ∘ g := by obtain ⟨i, hi⟩ : ∃ i, range f ⊆ range (.mk i) := by rcases Sigma.isConnected_iff.1 (isConnected_range hf) with ⟨i, s, -, hs⟩ exact ⟨i, hs.trans_subset (image_subset_range _ _)⟩ rcases range_subset_range_iff_exists_comp.1 hi with ⟨g, rfl⟩ refine ⟨i, g, ?_, rfl⟩ rwa [← embedding_sigmaMk.continuous_iff] at hf theorem nonempty_inter [PreconnectedSpace α] {s t : Set α} : IsOpen s → IsOpen t → s ∪ t = univ → s.Nonempty → t.Nonempty → (s ∩ t).Nonempty := by simpa only [univ_inter, univ_subset_iff] using @PreconnectedSpace.isPreconnected_univ α _ _ s t #align nonempty_inter nonempty_inter theorem isClopen_iff [PreconnectedSpace α] {s : Set α} : IsClopen s ↔ s = ∅ ∨ s = univ := ⟨fun hs => by_contradiction fun h => have h1 : s ≠ ∅ ∧ sᶜ ≠ ∅ := ⟨mt Or.inl h, mt (fun h2 => Or.inr <| (by rw [← compl_compl s, h2, compl_empty] : s = univ)) h⟩ let ⟨_, h2, h3⟩ := nonempty_inter hs.2 hs.1.isOpen_compl (union_compl_self s) (nonempty_iff_ne_empty.2 h1.1) (nonempty_iff_ne_empty.2 h1.2) h3 h2, by rintro (rfl | rfl) <;> [exact isClopen_empty; exact isClopen_univ]⟩ #align is_clopen_iff isClopen_iff theorem IsClopen.eq_univ [PreconnectedSpace α] {s : Set α} (h' : IsClopen s) (h : s.Nonempty) : s = univ := (isClopen_iff.mp h').resolve_left h.ne_empty #align is_clopen.eq_univ IsClopen.eq_univ theorem frontier_eq_empty_iff [PreconnectedSpace α] {s : Set α} : frontier s = ∅ ↔ s = ∅ ∨ s = univ := isClopen_iff_frontier_eq_empty.symm.trans isClopen_iff #align frontier_eq_empty_iff frontier_eq_empty_iff theorem nonempty_frontier_iff [PreconnectedSpace α] {s : Set α} : (frontier s).Nonempty ↔ s.Nonempty ∧ s ≠ univ := by simp only [nonempty_iff_ne_empty, Ne, frontier_eq_empty_iff, not_or] #align nonempty_frontier_iff nonempty_frontier_iff theorem Subtype.preconnectedSpace {s : Set α} (h : IsPreconnected s) : PreconnectedSpace s where isPreconnected_univ := by rwa [← inducing_subtype_val.isPreconnected_image, image_univ, Subtype.range_val] #align subtype.preconnected_space Subtype.preconnectedSpace theorem Subtype.connectedSpace {s : Set α} (h : IsConnected s) : ConnectedSpace s where toPreconnectedSpace := Subtype.preconnectedSpace h.isPreconnected toNonempty := h.nonempty.to_subtype #align subtype.connected_space Subtype.connectedSpace theorem isPreconnected_iff_preconnectedSpace {s : Set α} : IsPreconnected s ↔ PreconnectedSpace s := ⟨Subtype.preconnectedSpace, fun h => by simpa using isPreconnected_univ.image ((↑) : s → α) continuous_subtype_val.continuousOn⟩ #align is_preconnected_iff_preconnected_space isPreconnected_iff_preconnectedSpace theorem isConnected_iff_connectedSpace {s : Set α} : IsConnected s ↔ ConnectedSpace s := ⟨Subtype.connectedSpace, fun h => ⟨nonempty_subtype.mp h.2, isPreconnected_iff_preconnectedSpace.mpr h.1⟩⟩ #align is_connected_iff_connected_space isConnected_iff_connectedSpace lemma PreconnectedSpace.induction₂' [PreconnectedSpace α] (P : α → α → Prop) (h : ∀ x, ∀ᶠ y in 𝓝 x, P x y ∧ P y x) (h' : Transitive P) (x y : α) : P x y := by let u := {z | P x z} have A : IsClosed u := by apply isClosed_iff_nhds.2 (fun z hz ↦ ?_) rcases hz _ (h z) with ⟨t, ht, h't⟩ exact h' h't ht.2 have B : IsOpen u := by apply isOpen_iff_mem_nhds.2 (fun z hz ↦ ?_) filter_upwards [h z] with t ht exact h' hz ht.1 have C : u.Nonempty := ⟨x, (mem_of_mem_nhds (h x)).1⟩ have D : u = Set.univ := IsClopen.eq_univ ⟨A, B⟩ C show y ∈ u simp [D] lemma PreconnectedSpace.induction₂ [PreconnectedSpace α] (P : α → α → Prop) (h : ∀ x, ∀ᶠ y in 𝓝 x, P x y) (h' : Transitive P) (h'' : Symmetric P) (x y : α) : P x y := by refine PreconnectedSpace.induction₂' P (fun z ↦ ?_) h' x y filter_upwards [h z] with a ha exact ⟨ha, h'' ha⟩ lemma IsPreconnected.induction₂' {s : Set α} (hs : IsPreconnected s) (P : α → α → Prop) (h : ∀ x ∈ s, ∀ᶠ y in 𝓝[s] x, P x y ∧ P y x) (h' : ∀ x y z, x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z) {x y : α} (hx : x ∈ s) (hy : y ∈ s) : P x y := by let Q : s → s → Prop := fun a b ↦ P a b show Q ⟨x, hx⟩ ⟨y, hy⟩ have : PreconnectedSpace s := Subtype.preconnectedSpace hs apply PreconnectedSpace.induction₂' · rintro ⟨x, hx⟩ have Z := h x hx rwa [nhdsWithin_eq_map_subtype_coe] at Z · rintro ⟨a, ha⟩ ⟨b, hb⟩ ⟨c, hc⟩ hab hbc exact h' a b c ha hb hc hab hbc lemma IsPreconnected.induction₂ {s : Set α} (hs : IsPreconnected s) (P : α → α → Prop) (h : ∀ x ∈ s, ∀ᶠ y in 𝓝[s] x, P x y) (h' : ∀ x y z, x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z) (h'' : ∀ x y, x ∈ s → y ∈ s → P x y → P y x) {x y : α} (hx : x ∈ s) (hy : y ∈ s) : P x y := by apply hs.induction₂' P (fun z hz ↦ ?_) h' hx hy filter_upwards [h z hz, self_mem_nhdsWithin] with a ha h'a exact ⟨ha, h'' z a hz h'a ha⟩
Mathlib/Topology/Connected/Basic.lean
1,027
1,047
theorem isPreconnected_iff_subset_of_disjoint {s : Set α} : IsPreconnected s ↔ ∀ u v, IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v := by
constructor <;> intro h · intro u v hu hv hs huv specialize h u v hu hv hs contrapose! huv simp [not_subset] at huv rcases huv with ⟨⟨x, hxs, hxu⟩, ⟨y, hys, hyv⟩⟩ have hxv : x ∈ v := or_iff_not_imp_left.mp (hs hxs) hxu have hyu : y ∈ u := or_iff_not_imp_right.mp (hs hys) hyv exact h ⟨y, hys, hyu⟩ ⟨x, hxs, hxv⟩ · intro u v hu hv hs hsu hsv by_contra H specialize h u v hu hv hs (Set.not_nonempty_iff_eq_empty.mp H) apply H cases' h with h h · rcases hsv with ⟨x, hxs, hxv⟩ exact ⟨x, hxs, ⟨h hxs, hxv⟩⟩ · rcases hsu with ⟨x, hxs, hxu⟩ exact ⟨x, hxs, ⟨hxu, h hxs⟩⟩
import Mathlib.Init.Function #align_import data.option.n_ary from "leanprover-community/mathlib"@"995b47e555f1b6297c7cf16855f1023e355219fb" universe u open Function namespace Option variable {α β γ δ : Type*} {f : α → β → γ} {a : Option α} {b : Option β} {c : Option γ} def map₂ (f : α → β → γ) (a : Option α) (b : Option β) : Option γ := a.bind fun a => b.map <| f a #align option.map₂ Option.map₂ theorem map₂_def {α β γ : Type u} (f : α → β → γ) (a : Option α) (b : Option β) : map₂ f a b = f <$> a <*> b := by cases a <;> rfl #align option.map₂_def Option.map₂_def -- Porting note (#10618): In Lean3, was `@[simp]` but now `simp` can prove it theorem map₂_some_some (f : α → β → γ) (a : α) (b : β) : map₂ f (some a) (some b) = f a b := rfl #align option.map₂_some_some Option.map₂_some_some theorem map₂_coe_coe (f : α → β → γ) (a : α) (b : β) : map₂ f a b = f a b := rfl #align option.map₂_coe_coe Option.map₂_coe_coe @[simp] theorem map₂_none_left (f : α → β → γ) (b : Option β) : map₂ f none b = none := rfl #align option.map₂_none_left Option.map₂_none_left @[simp] theorem map₂_none_right (f : α → β → γ) (a : Option α) : map₂ f a none = none := by cases a <;> rfl #align option.map₂_none_right Option.map₂_none_right @[simp] theorem map₂_coe_left (f : α → β → γ) (a : α) (b : Option β) : map₂ f a b = b.map fun b => f a b := rfl #align option.map₂_coe_left Option.map₂_coe_left -- Porting note: This proof was `rfl` in Lean3, but now is not. @[simp] theorem map₂_coe_right (f : α → β → γ) (a : Option α) (b : β) : map₂ f a b = a.map fun a => f a b := by cases a <;> rfl #align option.map₂_coe_right Option.map₂_coe_right -- Porting note: Removed the `@[simp]` tag as membership of an `Option` is no-longer simp-normal.
Mathlib/Data/Option/NAry.lean
78
79
theorem mem_map₂_iff {c : γ} : c ∈ map₂ f a b ↔ ∃ a' b', a' ∈ a ∧ b' ∈ b ∧ f a' b' = c := by
simp [map₂, bind_eq_some]
import Mathlib.Algebra.Algebra.Pi import Mathlib.Algebra.Polynomial.Eval import Mathlib.RingTheory.Adjoin.Basic #align_import data.polynomial.algebra_map from "leanprover-community/mathlib"@"e064a7bf82ad94c3c17b5128bbd860d1ec34874e" noncomputable section open Finset open Polynomial namespace Polynomial universe u v w z variable {R : Type u} {S : Type v} {T : Type w} {A : Type z} {A' B : Type*} {a b : R} {n : ℕ} section CommSemiring variable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B] variable {p q r : R[X]} instance algebraOfAlgebra : Algebra R A[X] where smul_def' r p := toFinsupp_injective <| by dsimp only [RingHom.toFun_eq_coe, RingHom.comp_apply] rw [toFinsupp_smul, toFinsupp_mul, toFinsupp_C] exact Algebra.smul_def' _ _ commutes' r p := toFinsupp_injective <| by dsimp only [RingHom.toFun_eq_coe, RingHom.comp_apply] simp_rw [toFinsupp_mul, toFinsupp_C] convert Algebra.commutes' r p.toFinsupp toRingHom := C.comp (algebraMap R A) #align polynomial.algebra_of_algebra Polynomial.algebraOfAlgebra @[simp] theorem algebraMap_apply (r : R) : algebraMap R A[X] r = C (algebraMap R A r) := rfl #align polynomial.algebra_map_apply Polynomial.algebraMap_apply @[simp] theorem toFinsupp_algebraMap (r : R) : (algebraMap R A[X] r).toFinsupp = algebraMap R _ r := show toFinsupp (C (algebraMap _ _ r)) = _ by rw [toFinsupp_C] rfl #align polynomial.to_finsupp_algebra_map Polynomial.toFinsupp_algebraMap theorem ofFinsupp_algebraMap (r : R) : (⟨algebraMap R _ r⟩ : A[X]) = algebraMap R A[X] r := toFinsupp_injective (toFinsupp_algebraMap _).symm #align polynomial.of_finsupp_algebra_map Polynomial.ofFinsupp_algebraMap theorem C_eq_algebraMap (r : R) : C r = algebraMap R R[X] r := rfl set_option linter.uppercaseLean3 false in #align polynomial.C_eq_algebra_map Polynomial.C_eq_algebraMap @[simp] theorem algebraMap_eq : algebraMap R R[X] = C := rfl @[simps! apply] def CAlgHom : A →ₐ[R] A[X] where toRingHom := C commutes' _ := rfl @[ext 1100] theorem algHom_ext' {f g : A[X] →ₐ[R] B} (hC : f.comp CAlgHom = g.comp CAlgHom) (hX : f X = g X) : f = g := AlgHom.coe_ringHom_injective (ringHom_ext' (congr_arg AlgHom.toRingHom hC) hX) #align polynomial.alg_hom_ext' Polynomial.algHom_ext' variable (R) open AddMonoidAlgebra in @[simps!] def toFinsuppIsoAlg : R[X] ≃ₐ[R] R[ℕ] := { toFinsuppIso R with commutes' := fun r => by dsimp } #align polynomial.to_finsupp_iso_alg Polynomial.toFinsuppIsoAlg variable {R} instance subalgebraNontrivial [Nontrivial A] : Nontrivial (Subalgebra R A[X]) := ⟨⟨⊥, ⊤, by rw [Ne, SetLike.ext_iff, not_forall] refine ⟨X, ?_⟩ simp only [Algebra.mem_bot, not_exists, Set.mem_range, iff_true_iff, Algebra.mem_top, algebraMap_apply, not_forall] intro x rw [ext_iff, not_forall] refine ⟨1, ?_⟩ simp [coeff_C]⟩⟩ @[simp]
Mathlib/Algebra/Polynomial/AlgebraMap.lean
123
127
theorem algHom_eval₂_algebraMap {R A B : Type*} [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B] (p : R[X]) (f : A →ₐ[R] B) (a : A) : f (eval₂ (algebraMap R A) a p) = eval₂ (algebraMap R B) (f a) p := by
simp only [eval₂_eq_sum, sum_def] simp only [f.map_sum, f.map_mul, f.map_pow, eq_intCast, map_intCast, AlgHom.commutes]
import Mathlib.MeasureTheory.Integral.IntegralEqImproper #align_import measure_theory.integral.peak_function from "leanprover-community/mathlib"@"13b0d72fd8533ba459ac66e9a885e35ffabb32b2" open Set Filter MeasureTheory MeasureTheory.Measure TopologicalSpace Metric open scoped Topology ENNReal open Set variable {α E ι : Type*} {hm : MeasurableSpace α} {μ : Measure α} [TopologicalSpace α] [BorelSpace α] [NormedAddCommGroup E] [NormedSpace ℝ E] {g : α → E} {l : Filter ι} {x₀ : α} {s t : Set α} {φ : ι → α → ℝ} {a : E} theorem integrableOn_peak_smul_of_integrableOn_of_tendsto (hs : MeasurableSet s) (h'st : t ∈ 𝓝[s] x₀) (hlφ : ∀ u : Set α, IsOpen u → x₀ ∈ u → TendstoUniformlyOn φ 0 l (s \ u)) (hiφ : Tendsto (fun i ↦ ∫ x in t, φ i x ∂μ) l (𝓝 1)) (h'iφ : ∀ᶠ i in l, AEStronglyMeasurable (φ i) (μ.restrict s)) (hmg : IntegrableOn g s μ) (hcg : Tendsto g (𝓝[s] x₀) (𝓝 a)) : ∀ᶠ i in l, IntegrableOn (fun x => φ i x • g x) s μ := by obtain ⟨u, u_open, x₀u, ut, hu⟩ : ∃ u, IsOpen u ∧ x₀ ∈ u ∧ s ∩ u ⊆ t ∧ ∀ x ∈ u ∩ s, g x ∈ ball a 1 := by rcases mem_nhdsWithin.1 (Filter.inter_mem h'st (hcg (ball_mem_nhds _ zero_lt_one))) with ⟨u, u_open, x₀u, hu⟩ refine ⟨u, u_open, x₀u, ?_, hu.trans inter_subset_right⟩ rw [inter_comm] exact hu.trans inter_subset_left rw [tendsto_iff_norm_sub_tendsto_zero] at hiφ filter_upwards [tendstoUniformlyOn_iff.1 (hlφ u u_open x₀u) 1 zero_lt_one, (tendsto_order.1 hiφ).2 1 zero_lt_one, h'iφ] with i hi h'i h''i have I : IntegrableOn (φ i) t μ := .of_integral_ne_zero (fun h ↦ by simp [h] at h'i) have A : IntegrableOn (fun x => φ i x • g x) (s \ u) μ := by refine Integrable.smul_of_top_right (hmg.mono diff_subset le_rfl) ?_ apply memℒp_top_of_bound (h''i.mono_set diff_subset) 1 filter_upwards [self_mem_ae_restrict (hs.diff u_open.measurableSet)] with x hx simpa only [Pi.zero_apply, dist_zero_left] using (hi x hx).le have B : IntegrableOn (fun x => φ i x • g x) (s ∩ u) μ := by apply Integrable.smul_of_top_left · exact IntegrableOn.mono_set I ut · apply memℒp_top_of_bound (hmg.mono_set inter_subset_left).aestronglyMeasurable (‖a‖ + 1) filter_upwards [self_mem_ae_restrict (hs.inter u_open.measurableSet)] with x hx rw [inter_comm] at hx exact (norm_lt_of_mem_ball (hu x hx)).le convert A.union B simp only [diff_union_inter] #align integrable_on_peak_smul_of_integrable_on_of_continuous_within_at integrableOn_peak_smul_of_integrableOn_of_tendsto @[deprecated (since := "2024-02-20")] alias integrableOn_peak_smul_of_integrableOn_of_continuousWithinAt := integrableOn_peak_smul_of_integrableOn_of_tendsto variable [CompleteSpace E] theorem tendsto_setIntegral_peak_smul_of_integrableOn_of_tendsto_aux (hs : MeasurableSet s) (ht : MeasurableSet t) (hts : t ⊆ s) (h'ts : t ∈ 𝓝[s] x₀) (hnφ : ∀ᶠ i in l, ∀ x ∈ s, 0 ≤ φ i x) (hlφ : ∀ u : Set α, IsOpen u → x₀ ∈ u → TendstoUniformlyOn φ 0 l (s \ u)) (hiφ : Tendsto (fun i ↦ ∫ x in t, φ i x ∂μ) l (𝓝 1)) (h'iφ : ∀ᶠ i in l, AEStronglyMeasurable (φ i) (μ.restrict s)) (hmg : IntegrableOn g s μ) (hcg : Tendsto g (𝓝[s] x₀) (𝓝 0)) : Tendsto (fun i : ι => ∫ x in s, φ i x • g x ∂μ) l (𝓝 0) := by refine Metric.tendsto_nhds.2 fun ε εpos => ?_ obtain ⟨δ, hδ, δpos, δone⟩ : ∃ δ, (δ * ∫ x in s, ‖g x‖ ∂μ) + 2 * δ < ε ∧ 0 < δ ∧ δ < 1:= by have A : Tendsto (fun δ => (δ * ∫ x in s, ‖g x‖ ∂μ) + 2 * δ) (𝓝[>] 0) (𝓝 ((0 * ∫ x in s, ‖g x‖ ∂μ) + 2 * 0)) := by apply Tendsto.mono_left _ nhdsWithin_le_nhds exact (tendsto_id.mul tendsto_const_nhds).add (tendsto_id.const_mul _) rw [zero_mul, zero_add, mul_zero] at A have : Ioo (0 : ℝ) 1 ∈ 𝓝[>] 0 := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, zero_lt_one⟩ rcases (((tendsto_order.1 A).2 ε εpos).and this).exists with ⟨δ, hδ, h'δ⟩ exact ⟨δ, hδ, h'δ.1, h'δ.2⟩ suffices ∀ᶠ i in l, ‖∫ x in s, φ i x • g x ∂μ‖ ≤ (δ * ∫ x in s, ‖g x‖ ∂μ) + 2 * δ by filter_upwards [this] with i hi simp only [dist_zero_right] exact hi.trans_lt hδ obtain ⟨u, u_open, x₀u, ut, hu⟩ : ∃ u, IsOpen u ∧ x₀ ∈ u ∧ s ∩ u ⊆ t ∧ ∀ x ∈ u ∩ s, g x ∈ ball 0 δ := by rcases mem_nhdsWithin.1 (Filter.inter_mem h'ts (hcg (ball_mem_nhds _ δpos))) with ⟨u, u_open, x₀u, hu⟩ refine ⟨u, u_open, x₀u, ?_, hu.trans inter_subset_right⟩ rw [inter_comm] exact hu.trans inter_subset_left filter_upwards [tendstoUniformlyOn_iff.1 (hlφ u u_open x₀u) δ δpos, (tendsto_order.1 (tendsto_iff_norm_sub_tendsto_zero.1 hiφ)).2 δ δpos, hnφ, integrableOn_peak_smul_of_integrableOn_of_tendsto hs h'ts hlφ hiφ h'iφ hmg hcg] with i hi h'i hφpos h''i have I : IntegrableOn (φ i) t μ := by apply Integrable.of_integral_ne_zero (fun h ↦ ?_) simp [h] at h'i linarith have B : ‖∫ x in s ∩ u, φ i x • g x ∂μ‖ ≤ 2 * δ := calc ‖∫ x in s ∩ u, φ i x • g x ∂μ‖ ≤ ∫ x in s ∩ u, ‖φ i x • g x‖ ∂μ := norm_integral_le_integral_norm _ _ ≤ ∫ x in s ∩ u, ‖φ i x‖ * δ ∂μ := by refine setIntegral_mono_on ?_ ?_ (hs.inter u_open.measurableSet) fun x hx => ?_ · exact IntegrableOn.mono_set h''i.norm inter_subset_left · exact IntegrableOn.mono_set (I.norm.mul_const _) ut rw [norm_smul] apply mul_le_mul_of_nonneg_left _ (norm_nonneg _) rw [inter_comm] at hu exact (mem_ball_zero_iff.1 (hu x hx)).le _ ≤ ∫ x in t, ‖φ i x‖ * δ ∂μ := by apply setIntegral_mono_set · exact I.norm.mul_const _ · exact eventually_of_forall fun x => mul_nonneg (norm_nonneg _) δpos.le · exact eventually_of_forall ut _ = ∫ x in t, φ i x * δ ∂μ := by apply setIntegral_congr ht fun x hx => ?_ rw [Real.norm_of_nonneg (hφpos _ (hts hx))] _ = (∫ x in t, φ i x ∂μ) * δ := by rw [integral_mul_right] _ ≤ 2 * δ := by gcongr; linarith [(le_abs_self _).trans h'i.le] have C : ‖∫ x in s \ u, φ i x • g x ∂μ‖ ≤ δ * ∫ x in s, ‖g x‖ ∂μ := calc ‖∫ x in s \ u, φ i x • g x ∂μ‖ ≤ ∫ x in s \ u, ‖φ i x • g x‖ ∂μ := norm_integral_le_integral_norm _ _ ≤ ∫ x in s \ u, δ * ‖g x‖ ∂μ := by refine setIntegral_mono_on ?_ ?_ (hs.diff u_open.measurableSet) fun x hx => ?_ · exact IntegrableOn.mono_set h''i.norm diff_subset · exact IntegrableOn.mono_set (hmg.norm.const_mul _) diff_subset rw [norm_smul] apply mul_le_mul_of_nonneg_right _ (norm_nonneg _) simpa only [Pi.zero_apply, dist_zero_left] using (hi x hx).le _ ≤ δ * ∫ x in s, ‖g x‖ ∂μ := by rw [integral_mul_left] apply mul_le_mul_of_nonneg_left (setIntegral_mono_set hmg.norm _ _) δpos.le · filter_upwards with x using norm_nonneg _ · filter_upwards using diff_subset (s := s) (t := u) calc ‖∫ x in s, φ i x • g x ∂μ‖ = ‖(∫ x in s \ u, φ i x • g x ∂μ) + ∫ x in s ∩ u, φ i x • g x ∂μ‖ := by conv_lhs => rw [← diff_union_inter s u] rw [integral_union disjoint_sdiff_inter (hs.inter u_open.measurableSet) (h''i.mono_set diff_subset) (h''i.mono_set inter_subset_left)] _ ≤ ‖∫ x in s \ u, φ i x • g x ∂μ‖ + ‖∫ x in s ∩ u, φ i x • g x ∂μ‖ := norm_add_le _ _ _ ≤ (δ * ∫ x in s, ‖g x‖ ∂μ) + 2 * δ := add_le_add C B #align tendsto_set_integral_peak_smul_of_integrable_on_of_continuous_within_at_aux tendsto_setIntegral_peak_smul_of_integrableOn_of_tendsto_aux @[deprecated (since := "2024-02-20")] alias tendsto_setIntegral_peak_smul_of_integrableOn_of_continuousWithinAt_aux := tendsto_setIntegral_peak_smul_of_integrableOn_of_tendsto_aux theorem tendsto_setIntegral_peak_smul_of_integrableOn_of_tendsto (hs : MeasurableSet s) {t : Set α} (ht : MeasurableSet t) (hts : t ⊆ s) (h'ts : t ∈ 𝓝[s] x₀) (h't : μ t ≠ ∞) (hnφ : ∀ᶠ i in l, ∀ x ∈ s, 0 ≤ φ i x) (hlφ : ∀ u : Set α, IsOpen u → x₀ ∈ u → TendstoUniformlyOn φ 0 l (s \ u)) (hiφ : Tendsto (fun i ↦ ∫ x in t, φ i x ∂μ) l (𝓝 1)) (h'iφ : ∀ᶠ i in l, AEStronglyMeasurable (φ i) (μ.restrict s)) (hmg : IntegrableOn g s μ) (hcg : Tendsto g (𝓝[s] x₀) (𝓝 a)) : Tendsto (fun i : ι ↦ ∫ x in s, φ i x • g x ∂μ) l (𝓝 a) := by let h := g - t.indicator (fun _ ↦ a) have A : Tendsto (fun i : ι => (∫ x in s, φ i x • h x ∂μ) + (∫ x in t, φ i x ∂μ) • a) l (𝓝 (0 + (1 : ℝ) • a)) := by refine Tendsto.add ?_ (Tendsto.smul hiφ tendsto_const_nhds) apply tendsto_setIntegral_peak_smul_of_integrableOn_of_tendsto_aux hs ht hts h'ts hnφ hlφ hiφ h'iφ · apply hmg.sub simp only [integrable_indicator_iff ht, integrableOn_const, ht, Measure.restrict_apply] right exact lt_of_le_of_lt (measure_mono inter_subset_left) (h't.lt_top) · rw [← sub_self a] apply Tendsto.sub hcg apply tendsto_const_nhds.congr' filter_upwards [h'ts] with x hx using by simp [hx] simp only [one_smul, zero_add] at A refine Tendsto.congr' ?_ A filter_upwards [integrableOn_peak_smul_of_integrableOn_of_tendsto hs h'ts hlφ hiφ h'iφ hmg hcg, (tendsto_order.1 (tendsto_iff_norm_sub_tendsto_zero.1 hiφ)).2 1 zero_lt_one] with i hi h'i simp only [h, Pi.sub_apply, smul_sub, ← indicator_smul_apply] rw [integral_sub hi, setIntegral_indicator ht, inter_eq_right.mpr hts, integral_smul_const, sub_add_cancel] rw [integrable_indicator_iff ht] apply Integrable.smul_const rw [restrict_restrict ht, inter_eq_left.mpr hts] exact .of_integral_ne_zero (fun h ↦ by simp [h] at h'i) #align tendsto_set_integral_peak_smul_of_integrable_on_of_continuous_within_at tendsto_setIntegral_peak_smul_of_integrableOn_of_tendsto @[deprecated (since := "2024-02-20")] alias tendsto_setIntegral_peak_smul_of_integrableOn_of_continuousWithinAt := tendsto_setIntegral_peak_smul_of_integrableOn_of_tendsto theorem tendsto_integral_peak_smul_of_integrable_of_tendsto {t : Set α} (ht : MeasurableSet t) (h'ts : t ∈ 𝓝 x₀) (h't : μ t ≠ ∞) (hnφ : ∀ᶠ i in l, ∀ x, 0 ≤ φ i x) (hlφ : ∀ u : Set α, IsOpen u → x₀ ∈ u → TendstoUniformlyOn φ 0 l uᶜ) (hiφ : Tendsto (fun i ↦ ∫ x in t, φ i x ∂μ) l (𝓝 1)) (h'iφ : ∀ᶠ i in l, AEStronglyMeasurable (φ i) μ) (hmg : Integrable g μ) (hcg : Tendsto g (𝓝 x₀) (𝓝 a)) : Tendsto (fun i : ι ↦ ∫ x, φ i x • g x ∂μ) l (𝓝 a) := by suffices Tendsto (fun i : ι ↦ ∫ x in univ, φ i x • g x ∂μ) l (𝓝 a) by simpa exact tendsto_setIntegral_peak_smul_of_integrableOn_of_tendsto MeasurableSet.univ ht (x₀ := x₀) (subset_univ _) (by simpa [nhdsWithin_univ]) h't (by simpa) (by simpa [← compl_eq_univ_diff] using hlφ) hiφ (by simpa) (by simpa) (by simpa [nhdsWithin_univ]) theorem tendsto_setIntegral_pow_smul_of_unique_maximum_of_isCompact_of_measure_nhdsWithin_pos [MetrizableSpace α] [IsLocallyFiniteMeasure μ] (hs : IsCompact s) (hμ : ∀ u, IsOpen u → x₀ ∈ u → 0 < μ (u ∩ s)) {c : α → ℝ} (hc : ContinuousOn c s) (h'c : ∀ y ∈ s, y ≠ x₀ → c y < c x₀) (hnc : ∀ x ∈ s, 0 ≤ c x) (hnc₀ : 0 < c x₀) (h₀ : x₀ ∈ s) (hmg : IntegrableOn g s μ) (hcg : ContinuousWithinAt g s x₀) : Tendsto (fun n : ℕ => (∫ x in s, c x ^ n ∂μ)⁻¹ • ∫ x in s, c x ^ n • g x ∂μ) atTop (𝓝 (g x₀)) := by let φ : ℕ → α → ℝ := fun n x => (∫ x in s, c x ^ n ∂μ)⁻¹ * c x ^ n have hnφ : ∀ n, ∀ x ∈ s, 0 ≤ φ n x := by intro n x hx apply mul_nonneg (inv_nonneg.2 _) (pow_nonneg (hnc x hx) _) exact setIntegral_nonneg hs.measurableSet fun x hx => pow_nonneg (hnc x hx) _ have I : ∀ n, IntegrableOn (fun x => c x ^ n) s μ := fun n => ContinuousOn.integrableOn_compact hs (hc.pow n) have J : ∀ n, 0 ≤ᵐ[μ.restrict s] fun x : α => c x ^ n := by intro n filter_upwards [ae_restrict_mem hs.measurableSet] with x hx exact pow_nonneg (hnc x hx) n have P : ∀ n, (0 : ℝ) < ∫ x in s, c x ^ n ∂μ := by intro n refine (setIntegral_pos_iff_support_of_nonneg_ae (J n) (I n)).2 ?_ obtain ⟨u, u_open, x₀_u, hu⟩ : ∃ u : Set α, IsOpen u ∧ x₀ ∈ u ∧ u ∩ s ⊆ c ⁻¹' Ioi 0 := _root_.continuousOn_iff.1 hc x₀ h₀ (Ioi (0 : ℝ)) isOpen_Ioi hnc₀ apply (hμ u u_open x₀_u).trans_le exact measure_mono fun x hx => ⟨ne_of_gt (pow_pos (a := c x) (hu hx) _), hx.2⟩ have hiφ : ∀ n, ∫ x in s, φ n x ∂μ = 1 := fun n => by rw [integral_mul_left, inv_mul_cancel (P n).ne'] have A : ∀ u : Set α, IsOpen u → x₀ ∈ u → TendstoUniformlyOn φ 0 atTop (s \ u) := by intro u u_open x₀u obtain ⟨t, t_pos, tx₀, ht⟩ : ∃ t, 0 ≤ t ∧ t < c x₀ ∧ ∀ x ∈ s \ u, c x ≤ t := by rcases eq_empty_or_nonempty (s \ u) with (h | h) · exact ⟨0, le_rfl, hnc₀, by simp only [h, mem_empty_iff_false, IsEmpty.forall_iff, imp_true_iff]⟩ obtain ⟨x, hx, h'x⟩ : ∃ x ∈ s \ u, ∀ y ∈ s \ u, c y ≤ c x := IsCompact.exists_isMaxOn (hs.diff u_open) h (hc.mono diff_subset) refine ⟨c x, hnc x hx.1, h'c x hx.1 ?_, h'x⟩ rintro rfl exact hx.2 x₀u obtain ⟨t', tt', t'x₀⟩ : ∃ t', t < t' ∧ t' < c x₀ := exists_between tx₀ have t'_pos : 0 < t' := t_pos.trans_lt tt' obtain ⟨v, v_open, x₀_v, hv⟩ : ∃ v : Set α, IsOpen v ∧ x₀ ∈ v ∧ v ∩ s ⊆ c ⁻¹' Ioi t' := _root_.continuousOn_iff.1 hc x₀ h₀ (Ioi t') isOpen_Ioi t'x₀ have M : ∀ n, ∀ x ∈ s \ u, φ n x ≤ (μ (v ∩ s)).toReal⁻¹ * (t / t') ^ n := by intro n x hx have B : t' ^ n * (μ (v ∩ s)).toReal ≤ ∫ y in s, c y ^ n ∂μ := calc t' ^ n * (μ (v ∩ s)).toReal = ∫ _ in v ∩ s, t' ^ n ∂μ := by simp only [integral_const, Measure.restrict_apply, MeasurableSet.univ, univ_inter, Algebra.id.smul_eq_mul, mul_comm] _ ≤ ∫ y in v ∩ s, c y ^ n ∂μ := by apply setIntegral_mono_on _ _ (v_open.measurableSet.inter hs.measurableSet) _ · apply integrableOn_const.2 (Or.inr _) exact lt_of_le_of_lt (measure_mono inter_subset_right) hs.measure_lt_top · exact (I n).mono inter_subset_right le_rfl · intro x hx exact pow_le_pow_left t'_pos.le (le_of_lt (hv hx)) _ _ ≤ ∫ y in s, c y ^ n ∂μ := setIntegral_mono_set (I n) (J n) (eventually_of_forall inter_subset_right) simp_rw [φ, ← div_eq_inv_mul, div_pow, div_div] apply div_le_div (pow_nonneg t_pos n) _ _ B · exact pow_le_pow_left (hnc _ hx.1) (ht x hx) _ · apply mul_pos (pow_pos (t_pos.trans_lt tt') _) (ENNReal.toReal_pos (hμ v v_open x₀_v).ne' _) have : μ (v ∩ s) ≤ μ s := measure_mono inter_subset_right exact ne_of_lt (lt_of_le_of_lt this hs.measure_lt_top) have N : Tendsto (fun n => (μ (v ∩ s)).toReal⁻¹ * (t / t') ^ n) atTop (𝓝 ((μ (v ∩ s)).toReal⁻¹ * 0)) := by apply Tendsto.mul tendsto_const_nhds _ apply tendsto_pow_atTop_nhds_zero_of_lt_one (div_nonneg t_pos t'_pos.le) exact (div_lt_one t'_pos).2 tt' rw [mul_zero] at N refine tendstoUniformlyOn_iff.2 fun ε εpos => ?_ filter_upwards [(tendsto_order.1 N).2 ε εpos] with n hn x hx simp only [Pi.zero_apply, dist_zero_left, Real.norm_of_nonneg (hnφ n x hx.1)] exact (M n x hx).trans_lt hn have : Tendsto (fun i : ℕ => ∫ x : α in s, φ i x • g x ∂μ) atTop (𝓝 (g x₀)) := by have B : Tendsto (fun i ↦ ∫ (x : α) in s, φ i x ∂μ) atTop (𝓝 1) := tendsto_const_nhds.congr (fun n ↦ (hiφ n).symm) have C : ∀ᶠ (i : ℕ) in atTop, AEStronglyMeasurable (fun x ↦ φ i x) (μ.restrict s) := by apply eventually_of_forall (fun n ↦ ((I n).const_mul _).aestronglyMeasurable) exact tendsto_setIntegral_peak_smul_of_integrableOn_of_tendsto hs.measurableSet hs.measurableSet (Subset.rfl) (self_mem_nhdsWithin) hs.measure_lt_top.ne (eventually_of_forall hnφ) A B C hmg hcg convert this simp_rw [φ, ← smul_smul, integral_smul] #align tendsto_set_integral_pow_smul_of_unique_maximum_of_is_compact_of_measure_nhds_within_pos tendsto_setIntegral_pow_smul_of_unique_maximum_of_isCompact_of_measure_nhdsWithin_pos theorem tendsto_setIntegral_pow_smul_of_unique_maximum_of_isCompact_of_integrableOn [MetrizableSpace α] [IsLocallyFiniteMeasure μ] [IsOpenPosMeasure μ] (hs : IsCompact s) {c : α → ℝ} (hc : ContinuousOn c s) (h'c : ∀ y ∈ s, y ≠ x₀ → c y < c x₀) (hnc : ∀ x ∈ s, 0 ≤ c x) (hnc₀ : 0 < c x₀) (h₀ : x₀ ∈ closure (interior s)) (hmg : IntegrableOn g s μ) (hcg : ContinuousWithinAt g s x₀) : Tendsto (fun n : ℕ => (∫ x in s, c x ^ n ∂μ)⁻¹ • ∫ x in s, c x ^ n • g x ∂μ) atTop (𝓝 (g x₀)) := by have : x₀ ∈ s := by rw [← hs.isClosed.closure_eq]; exact closure_mono interior_subset h₀ apply tendsto_setIntegral_pow_smul_of_unique_maximum_of_isCompact_of_measure_nhdsWithin_pos hs _ hc h'c hnc hnc₀ this hmg hcg intro u u_open x₀_u calc 0 < μ (u ∩ interior s) := (u_open.inter isOpen_interior).measure_pos μ (_root_.mem_closure_iff.1 h₀ u u_open x₀_u) _ ≤ μ (u ∩ s) := by gcongr; apply interior_subset #align tendsto_set_integral_pow_smul_of_unique_maximum_of_is_compact_of_integrable_on tendsto_setIntegral_pow_smul_of_unique_maximum_of_isCompact_of_integrableOn
Mathlib/MeasureTheory/Integral/PeakFunction.lean
388
396
theorem tendsto_setIntegral_pow_smul_of_unique_maximum_of_isCompact_of_continuousOn [MetrizableSpace α] [IsLocallyFiniteMeasure μ] [IsOpenPosMeasure μ] (hs : IsCompact s) {c : α → ℝ} (hc : ContinuousOn c s) (h'c : ∀ y ∈ s, y ≠ x₀ → c y < c x₀) (hnc : ∀ x ∈ s, 0 ≤ c x) (hnc₀ : 0 < c x₀) (h₀ : x₀ ∈ closure (interior s)) (hmg : ContinuousOn g s) : Tendsto (fun n : ℕ => (∫ x in s, c x ^ n ∂μ)⁻¹ • ∫ x in s, c x ^ n • g x ∂μ) atTop (𝓝 (g x₀)) := haveI : x₀ ∈ s := by
rw [← hs.isClosed.closure_eq]; exact closure_mono interior_subset h₀ tendsto_setIntegral_pow_smul_of_unique_maximum_of_isCompact_of_integrableOn hs hc h'c hnc hnc₀ h₀ (hmg.integrableOn_compact hs) (hmg x₀ this)
import Mathlib.Data.Set.Function import Mathlib.Order.Interval.Set.OrdConnected #align_import data.set.intervals.proj_Icc from "leanprover-community/mathlib"@"4e24c4bfcff371c71f7ba22050308aa17815626c" variable {α β : Type*} [LinearOrder α] open Function namespace Set def projIci (a x : α) : Ici a := ⟨max a x, le_max_left _ _⟩ #align set.proj_Ici Set.projIci def projIic (b x : α) : Iic b := ⟨min b x, min_le_left _ _⟩ #align set.proj_Iic Set.projIic def projIcc (a b : α) (h : a ≤ b) (x : α) : Icc a b := ⟨max a (min b x), le_max_left _ _, max_le h (min_le_left _ _)⟩ #align set.proj_Icc Set.projIcc variable {a b : α} (h : a ≤ b) {x : α} @[norm_cast] theorem coe_projIci (a x : α) : (projIci a x : α) = max a x := rfl #align set.coe_proj_Ici Set.coe_projIci @[norm_cast] theorem coe_projIic (b x : α) : (projIic b x : α) = min b x := rfl #align set.coe_proj_Iic Set.coe_projIic @[norm_cast] theorem coe_projIcc (a b : α) (h : a ≤ b) (x : α) : (projIcc a b h x : α) = max a (min b x) := rfl #align set.coe_proj_Icc Set.coe_projIcc theorem projIci_of_le (hx : x ≤ a) : projIci a x = ⟨a, le_rfl⟩ := Subtype.ext <| max_eq_left hx #align set.proj_Ici_of_le Set.projIci_of_le theorem projIic_of_le (hx : b ≤ x) : projIic b x = ⟨b, le_rfl⟩ := Subtype.ext <| min_eq_left hx #align set.proj_Iic_of_le Set.projIic_of_le theorem projIcc_of_le_left (hx : x ≤ a) : projIcc a b h x = ⟨a, left_mem_Icc.2 h⟩ := by simp [projIcc, hx, hx.trans h] #align set.proj_Icc_of_le_left Set.projIcc_of_le_left theorem projIcc_of_right_le (hx : b ≤ x) : projIcc a b h x = ⟨b, right_mem_Icc.2 h⟩ := by simp [projIcc, hx, h] #align set.proj_Icc_of_right_le Set.projIcc_of_right_le @[simp] theorem projIci_self (a : α) : projIci a a = ⟨a, le_rfl⟩ := projIci_of_le le_rfl #align set.proj_Ici_self Set.projIci_self @[simp] theorem projIic_self (b : α) : projIic b b = ⟨b, le_rfl⟩ := projIic_of_le le_rfl #align set.proj_Iic_self Set.projIic_self @[simp] theorem projIcc_left : projIcc a b h a = ⟨a, left_mem_Icc.2 h⟩ := projIcc_of_le_left h le_rfl #align set.proj_Icc_left Set.projIcc_left @[simp] theorem projIcc_right : projIcc a b h b = ⟨b, right_mem_Icc.2 h⟩ := projIcc_of_right_le h le_rfl #align set.proj_Icc_right Set.projIcc_right theorem projIci_eq_self : projIci a x = ⟨a, le_rfl⟩ ↔ x ≤ a := by simp [projIci, Subtype.ext_iff] #align set.proj_Ici_eq_self Set.projIci_eq_self theorem projIic_eq_self : projIic b x = ⟨b, le_rfl⟩ ↔ b ≤ x := by simp [projIic, Subtype.ext_iff] #align set.proj_Iic_eq_self Set.projIic_eq_self theorem projIcc_eq_left (h : a < b) : projIcc a b h.le x = ⟨a, left_mem_Icc.mpr h.le⟩ ↔ x ≤ a := by simp [projIcc, Subtype.ext_iff, h.not_le] #align set.proj_Icc_eq_left Set.projIcc_eq_left theorem projIcc_eq_right (h : a < b) : projIcc a b h.le x = ⟨b, right_mem_Icc.2 h.le⟩ ↔ b ≤ x := by simp [projIcc, Subtype.ext_iff, max_min_distrib_left, h.le, h.not_le] #align set.proj_Icc_eq_right Set.projIcc_eq_right theorem projIci_of_mem (hx : x ∈ Ici a) : projIci a x = ⟨x, hx⟩ := by simpa [projIci] #align set.proj_Ici_of_mem Set.projIci_of_mem theorem projIic_of_mem (hx : x ∈ Iic b) : projIic b x = ⟨x, hx⟩ := by simpa [projIic] #align set.proj_Iic_of_mem Set.projIic_of_mem
Mathlib/Order/Interval/Set/ProjIcc.lean
119
120
theorem projIcc_of_mem (hx : x ∈ Icc a b) : projIcc a b h x = ⟨x, hx⟩ := by
simp [projIcc, hx.1, hx.2]
import Mathlib.Geometry.Euclidean.Sphere.Basic import Mathlib.LinearAlgebra.AffineSpace.FiniteDimensional import Mathlib.Tactic.DeriveFintype #align_import geometry.euclidean.circumcenter from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0" noncomputable section open scoped Classical open RealInnerProductSpace namespace EuclideanGeometry variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P] open AffineSubspace theorem dist_eq_iff_dist_orthogonalProjection_eq {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {p1 p2 : P} (p3 : P) (hp1 : p1 ∈ s) (hp2 : p2 ∈ s) : dist p1 p3 = dist p2 p3 ↔ dist p1 (orthogonalProjection s p3) = dist p2 (orthogonalProjection s p3) := by rw [← mul_self_inj_of_nonneg dist_nonneg dist_nonneg, ← mul_self_inj_of_nonneg dist_nonneg dist_nonneg, dist_sq_eq_dist_orthogonalProjection_sq_add_dist_orthogonalProjection_sq p3 hp1, dist_sq_eq_dist_orthogonalProjection_sq_add_dist_orthogonalProjection_sq p3 hp2] simp #align euclidean_geometry.dist_eq_iff_dist_orthogonal_projection_eq EuclideanGeometry.dist_eq_iff_dist_orthogonalProjection_eq theorem dist_set_eq_iff_dist_orthogonalProjection_eq {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {ps : Set P} (hps : ps ⊆ s) (p : P) : (Set.Pairwise ps fun p1 p2 => dist p1 p = dist p2 p) ↔ Set.Pairwise ps fun p1 p2 => dist p1 (orthogonalProjection s p) = dist p2 (orthogonalProjection s p) := ⟨fun h _ hp1 _ hp2 hne => (dist_eq_iff_dist_orthogonalProjection_eq p (hps hp1) (hps hp2)).1 (h hp1 hp2 hne), fun h _ hp1 _ hp2 hne => (dist_eq_iff_dist_orthogonalProjection_eq p (hps hp1) (hps hp2)).2 (h hp1 hp2 hne)⟩ #align euclidean_geometry.dist_set_eq_iff_dist_orthogonal_projection_eq EuclideanGeometry.dist_set_eq_iff_dist_orthogonalProjection_eq theorem exists_dist_eq_iff_exists_dist_orthogonalProjection_eq {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {ps : Set P} (hps : ps ⊆ s) (p : P) : (∃ r, ∀ p1 ∈ ps, dist p1 p = r) ↔ ∃ r, ∀ p1 ∈ ps, dist p1 ↑(orthogonalProjection s p) = r := by have h := dist_set_eq_iff_dist_orthogonalProjection_eq hps p simp_rw [Set.pairwise_eq_iff_exists_eq] at h exact h #align euclidean_geometry.exists_dist_eq_iff_exists_dist_orthogonal_projection_eq EuclideanGeometry.exists_dist_eq_iff_exists_dist_orthogonalProjection_eq
Mathlib/Geometry/Euclidean/Circumcenter.lean
91
179
theorem existsUnique_dist_eq_of_insert {s : AffineSubspace ℝ P} [HasOrthogonalProjection s.direction] {ps : Set P} (hnps : ps.Nonempty) {p : P} (hps : ps ⊆ s) (hp : p ∉ s) (hu : ∃! cs : Sphere P, cs.center ∈ s ∧ ps ⊆ (cs : Set P)) : ∃! cs₂ : Sphere P, cs₂.center ∈ affineSpan ℝ (insert p (s : Set P)) ∧ insert p ps ⊆ (cs₂ : Set P) := by
haveI : Nonempty s := Set.Nonempty.to_subtype (hnps.mono hps) rcases hu with ⟨⟨cc, cr⟩, ⟨hcc, hcr⟩, hcccru⟩ simp only at hcc hcr hcccru let x := dist cc (orthogonalProjection s p) let y := dist p (orthogonalProjection s p) have hy0 : y ≠ 0 := dist_orthogonalProjection_ne_zero_of_not_mem hp let ycc₂ := (x * x + y * y - cr * cr) / (2 * y) let cc₂ := (ycc₂ / y) • (p -ᵥ orthogonalProjection s p : V) +ᵥ cc let cr₂ := √(cr * cr + ycc₂ * ycc₂) use ⟨cc₂, cr₂⟩ simp (config := { zeta := false, proj := false }) only have hpo : p = (1 : ℝ) • (p -ᵥ orthogonalProjection s p : V) +ᵥ (orthogonalProjection s p : P) := by simp constructor · constructor · refine vadd_mem_of_mem_direction ?_ (mem_affineSpan ℝ (Set.mem_insert_of_mem _ hcc)) rw [direction_affineSpan] exact Submodule.smul_mem _ _ (vsub_mem_vectorSpan ℝ (Set.mem_insert _ _) (Set.mem_insert_of_mem _ (orthogonalProjection_mem _))) · intro p1 hp1 rw [Sphere.mem_coe, mem_sphere, ← mul_self_inj_of_nonneg dist_nonneg (Real.sqrt_nonneg _), Real.mul_self_sqrt (add_nonneg (mul_self_nonneg _) (mul_self_nonneg _))] cases' hp1 with hp1 hp1 · rw [hp1] rw [hpo, dist_sq_smul_orthogonal_vadd_smul_orthogonal_vadd (orthogonalProjection_mem p) hcc _ _ (vsub_orthogonalProjection_mem_direction_orthogonal s p), ← dist_eq_norm_vsub V p, dist_comm _ cc] field_simp [ycc₂, hy0] ring · rw [dist_sq_eq_dist_orthogonalProjection_sq_add_dist_orthogonalProjection_sq _ (hps hp1), orthogonalProjection_vadd_smul_vsub_orthogonalProjection _ _ hcc, Subtype.coe_mk, dist_of_mem_subset_mk_sphere hp1 hcr, dist_eq_norm_vsub V cc₂ cc, vadd_vsub, norm_smul, ← dist_eq_norm_vsub V, Real.norm_eq_abs, abs_div, abs_of_nonneg dist_nonneg, div_mul_cancel₀ _ hy0, abs_mul_abs_self] · rintro ⟨cc₃, cr₃⟩ ⟨hcc₃, hcr₃⟩ simp only at hcc₃ hcr₃ obtain ⟨t₃, cc₃', hcc₃', hcc₃''⟩ : ∃ r : ℝ, ∃ p0 ∈ s, cc₃ = r • (p -ᵥ ↑((orthogonalProjection s) p)) +ᵥ p0 := by rwa [mem_affineSpan_insert_iff (orthogonalProjection_mem p)] at hcc₃ have hcr₃' : ∃ r, ∀ p1 ∈ ps, dist p1 cc₃ = r := ⟨cr₃, fun p1 hp1 => dist_of_mem_subset_mk_sphere (Set.mem_insert_of_mem _ hp1) hcr₃⟩ rw [exists_dist_eq_iff_exists_dist_orthogonalProjection_eq hps cc₃, hcc₃'', orthogonalProjection_vadd_smul_vsub_orthogonalProjection _ _ hcc₃'] at hcr₃' cases' hcr₃' with cr₃' hcr₃' have hu := hcccru ⟨cc₃', cr₃'⟩ simp only at hu replace hu := hu ⟨hcc₃', hcr₃'⟩ -- Porting note: was -- cases' hu with hucc hucr -- substs hucc hucr cases' hu have hcr₃val : cr₃ = √(cr * cr + t₃ * y * (t₃ * y)) := by cases' hnps with p0 hp0 have h' : ↑(⟨cc, hcc₃'⟩ : s) = cc := rfl rw [← dist_of_mem_subset_mk_sphere (Set.mem_insert_of_mem _ hp0) hcr₃, hcc₃'', ← mul_self_inj_of_nonneg dist_nonneg (Real.sqrt_nonneg _), Real.mul_self_sqrt (add_nonneg (mul_self_nonneg _) (mul_self_nonneg _)), dist_sq_eq_dist_orthogonalProjection_sq_add_dist_orthogonalProjection_sq _ (hps hp0), orthogonalProjection_vadd_smul_vsub_orthogonalProjection _ _ hcc₃', h', dist_of_mem_subset_mk_sphere hp0 hcr, dist_eq_norm_vsub V _ cc, vadd_vsub, norm_smul, ← dist_eq_norm_vsub V p, Real.norm_eq_abs, ← mul_assoc, mul_comm _ |t₃|, ← mul_assoc, abs_mul_abs_self] ring replace hcr₃ := dist_of_mem_subset_mk_sphere (Set.mem_insert _ _) hcr₃ rw [hpo, hcc₃'', hcr₃val, ← mul_self_inj_of_nonneg dist_nonneg (Real.sqrt_nonneg _), dist_sq_smul_orthogonal_vadd_smul_orthogonal_vadd (orthogonalProjection_mem p) hcc₃' _ _ (vsub_orthogonalProjection_mem_direction_orthogonal s p), dist_comm, ← dist_eq_norm_vsub V p, Real.mul_self_sqrt (add_nonneg (mul_self_nonneg _) (mul_self_nonneg _))] at hcr₃ change x * x + _ * (y * y) = _ at hcr₃ rw [show x * x + (1 - t₃) * (1 - t₃) * (y * y) = x * x + y * y - 2 * y * (t₃ * y) + t₃ * y * (t₃ * y) by ring, add_left_inj] at hcr₃ have ht₃ : t₃ = ycc₂ / y := by field_simp [ycc₂, ← hcr₃, hy0] subst ht₃ change cc₃ = cc₂ at hcc₃'' congr rw [hcr₃val] congr 2 field_simp [hy0]
import Mathlib.Topology.CompactOpen import Mathlib.Topology.Sets.Closeds open Function Set Filter TopologicalSpace open scoped Topology variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [CompactSpace Y]
Mathlib/Topology/ClopenBox.lean
36
44
theorem TopologicalSpace.Clopens.exists_prod_subset (W : Clopens (X × Y)) {a : X × Y} (h : a ∈ W) : ∃ U : Clopens X, a.1 ∈ U ∧ ∃ V : Clopens Y, a.2 ∈ V ∧ U ×ˢ V ≤ W := by
have hp : Continuous (fun y : Y ↦ (a.1, y)) := Continuous.Prod.mk _ let V : Set Y := {y | (a.1, y) ∈ W} have hV : IsCompact V := (W.2.1.preimage hp).isCompact let U : Set X := {x | MapsTo (Prod.mk x) V W} have hUV : U ×ˢ V ⊆ W := fun ⟨_, _⟩ hw ↦ hw.1 hw.2 exact ⟨⟨U, (ContinuousMap.isClopen_setOf_mapsTo hV W.2).preimage (ContinuousMap.id (X × Y)).curry.2⟩, by simp [U, V, MapsTo], ⟨V, W.2.preimage hp⟩, h, hUV⟩