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.Algebra.Group.Submonoid.Membership import Mathlib.Algebra.Order.BigOperators.Group.List import Mathlib.Data.Set.Pointwise.SMul import Mathlib.Order.WellFoundedSet #align_import group_theory.submonoid.pointwise from "leanprover-community/mathlib"@"2bbc7e3884ba234309d2a43b19144105a753292e" open Set Pointwise variable {α : Type*} {G : Type*} {M : Type*} {R : Type*} {A : Type*} variable [Monoid M] [AddMonoid A] namespace Submonoid variable {s t u : Set M} @[to_additive] theorem mul_subset {S : Submonoid M} (hs : s ⊆ S) (ht : t ⊆ S) : s * t ⊆ S := mul_subset_iff.2 fun _x hx _y hy ↦ mul_mem (hs hx) (ht hy) #align submonoid.mul_subset Submonoid.mul_subset #align add_submonoid.add_subset AddSubmonoid.add_subset @[to_additive] theorem mul_subset_closure (hs : s ⊆ u) (ht : t ⊆ u) : s * t ⊆ Submonoid.closure u := mul_subset (Subset.trans hs Submonoid.subset_closure) (Subset.trans ht Submonoid.subset_closure) #align submonoid.mul_subset_closure Submonoid.mul_subset_closure #align add_submonoid.add_subset_closure AddSubmonoid.add_subset_closure @[to_additive] theorem coe_mul_self_eq (s : Submonoid M) : (s : Set M) * s = s := by ext x refine ⟨?_, fun h => ⟨x, h, 1, s.one_mem, mul_one x⟩⟩ rintro ⟨a, ha, b, hb, rfl⟩ exact s.mul_mem ha hb #align submonoid.coe_mul_self_eq Submonoid.coe_mul_self_eq #align add_submonoid.coe_add_self_eq AddSubmonoid.coe_add_self_eq @[to_additive] theorem closure_mul_le (S T : Set M) : closure (S * T) ≤ closure S ⊔ closure T := sInf_le fun _x ⟨_s, hs, _t, ht, hx⟩ => hx ▸ (closure S ⊔ closure T).mul_mem (SetLike.le_def.mp le_sup_left <| subset_closure hs) (SetLike.le_def.mp le_sup_right <| subset_closure ht) #align submonoid.closure_mul_le Submonoid.closure_mul_le #align add_submonoid.closure_add_le AddSubmonoid.closure_add_le @[to_additive] theorem sup_eq_closure_mul (H K : Submonoid M) : H ⊔ K = closure ((H : Set M) * (K : Set M)) := le_antisymm (sup_le (fun h hh => subset_closure ⟨h, hh, 1, K.one_mem, mul_one h⟩) fun k hk => subset_closure ⟨1, H.one_mem, k, hk, one_mul k⟩) ((closure_mul_le _ _).trans <| by rw [closure_eq, closure_eq]) #align submonoid.sup_eq_closure Submonoid.sup_eq_closure_mul #align add_submonoid.sup_eq_closure AddSubmonoid.sup_eq_closure_add @[to_additive]
Mathlib/Algebra/Group/Submonoid/Pointwise.lean
98
107
theorem pow_smul_mem_closure_smul {N : Type*} [CommMonoid N] [MulAction M N] [IsScalarTower M N N] (r : M) (s : Set N) {x : N} (hx : x ∈ closure s) : ∃ n : ℕ, r ^ n • x ∈ closure (r • s) := by
refine @closure_induction N _ s (fun x : N => ∃ n : ℕ, r ^ n • x ∈ closure (r • s)) _ hx ?_ ?_ ?_ · intro x hx exact ⟨1, subset_closure ⟨_, hx, by rw [pow_one]⟩⟩ · exact ⟨0, by simpa using one_mem _⟩ · rintro x y ⟨nx, hx⟩ ⟨ny, hy⟩ use ny + nx rw [pow_add, mul_smul, ← smul_mul_assoc, mul_comm, ← smul_mul_assoc] exact mul_mem hy hx
import Mathlib.LinearAlgebra.Matrix.BilinearForm import Mathlib.LinearAlgebra.Matrix.Charpoly.Minpoly import Mathlib.LinearAlgebra.Determinant import Mathlib.LinearAlgebra.FiniteDimensional import Mathlib.LinearAlgebra.Vandermonde import Mathlib.LinearAlgebra.Trace import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure import Mathlib.FieldTheory.PrimitiveElement import Mathlib.FieldTheory.Galois import Mathlib.RingTheory.PowerBasis import Mathlib.FieldTheory.Minpoly.MinpolyDiv #align_import ring_theory.trace from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" universe u v w z variable {R S T : Type*} [CommRing R] [CommRing S] [CommRing T] variable [Algebra R S] [Algebra R T] variable {K L : Type*} [Field K] [Field L] [Algebra K L] variable {ι κ : Type w} [Fintype ι] open FiniteDimensional open LinearMap (BilinForm) open LinearMap open Matrix open scoped Matrix namespace Algebra variable (b : Basis ι R S) variable (R S) noncomputable def trace : S →ₗ[R] R := (LinearMap.trace R S).comp (lmul R S).toLinearMap #align algebra.trace Algebra.trace variable {S} -- Not a `simp` lemma since there are more interesting ways to rewrite `trace R S x`, -- for example `trace_trace` theorem trace_apply (x) : trace R S x = LinearMap.trace R S (lmul R S x) := rfl #align algebra.trace_apply Algebra.trace_apply theorem trace_eq_zero_of_not_exists_basis (h : ¬∃ s : Finset S, Nonempty (Basis s R S)) : trace R S = 0 := by ext s; simp [trace_apply, LinearMap.trace, h] #align algebra.trace_eq_zero_of_not_exists_basis Algebra.trace_eq_zero_of_not_exists_basis variable {R} -- Can't be a `simp` lemma because it depends on a choice of basis theorem trace_eq_matrix_trace [DecidableEq ι] (b : Basis ι R S) (s : S) : trace R S s = Matrix.trace (Algebra.leftMulMatrix b s) := by rw [trace_apply, LinearMap.trace_eq_matrix_trace _ b, ← toMatrix_lmul_eq]; rfl #align algebra.trace_eq_matrix_trace Algebra.trace_eq_matrix_trace theorem trace_algebraMap_of_basis (x : R) : trace R S (algebraMap R S x) = Fintype.card ι • x := by haveI := Classical.decEq ι rw [trace_apply, LinearMap.trace_eq_matrix_trace R b, Matrix.trace] convert Finset.sum_const x simp [-coe_lmul_eq_mul] #align algebra.trace_algebra_map_of_basis Algebra.trace_algebraMap_of_basis @[simp] theorem trace_algebraMap (x : K) : trace K L (algebraMap K L x) = finrank K L • x := by by_cases H : ∃ s : Finset L, Nonempty (Basis s K L) · rw [trace_algebraMap_of_basis H.choose_spec.some, finrank_eq_card_basis H.choose_spec.some] · simp [trace_eq_zero_of_not_exists_basis K H, finrank_eq_zero_of_not_exists_basis_finset H] #align algebra.trace_algebra_map Algebra.trace_algebraMap theorem trace_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι] [Finite κ] (b : Basis ι R S) (c : Basis κ S T) (x : T) : trace R S (trace S T x) = trace R T x := by haveI := Classical.decEq ι haveI := Classical.decEq κ cases nonempty_fintype ι cases nonempty_fintype κ rw [trace_eq_matrix_trace (b.smul c), trace_eq_matrix_trace b, trace_eq_matrix_trace c, Matrix.trace, Matrix.trace, Matrix.trace, ← Finset.univ_product_univ, Finset.sum_product] refine Finset.sum_congr rfl fun i _ ↦ ?_ simp only [AlgHom.map_sum, smul_leftMulMatrix, Finset.sum_apply, Matrix.diag, Finset.sum_apply i (Finset.univ : Finset κ) fun y => leftMulMatrix b (leftMulMatrix c x y y)] #align algebra.trace_trace_of_basis Algebra.trace_trace_of_basis theorem trace_comp_trace_of_basis [Algebra S T] [IsScalarTower R S T] {ι κ : Type*} [Finite ι] [Finite κ] (b : Basis ι R S) (c : Basis κ S T) : (trace R S).comp ((trace S T).restrictScalars R) = trace R T := by ext rw [LinearMap.comp_apply, LinearMap.restrictScalars_apply, trace_trace_of_basis b c] #align algebra.trace_comp_trace_of_basis Algebra.trace_comp_trace_of_basis @[simp] theorem trace_trace [Algebra K T] [Algebra L T] [IsScalarTower K L T] [FiniteDimensional K L] [FiniteDimensional L T] (x : T) : trace K L (trace L T x) = trace K T x := trace_trace_of_basis (Basis.ofVectorSpace K L) (Basis.ofVectorSpace L T) x #align algebra.trace_trace Algebra.trace_trace @[simp] theorem trace_comp_trace [Algebra K T] [Algebra L T] [IsScalarTower K L T] [FiniteDimensional K L] [FiniteDimensional L T] : (trace K L).comp ((trace L T).restrictScalars K) = trace K T := by ext; rw [LinearMap.comp_apply, LinearMap.restrictScalars_apply, trace_trace] #align algebra.trace_comp_trace Algebra.trace_comp_trace @[simp] theorem trace_prod_apply [Module.Free R S] [Module.Free R T] [Module.Finite R S] [Module.Finite R T] (x : S × T) : trace R (S × T) x = trace R S x.fst + trace R T x.snd := by nontriviality R let f := (lmul R S).toLinearMap.prodMap (lmul R T).toLinearMap have : (lmul R (S × T)).toLinearMap = (prodMapLinear R S T S T R).comp f := LinearMap.ext₂ Prod.mul_def simp_rw [trace, this] exact trace_prodMap' _ _ #align algebra.trace_prod_apply Algebra.trace_prod_apply theorem trace_prod [Module.Free R S] [Module.Free R T] [Module.Finite R S] [Module.Finite R T] : trace R (S × T) = (trace R S).coprod (trace R T) := LinearMap.ext fun p => by rw [coprod_apply, trace_prod_apply] #align algebra.trace_prod Algebra.trace_prod section EqSumRoots open Algebra Polynomial variable {F : Type*} [Field F] variable [Algebra K S] [Algebra K F]
Mathlib/RingTheory/Trace.lean
227
233
theorem PowerBasis.trace_gen_eq_nextCoeff_minpoly [Nontrivial S] (pb : PowerBasis K S) : Algebra.trace K S pb.gen = -(minpoly K pb.gen).nextCoeff := by
have d_pos : 0 < pb.dim := PowerBasis.dim_pos pb have d_pos' : 0 < (minpoly K pb.gen).natDegree := by simpa haveI : Nonempty (Fin pb.dim) := ⟨⟨0, d_pos⟩⟩ rw [trace_eq_matrix_trace pb.basis, trace_eq_neg_charpoly_coeff, charpoly_leftMulMatrix, ← pb.natDegree_minpoly, Fintype.card_fin, ← nextCoeff_of_natDegree_pos d_pos']
import Mathlib.Algebra.Ring.Prod import Mathlib.GroupTheory.OrderOfElement import Mathlib.Tactic.FinCases #align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7" assert_not_exists Submodule open Function namespace ZMod instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ) def val : ∀ {n : ℕ}, ZMod n → ℕ | 0 => Int.natAbs | n + 1 => ((↑) : Fin (n + 1) → ℕ) #align zmod.val ZMod.val theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by cases n · cases NeZero.ne 0 rfl exact Fin.is_lt a #align zmod.val_lt ZMod.val_lt theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n := a.val_lt.le #align zmod.val_le ZMod.val_le @[simp] theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0 | 0 => rfl | _ + 1 => rfl #align zmod.val_zero ZMod.val_zero @[simp] theorem val_one' : (1 : ZMod 0).val = 1 := rfl #align zmod.val_one' ZMod.val_one' @[simp] theorem val_neg' {n : ZMod 0} : (-n).val = n.val := Int.natAbs_neg n #align zmod.val_neg' ZMod.val_neg' @[simp] theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val := Int.natAbs_mul m n #align zmod.val_mul' ZMod.val_mul' @[simp] theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by cases n · rw [Nat.mod_zero] exact Int.natAbs_ofNat a · apply Fin.val_natCast #align zmod.val_nat_cast ZMod.val_natCast @[deprecated (since := "2024-04-17")] alias val_nat_cast := val_natCast theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by simp only [val] rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one] lemma eq_one_of_isUnit_natCast {n : ℕ} (h : IsUnit (n : ZMod 0)) : n = 1 := by rw [← Nat.mod_zero n, ← val_natCast, val_unit'.mp h] theorem val_natCast_of_lt {n a : ℕ} (h : a < n) : (a : ZMod n).val = a := by rwa [val_natCast, Nat.mod_eq_of_lt] @[deprecated (since := "2024-04-17")] alias val_nat_cast_of_lt := val_natCast_of_lt instance charP (n : ℕ) : CharP (ZMod n) n where cast_eq_zero_iff' := by intro k cases' n with n · simp [zero_dvd_iff, Int.natCast_eq_zero, Nat.zero_eq] · exact Fin.natCast_eq_zero @[simp] theorem addOrderOf_one (n : ℕ) : addOrderOf (1 : ZMod n) = n := CharP.eq _ (CharP.addOrderOf_one _) (ZMod.charP n) #align zmod.add_order_of_one ZMod.addOrderOf_one @[simp] theorem addOrderOf_coe (a : ℕ) {n : ℕ} (n0 : n ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by cases' a with a · simp only [Nat.zero_eq, Nat.cast_zero, addOrderOf_zero, Nat.gcd_zero_right, Nat.pos_of_ne_zero n0, Nat.div_self] rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a.succ_ne_zero, ZMod.addOrderOf_one] #align zmod.add_order_of_coe ZMod.addOrderOf_coe @[simp] theorem addOrderOf_coe' {a : ℕ} (n : ℕ) (a0 : a ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a0, ZMod.addOrderOf_one] #align zmod.add_order_of_coe' ZMod.addOrderOf_coe' theorem ringChar_zmod_n (n : ℕ) : ringChar (ZMod n) = n := by rw [ringChar.eq_iff] exact ZMod.charP n #align zmod.ring_char_zmod_n ZMod.ringChar_zmod_n -- @[simp] -- Porting note (#10618): simp can prove this theorem natCast_self (n : ℕ) : (n : ZMod n) = 0 := CharP.cast_eq_zero (ZMod n) n #align zmod.nat_cast_self ZMod.natCast_self @[deprecated (since := "2024-04-17")] alias nat_cast_self := natCast_self @[simp] theorem natCast_self' (n : ℕ) : (n + 1 : ZMod (n + 1)) = 0 := by rw [← Nat.cast_add_one, natCast_self (n + 1)] #align zmod.nat_cast_self' ZMod.natCast_self' @[deprecated (since := "2024-04-17")] alias nat_cast_self' := natCast_self' section UniversalProperty variable {n : ℕ} {R : Type*} section variable [AddGroupWithOne R] def cast : ∀ {n : ℕ}, ZMod n → R | 0 => Int.cast | _ + 1 => fun i => i.val #align zmod.cast ZMod.cast @[simp]
Mathlib/Data/ZMod/Basic.lean
176
180
theorem cast_zero : (cast (0 : ZMod n) : R) = 0 := by
delta ZMod.cast cases n · exact Int.cast_zero · simp
import Mathlib.Algebra.Polynomial.Degree.Definitions import Mathlib.Algebra.Polynomial.Induction #align_import data.polynomial.eval from "leanprover-community/mathlib"@"728baa2f54e6062c5879a3e397ac6bac323e506f" set_option linter.uppercaseLean3 false noncomputable section open Finset AddMonoidAlgebra open Polynomial namespace Polynomial universe u v w y variable {R : Type u} {S : Type v} {T : Type w} {ι : Type y} {a b : R} {m n : ℕ} section Semiring variable [Semiring R] {p q r : R[X]} section variable [Semiring S] variable (f : R →+* S) (x : S) irreducible_def eval₂ (p : R[X]) : S := p.sum fun e a => f a * x ^ e #align polynomial.eval₂ Polynomial.eval₂ theorem eval₂_eq_sum {f : R →+* S} {x : S} : p.eval₂ f x = p.sum fun e a => f a * x ^ e := by rw [eval₂_def] #align polynomial.eval₂_eq_sum Polynomial.eval₂_eq_sum theorem eval₂_congr {R S : Type*} [Semiring R] [Semiring S] {f g : R →+* S} {s t : S} {φ ψ : R[X]} : f = g → s = t → φ = ψ → eval₂ f s φ = eval₂ g t ψ := by rintro rfl rfl rfl; rfl #align polynomial.eval₂_congr Polynomial.eval₂_congr @[simp]
Mathlib/Algebra/Polynomial/Eval.lean
58
61
theorem eval₂_at_zero : p.eval₂ f 0 = f (coeff p 0) := by
simp (config := { contextual := true }) only [eval₂_eq_sum, zero_pow_eq, mul_ite, mul_zero, mul_one, sum, Classical.not_not, mem_support_iff, sum_ite_eq', ite_eq_left_iff, RingHom.map_zero, imp_true_iff, eq_self_iff_true]
import Mathlib.RingTheory.IntegralClosure import Mathlib.RingTheory.FractionalIdeal.Basic #align_import ring_theory.fractional_ideal from "leanprover-community/mathlib"@"ed90a7d327c3a5caf65a6faf7e8a0d63c4605df7" open IsLocalization Pointwise nonZeroDivisors namespace FractionalIdeal open Set Submodule variable {R : Type*} [CommRing R] {S : Submonoid R} {P : Type*} [CommRing P] variable [Algebra R P] [loc : IsLocalization S P] section variable {P' : Type*} [CommRing P'] [Algebra R P'] [loc' : IsLocalization S P'] variable {P'' : Type*} [CommRing P''] [Algebra R P''] [loc'' : IsLocalization S P''] theorem _root_.IsFractional.map (g : P →ₐ[R] P') {I : Submodule R P} : IsFractional S I → IsFractional S (Submodule.map g.toLinearMap I) | ⟨a, a_nonzero, hI⟩ => ⟨a, a_nonzero, fun b hb => by obtain ⟨b', b'_mem, hb'⟩ := Submodule.mem_map.mp hb rw [AlgHom.toLinearMap_apply] at hb' obtain ⟨x, hx⟩ := hI b' b'_mem use x rw [← g.commutes, hx, g.map_smul, hb']⟩ #align is_fractional.map IsFractional.map def map (g : P →ₐ[R] P') : FractionalIdeal S P → FractionalIdeal S P' := fun I => ⟨Submodule.map g.toLinearMap I, I.isFractional.map g⟩ #align fractional_ideal.map FractionalIdeal.map @[simp, norm_cast] theorem coe_map (g : P →ₐ[R] P') (I : FractionalIdeal S P) : ↑(map g I) = Submodule.map g.toLinearMap I := rfl #align fractional_ideal.coe_map FractionalIdeal.coe_map @[simp] theorem mem_map {I : FractionalIdeal S P} {g : P →ₐ[R] P'} {y : P'} : y ∈ I.map g ↔ ∃ x, x ∈ I ∧ g x = y := Submodule.mem_map #align fractional_ideal.mem_map FractionalIdeal.mem_map variable (I J : FractionalIdeal S P) (g : P →ₐ[R] P') @[simp] theorem map_id : I.map (AlgHom.id _ _) = I := coeToSubmodule_injective (Submodule.map_id (I : Submodule R P)) #align fractional_ideal.map_id FractionalIdeal.map_id @[simp] theorem map_comp (g' : P' →ₐ[R] P'') : I.map (g'.comp g) = (I.map g).map g' := coeToSubmodule_injective (Submodule.map_comp g.toLinearMap g'.toLinearMap I) #align fractional_ideal.map_comp FractionalIdeal.map_comp @[simp, norm_cast] theorem map_coeIdeal (I : Ideal R) : (I : FractionalIdeal S P).map g = I := by ext x simp only [mem_coeIdeal] constructor · rintro ⟨_, ⟨y, hy, rfl⟩, rfl⟩ exact ⟨y, hy, (g.commutes y).symm⟩ · rintro ⟨y, hy, rfl⟩ exact ⟨_, ⟨y, hy, rfl⟩, g.commutes y⟩ #align fractional_ideal.map_coe_ideal FractionalIdeal.map_coeIdeal @[simp] theorem map_one : (1 : FractionalIdeal S P).map g = 1 := map_coeIdeal g ⊤ #align fractional_ideal.map_one FractionalIdeal.map_one @[simp] theorem map_zero : (0 : FractionalIdeal S P).map g = 0 := map_coeIdeal g 0 #align fractional_ideal.map_zero FractionalIdeal.map_zero @[simp] theorem map_add : (I + J).map g = I.map g + J.map g := coeToSubmodule_injective (Submodule.map_sup _ _ _) #align fractional_ideal.map_add FractionalIdeal.map_add @[simp] theorem map_mul : (I * J).map g = I.map g * J.map g := by simp only [mul_def] exact coeToSubmodule_injective (Submodule.map_mul _ _ _) #align fractional_ideal.map_mul FractionalIdeal.map_mul @[simp] theorem map_map_symm (g : P ≃ₐ[R] P') : (I.map (g : P →ₐ[R] P')).map (g.symm : P' →ₐ[R] P) = I := by rw [← map_comp, g.symm_comp, map_id] #align fractional_ideal.map_map_symm FractionalIdeal.map_map_symm @[simp] theorem map_symm_map (I : FractionalIdeal S P') (g : P ≃ₐ[R] P') : (I.map (g.symm : P' →ₐ[R] P)).map (g : P →ₐ[R] P') = I := by rw [← map_comp, g.comp_symm, map_id] #align fractional_ideal.map_symm_map FractionalIdeal.map_symm_map theorem map_mem_map {f : P →ₐ[R] P'} (h : Function.Injective f) {x : P} {I : FractionalIdeal S P} : f x ∈ map f I ↔ x ∈ I := mem_map.trans ⟨fun ⟨_, hx', x'_eq⟩ => h x'_eq ▸ hx', fun h => ⟨x, h, rfl⟩⟩ #align fractional_ideal.map_mem_map FractionalIdeal.map_mem_map theorem map_injective (f : P →ₐ[R] P') (h : Function.Injective f) : Function.Injective (map f : FractionalIdeal S P → FractionalIdeal S P') := fun _ _ hIJ => ext fun _ => (map_mem_map h).symm.trans (hIJ.symm ▸ map_mem_map h) #align fractional_ideal.map_injective FractionalIdeal.map_injective def mapEquiv (g : P ≃ₐ[R] P') : FractionalIdeal S P ≃+* FractionalIdeal S P' where toFun := map g invFun := map g.symm map_add' I J := map_add I J _ map_mul' I J := map_mul I J _ left_inv I := by rw [← map_comp, AlgEquiv.symm_comp, map_id] right_inv I := by rw [← map_comp, AlgEquiv.comp_symm, map_id] #align fractional_ideal.map_equiv FractionalIdeal.mapEquiv @[simp] theorem coeFun_mapEquiv (g : P ≃ₐ[R] P') : (mapEquiv g : FractionalIdeal S P → FractionalIdeal S P') = map g := rfl #align fractional_ideal.coe_fun_map_equiv FractionalIdeal.coeFun_mapEquiv @[simp] theorem mapEquiv_apply (g : P ≃ₐ[R] P') (I : FractionalIdeal S P) : mapEquiv g I = map (↑g) I := rfl #align fractional_ideal.map_equiv_apply FractionalIdeal.mapEquiv_apply @[simp] theorem mapEquiv_symm (g : P ≃ₐ[R] P') : ((mapEquiv g).symm : FractionalIdeal S P' ≃+* _) = mapEquiv g.symm := rfl #align fractional_ideal.map_equiv_symm FractionalIdeal.mapEquiv_symm @[simp] theorem mapEquiv_refl : mapEquiv AlgEquiv.refl = RingEquiv.refl (FractionalIdeal S P) := RingEquiv.ext fun x => by simp #align fractional_ideal.map_equiv_refl FractionalIdeal.mapEquiv_refl theorem isFractional_span_iff {s : Set P} : IsFractional S (span R s) ↔ ∃ a ∈ S, ∀ b : P, b ∈ s → IsInteger R (a • b) := ⟨fun ⟨a, a_mem, h⟩ => ⟨a, a_mem, fun b hb => h b (subset_span hb)⟩, fun ⟨a, a_mem, h⟩ => ⟨a, a_mem, fun b hb => span_induction hb h (by rw [smul_zero] exact isInteger_zero) (fun x y hx hy => by rw [smul_add] exact isInteger_add hx hy) fun s x hx => by rw [smul_comm] exact isInteger_smul hx⟩⟩ #align fractional_ideal.is_fractional_span_iff FractionalIdeal.isFractional_span_iff theorem isFractional_of_fg {I : Submodule R P} (hI : I.FG) : IsFractional S I := by rcases hI with ⟨I, rfl⟩ rcases exist_integer_multiples_of_finset S I with ⟨⟨s, hs1⟩, hs⟩ rw [isFractional_span_iff] exact ⟨s, hs1, hs⟩ #align fractional_ideal.is_fractional_of_fg FractionalIdeal.isFractional_of_fg theorem mem_span_mul_finite_of_mem_mul {I J : FractionalIdeal S P} {x : P} (hx : x ∈ I * J) : ∃ T T' : Finset P, (T : Set P) ⊆ I ∧ (T' : Set P) ⊆ J ∧ x ∈ span R (T * T' : Set P) := Submodule.mem_span_mul_finite_of_mem_mul (by simpa using mem_coe.mpr hx) #align fractional_ideal.mem_span_mul_finite_of_mem_mul FractionalIdeal.mem_span_mul_finite_of_mem_mul variable (S) theorem coeIdeal_fg (inj : Function.Injective (algebraMap R P)) (I : Ideal R) : FG ((I : FractionalIdeal S P) : Submodule R P) ↔ I.FG := coeSubmodule_fg _ inj _ #align fractional_ideal.coe_ideal_fg FractionalIdeal.coeIdeal_fg variable {S} theorem fg_unit (I : (FractionalIdeal S P)ˣ) : FG (I : Submodule R P) := Submodule.fg_unit <| Units.map (coeSubmoduleHom S P).toMonoidHom I #align fractional_ideal.fg_unit FractionalIdeal.fg_unit theorem fg_of_isUnit (I : FractionalIdeal S P) (h : IsUnit I) : FG (I : Submodule R P) := fg_unit h.unit #align fractional_ideal.fg_of_is_unit FractionalIdeal.fg_of_isUnit theorem _root_.Ideal.fg_of_isUnit (inj : Function.Injective (algebraMap R P)) (I : Ideal R) (h : IsUnit (I : FractionalIdeal S P)) : I.FG := by rw [← coeIdeal_fg S inj I] exact FractionalIdeal.fg_of_isUnit I h #align ideal.fg_of_is_unit Ideal.fg_of_isUnit variable (S P P') noncomputable irreducible_def canonicalEquiv : FractionalIdeal S P ≃+* FractionalIdeal S P' := mapEquiv { ringEquivOfRingEquiv P P' (RingEquiv.refl R) (show S.map _ = S by rw [RingEquiv.toMonoidHom_refl, Submonoid.map_id]) with commutes' := fun r => ringEquivOfRingEquiv_eq _ _ } #align fractional_ideal.canonical_equiv FractionalIdeal.canonicalEquiv @[simp] theorem mem_canonicalEquiv_apply {I : FractionalIdeal S P} {x : P'} : x ∈ canonicalEquiv S P P' I ↔ ∃ y ∈ I, IsLocalization.map P' (RingHom.id R) (fun y (hy : y ∈ S) => show RingHom.id R y ∈ S from hy) (y : P) = x := by rw [canonicalEquiv, mapEquiv_apply, mem_map] exact ⟨fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩, fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩⟩ #align fractional_ideal.mem_canonical_equiv_apply FractionalIdeal.mem_canonicalEquiv_apply @[simp] theorem canonicalEquiv_symm : (canonicalEquiv S P P').symm = canonicalEquiv S P' P := RingEquiv.ext fun I => SetLike.ext_iff.mpr fun x => by rw [mem_canonicalEquiv_apply, canonicalEquiv, mapEquiv_symm, mapEquiv_apply, mem_map] exact ⟨fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩, fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩⟩ #align fractional_ideal.canonical_equiv_symm FractionalIdeal.canonicalEquiv_symm theorem canonicalEquiv_flip (I) : canonicalEquiv S P P' (canonicalEquiv S P' P I) = I := by rw [← canonicalEquiv_symm]; erw [RingEquiv.apply_symm_apply] #align fractional_ideal.canonical_equiv_flip FractionalIdeal.canonicalEquiv_flip @[simp] theorem canonicalEquiv_canonicalEquiv (P'' : Type*) [CommRing P''] [Algebra R P''] [IsLocalization S P''] (I : FractionalIdeal S P) : canonicalEquiv S P' P'' (canonicalEquiv S P P' I) = canonicalEquiv S P P'' I := by ext simp only [IsLocalization.map_map, RingHomInvPair.comp_eq₂, mem_canonicalEquiv_apply, exists_prop, exists_exists_and_eq_and] #align fractional_ideal.canonical_equiv_canonical_equiv FractionalIdeal.canonicalEquiv_canonicalEquiv theorem canonicalEquiv_trans_canonicalEquiv (P'' : Type*) [CommRing P''] [Algebra R P''] [IsLocalization S P''] : (canonicalEquiv S P P').trans (canonicalEquiv S P' P'') = canonicalEquiv S P P'' := RingEquiv.ext (canonicalEquiv_canonicalEquiv S P P' P'') #align fractional_ideal.canonical_equiv_trans_canonical_equiv FractionalIdeal.canonicalEquiv_trans_canonicalEquiv @[simp] theorem canonicalEquiv_coeIdeal (I : Ideal R) : canonicalEquiv S P P' I = I := by ext simp [IsLocalization.map_eq] #align fractional_ideal.canonical_equiv_coe_ideal FractionalIdeal.canonicalEquiv_coeIdeal @[simp] theorem canonicalEquiv_self : canonicalEquiv S P P = RingEquiv.refl _ := by rw [← canonicalEquiv_trans_canonicalEquiv S P P] convert (canonicalEquiv S P P).symm_trans_self exact (canonicalEquiv_symm S P P).symm #align fractional_ideal.canonical_equiv_self FractionalIdeal.canonicalEquiv_self end section PrincipalIdeal variable {R₁ : Type*} [CommRing R₁] {K : Type*} [Field K] variable [Algebra R₁ K] [IsFractionRing R₁ K] open scoped Classical variable (R₁) -- Porting note: `@[simps]` generated a `Subtype.val` coercion instead of a -- `FractionalIdeal.coeToSubmodule` coercion def spanFinset {ι : Type*} (s : Finset ι) (f : ι → K) : FractionalIdeal R₁⁰ K := ⟨Submodule.span R₁ (f '' s), by obtain ⟨a', ha'⟩ := IsLocalization.exist_integer_multiples R₁⁰ s f refine ⟨a', a'.2, fun x hx => Submodule.span_induction hx ?_ ?_ ?_ ?_⟩ · rintro _ ⟨i, hi, rfl⟩ exact ha' i hi · rw [smul_zero] exact IsLocalization.isInteger_zero · intro x y hx hy rw [smul_add] exact IsLocalization.isInteger_add hx hy · intro c x hx rw [smul_comm] exact IsLocalization.isInteger_smul hx⟩ #align fractional_ideal.span_finset FractionalIdeal.spanFinset @[simp] lemma spanFinset_coe {ι : Type*} (s : Finset ι) (f : ι → K) : (spanFinset R₁ s f : Submodule R₁ K) = Submodule.span R₁ (f '' s) := rfl variable {R₁} @[simp] theorem spanFinset_eq_zero {ι : Type*} {s : Finset ι} {f : ι → K} : spanFinset R₁ s f = 0 ↔ ∀ j ∈ s, f j = 0 := by simp only [← coeToSubmodule_inj, spanFinset_coe, coe_zero, Submodule.span_eq_bot, Set.mem_image, Finset.mem_coe, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] #align fractional_ideal.span_finset_eq_zero FractionalIdeal.spanFinset_eq_zero theorem spanFinset_ne_zero {ι : Type*} {s : Finset ι} {f : ι → K} : spanFinset R₁ s f ≠ 0 ↔ ∃ j ∈ s, f j ≠ 0 := by simp #align fractional_ideal.span_finset_ne_zero FractionalIdeal.spanFinset_ne_zero open Submodule.IsPrincipal theorem isFractional_span_singleton (x : P) : IsFractional S (span R {x} : Submodule R P) := let ⟨a, ha⟩ := exists_integer_multiple S x isFractional_span_iff.mpr ⟨a, a.2, fun _ hx' => (Set.mem_singleton_iff.mp hx').symm ▸ ha⟩ #align fractional_ideal.is_fractional_span_singleton FractionalIdeal.isFractional_span_singleton variable (S) irreducible_def spanSingleton (x : P) : FractionalIdeal S P := ⟨span R {x}, isFractional_span_singleton x⟩ #align fractional_ideal.span_singleton FractionalIdeal.spanSingleton -- local attribute [semireducible] span_singleton @[simp] theorem coe_spanSingleton (x : P) : (spanSingleton S x : Submodule R P) = span R {x} := by rw [spanSingleton] rfl #align fractional_ideal.coe_span_singleton FractionalIdeal.coe_spanSingleton @[simp] theorem mem_spanSingleton {x y : P} : x ∈ spanSingleton S y ↔ ∃ z : R, z • y = x := by rw [spanSingleton] exact Submodule.mem_span_singleton #align fractional_ideal.mem_span_singleton FractionalIdeal.mem_spanSingleton theorem mem_spanSingleton_self (x : P) : x ∈ spanSingleton S x := (mem_spanSingleton S).mpr ⟨1, one_smul _ _⟩ #align fractional_ideal.mem_span_singleton_self FractionalIdeal.mem_spanSingleton_self variable (P) in theorem den_mul_self_eq_num' (I : FractionalIdeal S P) : spanSingleton S (algebraMap R P I.den) * I = I.num := by apply coeToSubmodule_injective dsimp only rw [coe_mul, ← smul_eq_mul, coe_spanSingleton, smul_eq_mul, Submodule.span_singleton_mul] convert I.den_mul_self_eq_num using 1 ext erw [Set.mem_smul_set, Set.mem_smul_set] simp [Algebra.smul_def] variable {S} @[simp] theorem spanSingleton_le_iff_mem {x : P} {I : FractionalIdeal S P} : spanSingleton S x ≤ I ↔ x ∈ I := by rw [← coe_le_coe, coe_spanSingleton, Submodule.span_singleton_le_iff_mem, mem_coe] #align fractional_ideal.span_singleton_le_iff_mem FractionalIdeal.spanSingleton_le_iff_mem theorem spanSingleton_eq_spanSingleton [NoZeroSMulDivisors R P] {x y : P} : spanSingleton S x = spanSingleton S y ↔ ∃ z : Rˣ, z • x = y := by rw [← Submodule.span_singleton_eq_span_singleton, spanSingleton, spanSingleton] exact Subtype.mk_eq_mk #align fractional_ideal.span_singleton_eq_span_singleton FractionalIdeal.spanSingleton_eq_spanSingleton theorem eq_spanSingleton_of_principal (I : FractionalIdeal S P) [IsPrincipal (I : Submodule R P)] : I = spanSingleton S (generator (I : Submodule R P)) := by -- Porting note: this used to be `coeToSubmodule_injective (span_singleton_generator ↑I).symm` -- but Lean 4 struggled to unify everything. Turned it into an explicit `rw`. rw [spanSingleton, ← coeToSubmodule_inj, coe_mk, span_singleton_generator] #align fractional_ideal.eq_span_singleton_of_principal FractionalIdeal.eq_spanSingleton_of_principal theorem isPrincipal_iff (I : FractionalIdeal S P) : IsPrincipal (I : Submodule R P) ↔ ∃ x, I = spanSingleton S x := ⟨fun h => ⟨@generator _ _ _ _ _ (↑I) h, @eq_spanSingleton_of_principal _ _ _ _ _ _ _ I h⟩, fun ⟨x, hx⟩ => { principal' := ⟨x, Eq.trans (congr_arg _ hx) (coe_spanSingleton _ x)⟩ }⟩ #align fractional_ideal.is_principal_iff FractionalIdeal.isPrincipal_iff @[simp] theorem spanSingleton_zero : spanSingleton S (0 : P) = 0 := by ext simp [Submodule.mem_span_singleton, eq_comm] #align fractional_ideal.span_singleton_zero FractionalIdeal.spanSingleton_zero theorem spanSingleton_eq_zero_iff {y : P} : spanSingleton S y = 0 ↔ y = 0 := ⟨fun h => span_eq_bot.mp (by simpa using congr_arg Subtype.val h : span R {y} = ⊥) y (mem_singleton y), fun h => by simp [h]⟩ #align fractional_ideal.span_singleton_eq_zero_iff FractionalIdeal.spanSingleton_eq_zero_iff theorem spanSingleton_ne_zero_iff {y : P} : spanSingleton S y ≠ 0 ↔ y ≠ 0 := not_congr spanSingleton_eq_zero_iff #align fractional_ideal.span_singleton_ne_zero_iff FractionalIdeal.spanSingleton_ne_zero_iff @[simp] theorem spanSingleton_one : spanSingleton S (1 : P) = 1 := by ext refine (mem_spanSingleton S).trans ((exists_congr ?_).trans (mem_one_iff S).symm) intro x' rw [Algebra.smul_def, mul_one] #align fractional_ideal.span_singleton_one FractionalIdeal.spanSingleton_one @[simp] theorem spanSingleton_mul_spanSingleton (x y : P) : spanSingleton S x * spanSingleton S y = spanSingleton S (x * y) := by apply coeToSubmodule_injective simp only [coe_mul, coe_spanSingleton, span_mul_span, singleton_mul_singleton] #align fractional_ideal.span_singleton_mul_span_singleton FractionalIdeal.spanSingleton_mul_spanSingleton @[simp] theorem spanSingleton_pow (x : P) (n : ℕ) : spanSingleton S x ^ n = spanSingleton S (x ^ n) := by induction' n with n hn · rw [pow_zero, pow_zero, spanSingleton_one] · rw [pow_succ, hn, spanSingleton_mul_spanSingleton, pow_succ] #align fractional_ideal.span_singleton_pow FractionalIdeal.spanSingleton_pow @[simp] theorem coeIdeal_span_singleton (x : R) : (↑(Ideal.span {x} : Ideal R) : FractionalIdeal S P) = spanSingleton S (algebraMap R P x) := by ext y refine (mem_coeIdeal S).trans (Iff.trans ?_ (mem_spanSingleton S).symm) constructor · rintro ⟨y', hy', rfl⟩ obtain ⟨x', rfl⟩ := Submodule.mem_span_singleton.mp hy' use x' rw [smul_eq_mul, RingHom.map_mul, Algebra.smul_def] · rintro ⟨y', rfl⟩ refine ⟨y' * x, Submodule.mem_span_singleton.mpr ⟨y', rfl⟩, ?_⟩ rw [RingHom.map_mul, Algebra.smul_def] #align fractional_ideal.coe_ideal_span_singleton FractionalIdeal.coeIdeal_span_singleton @[simp]
Mathlib/RingTheory/FractionalIdeal/Operations.lean
737
755
theorem canonicalEquiv_spanSingleton {P'} [CommRing P'] [Algebra R P'] [IsLocalization S P'] (x : P) : canonicalEquiv S P P' (spanSingleton S x) = spanSingleton S (IsLocalization.map P' (RingHom.id R) (fun y (hy : y ∈ S) => show RingHom.id R y ∈ S from hy) x) := by
apply SetLike.ext_iff.mpr intro y constructor <;> intro h · rw [mem_spanSingleton] obtain ⟨x', hx', rfl⟩ := (mem_canonicalEquiv_apply _ _ _).mp h obtain ⟨z, rfl⟩ := (mem_spanSingleton _).mp hx' use z rw [IsLocalization.map_smul, RingHom.id_apply] · rw [mem_canonicalEquiv_apply] obtain ⟨z, rfl⟩ := (mem_spanSingleton _).mp h use z • x use (mem_spanSingleton _).mpr ⟨z, rfl⟩ simp [IsLocalization.map_smul]
import Mathlib.Algebra.GroupWithZero.NonZeroDivisors import Mathlib.Algebra.Polynomial.Lifts import Mathlib.GroupTheory.MonoidLocalization import Mathlib.RingTheory.Algebraic import Mathlib.RingTheory.Ideal.LocalRing import Mathlib.RingTheory.IntegralClosure import Mathlib.RingTheory.Localization.FractionRing import Mathlib.RingTheory.Localization.Integer #align_import ring_theory.localization.integral from "leanprover-community/mathlib"@"831c494092374cfe9f50591ed0ac81a25efc5b86" variable {R : Type*} [CommRing R] (M : Submonoid R) {S : Type*} [CommRing S] variable [Algebra R S] {P : Type*} [CommRing P] open Polynomial namespace IsLocalization open IsLocalization section IsIntegral variable {Rₘ Sₘ : Type*} [CommRing Rₘ] [CommRing Sₘ] variable [Algebra R Rₘ] [IsLocalization M Rₘ] variable [Algebra S Sₘ] [IsLocalization (Algebra.algebraMapSubmonoid S M) Sₘ] variable {M} open Polynomial
Mathlib/RingTheory/Localization/Integral.lean
185
201
theorem RingHom.isIntegralElem_localization_at_leadingCoeff {R S : Type*} [CommRing R] [CommRing S] (f : R →+* S) (x : S) (p : R[X]) (hf : p.eval₂ f x = 0) (M : Submonoid R) (hM : p.leadingCoeff ∈ M) {Rₘ Sₘ : Type*} [CommRing Rₘ] [CommRing Sₘ] [Algebra R Rₘ] [IsLocalization M Rₘ] [Algebra S Sₘ] [IsLocalization (M.map f : Submonoid S) Sₘ] : (map Sₘ f M.le_comap_map : Rₘ →+* _).IsIntegralElem (algebraMap S Sₘ x) := by
by_cases triv : (1 : Rₘ) = 0 · exact ⟨0, ⟨_root_.trans leadingCoeff_zero triv.symm, eval₂_zero _ _⟩⟩ haveI : Nontrivial Rₘ := nontrivial_of_ne 1 0 triv obtain ⟨b, hb⟩ := isUnit_iff_exists_inv.mp (map_units Rₘ ⟨p.leadingCoeff, hM⟩) refine ⟨p.map (algebraMap R Rₘ) * C b, ⟨?_, ?_⟩⟩ · refine monic_mul_C_of_leadingCoeff_mul_eq_one ?_ rwa [leadingCoeff_map_of_leadingCoeff_ne_zero (algebraMap R Rₘ)] refine fun hfp => zero_ne_one (_root_.trans (zero_mul b).symm (hfp ▸ hb) : (0 : Rₘ) = 1) · refine eval₂_mul_eq_zero_of_left _ _ _ ?_ erw [eval₂_map, IsLocalization.map_comp, ← hom_eval₂ _ f (algebraMap S Sₘ) x] exact _root_.trans (congr_arg (algebraMap S Sₘ) hf) (RingHom.map_zero _)
import Mathlib.RingTheory.Ideal.IsPrimary import Mathlib.RingTheory.Ideal.Quotient import Mathlib.RingTheory.Polynomial.Quotient #align_import ring_theory.jacobson_ideal from "leanprover-community/mathlib"@"da420a8c6dd5bdfb85c4ced85c34388f633bc6ff" universe u v namespace Ideal variable {R : Type u} {S : Type v} open Polynomial section Jacobson section Ring variable [Ring R] [Ring S] {I : Ideal R} def jacobson (I : Ideal R) : Ideal R := sInf { J : Ideal R | I ≤ J ∧ IsMaximal J } #align ideal.jacobson Ideal.jacobson theorem le_jacobson : I ≤ jacobson I := fun _ hx => mem_sInf.mpr fun _ hJ => hJ.left hx #align ideal.le_jacobson Ideal.le_jacobson @[simp] theorem jacobson_idem : jacobson (jacobson I) = jacobson I := le_antisymm (sInf_le_sInf fun _ hJ => ⟨sInf_le hJ, hJ.2⟩) le_jacobson #align ideal.jacobson_idem Ideal.jacobson_idem @[simp] theorem jacobson_top : jacobson (⊤ : Ideal R) = ⊤ := eq_top_iff.2 le_jacobson #align ideal.jacobson_top Ideal.jacobson_top @[simp] theorem jacobson_eq_top_iff : jacobson I = ⊤ ↔ I = ⊤ := ⟨fun H => by_contradiction fun hi => let ⟨M, hm, him⟩ := exists_le_maximal I hi lt_top_iff_ne_top.1 (lt_of_le_of_lt (show jacobson I ≤ M from sInf_le ⟨him, hm⟩) <| lt_top_iff_ne_top.2 hm.ne_top) H, fun H => eq_top_iff.2 <| le_sInf fun _ ⟨hij, _⟩ => H ▸ hij⟩ #align ideal.jacobson_eq_top_iff Ideal.jacobson_eq_top_iff theorem jacobson_eq_bot : jacobson I = ⊥ → I = ⊥ := fun h => eq_bot_iff.mpr (h ▸ le_jacobson) #align ideal.jacobson_eq_bot Ideal.jacobson_eq_bot theorem jacobson_eq_self_of_isMaximal [H : IsMaximal I] : I.jacobson = I := le_antisymm (sInf_le ⟨le_of_eq rfl, H⟩) le_jacobson #align ideal.jacobson_eq_self_of_is_maximal Ideal.jacobson_eq_self_of_isMaximal instance (priority := 100) jacobson.isMaximal [H : IsMaximal I] : IsMaximal (jacobson I) := ⟨⟨fun htop => H.1.1 (jacobson_eq_top_iff.1 htop), fun _ hJ => H.1.2 _ (lt_of_le_of_lt le_jacobson hJ)⟩⟩ #align ideal.jacobson.is_maximal Ideal.jacobson.isMaximal theorem mem_jacobson_iff {x : R} : x ∈ jacobson I ↔ ∀ y, ∃ z, z * y * x + z - 1 ∈ I := ⟨fun hx y => by_cases (fun hxy : I ⊔ span {y * x + 1} = ⊤ => let ⟨p, hpi, q, hq, hpq⟩ := Submodule.mem_sup.1 ((eq_top_iff_one _).1 hxy) let ⟨r, hr⟩ := mem_span_singleton'.1 hq ⟨r, by -- Porting note: supply `mul_add_one` with explicit variables rw [mul_assoc, ← mul_add_one r (y * x), hr, ← hpq, ← neg_sub, add_sub_cancel_right] exact I.neg_mem hpi⟩) fun hxy : I ⊔ span {y * x + 1} ≠ ⊤ => let ⟨M, hm1, hm2⟩ := exists_le_maximal _ hxy suffices x ∉ M from (this <| mem_sInf.1 hx ⟨le_trans le_sup_left hm2, hm1⟩).elim fun hxm => hm1.1.1 <| (eq_top_iff_one _).2 <| add_sub_cancel_left (y * x) 1 ▸ M.sub_mem (le_sup_right.trans hm2 <| subset_span rfl) (M.mul_mem_left _ hxm), fun hx => mem_sInf.2 fun M ⟨him, hm⟩ => by_contradiction fun hxm => let ⟨y, i, hi, df⟩ := hm.exists_inv hxm let ⟨z, hz⟩ := hx (-y) hm.1.1 <| (eq_top_iff_one _).2 <| sub_sub_cancel (z * -y * x + z) 1 ▸ M.sub_mem (by -- Porting note: supply `mul_add_one` with explicit variables rw [mul_assoc, ← mul_add_one z, neg_mul, ← sub_eq_iff_eq_add.mpr df.symm, neg_sub, sub_add_cancel] exact M.mul_mem_left _ hi) <| him hz⟩ #align ideal.mem_jacobson_iff Ideal.mem_jacobson_iff theorem exists_mul_sub_mem_of_sub_one_mem_jacobson {I : Ideal R} (r : R) (h : r - 1 ∈ jacobson I) : ∃ s, s * r - 1 ∈ I := by cases' mem_jacobson_iff.1 h 1 with s hs use s simpa [mul_sub] using hs #align ideal.exists_mul_sub_mem_of_sub_one_mem_jacobson Ideal.exists_mul_sub_mem_of_sub_one_mem_jacobson theorem eq_jacobson_iff_sInf_maximal : I.jacobson = I ↔ ∃ M : Set (Ideal R), (∀ J ∈ M, IsMaximal J ∨ J = ⊤) ∧ I = sInf M := by use fun hI => ⟨{ J : Ideal R | I ≤ J ∧ J.IsMaximal }, ⟨fun _ hJ => Or.inl hJ.right, hI.symm⟩⟩ rintro ⟨M, hM, hInf⟩ refine le_antisymm (fun x hx => ?_) le_jacobson rw [hInf, mem_sInf] intro I hI cases' hM I hI with is_max is_top · exact (mem_sInf.1 hx) ⟨le_sInf_iff.1 (le_of_eq hInf) I hI, is_max⟩ · exact is_top.symm ▸ Submodule.mem_top #align ideal.eq_jacobson_iff_Inf_maximal Ideal.eq_jacobson_iff_sInf_maximal theorem eq_jacobson_iff_sInf_maximal' : I.jacobson = I ↔ ∃ M : Set (Ideal R), (∀ J ∈ M, ∀ (K : Ideal R), J < K → K = ⊤) ∧ I = sInf M := eq_jacobson_iff_sInf_maximal.trans ⟨fun h => let ⟨M, hM⟩ := h ⟨M, ⟨fun J hJ K hK => Or.recOn (hM.1 J hJ) (fun h => h.1.2 K hK) fun h => eq_top_iff.2 (le_of_lt (h ▸ hK)), hM.2⟩⟩, fun h => let ⟨M, hM⟩ := h ⟨M, ⟨fun J hJ => Or.recOn (Classical.em (J = ⊤)) (fun h => Or.inr h) fun h => Or.inl ⟨⟨h, hM.1 J hJ⟩⟩, hM.2⟩⟩⟩ #align ideal.eq_jacobson_iff_Inf_maximal' Ideal.eq_jacobson_iff_sInf_maximal'
Mathlib/RingTheory/JacobsonIdeal.lean
165
176
theorem eq_jacobson_iff_not_mem : I.jacobson = I ↔ ∀ (x) (_ : x ∉ I), ∃ M : Ideal R, (I ≤ M ∧ M.IsMaximal) ∧ x ∉ M := by
constructor · intro h x hx erw [← h, mem_sInf] at hx push_neg at hx exact hx · refine fun h => le_antisymm (fun x hx => ?_) le_jacobson contrapose hx erw [mem_sInf] push_neg exact h x hx
import Mathlib.Probability.Notation import Mathlib.Probability.Density import Mathlib.Probability.ConditionalProbability import Mathlib.Probability.ProbabilityMassFunction.Constructions open scoped Classical MeasureTheory NNReal ENNReal -- TODO: We can't `open ProbabilityTheory` without opening the `ProbabilityTheory` locale :( open TopologicalSpace MeasureTheory.Measure PMF noncomputable section namespace MeasureTheory variable {E : Type*} [MeasurableSpace E] {m : Measure E} {μ : Measure E} namespace pdf variable {Ω : Type*} variable {_ : MeasurableSpace Ω} {ℙ : Measure Ω} def IsUniform (X : Ω → E) (s : Set E) (ℙ : Measure Ω) (μ : Measure E := by volume_tac) := map X ℙ = ProbabilityTheory.cond μ s #align measure_theory.pdf.is_uniform MeasureTheory.pdf.IsUniform namespace IsUniform theorem aemeasurable {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞) (hu : IsUniform X s ℙ μ) : AEMeasurable X ℙ := by dsimp [IsUniform, ProbabilityTheory.cond] at hu by_contra h rw [map_of_not_aemeasurable h] at hu apply zero_ne_one' ℝ≥0∞ calc 0 = (0 : Measure E) Set.univ := rfl _ = _ := by rw [hu, smul_apply, restrict_apply MeasurableSet.univ, Set.univ_inter, smul_eq_mul, ENNReal.inv_mul_cancel hns hnt] theorem absolutelyContinuous {X : Ω → E} {s : Set E} (hu : IsUniform X s ℙ μ) : map X ℙ ≪ μ := by rw [hu]; exact ProbabilityTheory.cond_absolutelyContinuous theorem measure_preimage {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞) (hu : IsUniform X s ℙ μ) {A : Set E} (hA : MeasurableSet A) : ℙ (X ⁻¹' A) = μ (s ∩ A) / μ s := by rwa [← map_apply_of_aemeasurable (hu.aemeasurable hns hnt) hA, hu, ProbabilityTheory.cond_apply', ENNReal.div_eq_inv_mul] #align measure_theory.pdf.is_uniform.measure_preimage MeasureTheory.pdf.IsUniform.measure_preimage theorem isProbabilityMeasure {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞) (hu : IsUniform X s ℙ μ) : IsProbabilityMeasure ℙ := ⟨by have : X ⁻¹' Set.univ = Set.univ := Set.preimage_univ rw [← this, hu.measure_preimage hns hnt MeasurableSet.univ, Set.inter_univ, ENNReal.div_self hns hnt]⟩ #align measure_theory.pdf.is_uniform.is_probability_measure MeasureTheory.pdf.IsUniform.isProbabilityMeasure theorem toMeasurable_iff {X : Ω → E} {s : Set E} : IsUniform X (toMeasurable μ s) ℙ μ ↔ IsUniform X s ℙ μ := by unfold IsUniform rw [ProbabilityTheory.cond_toMeasurable_eq] protected theorem toMeasurable {X : Ω → E} {s : Set E} (hu : IsUniform X s ℙ μ) : IsUniform X (toMeasurable μ s) ℙ μ := by unfold IsUniform at * rwa [ProbabilityTheory.cond_toMeasurable_eq]
Mathlib/Probability/Distributions/Uniform.lean
105
111
theorem hasPDF {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞) (hu : IsUniform X s ℙ μ) : HasPDF X ℙ μ := by
let t := toMeasurable μ s apply hasPDF_of_map_eq_withDensity (hu.aemeasurable hns hnt) (t.indicator ((μ t)⁻¹ • 1)) <| (measurable_one.aemeasurable.const_smul (μ t)⁻¹).indicator (measurableSet_toMeasurable μ s) rw [hu, withDensity_indicator (measurableSet_toMeasurable μ s), withDensity_smul _ measurable_one, withDensity_one, restrict_toMeasurable hnt, measure_toMeasurable, ProbabilityTheory.cond]
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 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 #align probability_theory.evariance_eq_lintegral_of_real ProbabilityTheory.evariance_eq_lintegral_ofReal theorem _root_.MeasureTheory.Memℒp.variance_eq_of_integral_eq_zero (hX : Memℒp X 2 μ) (hXint : μ[X] = 0) : variance X μ = μ[X ^ (2 : Nat)] := by rw [variance, evariance_eq_lintegral_ofReal, ← ofReal_integral_eq_lintegral_ofReal, ENNReal.toReal_ofReal (by positivity)] <;> simp_rw [hXint, sub_zero] · rfl · convert hX.integrable_norm_rpow two_ne_zero ENNReal.two_ne_top with ω simp only [Pi.sub_apply, Real.norm_eq_abs, coe_two, ENNReal.one_toReal, Real.rpow_two, sq_abs, abs_pow] · exact ae_of_all _ fun ω => pow_two_nonneg _ #align measure_theory.mem_ℒp.variance_eq_of_integral_eq_zero MeasureTheory.Memℒp.variance_eq_of_integral_eq_zero theorem _root_.MeasureTheory.Memℒp.variance_eq [IsFiniteMeasure μ] (hX : Memℒp X 2 μ) : variance X μ = μ[(X - fun _ => μ[X] :) ^ (2 : Nat)] := by rw [variance, evariance_eq_lintegral_ofReal, ← ofReal_integral_eq_lintegral_ofReal, ENNReal.toReal_ofReal (by positivity)] · rfl · -- Porting note: `μ[X]` without whitespace is ambiguous as it could be GetElem, -- and `convert` cannot disambiguate based on typeclass inference failure. convert (hX.sub <| memℒp_const (μ [X])).integrable_norm_rpow two_ne_zero ENNReal.two_ne_top with ω simp only [Pi.sub_apply, Real.norm_eq_abs, coe_two, ENNReal.one_toReal, Real.rpow_two, sq_abs, abs_pow] · exact ae_of_all _ fun ω => pow_two_nonneg _ #align measure_theory.mem_ℒp.variance_eq MeasureTheory.Memℒp.variance_eq @[simp] theorem evariance_zero : evariance 0 μ = 0 := by simp [evariance] #align probability_theory.evariance_zero ProbabilityTheory.evariance_zero theorem evariance_eq_zero_iff (hX : AEMeasurable X μ) : evariance X μ = 0 ↔ X =ᵐ[μ] fun _ => μ[X] := by rw [evariance, lintegral_eq_zero_iff'] constructor <;> intro hX <;> filter_upwards [hX] with ω hω · simpa only [Pi.zero_apply, sq_eq_zero_iff, ENNReal.coe_eq_zero, nnnorm_eq_zero, sub_eq_zero] using hω · rw [hω] simp · exact (hX.sub_const _).ennnorm.pow_const _ -- TODO `measurability` and `fun_prop` fail #align probability_theory.evariance_eq_zero_iff ProbabilityTheory.evariance_eq_zero_iff theorem evariance_mul (c : ℝ) (X : Ω → ℝ) (μ : Measure Ω) : evariance (fun ω => c * X ω) μ = ENNReal.ofReal (c ^ 2) * evariance X μ := by rw [evariance, evariance, ← lintegral_const_mul' _ _ ENNReal.ofReal_lt_top.ne] congr ext1 ω rw [ENNReal.ofReal, ← ENNReal.coe_pow, ← ENNReal.coe_pow, ← ENNReal.coe_mul] congr rw [← sq_abs, ← Real.rpow_two, Real.toNNReal_rpow_of_nonneg (abs_nonneg _), NNReal.rpow_two, ← mul_pow, Real.toNNReal_mul_nnnorm _ (abs_nonneg _)] conv_rhs => rw [← nnnorm_norm, norm_mul, norm_abs_eq_norm, ← norm_mul, nnnorm_norm, mul_sub] congr rw [mul_comm] simp_rw [← smul_eq_mul, ← integral_smul_const, smul_eq_mul, mul_comm] #align probability_theory.evariance_mul ProbabilityTheory.evariance_mul scoped notation "eVar[" X "]" => ProbabilityTheory.evariance X MeasureTheory.MeasureSpace.volume @[simp] theorem variance_zero (μ : Measure Ω) : variance 0 μ = 0 := by simp only [variance, evariance_zero, ENNReal.zero_toReal] #align probability_theory.variance_zero ProbabilityTheory.variance_zero theorem variance_nonneg (X : Ω → ℝ) (μ : Measure Ω) : 0 ≤ variance X μ := ENNReal.toReal_nonneg #align probability_theory.variance_nonneg ProbabilityTheory.variance_nonneg theorem variance_mul (c : ℝ) (X : Ω → ℝ) (μ : Measure Ω) : variance (fun ω => c * X ω) μ = c ^ 2 * variance X μ := by rw [variance, evariance_mul, ENNReal.toReal_mul, ENNReal.toReal_ofReal (sq_nonneg _)] rfl #align probability_theory.variance_mul ProbabilityTheory.variance_mul theorem variance_smul (c : ℝ) (X : Ω → ℝ) (μ : Measure Ω) : variance (c • X) μ = c ^ 2 * variance X μ := variance_mul c X μ #align probability_theory.variance_smul ProbabilityTheory.variance_smul
Mathlib/Probability/Variance.lean
194
198
theorem variance_smul' {A : Type*} [CommSemiring A] [Algebra A ℝ] (c : A) (X : Ω → ℝ) (μ : Measure Ω) : variance (c • X) μ = c ^ 2 • variance X μ := by
convert variance_smul (algebraMap A ℝ c) X μ using 1 · congr; simp only [algebraMap_smul] · simp only [Algebra.smul_def, map_pow]
import Mathlib.Dynamics.Ergodic.MeasurePreserving import Mathlib.MeasureTheory.Function.SimpleFunc import Mathlib.MeasureTheory.Measure.MutuallySingular import Mathlib.MeasureTheory.Measure.Count import Mathlib.Topology.IndicatorConstPointwise import Mathlib.MeasureTheory.Constructions.BorelSpace.Real #align_import measure_theory.integral.lebesgue from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" assert_not_exists NormedSpace set_option autoImplicit true noncomputable section open Set hiding restrict restrict_apply open Filter ENNReal open Function (support) open scoped Classical open Topology NNReal ENNReal MeasureTheory namespace MeasureTheory local infixr:25 " →ₛ " => SimpleFunc variable {α β γ δ : Type*} section Lintegral open SimpleFunc variable {m : MeasurableSpace α} {μ ν : Measure α} irreducible_def lintegral {_ : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) : ℝ≥0∞ := ⨆ (g : α →ₛ ℝ≥0∞) (_ : ⇑g ≤ f), g.lintegral μ #align measure_theory.lintegral MeasureTheory.lintegral @[inherit_doc MeasureTheory.lintegral] notation3 "∫⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => lintegral μ r @[inherit_doc MeasureTheory.lintegral] notation3 "∫⁻ "(...)", "r:60:(scoped f => lintegral volume f) => r @[inherit_doc MeasureTheory.lintegral] notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => lintegral (Measure.restrict μ s) r @[inherit_doc MeasureTheory.lintegral] notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => lintegral (Measure.restrict volume s) f) => r theorem SimpleFunc.lintegral_eq_lintegral {m : MeasurableSpace α} (f : α →ₛ ℝ≥0∞) (μ : Measure α) : ∫⁻ a, f a ∂μ = f.lintegral μ := by rw [MeasureTheory.lintegral] exact le_antisymm (iSup₂_le fun g hg => lintegral_mono hg <| le_rfl) (le_iSup₂_of_le f le_rfl le_rfl) #align measure_theory.simple_func.lintegral_eq_lintegral MeasureTheory.SimpleFunc.lintegral_eq_lintegral @[mono] theorem lintegral_mono' {m : MeasurableSpace α} ⦃μ ν : Measure α⦄ (hμν : μ ≤ ν) ⦃f g : α → ℝ≥0∞⦄ (hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂ν := by rw [lintegral, lintegral] exact iSup_mono fun φ => iSup_mono' fun hφ => ⟨le_trans hφ hfg, lintegral_mono (le_refl φ) hμν⟩ #align measure_theory.lintegral_mono' MeasureTheory.lintegral_mono' -- workaround for the known eta-reduction issue with `@[gcongr]` @[gcongr] theorem lintegral_mono_fn' ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) (h2 : μ ≤ ν) : lintegral μ f ≤ lintegral ν g := lintegral_mono' h2 hfg theorem lintegral_mono ⦃f g : α → ℝ≥0∞⦄ (hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := lintegral_mono' (le_refl μ) hfg #align measure_theory.lintegral_mono MeasureTheory.lintegral_mono -- workaround for the known eta-reduction issue with `@[gcongr]` @[gcongr] theorem lintegral_mono_fn ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) : lintegral μ f ≤ lintegral μ g := lintegral_mono hfg theorem lintegral_mono_nnreal {f g : α → ℝ≥0} (h : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := lintegral_mono fun a => ENNReal.coe_le_coe.2 (h a) #align measure_theory.lintegral_mono_nnreal MeasureTheory.lintegral_mono_nnreal theorem iSup_lintegral_measurable_le_eq_lintegral (f : α → ℝ≥0∞) : ⨆ (g : α → ℝ≥0∞) (_ : Measurable g) (_ : g ≤ f), ∫⁻ a, g a ∂μ = ∫⁻ a, f a ∂μ := by apply le_antisymm · exact iSup_le fun i => iSup_le fun _ => iSup_le fun h'i => lintegral_mono h'i · rw [lintegral] refine iSup₂_le fun i hi => le_iSup₂_of_le i i.measurable <| le_iSup_of_le hi ?_ exact le_of_eq (i.lintegral_eq_lintegral _).symm #align measure_theory.supr_lintegral_measurable_le_eq_lintegral MeasureTheory.iSup_lintegral_measurable_le_eq_lintegral theorem lintegral_mono_set {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞} (hst : s ⊆ t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ := lintegral_mono' (Measure.restrict_mono hst (le_refl μ)) (le_refl f) #align measure_theory.lintegral_mono_set MeasureTheory.lintegral_mono_set theorem lintegral_mono_set' {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞} (hst : s ≤ᵐ[μ] t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ := lintegral_mono' (Measure.restrict_mono' hst (le_refl μ)) (le_refl f) #align measure_theory.lintegral_mono_set' MeasureTheory.lintegral_mono_set' theorem monotone_lintegral {_ : MeasurableSpace α} (μ : Measure α) : Monotone (lintegral μ) := lintegral_mono #align measure_theory.monotone_lintegral MeasureTheory.monotone_lintegral @[simp] theorem lintegral_const (c : ℝ≥0∞) : ∫⁻ _, c ∂μ = c * μ univ := by rw [← SimpleFunc.const_lintegral, ← SimpleFunc.lintegral_eq_lintegral, SimpleFunc.coe_const] rfl #align measure_theory.lintegral_const MeasureTheory.lintegral_const theorem lintegral_zero : ∫⁻ _ : α, 0 ∂μ = 0 := by simp #align measure_theory.lintegral_zero MeasureTheory.lintegral_zero theorem lintegral_zero_fun : lintegral μ (0 : α → ℝ≥0∞) = 0 := lintegral_zero #align measure_theory.lintegral_zero_fun MeasureTheory.lintegral_zero_fun -- @[simp] -- Porting note (#10618): simp can prove this theorem lintegral_one : ∫⁻ _, (1 : ℝ≥0∞) ∂μ = μ univ := by rw [lintegral_const, one_mul] #align measure_theory.lintegral_one MeasureTheory.lintegral_one theorem set_lintegral_const (s : Set α) (c : ℝ≥0∞) : ∫⁻ _ in s, c ∂μ = c * μ s := by rw [lintegral_const, Measure.restrict_apply_univ] #align measure_theory.set_lintegral_const MeasureTheory.set_lintegral_const theorem set_lintegral_one (s) : ∫⁻ _ in s, 1 ∂μ = μ s := by rw [set_lintegral_const, one_mul] #align measure_theory.set_lintegral_one MeasureTheory.set_lintegral_one theorem set_lintegral_const_lt_top [IsFiniteMeasure μ] (s : Set α) {c : ℝ≥0∞} (hc : c ≠ ∞) : ∫⁻ _ in s, c ∂μ < ∞ := by rw [lintegral_const] exact ENNReal.mul_lt_top hc (measure_ne_top (μ.restrict s) univ) #align measure_theory.set_lintegral_const_lt_top MeasureTheory.set_lintegral_const_lt_top theorem lintegral_const_lt_top [IsFiniteMeasure μ] {c : ℝ≥0∞} (hc : c ≠ ∞) : ∫⁻ _, c ∂μ < ∞ := by simpa only [Measure.restrict_univ] using set_lintegral_const_lt_top (univ : Set α) hc #align measure_theory.lintegral_const_lt_top MeasureTheory.lintegral_const_lt_top section variable (μ) theorem exists_measurable_le_lintegral_eq (f : α → ℝ≥0∞) : ∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := by rcases eq_or_ne (∫⁻ a, f a ∂μ) 0 with h₀ | h₀ · exact ⟨0, measurable_zero, zero_le f, h₀.trans lintegral_zero.symm⟩ rcases exists_seq_strictMono_tendsto' h₀.bot_lt with ⟨L, _, hLf, hL_tendsto⟩ have : ∀ n, ∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ L n < ∫⁻ a, g a ∂μ := by intro n simpa only [← iSup_lintegral_measurable_le_eq_lintegral f, lt_iSup_iff, exists_prop] using (hLf n).2 choose g hgm hgf hLg using this refine ⟨fun x => ⨆ n, g n x, measurable_iSup hgm, fun x => iSup_le fun n => hgf n x, le_antisymm ?_ ?_⟩ · refine le_of_tendsto' hL_tendsto fun n => (hLg n).le.trans <| lintegral_mono fun x => ?_ exact le_iSup (fun n => g n x) n · exact lintegral_mono fun x => iSup_le fun n => hgf n x #align measure_theory.exists_measurable_le_lintegral_eq MeasureTheory.exists_measurable_le_lintegral_eq end theorem lintegral_eq_nnreal {m : MeasurableSpace α} (f : α → ℝ≥0∞) (μ : Measure α) : ∫⁻ a, f a ∂μ = ⨆ (φ : α →ₛ ℝ≥0) (_ : ∀ x, ↑(φ x) ≤ f x), (φ.map ((↑) : ℝ≥0 → ℝ≥0∞)).lintegral μ := by rw [lintegral] refine le_antisymm (iSup₂_le fun φ hφ => ?_) (iSup_mono' fun φ => ⟨φ.map ((↑) : ℝ≥0 → ℝ≥0∞), le_rfl⟩) by_cases h : ∀ᵐ a ∂μ, φ a ≠ ∞ · let ψ := φ.map ENNReal.toNNReal replace h : ψ.map ((↑) : ℝ≥0 → ℝ≥0∞) =ᵐ[μ] φ := h.mono fun a => ENNReal.coe_toNNReal have : ∀ x, ↑(ψ x) ≤ f x := fun x => le_trans ENNReal.coe_toNNReal_le_self (hφ x) exact le_iSup_of_le (φ.map ENNReal.toNNReal) (le_iSup_of_le this (ge_of_eq <| lintegral_congr h)) · have h_meas : μ (φ ⁻¹' {∞}) ≠ 0 := mt measure_zero_iff_ae_nmem.1 h refine le_trans le_top (ge_of_eq <| (iSup_eq_top _).2 fun b hb => ?_) obtain ⟨n, hn⟩ : ∃ n : ℕ, b < n * μ (φ ⁻¹' {∞}) := exists_nat_mul_gt h_meas (ne_of_lt hb) use (const α (n : ℝ≥0)).restrict (φ ⁻¹' {∞}) simp only [lt_iSup_iff, exists_prop, coe_restrict, φ.measurableSet_preimage, coe_const, ENNReal.coe_indicator, map_coe_ennreal_restrict, SimpleFunc.map_const, ENNReal.coe_natCast, restrict_const_lintegral] refine ⟨indicator_le fun x hx => le_trans ?_ (hφ _), hn⟩ simp only [mem_preimage, mem_singleton_iff] at hx simp only [hx, le_top] #align measure_theory.lintegral_eq_nnreal MeasureTheory.lintegral_eq_nnreal theorem exists_simpleFunc_forall_lintegral_sub_lt_of_pos {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ φ : α →ₛ ℝ≥0, (∀ x, ↑(φ x) ≤ f x) ∧ ∀ ψ : α →ₛ ℝ≥0, (∀ x, ↑(ψ x) ≤ f x) → (map (↑) (ψ - φ)).lintegral μ < ε := by rw [lintegral_eq_nnreal] at h have := ENNReal.lt_add_right h hε erw [ENNReal.biSup_add] at this <;> [skip; exact ⟨0, fun x => zero_le _⟩] simp_rw [lt_iSup_iff, iSup_lt_iff, iSup_le_iff] at this rcases this with ⟨φ, hle : ∀ x, ↑(φ x) ≤ f x, b, hbφ, hb⟩ refine ⟨φ, hle, fun ψ hψ => ?_⟩ have : (map (↑) φ).lintegral μ ≠ ∞ := ne_top_of_le_ne_top h (by exact le_iSup₂ (α := ℝ≥0∞) φ hle) rw [← ENNReal.add_lt_add_iff_left this, ← add_lintegral, ← SimpleFunc.map_add @ENNReal.coe_add] refine (hb _ fun x => le_trans ?_ (max_le (hle x) (hψ x))).trans_lt hbφ norm_cast simp only [add_apply, sub_apply, add_tsub_eq_max] rfl #align measure_theory.exists_simple_func_forall_lintegral_sub_lt_of_pos MeasureTheory.exists_simpleFunc_forall_lintegral_sub_lt_of_pos theorem iSup_lintegral_le {ι : Sort*} (f : ι → α → ℝ≥0∞) : ⨆ i, ∫⁻ a, f i a ∂μ ≤ ∫⁻ a, ⨆ i, f i a ∂μ := by simp only [← iSup_apply] exact (monotone_lintegral μ).le_map_iSup #align measure_theory.supr_lintegral_le MeasureTheory.iSup_lintegral_le theorem iSup₂_lintegral_le {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) : ⨆ (i) (j), ∫⁻ a, f i j a ∂μ ≤ ∫⁻ a, ⨆ (i) (j), f i j a ∂μ := by convert (monotone_lintegral μ).le_map_iSup₂ f with a simp only [iSup_apply] #align measure_theory.supr₂_lintegral_le MeasureTheory.iSup₂_lintegral_le theorem le_iInf_lintegral {ι : Sort*} (f : ι → α → ℝ≥0∞) : ∫⁻ a, ⨅ i, f i a ∂μ ≤ ⨅ i, ∫⁻ a, f i a ∂μ := by simp only [← iInf_apply] exact (monotone_lintegral μ).map_iInf_le #align measure_theory.le_infi_lintegral MeasureTheory.le_iInf_lintegral theorem le_iInf₂_lintegral {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) : ∫⁻ a, ⨅ (i) (h : ι' i), f i h a ∂μ ≤ ⨅ (i) (h : ι' i), ∫⁻ a, f i h a ∂μ := by convert (monotone_lintegral μ).map_iInf₂_le f with a simp only [iInf_apply] #align measure_theory.le_infi₂_lintegral MeasureTheory.le_iInf₂_lintegral
Mathlib/MeasureTheory/Integral/Lebesgue.lean
266
280
theorem lintegral_mono_ae {f g : α → ℝ≥0∞} (h : ∀ᵐ a ∂μ, f a ≤ g a) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := by
rcases exists_measurable_superset_of_null h with ⟨t, hts, ht, ht0⟩ have : ∀ᵐ x ∂μ, x ∉ t := measure_zero_iff_ae_nmem.1 ht0 rw [lintegral, lintegral] refine iSup_le fun s => iSup_le fun hfs => le_iSup_of_le (s.restrict tᶜ) <| le_iSup_of_le ?_ ?_ · intro a by_cases h : a ∈ t <;> simp only [restrict_apply s ht.compl, mem_compl_iff, h, not_true, not_false_eq_true, indicator_of_not_mem, zero_le, not_false_eq_true, indicator_of_mem] exact le_trans (hfs a) (_root_.by_contradiction fun hnfg => h (hts hnfg)) · refine le_of_eq (SimpleFunc.lintegral_congr <| this.mono fun a hnt => ?_) by_cases hat : a ∈ t <;> simp only [restrict_apply s ht.compl, mem_compl_iff, hat, not_true, not_false_eq_true, indicator_of_not_mem, not_false_eq_true, indicator_of_mem] exact (hnt hat).elim
import Mathlib.Algebra.Field.Basic import Mathlib.Algebra.GroupWithZero.Units.Equiv import Mathlib.Algebra.Order.Field.Defs import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Order.Bounds.OrderIso import Mathlib.Tactic.Positivity.Core #align_import algebra.order.field.basic from "leanprover-community/mathlib"@"84771a9f5f0bd5e5d6218811556508ddf476dcbd" open Function OrderDual variable {ι α β : Type*} section LinearOrderedSemifield variable [LinearOrderedSemifield α] {a b c d e : α} {m n : ℤ} @[simps! (config := { simpRhs := true })] def OrderIso.mulLeft₀ (a : α) (ha : 0 < a) : α ≃o α := { Equiv.mulLeft₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_left ha } #align order_iso.mul_left₀ OrderIso.mulLeft₀ #align order_iso.mul_left₀_symm_apply OrderIso.mulLeft₀_symm_apply #align order_iso.mul_left₀_apply OrderIso.mulLeft₀_apply @[simps! (config := { simpRhs := true })] def OrderIso.mulRight₀ (a : α) (ha : 0 < a) : α ≃o α := { Equiv.mulRight₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_right ha } #align order_iso.mul_right₀ OrderIso.mulRight₀ #align order_iso.mul_right₀_symm_apply OrderIso.mulRight₀_symm_apply #align order_iso.mul_right₀_apply OrderIso.mulRight₀_apply theorem le_div_iff (hc : 0 < c) : a ≤ b / c ↔ a * c ≤ b := ⟨fun h => div_mul_cancel₀ b (ne_of_lt hc).symm ▸ mul_le_mul_of_nonneg_right h hc.le, fun h => calc a = a * c * (1 / c) := mul_mul_div a (ne_of_lt hc).symm _ ≤ b * (1 / c) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hc).le _ = b / c := (div_eq_mul_one_div b c).symm ⟩ #align le_div_iff le_div_iff theorem le_div_iff' (hc : 0 < c) : a ≤ b / c ↔ c * a ≤ b := by rw [mul_comm, le_div_iff hc] #align le_div_iff' le_div_iff' theorem div_le_iff (hb : 0 < b) : a / b ≤ c ↔ a ≤ c * b := ⟨fun h => calc a = a / b * b := by rw [div_mul_cancel₀ _ (ne_of_lt hb).symm] _ ≤ c * b := mul_le_mul_of_nonneg_right h hb.le , fun h => calc a / b = a * (1 / b) := div_eq_mul_one_div a b _ ≤ c * b * (1 / b) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hb).le _ = c * b / b := (div_eq_mul_one_div (c * b) b).symm _ = c := by refine (div_eq_iff (ne_of_gt hb)).mpr rfl ⟩ #align div_le_iff div_le_iff theorem div_le_iff' (hb : 0 < b) : a / b ≤ c ↔ a ≤ b * c := by rw [mul_comm, div_le_iff hb] #align div_le_iff' div_le_iff' lemma div_le_comm₀ (hb : 0 < b) (hc : 0 < c) : a / b ≤ c ↔ a / c ≤ b := by rw [div_le_iff hb, div_le_iff' hc] theorem lt_div_iff (hc : 0 < c) : a < b / c ↔ a * c < b := lt_iff_lt_of_le_iff_le <| div_le_iff hc #align lt_div_iff lt_div_iff theorem lt_div_iff' (hc : 0 < c) : a < b / c ↔ c * a < b := by rw [mul_comm, lt_div_iff hc] #align lt_div_iff' lt_div_iff' theorem div_lt_iff (hc : 0 < c) : b / c < a ↔ b < a * c := lt_iff_lt_of_le_iff_le (le_div_iff hc) #align div_lt_iff div_lt_iff theorem div_lt_iff' (hc : 0 < c) : b / c < a ↔ b < c * a := by rw [mul_comm, div_lt_iff hc] #align div_lt_iff' div_lt_iff' lemma div_lt_comm₀ (hb : 0 < b) (hc : 0 < c) : a / b < c ↔ a / c < b := by rw [div_lt_iff hb, div_lt_iff' hc] theorem inv_mul_le_iff (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ b * c := by rw [inv_eq_one_div, mul_comm, ← div_eq_mul_one_div] exact div_le_iff' h #align inv_mul_le_iff inv_mul_le_iff theorem inv_mul_le_iff' (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ c * b := by rw [inv_mul_le_iff h, mul_comm] #align inv_mul_le_iff' inv_mul_le_iff' theorem mul_inv_le_iff (h : 0 < b) : a * b⁻¹ ≤ c ↔ a ≤ b * c := by rw [mul_comm, inv_mul_le_iff h] #align mul_inv_le_iff mul_inv_le_iff theorem mul_inv_le_iff' (h : 0 < b) : a * b⁻¹ ≤ c ↔ a ≤ c * b := by rw [mul_comm, inv_mul_le_iff' h] #align mul_inv_le_iff' mul_inv_le_iff' theorem div_self_le_one (a : α) : a / a ≤ 1 := if h : a = 0 then by simp [h] else by simp [h] #align div_self_le_one div_self_le_one theorem inv_mul_lt_iff (h : 0 < b) : b⁻¹ * a < c ↔ a < b * c := by rw [inv_eq_one_div, mul_comm, ← div_eq_mul_one_div] exact div_lt_iff' h #align inv_mul_lt_iff inv_mul_lt_iff theorem inv_mul_lt_iff' (h : 0 < b) : b⁻¹ * a < c ↔ a < c * b := by rw [inv_mul_lt_iff h, mul_comm] #align inv_mul_lt_iff' inv_mul_lt_iff' theorem mul_inv_lt_iff (h : 0 < b) : a * b⁻¹ < c ↔ a < b * c := by rw [mul_comm, inv_mul_lt_iff h] #align mul_inv_lt_iff mul_inv_lt_iff theorem mul_inv_lt_iff' (h : 0 < b) : a * b⁻¹ < c ↔ a < c * b := by rw [mul_comm, inv_mul_lt_iff' h] #align mul_inv_lt_iff' mul_inv_lt_iff' theorem inv_pos_le_iff_one_le_mul (ha : 0 < a) : a⁻¹ ≤ b ↔ 1 ≤ b * a := by rw [inv_eq_one_div] exact div_le_iff ha #align inv_pos_le_iff_one_le_mul inv_pos_le_iff_one_le_mul theorem inv_pos_le_iff_one_le_mul' (ha : 0 < a) : a⁻¹ ≤ b ↔ 1 ≤ a * b := by rw [inv_eq_one_div] exact div_le_iff' ha #align inv_pos_le_iff_one_le_mul' inv_pos_le_iff_one_le_mul' theorem inv_pos_lt_iff_one_lt_mul (ha : 0 < a) : a⁻¹ < b ↔ 1 < b * a := by rw [inv_eq_one_div] exact div_lt_iff ha #align inv_pos_lt_iff_one_lt_mul inv_pos_lt_iff_one_lt_mul theorem inv_pos_lt_iff_one_lt_mul' (ha : 0 < a) : a⁻¹ < b ↔ 1 < a * b := by rw [inv_eq_one_div] exact div_lt_iff' ha #align inv_pos_lt_iff_one_lt_mul' inv_pos_lt_iff_one_lt_mul' theorem div_le_of_nonneg_of_le_mul (hb : 0 ≤ b) (hc : 0 ≤ c) (h : a ≤ c * b) : a / b ≤ c := by rcases eq_or_lt_of_le hb with (rfl | hb') · simp only [div_zero, hc] · rwa [div_le_iff hb'] #align div_le_of_nonneg_of_le_mul div_le_of_nonneg_of_le_mul lemma mul_le_of_nonneg_of_le_div (hb : 0 ≤ b) (hc : 0 ≤ c) (h : a ≤ b / c) : a * c ≤ b := by obtain rfl | hc := hc.eq_or_lt · simpa using hb · rwa [le_div_iff hc] at h #align mul_le_of_nonneg_of_le_div mul_le_of_nonneg_of_le_div theorem div_le_one_of_le (h : a ≤ b) (hb : 0 ≤ b) : a / b ≤ 1 := div_le_of_nonneg_of_le_mul hb zero_le_one <| by rwa [one_mul] #align div_le_one_of_le div_le_one_of_le lemma mul_inv_le_one_of_le (h : a ≤ b) (hb : 0 ≤ b) : a * b⁻¹ ≤ 1 := by simpa only [← div_eq_mul_inv] using div_le_one_of_le h hb lemma inv_mul_le_one_of_le (h : a ≤ b) (hb : 0 ≤ b) : b⁻¹ * a ≤ 1 := by simpa only [← div_eq_inv_mul] using div_le_one_of_le h hb @[gcongr] theorem inv_le_inv_of_le (ha : 0 < a) (h : a ≤ b) : b⁻¹ ≤ a⁻¹ := by rwa [← one_div a, le_div_iff' ha, ← div_eq_mul_inv, div_le_iff (ha.trans_le h), one_mul] #align inv_le_inv_of_le inv_le_inv_of_le theorem inv_le_inv (ha : 0 < a) (hb : 0 < b) : a⁻¹ ≤ b⁻¹ ↔ b ≤ a := by rw [← one_div, div_le_iff ha, ← div_eq_inv_mul, le_div_iff hb, one_mul] #align inv_le_inv inv_le_inv theorem inv_le (ha : 0 < a) (hb : 0 < b) : a⁻¹ ≤ b ↔ b⁻¹ ≤ a := by rw [← inv_le_inv hb (inv_pos.2 ha), inv_inv] #align inv_le inv_le theorem inv_le_of_inv_le (ha : 0 < a) (h : a⁻¹ ≤ b) : b⁻¹ ≤ a := (inv_le ha ((inv_pos.2 ha).trans_le h)).1 h #align inv_le_of_inv_le inv_le_of_inv_le theorem le_inv (ha : 0 < a) (hb : 0 < b) : a ≤ b⁻¹ ↔ b ≤ a⁻¹ := by rw [← inv_le_inv (inv_pos.2 hb) ha, inv_inv] #align le_inv le_inv theorem inv_lt_inv (ha : 0 < a) (hb : 0 < b) : a⁻¹ < b⁻¹ ↔ b < a := lt_iff_lt_of_le_iff_le (inv_le_inv hb ha) #align inv_lt_inv inv_lt_inv @[gcongr] theorem inv_lt_inv_of_lt (hb : 0 < b) (h : b < a) : a⁻¹ < b⁻¹ := (inv_lt_inv (hb.trans h) hb).2 h #align inv_lt_inv_of_lt inv_lt_inv_of_lt theorem inv_lt (ha : 0 < a) (hb : 0 < b) : a⁻¹ < b ↔ b⁻¹ < a := lt_iff_lt_of_le_iff_le (le_inv hb ha) #align inv_lt inv_lt theorem inv_lt_of_inv_lt (ha : 0 < a) (h : a⁻¹ < b) : b⁻¹ < a := (inv_lt ha ((inv_pos.2 ha).trans h)).1 h #align inv_lt_of_inv_lt inv_lt_of_inv_lt theorem lt_inv (ha : 0 < a) (hb : 0 < b) : a < b⁻¹ ↔ b < a⁻¹ := lt_iff_lt_of_le_iff_le (inv_le hb ha) #align lt_inv lt_inv theorem inv_lt_one (ha : 1 < a) : a⁻¹ < 1 := by rwa [inv_lt (zero_lt_one.trans ha) zero_lt_one, inv_one] #align inv_lt_one inv_lt_one theorem one_lt_inv (h₁ : 0 < a) (h₂ : a < 1) : 1 < a⁻¹ := by rwa [lt_inv (@zero_lt_one α _ _ _ _ _) h₁, inv_one] #align one_lt_inv one_lt_inv theorem inv_le_one (ha : 1 ≤ a) : a⁻¹ ≤ 1 := by rwa [inv_le (zero_lt_one.trans_le ha) zero_lt_one, inv_one] #align inv_le_one inv_le_one theorem one_le_inv (h₁ : 0 < a) (h₂ : a ≤ 1) : 1 ≤ a⁻¹ := by rwa [le_inv (@zero_lt_one α _ _ _ _ _) h₁, inv_one] #align one_le_inv one_le_inv theorem inv_lt_one_iff_of_pos (h₀ : 0 < a) : a⁻¹ < 1 ↔ 1 < a := ⟨fun h₁ => inv_inv a ▸ one_lt_inv (inv_pos.2 h₀) h₁, inv_lt_one⟩ #align inv_lt_one_iff_of_pos inv_lt_one_iff_of_pos theorem inv_lt_one_iff : a⁻¹ < 1 ↔ a ≤ 0 ∨ 1 < a := by rcases le_or_lt a 0 with ha | ha · simp [ha, (inv_nonpos.2 ha).trans_lt zero_lt_one] · simp only [ha.not_le, false_or_iff, inv_lt_one_iff_of_pos ha] #align inv_lt_one_iff inv_lt_one_iff theorem one_lt_inv_iff : 1 < a⁻¹ ↔ 0 < a ∧ a < 1 := ⟨fun h => ⟨inv_pos.1 (zero_lt_one.trans h), inv_inv a ▸ inv_lt_one h⟩, and_imp.2 one_lt_inv⟩ #align one_lt_inv_iff one_lt_inv_iff theorem inv_le_one_iff : a⁻¹ ≤ 1 ↔ a ≤ 0 ∨ 1 ≤ a := by rcases em (a = 1) with (rfl | ha) · simp [le_rfl] · simp only [Ne.le_iff_lt (Ne.symm ha), Ne.le_iff_lt (mt inv_eq_one.1 ha), inv_lt_one_iff] #align inv_le_one_iff inv_le_one_iff theorem one_le_inv_iff : 1 ≤ a⁻¹ ↔ 0 < a ∧ a ≤ 1 := ⟨fun h => ⟨inv_pos.1 (zero_lt_one.trans_le h), inv_inv a ▸ inv_le_one h⟩, and_imp.2 one_le_inv⟩ #align one_le_inv_iff one_le_inv_iff @[mono, gcongr] lemma div_le_div_of_nonneg_right (hab : a ≤ b) (hc : 0 ≤ c) : a / c ≤ b / c := by rw [div_eq_mul_one_div a c, div_eq_mul_one_div b c] exact mul_le_mul_of_nonneg_right hab (one_div_nonneg.2 hc) #align div_le_div_of_le_of_nonneg div_le_div_of_nonneg_right @[gcongr] lemma div_lt_div_of_pos_right (h : a < b) (hc : 0 < c) : a / c < b / c := by rw [div_eq_mul_one_div a c, div_eq_mul_one_div b c] exact mul_lt_mul_of_pos_right h (one_div_pos.2 hc) #align div_lt_div_of_lt div_lt_div_of_pos_right -- Not a `mono` lemma b/c `div_le_div` is strictly more general @[gcongr] lemma div_le_div_of_nonneg_left (ha : 0 ≤ a) (hc : 0 < c) (h : c ≤ b) : a / b ≤ a / c := by rw [div_eq_mul_inv, div_eq_mul_inv] exact mul_le_mul_of_nonneg_left ((inv_le_inv (hc.trans_le h) hc).mpr h) ha #align div_le_div_of_le_left div_le_div_of_nonneg_left @[gcongr] lemma div_lt_div_of_pos_left (ha : 0 < a) (hc : 0 < c) (h : c < b) : a / b < a / c := by simpa only [div_eq_mul_inv, mul_lt_mul_left ha, inv_lt_inv (hc.trans h) hc] #align div_lt_div_of_lt_left div_lt_div_of_pos_left -- 2024-02-16 @[deprecated] alias div_le_div_of_le_of_nonneg := div_le_div_of_nonneg_right @[deprecated] alias div_lt_div_of_lt := div_lt_div_of_pos_right @[deprecated] alias div_le_div_of_le_left := div_le_div_of_nonneg_left @[deprecated] alias div_lt_div_of_lt_left := div_lt_div_of_pos_left @[deprecated div_le_div_of_nonneg_right (since := "2024-02-16")] lemma div_le_div_of_le (hc : 0 ≤ c) (hab : a ≤ b) : a / c ≤ b / c := div_le_div_of_nonneg_right hab hc #align div_le_div_of_le div_le_div_of_le theorem div_le_div_right (hc : 0 < c) : a / c ≤ b / c ↔ a ≤ b := ⟨le_imp_le_of_lt_imp_lt fun hab ↦ div_lt_div_of_pos_right hab hc, fun hab ↦ div_le_div_of_nonneg_right hab hc.le⟩ #align div_le_div_right div_le_div_right theorem div_lt_div_right (hc : 0 < c) : a / c < b / c ↔ a < b := lt_iff_lt_of_le_iff_le <| div_le_div_right hc #align div_lt_div_right div_lt_div_right theorem div_lt_div_left (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : a / b < a / c ↔ c < b := by simp only [div_eq_mul_inv, mul_lt_mul_left ha, inv_lt_inv hb hc] #align div_lt_div_left div_lt_div_left theorem div_le_div_left (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : a / b ≤ a / c ↔ c ≤ b := le_iff_le_iff_lt_iff_lt.2 (div_lt_div_left ha hc hb) #align div_le_div_left div_le_div_left theorem div_lt_div_iff (b0 : 0 < b) (d0 : 0 < d) : a / b < c / d ↔ a * d < c * b := by rw [lt_div_iff d0, div_mul_eq_mul_div, div_lt_iff b0] #align div_lt_div_iff div_lt_div_iff theorem div_le_div_iff (b0 : 0 < b) (d0 : 0 < d) : a / b ≤ c / d ↔ a * d ≤ c * b := by rw [le_div_iff d0, div_mul_eq_mul_div, div_le_iff b0] #align div_le_div_iff div_le_div_iff @[mono, gcongr] theorem div_le_div (hc : 0 ≤ c) (hac : a ≤ c) (hd : 0 < d) (hbd : d ≤ b) : a / b ≤ c / d := by rw [div_le_div_iff (hd.trans_le hbd) hd] exact mul_le_mul hac hbd hd.le hc #align div_le_div div_le_div @[gcongr] theorem div_lt_div (hac : a < c) (hbd : d ≤ b) (c0 : 0 ≤ c) (d0 : 0 < d) : a / b < c / d := (div_lt_div_iff (d0.trans_le hbd) d0).2 (mul_lt_mul hac hbd d0 c0) #align div_lt_div div_lt_div theorem div_lt_div' (hac : a ≤ c) (hbd : d < b) (c0 : 0 < c) (d0 : 0 < d) : a / b < c / d := (div_lt_div_iff (d0.trans hbd) d0).2 (mul_lt_mul' hac hbd d0.le c0) #align div_lt_div' div_lt_div' theorem div_le_self (ha : 0 ≤ a) (hb : 1 ≤ b) : a / b ≤ a := by simpa only [div_one] using div_le_div_of_nonneg_left ha zero_lt_one hb #align div_le_self div_le_self theorem div_lt_self (ha : 0 < a) (hb : 1 < b) : a / b < a := by simpa only [div_one] using div_lt_div_of_pos_left ha zero_lt_one hb #align div_lt_self div_lt_self theorem le_div_self (ha : 0 ≤ a) (hb₀ : 0 < b) (hb₁ : b ≤ 1) : a ≤ a / b := by simpa only [div_one] using div_le_div_of_nonneg_left ha hb₀ hb₁ #align le_div_self le_div_self theorem one_le_div (hb : 0 < b) : 1 ≤ a / b ↔ b ≤ a := by rw [le_div_iff hb, one_mul] #align one_le_div one_le_div theorem div_le_one (hb : 0 < b) : a / b ≤ 1 ↔ a ≤ b := by rw [div_le_iff hb, one_mul] #align div_le_one div_le_one theorem one_lt_div (hb : 0 < b) : 1 < a / b ↔ b < a := by rw [lt_div_iff hb, one_mul] #align one_lt_div one_lt_div theorem div_lt_one (hb : 0 < b) : a / b < 1 ↔ a < b := by rw [div_lt_iff hb, one_mul] #align div_lt_one div_lt_one theorem one_div_le (ha : 0 < a) (hb : 0 < b) : 1 / a ≤ b ↔ 1 / b ≤ a := by simpa using inv_le ha hb #align one_div_le one_div_le
Mathlib/Algebra/Order/Field/Basic.lean
379
379
theorem one_div_lt (ha : 0 < a) (hb : 0 < b) : 1 / a < b ↔ 1 / b < a := by
simpa using inv_lt ha hb
import Mathlib.LinearAlgebra.FiniteDimensional import Mathlib.RingTheory.IntegralClosure import Mathlib.RingTheory.Polynomial.IntegralNormalization #align_import ring_theory.algebraic from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" universe u v w open scoped Classical open Polynomial section variable (R : Type u) {A : Type v} [CommRing R] [Ring A] [Algebra R A] def IsAlgebraic (x : A) : Prop := ∃ p : R[X], p ≠ 0 ∧ aeval x p = 0 #align is_algebraic IsAlgebraic def Transcendental (x : A) : Prop := ¬IsAlgebraic R x #align transcendental Transcendental theorem is_transcendental_of_subsingleton [Subsingleton R] (x : A) : Transcendental R x := fun ⟨p, h, _⟩ => h <| Subsingleton.elim p 0 #align is_transcendental_of_subsingleton is_transcendental_of_subsingleton variable {R} nonrec def Subalgebra.IsAlgebraic (S : Subalgebra R A) : Prop := ∀ x ∈ S, IsAlgebraic R x #align subalgebra.is_algebraic Subalgebra.IsAlgebraic variable (R A) protected class Algebra.IsAlgebraic : Prop := isAlgebraic : ∀ x : A, IsAlgebraic R x #align algebra.is_algebraic Algebra.IsAlgebraic variable {R A} lemma Algebra.isAlgebraic_def : Algebra.IsAlgebraic R A ↔ ∀ x : A, IsAlgebraic R x := ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩ theorem Subalgebra.isAlgebraic_iff (S : Subalgebra R A) : S.IsAlgebraic ↔ @Algebra.IsAlgebraic R S _ _ S.algebra := by delta Subalgebra.IsAlgebraic rw [Subtype.forall', Algebra.isAlgebraic_def] refine forall_congr' fun x => exists_congr fun p => and_congr Iff.rfl ?_ have h : Function.Injective S.val := Subtype.val_injective conv_rhs => rw [← h.eq_iff, AlgHom.map_zero] rw [← aeval_algHom_apply, S.val_apply] #align subalgebra.is_algebraic_iff Subalgebra.isAlgebraic_iff theorem Algebra.isAlgebraic_iff : Algebra.IsAlgebraic R A ↔ (⊤ : Subalgebra R A).IsAlgebraic := by delta Subalgebra.IsAlgebraic simp only [Algebra.isAlgebraic_def, Algebra.mem_top, forall_prop_of_true, iff_self_iff] #align algebra.is_algebraic_iff Algebra.isAlgebraic_iff theorem isAlgebraic_iff_not_injective {x : A} : IsAlgebraic R x ↔ ¬Function.Injective (Polynomial.aeval x : R[X] →ₐ[R] A) := by simp only [IsAlgebraic, injective_iff_map_eq_zero, not_forall, and_comm, exists_prop] #align is_algebraic_iff_not_injective isAlgebraic_iff_not_injective end section zero_ne_one variable {R : Type u} {S : Type*} {A : Type v} [CommRing R] variable [CommRing S] [Ring A] [Algebra R A] [Algebra R S] [Algebra S A] variable [IsScalarTower R S A] theorem IsIntegral.isAlgebraic [Nontrivial R] {x : A} : IsIntegral R x → IsAlgebraic R x := fun ⟨p, hp, hpx⟩ => ⟨p, hp.ne_zero, hpx⟩ #align is_integral.is_algebraic IsIntegral.isAlgebraic instance Algebra.IsIntegral.isAlgebraic [Nontrivial R] [Algebra.IsIntegral R A] : Algebra.IsAlgebraic R A := ⟨fun a ↦ (Algebra.IsIntegral.isIntegral a).isAlgebraic⟩ theorem isAlgebraic_zero [Nontrivial R] : IsAlgebraic R (0 : A) := ⟨_, X_ne_zero, aeval_X 0⟩ #align is_algebraic_zero isAlgebraic_zero theorem isAlgebraic_algebraMap [Nontrivial R] (x : R) : IsAlgebraic R (algebraMap R A x) := ⟨_, X_sub_C_ne_zero x, by rw [_root_.map_sub, aeval_X, aeval_C, sub_self]⟩ #align is_algebraic_algebra_map isAlgebraic_algebraMap theorem isAlgebraic_one [Nontrivial R] : IsAlgebraic R (1 : A) := by rw [← _root_.map_one (algebraMap R A)] exact isAlgebraic_algebraMap 1 #align is_algebraic_one isAlgebraic_one theorem isAlgebraic_nat [Nontrivial R] (n : ℕ) : IsAlgebraic R (n : A) := by rw [← map_natCast (_ : R →+* A) n] exact isAlgebraic_algebraMap (Nat.cast n) #align is_algebraic_nat isAlgebraic_nat theorem isAlgebraic_int [Nontrivial R] (n : ℤ) : IsAlgebraic R (n : A) := by rw [← _root_.map_intCast (algebraMap R A)] exact isAlgebraic_algebraMap (Int.cast n) #align is_algebraic_int isAlgebraic_int
Mathlib/RingTheory/Algebraic.lean
128
131
theorem isAlgebraic_rat (R : Type u) {A : Type v} [DivisionRing A] [Field R] [Algebra R A] (n : ℚ) : IsAlgebraic R (n : A) := by
rw [← map_ratCast (algebraMap R A)] exact isAlgebraic_algebraMap (Rat.cast n)
import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Data.Complex.Exponential import Mathlib.Data.Complex.Module import Mathlib.RingTheory.Polynomial.Chebyshev #align_import analysis.special_functions.trigonometric.chebyshev from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" set_option linter.uppercaseLean3 false namespace Polynomial.Chebyshev open Polynomial variable {R A : Type*} [CommRing R] [CommRing A] [Algebra R A] @[simp] theorem aeval_T (x : A) (n : ℤ) : aeval x (T R n) = (T A n).eval x := by rw [aeval_def, eval₂_eq_eval_map, map_T] #align polynomial.chebyshev.aeval_T Polynomial.Chebyshev.aeval_T @[simp] theorem aeval_U (x : A) (n : ℤ) : aeval x (U R n) = (U A n).eval x := by rw [aeval_def, eval₂_eq_eval_map, map_U] #align polynomial.chebyshev.aeval_U Polynomial.Chebyshev.aeval_U @[simp] theorem algebraMap_eval_T (x : R) (n : ℤ) : algebraMap R A ((T R n).eval x) = (T A n).eval (algebraMap R A x) := by rw [← aeval_algebraMap_apply_eq_algebraMap_eval, aeval_T] #align polynomial.chebyshev.algebra_map_eval_T Polynomial.Chebyshev.algebraMap_eval_T @[simp] theorem algebraMap_eval_U (x : R) (n : ℤ) : algebraMap R A ((U R n).eval x) = (U A n).eval (algebraMap R A x) := by rw [← aeval_algebraMap_apply_eq_algebraMap_eval, aeval_U] #align polynomial.chebyshev.algebra_map_eval_U Polynomial.Chebyshev.algebraMap_eval_U -- Porting note: added type ascriptions to the statement @[simp, norm_cast] theorem complex_ofReal_eval_T : ∀ (x : ℝ) n, (((T ℝ n).eval x : ℝ) : ℂ) = (T ℂ n).eval (x : ℂ) := @algebraMap_eval_T ℝ ℂ _ _ _ #align polynomial.chebyshev.complex_of_real_eval_T Polynomial.Chebyshev.complex_ofReal_eval_T -- Porting note: added type ascriptions to the statement @[simp, norm_cast] theorem complex_ofReal_eval_U : ∀ (x : ℝ) n, (((U ℝ n).eval x : ℝ) : ℂ) = (U ℂ n).eval (x : ℂ) := @algebraMap_eval_U ℝ ℂ _ _ _ #align polynomial.chebyshev.complex_of_real_eval_U Polynomial.Chebyshev.complex_ofReal_eval_U section Complex open Complex variable (θ : ℂ) @[simp] theorem T_complex_cos (n : ℤ) : (T ℂ n).eval (cos θ) = cos (n * θ) := by induction n using Polynomial.Chebyshev.induct with | zero => simp | one => simp | add_two n ih1 ih2 => simp only [T_add_two, eval_sub, eval_mul, eval_X, eval_ofNat, ih1, ih2, sub_eq_iff_eq_add, cos_add_cos] push_cast ring_nf | neg_add_one n ih1 ih2 => simp only [T_sub_one, eval_sub, eval_mul, eval_X, eval_ofNat, ih1, ih2, sub_eq_iff_eq_add', cos_add_cos] push_cast ring_nf #align polynomial.chebyshev.T_complex_cos Polynomial.Chebyshev.T_complex_cos @[simp]
Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev.lean
92
105
theorem U_complex_cos (n : ℤ) : (U ℂ n).eval (cos θ) * sin θ = sin ((n + 1) * θ) := by
induction n using Polynomial.Chebyshev.induct with | zero => simp | one => simp [one_add_one_eq_two, sin_two_mul]; ring | add_two n ih1 ih2 => simp only [U_add_two, add_sub_cancel_right, eval_sub, eval_mul, eval_X, eval_ofNat, sub_mul, mul_assoc, ih1, ih2, sub_eq_iff_eq_add, sin_add_sin] push_cast ring_nf | neg_add_one n ih1 ih2 => simp only [U_sub_one, add_sub_cancel_right, eval_sub, eval_mul, eval_X, eval_ofNat, sub_mul, mul_assoc, ih1, ih2, sub_eq_iff_eq_add', sin_add_sin] push_cast ring_nf
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 : ℕ}
Mathlib/RingTheory/RootsOfUnity/Basic.lean
335
342
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
import Mathlib.Analysis.InnerProductSpace.Rayleigh import Mathlib.Analysis.InnerProductSpace.PiL2 import Mathlib.Algebra.DirectSum.Decomposition import Mathlib.LinearAlgebra.Eigenspace.Minpoly #align_import analysis.inner_product_space.spectrum from "leanprover-community/mathlib"@"6b0169218d01f2837d79ea2784882009a0da1aa1" variable {𝕜 : Type*} [RCLike 𝕜] variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] local notation "⟪" x ", " y "⟫" => @inner 𝕜 E _ x y open scoped ComplexConjugate open Module.End namespace LinearMap namespace IsSymmetric variable {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) theorem invariant_orthogonalComplement_eigenspace (μ : 𝕜) (v : E) (hv : v ∈ (eigenspace T μ)ᗮ) : T v ∈ (eigenspace T μ)ᗮ := by intro w hw have : T w = (μ : 𝕜) • w := by rwa [mem_eigenspace_iff] at hw simp [← hT w, this, inner_smul_left, hv w hw] #align linear_map.is_symmetric.invariant_orthogonal_eigenspace LinearMap.IsSymmetric.invariant_orthogonalComplement_eigenspace theorem conj_eigenvalue_eq_self {μ : 𝕜} (hμ : HasEigenvalue T μ) : conj μ = μ := by obtain ⟨v, hv₁, hv₂⟩ := hμ.exists_hasEigenvector rw [mem_eigenspace_iff] at hv₁ simpa [hv₂, inner_smul_left, inner_smul_right, hv₁] using hT v v #align linear_map.is_symmetric.conj_eigenvalue_eq_self LinearMap.IsSymmetric.conj_eigenvalue_eq_self theorem orthogonalFamily_eigenspaces : OrthogonalFamily 𝕜 (fun μ => eigenspace T μ) fun μ => (eigenspace T μ).subtypeₗᵢ := by rintro μ ν hμν ⟨v, hv⟩ ⟨w, hw⟩ by_cases hv' : v = 0 · simp [hv'] have H := hT.conj_eigenvalue_eq_self (hasEigenvalue_of_hasEigenvector ⟨hv, hv'⟩) rw [mem_eigenspace_iff] at hv hw refine Or.resolve_left ?_ hμν.symm simpa [inner_smul_left, inner_smul_right, hv, hw, H] using (hT v w).symm #align linear_map.is_symmetric.orthogonal_family_eigenspaces LinearMap.IsSymmetric.orthogonalFamily_eigenspaces theorem orthogonalFamily_eigenspaces' : OrthogonalFamily 𝕜 (fun μ : Eigenvalues T => eigenspace T μ) fun μ => (eigenspace T μ).subtypeₗᵢ := hT.orthogonalFamily_eigenspaces.comp Subtype.coe_injective #align linear_map.is_symmetric.orthogonal_family_eigenspaces' LinearMap.IsSymmetric.orthogonalFamily_eigenspaces' theorem orthogonalComplement_iSup_eigenspaces_invariant ⦃v : E⦄ (hv : v ∈ (⨆ μ, eigenspace T μ)ᗮ) : T v ∈ (⨆ μ, eigenspace T μ)ᗮ := by rw [← Submodule.iInf_orthogonal] at hv ⊢ exact T.iInf_invariant hT.invariant_orthogonalComplement_eigenspace v hv #align linear_map.is_symmetric.orthogonal_supr_eigenspaces_invariant LinearMap.IsSymmetric.orthogonalComplement_iSup_eigenspaces_invariant theorem orthogonalComplement_iSup_eigenspaces (μ : 𝕜) : eigenspace (T.restrict hT.orthogonalComplement_iSup_eigenspaces_invariant) μ = ⊥ := by set p : Submodule 𝕜 E := (⨆ μ, eigenspace T μ)ᗮ refine eigenspace_restrict_eq_bot hT.orthogonalComplement_iSup_eigenspaces_invariant ?_ have H₂ : eigenspace T μ ⟂ p := (Submodule.isOrtho_orthogonal_right _).mono_left (le_iSup _ _) exact H₂.disjoint #align linear_map.is_symmetric.orthogonal_supr_eigenspaces LinearMap.IsSymmetric.orthogonalComplement_iSup_eigenspaces variable [FiniteDimensional 𝕜 E] theorem orthogonalComplement_iSup_eigenspaces_eq_bot : (⨆ μ, eigenspace T μ)ᗮ = ⊥ := by have hT' : IsSymmetric _ := hT.restrict_invariant hT.orthogonalComplement_iSup_eigenspaces_invariant -- a self-adjoint operator on a nontrivial inner product space has an eigenvalue haveI := hT'.subsingleton_of_no_eigenvalue_finiteDimensional hT.orthogonalComplement_iSup_eigenspaces exact Submodule.eq_bot_of_subsingleton #align linear_map.is_symmetric.orthogonal_supr_eigenspaces_eq_bot LinearMap.IsSymmetric.orthogonalComplement_iSup_eigenspaces_eq_bot theorem orthogonalComplement_iSup_eigenspaces_eq_bot' : (⨆ μ : Eigenvalues T, eigenspace T μ)ᗮ = ⊥ := show (⨆ μ : { μ // eigenspace T μ ≠ ⊥ }, eigenspace T μ)ᗮ = ⊥ by rw [iSup_ne_bot_subtype, hT.orthogonalComplement_iSup_eigenspaces_eq_bot] #align linear_map.is_symmetric.orthogonal_supr_eigenspaces_eq_bot' LinearMap.IsSymmetric.orthogonalComplement_iSup_eigenspaces_eq_bot' noncomputable instance directSumDecomposition [hT : Fact T.IsSymmetric] : DirectSum.Decomposition fun μ : Eigenvalues T => eigenspace T μ := haveI h : ∀ μ : Eigenvalues T, CompleteSpace (eigenspace T μ) := fun μ => by infer_instance hT.out.orthogonalFamily_eigenspaces'.decomposition (Submodule.orthogonal_eq_bot_iff.mp hT.out.orthogonalComplement_iSup_eigenspaces_eq_bot') #align linear_map.is_symmetric.direct_sum_decomposition LinearMap.IsSymmetric.directSumDecomposition theorem directSum_decompose_apply [_hT : Fact T.IsSymmetric] (x : E) (μ : Eigenvalues T) : DirectSum.decompose (fun μ : Eigenvalues T => eigenspace T μ) x μ = orthogonalProjection (eigenspace T μ) x := rfl #align linear_map.is_symmetric.direct_sum_decompose_apply LinearMap.IsSymmetric.directSum_decompose_apply theorem direct_sum_isInternal : DirectSum.IsInternal fun μ : Eigenvalues T => eigenspace T μ := hT.orthogonalFamily_eigenspaces'.isInternal_iff.mpr hT.orthogonalComplement_iSup_eigenspaces_eq_bot' #align linear_map.is_symmetric.direct_sum_is_internal LinearMap.IsSymmetric.direct_sum_isInternal section Version2 variable {n : ℕ} (hn : FiniteDimensional.finrank 𝕜 E = n) noncomputable irreducible_def eigenvectorBasis : OrthonormalBasis (Fin n) 𝕜 E := hT.direct_sum_isInternal.subordinateOrthonormalBasis hn hT.orthogonalFamily_eigenspaces' #align linear_map.is_symmetric.eigenvector_basis LinearMap.IsSymmetric.eigenvectorBasis noncomputable irreducible_def eigenvalues (i : Fin n) : ℝ := @RCLike.re 𝕜 _ <| (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i hT.orthogonalFamily_eigenspaces').val #align linear_map.is_symmetric.eigenvalues LinearMap.IsSymmetric.eigenvalues
Mathlib/Analysis/InnerProductSpace/Spectrum.lean
218
237
theorem hasEigenvector_eigenvectorBasis (i : Fin n) : HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
let v : E := hT.eigenvectorBasis hn i let μ : 𝕜 := (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i hT.orthogonalFamily_eigenspaces').val simp_rw [eigenvalues] change HasEigenvector T (RCLike.re μ) v have key : HasEigenvector T μ v := by have H₁ : v ∈ eigenspace T μ := by simp_rw [v, eigenvectorBasis] exact hT.direct_sum_isInternal.subordinateOrthonormalBasis_subordinate hn i hT.orthogonalFamily_eigenspaces' have H₂ : v ≠ 0 := by simpa using (hT.eigenvectorBasis hn).toBasis.ne_zero i exact ⟨H₁, H₂⟩ have re_μ : ↑(RCLike.re μ) = μ := by rw [← RCLike.conj_eq_iff_re] exact hT.conj_eigenvalue_eq_self (hasEigenvalue_of_hasEigenvector key) simpa [re_μ] using key
import Mathlib.Logic.Pairwise import Mathlib.Order.CompleteBooleanAlgebra import Mathlib.Order.Directed import Mathlib.Order.GaloisConnection #align_import data.set.lattice from "leanprover-community/mathlib"@"b86832321b586c6ac23ef8cdef6a7a27e42b13bd" open Function Set universe u variable {α β γ : Type*} {ι ι' ι₂ : Sort*} {κ κ₁ κ₂ : ι → Sort*} {κ' : ι' → Sort*} namespace Set theorem mem_iUnion₂ {x : γ} {s : ∀ i, κ i → Set γ} : (x ∈ ⋃ (i) (j), s i j) ↔ ∃ i j, x ∈ s i j := by simp_rw [mem_iUnion] #align set.mem_Union₂ Set.mem_iUnion₂ theorem mem_iInter₂ {x : γ} {s : ∀ i, κ i → Set γ} : (x ∈ ⋂ (i) (j), s i j) ↔ ∀ i j, x ∈ s i j := by simp_rw [mem_iInter] #align set.mem_Inter₂ Set.mem_iInter₂ theorem mem_iUnion_of_mem {s : ι → Set α} {a : α} (i : ι) (ha : a ∈ s i) : a ∈ ⋃ i, s i := mem_iUnion.2 ⟨i, ha⟩ #align set.mem_Union_of_mem Set.mem_iUnion_of_mem theorem mem_iUnion₂_of_mem {s : ∀ i, κ i → Set α} {a : α} {i : ι} (j : κ i) (ha : a ∈ s i j) : a ∈ ⋃ (i) (j), s i j := mem_iUnion₂.2 ⟨i, j, ha⟩ #align set.mem_Union₂_of_mem Set.mem_iUnion₂_of_mem theorem mem_iInter_of_mem {s : ι → Set α} {a : α} (h : ∀ i, a ∈ s i) : a ∈ ⋂ i, s i := mem_iInter.2 h #align set.mem_Inter_of_mem Set.mem_iInter_of_mem theorem mem_iInter₂_of_mem {s : ∀ i, κ i → Set α} {a : α} (h : ∀ i j, a ∈ s i j) : a ∈ ⋂ (i) (j), s i j := mem_iInter₂.2 h #align set.mem_Inter₂_of_mem Set.mem_iInter₂_of_mem instance completeAtomicBooleanAlgebra : CompleteAtomicBooleanAlgebra (Set α) := { instBooleanAlgebraSet with le_sSup := fun s t t_in a a_in => ⟨t, t_in, a_in⟩ sSup_le := fun s t h a ⟨t', ⟨t'_in, a_in⟩⟩ => h t' t'_in a_in le_sInf := fun s t h a a_in t' t'_in => h t' t'_in a_in sInf_le := fun s t t_in a h => h _ t_in iInf_iSup_eq := by intros; ext; simp [Classical.skolem] } instance : OrderTop (Set α) where top := univ le_top := by simp @[congr] theorem iUnion_congr_Prop {p q : Prop} {f₁ : p → Set α} {f₂ : q → Set α} (pq : p ↔ q) (f : ∀ x, f₁ (pq.mpr x) = f₂ x) : iUnion f₁ = iUnion f₂ := iSup_congr_Prop pq f #align set.Union_congr_Prop Set.iUnion_congr_Prop @[congr] theorem iInter_congr_Prop {p q : Prop} {f₁ : p → Set α} {f₂ : q → Set α} (pq : p ↔ q) (f : ∀ x, f₁ (pq.mpr x) = f₂ x) : iInter f₁ = iInter f₂ := iInf_congr_Prop pq f #align set.Inter_congr_Prop Set.iInter_congr_Prop theorem iUnion_plift_up (f : PLift ι → Set α) : ⋃ i, f (PLift.up i) = ⋃ i, f i := iSup_plift_up _ #align set.Union_plift_up Set.iUnion_plift_up theorem iUnion_plift_down (f : ι → Set α) : ⋃ i, f (PLift.down i) = ⋃ i, f i := iSup_plift_down _ #align set.Union_plift_down Set.iUnion_plift_down theorem iInter_plift_up (f : PLift ι → Set α) : ⋂ i, f (PLift.up i) = ⋂ i, f i := iInf_plift_up _ #align set.Inter_plift_up Set.iInter_plift_up theorem iInter_plift_down (f : ι → Set α) : ⋂ i, f (PLift.down i) = ⋂ i, f i := iInf_plift_down _ #align set.Inter_plift_down Set.iInter_plift_down theorem iUnion_eq_if {p : Prop} [Decidable p] (s : Set α) : ⋃ _ : p, s = if p then s else ∅ := iSup_eq_if _ #align set.Union_eq_if Set.iUnion_eq_if theorem iUnion_eq_dif {p : Prop} [Decidable p] (s : p → Set α) : ⋃ h : p, s h = if h : p then s h else ∅ := iSup_eq_dif _ #align set.Union_eq_dif Set.iUnion_eq_dif theorem iInter_eq_if {p : Prop} [Decidable p] (s : Set α) : ⋂ _ : p, s = if p then s else univ := iInf_eq_if _ #align set.Inter_eq_if Set.iInter_eq_if theorem iInf_eq_dif {p : Prop} [Decidable p] (s : p → Set α) : ⋂ h : p, s h = if h : p then s h else univ := _root_.iInf_eq_dif _ #align set.Infi_eq_dif Set.iInf_eq_dif theorem exists_set_mem_of_union_eq_top {ι : Type*} (t : Set ι) (s : ι → Set β) (w : ⋃ i ∈ t, s i = ⊤) (x : β) : ∃ i ∈ t, x ∈ s i := by have p : x ∈ ⊤ := Set.mem_univ x rw [← w, Set.mem_iUnion] at p simpa using p #align set.exists_set_mem_of_union_eq_top Set.exists_set_mem_of_union_eq_top theorem nonempty_of_union_eq_top_of_nonempty {ι : Type*} (t : Set ι) (s : ι → Set α) (H : Nonempty α) (w : ⋃ i ∈ t, s i = ⊤) : t.Nonempty := by obtain ⟨x, m, -⟩ := exists_set_mem_of_union_eq_top t s w H.some exact ⟨x, m⟩ #align set.nonempty_of_union_eq_top_of_nonempty Set.nonempty_of_union_eq_top_of_nonempty theorem nonempty_of_nonempty_iUnion {s : ι → Set α} (h_Union : (⋃ i, s i).Nonempty) : Nonempty ι := by obtain ⟨x, hx⟩ := h_Union exact ⟨Classical.choose <| mem_iUnion.mp hx⟩ theorem nonempty_of_nonempty_iUnion_eq_univ {s : ι → Set α} [Nonempty α] (h_Union : ⋃ i, s i = univ) : Nonempty ι := nonempty_of_nonempty_iUnion (s := s) (by simpa only [h_Union] using univ_nonempty) theorem setOf_exists (p : ι → β → Prop) : { x | ∃ i, p i x } = ⋃ i, { x | p i x } := ext fun _ => mem_iUnion.symm #align set.set_of_exists Set.setOf_exists theorem setOf_forall (p : ι → β → Prop) : { x | ∀ i, p i x } = ⋂ i, { x | p i x } := ext fun _ => mem_iInter.symm #align set.set_of_forall Set.setOf_forall theorem iUnion_subset {s : ι → Set α} {t : Set α} (h : ∀ i, s i ⊆ t) : ⋃ i, s i ⊆ t := iSup_le h #align set.Union_subset Set.iUnion_subset theorem iUnion₂_subset {s : ∀ i, κ i → Set α} {t : Set α} (h : ∀ i j, s i j ⊆ t) : ⋃ (i) (j), s i j ⊆ t := iUnion_subset fun x => iUnion_subset (h x) #align set.Union₂_subset Set.iUnion₂_subset theorem subset_iInter {t : Set β} {s : ι → Set β} (h : ∀ i, t ⊆ s i) : t ⊆ ⋂ i, s i := le_iInf h #align set.subset_Inter Set.subset_iInter theorem subset_iInter₂ {s : Set α} {t : ∀ i, κ i → Set α} (h : ∀ i j, s ⊆ t i j) : s ⊆ ⋂ (i) (j), t i j := subset_iInter fun x => subset_iInter <| h x #align set.subset_Inter₂ Set.subset_iInter₂ @[simp] theorem iUnion_subset_iff {s : ι → Set α} {t : Set α} : ⋃ i, s i ⊆ t ↔ ∀ i, s i ⊆ t := ⟨fun h _ => Subset.trans (le_iSup s _) h, iUnion_subset⟩ #align set.Union_subset_iff Set.iUnion_subset_iff theorem iUnion₂_subset_iff {s : ∀ i, κ i → Set α} {t : Set α} : ⋃ (i) (j), s i j ⊆ t ↔ ∀ i j, s i j ⊆ t := by simp_rw [iUnion_subset_iff] #align set.Union₂_subset_iff Set.iUnion₂_subset_iff @[simp] theorem subset_iInter_iff {s : Set α} {t : ι → Set α} : (s ⊆ ⋂ i, t i) ↔ ∀ i, s ⊆ t i := le_iInf_iff #align set.subset_Inter_iff Set.subset_iInter_iff -- Porting note (#10618): removing `simp`. `simp` can prove it theorem subset_iInter₂_iff {s : Set α} {t : ∀ i, κ i → Set α} : (s ⊆ ⋂ (i) (j), t i j) ↔ ∀ i j, s ⊆ t i j := by simp_rw [subset_iInter_iff] #align set.subset_Inter₂_iff Set.subset_iInter₂_iff theorem subset_iUnion : ∀ (s : ι → Set β) (i : ι), s i ⊆ ⋃ i, s i := le_iSup #align set.subset_Union Set.subset_iUnion theorem iInter_subset : ∀ (s : ι → Set β) (i : ι), ⋂ i, s i ⊆ s i := iInf_le #align set.Inter_subset Set.iInter_subset theorem subset_iUnion₂ {s : ∀ i, κ i → Set α} (i : ι) (j : κ i) : s i j ⊆ ⋃ (i') (j'), s i' j' := le_iSup₂ i j #align set.subset_Union₂ Set.subset_iUnion₂ theorem iInter₂_subset {s : ∀ i, κ i → Set α} (i : ι) (j : κ i) : ⋂ (i) (j), s i j ⊆ s i j := iInf₂_le i j #align set.Inter₂_subset Set.iInter₂_subset theorem subset_iUnion_of_subset {s : Set α} {t : ι → Set α} (i : ι) (h : s ⊆ t i) : s ⊆ ⋃ i, t i := le_iSup_of_le i h #align set.subset_Union_of_subset Set.subset_iUnion_of_subset theorem iInter_subset_of_subset {s : ι → Set α} {t : Set α} (i : ι) (h : s i ⊆ t) : ⋂ i, s i ⊆ t := iInf_le_of_le i h #align set.Inter_subset_of_subset Set.iInter_subset_of_subset theorem subset_iUnion₂_of_subset {s : Set α} {t : ∀ i, κ i → Set α} (i : ι) (j : κ i) (h : s ⊆ t i j) : s ⊆ ⋃ (i) (j), t i j := le_iSup₂_of_le i j h #align set.subset_Union₂_of_subset Set.subset_iUnion₂_of_subset theorem iInter₂_subset_of_subset {s : ∀ i, κ i → Set α} {t : Set α} (i : ι) (j : κ i) (h : s i j ⊆ t) : ⋂ (i) (j), s i j ⊆ t := iInf₂_le_of_le i j h #align set.Inter₂_subset_of_subset Set.iInter₂_subset_of_subset theorem iUnion_mono {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : ⋃ i, s i ⊆ ⋃ i, t i := iSup_mono h #align set.Union_mono Set.iUnion_mono @[gcongr] theorem iUnion_mono'' {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : iUnion s ⊆ iUnion t := iSup_mono h theorem iUnion₂_mono {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j ⊆ t i j) : ⋃ (i) (j), s i j ⊆ ⋃ (i) (j), t i j := iSup₂_mono h #align set.Union₂_mono Set.iUnion₂_mono theorem iInter_mono {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : ⋂ i, s i ⊆ ⋂ i, t i := iInf_mono h #align set.Inter_mono Set.iInter_mono @[gcongr] theorem iInter_mono'' {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : iInter s ⊆ iInter t := iInf_mono h theorem iInter₂_mono {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j ⊆ t i j) : ⋂ (i) (j), s i j ⊆ ⋂ (i) (j), t i j := iInf₂_mono h #align set.Inter₂_mono Set.iInter₂_mono theorem iUnion_mono' {s : ι → Set α} {t : ι₂ → Set α} (h : ∀ i, ∃ j, s i ⊆ t j) : ⋃ i, s i ⊆ ⋃ i, t i := iSup_mono' h #align set.Union_mono' Set.iUnion_mono' theorem iUnion₂_mono' {s : ∀ i, κ i → Set α} {t : ∀ i', κ' i' → Set α} (h : ∀ i j, ∃ i' j', s i j ⊆ t i' j') : ⋃ (i) (j), s i j ⊆ ⋃ (i') (j'), t i' j' := iSup₂_mono' h #align set.Union₂_mono' Set.iUnion₂_mono' theorem iInter_mono' {s : ι → Set α} {t : ι' → Set α} (h : ∀ j, ∃ i, s i ⊆ t j) : ⋂ i, s i ⊆ ⋂ j, t j := Set.subset_iInter fun j => let ⟨i, hi⟩ := h j iInter_subset_of_subset i hi #align set.Inter_mono' Set.iInter_mono' theorem iInter₂_mono' {s : ∀ i, κ i → Set α} {t : ∀ i', κ' i' → Set α} (h : ∀ i' j', ∃ i j, s i j ⊆ t i' j') : ⋂ (i) (j), s i j ⊆ ⋂ (i') (j'), t i' j' := subset_iInter₂_iff.2 fun i' j' => let ⟨_, _, hst⟩ := h i' j' (iInter₂_subset _ _).trans hst #align set.Inter₂_mono' Set.iInter₂_mono' theorem iUnion₂_subset_iUnion (κ : ι → Sort*) (s : ι → Set α) : ⋃ (i) (_ : κ i), s i ⊆ ⋃ i, s i := iUnion_mono fun _ => iUnion_subset fun _ => Subset.rfl #align set.Union₂_subset_Union Set.iUnion₂_subset_iUnion theorem iInter_subset_iInter₂ (κ : ι → Sort*) (s : ι → Set α) : ⋂ i, s i ⊆ ⋂ (i) (_ : κ i), s i := iInter_mono fun _ => subset_iInter fun _ => Subset.rfl #align set.Inter_subset_Inter₂ Set.iInter_subset_iInter₂ theorem iUnion_setOf (P : ι → α → Prop) : ⋃ i, { x : α | P i x } = { x : α | ∃ i, P i x } := by ext exact mem_iUnion #align set.Union_set_of Set.iUnion_setOf theorem iInter_setOf (P : ι → α → Prop) : ⋂ i, { x : α | P i x } = { x : α | ∀ i, P i x } := by ext exact mem_iInter #align set.Inter_set_of Set.iInter_setOf theorem iUnion_congr_of_surjective {f : ι → Set α} {g : ι₂ → Set α} (h : ι → ι₂) (h1 : Surjective h) (h2 : ∀ x, g (h x) = f x) : ⋃ x, f x = ⋃ y, g y := h1.iSup_congr h h2 #align set.Union_congr_of_surjective Set.iUnion_congr_of_surjective theorem iInter_congr_of_surjective {f : ι → Set α} {g : ι₂ → Set α} (h : ι → ι₂) (h1 : Surjective h) (h2 : ∀ x, g (h x) = f x) : ⋂ x, f x = ⋂ y, g y := h1.iInf_congr h h2 #align set.Inter_congr_of_surjective Set.iInter_congr_of_surjective lemma iUnion_congr {s t : ι → Set α} (h : ∀ i, s i = t i) : ⋃ i, s i = ⋃ i, t i := iSup_congr h #align set.Union_congr Set.iUnion_congr lemma iInter_congr {s t : ι → Set α} (h : ∀ i, s i = t i) : ⋂ i, s i = ⋂ i, t i := iInf_congr h #align set.Inter_congr Set.iInter_congr lemma iUnion₂_congr {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j = t i j) : ⋃ (i) (j), s i j = ⋃ (i) (j), t i j := iUnion_congr fun i => iUnion_congr <| h i #align set.Union₂_congr Set.iUnion₂_congr lemma iInter₂_congr {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j = t i j) : ⋂ (i) (j), s i j = ⋂ (i) (j), t i j := iInter_congr fun i => iInter_congr <| h i #align set.Inter₂_congr Set.iInter₂_congr @[simp] theorem compl_iUnion (s : ι → Set β) : (⋃ i, s i)ᶜ = ⋂ i, (s i)ᶜ := compl_iSup #align set.compl_Union Set.compl_iUnion theorem compl_iUnion₂ (s : ∀ i, κ i → Set α) : (⋃ (i) (j), s i j)ᶜ = ⋂ (i) (j), (s i j)ᶜ := by simp_rw [compl_iUnion] #align set.compl_Union₂ Set.compl_iUnion₂ @[simp] theorem compl_iInter (s : ι → Set β) : (⋂ i, s i)ᶜ = ⋃ i, (s i)ᶜ := compl_iInf #align set.compl_Inter Set.compl_iInter theorem compl_iInter₂ (s : ∀ i, κ i → Set α) : (⋂ (i) (j), s i j)ᶜ = ⋃ (i) (j), (s i j)ᶜ := by simp_rw [compl_iInter] #align set.compl_Inter₂ Set.compl_iInter₂ -- classical -- complete_boolean_algebra theorem iUnion_eq_compl_iInter_compl (s : ι → Set β) : ⋃ i, s i = (⋂ i, (s i)ᶜ)ᶜ := by simp only [compl_iInter, compl_compl] #align set.Union_eq_compl_Inter_compl Set.iUnion_eq_compl_iInter_compl -- classical -- complete_boolean_algebra theorem iInter_eq_compl_iUnion_compl (s : ι → Set β) : ⋂ i, s i = (⋃ i, (s i)ᶜ)ᶜ := by simp only [compl_iUnion, compl_compl] #align set.Inter_eq_compl_Union_compl Set.iInter_eq_compl_iUnion_compl theorem inter_iUnion (s : Set β) (t : ι → Set β) : (s ∩ ⋃ i, t i) = ⋃ i, s ∩ t i := inf_iSup_eq _ _ #align set.inter_Union Set.inter_iUnion theorem iUnion_inter (s : Set β) (t : ι → Set β) : (⋃ i, t i) ∩ s = ⋃ i, t i ∩ s := iSup_inf_eq _ _ #align set.Union_inter Set.iUnion_inter theorem iUnion_union_distrib (s : ι → Set β) (t : ι → Set β) : ⋃ i, s i ∪ t i = (⋃ i, s i) ∪ ⋃ i, t i := iSup_sup_eq #align set.Union_union_distrib Set.iUnion_union_distrib theorem iInter_inter_distrib (s : ι → Set β) (t : ι → Set β) : ⋂ i, s i ∩ t i = (⋂ i, s i) ∩ ⋂ i, t i := iInf_inf_eq #align set.Inter_inter_distrib Set.iInter_inter_distrib theorem union_iUnion [Nonempty ι] (s : Set β) (t : ι → Set β) : (s ∪ ⋃ i, t i) = ⋃ i, s ∪ t i := sup_iSup #align set.union_Union Set.union_iUnion theorem iUnion_union [Nonempty ι] (s : Set β) (t : ι → Set β) : (⋃ i, t i) ∪ s = ⋃ i, t i ∪ s := iSup_sup #align set.Union_union Set.iUnion_union theorem inter_iInter [Nonempty ι] (s : Set β) (t : ι → Set β) : (s ∩ ⋂ i, t i) = ⋂ i, s ∩ t i := inf_iInf #align set.inter_Inter Set.inter_iInter theorem iInter_inter [Nonempty ι] (s : Set β) (t : ι → Set β) : (⋂ i, t i) ∩ s = ⋂ i, t i ∩ s := iInf_inf #align set.Inter_inter Set.iInter_inter -- classical theorem union_iInter (s : Set β) (t : ι → Set β) : (s ∪ ⋂ i, t i) = ⋂ i, s ∪ t i := sup_iInf_eq _ _ #align set.union_Inter Set.union_iInter theorem iInter_union (s : ι → Set β) (t : Set β) : (⋂ i, s i) ∪ t = ⋂ i, s i ∪ t := iInf_sup_eq _ _ #align set.Inter_union Set.iInter_union theorem iUnion_diff (s : Set β) (t : ι → Set β) : (⋃ i, t i) \ s = ⋃ i, t i \ s := iUnion_inter _ _ #align set.Union_diff Set.iUnion_diff theorem diff_iUnion [Nonempty ι] (s : Set β) (t : ι → Set β) : (s \ ⋃ i, t i) = ⋂ i, s \ t i := by rw [diff_eq, compl_iUnion, inter_iInter]; rfl #align set.diff_Union Set.diff_iUnion theorem diff_iInter (s : Set β) (t : ι → Set β) : (s \ ⋂ i, t i) = ⋃ i, s \ t i := by rw [diff_eq, compl_iInter, inter_iUnion]; rfl #align set.diff_Inter Set.diff_iInter theorem iUnion_inter_subset {ι α} {s t : ι → Set α} : ⋃ i, s i ∩ t i ⊆ (⋃ i, s i) ∩ ⋃ i, t i := le_iSup_inf_iSup s t #align set.Union_inter_subset Set.iUnion_inter_subset theorem iUnion_inter_of_monotone {ι α} [Preorder ι] [IsDirected ι (· ≤ ·)] {s t : ι → Set α} (hs : Monotone s) (ht : Monotone t) : ⋃ i, s i ∩ t i = (⋃ i, s i) ∩ ⋃ i, t i := iSup_inf_of_monotone hs ht #align set.Union_inter_of_monotone Set.iUnion_inter_of_monotone theorem iUnion_inter_of_antitone {ι α} [Preorder ι] [IsDirected ι (swap (· ≤ ·))] {s t : ι → Set α} (hs : Antitone s) (ht : Antitone t) : ⋃ i, s i ∩ t i = (⋃ i, s i) ∩ ⋃ i, t i := iSup_inf_of_antitone hs ht #align set.Union_inter_of_antitone Set.iUnion_inter_of_antitone theorem iInter_union_of_monotone {ι α} [Preorder ι] [IsDirected ι (swap (· ≤ ·))] {s t : ι → Set α} (hs : Monotone s) (ht : Monotone t) : ⋂ i, s i ∪ t i = (⋂ i, s i) ∪ ⋂ i, t i := iInf_sup_of_monotone hs ht #align set.Inter_union_of_monotone Set.iInter_union_of_monotone theorem iInter_union_of_antitone {ι α} [Preorder ι] [IsDirected ι (· ≤ ·)] {s t : ι → Set α} (hs : Antitone s) (ht : Antitone t) : ⋂ i, s i ∪ t i = (⋂ i, s i) ∪ ⋂ i, t i := iInf_sup_of_antitone hs ht #align set.Inter_union_of_antitone Set.iInter_union_of_antitone theorem iUnion_iInter_subset {s : ι → ι' → Set α} : (⋃ j, ⋂ i, s i j) ⊆ ⋂ i, ⋃ j, s i j := iSup_iInf_le_iInf_iSup (flip s) #align set.Union_Inter_subset Set.iUnion_iInter_subset theorem iUnion_option {ι} (s : Option ι → Set α) : ⋃ o, s o = s none ∪ ⋃ i, s (some i) := iSup_option s #align set.Union_option Set.iUnion_option theorem iInter_option {ι} (s : Option ι → Set α) : ⋂ o, s o = s none ∩ ⋂ i, s (some i) := iInf_option s #align set.Inter_option Set.iInter_option section variable (p : ι → Prop) [DecidablePred p] theorem iUnion_dite (f : ∀ i, p i → Set α) (g : ∀ i, ¬p i → Set α) : ⋃ i, (if h : p i then f i h else g i h) = (⋃ (i) (h : p i), f i h) ∪ ⋃ (i) (h : ¬p i), g i h := iSup_dite _ _ _ #align set.Union_dite Set.iUnion_dite theorem iUnion_ite (f g : ι → Set α) : ⋃ i, (if p i then f i else g i) = (⋃ (i) (_ : p i), f i) ∪ ⋃ (i) (_ : ¬p i), g i := iUnion_dite _ _ _ #align set.Union_ite Set.iUnion_ite theorem iInter_dite (f : ∀ i, p i → Set α) (g : ∀ i, ¬p i → Set α) : ⋂ i, (if h : p i then f i h else g i h) = (⋂ (i) (h : p i), f i h) ∩ ⋂ (i) (h : ¬p i), g i h := iInf_dite _ _ _ #align set.Inter_dite Set.iInter_dite theorem iInter_ite (f g : ι → Set α) : ⋂ i, (if p i then f i else g i) = (⋂ (i) (_ : p i), f i) ∩ ⋂ (i) (_ : ¬p i), g i := iInter_dite _ _ _ #align set.Inter_ite Set.iInter_ite end theorem image_projection_prod {ι : Type*} {α : ι → Type*} {v : ∀ i : ι, Set (α i)} (hv : (pi univ v).Nonempty) (i : ι) : ((fun x : ∀ i : ι, α i => x i) '' ⋂ k, (fun x : ∀ j : ι, α j => x k) ⁻¹' v k) = v i := by classical apply Subset.antisymm · simp [iInter_subset] · intro y y_in simp only [mem_image, mem_iInter, mem_preimage] rcases hv with ⟨z, hz⟩ refine ⟨Function.update z i y, ?_, update_same i y z⟩ rw [@forall_update_iff ι α _ z i y fun i t => t ∈ v i] exact ⟨y_in, fun j _ => by simpa using hz j⟩ #align set.image_projection_prod Set.image_projection_prod theorem iInter_false {s : False → Set α} : iInter s = univ := iInf_false #align set.Inter_false Set.iInter_false theorem iUnion_false {s : False → Set α} : iUnion s = ∅ := iSup_false #align set.Union_false Set.iUnion_false @[simp] theorem iInter_true {s : True → Set α} : iInter s = s trivial := iInf_true #align set.Inter_true Set.iInter_true @[simp] theorem iUnion_true {s : True → Set α} : iUnion s = s trivial := iSup_true #align set.Union_true Set.iUnion_true @[simp] theorem iInter_exists {p : ι → Prop} {f : Exists p → Set α} : ⋂ x, f x = ⋂ (i) (h : p i), f ⟨i, h⟩ := iInf_exists #align set.Inter_exists Set.iInter_exists @[simp] theorem iUnion_exists {p : ι → Prop} {f : Exists p → Set α} : ⋃ x, f x = ⋃ (i) (h : p i), f ⟨i, h⟩ := iSup_exists #align set.Union_exists Set.iUnion_exists @[simp] theorem iUnion_empty : (⋃ _ : ι, ∅ : Set α) = ∅ := iSup_bot #align set.Union_empty Set.iUnion_empty @[simp] theorem iInter_univ : (⋂ _ : ι, univ : Set α) = univ := iInf_top #align set.Inter_univ Set.iInter_univ section variable {s : ι → Set α} @[simp] theorem iUnion_eq_empty : ⋃ i, s i = ∅ ↔ ∀ i, s i = ∅ := iSup_eq_bot #align set.Union_eq_empty Set.iUnion_eq_empty @[simp] theorem iInter_eq_univ : ⋂ i, s i = univ ↔ ∀ i, s i = univ := iInf_eq_top #align set.Inter_eq_univ Set.iInter_eq_univ @[simp] theorem nonempty_iUnion : (⋃ i, s i).Nonempty ↔ ∃ i, (s i).Nonempty := by simp [nonempty_iff_ne_empty] #align set.nonempty_Union Set.nonempty_iUnion -- Porting note (#10618): removing `simp`. `simp` can prove it theorem nonempty_biUnion {t : Set α} {s : α → Set β} : (⋃ i ∈ t, s i).Nonempty ↔ ∃ i ∈ t, (s i).Nonempty := by simp #align set.nonempty_bUnion Set.nonempty_biUnion theorem iUnion_nonempty_index (s : Set α) (t : s.Nonempty → Set β) : ⋃ h, t h = ⋃ x ∈ s, t ⟨x, ‹_›⟩ := iSup_exists #align set.Union_nonempty_index Set.iUnion_nonempty_index end @[simp] theorem iInter_iInter_eq_left {b : β} {s : ∀ x : β, x = b → Set α} : ⋂ (x) (h : x = b), s x h = s b rfl := iInf_iInf_eq_left #align set.Inter_Inter_eq_left Set.iInter_iInter_eq_left @[simp] theorem iInter_iInter_eq_right {b : β} {s : ∀ x : β, b = x → Set α} : ⋂ (x) (h : b = x), s x h = s b rfl := iInf_iInf_eq_right #align set.Inter_Inter_eq_right Set.iInter_iInter_eq_right @[simp] theorem iUnion_iUnion_eq_left {b : β} {s : ∀ x : β, x = b → Set α} : ⋃ (x) (h : x = b), s x h = s b rfl := iSup_iSup_eq_left #align set.Union_Union_eq_left Set.iUnion_iUnion_eq_left @[simp] theorem iUnion_iUnion_eq_right {b : β} {s : ∀ x : β, b = x → Set α} : ⋃ (x) (h : b = x), s x h = s b rfl := iSup_iSup_eq_right #align set.Union_Union_eq_right Set.iUnion_iUnion_eq_right theorem iInter_or {p q : Prop} (s : p ∨ q → Set α) : ⋂ h, s h = (⋂ h : p, s (Or.inl h)) ∩ ⋂ h : q, s (Or.inr h) := iInf_or #align set.Inter_or Set.iInter_or theorem iUnion_or {p q : Prop} (s : p ∨ q → Set α) : ⋃ h, s h = (⋃ i, s (Or.inl i)) ∪ ⋃ j, s (Or.inr j) := iSup_or #align set.Union_or Set.iUnion_or theorem iUnion_and {p q : Prop} (s : p ∧ q → Set α) : ⋃ h, s h = ⋃ (hp) (hq), s ⟨hp, hq⟩ := iSup_and #align set.Union_and Set.iUnion_and theorem iInter_and {p q : Prop} (s : p ∧ q → Set α) : ⋂ h, s h = ⋂ (hp) (hq), s ⟨hp, hq⟩ := iInf_and #align set.Inter_and Set.iInter_and theorem iUnion_comm (s : ι → ι' → Set α) : ⋃ (i) (i'), s i i' = ⋃ (i') (i), s i i' := iSup_comm #align set.Union_comm Set.iUnion_comm theorem iInter_comm (s : ι → ι' → Set α) : ⋂ (i) (i'), s i i' = ⋂ (i') (i), s i i' := iInf_comm #align set.Inter_comm Set.iInter_comm theorem iUnion_sigma {γ : α → Type*} (s : Sigma γ → Set β) : ⋃ ia, s ia = ⋃ i, ⋃ a, s ⟨i, a⟩ := iSup_sigma theorem iUnion_sigma' {γ : α → Type*} (s : ∀ i, γ i → Set β) : ⋃ i, ⋃ a, s i a = ⋃ ia : Sigma γ, s ia.1 ia.2 := iSup_sigma' _ theorem iInter_sigma {γ : α → Type*} (s : Sigma γ → Set β) : ⋂ ia, s ia = ⋂ i, ⋂ a, s ⟨i, a⟩ := iInf_sigma theorem iInter_sigma' {γ : α → Type*} (s : ∀ i, γ i → Set β) : ⋂ i, ⋂ a, s i a = ⋂ ia : Sigma γ, s ia.1 ia.2 := iInf_sigma' _ theorem iUnion₂_comm (s : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → Set α) : ⋃ (i₁) (j₁) (i₂) (j₂), s i₁ j₁ i₂ j₂ = ⋃ (i₂) (j₂) (i₁) (j₁), s i₁ j₁ i₂ j₂ := iSup₂_comm _ #align set.Union₂_comm Set.iUnion₂_comm theorem iInter₂_comm (s : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → Set α) : ⋂ (i₁) (j₁) (i₂) (j₂), s i₁ j₁ i₂ j₂ = ⋂ (i₂) (j₂) (i₁) (j₁), s i₁ j₁ i₂ j₂ := iInf₂_comm _ #align set.Inter₂_comm Set.iInter₂_comm @[simp] theorem biUnion_and (p : ι → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p x ∧ q x y → Set α) : ⋃ (x : ι) (y : ι') (h : p x ∧ q x y), s x y h = ⋃ (x : ι) (hx : p x) (y : ι') (hy : q x y), s x y ⟨hx, hy⟩ := by simp only [iUnion_and, @iUnion_comm _ ι'] #align set.bUnion_and Set.biUnion_and @[simp] theorem biUnion_and' (p : ι' → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p y ∧ q x y → Set α) : ⋃ (x : ι) (y : ι') (h : p y ∧ q x y), s x y h = ⋃ (y : ι') (hy : p y) (x : ι) (hx : q x y), s x y ⟨hy, hx⟩ := by simp only [iUnion_and, @iUnion_comm _ ι] #align set.bUnion_and' Set.biUnion_and' @[simp] theorem biInter_and (p : ι → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p x ∧ q x y → Set α) : ⋂ (x : ι) (y : ι') (h : p x ∧ q x y), s x y h = ⋂ (x : ι) (hx : p x) (y : ι') (hy : q x y), s x y ⟨hx, hy⟩ := by simp only [iInter_and, @iInter_comm _ ι'] #align set.bInter_and Set.biInter_and @[simp] theorem biInter_and' (p : ι' → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p y ∧ q x y → Set α) : ⋂ (x : ι) (y : ι') (h : p y ∧ q x y), s x y h = ⋂ (y : ι') (hy : p y) (x : ι) (hx : q x y), s x y ⟨hy, hx⟩ := by simp only [iInter_and, @iInter_comm _ ι] #align set.bInter_and' Set.biInter_and' @[simp] theorem iUnion_iUnion_eq_or_left {b : β} {p : β → Prop} {s : ∀ x : β, x = b ∨ p x → Set α} : ⋃ (x) (h), s x h = s b (Or.inl rfl) ∪ ⋃ (x) (h : p x), s x (Or.inr h) := by simp only [iUnion_or, iUnion_union_distrib, iUnion_iUnion_eq_left] #align set.Union_Union_eq_or_left Set.iUnion_iUnion_eq_or_left @[simp] theorem iInter_iInter_eq_or_left {b : β} {p : β → Prop} {s : ∀ x : β, x = b ∨ p x → Set α} : ⋂ (x) (h), s x h = s b (Or.inl rfl) ∩ ⋂ (x) (h : p x), s x (Or.inr h) := by simp only [iInter_or, iInter_inter_distrib, iInter_iInter_eq_left] #align set.Inter_Inter_eq_or_left Set.iInter_iInter_eq_or_left theorem mem_biUnion {s : Set α} {t : α → Set β} {x : α} {y : β} (xs : x ∈ s) (ytx : y ∈ t x) : y ∈ ⋃ x ∈ s, t x := mem_iUnion₂_of_mem xs ytx #align set.mem_bUnion Set.mem_biUnion theorem mem_biInter {s : Set α} {t : α → Set β} {y : β} (h : ∀ x ∈ s, y ∈ t x) : y ∈ ⋂ x ∈ s, t x := mem_iInter₂_of_mem h #align set.mem_bInter Set.mem_biInter theorem subset_biUnion_of_mem {s : Set α} {u : α → Set β} {x : α} (xs : x ∈ s) : u x ⊆ ⋃ x ∈ s, u x := -- Porting note: Why is this not just `subset_iUnion₂ x xs`? @subset_iUnion₂ β α (· ∈ s) (fun i _ => u i) x xs #align set.subset_bUnion_of_mem Set.subset_biUnion_of_mem theorem biInter_subset_of_mem {s : Set α} {t : α → Set β} {x : α} (xs : x ∈ s) : ⋂ x ∈ s, t x ⊆ t x := iInter₂_subset x xs #align set.bInter_subset_of_mem Set.biInter_subset_of_mem theorem biUnion_subset_biUnion_left {s s' : Set α} {t : α → Set β} (h : s ⊆ s') : ⋃ x ∈ s, t x ⊆ ⋃ x ∈ s', t x := iUnion₂_subset fun _ hx => subset_biUnion_of_mem <| h hx #align set.bUnion_subset_bUnion_left Set.biUnion_subset_biUnion_left theorem biInter_subset_biInter_left {s s' : Set α} {t : α → Set β} (h : s' ⊆ s) : ⋂ x ∈ s, t x ⊆ ⋂ x ∈ s', t x := subset_iInter₂ fun _ hx => biInter_subset_of_mem <| h hx #align set.bInter_subset_bInter_left Set.biInter_subset_biInter_left theorem biUnion_mono {s s' : Set α} {t t' : α → Set β} (hs : s' ⊆ s) (h : ∀ x ∈ s, t x ⊆ t' x) : ⋃ x ∈ s', t x ⊆ ⋃ x ∈ s, t' x := (biUnion_subset_biUnion_left hs).trans <| iUnion₂_mono h #align set.bUnion_mono Set.biUnion_mono theorem biInter_mono {s s' : Set α} {t t' : α → Set β} (hs : s ⊆ s') (h : ∀ x ∈ s, t x ⊆ t' x) : ⋂ x ∈ s', t x ⊆ ⋂ x ∈ s, t' x := (biInter_subset_biInter_left hs).trans <| iInter₂_mono h #align set.bInter_mono Set.biInter_mono theorem biUnion_eq_iUnion (s : Set α) (t : ∀ x ∈ s, Set β) : ⋃ x ∈ s, t x ‹_› = ⋃ x : s, t x x.2 := iSup_subtype' #align set.bUnion_eq_Union Set.biUnion_eq_iUnion theorem biInter_eq_iInter (s : Set α) (t : ∀ x ∈ s, Set β) : ⋂ x ∈ s, t x ‹_› = ⋂ x : s, t x x.2 := iInf_subtype' #align set.bInter_eq_Inter Set.biInter_eq_iInter theorem iUnion_subtype (p : α → Prop) (s : { x // p x } → Set β) : ⋃ x : { x // p x }, s x = ⋃ (x) (hx : p x), s ⟨x, hx⟩ := iSup_subtype #align set.Union_subtype Set.iUnion_subtype theorem iInter_subtype (p : α → Prop) (s : { x // p x } → Set β) : ⋂ x : { x // p x }, s x = ⋂ (x) (hx : p x), s ⟨x, hx⟩ := iInf_subtype #align set.Inter_subtype Set.iInter_subtype theorem biInter_empty (u : α → Set β) : ⋂ x ∈ (∅ : Set α), u x = univ := iInf_emptyset #align set.bInter_empty Set.biInter_empty theorem biInter_univ (u : α → Set β) : ⋂ x ∈ @univ α, u x = ⋂ x, u x := iInf_univ #align set.bInter_univ Set.biInter_univ @[simp] theorem biUnion_self (s : Set α) : ⋃ x ∈ s, s = s := Subset.antisymm (iUnion₂_subset fun _ _ => Subset.refl s) fun _ hx => mem_biUnion hx hx #align set.bUnion_self Set.biUnion_self @[simp]
Mathlib/Data/Set/Lattice.lean
896
897
theorem iUnion_nonempty_self (s : Set α) : ⋃ _ : s.Nonempty, s = s := by
rw [iUnion_nonempty_index, biUnion_self]
import Mathlib.Init.Control.Combinators import Mathlib.Init.Function import Mathlib.Tactic.CasesM import Mathlib.Tactic.Attr.Core #align_import control.basic from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" universe u v w variable {α β γ : Type u} section Applicative variable {F : Type u → Type v} [Applicative F] def zipWithM {α₁ α₂ φ : Type u} (f : α₁ → α₂ → F φ) : ∀ (_ : List α₁) (_ : List α₂), F (List φ) | x :: xs, y :: ys => (· :: ·) <$> f x y <*> zipWithM f xs ys | _, _ => pure [] #align mzip_with zipWithM def zipWithM' (f : α → β → F γ) : List α → List β → F PUnit | x :: xs, y :: ys => f x y *> zipWithM' f xs ys | [], _ => pure PUnit.unit | _, [] => pure PUnit.unit #align mzip_with' zipWithM' variable [LawfulApplicative F] @[simp] theorem pure_id'_seq (x : F α) : (pure fun x => x) <*> x = x := pure_id_seq x #align pure_id'_seq pure_id'_seq @[functor_norm] theorem seq_map_assoc (x : F (α → β)) (f : γ → α) (y : F γ) : x <*> f <$> y = (· ∘ f) <$> x <*> y := by simp only [← pure_seq] simp only [seq_assoc, Function.comp, seq_pure, ← comp_map] simp [pure_seq] #align seq_map_assoc seq_map_assoc @[functor_norm]
Mathlib/Control/Basic.lean
68
70
theorem map_seq (f : β → γ) (x : F (α → β)) (y : F α) : f <$> (x <*> y) = (f ∘ ·) <$> x <*> y := by
simp only [← pure_seq]; simp [seq_assoc]
import Mathlib.GroupTheory.QuotientGroup import Mathlib.RingTheory.DedekindDomain.Ideal #align_import ring_theory.class_group from "leanprover-community/mathlib"@"565eb991e264d0db702722b4bde52ee5173c9950" variable {R K L : Type*} [CommRing R] variable [Field K] [Field L] [DecidableEq L] variable [Algebra R K] [IsFractionRing R K] variable [Algebra K L] [FiniteDimensional K L] variable [Algebra R L] [IsScalarTower R K L] open scoped nonZeroDivisors open IsLocalization IsFractionRing FractionalIdeal Units section variable (R K) irreducible_def toPrincipalIdeal : Kˣ →* (FractionalIdeal R⁰ K)ˣ := { toFun := fun x => ⟨spanSingleton _ x, spanSingleton _ x⁻¹, by simp only [spanSingleton_one, Units.mul_inv', spanSingleton_mul_spanSingleton], by simp only [spanSingleton_one, Units.inv_mul', spanSingleton_mul_spanSingleton]⟩ map_mul' := fun x y => ext (by simp only [Units.val_mk, Units.val_mul, spanSingleton_mul_spanSingleton]) map_one' := ext (by simp only [spanSingleton_one, Units.val_mk, Units.val_one]) } #align to_principal_ideal toPrincipalIdeal variable {R K} @[simp] theorem coe_toPrincipalIdeal (x : Kˣ) : (toPrincipalIdeal R K x : FractionalIdeal R⁰ K) = spanSingleton _ (x : K) := by simp only [toPrincipalIdeal]; rfl #align coe_to_principal_ideal coe_toPrincipalIdeal @[simp] theorem toPrincipalIdeal_eq_iff {I : (FractionalIdeal R⁰ K)ˣ} {x : Kˣ} : toPrincipalIdeal R K x = I ↔ spanSingleton R⁰ (x : K) = I := by simp only [toPrincipalIdeal]; exact Units.ext_iff #align to_principal_ideal_eq_iff toPrincipalIdeal_eq_iff theorem mem_principal_ideals_iff {I : (FractionalIdeal R⁰ K)ˣ} : I ∈ (toPrincipalIdeal R K).range ↔ ∃ x : K, spanSingleton R⁰ x = I := by simp only [MonoidHom.mem_range, toPrincipalIdeal_eq_iff] constructor <;> rintro ⟨x, hx⟩ · exact ⟨x, hx⟩ · refine ⟨Units.mk0 x ?_, hx⟩ rintro rfl simp [I.ne_zero.symm] at hx #align mem_principal_ideals_iff mem_principal_ideals_iff instance PrincipalIdeals.normal : (toPrincipalIdeal R K).range.Normal := Subgroup.normal_of_comm _ #align principal_ideals.normal PrincipalIdeals.normal end variable (R) variable [IsDomain R] def ClassGroup := (FractionalIdeal R⁰ (FractionRing R))ˣ ⧸ (toPrincipalIdeal R (FractionRing R)).range #align class_group ClassGroup noncomputable instance : CommGroup (ClassGroup R) := QuotientGroup.Quotient.commGroup (toPrincipalIdeal R (FractionRing R)).range noncomputable instance : Inhabited (ClassGroup R) := ⟨1⟩ variable {R} noncomputable def ClassGroup.mk : (FractionalIdeal R⁰ K)ˣ →* ClassGroup R := (QuotientGroup.mk' (toPrincipalIdeal R (FractionRing R)).range).comp (Units.map (FractionalIdeal.canonicalEquiv R⁰ K (FractionRing R))) #align class_group.mk ClassGroup.mk -- Can't be `@[simp]` because it can't figure out the quotient relation. theorem ClassGroup.Quot_mk_eq_mk (I : (FractionalIdeal R⁰ (FractionRing R))ˣ) : Quot.mk _ I = ClassGroup.mk I := by rw [ClassGroup.mk, canonicalEquiv_self, RingEquiv.coe_monoidHom_refl, Units.map_id] -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [MonoidHom.comp_apply] rw [MonoidHom.id_apply, QuotientGroup.mk'_apply] rfl
Mathlib/RingTheory/ClassGroup.lean
119
123
theorem ClassGroup.mk_eq_mk {I J : (FractionalIdeal R⁰ <| FractionRing R)ˣ} : ClassGroup.mk I = ClassGroup.mk J ↔ ∃ x : (FractionRing R)ˣ, I * toPrincipalIdeal R (FractionRing R) x = J := by
erw [QuotientGroup.mk'_eq_mk', canonicalEquiv_self, Units.map_id, Set.exists_range_iff] rfl
import Mathlib.Logic.Pairwise import Mathlib.Order.CompleteBooleanAlgebra import Mathlib.Order.Directed import Mathlib.Order.GaloisConnection #align_import data.set.lattice from "leanprover-community/mathlib"@"b86832321b586c6ac23ef8cdef6a7a27e42b13bd" open Function Set universe u variable {α β γ : Type*} {ι ι' ι₂ : Sort*} {κ κ₁ κ₂ : ι → Sort*} {κ' : ι' → Sort*} namespace Set theorem mem_iUnion₂ {x : γ} {s : ∀ i, κ i → Set γ} : (x ∈ ⋃ (i) (j), s i j) ↔ ∃ i j, x ∈ s i j := by simp_rw [mem_iUnion] #align set.mem_Union₂ Set.mem_iUnion₂ theorem mem_iInter₂ {x : γ} {s : ∀ i, κ i → Set γ} : (x ∈ ⋂ (i) (j), s i j) ↔ ∀ i j, x ∈ s i j := by simp_rw [mem_iInter] #align set.mem_Inter₂ Set.mem_iInter₂ theorem mem_iUnion_of_mem {s : ι → Set α} {a : α} (i : ι) (ha : a ∈ s i) : a ∈ ⋃ i, s i := mem_iUnion.2 ⟨i, ha⟩ #align set.mem_Union_of_mem Set.mem_iUnion_of_mem theorem mem_iUnion₂_of_mem {s : ∀ i, κ i → Set α} {a : α} {i : ι} (j : κ i) (ha : a ∈ s i j) : a ∈ ⋃ (i) (j), s i j := mem_iUnion₂.2 ⟨i, j, ha⟩ #align set.mem_Union₂_of_mem Set.mem_iUnion₂_of_mem theorem mem_iInter_of_mem {s : ι → Set α} {a : α} (h : ∀ i, a ∈ s i) : a ∈ ⋂ i, s i := mem_iInter.2 h #align set.mem_Inter_of_mem Set.mem_iInter_of_mem theorem mem_iInter₂_of_mem {s : ∀ i, κ i → Set α} {a : α} (h : ∀ i j, a ∈ s i j) : a ∈ ⋂ (i) (j), s i j := mem_iInter₂.2 h #align set.mem_Inter₂_of_mem Set.mem_iInter₂_of_mem instance completeAtomicBooleanAlgebra : CompleteAtomicBooleanAlgebra (Set α) := { instBooleanAlgebraSet with le_sSup := fun s t t_in a a_in => ⟨t, t_in, a_in⟩ sSup_le := fun s t h a ⟨t', ⟨t'_in, a_in⟩⟩ => h t' t'_in a_in le_sInf := fun s t h a a_in t' t'_in => h t' t'_in a_in sInf_le := fun s t t_in a h => h _ t_in iInf_iSup_eq := by intros; ext; simp [Classical.skolem] } instance : OrderTop (Set α) where top := univ le_top := by simp @[congr] theorem iUnion_congr_Prop {p q : Prop} {f₁ : p → Set α} {f₂ : q → Set α} (pq : p ↔ q) (f : ∀ x, f₁ (pq.mpr x) = f₂ x) : iUnion f₁ = iUnion f₂ := iSup_congr_Prop pq f #align set.Union_congr_Prop Set.iUnion_congr_Prop @[congr] theorem iInter_congr_Prop {p q : Prop} {f₁ : p → Set α} {f₂ : q → Set α} (pq : p ↔ q) (f : ∀ x, f₁ (pq.mpr x) = f₂ x) : iInter f₁ = iInter f₂ := iInf_congr_Prop pq f #align set.Inter_congr_Prop Set.iInter_congr_Prop theorem iUnion_plift_up (f : PLift ι → Set α) : ⋃ i, f (PLift.up i) = ⋃ i, f i := iSup_plift_up _ #align set.Union_plift_up Set.iUnion_plift_up theorem iUnion_plift_down (f : ι → Set α) : ⋃ i, f (PLift.down i) = ⋃ i, f i := iSup_plift_down _ #align set.Union_plift_down Set.iUnion_plift_down theorem iInter_plift_up (f : PLift ι → Set α) : ⋂ i, f (PLift.up i) = ⋂ i, f i := iInf_plift_up _ #align set.Inter_plift_up Set.iInter_plift_up theorem iInter_plift_down (f : ι → Set α) : ⋂ i, f (PLift.down i) = ⋂ i, f i := iInf_plift_down _ #align set.Inter_plift_down Set.iInter_plift_down theorem iUnion_eq_if {p : Prop} [Decidable p] (s : Set α) : ⋃ _ : p, s = if p then s else ∅ := iSup_eq_if _ #align set.Union_eq_if Set.iUnion_eq_if theorem iUnion_eq_dif {p : Prop} [Decidable p] (s : p → Set α) : ⋃ h : p, s h = if h : p then s h else ∅ := iSup_eq_dif _ #align set.Union_eq_dif Set.iUnion_eq_dif theorem iInter_eq_if {p : Prop} [Decidable p] (s : Set α) : ⋂ _ : p, s = if p then s else univ := iInf_eq_if _ #align set.Inter_eq_if Set.iInter_eq_if theorem iInf_eq_dif {p : Prop} [Decidable p] (s : p → Set α) : ⋂ h : p, s h = if h : p then s h else univ := _root_.iInf_eq_dif _ #align set.Infi_eq_dif Set.iInf_eq_dif theorem exists_set_mem_of_union_eq_top {ι : Type*} (t : Set ι) (s : ι → Set β) (w : ⋃ i ∈ t, s i = ⊤) (x : β) : ∃ i ∈ t, x ∈ s i := by have p : x ∈ ⊤ := Set.mem_univ x rw [← w, Set.mem_iUnion] at p simpa using p #align set.exists_set_mem_of_union_eq_top Set.exists_set_mem_of_union_eq_top theorem nonempty_of_union_eq_top_of_nonempty {ι : Type*} (t : Set ι) (s : ι → Set α) (H : Nonempty α) (w : ⋃ i ∈ t, s i = ⊤) : t.Nonempty := by obtain ⟨x, m, -⟩ := exists_set_mem_of_union_eq_top t s w H.some exact ⟨x, m⟩ #align set.nonempty_of_union_eq_top_of_nonempty Set.nonempty_of_union_eq_top_of_nonempty theorem nonempty_of_nonempty_iUnion {s : ι → Set α} (h_Union : (⋃ i, s i).Nonempty) : Nonempty ι := by obtain ⟨x, hx⟩ := h_Union exact ⟨Classical.choose <| mem_iUnion.mp hx⟩ theorem nonempty_of_nonempty_iUnion_eq_univ {s : ι → Set α} [Nonempty α] (h_Union : ⋃ i, s i = univ) : Nonempty ι := nonempty_of_nonempty_iUnion (s := s) (by simpa only [h_Union] using univ_nonempty) theorem setOf_exists (p : ι → β → Prop) : { x | ∃ i, p i x } = ⋃ i, { x | p i x } := ext fun _ => mem_iUnion.symm #align set.set_of_exists Set.setOf_exists theorem setOf_forall (p : ι → β → Prop) : { x | ∀ i, p i x } = ⋂ i, { x | p i x } := ext fun _ => mem_iInter.symm #align set.set_of_forall Set.setOf_forall theorem iUnion_subset {s : ι → Set α} {t : Set α} (h : ∀ i, s i ⊆ t) : ⋃ i, s i ⊆ t := iSup_le h #align set.Union_subset Set.iUnion_subset theorem iUnion₂_subset {s : ∀ i, κ i → Set α} {t : Set α} (h : ∀ i j, s i j ⊆ t) : ⋃ (i) (j), s i j ⊆ t := iUnion_subset fun x => iUnion_subset (h x) #align set.Union₂_subset Set.iUnion₂_subset theorem subset_iInter {t : Set β} {s : ι → Set β} (h : ∀ i, t ⊆ s i) : t ⊆ ⋂ i, s i := le_iInf h #align set.subset_Inter Set.subset_iInter theorem subset_iInter₂ {s : Set α} {t : ∀ i, κ i → Set α} (h : ∀ i j, s ⊆ t i j) : s ⊆ ⋂ (i) (j), t i j := subset_iInter fun x => subset_iInter <| h x #align set.subset_Inter₂ Set.subset_iInter₂ @[simp] theorem iUnion_subset_iff {s : ι → Set α} {t : Set α} : ⋃ i, s i ⊆ t ↔ ∀ i, s i ⊆ t := ⟨fun h _ => Subset.trans (le_iSup s _) h, iUnion_subset⟩ #align set.Union_subset_iff Set.iUnion_subset_iff theorem iUnion₂_subset_iff {s : ∀ i, κ i → Set α} {t : Set α} : ⋃ (i) (j), s i j ⊆ t ↔ ∀ i j, s i j ⊆ t := by simp_rw [iUnion_subset_iff] #align set.Union₂_subset_iff Set.iUnion₂_subset_iff @[simp] theorem subset_iInter_iff {s : Set α} {t : ι → Set α} : (s ⊆ ⋂ i, t i) ↔ ∀ i, s ⊆ t i := le_iInf_iff #align set.subset_Inter_iff Set.subset_iInter_iff -- Porting note (#10618): removing `simp`. `simp` can prove it theorem subset_iInter₂_iff {s : Set α} {t : ∀ i, κ i → Set α} : (s ⊆ ⋂ (i) (j), t i j) ↔ ∀ i j, s ⊆ t i j := by simp_rw [subset_iInter_iff] #align set.subset_Inter₂_iff Set.subset_iInter₂_iff theorem subset_iUnion : ∀ (s : ι → Set β) (i : ι), s i ⊆ ⋃ i, s i := le_iSup #align set.subset_Union Set.subset_iUnion theorem iInter_subset : ∀ (s : ι → Set β) (i : ι), ⋂ i, s i ⊆ s i := iInf_le #align set.Inter_subset Set.iInter_subset theorem subset_iUnion₂ {s : ∀ i, κ i → Set α} (i : ι) (j : κ i) : s i j ⊆ ⋃ (i') (j'), s i' j' := le_iSup₂ i j #align set.subset_Union₂ Set.subset_iUnion₂ theorem iInter₂_subset {s : ∀ i, κ i → Set α} (i : ι) (j : κ i) : ⋂ (i) (j), s i j ⊆ s i j := iInf₂_le i j #align set.Inter₂_subset Set.iInter₂_subset theorem subset_iUnion_of_subset {s : Set α} {t : ι → Set α} (i : ι) (h : s ⊆ t i) : s ⊆ ⋃ i, t i := le_iSup_of_le i h #align set.subset_Union_of_subset Set.subset_iUnion_of_subset theorem iInter_subset_of_subset {s : ι → Set α} {t : Set α} (i : ι) (h : s i ⊆ t) : ⋂ i, s i ⊆ t := iInf_le_of_le i h #align set.Inter_subset_of_subset Set.iInter_subset_of_subset theorem subset_iUnion₂_of_subset {s : Set α} {t : ∀ i, κ i → Set α} (i : ι) (j : κ i) (h : s ⊆ t i j) : s ⊆ ⋃ (i) (j), t i j := le_iSup₂_of_le i j h #align set.subset_Union₂_of_subset Set.subset_iUnion₂_of_subset theorem iInter₂_subset_of_subset {s : ∀ i, κ i → Set α} {t : Set α} (i : ι) (j : κ i) (h : s i j ⊆ t) : ⋂ (i) (j), s i j ⊆ t := iInf₂_le_of_le i j h #align set.Inter₂_subset_of_subset Set.iInter₂_subset_of_subset theorem iUnion_mono {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : ⋃ i, s i ⊆ ⋃ i, t i := iSup_mono h #align set.Union_mono Set.iUnion_mono @[gcongr] theorem iUnion_mono'' {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : iUnion s ⊆ iUnion t := iSup_mono h theorem iUnion₂_mono {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j ⊆ t i j) : ⋃ (i) (j), s i j ⊆ ⋃ (i) (j), t i j := iSup₂_mono h #align set.Union₂_mono Set.iUnion₂_mono theorem iInter_mono {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : ⋂ i, s i ⊆ ⋂ i, t i := iInf_mono h #align set.Inter_mono Set.iInter_mono @[gcongr] theorem iInter_mono'' {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : iInter s ⊆ iInter t := iInf_mono h theorem iInter₂_mono {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j ⊆ t i j) : ⋂ (i) (j), s i j ⊆ ⋂ (i) (j), t i j := iInf₂_mono h #align set.Inter₂_mono Set.iInter₂_mono theorem iUnion_mono' {s : ι → Set α} {t : ι₂ → Set α} (h : ∀ i, ∃ j, s i ⊆ t j) : ⋃ i, s i ⊆ ⋃ i, t i := iSup_mono' h #align set.Union_mono' Set.iUnion_mono' theorem iUnion₂_mono' {s : ∀ i, κ i → Set α} {t : ∀ i', κ' i' → Set α} (h : ∀ i j, ∃ i' j', s i j ⊆ t i' j') : ⋃ (i) (j), s i j ⊆ ⋃ (i') (j'), t i' j' := iSup₂_mono' h #align set.Union₂_mono' Set.iUnion₂_mono' theorem iInter_mono' {s : ι → Set α} {t : ι' → Set α} (h : ∀ j, ∃ i, s i ⊆ t j) : ⋂ i, s i ⊆ ⋂ j, t j := Set.subset_iInter fun j => let ⟨i, hi⟩ := h j iInter_subset_of_subset i hi #align set.Inter_mono' Set.iInter_mono' theorem iInter₂_mono' {s : ∀ i, κ i → Set α} {t : ∀ i', κ' i' → Set α} (h : ∀ i' j', ∃ i j, s i j ⊆ t i' j') : ⋂ (i) (j), s i j ⊆ ⋂ (i') (j'), t i' j' := subset_iInter₂_iff.2 fun i' j' => let ⟨_, _, hst⟩ := h i' j' (iInter₂_subset _ _).trans hst #align set.Inter₂_mono' Set.iInter₂_mono' theorem iUnion₂_subset_iUnion (κ : ι → Sort*) (s : ι → Set α) : ⋃ (i) (_ : κ i), s i ⊆ ⋃ i, s i := iUnion_mono fun _ => iUnion_subset fun _ => Subset.rfl #align set.Union₂_subset_Union Set.iUnion₂_subset_iUnion theorem iInter_subset_iInter₂ (κ : ι → Sort*) (s : ι → Set α) : ⋂ i, s i ⊆ ⋂ (i) (_ : κ i), s i := iInter_mono fun _ => subset_iInter fun _ => Subset.rfl #align set.Inter_subset_Inter₂ Set.iInter_subset_iInter₂ theorem iUnion_setOf (P : ι → α → Prop) : ⋃ i, { x : α | P i x } = { x : α | ∃ i, P i x } := by ext exact mem_iUnion #align set.Union_set_of Set.iUnion_setOf theorem iInter_setOf (P : ι → α → Prop) : ⋂ i, { x : α | P i x } = { x : α | ∀ i, P i x } := by ext exact mem_iInter #align set.Inter_set_of Set.iInter_setOf theorem iUnion_congr_of_surjective {f : ι → Set α} {g : ι₂ → Set α} (h : ι → ι₂) (h1 : Surjective h) (h2 : ∀ x, g (h x) = f x) : ⋃ x, f x = ⋃ y, g y := h1.iSup_congr h h2 #align set.Union_congr_of_surjective Set.iUnion_congr_of_surjective theorem iInter_congr_of_surjective {f : ι → Set α} {g : ι₂ → Set α} (h : ι → ι₂) (h1 : Surjective h) (h2 : ∀ x, g (h x) = f x) : ⋂ x, f x = ⋂ y, g y := h1.iInf_congr h h2 #align set.Inter_congr_of_surjective Set.iInter_congr_of_surjective lemma iUnion_congr {s t : ι → Set α} (h : ∀ i, s i = t i) : ⋃ i, s i = ⋃ i, t i := iSup_congr h #align set.Union_congr Set.iUnion_congr lemma iInter_congr {s t : ι → Set α} (h : ∀ i, s i = t i) : ⋂ i, s i = ⋂ i, t i := iInf_congr h #align set.Inter_congr Set.iInter_congr lemma iUnion₂_congr {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j = t i j) : ⋃ (i) (j), s i j = ⋃ (i) (j), t i j := iUnion_congr fun i => iUnion_congr <| h i #align set.Union₂_congr Set.iUnion₂_congr lemma iInter₂_congr {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j = t i j) : ⋂ (i) (j), s i j = ⋂ (i) (j), t i j := iInter_congr fun i => iInter_congr <| h i #align set.Inter₂_congr Set.iInter₂_congr @[simp] theorem compl_iUnion (s : ι → Set β) : (⋃ i, s i)ᶜ = ⋂ i, (s i)ᶜ := compl_iSup #align set.compl_Union Set.compl_iUnion theorem compl_iUnion₂ (s : ∀ i, κ i → Set α) : (⋃ (i) (j), s i j)ᶜ = ⋂ (i) (j), (s i j)ᶜ := by simp_rw [compl_iUnion] #align set.compl_Union₂ Set.compl_iUnion₂ @[simp] theorem compl_iInter (s : ι → Set β) : (⋂ i, s i)ᶜ = ⋃ i, (s i)ᶜ := compl_iInf #align set.compl_Inter Set.compl_iInter theorem compl_iInter₂ (s : ∀ i, κ i → Set α) : (⋂ (i) (j), s i j)ᶜ = ⋃ (i) (j), (s i j)ᶜ := by simp_rw [compl_iInter] #align set.compl_Inter₂ Set.compl_iInter₂ -- classical -- complete_boolean_algebra theorem iUnion_eq_compl_iInter_compl (s : ι → Set β) : ⋃ i, s i = (⋂ i, (s i)ᶜ)ᶜ := by simp only [compl_iInter, compl_compl] #align set.Union_eq_compl_Inter_compl Set.iUnion_eq_compl_iInter_compl -- classical -- complete_boolean_algebra theorem iInter_eq_compl_iUnion_compl (s : ι → Set β) : ⋂ i, s i = (⋃ i, (s i)ᶜ)ᶜ := by simp only [compl_iUnion, compl_compl] #align set.Inter_eq_compl_Union_compl Set.iInter_eq_compl_iUnion_compl theorem inter_iUnion (s : Set β) (t : ι → Set β) : (s ∩ ⋃ i, t i) = ⋃ i, s ∩ t i := inf_iSup_eq _ _ #align set.inter_Union Set.inter_iUnion theorem iUnion_inter (s : Set β) (t : ι → Set β) : (⋃ i, t i) ∩ s = ⋃ i, t i ∩ s := iSup_inf_eq _ _ #align set.Union_inter Set.iUnion_inter theorem iUnion_union_distrib (s : ι → Set β) (t : ι → Set β) : ⋃ i, s i ∪ t i = (⋃ i, s i) ∪ ⋃ i, t i := iSup_sup_eq #align set.Union_union_distrib Set.iUnion_union_distrib theorem iInter_inter_distrib (s : ι → Set β) (t : ι → Set β) : ⋂ i, s i ∩ t i = (⋂ i, s i) ∩ ⋂ i, t i := iInf_inf_eq #align set.Inter_inter_distrib Set.iInter_inter_distrib theorem union_iUnion [Nonempty ι] (s : Set β) (t : ι → Set β) : (s ∪ ⋃ i, t i) = ⋃ i, s ∪ t i := sup_iSup #align set.union_Union Set.union_iUnion theorem iUnion_union [Nonempty ι] (s : Set β) (t : ι → Set β) : (⋃ i, t i) ∪ s = ⋃ i, t i ∪ s := iSup_sup #align set.Union_union Set.iUnion_union theorem inter_iInter [Nonempty ι] (s : Set β) (t : ι → Set β) : (s ∩ ⋂ i, t i) = ⋂ i, s ∩ t i := inf_iInf #align set.inter_Inter Set.inter_iInter theorem iInter_inter [Nonempty ι] (s : Set β) (t : ι → Set β) : (⋂ i, t i) ∩ s = ⋂ i, t i ∩ s := iInf_inf #align set.Inter_inter Set.iInter_inter -- classical theorem union_iInter (s : Set β) (t : ι → Set β) : (s ∪ ⋂ i, t i) = ⋂ i, s ∪ t i := sup_iInf_eq _ _ #align set.union_Inter Set.union_iInter theorem iInter_union (s : ι → Set β) (t : Set β) : (⋂ i, s i) ∪ t = ⋂ i, s i ∪ t := iInf_sup_eq _ _ #align set.Inter_union Set.iInter_union theorem iUnion_diff (s : Set β) (t : ι → Set β) : (⋃ i, t i) \ s = ⋃ i, t i \ s := iUnion_inter _ _ #align set.Union_diff Set.iUnion_diff theorem diff_iUnion [Nonempty ι] (s : Set β) (t : ι → Set β) : (s \ ⋃ i, t i) = ⋂ i, s \ t i := by rw [diff_eq, compl_iUnion, inter_iInter]; rfl #align set.diff_Union Set.diff_iUnion theorem diff_iInter (s : Set β) (t : ι → Set β) : (s \ ⋂ i, t i) = ⋃ i, s \ t i := by rw [diff_eq, compl_iInter, inter_iUnion]; rfl #align set.diff_Inter Set.diff_iInter theorem iUnion_inter_subset {ι α} {s t : ι → Set α} : ⋃ i, s i ∩ t i ⊆ (⋃ i, s i) ∩ ⋃ i, t i := le_iSup_inf_iSup s t #align set.Union_inter_subset Set.iUnion_inter_subset theorem iUnion_inter_of_monotone {ι α} [Preorder ι] [IsDirected ι (· ≤ ·)] {s t : ι → Set α} (hs : Monotone s) (ht : Monotone t) : ⋃ i, s i ∩ t i = (⋃ i, s i) ∩ ⋃ i, t i := iSup_inf_of_monotone hs ht #align set.Union_inter_of_monotone Set.iUnion_inter_of_monotone theorem iUnion_inter_of_antitone {ι α} [Preorder ι] [IsDirected ι (swap (· ≤ ·))] {s t : ι → Set α} (hs : Antitone s) (ht : Antitone t) : ⋃ i, s i ∩ t i = (⋃ i, s i) ∩ ⋃ i, t i := iSup_inf_of_antitone hs ht #align set.Union_inter_of_antitone Set.iUnion_inter_of_antitone theorem iInter_union_of_monotone {ι α} [Preorder ι] [IsDirected ι (swap (· ≤ ·))] {s t : ι → Set α} (hs : Monotone s) (ht : Monotone t) : ⋂ i, s i ∪ t i = (⋂ i, s i) ∪ ⋂ i, t i := iInf_sup_of_monotone hs ht #align set.Inter_union_of_monotone Set.iInter_union_of_monotone theorem iInter_union_of_antitone {ι α} [Preorder ι] [IsDirected ι (· ≤ ·)] {s t : ι → Set α} (hs : Antitone s) (ht : Antitone t) : ⋂ i, s i ∪ t i = (⋂ i, s i) ∪ ⋂ i, t i := iInf_sup_of_antitone hs ht #align set.Inter_union_of_antitone Set.iInter_union_of_antitone theorem iUnion_iInter_subset {s : ι → ι' → Set α} : (⋃ j, ⋂ i, s i j) ⊆ ⋂ i, ⋃ j, s i j := iSup_iInf_le_iInf_iSup (flip s) #align set.Union_Inter_subset Set.iUnion_iInter_subset theorem iUnion_option {ι} (s : Option ι → Set α) : ⋃ o, s o = s none ∪ ⋃ i, s (some i) := iSup_option s #align set.Union_option Set.iUnion_option theorem iInter_option {ι} (s : Option ι → Set α) : ⋂ o, s o = s none ∩ ⋂ i, s (some i) := iInf_option s #align set.Inter_option Set.iInter_option section variable (p : ι → Prop) [DecidablePred p] theorem iUnion_dite (f : ∀ i, p i → Set α) (g : ∀ i, ¬p i → Set α) : ⋃ i, (if h : p i then f i h else g i h) = (⋃ (i) (h : p i), f i h) ∪ ⋃ (i) (h : ¬p i), g i h := iSup_dite _ _ _ #align set.Union_dite Set.iUnion_dite theorem iUnion_ite (f g : ι → Set α) : ⋃ i, (if p i then f i else g i) = (⋃ (i) (_ : p i), f i) ∪ ⋃ (i) (_ : ¬p i), g i := iUnion_dite _ _ _ #align set.Union_ite Set.iUnion_ite theorem iInter_dite (f : ∀ i, p i → Set α) (g : ∀ i, ¬p i → Set α) : ⋂ i, (if h : p i then f i h else g i h) = (⋂ (i) (h : p i), f i h) ∩ ⋂ (i) (h : ¬p i), g i h := iInf_dite _ _ _ #align set.Inter_dite Set.iInter_dite theorem iInter_ite (f g : ι → Set α) : ⋂ i, (if p i then f i else g i) = (⋂ (i) (_ : p i), f i) ∩ ⋂ (i) (_ : ¬p i), g i := iInter_dite _ _ _ #align set.Inter_ite Set.iInter_ite end theorem image_projection_prod {ι : Type*} {α : ι → Type*} {v : ∀ i : ι, Set (α i)} (hv : (pi univ v).Nonempty) (i : ι) : ((fun x : ∀ i : ι, α i => x i) '' ⋂ k, (fun x : ∀ j : ι, α j => x k) ⁻¹' v k) = v i := by classical apply Subset.antisymm · simp [iInter_subset] · intro y y_in simp only [mem_image, mem_iInter, mem_preimage] rcases hv with ⟨z, hz⟩ refine ⟨Function.update z i y, ?_, update_same i y z⟩ rw [@forall_update_iff ι α _ z i y fun i t => t ∈ v i] exact ⟨y_in, fun j _ => by simpa using hz j⟩ #align set.image_projection_prod Set.image_projection_prod theorem iInter_false {s : False → Set α} : iInter s = univ := iInf_false #align set.Inter_false Set.iInter_false theorem iUnion_false {s : False → Set α} : iUnion s = ∅ := iSup_false #align set.Union_false Set.iUnion_false @[simp] theorem iInter_true {s : True → Set α} : iInter s = s trivial := iInf_true #align set.Inter_true Set.iInter_true @[simp] theorem iUnion_true {s : True → Set α} : iUnion s = s trivial := iSup_true #align set.Union_true Set.iUnion_true @[simp] theorem iInter_exists {p : ι → Prop} {f : Exists p → Set α} : ⋂ x, f x = ⋂ (i) (h : p i), f ⟨i, h⟩ := iInf_exists #align set.Inter_exists Set.iInter_exists @[simp] theorem iUnion_exists {p : ι → Prop} {f : Exists p → Set α} : ⋃ x, f x = ⋃ (i) (h : p i), f ⟨i, h⟩ := iSup_exists #align set.Union_exists Set.iUnion_exists @[simp] theorem iUnion_empty : (⋃ _ : ι, ∅ : Set α) = ∅ := iSup_bot #align set.Union_empty Set.iUnion_empty @[simp] theorem iInter_univ : (⋂ _ : ι, univ : Set α) = univ := iInf_top #align set.Inter_univ Set.iInter_univ section variable {s : ι → Set α} @[simp] theorem iUnion_eq_empty : ⋃ i, s i = ∅ ↔ ∀ i, s i = ∅ := iSup_eq_bot #align set.Union_eq_empty Set.iUnion_eq_empty @[simp] theorem iInter_eq_univ : ⋂ i, s i = univ ↔ ∀ i, s i = univ := iInf_eq_top #align set.Inter_eq_univ Set.iInter_eq_univ @[simp] theorem nonempty_iUnion : (⋃ i, s i).Nonempty ↔ ∃ i, (s i).Nonempty := by simp [nonempty_iff_ne_empty] #align set.nonempty_Union Set.nonempty_iUnion -- Porting note (#10618): removing `simp`. `simp` can prove it theorem nonempty_biUnion {t : Set α} {s : α → Set β} : (⋃ i ∈ t, s i).Nonempty ↔ ∃ i ∈ t, (s i).Nonempty := by simp #align set.nonempty_bUnion Set.nonempty_biUnion theorem iUnion_nonempty_index (s : Set α) (t : s.Nonempty → Set β) : ⋃ h, t h = ⋃ x ∈ s, t ⟨x, ‹_›⟩ := iSup_exists #align set.Union_nonempty_index Set.iUnion_nonempty_index end @[simp] theorem iInter_iInter_eq_left {b : β} {s : ∀ x : β, x = b → Set α} : ⋂ (x) (h : x = b), s x h = s b rfl := iInf_iInf_eq_left #align set.Inter_Inter_eq_left Set.iInter_iInter_eq_left @[simp] theorem iInter_iInter_eq_right {b : β} {s : ∀ x : β, b = x → Set α} : ⋂ (x) (h : b = x), s x h = s b rfl := iInf_iInf_eq_right #align set.Inter_Inter_eq_right Set.iInter_iInter_eq_right @[simp] theorem iUnion_iUnion_eq_left {b : β} {s : ∀ x : β, x = b → Set α} : ⋃ (x) (h : x = b), s x h = s b rfl := iSup_iSup_eq_left #align set.Union_Union_eq_left Set.iUnion_iUnion_eq_left @[simp] theorem iUnion_iUnion_eq_right {b : β} {s : ∀ x : β, b = x → Set α} : ⋃ (x) (h : b = x), s x h = s b rfl := iSup_iSup_eq_right #align set.Union_Union_eq_right Set.iUnion_iUnion_eq_right theorem iInter_or {p q : Prop} (s : p ∨ q → Set α) : ⋂ h, s h = (⋂ h : p, s (Or.inl h)) ∩ ⋂ h : q, s (Or.inr h) := iInf_or #align set.Inter_or Set.iInter_or theorem iUnion_or {p q : Prop} (s : p ∨ q → Set α) : ⋃ h, s h = (⋃ i, s (Or.inl i)) ∪ ⋃ j, s (Or.inr j) := iSup_or #align set.Union_or Set.iUnion_or theorem iUnion_and {p q : Prop} (s : p ∧ q → Set α) : ⋃ h, s h = ⋃ (hp) (hq), s ⟨hp, hq⟩ := iSup_and #align set.Union_and Set.iUnion_and theorem iInter_and {p q : Prop} (s : p ∧ q → Set α) : ⋂ h, s h = ⋂ (hp) (hq), s ⟨hp, hq⟩ := iInf_and #align set.Inter_and Set.iInter_and theorem iUnion_comm (s : ι → ι' → Set α) : ⋃ (i) (i'), s i i' = ⋃ (i') (i), s i i' := iSup_comm #align set.Union_comm Set.iUnion_comm theorem iInter_comm (s : ι → ι' → Set α) : ⋂ (i) (i'), s i i' = ⋂ (i') (i), s i i' := iInf_comm #align set.Inter_comm Set.iInter_comm theorem iUnion_sigma {γ : α → Type*} (s : Sigma γ → Set β) : ⋃ ia, s ia = ⋃ i, ⋃ a, s ⟨i, a⟩ := iSup_sigma theorem iUnion_sigma' {γ : α → Type*} (s : ∀ i, γ i → Set β) : ⋃ i, ⋃ a, s i a = ⋃ ia : Sigma γ, s ia.1 ia.2 := iSup_sigma' _ theorem iInter_sigma {γ : α → Type*} (s : Sigma γ → Set β) : ⋂ ia, s ia = ⋂ i, ⋂ a, s ⟨i, a⟩ := iInf_sigma theorem iInter_sigma' {γ : α → Type*} (s : ∀ i, γ i → Set β) : ⋂ i, ⋂ a, s i a = ⋂ ia : Sigma γ, s ia.1 ia.2 := iInf_sigma' _ theorem iUnion₂_comm (s : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → Set α) : ⋃ (i₁) (j₁) (i₂) (j₂), s i₁ j₁ i₂ j₂ = ⋃ (i₂) (j₂) (i₁) (j₁), s i₁ j₁ i₂ j₂ := iSup₂_comm _ #align set.Union₂_comm Set.iUnion₂_comm theorem iInter₂_comm (s : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → Set α) : ⋂ (i₁) (j₁) (i₂) (j₂), s i₁ j₁ i₂ j₂ = ⋂ (i₂) (j₂) (i₁) (j₁), s i₁ j₁ i₂ j₂ := iInf₂_comm _ #align set.Inter₂_comm Set.iInter₂_comm @[simp] theorem biUnion_and (p : ι → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p x ∧ q x y → Set α) : ⋃ (x : ι) (y : ι') (h : p x ∧ q x y), s x y h = ⋃ (x : ι) (hx : p x) (y : ι') (hy : q x y), s x y ⟨hx, hy⟩ := by simp only [iUnion_and, @iUnion_comm _ ι'] #align set.bUnion_and Set.biUnion_and @[simp] theorem biUnion_and' (p : ι' → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p y ∧ q x y → Set α) : ⋃ (x : ι) (y : ι') (h : p y ∧ q x y), s x y h = ⋃ (y : ι') (hy : p y) (x : ι) (hx : q x y), s x y ⟨hy, hx⟩ := by simp only [iUnion_and, @iUnion_comm _ ι] #align set.bUnion_and' Set.biUnion_and' @[simp] theorem biInter_and (p : ι → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p x ∧ q x y → Set α) : ⋂ (x : ι) (y : ι') (h : p x ∧ q x y), s x y h = ⋂ (x : ι) (hx : p x) (y : ι') (hy : q x y), s x y ⟨hx, hy⟩ := by simp only [iInter_and, @iInter_comm _ ι'] #align set.bInter_and Set.biInter_and @[simp] theorem biInter_and' (p : ι' → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p y ∧ q x y → Set α) : ⋂ (x : ι) (y : ι') (h : p y ∧ q x y), s x y h = ⋂ (y : ι') (hy : p y) (x : ι) (hx : q x y), s x y ⟨hy, hx⟩ := by simp only [iInter_and, @iInter_comm _ ι] #align set.bInter_and' Set.biInter_and' @[simp] theorem iUnion_iUnion_eq_or_left {b : β} {p : β → Prop} {s : ∀ x : β, x = b ∨ p x → Set α} : ⋃ (x) (h), s x h = s b (Or.inl rfl) ∪ ⋃ (x) (h : p x), s x (Or.inr h) := by simp only [iUnion_or, iUnion_union_distrib, iUnion_iUnion_eq_left] #align set.Union_Union_eq_or_left Set.iUnion_iUnion_eq_or_left @[simp] theorem iInter_iInter_eq_or_left {b : β} {p : β → Prop} {s : ∀ x : β, x = b ∨ p x → Set α} : ⋂ (x) (h), s x h = s b (Or.inl rfl) ∩ ⋂ (x) (h : p x), s x (Or.inr h) := by simp only [iInter_or, iInter_inter_distrib, iInter_iInter_eq_left] #align set.Inter_Inter_eq_or_left Set.iInter_iInter_eq_or_left theorem mem_biUnion {s : Set α} {t : α → Set β} {x : α} {y : β} (xs : x ∈ s) (ytx : y ∈ t x) : y ∈ ⋃ x ∈ s, t x := mem_iUnion₂_of_mem xs ytx #align set.mem_bUnion Set.mem_biUnion theorem mem_biInter {s : Set α} {t : α → Set β} {y : β} (h : ∀ x ∈ s, y ∈ t x) : y ∈ ⋂ x ∈ s, t x := mem_iInter₂_of_mem h #align set.mem_bInter Set.mem_biInter theorem subset_biUnion_of_mem {s : Set α} {u : α → Set β} {x : α} (xs : x ∈ s) : u x ⊆ ⋃ x ∈ s, u x := -- Porting note: Why is this not just `subset_iUnion₂ x xs`? @subset_iUnion₂ β α (· ∈ s) (fun i _ => u i) x xs #align set.subset_bUnion_of_mem Set.subset_biUnion_of_mem theorem biInter_subset_of_mem {s : Set α} {t : α → Set β} {x : α} (xs : x ∈ s) : ⋂ x ∈ s, t x ⊆ t x := iInter₂_subset x xs #align set.bInter_subset_of_mem Set.biInter_subset_of_mem theorem biUnion_subset_biUnion_left {s s' : Set α} {t : α → Set β} (h : s ⊆ s') : ⋃ x ∈ s, t x ⊆ ⋃ x ∈ s', t x := iUnion₂_subset fun _ hx => subset_biUnion_of_mem <| h hx #align set.bUnion_subset_bUnion_left Set.biUnion_subset_biUnion_left theorem biInter_subset_biInter_left {s s' : Set α} {t : α → Set β} (h : s' ⊆ s) : ⋂ x ∈ s, t x ⊆ ⋂ x ∈ s', t x := subset_iInter₂ fun _ hx => biInter_subset_of_mem <| h hx #align set.bInter_subset_bInter_left Set.biInter_subset_biInter_left theorem biUnion_mono {s s' : Set α} {t t' : α → Set β} (hs : s' ⊆ s) (h : ∀ x ∈ s, t x ⊆ t' x) : ⋃ x ∈ s', t x ⊆ ⋃ x ∈ s, t' x := (biUnion_subset_biUnion_left hs).trans <| iUnion₂_mono h #align set.bUnion_mono Set.biUnion_mono theorem biInter_mono {s s' : Set α} {t t' : α → Set β} (hs : s ⊆ s') (h : ∀ x ∈ s, t x ⊆ t' x) : ⋂ x ∈ s', t x ⊆ ⋂ x ∈ s, t' x := (biInter_subset_biInter_left hs).trans <| iInter₂_mono h #align set.bInter_mono Set.biInter_mono theorem biUnion_eq_iUnion (s : Set α) (t : ∀ x ∈ s, Set β) : ⋃ x ∈ s, t x ‹_› = ⋃ x : s, t x x.2 := iSup_subtype' #align set.bUnion_eq_Union Set.biUnion_eq_iUnion theorem biInter_eq_iInter (s : Set α) (t : ∀ x ∈ s, Set β) : ⋂ x ∈ s, t x ‹_› = ⋂ x : s, t x x.2 := iInf_subtype' #align set.bInter_eq_Inter Set.biInter_eq_iInter theorem iUnion_subtype (p : α → Prop) (s : { x // p x } → Set β) : ⋃ x : { x // p x }, s x = ⋃ (x) (hx : p x), s ⟨x, hx⟩ := iSup_subtype #align set.Union_subtype Set.iUnion_subtype theorem iInter_subtype (p : α → Prop) (s : { x // p x } → Set β) : ⋂ x : { x // p x }, s x = ⋂ (x) (hx : p x), s ⟨x, hx⟩ := iInf_subtype #align set.Inter_subtype Set.iInter_subtype theorem biInter_empty (u : α → Set β) : ⋂ x ∈ (∅ : Set α), u x = univ := iInf_emptyset #align set.bInter_empty Set.biInter_empty theorem biInter_univ (u : α → Set β) : ⋂ x ∈ @univ α, u x = ⋂ x, u x := iInf_univ #align set.bInter_univ Set.biInter_univ @[simp] theorem biUnion_self (s : Set α) : ⋃ x ∈ s, s = s := Subset.antisymm (iUnion₂_subset fun _ _ => Subset.refl s) fun _ hx => mem_biUnion hx hx #align set.bUnion_self Set.biUnion_self @[simp] theorem iUnion_nonempty_self (s : Set α) : ⋃ _ : s.Nonempty, s = s := by rw [iUnion_nonempty_index, biUnion_self] #align set.Union_nonempty_self Set.iUnion_nonempty_self theorem biInter_singleton (a : α) (s : α → Set β) : ⋂ x ∈ ({a} : Set α), s x = s a := iInf_singleton #align set.bInter_singleton Set.biInter_singleton theorem biInter_union (s t : Set α) (u : α → Set β) : ⋂ x ∈ s ∪ t, u x = (⋂ x ∈ s, u x) ∩ ⋂ x ∈ t, u x := iInf_union #align set.bInter_union Set.biInter_union
Mathlib/Data/Set/Lattice.lean
909
910
theorem biInter_insert (a : α) (s : Set α) (t : α → Set β) : ⋂ x ∈ insert a s, t x = t a ∩ ⋂ x ∈ s, t x := by
simp
import Mathlib.Data.Finset.Lattice import Mathlib.Data.Set.Sigma #align_import data.finset.sigma from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" open Function Multiset variable {ι : Type*} namespace Finset section SigmaLift variable {α β γ : ι → Type*} [DecidableEq ι] def sigmaLift (f : ∀ ⦃i⦄, α i → β i → Finset (γ i)) (a : Sigma α) (b : Sigma β) : Finset (Sigma γ) := dite (a.1 = b.1) (fun h => (f (h ▸ a.2) b.2).map <| Embedding.sigmaMk _) fun _ => ∅ #align finset.sigma_lift Finset.sigmaLift theorem mem_sigmaLift (f : ∀ ⦃i⦄, α i → β i → Finset (γ i)) (a : Sigma α) (b : Sigma β) (x : Sigma γ) : x ∈ sigmaLift f a b ↔ ∃ (ha : a.1 = x.1) (hb : b.1 = x.1), x.2 ∈ f (ha ▸ a.2) (hb ▸ b.2) := by obtain ⟨⟨i, a⟩, j, b⟩ := a, b obtain rfl | h := Decidable.eq_or_ne i j · constructor · simp_rw [sigmaLift] simp only [dite_eq_ite, ite_true, mem_map, Embedding.sigmaMk_apply, forall_exists_index, and_imp] rintro x hx rfl exact ⟨rfl, rfl, hx⟩ · rintro ⟨⟨⟩, ⟨⟩, hx⟩ rw [sigmaLift, dif_pos rfl, mem_map] exact ⟨_, hx, by simp [Sigma.ext_iff]⟩ · rw [sigmaLift, dif_neg h] refine iff_of_false (not_mem_empty _) ?_ rintro ⟨⟨⟩, ⟨⟩, _⟩ exact h rfl #align finset.mem_sigma_lift Finset.mem_sigmaLift theorem mk_mem_sigmaLift (f : ∀ ⦃i⦄, α i → β i → Finset (γ i)) (i : ι) (a : α i) (b : β i) (x : γ i) : (⟨i, x⟩ : Sigma γ) ∈ sigmaLift f ⟨i, a⟩ ⟨i, b⟩ ↔ x ∈ f a b := by rw [sigmaLift, dif_pos rfl, mem_map] refine ⟨?_, fun hx => ⟨_, hx, rfl⟩⟩ rintro ⟨x, hx, _, rfl⟩ exact hx #align finset.mk_mem_sigma_lift Finset.mk_mem_sigmaLift theorem not_mem_sigmaLift_of_ne_left (f : ∀ ⦃i⦄, α i → β i → Finset (γ i)) (a : Sigma α) (b : Sigma β) (x : Sigma γ) (h : a.1 ≠ x.1) : x ∉ sigmaLift f a b := by rw [mem_sigmaLift] exact fun H => h H.fst #align finset.not_mem_sigma_lift_of_ne_left Finset.not_mem_sigmaLift_of_ne_left theorem not_mem_sigmaLift_of_ne_right (f : ∀ ⦃i⦄, α i → β i → Finset (γ i)) {a : Sigma α} (b : Sigma β) {x : Sigma γ} (h : b.1 ≠ x.1) : x ∉ sigmaLift f a b := by rw [mem_sigmaLift] exact fun H => h H.snd.fst #align finset.not_mem_sigma_lift_of_ne_right Finset.not_mem_sigmaLift_of_ne_right variable {f g : ∀ ⦃i⦄, α i → β i → Finset (γ i)} {a : Σi, α i} {b : Σi, β i}
Mathlib/Data/Finset/Sigma.lean
198
201
theorem sigmaLift_nonempty : (sigmaLift f a b).Nonempty ↔ ∃ h : a.1 = b.1, (f (h ▸ a.2) b.2).Nonempty := by
simp_rw [nonempty_iff_ne_empty, sigmaLift] split_ifs with h <;> simp [h]
import Mathlib.LinearAlgebra.Matrix.Adjugate import Mathlib.RingTheory.PolynomialAlgebra #align_import linear_algebra.matrix.charpoly.basic from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" noncomputable section universe u v w namespace Matrix open Finset Matrix Polynomial variable {R S : Type*} [CommRing R] [CommRing S] variable {m n : Type*} [DecidableEq m] [DecidableEq n] [Fintype m] [Fintype n] variable (M₁₁ : Matrix m m R) (M₁₂ : Matrix m n R) (M₂₁ : Matrix n m R) (M₂₂ M : Matrix n n R) variable (i j : n) def charmatrix (M : Matrix n n R) : Matrix n n R[X] := Matrix.scalar n (X : R[X]) - (C : R →+* R[X]).mapMatrix M #align charmatrix Matrix.charmatrix theorem charmatrix_apply : charmatrix M i j = (Matrix.diagonal fun _ : n => X) i j - C (M i j) := rfl #align charmatrix_apply Matrix.charmatrix_apply @[simp]
Mathlib/LinearAlgebra/Matrix/Charpoly/Basic.lean
55
57
theorem charmatrix_apply_eq : charmatrix M i i = (X : R[X]) - C (M i i) := by
simp only [charmatrix, RingHom.mapMatrix_apply, sub_apply, scalar_apply, map_apply, diagonal_apply_eq]
import Mathlib.CategoryTheory.Adjunction.Basic open CategoryTheory variable {C D : Type*} [Category C] [Category D] namespace CategoryTheory.Adjunction @[simps] def natTransEquiv {F F' : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') : (G ⟶ G') ≃ (F' ⟶ F) where toFun f := { app := fun X ↦ F'.map ((adj1.unit ≫ whiskerLeft F f).app X) ≫ adj2.counit.app _ naturality := by intro X Y g simp only [← Category.assoc, ← Functor.map_comp] erw [(adj1.unit ≫ (whiskerLeft F f)).naturality] simp } invFun f := { app := fun X ↦ adj2.unit.app (G.obj X) ≫ G'.map (f.app (G.obj X) ≫ adj1.counit.app X) naturality := by intro X Y g erw [← adj2.unit_naturality_assoc] simp only [← Functor.map_comp] simp } left_inv f := by ext X simp only [Functor.comp_obj, NatTrans.comp_app, Functor.id_obj, whiskerLeft_app, Functor.map_comp, Category.assoc, unit_naturality_assoc, right_triangle_components_assoc] erw [← f.naturality (adj1.counit.app X), ← Category.assoc] simp right_inv f := by ext simp @[simp] lemma natTransEquiv_id {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) : natTransEquiv adj adj (𝟙 _) = 𝟙 _ := by ext; simp @[simp] lemma natTransEquiv_id_symm {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) : (natTransEquiv adj adj).symm (𝟙 _) = 𝟙 _ := by ext; simp @[simp] lemma natTransEquiv_comp {F F' F'' : C ⥤ D} {G G' G'' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') (adj3 : F'' ⊣ G'') (f : G ⟶ G') (g : G' ⟶ G'') : natTransEquiv adj2 adj3 g ≫ natTransEquiv adj1 adj2 f = natTransEquiv adj1 adj3 (f ≫ g) := by apply (natTransEquiv adj1 adj3).symm.injective ext X simp only [natTransEquiv_symm_apply_app, Functor.comp_obj, NatTrans.comp_app, natTransEquiv_apply_app, Functor.id_obj, whiskerLeft_app, Functor.map_comp, Category.assoc, unit_naturality_assoc, right_triangle_components_assoc, Equiv.symm_apply_apply, ← g.naturality_assoc, ← g.naturality] simp only [← Category.assoc, unit_naturality, Functor.comp_obj, right_triangle_components, Category.comp_id, ← f.naturality, Category.id_comp] @[simp] lemma natTransEquiv_comp_symm {F F' F'' : C ⥤ D} {G G' G'' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') (adj3 : F'' ⊣ G'') (f : F' ⟶ F) (g : F'' ⟶ F') : (natTransEquiv adj1 adj2).symm f ≫ (natTransEquiv adj2 adj3).symm g = (natTransEquiv adj1 adj3).symm (g ≫ f) := by apply (natTransEquiv adj1 adj3).injective ext simp @[simps] def natIsoEquiv {F F' : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') : (G ≅ G') ≃ (F' ≅ F) where toFun i := { hom := natTransEquiv adj1 adj2 i.hom inv := natTransEquiv adj2 adj1 i.inv } invFun i := { hom := (natTransEquiv adj1 adj2).symm i.hom inv := (natTransEquiv adj2 adj1).symm i.inv } left_inv i := by simp right_inv i := by simp def leftAdjointUniq {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) : F ≅ F' := (natIsoEquiv adj1 adj2 (Iso.refl _)).symm #align category_theory.adjunction.left_adjoint_uniq CategoryTheory.Adjunction.leftAdjointUniq -- Porting note (#10618): removed simp as simp can prove this theorem homEquiv_leftAdjointUniq_hom_app {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) : adj1.homEquiv _ _ ((leftAdjointUniq adj1 adj2).hom.app x) = adj2.unit.app x := by simp [leftAdjointUniq] #align category_theory.adjunction.hom_equiv_left_adjoint_uniq_hom_app CategoryTheory.Adjunction.homEquiv_leftAdjointUniq_hom_app @[reassoc (attr := simp)] theorem unit_leftAdjointUniq_hom {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) : adj1.unit ≫ whiskerRight (leftAdjointUniq adj1 adj2).hom G = adj2.unit := by ext x rw [NatTrans.comp_app, ← homEquiv_leftAdjointUniq_hom_app adj1 adj2] simp [← G.map_comp] #align category_theory.adjunction.unit_left_adjoint_uniq_hom CategoryTheory.Adjunction.unit_leftAdjointUniq_hom @[reassoc (attr := simp)] theorem unit_leftAdjointUniq_hom_app {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) : adj1.unit.app x ≫ G.map ((leftAdjointUniq adj1 adj2).hom.app x) = adj2.unit.app x := by rw [← unit_leftAdjointUniq_hom adj1 adj2]; rfl #align category_theory.adjunction.unit_left_adjoint_uniq_hom_app CategoryTheory.Adjunction.unit_leftAdjointUniq_hom_app @[reassoc (attr := simp)] theorem leftAdjointUniq_hom_counit {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) : whiskerLeft G (leftAdjointUniq adj1 adj2).hom ≫ adj2.counit = adj1.counit := by ext x simp only [Functor.comp_obj, Functor.id_obj, leftAdjointUniq, Iso.symm_hom, natIsoEquiv_apply_inv, Iso.refl_inv, NatTrans.comp_app, whiskerLeft_app, natTransEquiv_apply_app, whiskerLeft_id', Category.comp_id, Category.assoc] rw [← adj1.counit_naturality, ← Category.assoc, ← F.map_comp] simp #align category_theory.adjunction.left_adjoint_uniq_hom_counit CategoryTheory.Adjunction.leftAdjointUniq_hom_counit @[reassoc (attr := simp)] theorem leftAdjointUniq_hom_app_counit {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : D) : (leftAdjointUniq adj1 adj2).hom.app (G.obj x) ≫ adj2.counit.app x = adj1.counit.app x := by rw [← leftAdjointUniq_hom_counit adj1 adj2] rfl #align category_theory.adjunction.left_adjoint_uniq_hom_app_counit CategoryTheory.Adjunction.leftAdjointUniq_hom_app_counit theorem leftAdjointUniq_inv_app {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) : (leftAdjointUniq adj1 adj2).inv.app x = (leftAdjointUniq adj2 adj1).hom.app x := rfl #align category_theory.adjunction.left_adjoint_uniq_inv_app CategoryTheory.Adjunction.leftAdjointUniq_inv_app @[reassoc (attr := simp)] theorem leftAdjointUniq_trans {F F' F'' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (adj3 : F'' ⊣ G) : (leftAdjointUniq adj1 adj2).hom ≫ (leftAdjointUniq adj2 adj3).hom = (leftAdjointUniq adj1 adj3).hom := by simp [leftAdjointUniq] #align category_theory.adjunction.left_adjoint_uniq_trans CategoryTheory.Adjunction.leftAdjointUniq_trans @[reassoc (attr := simp)] theorem leftAdjointUniq_trans_app {F F' F'' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (adj3 : F'' ⊣ G) (x : C) : (leftAdjointUniq adj1 adj2).hom.app x ≫ (leftAdjointUniq adj2 adj3).hom.app x = (leftAdjointUniq adj1 adj3).hom.app x := by rw [← leftAdjointUniq_trans adj1 adj2 adj3] rfl #align category_theory.adjunction.left_adjoint_uniq_trans_app CategoryTheory.Adjunction.leftAdjointUniq_trans_app @[simp] theorem leftAdjointUniq_refl {F : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) : (leftAdjointUniq adj1 adj1).hom = 𝟙 _ := by simp [leftAdjointUniq] #align category_theory.adjunction.left_adjoint_uniq_refl CategoryTheory.Adjunction.leftAdjointUniq_refl def rightAdjointUniq {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') : G ≅ G' := (natIsoEquiv adj1 adj2).symm (Iso.refl _) #align category_theory.adjunction.right_adjoint_uniq CategoryTheory.Adjunction.rightAdjointUniq -- Porting note (#10618): simp can prove this theorem homEquiv_symm_rightAdjointUniq_hom_app {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') (x : D) : (adj2.homEquiv _ _).symm ((rightAdjointUniq adj1 adj2).hom.app x) = adj1.counit.app x := by simp [rightAdjointUniq] #align category_theory.adjunction.hom_equiv_symm_right_adjoint_uniq_hom_app CategoryTheory.Adjunction.homEquiv_symm_rightAdjointUniq_hom_app @[reassoc (attr := simp)]
Mathlib/CategoryTheory/Adjunction/Unique.lean
197
203
theorem unit_rightAdjointUniq_hom_app {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') (x : C) : adj1.unit.app x ≫ (rightAdjointUniq adj1 adj2).hom.app (F.obj x) = adj2.unit.app x := by
simp only [Functor.id_obj, Functor.comp_obj, rightAdjointUniq, natIsoEquiv_symm_apply_hom, Iso.refl_hom, natTransEquiv_symm_apply_app, NatTrans.id_app, Category.id_comp] rw [← adj2.unit_naturality_assoc, ← G'.map_comp] simp
import Mathlib.Algebra.Order.BigOperators.Ring.Finset import Mathlib.Analysis.Convex.Hull import Mathlib.LinearAlgebra.AffineSpace.Basis #align_import analysis.convex.combination from "leanprover-community/mathlib"@"92bd7b1ffeb306a89f450bee126ddd8a284c259d" open Set Function open scoped Classical open Pointwise universe u u' variable {R R' E F ι ι' α : Type*} [LinearOrderedField R] [LinearOrderedField R'] [AddCommGroup E] [AddCommGroup F] [LinearOrderedAddCommGroup α] [Module R E] [Module R F] [Module R α] [OrderedSMul R α] {s : Set E} def Finset.centerMass (t : Finset ι) (w : ι → R) (z : ι → E) : E := (∑ i ∈ t, w i)⁻¹ • ∑ i ∈ t, w i • z i #align finset.center_mass Finset.centerMass variable (i j : ι) (c : R) (t : Finset ι) (w : ι → R) (z : ι → E) open Finset theorem Finset.centerMass_empty : (∅ : Finset ι).centerMass w z = 0 := by simp only [centerMass, sum_empty, smul_zero] #align finset.center_mass_empty Finset.centerMass_empty theorem Finset.centerMass_pair (hne : i ≠ j) : ({i, j} : Finset ι).centerMass w z = (w i / (w i + w j)) • z i + (w j / (w i + w j)) • z j := by simp only [centerMass, sum_pair hne, smul_add, (mul_smul _ _ _).symm, div_eq_inv_mul] #align finset.center_mass_pair Finset.centerMass_pair variable {w} theorem Finset.centerMass_insert (ha : i ∉ t) (hw : ∑ j ∈ t, w j ≠ 0) : (insert i t).centerMass w z = (w i / (w i + ∑ j ∈ t, w j)) • z i + ((∑ j ∈ t, w j) / (w i + ∑ j ∈ t, w j)) • t.centerMass w z := by simp only [centerMass, sum_insert ha, smul_add, (mul_smul _ _ _).symm, ← div_eq_inv_mul] congr 2 rw [div_mul_eq_mul_div, mul_inv_cancel hw, one_div] #align finset.center_mass_insert Finset.centerMass_insert theorem Finset.centerMass_singleton (hw : w i ≠ 0) : ({i} : Finset ι).centerMass w z = z i := by rw [centerMass, sum_singleton, sum_singleton, ← mul_smul, inv_mul_cancel hw, one_smul] #align finset.center_mass_singleton Finset.centerMass_singleton @[simp] lemma Finset.centerMass_neg_left : t.centerMass (-w) z = t.centerMass w z := by simp [centerMass, inv_neg] lemma Finset.centerMass_smul_left {c : R'} [Module R' R] [Module R' E] [SMulCommClass R' R R] [IsScalarTower R' R R] [SMulCommClass R R' E] [IsScalarTower R' R E] (hc : c ≠ 0) : t.centerMass (c • w) z = t.centerMass w z := by simp [centerMass, -smul_assoc, smul_assoc c, ← smul_sum, smul_inv₀, smul_smul_smul_comm, hc]
Mathlib/Analysis/Convex/Combination.lean
82
84
theorem Finset.centerMass_eq_of_sum_1 (hw : ∑ i ∈ t, w i = 1) : t.centerMass w z = ∑ i ∈ t, w i • z i := by
simp only [Finset.centerMass, hw, inv_one, one_smul]
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 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 #align interval_integrable.mul_continuous_on IntervalIntegrable.mul_continuousOn theorem continuousOn_mul {f g : ℝ → A} (hf : IntervalIntegrable f μ a b) (hg : ContinuousOn g [[a, b]]) : IntervalIntegrable (fun x => g x * f x) μ a b := by rw [intervalIntegrable_iff] at hf ⊢ exact hf.continuousOn_mul_of_subset hg isCompact_uIcc measurableSet_Ioc Ioc_subset_Icc_self #align interval_integrable.continuous_on_mul IntervalIntegrable.continuousOn_mul @[simp] theorem const_mul {f : ℝ → A} (hf : IntervalIntegrable f μ a b) (c : A) : IntervalIntegrable (fun x => c * f x) μ a b := hf.continuousOn_mul continuousOn_const #align interval_integrable.const_mul IntervalIntegrable.const_mul @[simp] theorem mul_const {f : ℝ → A} (hf : IntervalIntegrable f μ a b) (c : A) : IntervalIntegrable (fun x => f x * c) μ a b := hf.mul_continuousOn continuousOn_const #align interval_integrable.mul_const IntervalIntegrable.mul_const @[simp] theorem div_const {𝕜 : Type*} {f : ℝ → 𝕜} [NormedField 𝕜] (h : IntervalIntegrable f μ a b) (c : 𝕜) : IntervalIntegrable (fun x => f x / c) μ a b := by simpa only [div_eq_mul_inv] using mul_const h c⁻¹ #align interval_integrable.div_const IntervalIntegrable.div_const theorem comp_mul_left (hf : IntervalIntegrable f volume a b) (c : ℝ) : IntervalIntegrable (fun x => f (c * x)) volume (a / c) (b / c) := by rcases eq_or_ne c 0 with (hc | hc); · rw [hc]; simp rw [intervalIntegrable_iff'] at hf ⊢ have A : MeasurableEmbedding fun x => x * c⁻¹ := (Homeomorph.mulRight₀ _ (inv_ne_zero hc)).closedEmbedding.measurableEmbedding rw [← Real.smul_map_volume_mul_right (inv_ne_zero hc), IntegrableOn, Measure.restrict_smul, integrable_smul_measure (by simpa : ENNReal.ofReal |c⁻¹| ≠ 0) ENNReal.ofReal_ne_top, ← IntegrableOn, MeasurableEmbedding.integrableOn_map_iff A] convert hf using 1 · ext; simp only [comp_apply]; congr 1; field_simp · rw [preimage_mul_const_uIcc (inv_ne_zero hc)]; field_simp [hc] #align interval_integrable.comp_mul_left IntervalIntegrable.comp_mul_left -- Porting note (#10756): new lemma theorem comp_mul_left_iff {c : ℝ} (hc : c ≠ 0) : IntervalIntegrable (fun x ↦ f (c * x)) volume (a / c) (b / c) ↔ IntervalIntegrable f volume a b := ⟨fun h ↦ by simpa [hc] using h.comp_mul_left c⁻¹, (comp_mul_left · c)⟩ theorem comp_mul_right (hf : IntervalIntegrable f volume a b) (c : ℝ) : IntervalIntegrable (fun x => f (x * c)) volume (a / c) (b / c) := by simpa only [mul_comm] using comp_mul_left hf c #align interval_integrable.comp_mul_right IntervalIntegrable.comp_mul_right
Mathlib/MeasureTheory/Integral/IntervalIntegral.lean
333
342
theorem comp_add_right (hf : IntervalIntegrable f volume a b) (c : ℝ) : IntervalIntegrable (fun x => f (x + c)) volume (a - c) (b - c) := by
wlog h : a ≤ b generalizing a b · exact IntervalIntegrable.symm (this hf.symm (le_of_not_le h)) rw [intervalIntegrable_iff'] at hf ⊢ have A : MeasurableEmbedding fun x => x + c := (Homeomorph.addRight c).closedEmbedding.measurableEmbedding rw [← map_add_right_eq_self volume c] at hf convert (MeasurableEmbedding.integrableOn_map_iff A).mp hf using 1 rw [preimage_add_const_uIcc]
import Mathlib.Algebra.ContinuedFractions.Computation.Basic import Mathlib.Algebra.ContinuedFractions.Translations #align_import algebra.continued_fractions.computation.translations from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" namespace GeneralizedContinuedFraction open GeneralizedContinuedFraction (of) -- Fix a discrete linear ordered floor field and a value `v`. variable {K : Type*} [LinearOrderedField K] [FloorRing K] {v : K} namespace IntFractPair theorem stream_zero (v : K) : IntFractPair.stream v 0 = some (IntFractPair.of v) := rfl #align generalized_continued_fraction.int_fract_pair.stream_zero GeneralizedContinuedFraction.IntFractPair.stream_zero variable {n : ℕ} theorem stream_eq_none_of_fr_eq_zero {ifp_n : IntFractPair K} (stream_nth_eq : IntFractPair.stream v n = some ifp_n) (nth_fr_eq_zero : ifp_n.fr = 0) : IntFractPair.stream v (n + 1) = none := by cases' ifp_n with _ fr change fr = 0 at nth_fr_eq_zero simp [IntFractPair.stream, stream_nth_eq, nth_fr_eq_zero] #align generalized_continued_fraction.int_fract_pair.stream_eq_none_of_fr_eq_zero GeneralizedContinuedFraction.IntFractPair.stream_eq_none_of_fr_eq_zero theorem succ_nth_stream_eq_none_iff : IntFractPair.stream v (n + 1) = none ↔ IntFractPair.stream v n = none ∨ ∃ ifp, IntFractPair.stream v n = some ifp ∧ ifp.fr = 0 := by rw [IntFractPair.stream] cases IntFractPair.stream v n <;> simp [imp_false] #align generalized_continued_fraction.int_fract_pair.succ_nth_stream_eq_none_iff GeneralizedContinuedFraction.IntFractPair.succ_nth_stream_eq_none_iff
Mathlib/Algebra/ContinuedFractions/Computation/Translations.lean
87
92
theorem succ_nth_stream_eq_some_iff {ifp_succ_n : IntFractPair K} : IntFractPair.stream v (n + 1) = some ifp_succ_n ↔ ∃ ifp_n : IntFractPair K, IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n := by
simp [IntFractPair.stream, ite_eq_iff, Option.bind_eq_some]
import Mathlib.GroupTheory.QuotientGroup import Mathlib.RingTheory.DedekindDomain.Ideal #align_import ring_theory.class_group from "leanprover-community/mathlib"@"565eb991e264d0db702722b4bde52ee5173c9950" variable {R K L : Type*} [CommRing R] variable [Field K] [Field L] [DecidableEq L] variable [Algebra R K] [IsFractionRing R K] variable [Algebra K L] [FiniteDimensional K L] variable [Algebra R L] [IsScalarTower R K L] open scoped nonZeroDivisors open IsLocalization IsFractionRing FractionalIdeal Units section variable (R K) irreducible_def toPrincipalIdeal : Kˣ →* (FractionalIdeal R⁰ K)ˣ := { toFun := fun x => ⟨spanSingleton _ x, spanSingleton _ x⁻¹, by simp only [spanSingleton_one, Units.mul_inv', spanSingleton_mul_spanSingleton], by simp only [spanSingleton_one, Units.inv_mul', spanSingleton_mul_spanSingleton]⟩ map_mul' := fun x y => ext (by simp only [Units.val_mk, Units.val_mul, spanSingleton_mul_spanSingleton]) map_one' := ext (by simp only [spanSingleton_one, Units.val_mk, Units.val_one]) } #align to_principal_ideal toPrincipalIdeal variable {R K} @[simp] theorem coe_toPrincipalIdeal (x : Kˣ) : (toPrincipalIdeal R K x : FractionalIdeal R⁰ K) = spanSingleton _ (x : K) := by simp only [toPrincipalIdeal]; rfl #align coe_to_principal_ideal coe_toPrincipalIdeal @[simp] theorem toPrincipalIdeal_eq_iff {I : (FractionalIdeal R⁰ K)ˣ} {x : Kˣ} : toPrincipalIdeal R K x = I ↔ spanSingleton R⁰ (x : K) = I := by simp only [toPrincipalIdeal]; exact Units.ext_iff #align to_principal_ideal_eq_iff toPrincipalIdeal_eq_iff theorem mem_principal_ideals_iff {I : (FractionalIdeal R⁰ K)ˣ} : I ∈ (toPrincipalIdeal R K).range ↔ ∃ x : K, spanSingleton R⁰ x = I := by simp only [MonoidHom.mem_range, toPrincipalIdeal_eq_iff] constructor <;> rintro ⟨x, hx⟩ · exact ⟨x, hx⟩ · refine ⟨Units.mk0 x ?_, hx⟩ rintro rfl simp [I.ne_zero.symm] at hx #align mem_principal_ideals_iff mem_principal_ideals_iff instance PrincipalIdeals.normal : (toPrincipalIdeal R K).range.Normal := Subgroup.normal_of_comm _ #align principal_ideals.normal PrincipalIdeals.normal end variable (R) variable [IsDomain R] def ClassGroup := (FractionalIdeal R⁰ (FractionRing R))ˣ ⧸ (toPrincipalIdeal R (FractionRing R)).range #align class_group ClassGroup noncomputable instance : CommGroup (ClassGroup R) := QuotientGroup.Quotient.commGroup (toPrincipalIdeal R (FractionRing R)).range noncomputable instance : Inhabited (ClassGroup R) := ⟨1⟩ variable {R} noncomputable def ClassGroup.mk : (FractionalIdeal R⁰ K)ˣ →* ClassGroup R := (QuotientGroup.mk' (toPrincipalIdeal R (FractionRing R)).range).comp (Units.map (FractionalIdeal.canonicalEquiv R⁰ K (FractionRing R))) #align class_group.mk ClassGroup.mk -- Can't be `@[simp]` because it can't figure out the quotient relation. theorem ClassGroup.Quot_mk_eq_mk (I : (FractionalIdeal R⁰ (FractionRing R))ˣ) : Quot.mk _ I = ClassGroup.mk I := by rw [ClassGroup.mk, canonicalEquiv_self, RingEquiv.coe_monoidHom_refl, Units.map_id] -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [MonoidHom.comp_apply] rw [MonoidHom.id_apply, QuotientGroup.mk'_apply] rfl theorem ClassGroup.mk_eq_mk {I J : (FractionalIdeal R⁰ <| FractionRing R)ˣ} : ClassGroup.mk I = ClassGroup.mk J ↔ ∃ x : (FractionRing R)ˣ, I * toPrincipalIdeal R (FractionRing R) x = J := by erw [QuotientGroup.mk'_eq_mk', canonicalEquiv_self, Units.map_id, Set.exists_range_iff] rfl #align class_group.mk_eq_mk ClassGroup.mk_eq_mk theorem ClassGroup.mk_eq_mk_of_coe_ideal {I J : (FractionalIdeal R⁰ <| FractionRing R)ˣ} {I' J' : Ideal R} (hI : (I : FractionalIdeal R⁰ <| FractionRing R) = I') (hJ : (J : FractionalIdeal R⁰ <| FractionRing R) = J') : ClassGroup.mk I = ClassGroup.mk J ↔ ∃ x y : R, x ≠ 0 ∧ y ≠ 0 ∧ Ideal.span {x} * I' = Ideal.span {y} * J' := by rw [ClassGroup.mk_eq_mk] constructor · rintro ⟨x, rfl⟩ rw [Units.val_mul, hI, coe_toPrincipalIdeal, mul_comm, spanSingleton_mul_coeIdeal_eq_coeIdeal] at hJ exact ⟨_, _, sec_fst_ne_zero (R := R) le_rfl x.ne_zero, sec_snd_ne_zero (R := R) le_rfl (x : FractionRing R), hJ⟩ · rintro ⟨x, y, hx, hy, h⟩ have : IsUnit (mk' (FractionRing R) x ⟨y, mem_nonZeroDivisors_of_ne_zero hy⟩) := by simpa only [isUnit_iff_ne_zero, ne_eq, mk'_eq_zero_iff_eq_zero] using hx refine ⟨this.unit, ?_⟩ rw [mul_comm, ← Units.eq_iff, Units.val_mul, coe_toPrincipalIdeal] convert (mk'_mul_coeIdeal_eq_coeIdeal (FractionRing R) <| mem_nonZeroDivisors_of_ne_zero hy).2 h #align class_group.mk_eq_mk_of_coe_ideal ClassGroup.mk_eq_mk_of_coe_ideal theorem ClassGroup.mk_eq_one_of_coe_ideal {I : (FractionalIdeal R⁰ <| FractionRing R)ˣ} {I' : Ideal R} (hI : (I : FractionalIdeal R⁰ <| FractionRing R) = I') : ClassGroup.mk I = 1 ↔ ∃ x : R, x ≠ 0 ∧ I' = Ideal.span {x} := by rw [← _root_.map_one (ClassGroup.mk (R := R) (K := FractionRing R)), ClassGroup.mk_eq_mk_of_coe_ideal hI (?_ : _ = ↑(⊤ : Ideal R))] any_goals rfl constructor · rintro ⟨x, y, hx, hy, h⟩ rw [Ideal.mul_top] at h rcases Ideal.mem_span_singleton_mul.mp ((Ideal.span_singleton_le_iff_mem _).mp h.ge) with ⟨i, _hi, rfl⟩ rw [← Ideal.span_singleton_mul_span_singleton, Ideal.span_singleton_mul_right_inj hx] at h exact ⟨i, right_ne_zero_of_mul hy, h⟩ · rintro ⟨x, hx, rfl⟩ exact ⟨1, x, one_ne_zero, hx, by rw [Ideal.span_singleton_one, Ideal.top_mul, Ideal.mul_top]⟩ #align class_group.mk_eq_one_of_coe_ideal ClassGroup.mk_eq_one_of_coe_ideal variable (K) @[elab_as_elim] theorem ClassGroup.induction {P : ClassGroup R → Prop} (h : ∀ I : (FractionalIdeal R⁰ K)ˣ, P (ClassGroup.mk I)) (x : ClassGroup R) : P x := QuotientGroup.induction_on x fun I => by have : I = (Units.mapEquiv (canonicalEquiv R⁰ K (FractionRing R)).toMulEquiv) (Units.mapEquiv (canonicalEquiv R⁰ (FractionRing R) K).toMulEquiv I) := by simp [← Units.eq_iff] rw [congr_arg (QuotientGroup.mk (s := (toPrincipalIdeal R (FractionRing R)).range)) this] exact h _ #align class_group.induction ClassGroup.induction noncomputable def ClassGroup.equiv : ClassGroup R ≃* (FractionalIdeal R⁰ K)ˣ ⧸ (toPrincipalIdeal R K).range := by haveI : Subgroup.map (Units.mapEquiv (canonicalEquiv R⁰ (FractionRing R) K).toMulEquiv).toMonoidHom (toPrincipalIdeal R (FractionRing R)).range = (toPrincipalIdeal R K).range := by ext I simp only [Subgroup.mem_map, mem_principal_ideals_iff] constructor · rintro ⟨I, ⟨x, hx⟩, rfl⟩ refine ⟨FractionRing.algEquiv R K x, ?_⟩ simp only [RingEquiv.toMulEquiv_eq_coe, MulEquiv.coe_toMonoidHom, coe_mapEquiv, ← hx, RingEquiv.coe_toMulEquiv, canonicalEquiv_spanSingleton] rfl · rintro ⟨x, hx⟩ refine ⟨Units.mapEquiv (canonicalEquiv R⁰ K (FractionRing R)).toMulEquiv I, ⟨(FractionRing.algEquiv R K).symm x, ?_⟩, Units.ext ?_⟩ · simp only [RingEquiv.toMulEquiv_eq_coe, coe_mapEquiv, ← hx, RingEquiv.coe_toMulEquiv, canonicalEquiv_spanSingleton] rfl · simp only [RingEquiv.toMulEquiv_eq_coe, MulEquiv.coe_toMonoidHom, coe_mapEquiv, RingEquiv.coe_toMulEquiv, canonicalEquiv_canonicalEquiv, canonicalEquiv_self, RingEquiv.refl_apply] exact @QuotientGroup.congr (FractionalIdeal R⁰ (FractionRing R))ˣ _ (FractionalIdeal R⁰ K)ˣ _ (toPrincipalIdeal R (FractionRing R)).range (toPrincipalIdeal R K).range _ _ (Units.mapEquiv (FractionalIdeal.canonicalEquiv R⁰ (FractionRing R) K).toMulEquiv) this #align class_group.equiv ClassGroup.equiv @[simp] theorem ClassGroup.equiv_mk (K' : Type*) [Field K'] [Algebra R K'] [IsFractionRing R K'] (I : (FractionalIdeal R⁰ K)ˣ) : ClassGroup.equiv K' (ClassGroup.mk I) = QuotientGroup.mk' _ (Units.mapEquiv (↑(FractionalIdeal.canonicalEquiv R⁰ K K')) I) := by -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [ClassGroup.equiv, ClassGroup.mk, MonoidHom.comp_apply, QuotientGroup.congr_mk'] congr rw [← Units.eq_iff, Units.coe_mapEquiv, Units.coe_mapEquiv, Units.coe_map] exact FractionalIdeal.canonicalEquiv_canonicalEquiv _ _ _ _ _ #align class_group.equiv_mk ClassGroup.equiv_mk @[simp] theorem ClassGroup.mk_canonicalEquiv (K' : Type*) [Field K'] [Algebra R K'] [IsFractionRing R K'] (I : (FractionalIdeal R⁰ K)ˣ) : ClassGroup.mk (Units.map (↑(canonicalEquiv R⁰ K K')) I : (FractionalIdeal R⁰ K')ˣ) = ClassGroup.mk I := by -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [ClassGroup.mk, MonoidHom.comp_apply, ← MonoidHom.comp_apply (Units.map _), ← Units.map_comp, ← RingEquiv.coe_monoidHom_trans, FractionalIdeal.canonicalEquiv_trans_canonicalEquiv] rfl #align class_group.mk_canonical_equiv ClassGroup.mk_canonicalEquiv noncomputable def FractionalIdeal.mk0 [IsDedekindDomain R] : (Ideal R)⁰ →* (FractionalIdeal R⁰ K)ˣ where toFun I := Units.mk0 I (coeIdeal_ne_zero.mpr <| mem_nonZeroDivisors_iff_ne_zero.mp I.2) map_one' := by simp map_mul' x y := by simp #align fractional_ideal.mk0 FractionalIdeal.mk0 @[simp] theorem FractionalIdeal.coe_mk0 [IsDedekindDomain R] (I : (Ideal R)⁰) : (FractionalIdeal.mk0 K I : FractionalIdeal R⁰ K) = I := rfl #align fractional_ideal.coe_mk0 FractionalIdeal.coe_mk0
Mathlib/RingTheory/ClassGroup.lean
245
249
theorem FractionalIdeal.canonicalEquiv_mk0 [IsDedekindDomain R] (K' : Type*) [Field K'] [Algebra R K'] [IsFractionRing R K'] (I : (Ideal R)⁰) : FractionalIdeal.canonicalEquiv R⁰ K K' (FractionalIdeal.mk0 K I) = FractionalIdeal.mk0 K' I := by
simp only [FractionalIdeal.coe_mk0, FractionalIdeal.canonicalEquiv_coeIdeal]
import Mathlib.Algebra.Order.Field.Basic import Mathlib.Combinatorics.SimpleGraph.Basic import Mathlib.Data.Rat.Cast.Order import Mathlib.Order.Partition.Finpartition import Mathlib.Tactic.GCongr import Mathlib.Tactic.NormNum import Mathlib.Tactic.Positivity import Mathlib.Tactic.Ring #align_import combinatorics.simple_graph.density from "leanprover-community/mathlib"@"a4ec43f53b0bd44c697bcc3f5a62edd56f269ef1" open Finset variable {𝕜 ι κ α β : Type*} namespace Rel section Asymmetric variable [LinearOrderedField 𝕜] (r : α → β → Prop) [∀ a, DecidablePred (r a)] {s s₁ s₂ : Finset α} {t t₁ t₂ : Finset β} {a : α} {b : β} {δ : 𝕜} def interedges (s : Finset α) (t : Finset β) : Finset (α × β) := (s ×ˢ t).filter fun e ↦ r e.1 e.2 #align rel.interedges Rel.interedges def edgeDensity (s : Finset α) (t : Finset β) : ℚ := (interedges r s t).card / (s.card * t.card) #align rel.edge_density Rel.edgeDensity variable {r} theorem mem_interedges_iff {x : α × β} : x ∈ interedges r s t ↔ x.1 ∈ s ∧ x.2 ∈ t ∧ r x.1 x.2 := by rw [interedges, mem_filter, Finset.mem_product, and_assoc] #align rel.mem_interedges_iff Rel.mem_interedges_iff theorem mk_mem_interedges_iff : (a, b) ∈ interedges r s t ↔ a ∈ s ∧ b ∈ t ∧ r a b := mem_interedges_iff #align rel.mk_mem_interedges_iff Rel.mk_mem_interedges_iff @[simp] theorem interedges_empty_left (t : Finset β) : interedges r ∅ t = ∅ := by rw [interedges, Finset.empty_product, filter_empty] #align rel.interedges_empty_left Rel.interedges_empty_left theorem interedges_mono (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁) : interedges r s₂ t₂ ⊆ interedges r s₁ t₁ := fun x ↦ by simp_rw [mem_interedges_iff] exact fun h ↦ ⟨hs h.1, ht h.2.1, h.2.2⟩ #align rel.interedges_mono Rel.interedges_mono variable (r) theorem card_interedges_add_card_interedges_compl (s : Finset α) (t : Finset β) : (interedges r s t).card + (interedges (fun x y ↦ ¬r x y) s t).card = s.card * t.card := by classical rw [← card_product, interedges, interedges, ← card_union_of_disjoint, filter_union_filter_neg_eq] exact disjoint_filter.2 fun _ _ ↦ Classical.not_not.2 #align rel.card_interedges_add_card_interedges_compl Rel.card_interedges_add_card_interedges_compl theorem interedges_disjoint_left {s s' : Finset α} (hs : Disjoint s s') (t : Finset β) : Disjoint (interedges r s t) (interedges r s' t) := by rw [Finset.disjoint_left] at hs ⊢ intro _ hx hy rw [mem_interedges_iff] at hx hy exact hs hx.1 hy.1 #align rel.interedges_disjoint_left Rel.interedges_disjoint_left theorem interedges_disjoint_right (s : Finset α) {t t' : Finset β} (ht : Disjoint t t') : Disjoint (interedges r s t) (interedges r s t') := by rw [Finset.disjoint_left] at ht ⊢ intro _ hx hy rw [mem_interedges_iff] at hx hy exact ht hx.2.1 hy.2.1 #align rel.interedges_disjoint_right Rel.interedges_disjoint_right theorem card_interedges_le_mul (s : Finset α) (t : Finset β) : (interedges r s t).card ≤ s.card * t.card := (card_filter_le _ _).trans (card_product _ _).le #align rel.card_interedges_le_mul Rel.card_interedges_le_mul
Mathlib/Combinatorics/SimpleGraph/Density.lean
136
137
theorem edgeDensity_nonneg (s : Finset α) (t : Finset β) : 0 ≤ edgeDensity r s t := by
apply div_nonneg <;> exact mod_cast Nat.zero_le _
import Mathlib.Algebra.ModEq import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.Archimedean import Mathlib.Algebra.Periodic import Mathlib.Data.Int.SuccPred import Mathlib.GroupTheory.QuotientGroup import Mathlib.Order.Circular import Mathlib.Data.List.TFAE import Mathlib.Data.Set.Lattice #align_import algebra.order.to_interval_mod from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec" noncomputable section section LinearOrderedAddCommGroup variable {α : Type*} [LinearOrderedAddCommGroup α] [hα : Archimedean α] {p : α} (hp : 0 < p) {a b c : α} {n : ℤ} def toIcoDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ico hp b a).choose #align to_Ico_div toIcoDiv theorem sub_toIcoDiv_zsmul_mem_Ico (a b : α) : b - toIcoDiv hp a b • p ∈ Set.Ico a (a + p) := (existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.1 #align sub_to_Ico_div_zsmul_mem_Ico sub_toIcoDiv_zsmul_mem_Ico theorem toIcoDiv_eq_of_sub_zsmul_mem_Ico (h : b - n • p ∈ Set.Ico a (a + p)) : toIcoDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.2 _ h).symm #align to_Ico_div_eq_of_sub_zsmul_mem_Ico toIcoDiv_eq_of_sub_zsmul_mem_Ico def toIocDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose #align to_Ioc_div toIocDiv theorem sub_toIocDiv_zsmul_mem_Ioc (a b : α) : b - toIocDiv hp a b • p ∈ Set.Ioc a (a + p) := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.1 #align sub_to_Ioc_div_zsmul_mem_Ioc sub_toIocDiv_zsmul_mem_Ioc theorem toIocDiv_eq_of_sub_zsmul_mem_Ioc (h : b - n • p ∈ Set.Ioc a (a + p)) : toIocDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.2 _ h).symm #align to_Ioc_div_eq_of_sub_zsmul_mem_Ioc toIocDiv_eq_of_sub_zsmul_mem_Ioc def toIcoMod (a b : α) : α := b - toIcoDiv hp a b • p #align to_Ico_mod toIcoMod def toIocMod (a b : α) : α := b - toIocDiv hp a b • p #align to_Ioc_mod toIocMod theorem toIcoMod_mem_Ico (a b : α) : toIcoMod hp a b ∈ Set.Ico a (a + p) := sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_mod_mem_Ico toIcoMod_mem_Ico theorem toIcoMod_mem_Ico' (b : α) : toIcoMod hp 0 b ∈ Set.Ico 0 p := by convert toIcoMod_mem_Ico hp 0 b exact (zero_add p).symm #align to_Ico_mod_mem_Ico' toIcoMod_mem_Ico' theorem toIocMod_mem_Ioc (a b : α) : toIocMod hp a b ∈ Set.Ioc a (a + p) := sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_mod_mem_Ioc toIocMod_mem_Ioc theorem left_le_toIcoMod (a b : α) : a ≤ toIcoMod hp a b := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).1 #align left_le_to_Ico_mod left_le_toIcoMod theorem left_lt_toIocMod (a b : α) : a < toIocMod hp a b := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).1 #align left_lt_to_Ioc_mod left_lt_toIocMod theorem toIcoMod_lt_right (a b : α) : toIcoMod hp a b < a + p := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).2 #align to_Ico_mod_lt_right toIcoMod_lt_right theorem toIocMod_le_right (a b : α) : toIocMod hp a b ≤ a + p := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).2 #align to_Ioc_mod_le_right toIocMod_le_right @[simp] theorem self_sub_toIcoDiv_zsmul (a b : α) : b - toIcoDiv hp a b • p = toIcoMod hp a b := rfl #align self_sub_to_Ico_div_zsmul self_sub_toIcoDiv_zsmul @[simp] theorem self_sub_toIocDiv_zsmul (a b : α) : b - toIocDiv hp a b • p = toIocMod hp a b := rfl #align self_sub_to_Ioc_div_zsmul self_sub_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_self (a b : α) : toIcoDiv hp a b • p - b = -toIcoMod hp a b := by rw [toIcoMod, neg_sub] #align to_Ico_div_zsmul_sub_self toIcoDiv_zsmul_sub_self @[simp] theorem toIocDiv_zsmul_sub_self (a b : α) : toIocDiv hp a b • p - b = -toIocMod hp a b := by rw [toIocMod, neg_sub] #align to_Ioc_div_zsmul_sub_self toIocDiv_zsmul_sub_self @[simp] theorem toIcoMod_sub_self (a b : α) : toIcoMod hp a b - b = -toIcoDiv hp a b • p := by rw [toIcoMod, sub_sub_cancel_left, neg_smul] #align to_Ico_mod_sub_self toIcoMod_sub_self @[simp] theorem toIocMod_sub_self (a b : α) : toIocMod hp a b - b = -toIocDiv hp a b • p := by rw [toIocMod, sub_sub_cancel_left, neg_smul] #align to_Ioc_mod_sub_self toIocMod_sub_self @[simp] theorem self_sub_toIcoMod (a b : α) : b - toIcoMod hp a b = toIcoDiv hp a b • p := by rw [toIcoMod, sub_sub_cancel] #align self_sub_to_Ico_mod self_sub_toIcoMod @[simp] theorem self_sub_toIocMod (a b : α) : b - toIocMod hp a b = toIocDiv hp a b • p := by rw [toIocMod, sub_sub_cancel] #align self_sub_to_Ioc_mod self_sub_toIocMod @[simp] theorem toIcoMod_add_toIcoDiv_zsmul (a b : α) : toIcoMod hp a b + toIcoDiv hp a b • p = b := by rw [toIcoMod, sub_add_cancel] #align to_Ico_mod_add_to_Ico_div_zsmul toIcoMod_add_toIcoDiv_zsmul @[simp] theorem toIocMod_add_toIocDiv_zsmul (a b : α) : toIocMod hp a b + toIocDiv hp a b • p = b := by rw [toIocMod, sub_add_cancel] #align to_Ioc_mod_add_to_Ioc_div_zsmul toIocMod_add_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_toIcoMod (a b : α) : toIcoDiv hp a b • p + toIcoMod hp a b = b := by rw [add_comm, toIcoMod_add_toIcoDiv_zsmul] #align to_Ico_div_zsmul_sub_to_Ico_mod toIcoDiv_zsmul_sub_toIcoMod @[simp] theorem toIocDiv_zsmul_sub_toIocMod (a b : α) : toIocDiv hp a b • p + toIocMod hp a b = b := by rw [add_comm, toIocMod_add_toIocDiv_zsmul] #align to_Ioc_div_zsmul_sub_to_Ioc_mod toIocDiv_zsmul_sub_toIocMod theorem toIcoMod_eq_iff : toIcoMod hp a b = c ↔ c ∈ Set.Ico a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by refine ⟨fun h => ⟨h ▸ toIcoMod_mem_Ico hp a b, toIcoDiv hp a b, h ▸ (toIcoMod_add_toIcoDiv_zsmul _ _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIcoDiv_eq_of_sub_zsmul_mem_Ico hp hc, toIcoMod] #align to_Ico_mod_eq_iff toIcoMod_eq_iff theorem toIocMod_eq_iff : toIocMod hp a b = c ↔ c ∈ Set.Ioc a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by refine ⟨fun h => ⟨h ▸ toIocMod_mem_Ioc hp a b, toIocDiv hp a b, h ▸ (toIocMod_add_toIocDiv_zsmul hp _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIocDiv_eq_of_sub_zsmul_mem_Ioc hp hc, toIocMod] #align to_Ioc_mod_eq_iff toIocMod_eq_iff @[simp] theorem toIcoDiv_apply_left (a : α) : toIcoDiv hp a a = 0 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_left toIcoDiv_apply_left @[simp] theorem toIocDiv_apply_left (a : α) : toIocDiv hp a a = -1 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_left toIocDiv_apply_left @[simp] theorem toIcoMod_apply_left (a : α) : toIcoMod hp a a = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ico_mod_apply_left toIcoMod_apply_left @[simp] theorem toIocMod_apply_left (a : α) : toIocMod hp a a = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, -1, by simp⟩ #align to_Ioc_mod_apply_left toIocMod_apply_left theorem toIcoDiv_apply_right (a : α) : toIcoDiv hp a (a + p) = 1 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_right toIcoDiv_apply_right theorem toIocDiv_apply_right (a : α) : toIocDiv hp a (a + p) = 0 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_right toIocDiv_apply_right theorem toIcoMod_apply_right (a : α) : toIcoMod hp a (a + p) = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 1, by simp⟩ #align to_Ico_mod_apply_right toIcoMod_apply_right theorem toIocMod_apply_right (a : α) : toIocMod hp a (a + p) = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ioc_mod_apply_right toIocMod_apply_right @[simp] theorem toIcoDiv_add_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b + m • p) = toIcoDiv hp a b + m := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul toIcoDiv_add_zsmul @[simp] theorem toIcoDiv_add_zsmul' (a b : α) (m : ℤ) : toIcoDiv hp (a + m • p) b = toIcoDiv hp a b - m := by refine toIcoDiv_eq_of_sub_zsmul_mem_Ico _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul' toIcoDiv_add_zsmul' @[simp] theorem toIocDiv_add_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b + m • p) = toIocDiv hp a b + m := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul toIocDiv_add_zsmul @[simp] theorem toIocDiv_add_zsmul' (a b : α) (m : ℤ) : toIocDiv hp (a + m • p) b = toIocDiv hp a b - m := by refine toIocDiv_eq_of_sub_zsmul_mem_Ioc _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul' toIocDiv_add_zsmul' @[simp] theorem toIcoDiv_zsmul_add (a b : α) (m : ℤ) : toIcoDiv hp a (m • p + b) = m + toIcoDiv hp a b := by rw [add_comm, toIcoDiv_add_zsmul, add_comm] #align to_Ico_div_zsmul_add toIcoDiv_zsmul_add @[simp] theorem toIocDiv_zsmul_add (a b : α) (m : ℤ) : toIocDiv hp a (m • p + b) = m + toIocDiv hp a b := by rw [add_comm, toIocDiv_add_zsmul, add_comm] #align to_Ioc_div_zsmul_add toIocDiv_zsmul_add @[simp] theorem toIcoDiv_sub_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b - m • p) = toIcoDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul, sub_eq_add_neg] #align to_Ico_div_sub_zsmul toIcoDiv_sub_zsmul @[simp]
Mathlib/Algebra/Order/ToIntervalMod.lean
282
284
theorem toIcoDiv_sub_zsmul' (a b : α) (m : ℤ) : toIcoDiv hp (a - m • p) b = toIcoDiv hp a b + m := by
rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul', sub_neg_eq_add]
import Mathlib.CategoryTheory.Subobject.Limits #align_import algebra.homology.image_to_kernel from "leanprover-community/mathlib"@"618ea3d5c99240cd7000d8376924906a148bf9ff" universe v u w open CategoryTheory CategoryTheory.Limits variable {ι : Type*} variable {V : Type u} [Category.{v} V] [HasZeroMorphisms V] open scoped Classical noncomputable section section variable {A B C : V} (f : A ⟶ B) [HasImage f] (g : B ⟶ C) [HasKernel g] theorem image_le_kernel (w : f ≫ g = 0) : imageSubobject f ≤ kernelSubobject g := imageSubobject_le_mk _ _ (kernel.lift _ _ w) (by simp) #align image_le_kernel image_le_kernel def imageToKernel (w : f ≫ g = 0) : (imageSubobject f : V) ⟶ (kernelSubobject g : V) := Subobject.ofLE _ _ (image_le_kernel _ _ w) #align image_to_kernel imageToKernel instance (w : f ≫ g = 0) : Mono (imageToKernel f g w) := by dsimp only [imageToKernel] infer_instance @[simp] theorem subobject_ofLE_as_imageToKernel (w : f ≫ g = 0) (h) : Subobject.ofLE (imageSubobject f) (kernelSubobject g) h = imageToKernel f g w := rfl #align subobject_of_le_as_image_to_kernel subobject_ofLE_as_imageToKernel attribute [local instance] ConcreteCategory.instFunLike -- Porting note: removed elementwise attribute which does not seem to be helpful here -- a more suitable lemma is added below @[reassoc (attr := simp)] theorem imageToKernel_arrow (w : f ≫ g = 0) : imageToKernel f g w ≫ (kernelSubobject g).arrow = (imageSubobject f).arrow := by simp [imageToKernel] #align image_to_kernel_arrow imageToKernel_arrow @[simp] lemma imageToKernel_arrow_apply [ConcreteCategory V] (w : f ≫ g = 0) (x : (forget V).obj (Subobject.underlying.obj (imageSubobject f))) : (kernelSubobject g).arrow (imageToKernel f g w x) = (imageSubobject f).arrow x := by rw [← comp_apply, imageToKernel_arrow] -- This is less useful as a `simp` lemma than it initially appears, -- as it "loses" the information the morphism factors through the image. theorem factorThruImageSubobject_comp_imageToKernel (w : f ≫ g = 0) : factorThruImageSubobject f ≫ imageToKernel f g w = factorThruKernelSubobject g f w := by ext simp #align factor_thru_image_subobject_comp_image_to_kernel factorThruImageSubobject_comp_imageToKernel end section variable {A B C : V} (f : A ⟶ B) (g : B ⟶ C) @[simp] theorem imageToKernel_zero_left [HasKernels V] [HasZeroObject V] {w} : imageToKernel (0 : A ⟶ B) g w = 0 := by ext simp #align image_to_kernel_zero_left imageToKernel_zero_left theorem imageToKernel_zero_right [HasImages V] {w} : imageToKernel f (0 : B ⟶ C) w = (imageSubobject f).arrow ≫ inv (kernelSubobject (0 : B ⟶ C)).arrow := by ext simp #align image_to_kernel_zero_right imageToKernel_zero_right section variable [HasKernels V] [HasImages V] theorem imageToKernel_comp_right {D : V} (h : C ⟶ D) (w : f ≫ g = 0) : imageToKernel f (g ≫ h) (by simp [reassoc_of% w]) = imageToKernel f g w ≫ Subobject.ofLE _ _ (kernelSubobject_comp_le g h) := by ext simp #align image_to_kernel_comp_right imageToKernel_comp_right theorem imageToKernel_comp_left {Z : V} (h : Z ⟶ A) (w : f ≫ g = 0) : imageToKernel (h ≫ f) g (by simp [w]) = Subobject.ofLE _ _ (imageSubobject_comp_le h f) ≫ imageToKernel f g w := by ext simp #align image_to_kernel_comp_left imageToKernel_comp_left @[simp] theorem imageToKernel_comp_mono {D : V} (h : C ⟶ D) [Mono h] (w) : imageToKernel f (g ≫ h) w = imageToKernel f g ((cancel_mono h).mp (by simpa using w : (f ≫ g) ≫ h = 0 ≫ h)) ≫ (Subobject.isoOfEq _ _ (kernelSubobject_comp_mono g h)).inv := by ext simp #align image_to_kernel_comp_mono imageToKernel_comp_mono @[simp] theorem imageToKernel_epi_comp {Z : V} (h : Z ⟶ A) [Epi h] (w) : imageToKernel (h ≫ f) g w = Subobject.ofLE _ _ (imageSubobject_comp_le h f) ≫ imageToKernel f g ((cancel_epi h).mp (by simpa using w : h ≫ f ≫ g = h ≫ 0)) := by ext simp #align image_to_kernel_epi_comp imageToKernel_epi_comp end @[simp] theorem imageToKernel_comp_hom_inv_comp [HasEqualizers V] [HasImages V] {Z : V} {i : B ≅ Z} (w) : imageToKernel (f ≫ i.hom) (i.inv ≫ g) w = (imageSubobjectCompIso _ _).hom ≫ imageToKernel f g (by simpa using w) ≫ (kernelSubobjectIsoComp i.inv g).inv := by ext simp #align image_to_kernel_comp_hom_inv_comp imageToKernel_comp_hom_inv_comp open ZeroObject instance imageToKernel_epi_of_zero_of_mono [HasKernels V] [HasZeroObject V] [Mono g] : Epi (imageToKernel (0 : A ⟶ B) g (by simp)) := epi_of_target_iso_zero _ (kernelSubobjectIso g ≪≫ kernel.ofMono g) #align image_to_kernel_epi_of_zero_of_mono imageToKernel_epi_of_zero_of_mono instance imageToKernel_epi_of_epi_of_zero [HasImages V] [Epi f] : Epi (imageToKernel f (0 : B ⟶ C) (by simp)) := by simp only [imageToKernel_zero_right] haveI := epi_image_of_epi f rw [← imageSubobject_arrow] exact @epi_comp _ _ _ _ _ _ (epi_comp _ _) _ _ #align image_to_kernel_epi_of_epi_of_zero imageToKernel_epi_of_epi_of_zero end section variable {A B C : V} (f : A ⟶ B) [HasImage f] (g : B ⟶ C) [HasKernel g] def homology' {A B C : V} (f : A ⟶ B) [HasImage f] (g : B ⟶ C) [HasKernel g] (w : f ≫ g = 0) [HasCokernel (imageToKernel f g w)] : V := cokernel (imageToKernel f g w) #align homology homology' section variable (w : f ≫ g = 0) [HasCokernel (imageToKernel f g w)] def homology'.π : (kernelSubobject g : V) ⟶ homology' f g w := cokernel.π _ #align homology.π homology'.π @[simp] theorem homology'.condition : imageToKernel f g w ≫ homology'.π f g w = 0 := cokernel.condition _ #align homology.condition homology'.condition def homology'.desc {D : V} (k : (kernelSubobject g : V) ⟶ D) (p : imageToKernel f g w ≫ k = 0) : homology' f g w ⟶ D := cokernel.desc _ k p #align homology.desc homology'.desc -- Porting note: removed elementwise attribute which does not seem to be helpful here @[reassoc (attr := simp)] theorem homology'.π_desc {D : V} (k : (kernelSubobject g : V) ⟶ D) (p : imageToKernel f g w ≫ k = 0) : homology'.π f g w ≫ homology'.desc f g w k p = k := by simp [homology'.π, homology'.desc] #align homology.π_desc homology'.π_desc @[ext] theorem homology'.ext {D : V} {k k' : homology' f g w ⟶ D} (p : homology'.π f g w ≫ k = homology'.π f g w ≫ k') : k = k' := coequalizer.hom_ext p #align homology.ext homology'.ext def homology'OfZeroRight [HasCokernel (imageToKernel f (0 : B ⟶ C) comp_zero)] [HasCokernel f] [HasCokernel (image.ι f)] [Epi (factorThruImage f)] : homology' f (0 : B ⟶ C) comp_zero ≅ cokernel f := (cokernel.mapIso _ _ (imageSubobjectIso _) ((kernelSubobjectIso 0).trans kernelZeroIsoSource) (by simp)).trans (cokernelImageι _) #align homology_of_zero_right homology'OfZeroRight def homology'OfZeroLeft [HasZeroObject V] [HasKernels V] [HasImage (0 : A ⟶ B)] [HasCokernel (imageToKernel (0 : A ⟶ B) g zero_comp)] : homology' (0 : A ⟶ B) g zero_comp ≅ kernel g := ((cokernelIsoOfEq <| imageToKernel_zero_left _).trans cokernelZeroIsoTarget).trans (kernelSubobjectIso _) #align homology_of_zero_left homology'OfZeroLeft @[simps] def homology'ZeroZero [HasZeroObject V] [HasImage (0 : A ⟶ B)] [HasCokernel (imageToKernel (0 : A ⟶ B) (0 : B ⟶ C) zero_comp)] : homology' (0 : A ⟶ B) (0 : B ⟶ C) zero_comp ≅ B where hom := homology'.desc (0 : A ⟶ B) (0 : B ⟶ C) zero_comp (kernelSubobject 0).arrow (by simp) inv := inv (kernelSubobject 0).arrow ≫ homology'.π _ _ _ #align homology_zero_zero homology'ZeroZero end section variable {f g} (w : f ≫ g = 0) {A' B' C' : V} {f' : A' ⟶ B'} [HasImage f'] {g' : B' ⟶ C'} [HasKernel g'] (w' : f' ≫ g' = 0) (α : Arrow.mk f ⟶ Arrow.mk f') [HasImageMap α] (β : Arrow.mk g ⟶ Arrow.mk g') {A₁ B₁ C₁ : V} {f₁ : A₁ ⟶ B₁} [HasImage f₁] {g₁ : B₁ ⟶ C₁} [HasKernel g₁] (w₁ : f₁ ≫ g₁ = 0) {A₂ B₂ C₂ : V} {f₂ : A₂ ⟶ B₂} [HasImage f₂] {g₂ : B₂ ⟶ C₂} [HasKernel g₂] (w₂ : f₂ ≫ g₂ = 0) {A₃ B₃ C₃ : V} {f₃ : A₃ ⟶ B₃} [HasImage f₃] {g₃ : B₃ ⟶ C₃} [HasKernel g₃] (w₃ : f₃ ≫ g₃ = 0) (α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂) [HasImageMap α₁] (β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂) (α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃) [HasImageMap α₂] (β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃) @[reassoc] theorem imageSubobjectMap_comp_imageToKernel (p : α.right = β.left) : imageToKernel f g w ≫ kernelSubobjectMap β = imageSubobjectMap α ≫ imageToKernel f' g' w' := by ext simp [p] #align image_subobject_map_comp_image_to_kernel imageSubobjectMap_comp_imageToKernel variable [HasCokernel (imageToKernel f g w)] [HasCokernel (imageToKernel f' g' w')] variable [HasCokernel (imageToKernel f₁ g₁ w₁)] variable [HasCokernel (imageToKernel f₂ g₂ w₂)] variable [HasCokernel (imageToKernel f₃ g₃ w₃)] def homology'.map (p : α.right = β.left) : homology' f g w ⟶ homology' f' g' w' := cokernel.desc _ (kernelSubobjectMap β ≫ cokernel.π _) <| by rw [imageSubobjectMap_comp_imageToKernel_assoc w w' α β p] simp only [cokernel.condition, comp_zero] #align homology.map homology'.map -- Porting note: removed elementwise attribute which does not seem to be helpful here, -- the correct lemma is stated below @[reassoc (attr := simp)] theorem homology'.π_map (p : α.right = β.left) : homology'.π f g w ≫ homology'.map w w' α β p = kernelSubobjectMap β ≫ homology'.π f' g' w' := by simp only [homology'.π, homology'.map, cokernel.π_desc] #align homology.π_map homology'.π_map section attribute [local instance] ConcreteCategory.instFunLike @[simp] lemma homology'.π_map_apply [ConcreteCategory.{w} V] (p : α.right = β.left) (x : (forget V).obj (Subobject.underlying.obj (kernelSubobject g))) : homology'.map w w' α β p (homology'.π f g w x) = homology'.π f' g' w' (kernelSubobjectMap β x) := by simp only [← comp_apply, homology'.π_map w w' α β p] end @[reassoc (attr := simp), elementwise (attr := simp)] theorem homology'.map_desc (p : α.right = β.left) {D : V} (k : (kernelSubobject g' : V) ⟶ D) (z : imageToKernel f' g' w' ≫ k = 0) : homology'.map w w' α β p ≫ homology'.desc f' g' w' k z = homology'.desc f g w (kernelSubobjectMap β ≫ k) (by simp only [imageSubobjectMap_comp_imageToKernel_assoc w w' α β p, z, comp_zero]) := by ext simp only [homology'.π_desc, homology'.π_map_assoc] #align homology.map_desc homology'.map_desc @[simp] theorem homology'.map_id : homology'.map w w (𝟙 _) (𝟙 _) rfl = 𝟙 _ := by ext simp only [homology'.π_map, kernelSubobjectMap_id, Category.id_comp, Category.comp_id] #align homology.map_id homology'.map_id theorem homology'.comp_right_eq_comp_left {V : Type*} [Category V] {A₁ B₁ C₁ A₂ B₂ C₂ A₃ B₃ C₃ : V} {f₁ : A₁ ⟶ B₁} {g₁ : B₁ ⟶ C₁} {f₂ : A₂ ⟶ B₂} {g₂ : B₂ ⟶ C₂} {f₃ : A₃ ⟶ B₃} {g₃ : B₃ ⟶ C₃} {α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂} {β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂} {α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃} {β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃} (p₁ : α₁.right = β₁.left) (p₂ : α₂.right = β₂.left) : (α₁ ≫ α₂).right = (β₁ ≫ β₂).left := by simp only [Arrow.comp_left, Arrow.comp_right, p₁, p₂] #align homology.comp_right_eq_comp_left homology'.comp_right_eq_comp_left @[reassoc] theorem homology'.map_comp (p₁ : α₁.right = β₁.left) (p₂ : α₂.right = β₂.left) : homology'.map w₁ w₂ α₁ β₁ p₁ ≫ homology'.map w₂ w₃ α₂ β₂ p₂ = homology'.map w₁ w₃ (α₁ ≫ α₂) (β₁ ≫ β₂) (homology'.comp_right_eq_comp_left p₁ p₂) := by ext simp only [kernelSubobjectMap_comp, homology'.π_map_assoc, homology'.π_map, Category.assoc] #align homology.map_comp homology'.map_comp def homology'.mapIso (α : Arrow.mk f₁ ≅ Arrow.mk f₂) (β : Arrow.mk g₁ ≅ Arrow.mk g₂) (p : α.hom.right = β.hom.left) : homology' f₁ g₁ w₁ ≅ homology' f₂ g₂ w₂ where hom := homology'.map w₁ w₂ α.hom β.hom p inv := homology'.map w₂ w₁ α.inv β.inv (by rw [← cancel_mono α.hom.right, ← Comma.comp_right, α.inv_hom_id, Comma.id_right, p, ← Comma.comp_left, β.inv_hom_id, Comma.id_left] rfl) hom_inv_id := by rw [homology'.map_comp, ← homology'.map_id] congr <;> simp only [Iso.hom_inv_id] inv_hom_id := by rw [homology'.map_comp, ← homology'.map_id] congr <;> simp only [Iso.inv_hom_id] #align homology.map_iso homology'.mapIso end end section variable {A B C : V} {f : A ⟶ B} {g : B ⟶ C} (w : f ≫ g = 0) {f' : A ⟶ B} {g' : B ⟶ C} (w' : f' ≫ g' = 0) [HasKernels V] [HasCokernels V] [HasImages V] [HasImageMaps V] -- Porting note: removed the private auxiliary tactic which becomes unnecessary -- --private unsafe def aux_tac : tactic Unit := -- sorry @[simps] def homology'.congr (pf : f = f') (pg : g = g') : homology' f g w ≅ homology' f' g' w' where hom := homology'.map w w' ⟨𝟙 _, 𝟙 _, by aesop_cat⟩ ⟨𝟙 _, 𝟙 _, by aesop_cat⟩ rfl inv := homology'.map w' w ⟨𝟙 _, 𝟙 _, by aesop_cat⟩ ⟨𝟙 _, 𝟙 _, by aesop_cat⟩ rfl hom_inv_id := by obtain rfl := pf obtain rfl := pg rw [homology'.map_comp, ← homology'.map_id] congr <;> aesop_cat inv_hom_id := by obtain rfl := pf obtain rfl := pg rw [homology'.map_comp, ← homology'.map_id] congr <;> aesop_cat #align homology.congr homology'.congr end section imageToKernel' variable {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (w : f ≫ g = 0) [HasKernels V] [HasImages V] def imageToKernel' (w : f ≫ g = 0) : image f ⟶ kernel g := kernel.lift g (image.ι f) <| by ext simpa using w #align image_to_kernel' imageToKernel' @[simp] theorem imageSubobjectIso_imageToKernel' (w : f ≫ g = 0) : (imageSubobjectIso f).hom ≫ imageToKernel' f g w = imageToKernel f g w ≫ (kernelSubobjectIso g).hom := by ext simp [imageToKernel'] #align image_subobject_iso_image_to_kernel' imageSubobjectIso_imageToKernel' @[simp]
Mathlib/Algebra/Homology/ImageToKernel.lean
431
435
theorem imageToKernel'_kernelSubobjectIso (w : f ≫ g = 0) : imageToKernel' f g w ≫ (kernelSubobjectIso g).inv = (imageSubobjectIso f).inv ≫ imageToKernel f g w := by
ext simp [imageToKernel']
import Mathlib.CategoryTheory.Subobject.Limits #align_import algebra.homology.image_to_kernel from "leanprover-community/mathlib"@"618ea3d5c99240cd7000d8376924906a148bf9ff" universe v u w open CategoryTheory CategoryTheory.Limits variable {ι : Type*} variable {V : Type u} [Category.{v} V] [HasZeroMorphisms V] open scoped Classical noncomputable section section variable {A B C : V} (f : A ⟶ B) [HasImage f] (g : B ⟶ C) [HasKernel g] theorem image_le_kernel (w : f ≫ g = 0) : imageSubobject f ≤ kernelSubobject g := imageSubobject_le_mk _ _ (kernel.lift _ _ w) (by simp) #align image_le_kernel image_le_kernel def imageToKernel (w : f ≫ g = 0) : (imageSubobject f : V) ⟶ (kernelSubobject g : V) := Subobject.ofLE _ _ (image_le_kernel _ _ w) #align image_to_kernel imageToKernel instance (w : f ≫ g = 0) : Mono (imageToKernel f g w) := by dsimp only [imageToKernel] infer_instance @[simp] theorem subobject_ofLE_as_imageToKernel (w : f ≫ g = 0) (h) : Subobject.ofLE (imageSubobject f) (kernelSubobject g) h = imageToKernel f g w := rfl #align subobject_of_le_as_image_to_kernel subobject_ofLE_as_imageToKernel attribute [local instance] ConcreteCategory.instFunLike -- Porting note: removed elementwise attribute which does not seem to be helpful here -- a more suitable lemma is added below @[reassoc (attr := simp)] theorem imageToKernel_arrow (w : f ≫ g = 0) : imageToKernel f g w ≫ (kernelSubobject g).arrow = (imageSubobject f).arrow := by simp [imageToKernel] #align image_to_kernel_arrow imageToKernel_arrow @[simp] lemma imageToKernel_arrow_apply [ConcreteCategory V] (w : f ≫ g = 0) (x : (forget V).obj (Subobject.underlying.obj (imageSubobject f))) : (kernelSubobject g).arrow (imageToKernel f g w x) = (imageSubobject f).arrow x := by rw [← comp_apply, imageToKernel_arrow] -- This is less useful as a `simp` lemma than it initially appears, -- as it "loses" the information the morphism factors through the image. theorem factorThruImageSubobject_comp_imageToKernel (w : f ≫ g = 0) : factorThruImageSubobject f ≫ imageToKernel f g w = factorThruKernelSubobject g f w := by ext simp #align factor_thru_image_subobject_comp_image_to_kernel factorThruImageSubobject_comp_imageToKernel end section variable {A B C : V} (f : A ⟶ B) (g : B ⟶ C) @[simp] theorem imageToKernel_zero_left [HasKernels V] [HasZeroObject V] {w} : imageToKernel (0 : A ⟶ B) g w = 0 := by ext simp #align image_to_kernel_zero_left imageToKernel_zero_left theorem imageToKernel_zero_right [HasImages V] {w} : imageToKernel f (0 : B ⟶ C) w = (imageSubobject f).arrow ≫ inv (kernelSubobject (0 : B ⟶ C)).arrow := by ext simp #align image_to_kernel_zero_right imageToKernel_zero_right section variable [HasKernels V] [HasImages V] theorem imageToKernel_comp_right {D : V} (h : C ⟶ D) (w : f ≫ g = 0) : imageToKernel f (g ≫ h) (by simp [reassoc_of% w]) = imageToKernel f g w ≫ Subobject.ofLE _ _ (kernelSubobject_comp_le g h) := by ext simp #align image_to_kernel_comp_right imageToKernel_comp_right theorem imageToKernel_comp_left {Z : V} (h : Z ⟶ A) (w : f ≫ g = 0) : imageToKernel (h ≫ f) g (by simp [w]) = Subobject.ofLE _ _ (imageSubobject_comp_le h f) ≫ imageToKernel f g w := by ext simp #align image_to_kernel_comp_left imageToKernel_comp_left @[simp] theorem imageToKernel_comp_mono {D : V} (h : C ⟶ D) [Mono h] (w) : imageToKernel f (g ≫ h) w = imageToKernel f g ((cancel_mono h).mp (by simpa using w : (f ≫ g) ≫ h = 0 ≫ h)) ≫ (Subobject.isoOfEq _ _ (kernelSubobject_comp_mono g h)).inv := by ext simp #align image_to_kernel_comp_mono imageToKernel_comp_mono @[simp] theorem imageToKernel_epi_comp {Z : V} (h : Z ⟶ A) [Epi h] (w) : imageToKernel (h ≫ f) g w = Subobject.ofLE _ _ (imageSubobject_comp_le h f) ≫ imageToKernel f g ((cancel_epi h).mp (by simpa using w : h ≫ f ≫ g = h ≫ 0)) := by ext simp #align image_to_kernel_epi_comp imageToKernel_epi_comp end @[simp] theorem imageToKernel_comp_hom_inv_comp [HasEqualizers V] [HasImages V] {Z : V} {i : B ≅ Z} (w) : imageToKernel (f ≫ i.hom) (i.inv ≫ g) w = (imageSubobjectCompIso _ _).hom ≫ imageToKernel f g (by simpa using w) ≫ (kernelSubobjectIsoComp i.inv g).inv := by ext simp #align image_to_kernel_comp_hom_inv_comp imageToKernel_comp_hom_inv_comp open ZeroObject instance imageToKernel_epi_of_zero_of_mono [HasKernels V] [HasZeroObject V] [Mono g] : Epi (imageToKernel (0 : A ⟶ B) g (by simp)) := epi_of_target_iso_zero _ (kernelSubobjectIso g ≪≫ kernel.ofMono g) #align image_to_kernel_epi_of_zero_of_mono imageToKernel_epi_of_zero_of_mono instance imageToKernel_epi_of_epi_of_zero [HasImages V] [Epi f] : Epi (imageToKernel f (0 : B ⟶ C) (by simp)) := by simp only [imageToKernel_zero_right] haveI := epi_image_of_epi f rw [← imageSubobject_arrow] exact @epi_comp _ _ _ _ _ _ (epi_comp _ _) _ _ #align image_to_kernel_epi_of_epi_of_zero imageToKernel_epi_of_epi_of_zero end section variable {A B C : V} (f : A ⟶ B) [HasImage f] (g : B ⟶ C) [HasKernel g] def homology' {A B C : V} (f : A ⟶ B) [HasImage f] (g : B ⟶ C) [HasKernel g] (w : f ≫ g = 0) [HasCokernel (imageToKernel f g w)] : V := cokernel (imageToKernel f g w) #align homology homology' section variable (w : f ≫ g = 0) [HasCokernel (imageToKernel f g w)] def homology'.π : (kernelSubobject g : V) ⟶ homology' f g w := cokernel.π _ #align homology.π homology'.π @[simp] theorem homology'.condition : imageToKernel f g w ≫ homology'.π f g w = 0 := cokernel.condition _ #align homology.condition homology'.condition def homology'.desc {D : V} (k : (kernelSubobject g : V) ⟶ D) (p : imageToKernel f g w ≫ k = 0) : homology' f g w ⟶ D := cokernel.desc _ k p #align homology.desc homology'.desc -- Porting note: removed elementwise attribute which does not seem to be helpful here @[reassoc (attr := simp)] theorem homology'.π_desc {D : V} (k : (kernelSubobject g : V) ⟶ D) (p : imageToKernel f g w ≫ k = 0) : homology'.π f g w ≫ homology'.desc f g w k p = k := by simp [homology'.π, homology'.desc] #align homology.π_desc homology'.π_desc @[ext] theorem homology'.ext {D : V} {k k' : homology' f g w ⟶ D} (p : homology'.π f g w ≫ k = homology'.π f g w ≫ k') : k = k' := coequalizer.hom_ext p #align homology.ext homology'.ext def homology'OfZeroRight [HasCokernel (imageToKernel f (0 : B ⟶ C) comp_zero)] [HasCokernel f] [HasCokernel (image.ι f)] [Epi (factorThruImage f)] : homology' f (0 : B ⟶ C) comp_zero ≅ cokernel f := (cokernel.mapIso _ _ (imageSubobjectIso _) ((kernelSubobjectIso 0).trans kernelZeroIsoSource) (by simp)).trans (cokernelImageι _) #align homology_of_zero_right homology'OfZeroRight def homology'OfZeroLeft [HasZeroObject V] [HasKernels V] [HasImage (0 : A ⟶ B)] [HasCokernel (imageToKernel (0 : A ⟶ B) g zero_comp)] : homology' (0 : A ⟶ B) g zero_comp ≅ kernel g := ((cokernelIsoOfEq <| imageToKernel_zero_left _).trans cokernelZeroIsoTarget).trans (kernelSubobjectIso _) #align homology_of_zero_left homology'OfZeroLeft @[simps] def homology'ZeroZero [HasZeroObject V] [HasImage (0 : A ⟶ B)] [HasCokernel (imageToKernel (0 : A ⟶ B) (0 : B ⟶ C) zero_comp)] : homology' (0 : A ⟶ B) (0 : B ⟶ C) zero_comp ≅ B where hom := homology'.desc (0 : A ⟶ B) (0 : B ⟶ C) zero_comp (kernelSubobject 0).arrow (by simp) inv := inv (kernelSubobject 0).arrow ≫ homology'.π _ _ _ #align homology_zero_zero homology'ZeroZero end section variable {f g} (w : f ≫ g = 0) {A' B' C' : V} {f' : A' ⟶ B'} [HasImage f'] {g' : B' ⟶ C'} [HasKernel g'] (w' : f' ≫ g' = 0) (α : Arrow.mk f ⟶ Arrow.mk f') [HasImageMap α] (β : Arrow.mk g ⟶ Arrow.mk g') {A₁ B₁ C₁ : V} {f₁ : A₁ ⟶ B₁} [HasImage f₁] {g₁ : B₁ ⟶ C₁} [HasKernel g₁] (w₁ : f₁ ≫ g₁ = 0) {A₂ B₂ C₂ : V} {f₂ : A₂ ⟶ B₂} [HasImage f₂] {g₂ : B₂ ⟶ C₂} [HasKernel g₂] (w₂ : f₂ ≫ g₂ = 0) {A₃ B₃ C₃ : V} {f₃ : A₃ ⟶ B₃} [HasImage f₃] {g₃ : B₃ ⟶ C₃} [HasKernel g₃] (w₃ : f₃ ≫ g₃ = 0) (α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂) [HasImageMap α₁] (β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂) (α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃) [HasImageMap α₂] (β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃) @[reassoc] theorem imageSubobjectMap_comp_imageToKernel (p : α.right = β.left) : imageToKernel f g w ≫ kernelSubobjectMap β = imageSubobjectMap α ≫ imageToKernel f' g' w' := by ext simp [p] #align image_subobject_map_comp_image_to_kernel imageSubobjectMap_comp_imageToKernel variable [HasCokernel (imageToKernel f g w)] [HasCokernel (imageToKernel f' g' w')] variable [HasCokernel (imageToKernel f₁ g₁ w₁)] variable [HasCokernel (imageToKernel f₂ g₂ w₂)] variable [HasCokernel (imageToKernel f₃ g₃ w₃)] def homology'.map (p : α.right = β.left) : homology' f g w ⟶ homology' f' g' w' := cokernel.desc _ (kernelSubobjectMap β ≫ cokernel.π _) <| by rw [imageSubobjectMap_comp_imageToKernel_assoc w w' α β p] simp only [cokernel.condition, comp_zero] #align homology.map homology'.map -- Porting note: removed elementwise attribute which does not seem to be helpful here, -- the correct lemma is stated below @[reassoc (attr := simp)] theorem homology'.π_map (p : α.right = β.left) : homology'.π f g w ≫ homology'.map w w' α β p = kernelSubobjectMap β ≫ homology'.π f' g' w' := by simp only [homology'.π, homology'.map, cokernel.π_desc] #align homology.π_map homology'.π_map section attribute [local instance] ConcreteCategory.instFunLike @[simp] lemma homology'.π_map_apply [ConcreteCategory.{w} V] (p : α.right = β.left) (x : (forget V).obj (Subobject.underlying.obj (kernelSubobject g))) : homology'.map w w' α β p (homology'.π f g w x) = homology'.π f' g' w' (kernelSubobjectMap β x) := by simp only [← comp_apply, homology'.π_map w w' α β p] end @[reassoc (attr := simp), elementwise (attr := simp)] theorem homology'.map_desc (p : α.right = β.left) {D : V} (k : (kernelSubobject g' : V) ⟶ D) (z : imageToKernel f' g' w' ≫ k = 0) : homology'.map w w' α β p ≫ homology'.desc f' g' w' k z = homology'.desc f g w (kernelSubobjectMap β ≫ k) (by simp only [imageSubobjectMap_comp_imageToKernel_assoc w w' α β p, z, comp_zero]) := by ext simp only [homology'.π_desc, homology'.π_map_assoc] #align homology.map_desc homology'.map_desc @[simp] theorem homology'.map_id : homology'.map w w (𝟙 _) (𝟙 _) rfl = 𝟙 _ := by ext simp only [homology'.π_map, kernelSubobjectMap_id, Category.id_comp, Category.comp_id] #align homology.map_id homology'.map_id theorem homology'.comp_right_eq_comp_left {V : Type*} [Category V] {A₁ B₁ C₁ A₂ B₂ C₂ A₃ B₃ C₃ : V} {f₁ : A₁ ⟶ B₁} {g₁ : B₁ ⟶ C₁} {f₂ : A₂ ⟶ B₂} {g₂ : B₂ ⟶ C₂} {f₃ : A₃ ⟶ B₃} {g₃ : B₃ ⟶ C₃} {α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂} {β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂} {α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃} {β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃} (p₁ : α₁.right = β₁.left) (p₂ : α₂.right = β₂.left) : (α₁ ≫ α₂).right = (β₁ ≫ β₂).left := by simp only [Arrow.comp_left, Arrow.comp_right, p₁, p₂] #align homology.comp_right_eq_comp_left homology'.comp_right_eq_comp_left @[reassoc]
Mathlib/Algebra/Homology/ImageToKernel.lean
339
343
theorem homology'.map_comp (p₁ : α₁.right = β₁.left) (p₂ : α₂.right = β₂.left) : homology'.map w₁ w₂ α₁ β₁ p₁ ≫ homology'.map w₂ w₃ α₂ β₂ p₂ = homology'.map w₁ w₃ (α₁ ≫ α₂) (β₁ ≫ β₂) (homology'.comp_right_eq_comp_left p₁ p₂) := by
ext simp only [kernelSubobjectMap_comp, homology'.π_map_assoc, homology'.π_map, Category.assoc]
import Mathlib.Topology.Category.TopCat.Limits.Products #align_import topology.category.Top.limits.pullbacks from "leanprover-community/mathlib"@"178a32653e369dce2da68dc6b2694e385d484ef1" -- Porting note: every ML3 decl has an uppercase letter set_option linter.uppercaseLean3 false open TopologicalSpace open CategoryTheory open CategoryTheory.Limits universe v u w noncomputable section namespace TopCat variable {J : Type v} [SmallCategory J] section Pullback variable {X Y Z : TopCat.{u}} abbrev pullbackFst (f : X ⟶ Z) (g : Y ⟶ Z) : TopCat.of { p : X × Y // f p.1 = g p.2 } ⟶ X := ⟨Prod.fst ∘ Subtype.val, by apply Continuous.comp <;> set_option tactic.skipAssignedInstances false in continuity⟩ #align Top.pullback_fst TopCat.pullbackFst lemma pullbackFst_apply (f : X ⟶ Z) (g : Y ⟶ Z) (x) : pullbackFst f g x = x.1.1 := rfl abbrev pullbackSnd (f : X ⟶ Z) (g : Y ⟶ Z) : TopCat.of { p : X × Y // f p.1 = g p.2 } ⟶ Y := ⟨Prod.snd ∘ Subtype.val, by apply Continuous.comp <;> set_option tactic.skipAssignedInstances false in continuity⟩ #align Top.pullback_snd TopCat.pullbackSnd lemma pullbackSnd_apply (f : X ⟶ Z) (g : Y ⟶ Z) (x) : pullbackSnd f g x = x.1.2 := rfl def pullbackCone (f : X ⟶ Z) (g : Y ⟶ Z) : PullbackCone f g := PullbackCone.mk (pullbackFst f g) (pullbackSnd f g) (by dsimp [pullbackFst, pullbackSnd, Function.comp_def] ext ⟨x, h⟩ -- Next 2 lines were -- `rw [comp_apply, ContinuousMap.coe_mk, comp_apply, ContinuousMap.coe_mk]` -- `exact h` before leanprover/lean4#2644 rw [comp_apply, comp_apply] congr!) #align Top.pullback_cone TopCat.pullbackCone def pullbackConeIsLimit (f : X ⟶ Z) (g : Y ⟶ Z) : IsLimit (pullbackCone f g) := PullbackCone.isLimitAux' _ (by intro S constructor; swap · exact { toFun := fun x => ⟨⟨S.fst x, S.snd x⟩, by simpa using ConcreteCategory.congr_hom S.condition x⟩ continuous_toFun := by apply Continuous.subtype_mk <| Continuous.prod_mk ?_ ?_ · exact (PullbackCone.fst S)|>.continuous_toFun · exact (PullbackCone.snd S)|>.continuous_toFun } refine ⟨?_, ?_, ?_⟩ · delta pullbackCone ext a -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [comp_apply, ContinuousMap.coe_mk] · delta pullbackCone ext a -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [comp_apply, ContinuousMap.coe_mk] · intro m h₁ h₂ -- Porting note: used to be ext x apply ContinuousMap.ext; intro x apply Subtype.ext apply Prod.ext · simpa using ConcreteCategory.congr_hom h₁ x · simpa using ConcreteCategory.congr_hom h₂ x) #align Top.pullback_cone_is_limit TopCat.pullbackConeIsLimit def pullbackIsoProdSubtype (f : X ⟶ Z) (g : Y ⟶ Z) : pullback f g ≅ TopCat.of { p : X × Y // f p.1 = g p.2 } := (limit.isLimit _).conePointUniqueUpToIso (pullbackConeIsLimit f g) #align Top.pullback_iso_prod_subtype TopCat.pullbackIsoProdSubtype @[reassoc (attr := simp)] theorem pullbackIsoProdSubtype_inv_fst (f : X ⟶ Z) (g : Y ⟶ Z) : (pullbackIsoProdSubtype f g).inv ≫ pullback.fst = pullbackFst f g := by simp [pullbackCone, pullbackIsoProdSubtype] #align Top.pullback_iso_prod_subtype_inv_fst TopCat.pullbackIsoProdSubtype_inv_fst theorem pullbackIsoProdSubtype_inv_fst_apply (f : X ⟶ Z) (g : Y ⟶ Z) (x : { p : X × Y // f p.1 = g p.2 }) : (pullback.fst : pullback f g ⟶ _) ((pullbackIsoProdSubtype f g).inv x) = (x : X × Y).fst := ConcreteCategory.congr_hom (pullbackIsoProdSubtype_inv_fst f g) x #align Top.pullback_iso_prod_subtype_inv_fst_apply TopCat.pullbackIsoProdSubtype_inv_fst_apply @[reassoc (attr := simp)] theorem pullbackIsoProdSubtype_inv_snd (f : X ⟶ Z) (g : Y ⟶ Z) : (pullbackIsoProdSubtype f g).inv ≫ pullback.snd = pullbackSnd f g := by simp [pullbackCone, pullbackIsoProdSubtype] #align Top.pullback_iso_prod_subtype_inv_snd TopCat.pullbackIsoProdSubtype_inv_snd theorem pullbackIsoProdSubtype_inv_snd_apply (f : X ⟶ Z) (g : Y ⟶ Z) (x : { p : X × Y // f p.1 = g p.2 }) : (pullback.snd : pullback f g ⟶ _) ((pullbackIsoProdSubtype f g).inv x) = (x : X × Y).snd := ConcreteCategory.congr_hom (pullbackIsoProdSubtype_inv_snd f g) x #align Top.pullback_iso_prod_subtype_inv_snd_apply TopCat.pullbackIsoProdSubtype_inv_snd_apply theorem pullbackIsoProdSubtype_hom_fst (f : X ⟶ Z) (g : Y ⟶ Z) : (pullbackIsoProdSubtype f g).hom ≫ pullbackFst f g = pullback.fst := by rw [← Iso.eq_inv_comp, pullbackIsoProdSubtype_inv_fst] #align Top.pullback_iso_prod_subtype_hom_fst TopCat.pullbackIsoProdSubtype_hom_fst theorem pullbackIsoProdSubtype_hom_snd (f : X ⟶ Z) (g : Y ⟶ Z) : (pullbackIsoProdSubtype f g).hom ≫ pullbackSnd f g = pullback.snd := by rw [← Iso.eq_inv_comp, pullbackIsoProdSubtype_inv_snd] #align Top.pullback_iso_prod_subtype_hom_snd TopCat.pullbackIsoProdSubtype_hom_snd -- Porting note: why do I need to tell Lean to coerce pullback to a type theorem pullbackIsoProdSubtype_hom_apply {f : X ⟶ Z} {g : Y ⟶ Z} (x : ConcreteCategory.forget.obj (pullback f g)) : (pullbackIsoProdSubtype f g).hom x = ⟨⟨(pullback.fst : pullback f g ⟶ _) x, (pullback.snd : pullback f g ⟶ _) x⟩, by simpa using ConcreteCategory.congr_hom pullback.condition x⟩ := by apply Subtype.ext; apply Prod.ext exacts [ConcreteCategory.congr_hom (pullbackIsoProdSubtype_hom_fst f g) x, ConcreteCategory.congr_hom (pullbackIsoProdSubtype_hom_snd f g) x] #align Top.pullback_iso_prod_subtype_hom_apply TopCat.pullbackIsoProdSubtype_hom_apply theorem pullback_topology {X Y Z : TopCat.{u}} (f : X ⟶ Z) (g : Y ⟶ Z) : (pullback f g).str = induced (pullback.fst : pullback f g ⟶ _) X.str ⊓ induced (pullback.snd : pullback f g ⟶ _) Y.str := by let homeo := homeoOfIso (pullbackIsoProdSubtype f g) refine homeo.inducing.induced.trans ?_ change induced homeo (induced _ ( (induced Prod.fst X.str) ⊓ (induced Prod.snd Y.str))) = _ simp only [induced_compose, induced_inf] congr #align Top.pullback_topology TopCat.pullback_topology
Mathlib/Topology/Category/TopCat/Limits/Pullbacks.lean
158
173
theorem range_pullback_to_prod {X Y Z : TopCat} (f : X ⟶ Z) (g : Y ⟶ Z) : Set.range (prod.lift pullback.fst pullback.snd : pullback f g ⟶ X ⨯ Y) = { x | (Limits.prod.fst ≫ f) x = (Limits.prod.snd ≫ g) x } := by
ext x constructor · rintro ⟨y, rfl⟩ change (_ ≫ _ ≫ f) _ = (_ ≫ _ ≫ g) _ -- new `change` after #13170 simp [pullback.condition] · rintro (h : f (_, _).1 = g (_, _).2) use (pullbackIsoProdSubtype f g).inv ⟨⟨_, _⟩, h⟩ change (forget TopCat).map _ _ = _ -- new `change` after #13170 apply Concrete.limit_ext rintro ⟨⟨⟩⟩ <;> erw [← comp_apply, ← comp_apply, limit.lift_π] <;> -- now `erw` after #13170 -- This used to be `simp` before leanprover/lean4#2644 aesop_cat
import Mathlib.Data.Finsupp.Encodable import Mathlib.LinearAlgebra.Pi import Mathlib.LinearAlgebra.Span import Mathlib.Data.Set.Countable #align_import linear_algebra.finsupp from "leanprover-community/mathlib"@"9d684a893c52e1d6692a504a118bfccbae04feeb" noncomputable section open Set LinearMap Submodule namespace Finsupp variable {α : Type*} {M : Type*} {N : Type*} {P : Type*} {R : Type*} {S : Type*} variable [Semiring R] [Semiring S] [AddCommMonoid M] [Module R M] variable [AddCommMonoid N] [Module R N] variable [AddCommMonoid P] [Module R P] def lsingle (a : α) : M →ₗ[R] α →₀ M := { Finsupp.singleAddHom a with map_smul' := fun _ _ => (smul_single _ _ _).symm } #align finsupp.lsingle Finsupp.lsingle theorem lhom_ext ⦃φ ψ : (α →₀ M) →ₗ[R] N⦄ (h : ∀ a b, φ (single a b) = ψ (single a b)) : φ = ψ := LinearMap.toAddMonoidHom_injective <| addHom_ext h #align finsupp.lhom_ext Finsupp.lhom_ext -- Porting note: The priority should be higher than `LinearMap.ext`. @[ext high] theorem lhom_ext' ⦃φ ψ : (α →₀ M) →ₗ[R] N⦄ (h : ∀ a, φ.comp (lsingle a) = ψ.comp (lsingle a)) : φ = ψ := lhom_ext fun a => LinearMap.congr_fun (h a) #align finsupp.lhom_ext' Finsupp.lhom_ext' def lapply (a : α) : (α →₀ M) →ₗ[R] M := { Finsupp.applyAddHom a with map_smul' := fun _ _ => rfl } #align finsupp.lapply Finsupp.lapply @[simps] def lcoeFun : (α →₀ M) →ₗ[R] α → M where toFun := (⇑) map_add' x y := by ext simp map_smul' x y := by ext simp #align finsupp.lcoe_fun Finsupp.lcoeFun @[simp] theorem lsingle_apply (a : α) (b : M) : (lsingle a : M →ₗ[R] α →₀ M) b = single a b := rfl #align finsupp.lsingle_apply Finsupp.lsingle_apply @[simp] theorem lapply_apply (a : α) (f : α →₀ M) : (lapply a : (α →₀ M) →ₗ[R] M) f = f a := rfl #align finsupp.lapply_apply Finsupp.lapply_apply @[simp] theorem lapply_comp_lsingle_same (a : α) : lapply a ∘ₗ lsingle a = (.id : M →ₗ[R] M) := by ext; simp @[simp] theorem lapply_comp_lsingle_of_ne (a a' : α) (h : a ≠ a') : lapply a ∘ₗ lsingle a' = (0 : M →ₗ[R] M) := by ext; simp [h.symm] @[simp] theorem ker_lsingle (a : α) : ker (lsingle a : M →ₗ[R] α →₀ M) = ⊥ := ker_eq_bot_of_injective (single_injective a) #align finsupp.ker_lsingle Finsupp.ker_lsingle theorem lsingle_range_le_ker_lapply (s t : Set α) (h : Disjoint s t) : ⨆ a ∈ s, LinearMap.range (lsingle a : M →ₗ[R] α →₀ M) ≤ ⨅ a ∈ t, ker (lapply a : (α →₀ M) →ₗ[R] M) := by refine iSup_le fun a₁ => iSup_le fun h₁ => range_le_iff_comap.2 ?_ simp only [(ker_comp _ _).symm, eq_top_iff, SetLike.le_def, mem_ker, comap_iInf, mem_iInf] intro b _ a₂ h₂ have : a₁ ≠ a₂ := fun eq => h.le_bot ⟨h₁, eq.symm ▸ h₂⟩ exact single_eq_of_ne this #align finsupp.lsingle_range_le_ker_lapply Finsupp.lsingle_range_le_ker_lapply theorem iInf_ker_lapply_le_bot : ⨅ a, ker (lapply a : (α →₀ M) →ₗ[R] M) ≤ ⊥ := by simp only [SetLike.le_def, mem_iInf, mem_ker, mem_bot, lapply_apply] exact fun a h => Finsupp.ext h #align finsupp.infi_ker_lapply_le_bot Finsupp.iInf_ker_lapply_le_bot theorem iSup_lsingle_range : ⨆ a, LinearMap.range (lsingle a : M →ₗ[R] α →₀ M) = ⊤ := by refine eq_top_iff.2 <| SetLike.le_def.2 fun f _ => ?_ rw [← sum_single f] exact sum_mem fun a _ => Submodule.mem_iSup_of_mem a ⟨_, rfl⟩ #align finsupp.supr_lsingle_range Finsupp.iSup_lsingle_range theorem disjoint_lsingle_lsingle (s t : Set α) (hs : Disjoint s t) : Disjoint (⨆ a ∈ s, LinearMap.range (lsingle a : M →ₗ[R] α →₀ M)) (⨆ a ∈ t, LinearMap.range (lsingle a : M →ₗ[R] α →₀ M)) := by -- Porting note: 2 placeholders are added to prevent timeout. refine (Disjoint.mono (lsingle_range_le_ker_lapply s sᶜ ?_) (lsingle_range_le_ker_lapply t tᶜ ?_)) ?_ · apply disjoint_compl_right · apply disjoint_compl_right rw [disjoint_iff_inf_le] refine le_trans (le_iInf fun i => ?_) iInf_ker_lapply_le_bot classical by_cases his : i ∈ s · by_cases hit : i ∈ t · exact (hs.le_bot ⟨his, hit⟩).elim exact inf_le_of_right_le (iInf_le_of_le i <| iInf_le _ hit) exact inf_le_of_left_le (iInf_le_of_le i <| iInf_le _ his) #align finsupp.disjoint_lsingle_lsingle Finsupp.disjoint_lsingle_lsingle theorem span_single_image (s : Set M) (a : α) : Submodule.span R (single a '' s) = (Submodule.span R s).map (lsingle a : M →ₗ[R] α →₀ M) := by rw [← span_image]; rfl #align finsupp.span_single_image Finsupp.span_single_image variable (M R) def supported (s : Set α) : Submodule R (α →₀ M) where carrier := { p | ↑p.support ⊆ s } add_mem' {p q} hp hq := by classical refine Subset.trans (Subset.trans (Finset.coe_subset.2 support_add) ?_) (union_subset hp hq) rw [Finset.coe_union] zero_mem' := by simp only [subset_def, Finset.mem_coe, Set.mem_setOf_eq, mem_support_iff, zero_apply] intro h ha exact (ha rfl).elim smul_mem' a p hp := Subset.trans (Finset.coe_subset.2 support_smul) hp #align finsupp.supported Finsupp.supported variable {M} theorem mem_supported {s : Set α} (p : α →₀ M) : p ∈ supported M R s ↔ ↑p.support ⊆ s := Iff.rfl #align finsupp.mem_supported Finsupp.mem_supported
Mathlib/LinearAlgebra/Finsupp.lean
314
316
theorem mem_supported' {s : Set α} (p : α →₀ M) : p ∈ supported M R s ↔ ∀ x ∉ s, p x = 0 := by
haveI := Classical.decPred fun x : α => x ∈ s; simp [mem_supported, Set.subset_def, not_imp_comm]
import Mathlib.Data.Vector.Basic #align_import data.vector.mem from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226" namespace Vector variable {α β : Type*} {n : ℕ} (a a' : α) @[simp] theorem get_mem (i : Fin n) (v : Vector α n) : v.get i ∈ v.toList := by rw [get_eq_get] exact List.get_mem _ _ _ #align vector.nth_mem Vector.get_mem theorem mem_iff_get (v : Vector α n) : a ∈ v.toList ↔ ∃ i, v.get i = a := by simp only [List.mem_iff_get, Fin.exists_iff, Vector.get_eq_get] exact ⟨fun ⟨i, hi, h⟩ => ⟨i, by rwa [toList_length] at hi, h⟩, fun ⟨i, hi, h⟩ => ⟨i, by rwa [toList_length], h⟩⟩ #align vector.mem_iff_nth Vector.mem_iff_get theorem not_mem_nil : a ∉ (Vector.nil : Vector α 0).toList := by unfold Vector.nil dsimp simp #align vector.not_mem_nil Vector.not_mem_nil theorem not_mem_zero (v : Vector α 0) : a ∉ v.toList := (Vector.eq_nil v).symm ▸ not_mem_nil a #align vector.not_mem_zero Vector.not_mem_zero theorem mem_cons_iff (v : Vector α n) : a' ∈ (a ::ᵥ v).toList ↔ a' = a ∨ a' ∈ v.toList := by rw [Vector.toList_cons, List.mem_cons] #align vector.mem_cons_iff Vector.mem_cons_iff
Mathlib/Data/Vector/Mem.lean
52
54
theorem mem_succ_iff (v : Vector α (n + 1)) : a ∈ v.toList ↔ a = v.head ∨ a ∈ v.tail.toList := by
obtain ⟨a', v', h⟩ := exists_eq_cons v simp_rw [h, Vector.mem_cons_iff, Vector.head_cons, Vector.tail_cons]
import Mathlib.NumberTheory.DirichletCharacter.Bounds import Mathlib.NumberTheory.EulerProduct.Basic import Mathlib.NumberTheory.LSeries.Basic import Mathlib.NumberTheory.LSeries.RiemannZeta open Complex variable {s : ℂ} noncomputable def riemannZetaSummandHom (hs : s ≠ 0) : ℕ →*₀ ℂ where toFun n := (n : ℂ) ^ (-s) map_zero' := by simp [hs] map_one' := by simp map_mul' m n := by simpa only [Nat.cast_mul, ofReal_natCast] using mul_cpow_ofReal_nonneg m.cast_nonneg n.cast_nonneg _ noncomputable def dirichletSummandHom {n : ℕ} (χ : DirichletCharacter ℂ n) (hs : s ≠ 0) : ℕ →*₀ ℂ where toFun n := χ n * (n : ℂ) ^ (-s) map_zero' := by simp [hs] map_one' := by simp map_mul' m n := by simp_rw [← ofReal_natCast] simpa only [Nat.cast_mul, IsUnit.mul_iff, not_and, map_mul, ofReal_mul, mul_cpow_ofReal_nonneg m.cast_nonneg n.cast_nonneg _] using mul_mul_mul_comm .. lemma summable_riemannZetaSummand (hs : 1 < s.re) : Summable (fun n ↦ ‖riemannZetaSummandHom (ne_zero_of_one_lt_re hs) n‖) := by simp only [riemannZetaSummandHom, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk] convert Real.summable_nat_rpow_inv.mpr hs with n rw [← ofReal_natCast, Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_nonneg (Nat.cast_nonneg n) <| re_neg_ne_zero_of_one_lt_re hs, neg_re, Real.rpow_neg <| Nat.cast_nonneg n] lemma tsum_riemannZetaSummand (hs : 1 < s.re) : ∑' (n : ℕ), riemannZetaSummandHom (ne_zero_of_one_lt_re hs) n = riemannZeta s := by have hsum := summable_riemannZetaSummand hs rw [zeta_eq_tsum_one_div_nat_add_one_cpow hs, tsum_eq_zero_add hsum.of_norm, map_zero, zero_add] simp only [riemannZetaSummandHom, cpow_neg, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, Nat.cast_add, Nat.cast_one, one_div] lemma summable_dirichletSummand {N : ℕ} (χ : DirichletCharacter ℂ N) (hs : 1 < s.re) : Summable (fun n ↦ ‖dirichletSummandHom χ (ne_zero_of_one_lt_re hs) n‖) := by simp only [dirichletSummandHom, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, norm_mul] exact (summable_riemannZetaSummand hs).of_nonneg_of_le (fun _ ↦ by positivity) (fun n ↦ mul_le_of_le_one_left (norm_nonneg _) <| χ.norm_le_one n) open scoped LSeries.notation in lemma tsum_dirichletSummand {N : ℕ} (χ : DirichletCharacter ℂ N) (hs : 1 < s.re) : ∑' (n : ℕ), dirichletSummandHom χ (ne_zero_of_one_lt_re hs) n = L ↗χ s := by simp only [LSeries, LSeries.term, dirichletSummandHom] refine tsum_congr (fun n ↦ ?_) rcases eq_or_ne n 0 with rfl | hn · simp only [map_zero, ↓reduceIte] · simp only [cpow_neg, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, hn, ↓reduceIte, Field.div_eq_mul_inv] open Filter Nat Topology EulerProduct theorem riemannZeta_eulerProduct_hasProd (hs : 1 < s.re) : HasProd (fun p : Primes ↦ (1 - (p : ℂ) ^ (-s))⁻¹) (riemannZeta s) := by rw [← tsum_riemannZetaSummand hs] apply eulerProduct_completely_multiplicative_hasProd <| summable_riemannZetaSummand hs theorem riemannZeta_eulerProduct_tprod (hs : 1 < s.re) : ∏' p : Primes, (1 - (p : ℂ) ^ (-s))⁻¹ = riemannZeta s := (riemannZeta_eulerProduct_hasProd hs).tprod_eq theorem riemannZeta_eulerProduct (hs : 1 < s.re) : Tendsto (fun n : ℕ ↦ ∏ p ∈ primesBelow n, (1 - (p : ℂ) ^ (-s))⁻¹) atTop (𝓝 (riemannZeta s)) := by rw [← tsum_riemannZetaSummand hs] apply eulerProduct_completely_multiplicative <| summable_riemannZetaSummand hs open scoped LSeries.notation theorem dirichletLSeries_eulerProduct_hasProd {N : ℕ} (χ : DirichletCharacter ℂ N) (hs : 1 < s.re) : HasProd (fun p : Primes ↦ (1 - χ p * (p : ℂ) ^ (-s))⁻¹) (L ↗χ s) := by rw [← tsum_dirichletSummand χ hs] convert eulerProduct_completely_multiplicative_hasProd <| summable_dirichletSummand χ hs theorem dirichletLSeries_eulerProduct_tprod {N : ℕ} (χ : DirichletCharacter ℂ N) (hs : 1 < s.re) : ∏' p : Primes, (1 - χ p * (p : ℂ) ^ (-s))⁻¹ = L ↗χ s := (dirichletLSeries_eulerProduct_hasProd χ hs).tprod_eq
Mathlib/NumberTheory/EulerProduct/DirichletLSeries.lean
129
133
theorem dirichletLSeries_eulerProduct {N : ℕ} (χ : DirichletCharacter ℂ N) (hs : 1 < s.re) : Tendsto (fun n : ℕ ↦ ∏ p ∈ primesBelow n, (1 - χ p * (p : ℂ) ^ (-s))⁻¹) atTop (𝓝 (L ↗χ s)) := by
rw [← tsum_dirichletSummand χ hs] apply eulerProduct_completely_multiplicative <| summable_dirichletSummand χ hs
import Mathlib.CategoryTheory.Preadditive.Basic #align_import category_theory.preadditive.functor_category from "leanprover-community/mathlib"@"829895f162a1f29d0133f4b3538f4cd1fb5bffd3" namespace CategoryTheory open CategoryTheory.Limits Preadditive variable {C D : Type*} [Category C] [Category D] [Preadditive D] instance {F G : C ⥤ D} : Zero (F ⟶ G) where zero := { app := fun X => 0 } instance {F G : C ⥤ D} : Add (F ⟶ G) where add α β := { app := fun X => α.app X + β.app X } instance {F G : C ⥤ D} : Neg (F ⟶ G) where neg α := { app := fun X => -α.app X } instance functorCategoryPreadditive : Preadditive (C ⥤ D) where homGroup F G := { nsmul := nsmulRec zsmul := zsmulRec sub := fun α β => { app := fun X => α.app X - β.app X } add_assoc := by intros ext apply add_assoc zero_add := by intros dsimp ext apply zero_add add_zero := by intros dsimp ext apply add_zero add_comm := by intros dsimp ext apply add_comm sub_eq_add_neg := by intros dsimp ext apply sub_eq_add_neg add_left_neg := by intros dsimp ext apply add_left_neg } add_comp := by intros dsimp ext apply add_comp comp_add := by intros dsimp ext apply comp_add #align category_theory.functor_category_preadditive CategoryTheory.functorCategoryPreadditive namespace NatTrans variable {F G : C ⥤ D} @[simps] def appHom (X : C) : (F ⟶ G) →+ (F.obj X ⟶ G.obj X) where toFun α := α.app X map_zero' := rfl map_add' _ _ := rfl #align category_theory.nat_trans.app_hom CategoryTheory.NatTrans.appHom @[simp] theorem app_zero (X : C) : (0 : F ⟶ G).app X = 0 := rfl #align category_theory.nat_trans.app_zero CategoryTheory.NatTrans.app_zero @[simp] theorem app_add (X : C) (α β : F ⟶ G) : (α + β).app X = α.app X + β.app X := rfl #align category_theory.nat_trans.app_add CategoryTheory.NatTrans.app_add @[simp] theorem app_sub (X : C) (α β : F ⟶ G) : (α - β).app X = α.app X - β.app X := rfl #align category_theory.nat_trans.app_sub CategoryTheory.NatTrans.app_sub @[simp] theorem app_neg (X : C) (α : F ⟶ G) : (-α).app X = -α.app X := rfl #align category_theory.nat_trans.app_neg CategoryTheory.NatTrans.app_neg @[simp] theorem app_nsmul (X : C) (α : F ⟶ G) (n : ℕ) : (n • α).app X = n • α.app X := (appHom X).map_nsmul α n #align category_theory.nat_trans.app_nsmul CategoryTheory.NatTrans.app_nsmul @[simp] theorem app_zsmul (X : C) (α : F ⟶ G) (n : ℤ) : (n • α).app X = n • α.app X := (appHom X : (F ⟶ G) →+ (F.obj X ⟶ G.obj X)).map_zsmul α n #align category_theory.nat_trans.app_zsmul CategoryTheory.NatTrans.app_zsmul @[simp] theorem app_units_zsmul (X : C) (α : F ⟶ G) (n : ℤˣ) : (n • α).app X = n • α.app X := by apply app_zsmul @[simp]
Mathlib/CategoryTheory/Preadditive/FunctorCategory.lean
127
129
theorem app_sum {ι : Type*} (s : Finset ι) (X : C) (α : ι → (F ⟶ G)) : (∑ i ∈ s, α i).app X = ∑ i ∈ s, (α i).app X := by
simp only [← appHom_apply, map_sum]
import Mathlib.Algebra.Polynomial.Reverse import Mathlib.Algebra.Regular.SMul #align_import data.polynomial.monic from "leanprover-community/mathlib"@"cbdf7b565832144d024caa5a550117c6df0204a5" noncomputable section open Finset open Polynomial namespace Polynomial universe u v y variable {R : Type u} {S : Type v} {a b : R} {m n : ℕ} {ι : Type y} section Semiring variable [Semiring R] {p q r : R[X]} theorem monic_zero_iff_subsingleton : Monic (0 : R[X]) ↔ Subsingleton R := subsingleton_iff_zero_eq_one #align polynomial.monic_zero_iff_subsingleton Polynomial.monic_zero_iff_subsingleton theorem not_monic_zero_iff : ¬Monic (0 : R[X]) ↔ (0 : R) ≠ 1 := (monic_zero_iff_subsingleton.trans subsingleton_iff_zero_eq_one.symm).not #align polynomial.not_monic_zero_iff Polynomial.not_monic_zero_iff theorem monic_zero_iff_subsingleton' : Monic (0 : R[X]) ↔ (∀ f g : R[X], f = g) ∧ ∀ a b : R, a = b := Polynomial.monic_zero_iff_subsingleton.trans ⟨by intro simp [eq_iff_true_of_subsingleton], fun h => subsingleton_iff.mpr h.2⟩ #align polynomial.monic_zero_iff_subsingleton' Polynomial.monic_zero_iff_subsingleton' theorem Monic.as_sum (hp : p.Monic) : p = X ^ p.natDegree + ∑ i ∈ range p.natDegree, C (p.coeff i) * X ^ i := by conv_lhs => rw [p.as_sum_range_C_mul_X_pow, sum_range_succ_comm] suffices C (p.coeff p.natDegree) = 1 by rw [this, one_mul] exact congr_arg C hp #align polynomial.monic.as_sum Polynomial.Monic.as_sum theorem ne_zero_of_ne_zero_of_monic (hp : p ≠ 0) (hq : Monic q) : q ≠ 0 := by rintro rfl rw [Monic.def, leadingCoeff_zero] at hq rw [← mul_one p, ← C_1, ← hq, C_0, mul_zero] at hp exact hp rfl #align polynomial.ne_zero_of_ne_zero_of_monic Polynomial.ne_zero_of_ne_zero_of_monic theorem Monic.map [Semiring S] (f : R →+* S) (hp : Monic p) : Monic (p.map f) := by unfold Monic nontriviality have : f p.leadingCoeff ≠ 0 := by rw [show _ = _ from hp, f.map_one] exact one_ne_zero rw [Polynomial.leadingCoeff, coeff_map] suffices p.coeff (p.map f).natDegree = 1 by simp [this] rwa [natDegree_eq_of_degree_eq (degree_map_eq_of_leadingCoeff_ne_zero f this)] #align polynomial.monic.map Polynomial.Monic.map theorem monic_C_mul_of_mul_leadingCoeff_eq_one {b : R} (hp : b * p.leadingCoeff = 1) : Monic (C b * p) := by unfold Monic nontriviality rw [leadingCoeff_mul' _] <;> simp [leadingCoeff_C b, hp] set_option linter.uppercaseLean3 false in #align polynomial.monic_C_mul_of_mul_leading_coeff_eq_one Polynomial.monic_C_mul_of_mul_leadingCoeff_eq_one theorem monic_mul_C_of_leadingCoeff_mul_eq_one {b : R} (hp : p.leadingCoeff * b = 1) : Monic (p * C b) := by unfold Monic nontriviality rw [leadingCoeff_mul' _] <;> simp [leadingCoeff_C b, hp] set_option linter.uppercaseLean3 false in #align polynomial.monic_mul_C_of_leading_coeff_mul_eq_one Polynomial.monic_mul_C_of_leadingCoeff_mul_eq_one theorem monic_of_degree_le (n : ℕ) (H1 : degree p ≤ n) (H2 : coeff p n = 1) : Monic p := Decidable.byCases (fun H : degree p < n => eq_of_zero_eq_one (H2 ▸ (coeff_eq_zero_of_degree_lt H).symm) _ _) fun H : ¬degree p < n => by rwa [Monic, Polynomial.leadingCoeff, natDegree, (lt_or_eq_of_le H1).resolve_left H] #align polynomial.monic_of_degree_le Polynomial.monic_of_degree_le theorem monic_X_pow_add {n : ℕ} (H : degree p ≤ n) : Monic (X ^ (n + 1) + p) := have H1 : degree p < (n + 1 : ℕ) := lt_of_le_of_lt H (WithBot.coe_lt_coe.2 (Nat.lt_succ_self n)) monic_of_degree_le (n + 1) (le_trans (degree_add_le _ _) (max_le (degree_X_pow_le _) (le_of_lt H1))) (by rw [coeff_add, coeff_X_pow, if_pos rfl, coeff_eq_zero_of_degree_lt H1, add_zero]) set_option linter.uppercaseLean3 false in #align polynomial.monic_X_pow_add Polynomial.monic_X_pow_add variable (a) in theorem monic_X_pow_add_C {n : ℕ} (h : n ≠ 0) : (X ^ n + C a).Monic := by obtain ⟨k, rfl⟩ := Nat.exists_eq_succ_of_ne_zero h exact monic_X_pow_add <| degree_C_le.trans Nat.WithBot.coe_nonneg theorem monic_X_add_C (x : R) : Monic (X + C x) := pow_one (X : R[X]) ▸ monic_X_pow_add_C x one_ne_zero set_option linter.uppercaseLean3 false in #align polynomial.monic_X_add_C Polynomial.monic_X_add_C theorem Monic.mul (hp : Monic p) (hq : Monic q) : Monic (p * q) := letI := Classical.decEq R if h0 : (0 : R) = 1 then haveI := subsingleton_of_zero_eq_one h0 Subsingleton.elim _ _ else by have : p.leadingCoeff * q.leadingCoeff ≠ 0 := by simp [Monic.def.1 hp, Monic.def.1 hq, Ne.symm h0] rw [Monic.def, leadingCoeff_mul' this, Monic.def.1 hp, Monic.def.1 hq, one_mul] #align polynomial.monic.mul Polynomial.Monic.mul theorem Monic.pow (hp : Monic p) : ∀ n : ℕ, Monic (p ^ n) | 0 => monic_one | n + 1 => by rw [pow_succ] exact (Monic.pow hp n).mul hp #align polynomial.monic.pow Polynomial.Monic.pow theorem Monic.add_of_left (hp : Monic p) (hpq : degree q < degree p) : Monic (p + q) := by rwa [Monic, add_comm, leadingCoeff_add_of_degree_lt hpq] #align polynomial.monic.add_of_left Polynomial.Monic.add_of_left theorem Monic.add_of_right (hq : Monic q) (hpq : degree p < degree q) : Monic (p + q) := by rwa [Monic, leadingCoeff_add_of_degree_lt hpq] #align polynomial.monic.add_of_right Polynomial.Monic.add_of_right theorem Monic.of_mul_monic_left (hp : p.Monic) (hpq : (p * q).Monic) : q.Monic := by contrapose! hpq rw [Monic.def] at hpq ⊢ rwa [leadingCoeff_monic_mul hp] #align polynomial.monic.of_mul_monic_left Polynomial.Monic.of_mul_monic_left theorem Monic.of_mul_monic_right (hq : q.Monic) (hpq : (p * q).Monic) : p.Monic := by contrapose! hpq rw [Monic.def] at hpq ⊢ rwa [leadingCoeff_mul_monic hq] #align polynomial.monic.of_mul_monic_right Polynomial.Monic.of_mul_monic_right namespace Monic @[simp] theorem natDegree_eq_zero_iff_eq_one (hp : p.Monic) : p.natDegree = 0 ↔ p = 1 := by constructor <;> intro h swap · rw [h] exact natDegree_one have : p = C (p.coeff 0) := by rw [← Polynomial.degree_le_zero_iff] rwa [Polynomial.natDegree_eq_zero_iff_degree_le_zero] at h rw [this] rw [← h, ← Polynomial.leadingCoeff, Monic.def.1 hp, C_1] #align polynomial.monic.nat_degree_eq_zero_iff_eq_one Polynomial.Monic.natDegree_eq_zero_iff_eq_one @[simp] theorem degree_le_zero_iff_eq_one (hp : p.Monic) : p.degree ≤ 0 ↔ p = 1 := by rw [← hp.natDegree_eq_zero_iff_eq_one, natDegree_eq_zero_iff_degree_le_zero] #align polynomial.monic.degree_le_zero_iff_eq_one Polynomial.Monic.degree_le_zero_iff_eq_one theorem natDegree_mul (hp : p.Monic) (hq : q.Monic) : (p * q).natDegree = p.natDegree + q.natDegree := by nontriviality R apply natDegree_mul' simp [hp.leadingCoeff, hq.leadingCoeff] #align polynomial.monic.nat_degree_mul Polynomial.Monic.natDegree_mul theorem degree_mul_comm (hp : p.Monic) (q : R[X]) : (p * q).degree = (q * p).degree := by by_cases h : q = 0 · simp [h] rw [degree_mul', hp.degree_mul] · exact add_comm _ _ · rwa [hp.leadingCoeff, one_mul, leadingCoeff_ne_zero] #align polynomial.monic.degree_mul_comm Polynomial.Monic.degree_mul_comm nonrec theorem natDegree_mul' (hp : p.Monic) (hq : q ≠ 0) : (p * q).natDegree = p.natDegree + q.natDegree := by rw [natDegree_mul'] simpa [hp.leadingCoeff, leadingCoeff_ne_zero] #align polynomial.monic.nat_degree_mul' Polynomial.Monic.natDegree_mul' theorem natDegree_mul_comm (hp : p.Monic) (q : R[X]) : (p * q).natDegree = (q * p).natDegree := by by_cases h : q = 0 · simp [h] rw [hp.natDegree_mul' h, Polynomial.natDegree_mul', add_comm] simpa [hp.leadingCoeff, leadingCoeff_ne_zero] #align polynomial.monic.nat_degree_mul_comm Polynomial.Monic.natDegree_mul_comm theorem not_dvd_of_natDegree_lt (hp : Monic p) (h0 : q ≠ 0) (hl : natDegree q < natDegree p) : ¬p ∣ q := by rintro ⟨r, rfl⟩ rw [hp.natDegree_mul' <| right_ne_zero_of_mul h0] at hl exact hl.not_le (Nat.le_add_right _ _) #align polynomial.monic.not_dvd_of_nat_degree_lt Polynomial.Monic.not_dvd_of_natDegree_lt theorem not_dvd_of_degree_lt (hp : Monic p) (h0 : q ≠ 0) (hl : degree q < degree p) : ¬p ∣ q := Monic.not_dvd_of_natDegree_lt hp h0 <| natDegree_lt_natDegree h0 hl #align polynomial.monic.not_dvd_of_degree_lt Polynomial.Monic.not_dvd_of_degree_lt theorem nextCoeff_mul (hp : Monic p) (hq : Monic q) : nextCoeff (p * q) = nextCoeff p + nextCoeff q := by nontriviality simp only [← coeff_one_reverse] rw [reverse_mul] <;> simp [coeff_mul, antidiagonal, hp.leadingCoeff, hq.leadingCoeff, add_comm, show Nat.succ 0 = 1 from rfl] #align polynomial.monic.next_coeff_mul Polynomial.Monic.nextCoeff_mul
Mathlib/Algebra/Polynomial/Monic.lean
223
226
theorem nextCoeff_pow (hp : p.Monic) (n : ℕ) : (p ^ n).nextCoeff = n • p.nextCoeff := by
induction n with | zero => rw [pow_zero, zero_smul, ← map_one (f := C), nextCoeff_C_eq_zero] | succ n ih => rw [pow_succ, (hp.pow n).nextCoeff_mul hp, ih, succ_nsmul]
import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Tactic.LinearCombination #align_import ring_theory.polynomial.chebyshev from "leanprover-community/mathlib"@"d774451114d6045faeb6751c396bea1eb9058946" namespace Polynomial.Chebyshev set_option linter.uppercaseLean3 false -- `T` `U` `X` open Polynomial variable (R S : Type*) [CommRing R] [CommRing S] -- Well-founded definitions are now irreducible by default; -- as this was implemented before this change, -- we just set it back to semireducible to avoid needing to change any proofs. @[semireducible] noncomputable def T : ℤ → R[X] | 0 => 1 | 1 => X | (n : ℕ) + 2 => 2 * X * T (n + 1) - T n | -((n : ℕ) + 1) => 2 * X * T (-n) - T (-n + 1) termination_by n => Int.natAbs n + Int.natAbs (n - 1) #align polynomial.chebyshev.T Polynomial.Chebyshev.T @[elab_as_elim] protected theorem induct (motive : ℤ → Prop) (zero : motive 0) (one : motive 1) (add_two : ∀ (n : ℕ), motive (↑n + 1) → motive ↑n → motive (↑n + 2)) (neg_add_one : ∀ (n : ℕ), motive (-↑n) → motive (-↑n + 1) → motive (-↑n - 1)) : ∀ (a : ℤ), motive a := T.induct Unit motive zero one add_two fun n hn hnm => by simpa only [Int.negSucc_eq, neg_add] using neg_add_one n hn hnm @[simp] theorem T_add_two : ∀ n, T R (n + 2) = 2 * X * T R (n + 1) - T R n | (k : ℕ) => T.eq_3 R k | -(k + 1 : ℕ) => by linear_combination (norm := (simp [Int.negSucc_eq]; ring_nf)) T.eq_4 R k #align polynomial.chebyshev.T_add_two Polynomial.Chebyshev.T_add_two theorem T_add_one (n : ℤ) : T R (n + 1) = 2 * X * T R n - T R (n - 1) := by linear_combination (norm := ring_nf) T_add_two R (n - 1) theorem T_sub_two (n : ℤ) : T R (n - 2) = 2 * X * T R (n - 1) - T R n := by linear_combination (norm := ring_nf) T_add_two R (n - 2) theorem T_sub_one (n : ℤ) : T R (n - 1) = 2 * X * T R n - T R (n + 1) := by linear_combination (norm := ring_nf) T_add_two R (n - 1) theorem T_eq (n : ℤ) : T R n = 2 * X * T R (n - 1) - T R (n - 2) := by linear_combination (norm := ring_nf) T_add_two R (n - 2) #align polynomial.chebyshev.T_of_two_le Polynomial.Chebyshev.T_eq @[simp] theorem T_zero : T R 0 = 1 := rfl #align polynomial.chebyshev.T_zero Polynomial.Chebyshev.T_zero @[simp] theorem T_one : T R 1 = X := rfl #align polynomial.chebyshev.T_one Polynomial.Chebyshev.T_one theorem T_neg_one : T R (-1) = X := (by ring : 2 * X * 1 - X = X) theorem T_two : T R 2 = 2 * X ^ 2 - 1 := by simpa [pow_two, mul_assoc] using T_add_two R 0 #align polynomial.chebyshev.T_two Polynomial.Chebyshev.T_two @[simp] theorem T_neg (n : ℤ) : T R (-n) = T R n := by induction n using Polynomial.Chebyshev.induct with | zero => rfl | one => show 2 * X * 1 - X = X; ring | add_two n ih1 ih2 => have h₁ := T_add_two R n have h₂ := T_sub_two R (-n) linear_combination (norm := ring_nf) (2 * (X:R[X])) * ih1 - ih2 - h₁ + h₂ | neg_add_one n ih1 ih2 => have h₁ := T_add_one R n have h₂ := T_sub_one R (-n) linear_combination (norm := ring_nf) (2 * (X:R[X])) * ih1 - ih2 + h₁ - h₂ theorem T_natAbs (n : ℤ) : T R n.natAbs = T R n := by obtain h | h := Int.natAbs_eq n <;> nth_rw 2 [h]; simp theorem T_neg_two : T R (-2) = 2 * X ^ 2 - 1 := by simp [T_two] -- Well-founded definitions are now irreducible by default; -- as this was implemented before this change, -- we just set it back to semireducible to avoid needing to change any proofs. @[semireducible] noncomputable def U : ℤ → R[X] | 0 => 1 | 1 => 2 * X | (n : ℕ) + 2 => 2 * X * U (n + 1) - U n | -((n : ℕ) + 1) => 2 * X * U (-n) - U (-n + 1) termination_by n => Int.natAbs n + Int.natAbs (n - 1) #align polynomial.chebyshev.U Polynomial.Chebyshev.U @[simp] theorem U_add_two : ∀ n, U R (n + 2) = 2 * X * U R (n + 1) - U R n | (k : ℕ) => U.eq_3 R k | -(k + 1 : ℕ) => by linear_combination (norm := (simp [Int.negSucc_eq]; ring_nf)) U.eq_4 R k theorem U_add_one (n : ℤ) : U R (n + 1) = 2 * X * U R n - U R (n - 1) := by linear_combination (norm := ring_nf) U_add_two R (n - 1) theorem U_sub_two (n : ℤ) : U R (n - 2) = 2 * X * U R (n - 1) - U R n := by linear_combination (norm := ring_nf) U_add_two R (n - 2) theorem U_sub_one (n : ℤ) : U R (n - 1) = 2 * X * U R n - U R (n + 1) := by linear_combination (norm := ring_nf) U_add_two R (n - 1) theorem U_eq (n : ℤ) : U R n = 2 * X * U R (n - 1) - U R (n - 2) := by linear_combination (norm := ring_nf) U_add_two R (n - 2) #align polynomial.chebyshev.U_of_two_le Polynomial.Chebyshev.U_eq @[simp] theorem U_zero : U R 0 = 1 := rfl #align polynomial.chebyshev.U_zero Polynomial.Chebyshev.U_zero @[simp] theorem U_one : U R 1 = 2 * X := rfl #align polynomial.chebyshev.U_one Polynomial.Chebyshev.U_one @[simp] theorem U_neg_one : U R (-1) = 0 := by simpa using U_sub_one R 0 theorem U_two : U R 2 = 4 * X ^ 2 - 1 := by have := U_add_two R 0 simp only [zero_add, U_one, U_zero] at this linear_combination this #align polynomial.chebyshev.U_two Polynomial.Chebyshev.U_two @[simp] theorem U_neg_two : U R (-2) = -1 := by simpa [zero_sub, Int.reduceNeg, U_neg_one, mul_zero, U_zero] using U_sub_two R 0 theorem U_neg_sub_one (n : ℤ) : U R (-n - 1) = -U R (n - 1) := by induction n using Polynomial.Chebyshev.induct with | zero => simp | one => simp | add_two n ih1 ih2 => have h₁ := U_add_one R n have h₂ := U_sub_two R (-n - 1) linear_combination (norm := ring_nf) 2 * (X:R[X]) * ih1 - ih2 + h₁ + h₂ | neg_add_one n ih1 ih2 => have h₁ := U_eq R n have h₂ := U_sub_two R (-n) linear_combination (norm := ring_nf) 2 * (X:R[X]) * ih1 - ih2 + h₁ + h₂ theorem U_neg (n : ℤ) : U R (-n) = -U R (n - 2) := by simpa [sub_sub] using U_neg_sub_one R (n - 1) @[simp] theorem U_neg_sub_two (n : ℤ) : U R (-n - 2) = -U R n := by simpa [sub_eq_add_neg, add_comm] using U_neg R (n + 2) theorem U_eq_X_mul_U_add_T (n : ℤ) : U R (n + 1) = X * U R n + T R (n + 1) := by induction n using Polynomial.Chebyshev.induct with | zero => simp [two_mul] | one => simp [U_two, T_two]; ring | add_two n ih1 ih2 => have h₁ := U_add_two R (n + 1) have h₂ := U_add_two R n have h₃ := T_add_two R (n + 1) linear_combination (norm := ring_nf) -h₃ - (X:R[X]) * h₂ + h₁ + 2 * (X:R[X]) * ih1 - ih2 | neg_add_one n ih1 ih2 => have h₁ := U_add_two R (-n - 1) have h₂ := U_add_two R (-n) have h₃ := T_add_two R (-n) linear_combination (norm := ring_nf) -h₃ + h₂ - (X:R[X]) * h₁ - ih2 + 2 * (X:R[X]) * ih1 #align polynomial.chebyshev.U_eq_X_mul_U_add_T Polynomial.Chebyshev.U_eq_X_mul_U_add_T theorem T_eq_U_sub_X_mul_U (n : ℤ) : T R n = U R n - X * U R (n - 1) := by linear_combination (norm := ring_nf) - U_eq_X_mul_U_add_T R (n - 1) #align polynomial.chebyshev.T_eq_U_sub_X_mul_U Polynomial.Chebyshev.T_eq_U_sub_X_mul_U theorem T_eq_X_mul_T_sub_pol_U (n : ℤ) : T R (n + 2) = X * T R (n + 1) - (1 - X ^ 2) * U R n := by have h₁ := U_eq_X_mul_U_add_T R n have h₂ := U_eq_X_mul_U_add_T R (n + 1) have h₃ := U_add_two R n linear_combination (norm := ring_nf) h₃ - h₂ + (X:R[X]) * h₁ #align polynomial.chebyshev.T_eq_X_mul_T_sub_pol_U Polynomial.Chebyshev.T_eq_X_mul_T_sub_pol_U theorem one_sub_X_sq_mul_U_eq_pol_in_T (n : ℤ) : (1 - X ^ 2) * U R n = X * T R (n + 1) - T R (n + 2) := by linear_combination T_eq_X_mul_T_sub_pol_U R n #align polynomial.chebyshev.one_sub_X_sq_mul_U_eq_pol_in_T Polynomial.Chebyshev.one_sub_X_sq_mul_U_eq_pol_in_T variable {R S} @[simp] theorem map_T (f : R →+* S) (n : ℤ) : map f (T R n) = T S n := by induction n using Polynomial.Chebyshev.induct with | zero => simp | one => simp | add_two n ih1 ih2 => simp_rw [T_add_two, Polynomial.map_sub, Polynomial.map_mul, Polynomial.map_ofNat, map_X, ih1, ih2]; | neg_add_one n ih1 ih2 => simp_rw [T_sub_one, Polynomial.map_sub, Polynomial.map_mul, Polynomial.map_ofNat, map_X, ih1, ih2]; #align polynomial.chebyshev.map_T Polynomial.Chebyshev.map_T @[simp] theorem map_U (f : R →+* S) (n : ℤ) : map f (U R n) = U S n := by induction n using Polynomial.Chebyshev.induct with | zero => simp | one => simp | add_two n ih1 ih2 => simp_rw [U_add_two, Polynomial.map_sub, Polynomial.map_mul, Polynomial.map_ofNat, map_X, ih1, ih2]; | neg_add_one n ih1 ih2 => simp_rw [U_sub_one, Polynomial.map_sub, Polynomial.map_mul, Polynomial.map_ofNat, map_X, ih1, ih2]; #align polynomial.chebyshev.map_U Polynomial.Chebyshev.map_U theorem T_derivative_eq_U (n : ℤ) : derivative (T R n) = n * U R (n - 1) := by induction n using Polynomial.Chebyshev.induct with | zero => simp | one => simp [T_two, U_one, derivative_sub, derivative_one, derivative_mul, derivative_X_pow, add_mul] | add_two n ih1 ih2 => have h₁ := congr_arg derivative (T_add_two R n) have h₂ := U_sub_one R n have h₃ := T_eq_U_sub_X_mul_U R (n + 1) simp only [derivative_sub, derivative_mul, derivative_ofNat, derivative_X] at h₁ linear_combination (norm := (push_cast; ring_nf)) h₁ - ih2 + 2 * (X:R[X]) * ih1 + 2 * h₃ - n * h₂ | neg_add_one n ih1 ih2 => have h₁ := congr_arg derivative (T_sub_one R (-n)) have h₂ := U_sub_two R (-n) have h₃ := T_eq_U_sub_X_mul_U R (-n) simp only [derivative_sub, derivative_mul, derivative_ofNat, derivative_X] at h₁ linear_combination (norm := (push_cast; ring_nf)) -ih2 + 2 * (X:R[X]) * ih1 + h₁ + 2 * h₃ + (n + 1) * h₂ #align polynomial.chebyshev.T_derivative_eq_U Polynomial.Chebyshev.T_derivative_eq_U theorem one_sub_X_sq_mul_derivative_T_eq_poly_in_T (n : ℤ) : (1 - X ^ 2) * derivative (T R (n + 1)) = (n + 1 : R[X]) * (T R n - X * T R (n + 1)) := by have H₁ := one_sub_X_sq_mul_U_eq_pol_in_T R n have H₂ := T_derivative_eq_U (R := R) (n + 1) have h₁ := T_add_two R n linear_combination (norm := (push_cast; ring_nf)) (-n - 1) * h₁ + (-(X:R[X]) ^ 2 + 1) * H₂ + (n + 1) * H₁ #align polynomial.chebyshev.one_sub_X_sq_mul_derivative_T_eq_poly_in_T Polynomial.Chebyshev.one_sub_X_sq_mul_derivative_T_eq_poly_in_T theorem add_one_mul_T_eq_poly_in_U (n : ℤ) : ((n : R[X]) + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n) := by have h₁ := congr_arg derivative <| T_eq_X_mul_T_sub_pol_U R n simp only [derivative_sub, derivative_mul, derivative_X, derivative_one, derivative_X_pow, T_derivative_eq_U, C_eq_natCast] at h₁ have h₂ := T_eq_U_sub_X_mul_U R (n + 1) linear_combination (norm := (push_cast; ring_nf)) h₁ + (n + 2) * h₂ #align polynomial.chebyshev.add_one_mul_T_eq_poly_in_U Polynomial.Chebyshev.add_one_mul_T_eq_poly_in_U variable (R)
Mathlib/RingTheory/Polynomial/Chebyshev.lean
310
323
theorem mul_T (m k : ℤ) : 2 * T R m * T R k = T R (m + k) + T R (m - k) := by
induction k using Polynomial.Chebyshev.induct with | zero => simp [two_mul] | one => rw [T_add_one, T_one]; ring | add_two k ih1 ih2 => have h₁ := T_add_two R (m + k) have h₂ := T_sub_two R (m - k) have h₃ := T_add_two R k linear_combination (norm := ring_nf) 2 * T R m * h₃ - h₂ - h₁ - ih2 + 2 * (X:R[X]) * ih1 | neg_add_one k ih1 ih2 => have h₁ := T_add_two R (m + (-k - 1)) have h₂ := T_sub_two R (m - (-k - 1)) have h₃ := T_add_two R (-k - 1) linear_combination (norm := ring_nf) 2 * T R m * h₃ - h₂ - h₁ - ih2 + 2 * (X:R[X]) * ih1
import Mathlib.Analysis.Convex.Between import Mathlib.Analysis.Normed.Group.AddTorsor import Mathlib.Geometry.Euclidean.Angle.Unoriented.Basic import Mathlib.Analysis.NormedSpace.AffineIsometry #align_import geometry.euclidean.angle.unoriented.affine from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" noncomputable section open Real RealInnerProductSpace namespace EuclideanGeometry open InnerProductGeometry variable {V P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P] {p p₀ p₁ p₂ : P} nonrec def angle (p1 p2 p3 : P) : ℝ := angle (p1 -ᵥ p2 : V) (p3 -ᵥ p2) #align euclidean_geometry.angle EuclideanGeometry.angle @[inherit_doc] scoped notation "∠" => EuclideanGeometry.angle theorem continuousAt_angle {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 (InnerProductGeometry.continuousAt_angle hf1 hf2).comp ((continuous_fst.vsub continuous_snd.fst).prod_mk (continuous_snd.snd.vsub continuous_snd.fst)).continuousAt #align euclidean_geometry.continuous_at_angle EuclideanGeometry.continuousAt_angle @[simp] theorem _root_.AffineIsometry.angle_map {V₂ P₂ : Type*} [NormedAddCommGroup V₂] [InnerProductSpace ℝ V₂] [MetricSpace P₂] [NormedAddTorsor V₂ P₂] (f : P →ᵃⁱ[ℝ] P₂) (p₁ p₂ p₃ : P) : ∠ (f p₁) (f p₂) (f p₃) = ∠ p₁ p₂ p₃ := by simp_rw [angle, ← AffineIsometry.map_vsub, LinearIsometry.angle_map] #align affine_isometry.angle_map AffineIsometry.angle_map @[simp, norm_cast] theorem _root_.AffineSubspace.angle_coe {s : AffineSubspace ℝ P} (p₁ p₂ p₃ : s) : haveI : Nonempty s := ⟨p₁⟩ ∠ (p₁ : P) (p₂ : P) (p₃ : P) = ∠ p₁ p₂ p₃ := haveI : Nonempty s := ⟨p₁⟩ s.subtypeₐᵢ.angle_map p₁ p₂ p₃ #align affine_subspace.angle_coe AffineSubspace.angle_coe @[simp] theorem angle_const_vadd (v : V) (p₁ p₂ p₃ : P) : ∠ (v +ᵥ p₁) (v +ᵥ p₂) (v +ᵥ p₃) = ∠ p₁ p₂ p₃ := (AffineIsometryEquiv.constVAdd ℝ P v).toAffineIsometry.angle_map _ _ _ #align euclidean_geometry.angle_const_vadd EuclideanGeometry.angle_const_vadd @[simp] theorem angle_vadd_const (v₁ v₂ v₃ : V) (p : P) : ∠ (v₁ +ᵥ p) (v₂ +ᵥ p) (v₃ +ᵥ p) = ∠ v₁ v₂ v₃ := (AffineIsometryEquiv.vaddConst ℝ p).toAffineIsometry.angle_map _ _ _ #align euclidean_geometry.angle_vadd_const EuclideanGeometry.angle_vadd_const @[simp] theorem angle_const_vsub (p p₁ p₂ p₃ : P) : ∠ (p -ᵥ p₁) (p -ᵥ p₂) (p -ᵥ p₃) = ∠ p₁ p₂ p₃ := (AffineIsometryEquiv.constVSub ℝ p).toAffineIsometry.angle_map _ _ _ #align euclidean_geometry.angle_const_vsub EuclideanGeometry.angle_const_vsub @[simp] theorem angle_vsub_const (p₁ p₂ p₃ p : P) : ∠ (p₁ -ᵥ p) (p₂ -ᵥ p) (p₃ -ᵥ p) = ∠ p₁ p₂ p₃ := (AffineIsometryEquiv.vaddConst ℝ p).symm.toAffineIsometry.angle_map _ _ _ #align euclidean_geometry.angle_vsub_const EuclideanGeometry.angle_vsub_const @[simp] theorem angle_add_const (v₁ v₂ v₃ : V) (v : V) : ∠ (v₁ + v) (v₂ + v) (v₃ + v) = ∠ v₁ v₂ v₃ := angle_vadd_const _ _ _ _ #align euclidean_geometry.angle_add_const EuclideanGeometry.angle_add_const @[simp] theorem angle_const_add (v : V) (v₁ v₂ v₃ : V) : ∠ (v + v₁) (v + v₂) (v + v₃) = ∠ v₁ v₂ v₃ := angle_const_vadd _ _ _ _ #align euclidean_geometry.angle_const_add EuclideanGeometry.angle_const_add @[simp] theorem angle_sub_const (v₁ v₂ v₃ : V) (v : V) : ∠ (v₁ - v) (v₂ - v) (v₃ - v) = ∠ v₁ v₂ v₃ := by simpa only [vsub_eq_sub] using angle_vsub_const v₁ v₂ v₃ v #align euclidean_geometry.angle_sub_const EuclideanGeometry.angle_sub_const @[simp] theorem angle_const_sub (v : V) (v₁ v₂ v₃ : V) : ∠ (v - v₁) (v - v₂) (v - v₃) = ∠ v₁ v₂ v₃ := by simpa only [vsub_eq_sub] using angle_const_vsub v v₁ v₂ v₃ #align euclidean_geometry.angle_const_sub EuclideanGeometry.angle_const_sub @[simp] theorem angle_neg (v₁ v₂ v₃ : V) : ∠ (-v₁) (-v₂) (-v₃) = ∠ v₁ v₂ v₃ := by simpa only [zero_sub] using angle_const_sub 0 v₁ v₂ v₃ #align euclidean_geometry.angle_neg EuclideanGeometry.angle_neg nonrec theorem angle_comm (p1 p2 p3 : P) : ∠ p1 p2 p3 = ∠ p3 p2 p1 := angle_comm _ _ #align euclidean_geometry.angle_comm EuclideanGeometry.angle_comm nonrec theorem angle_nonneg (p1 p2 p3 : P) : 0 ≤ ∠ p1 p2 p3 := angle_nonneg _ _ #align euclidean_geometry.angle_nonneg EuclideanGeometry.angle_nonneg nonrec theorem angle_le_pi (p1 p2 p3 : P) : ∠ p1 p2 p3 ≤ π := angle_le_pi _ _ #align euclidean_geometry.angle_le_pi EuclideanGeometry.angle_le_pi @[simp] lemma angle_self_left (p₀ p : P) : ∠ p₀ p₀ p = π / 2 := by unfold angle rw [vsub_self] exact angle_zero_left _ #align euclidean_geometry.angle_eq_left EuclideanGeometry.angle_self_left @[simp] lemma angle_self_right (p₀ p : P) : ∠ p p₀ p₀ = π / 2 := by rw [angle_comm, angle_self_left] #align euclidean_geometry.angle_eq_right EuclideanGeometry.angle_self_right theorem angle_self_of_ne (h : p ≠ p₀) : ∠ p p₀ p = 0 := angle_self $ vsub_ne_zero.2 h #align euclidean_geometry.angle_eq_of_ne EuclideanGeometry.angle_self_of_ne @[deprecated (since := "2024-02-14")] alias angle_eq_left := angle_self_left @[deprecated (since := "2024-02-14")] alias angle_eq_right := angle_self_right @[deprecated (since := "2024-02-14")] alias angle_eq_of_ne := angle_self_of_ne theorem angle_eq_zero_of_angle_eq_pi_left {p1 p2 p3 : P} (h : ∠ p1 p2 p3 = π) : ∠ p2 p1 p3 = 0 := by unfold angle at h rw [angle_eq_pi_iff] at h rcases h with ⟨hp1p2, ⟨r, ⟨hr, hpr⟩⟩⟩ unfold angle rw [angle_eq_zero_iff] rw [← neg_vsub_eq_vsub_rev, neg_ne_zero] at hp1p2 use hp1p2, -r + 1, add_pos (neg_pos_of_neg hr) zero_lt_one rw [add_smul, ← neg_vsub_eq_vsub_rev p1 p2, smul_neg] simp [← hpr] #align euclidean_geometry.angle_eq_zero_of_angle_eq_pi_left EuclideanGeometry.angle_eq_zero_of_angle_eq_pi_left theorem angle_eq_zero_of_angle_eq_pi_right {p1 p2 p3 : P} (h : ∠ p1 p2 p3 = π) : ∠ p2 p3 p1 = 0 := by rw [angle_comm] at h exact angle_eq_zero_of_angle_eq_pi_left h #align euclidean_geometry.angle_eq_zero_of_angle_eq_pi_right EuclideanGeometry.angle_eq_zero_of_angle_eq_pi_right theorem angle_eq_angle_of_angle_eq_pi (p1 : P) {p2 p3 p4 : P} (h : ∠ p2 p3 p4 = π) : ∠ p1 p2 p3 = ∠ p1 p2 p4 := by unfold angle at * rcases angle_eq_pi_iff.1 h with ⟨_, ⟨r, ⟨hr, hpr⟩⟩⟩ rw [eq_comm] convert angle_smul_right_of_pos (p1 -ᵥ p2) (p3 -ᵥ p2) (add_pos (neg_pos_of_neg hr) zero_lt_one) rw [add_smul, ← neg_vsub_eq_vsub_rev p2 p3, smul_neg, neg_smul, ← hpr] simp #align euclidean_geometry.angle_eq_angle_of_angle_eq_pi EuclideanGeometry.angle_eq_angle_of_angle_eq_pi nonrec theorem angle_add_angle_eq_pi_of_angle_eq_pi (p1 : P) {p2 p3 p4 : P} (h : ∠ p2 p3 p4 = π) : ∠ p1 p3 p2 + ∠ p1 p3 p4 = π := by unfold angle at h rw [angle_comm p1 p3 p2, angle_comm p1 p3 p4] unfold angle exact angle_add_angle_eq_pi_of_angle_eq_pi _ h #align euclidean_geometry.angle_add_angle_eq_pi_of_angle_eq_pi EuclideanGeometry.angle_add_angle_eq_pi_of_angle_eq_pi theorem angle_eq_angle_of_angle_eq_pi_of_angle_eq_pi {p1 p2 p3 p4 p5 : P} (hapc : ∠ p1 p5 p3 = π) (hbpd : ∠ p2 p5 p4 = π) : ∠ p1 p5 p2 = ∠ p3 p5 p4 := by linarith [angle_add_angle_eq_pi_of_angle_eq_pi p1 hbpd, angle_comm p4 p5 p1, angle_add_angle_eq_pi_of_angle_eq_pi p4 hapc, angle_comm p4 p5 p3] #align euclidean_geometry.angle_eq_angle_of_angle_eq_pi_of_angle_eq_pi EuclideanGeometry.angle_eq_angle_of_angle_eq_pi_of_angle_eq_pi theorem left_dist_ne_zero_of_angle_eq_pi {p1 p2 p3 : P} (h : ∠ p1 p2 p3 = π) : dist p1 p2 ≠ 0 := by by_contra heq rw [dist_eq_zero] at heq rw [heq, angle_self_left] at h exact Real.pi_ne_zero (by linarith) #align euclidean_geometry.left_dist_ne_zero_of_angle_eq_pi EuclideanGeometry.left_dist_ne_zero_of_angle_eq_pi theorem right_dist_ne_zero_of_angle_eq_pi {p1 p2 p3 : P} (h : ∠ p1 p2 p3 = π) : dist p3 p2 ≠ 0 := left_dist_ne_zero_of_angle_eq_pi <| (angle_comm _ _ _).trans h #align euclidean_geometry.right_dist_ne_zero_of_angle_eq_pi EuclideanGeometry.right_dist_ne_zero_of_angle_eq_pi theorem dist_eq_add_dist_of_angle_eq_pi {p1 p2 p3 : P} (h : ∠ p1 p2 p3 = π) : dist p1 p3 = dist p1 p2 + dist p3 p2 := by rw [dist_eq_norm_vsub V, dist_eq_norm_vsub V, dist_eq_norm_vsub V, ← vsub_sub_vsub_cancel_right] exact norm_sub_eq_add_norm_of_angle_eq_pi h #align euclidean_geometry.dist_eq_add_dist_of_angle_eq_pi EuclideanGeometry.dist_eq_add_dist_of_angle_eq_pi theorem dist_eq_add_dist_iff_angle_eq_pi {p1 p2 p3 : P} (hp1p2 : p1 ≠ p2) (hp3p2 : p3 ≠ p2) : dist p1 p3 = dist p1 p2 + dist p3 p2 ↔ ∠ p1 p2 p3 = π := by rw [dist_eq_norm_vsub V, dist_eq_norm_vsub V, dist_eq_norm_vsub V, ← vsub_sub_vsub_cancel_right] exact norm_sub_eq_add_norm_iff_angle_eq_pi (fun he => hp1p2 (vsub_eq_zero_iff_eq.1 he)) fun he => hp3p2 (vsub_eq_zero_iff_eq.1 he) #align euclidean_geometry.dist_eq_add_dist_iff_angle_eq_pi EuclideanGeometry.dist_eq_add_dist_iff_angle_eq_pi theorem dist_eq_abs_sub_dist_of_angle_eq_zero {p1 p2 p3 : P} (h : ∠ p1 p2 p3 = 0) : dist p1 p3 = |dist p1 p2 - dist p3 p2| := by rw [dist_eq_norm_vsub V, dist_eq_norm_vsub V, dist_eq_norm_vsub V, ← vsub_sub_vsub_cancel_right] exact norm_sub_eq_abs_sub_norm_of_angle_eq_zero h #align euclidean_geometry.dist_eq_abs_sub_dist_of_angle_eq_zero EuclideanGeometry.dist_eq_abs_sub_dist_of_angle_eq_zero theorem dist_eq_abs_sub_dist_iff_angle_eq_zero {p1 p2 p3 : P} (hp1p2 : p1 ≠ p2) (hp3p2 : p3 ≠ p2) : dist p1 p3 = |dist p1 p2 - dist p3 p2| ↔ ∠ p1 p2 p3 = 0 := by rw [dist_eq_norm_vsub V, dist_eq_norm_vsub V, dist_eq_norm_vsub V, ← vsub_sub_vsub_cancel_right] exact norm_sub_eq_abs_sub_norm_iff_angle_eq_zero (fun he => hp1p2 (vsub_eq_zero_iff_eq.1 he)) fun he => hp3p2 (vsub_eq_zero_iff_eq.1 he) #align euclidean_geometry.dist_eq_abs_sub_dist_iff_angle_eq_zero EuclideanGeometry.dist_eq_abs_sub_dist_iff_angle_eq_zero theorem angle_midpoint_eq_pi (p1 p2 : P) (hp1p2 : p1 ≠ p2) : ∠ p1 (midpoint ℝ p1 p2) p2 = π := by simp only [angle, left_vsub_midpoint, invOf_eq_inv, right_vsub_midpoint, inv_pos, zero_lt_two, angle_smul_right_of_pos, angle_smul_left_of_pos] rw [← neg_vsub_eq_vsub_rev p1 p2] apply angle_self_neg_of_nonzero simpa only [ne_eq, vsub_eq_zero_iff_eq] #align euclidean_geometry.angle_midpoint_eq_pi EuclideanGeometry.angle_midpoint_eq_pi theorem angle_left_midpoint_eq_pi_div_two_of_dist_eq {p1 p2 p3 : P} (h : dist p3 p1 = dist p3 p2) : ∠ p3 (midpoint ℝ p1 p2) p1 = π / 2 := by let m : P := midpoint ℝ p1 p2 have h1 : p3 -ᵥ p1 = p3 -ᵥ m - (p1 -ᵥ m) := (vsub_sub_vsub_cancel_right p3 p1 m).symm have h2 : p3 -ᵥ p2 = p3 -ᵥ m + (p1 -ᵥ m) := by rw [left_vsub_midpoint, ← midpoint_vsub_right, vsub_add_vsub_cancel] rw [dist_eq_norm_vsub V p3 p1, dist_eq_norm_vsub V p3 p2, h1, h2] at h exact (norm_add_eq_norm_sub_iff_angle_eq_pi_div_two (p3 -ᵥ m) (p1 -ᵥ m)).mp h.symm #align euclidean_geometry.angle_left_midpoint_eq_pi_div_two_of_dist_eq EuclideanGeometry.angle_left_midpoint_eq_pi_div_two_of_dist_eq
Mathlib/Geometry/Euclidean/Angle/Unoriented/Affine.lean
280
282
theorem angle_right_midpoint_eq_pi_div_two_of_dist_eq {p1 p2 p3 : P} (h : dist p3 p1 = dist p3 p2) : ∠ p3 (midpoint ℝ p1 p2) p2 = π / 2 := by
rw [midpoint_comm p1 p2, angle_left_midpoint_eq_pi_div_two_of_dist_eq h.symm]
import Mathlib.GroupTheory.Coprod.Basic import Mathlib.GroupTheory.Complement open Monoid Coprod Multiplicative Subgroup Function def HNNExtension.con (G : Type*) [Group G] (A B : Subgroup G) (φ : A ≃* B) : Con (G ∗ Multiplicative ℤ) := conGen (fun x y => ∃ (a : A), x = inr (ofAdd 1) * inl (a : G) ∧ y = inl (φ a : G) * inr (ofAdd 1)) def HNNExtension (G : Type*) [Group G] (A B : Subgroup G) (φ : A ≃* B) : Type _ := (HNNExtension.con G A B φ).Quotient variable {G : Type*} [Group G] {A B : Subgroup G} {φ : A ≃* B} {H : Type*} [Group H] {M : Type*} [Monoid M] instance : Group (HNNExtension G A B φ) := by delta HNNExtension; infer_instance namespace HNNExtension def of : G →* HNNExtension G A B φ := (HNNExtension.con G A B φ).mk'.comp inl def t : HNNExtension G A B φ := (HNNExtension.con G A B φ).mk'.comp inr (ofAdd 1) theorem t_mul_of (a : A) : t * (of (a : G) : HNNExtension G A B φ) = of (φ a : G) * t := (Con.eq _).2 <| ConGen.Rel.of _ _ <| ⟨a, by simp⟩ theorem of_mul_t (b : B) : (of (b : G) : HNNExtension G A B φ) * t = t * of (φ.symm b : G) := by rw [t_mul_of]; simp theorem equiv_eq_conj (a : A) : (of (φ a : G) : HNNExtension G A B φ) = t * of (a : G) * t⁻¹ := by rw [t_mul_of]; simp theorem equiv_symm_eq_conj (b : B) : (of (φ.symm b : G) : HNNExtension G A B φ) = t⁻¹ * of (b : G) * t := by rw [mul_assoc, of_mul_t]; simp theorem inv_t_mul_of (b : B) : t⁻¹ * (of (b : G) : HNNExtension G A B φ) = of (φ.symm b : G) * t⁻¹ := by rw [equiv_symm_eq_conj]; simp theorem of_mul_inv_t (a : A) : (of (a : G) : HNNExtension G A B φ) * t⁻¹ = t⁻¹ * of (φ a : G) := by rw [equiv_eq_conj]; simp [mul_assoc] def lift (f : G →* H) (x : H) (hx : ∀ a : A, x * f ↑a = f (φ a : G) * x) : HNNExtension G A B φ →* H := Con.lift _ (Coprod.lift f (zpowersHom H x)) (Con.conGen_le <| by rintro _ _ ⟨a, rfl, rfl⟩ simp [hx]) @[simp] theorem lift_t (f : G →* H) (x : H) (hx : ∀ a : A, x * f ↑a = f (φ a : G) * x) : lift f x hx t = x := by delta HNNExtension; simp [lift, t] @[simp] theorem lift_of (f : G →* H) (x : H) (hx : ∀ a : A, x * f ↑a = f (φ a : G) * x) (g : G) : lift f x hx (of g) = f g := by delta HNNExtension; simp [lift, of] @[ext high] theorem hom_ext {f g : HNNExtension G A B φ →* M} (hg : f.comp of = g.comp of) (ht : f t = g t) : f = g := (MonoidHom.cancel_right Con.mk'_surjective).mp <| Coprod.hom_ext hg (MonoidHom.ext_mint ht) @[elab_as_elim] theorem induction_on {motive : HNNExtension G A B φ → Prop} (x : HNNExtension G A B φ) (of : ∀ g, motive (of g)) (t : motive t) (mul : ∀ x y, motive x → motive y → motive (x * y)) (inv : ∀ x, motive x → motive x⁻¹) : motive x := by let S : Subgroup (HNNExtension G A B φ) := { carrier := setOf motive one_mem' := by simpa using of 1 mul_mem' := mul _ _ inv_mem' := inv _ } let f : HNNExtension G A B φ →* S := lift (HNNExtension.of.codRestrict S of) ⟨HNNExtension.t, t⟩ (by intro a; ext; simp [equiv_eq_conj, mul_assoc]) have hf : S.subtype.comp f = MonoidHom.id _ := hom_ext (by ext; simp [f]) (by simp [f]) show motive (MonoidHom.id _ x) rw [← hf] exact (f x).2 variable (A B φ) def toSubgroup (u : ℤˣ) : Subgroup G := if u = 1 then A else B @[simp] theorem toSubgroup_one : toSubgroup A B 1 = A := rfl @[simp] theorem toSubgroup_neg_one : toSubgroup A B (-1) = B := rfl variable {A B} def toSubgroupEquiv (u : ℤˣ) : toSubgroup A B u ≃* toSubgroup A B (-u) := if hu : u = 1 then hu ▸ φ else by convert φ.symm <;> cases Int.units_eq_one_or u <;> simp_all @[simp] theorem toSubgroupEquiv_one : toSubgroupEquiv φ 1 = φ := rfl @[simp] theorem toSubgroupEquiv_neg_one : toSubgroupEquiv φ (-1) = φ.symm := rfl @[simp] theorem toSubgroupEquiv_neg_apply (u : ℤˣ) (a : toSubgroup A B u) : (toSubgroupEquiv φ (-u) (toSubgroupEquiv φ u a) : G) = a := by rcases Int.units_eq_one_or u with rfl | rfl · -- This used to be `simp` before leanprover/lean4#2644 simp; erw [MulEquiv.symm_apply_apply] · simp only [toSubgroup_neg_one, toSubgroupEquiv_neg_one, SetLike.coe_eq_coe] exact φ.apply_symm_apply a namespace NormalWord variable (G A B) structure TransversalPair : Type _ := set : ℤˣ → Set G compl : ∀ u, IsComplement (toSubgroup A B u : Subgroup G) (set u) instance TransversalPair.nonempty : Nonempty (TransversalPair G A B) := by choose t ht using fun u ↦ (toSubgroup A B u).exists_right_transversal 1 exact ⟨⟨t, fun i ↦ (ht i).1⟩⟩ structure ReducedWord : Type _ := head : G toList : List (ℤˣ × G) chain : toList.Chain' (fun a b => a.2 ∈ toSubgroup A B a.1 → a.1 = b.1) @[simps] def ReducedWord.empty : ReducedWord G A B := { head := 1 toList := [] chain := List.chain'_nil } variable {G A B} def ReducedWord.prod : ReducedWord G A B → HNNExtension G A B φ := fun w => of w.head * (w.toList.map (fun x => t ^ (x.1 : ℤ) * of x.2)).prod structure _root_.HNNExtension.NormalWord (d : TransversalPair G A B) extends ReducedWord G A B : Type _ := mem_set : ∀ (u : ℤˣ) (g : G), (u, g) ∈ toList → g ∈ d.set u variable {d : TransversalPair G A B} @[ext] theorem ext {w w' : NormalWord d} (h1 : w.head = w'.head) (h2 : w.toList = w'.toList): w = w' := by rcases w with ⟨⟨⟩, _⟩; cases w'; simp_all @[simps] def empty : NormalWord d := { head := 1 toList := [] mem_set := by simp chain := List.chain'_nil } @[simps] def ofGroup (g : G) : NormalWord d := { head := g toList := [] mem_set := by simp chain := List.chain'_nil } instance : Inhabited (NormalWord d) := ⟨empty⟩ instance : MulAction G (NormalWord d) := { smul := fun g w => { w with head := g * w.head } one_smul := by simp [instHSMul] mul_smul := by simp [instHSMul, mul_assoc] } theorem group_smul_def (g : G) (w : NormalWord d) : g • w = { w with head := g * w.head } := rfl @[simp] theorem group_smul_head (g : G) (w : NormalWord d) : (g • w).head = g * w.head := rfl @[simp] theorem group_smul_toList (g : G) (w : NormalWord d) : (g • w).toList = w.toList := rfl instance : FaithfulSMul G (NormalWord d) := ⟨by simp [group_smul_def]⟩ @[simps] def cons (g : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u) (h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?, w.head ∈ toSubgroup A B u → u = u') : NormalWord d := { head := g, toList := (u, w.head) :: w.toList, mem_set := by intro u' g' h' simp only [List.mem_cons, Prod.mk.injEq] at h' rcases h' with ⟨rfl, rfl⟩ | h' · exact h1 · exact w.mem_set _ _ h' chain := by refine List.chain'_cons'.2 ⟨?_, w.chain⟩ rintro ⟨u', g'⟩ hu' hw1 exact h2 _ (by simp_all) hw1 } @[elab_as_elim] def consRecOn {motive : NormalWord d → Sort*} (w : NormalWord d) (ofGroup : ∀g, motive (ofGroup g)) (cons : ∀ (g : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u) (h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?, w.head ∈ toSubgroup A B u → u = u'), motive w → motive (cons g u w h1 h2)) : motive w := by rcases w with ⟨⟨g, l, chain⟩, mem_set⟩ induction l generalizing g with | nil => exact ofGroup _ | cons a l ih => exact cons g a.1 { head := a.2 toList := l mem_set := fun _ _ h => mem_set _ _ (List.mem_cons_of_mem _ h), chain := (List.chain'_cons'.1 chain).2 } (mem_set a.1 a.2 (List.mem_cons_self _ _)) (by simpa using (List.chain'_cons'.1 chain).1) (ih _ _ _) @[simp] theorem consRecOn_ofGroup {motive : NormalWord d → Sort*} (g : G) (ofGroup : ∀g, motive (ofGroup g)) (cons : ∀ (g : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u) (h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?, w.head ∈ toSubgroup A B u → u = u'), motive w → motive (cons g u w h1 h2)) : consRecOn (.ofGroup g) ofGroup cons = ofGroup g := rfl @[simp] theorem consRecOn_cons {motive : NormalWord d → Sort*} (g : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u) (h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?, w.head ∈ toSubgroup A B u → u = u') (ofGroup : ∀g, motive (ofGroup g)) (cons : ∀ (g : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u) (h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?, w.head ∈ toSubgroup A B u → u = u'), motive w → motive (cons g u w h1 h2)) : consRecOn (.cons g u w h1 h2) ofGroup cons = cons g u w h1 h2 (consRecOn w ofGroup cons) := rfl @[simp] theorem smul_cons (g₁ g₂ : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u) (h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?, w.head ∈ toSubgroup A B u → u = u') : g₁ • cons g₂ u w h1 h2 = cons (g₁ * g₂) u w h1 h2 := rfl @[simp] theorem smul_ofGroup (g₁ g₂ : G) : g₁ • (ofGroup g₂ : NormalWord d) = ofGroup (g₁ * g₂) := rfl variable (d) noncomputable def unitsSMulGroup (u : ℤˣ) (g : G) : (toSubgroup A B (-u)) × d.set u := let g' := (d.compl u).equiv g (toSubgroupEquiv φ u g'.1, g'.2) theorem unitsSMulGroup_snd (u : ℤˣ) (g : G) : (unitsSMulGroup φ d u g).2 = ((d.compl u).equiv g).2 := by rcases Int.units_eq_one_or u with rfl | rfl <;> rfl variable {d} [DecidableEq G] def Cancels (u : ℤˣ) (w : NormalWord d) : Prop := (w.head ∈ (toSubgroup A B u : Subgroup G)) ∧ w.toList.head?.map Prod.fst = some (-u) def unitsSMulWithCancel (u : ℤˣ) (w : NormalWord d) : Cancels u w → NormalWord d := consRecOn w (by simp [Cancels, ofGroup]; tauto) (fun g u' w h1 h2 _ can => (toSubgroupEquiv φ u ⟨g, can.1⟩ : G) • w) noncomputable def unitsSMul (u : ℤˣ) (w : NormalWord d) : NormalWord d := letI := Classical.dec if h : Cancels u w then unitsSMulWithCancel φ u w h else let g' := unitsSMulGroup φ d u w.head cons g'.1 u ((g'.2 * w.head⁻¹ : G) • w) (by simp) (by simp only [g', group_smul_toList, Option.mem_def, Option.map_eq_some', Prod.exists, exists_and_right, exists_eq_right, group_smul_head, inv_mul_cancel_right, forall_exists_index, unitsSMulGroup] simp only [Cancels, Option.map_eq_some', Prod.exists, exists_and_right, exists_eq_right, not_and, not_exists] at h intro u' x hx hmem have : w.head ∈ toSubgroup A B u := by have := (d.compl u).rightCosetEquivalence_equiv_snd w.head rw [RightCosetEquivalence, rightCoset_eq_iff, mul_mem_cancel_left hmem] at this simp_all have := h this x simp_all [Int.units_ne_iff_eq_neg]) theorem not_cancels_of_cons_hyp (u : ℤˣ) (w : NormalWord d) (h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?, w.head ∈ toSubgroup A B u → u = u') : ¬ Cancels u w := by simp only [Cancels, Option.map_eq_some', Prod.exists, exists_and_right, exists_eq_right, not_and, not_exists] intro hw x hx rw [hx] at h2 simpa using h2 (-u) rfl hw theorem unitsSMul_cancels_iff (u : ℤˣ) (w : NormalWord d) : Cancels (-u) (unitsSMul φ u w) ↔ ¬ Cancels u w := by by_cases h : Cancels u w · simp only [unitsSMul, h, dite_true, not_true_eq_false, iff_false] induction w using consRecOn with | ofGroup => simp [Cancels, unitsSMulWithCancel] | cons g u' w h1 h2 _ => intro hc apply not_cancels_of_cons_hyp _ _ h2 simp only [Cancels, cons_head, cons_toList, List.head?_cons, Option.map_some', Option.some.injEq] at h cases h.2 simpa [Cancels, unitsSMulWithCancel, Subgroup.mul_mem_cancel_left] using hc · simp only [unitsSMul, dif_neg h] simpa [Cancels] using h theorem unitsSMul_neg (u : ℤˣ) (w : NormalWord d) : unitsSMul φ (-u) (unitsSMul φ u w) = w := by rw [unitsSMul] split_ifs with hcan · have hncan : ¬ Cancels u w := (unitsSMul_cancels_iff _ _ _).1 hcan unfold unitsSMul simp only [dif_neg hncan] simp [unitsSMulWithCancel, unitsSMulGroup, (d.compl u).equiv_snd_eq_inv_mul] -- This used to be the end of the proof before leanprover/lean4#2644 erw [(d.compl u).equiv_snd_eq_inv_mul] simp · have hcan2 : Cancels u w := not_not.1 (mt (unitsSMul_cancels_iff _ _ _).2 hcan) unfold unitsSMul at hcan ⊢ simp only [dif_pos hcan2] at hcan ⊢ cases w using consRecOn with | ofGroup => simp [Cancels] at hcan2 | cons g u' w h1 h2 ih => clear ih simp only [unitsSMulGroup, SetLike.coe_sort_coe, unitsSMulWithCancel, id_eq, consRecOn_cons, group_smul_head, IsComplement.equiv_mul_left, map_mul, Submonoid.coe_mul, coe_toSubmonoid, toSubgroupEquiv_neg_apply, mul_inv_rev] cases hcan2.2 have : ((d.compl (-u)).equiv w.head).1 = 1 := (d.compl (-u)).equiv_fst_eq_one_of_mem_of_one_mem _ h1 apply NormalWord.ext · -- This used to `simp [this]` before leanprover/lean4#2644 dsimp conv_lhs => erw [IsComplement.equiv_mul_left] rw [map_mul, Submonoid.coe_mul, toSubgroupEquiv_neg_apply, this] simp · -- The next two lines were not needed before leanprover/lean4#2644 dsimp conv_lhs => erw [IsComplement.equiv_mul_left] simp [mul_assoc, Units.ext_iff, (d.compl (-u)).equiv_snd_eq_inv_mul, this] -- The next two lines were not needed before leanprover/lean4#2644 erw [(d.compl (-u)).equiv_snd_eq_inv_mul, this] simp @[simps] noncomputable def unitsSMulEquiv : NormalWord d ≃ NormalWord d := { toFun := unitsSMul φ 1 invFun := unitsSMul φ (-1), left_inv := fun _ => by rw [unitsSMul_neg] right_inv := fun w => by convert unitsSMul_neg _ _ w; simp } theorem unitsSMul_one_group_smul (g : A) (w : NormalWord d) : unitsSMul φ 1 ((g : G) • w) = (φ g : G) • (unitsSMul φ 1 w) := by unfold unitsSMul have : Cancels 1 ((g : G) • w) ↔ Cancels 1 w := by simp [Cancels, Subgroup.mul_mem_cancel_left] by_cases hcan : Cancels 1 w · simp [unitsSMulWithCancel, dif_pos (this.2 hcan), dif_pos hcan] cases w using consRecOn · simp [Cancels] at hcan · simp only [smul_cons, consRecOn_cons, mul_smul] rw [← mul_smul, ← Subgroup.coe_mul, ← map_mul φ] rfl · rw [dif_neg (mt this.1 hcan), dif_neg hcan] simp [← mul_smul, mul_assoc, unitsSMulGroup] -- This used to be the end of the proof before leanprover/lean4#2644 dsimp congr 1 · conv_lhs => erw [IsComplement.equiv_mul_left] simp? says simp only [toSubgroup_one, SetLike.coe_sort_coe, map_mul, Submonoid.coe_mul, coe_toSubmonoid] conv_lhs => erw [IsComplement.equiv_mul_left] rfl noncomputable instance : MulAction (HNNExtension G A B φ) (NormalWord d) := MulAction.ofEndHom <| (MulAction.toEndHom (M := Equiv.Perm (NormalWord d))).comp (HNNExtension.lift (MulAction.toPermHom _ _) (unitsSMulEquiv φ) <| by intro a ext : 1 simp [unitsSMul_one_group_smul]) @[simp] theorem prod_group_smul (g : G) (w : NormalWord d) : (g • w).prod φ = of g * (w.prod φ) := by simp [ReducedWord.prod, smul_def, mul_assoc] theorem of_smul_eq_smul (g : G) (w : NormalWord d) : (of g : HNNExtension G A B φ) • w = g • w := by simp [instHSMul, SMul.smul, MulAction.toEndHom] theorem t_smul_eq_unitsSMul (w : NormalWord d) : (t : HNNExtension G A B φ) • w = unitsSMul φ 1 w := by simp [instHSMul, SMul.smul, MulAction.toEndHom] theorem t_pow_smul_eq_unitsSMul (u : ℤˣ) (w : NormalWord d) : (t ^ (u : ℤ) : HNNExtension G A B φ) • w = unitsSMul φ u w := by rcases Int.units_eq_one_or u with (rfl | rfl) <;> simp [instHSMul, SMul.smul, MulAction.toEndHom, Equiv.Perm.inv_def] @[simp]
Mathlib/GroupTheory/HNNExtension.lean
508
512
theorem prod_cons (g : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u) (h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?, w.head ∈ toSubgroup A B u → u = u') : (cons g u w h1 h2).prod φ = of g * (t ^ (u : ℤ) * w.prod φ) := by
simp [ReducedWord.prod, cons, smul_def, mul_assoc]
import Mathlib.CategoryTheory.Comma.StructuredArrow import Mathlib.CategoryTheory.IsConnected import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Terminal import Mathlib.CategoryTheory.Limits.Shapes.Types import Mathlib.CategoryTheory.Filtered.Basic import Mathlib.CategoryTheory.Limits.Yoneda import Mathlib.CategoryTheory.PUnit #align_import category_theory.limits.final from "leanprover-community/mathlib"@"8a318021995877a44630c898d0b2bc376fceef3b" noncomputable section universe v v₁ v₂ v₃ u₁ u₂ u₃ namespace CategoryTheory namespace Functor open Opposite open CategoryTheory.Limits section ArbitraryUniverse variable {C : Type u₁} [Category.{v₁} C] variable {D : Type u₂} [Category.{v₂} D] class Final (F : C ⥤ D) : Prop where out (d : D) : IsConnected (StructuredArrow d F) #align category_theory.functor.final CategoryTheory.Functor.Final attribute [instance] Final.out class Initial (F : C ⥤ D) : Prop where out (d : D) : IsConnected (CostructuredArrow F d) #align category_theory.functor.initial CategoryTheory.Functor.Initial attribute [instance] Initial.out instance final_op_of_initial (F : C ⥤ D) [Initial F] : Final F.op where out d := isConnected_of_equivalent (costructuredArrowOpEquivalence F (unop d)) #align category_theory.functor.final_op_of_initial CategoryTheory.Functor.final_op_of_initial instance initial_op_of_final (F : C ⥤ D) [Final F] : Initial F.op where out d := isConnected_of_equivalent (structuredArrowOpEquivalence F (unop d)) #align category_theory.functor.initial_op_of_final CategoryTheory.Functor.initial_op_of_final theorem final_of_initial_op (F : C ⥤ D) [Initial F.op] : Final F := { out := fun d => @isConnected_of_isConnected_op _ _ (isConnected_of_equivalent (structuredArrowOpEquivalence F d).symm) } #align category_theory.functor.final_of_initial_op CategoryTheory.Functor.final_of_initial_op theorem initial_of_final_op (F : C ⥤ D) [Final F.op] : Initial F := { out := fun d => @isConnected_of_isConnected_op _ _ (isConnected_of_equivalent (costructuredArrowOpEquivalence F d).symm) } #align category_theory.functor.initial_of_final_op CategoryTheory.Functor.initial_of_final_op theorem final_of_adjunction {L : C ⥤ D} {R : D ⥤ C} (adj : L ⊣ R) : Final R := { out := fun c => let u : StructuredArrow c R := StructuredArrow.mk (adj.unit.app c) @zigzag_isConnected _ _ ⟨u⟩ fun f g => Relation.ReflTransGen.trans (Relation.ReflTransGen.single (show Zag f u from Or.inr ⟨StructuredArrow.homMk ((adj.homEquiv c f.right).symm f.hom) (by simp [u])⟩)) (Relation.ReflTransGen.single (show Zag u g from Or.inl ⟨StructuredArrow.homMk ((adj.homEquiv c g.right).symm g.hom) (by simp [u])⟩)) } #align category_theory.functor.final_of_adjunction CategoryTheory.Functor.final_of_adjunction theorem initial_of_adjunction {L : C ⥤ D} {R : D ⥤ C} (adj : L ⊣ R) : Initial L := { out := fun d => let u : CostructuredArrow L d := CostructuredArrow.mk (adj.counit.app d) @zigzag_isConnected _ _ ⟨u⟩ fun f g => Relation.ReflTransGen.trans (Relation.ReflTransGen.single (show Zag f u from Or.inl ⟨CostructuredArrow.homMk (adj.homEquiv f.left d f.hom) (by simp [u])⟩)) (Relation.ReflTransGen.single (show Zag u g from Or.inr ⟨CostructuredArrow.homMk (adj.homEquiv g.left d g.hom) (by simp [u])⟩)) } #align category_theory.functor.initial_of_adjunction CategoryTheory.Functor.initial_of_adjunction instance (priority := 100) final_of_isRightAdjoint (F : C ⥤ D) [IsRightAdjoint F] : Final F := final_of_adjunction (Adjunction.ofIsRightAdjoint F) #align category_theory.functor.final_of_is_right_adjoint CategoryTheory.Functor.final_of_isRightAdjoint instance (priority := 100) initial_of_isLeftAdjoint (F : C ⥤ D) [IsLeftAdjoint F] : Initial F := initial_of_adjunction (Adjunction.ofIsLeftAdjoint F) #align category_theory.functor.initial_of_is_left_adjoint CategoryTheory.Functor.initial_of_isLeftAdjoint theorem final_of_natIso {F F' : C ⥤ D} [Final F] (i : F ≅ F') : Final F' where out _ := isConnected_of_equivalent (StructuredArrow.mapNatIso i) theorem final_natIso_iff {F F' : C ⥤ D} (i : F ≅ F') : Final F ↔ Final F' := ⟨fun _ => final_of_natIso i, fun _ => final_of_natIso i.symm⟩ theorem initial_of_natIso {F F' : C ⥤ D} [Initial F] (i : F ≅ F') : Initial F' where out _ := isConnected_of_equivalent (CostructuredArrow.mapNatIso i) theorem initial_natIso_iff {F F' : C ⥤ D} (i : F ≅ F') : Initial F ↔ Initial F' := ⟨fun _ => initial_of_natIso i, fun _ => initial_of_natIso i.symm⟩ section LocallySmall variable {C : Type v} [Category.{v} C] {D : Type u₁} [Category.{v} D] (F : C ⥤ D) namespace Final
Mathlib/CategoryTheory/Limits/Final.lean
386
404
theorem zigzag_of_eqvGen_quot_rel {F : C ⥤ D} {d : D} {f₁ f₂ : ΣX, d ⟶ F.obj X} (t : EqvGen (Types.Quot.Rel.{v, v} (F ⋙ coyoneda.obj (op d))) f₁ f₂) : Zigzag (StructuredArrow.mk f₁.2) (StructuredArrow.mk f₂.2) := by
induction t with | rel x y r => obtain ⟨f, w⟩ := r fconstructor swap · fconstructor left; fconstructor exact StructuredArrow.homMk f | refl => fconstructor | symm x y _ ih => apply zigzag_symmetric exact ih | trans x y z _ _ ih₁ ih₂ => apply Relation.ReflTransGen.trans · exact ih₁ · exact ih₂
import Mathlib.Analysis.InnerProductSpace.Dual #align_import analysis.inner_product_space.lax_milgram from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" noncomputable section open RCLike LinearMap ContinuousLinearMap InnerProductSpace open LinearMap (ker range) open RealInnerProductSpace NNReal universe u namespace IsCoercive variable {V : Type u} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [CompleteSpace V] variable {B : V →L[ℝ] V →L[ℝ] ℝ} local postfix:1024 "♯" => @continuousLinearMapOfBilin ℝ V _ _ _ _ theorem bounded_below (coercive : IsCoercive B) : ∃ C, 0 < C ∧ ∀ v, C * ‖v‖ ≤ ‖B♯ v‖ := by rcases coercive with ⟨C, C_ge_0, coercivity⟩ refine ⟨C, C_ge_0, ?_⟩ intro v by_cases h : 0 < ‖v‖ · refine (mul_le_mul_right h).mp ?_ calc C * ‖v‖ * ‖v‖ ≤ B v v := coercivity v _ = ⟪B♯ v, v⟫_ℝ := (continuousLinearMapOfBilin_apply B v v).symm _ ≤ ‖B♯ v‖ * ‖v‖ := real_inner_le_norm (B♯ v) v · have : v = 0 := by simpa using h simp [this] #align is_coercive.bounded_below IsCoercive.bounded_below theorem antilipschitz (coercive : IsCoercive B) : ∃ C : ℝ≥0, 0 < C ∧ AntilipschitzWith C B♯ := by rcases coercive.bounded_below with ⟨C, C_pos, below_bound⟩ refine ⟨C⁻¹.toNNReal, Real.toNNReal_pos.mpr (inv_pos.mpr C_pos), ?_⟩ refine ContinuousLinearMap.antilipschitz_of_bound B♯ ?_ simp_rw [Real.coe_toNNReal', max_eq_left_of_lt (inv_pos.mpr C_pos), ← inv_mul_le_iff (inv_pos.mpr C_pos)] simpa using below_bound #align is_coercive.antilipschitz IsCoercive.antilipschitz
Mathlib/Analysis/InnerProductSpace/LaxMilgram.lean
74
77
theorem ker_eq_bot (coercive : IsCoercive B) : ker B♯ = ⊥ := by
rw [LinearMapClass.ker_eq_bot] rcases coercive.antilipschitz with ⟨_, _, antilipschitz⟩ exact antilipschitz.injective
import Mathlib.Data.PFunctor.Univariate.Basic #align_import data.pfunctor.univariate.M from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" universe u v w open Nat Function open List variable (F : PFunctor.{u}) -- Porting note: the ♯ tactic is never used -- local prefix:0 "♯" => cast (by first |simp [*]|cc|solve_by_elim) namespace PFunctor namespace Approx inductive CofixA : ℕ → Type u | continue : CofixA 0 | intro {n} : ∀ a, (F.B a → CofixA n) → CofixA (succ n) #align pfunctor.approx.cofix_a PFunctor.Approx.CofixA protected def CofixA.default [Inhabited F.A] : ∀ n, CofixA F n | 0 => CofixA.continue | succ n => CofixA.intro default fun _ => CofixA.default n #align pfunctor.approx.cofix_a.default PFunctor.Approx.CofixA.default instance [Inhabited F.A] {n} : Inhabited (CofixA F n) := ⟨CofixA.default F n⟩ theorem cofixA_eq_zero : ∀ x y : CofixA F 0, x = y | CofixA.continue, CofixA.continue => rfl #align pfunctor.approx.cofix_a_eq_zero PFunctor.Approx.cofixA_eq_zero variable {F} def head' : ∀ {n}, CofixA F (succ n) → F.A | _, CofixA.intro i _ => i #align pfunctor.approx.head' PFunctor.Approx.head' def children' : ∀ {n} (x : CofixA F (succ n)), F.B (head' x) → CofixA F n | _, CofixA.intro _ f => f #align pfunctor.approx.children' PFunctor.Approx.children' theorem approx_eta {n : ℕ} (x : CofixA F (n + 1)) : x = CofixA.intro (head' x) (children' x) := by cases x; rfl #align pfunctor.approx.approx_eta PFunctor.Approx.approx_eta inductive Agree : ∀ {n : ℕ}, CofixA F n → CofixA F (n + 1) → Prop | continu (x : CofixA F 0) (y : CofixA F 1) : Agree x y | intro {n} {a} (x : F.B a → CofixA F n) (x' : F.B a → CofixA F (n + 1)) : (∀ i : F.B a, Agree (x i) (x' i)) → Agree (CofixA.intro a x) (CofixA.intro a x') #align pfunctor.approx.agree PFunctor.Approx.Agree def AllAgree (x : ∀ n, CofixA F n) := ∀ n, Agree (x n) (x (succ n)) #align pfunctor.approx.all_agree PFunctor.Approx.AllAgree @[simp] theorem agree_trival {x : CofixA F 0} {y : CofixA F 1} : Agree x y := by constructor #align pfunctor.approx.agree_trival PFunctor.Approx.agree_trival theorem agree_children {n : ℕ} (x : CofixA F (succ n)) (y : CofixA F (succ n + 1)) {i j} (h₀ : HEq i j) (h₁ : Agree x y) : Agree (children' x i) (children' y j) := by cases' h₁ with _ _ _ _ _ _ hagree; cases h₀ apply hagree #align pfunctor.approx.agree_children PFunctor.Approx.agree_children def truncate : ∀ {n : ℕ}, CofixA F (n + 1) → CofixA F n | 0, CofixA.intro _ _ => CofixA.continue | succ _, CofixA.intro i f => CofixA.intro i <| truncate ∘ f #align pfunctor.approx.truncate PFunctor.Approx.truncate theorem truncate_eq_of_agree {n : ℕ} (x : CofixA F n) (y : CofixA F (succ n)) (h : Agree x y) : truncate y = x := by induction n <;> cases x <;> cases y · rfl · -- cases' h with _ _ _ _ _ h₀ h₁ cases h simp only [truncate, Function.comp, true_and_iff, eq_self_iff_true, heq_iff_eq] -- Porting note: used to be `ext y` rename_i n_ih a f y h₁ suffices (fun x => truncate (y x)) = f by simp [this] funext y apply n_ih apply h₁ #align pfunctor.approx.truncate_eq_of_agree PFunctor.Approx.truncate_eq_of_agree variable {X : Type w} variable (f : X → F X) def sCorec : X → ∀ n, CofixA F n | _, 0 => CofixA.continue | j, succ _ => CofixA.intro (f j).1 fun i => sCorec ((f j).2 i) _ #align pfunctor.approx.s_corec PFunctor.Approx.sCorec theorem P_corec (i : X) (n : ℕ) : Agree (sCorec f i n) (sCorec f i (succ n)) := by induction' n with n n_ih generalizing i constructor cases' f i with y g constructor introv apply n_ih set_option linter.uppercaseLean3 false in #align pfunctor.approx.P_corec PFunctor.Approx.P_corec def Path (F : PFunctor.{u}) := List F.Idx #align pfunctor.approx.path PFunctor.Approx.Path instance Path.inhabited : Inhabited (Path F) := ⟨[]⟩ #align pfunctor.approx.path.inhabited PFunctor.Approx.Path.inhabited open List Nat instance CofixA.instSubsingleton : Subsingleton (CofixA F 0) := ⟨by rintro ⟨⟩ ⟨⟩; rfl⟩
Mathlib/Data/PFunctor/Univariate/M.lean
152
174
theorem head_succ' (n m : ℕ) (x : ∀ n, CofixA F n) (Hconsistent : AllAgree x) : head' (x (succ n)) = head' (x (succ m)) := by
suffices ∀ n, head' (x (succ n)) = head' (x 1) by simp [this] clear m n intro n cases' h₀ : x (succ n) with _ i₀ f₀ cases' h₁ : x 1 with _ i₁ f₁ dsimp only [head'] induction' n with n n_ih · rw [h₁] at h₀ cases h₀ trivial · have H := Hconsistent (succ n) cases' h₂ : x (succ n) with _ i₂ f₂ rw [h₀, h₂] at H apply n_ih (truncate ∘ f₀) rw [h₂] cases' H with _ _ _ _ _ _ hagree congr funext j dsimp only [comp_apply] rw [truncate_eq_of_agree] apply hagree
import Mathlib.CategoryTheory.Limits.Filtered import Mathlib.CategoryTheory.Limits.Shapes.FiniteProducts import Mathlib.CategoryTheory.Limits.Shapes.Kernels import Mathlib.CategoryTheory.DiscreteCategory #align_import category_theory.limits.opposites from "leanprover-community/mathlib"@"ac3ae212f394f508df43e37aa093722fa9b65d31" universe v₁ v₂ u₁ u₂ noncomputable section open CategoryTheory open CategoryTheory.Functor open Opposite namespace CategoryTheory.Limits variable {C : Type u₁} [Category.{v₁} C] variable {J : Type u₂} [Category.{v₂} J] #align category_theory.limits.is_limit_cocone_op CategoryTheory.Limits.IsColimit.op #align category_theory.limits.is_colimit_cone_op CategoryTheory.Limits.IsLimit.op #align category_theory.limits.is_limit_cocone_unop CategoryTheory.Limits.IsColimit.unop #align category_theory.limits.is_colimit_cone_unop CategoryTheory.Limits.IsLimit.unop -- 2024-03-26 @[deprecated] alias isLimitCoconeOp := IsColimit.op @[deprecated] alias isColimitConeOp := IsLimit.op @[deprecated] alias isLimitCoconeUnop := IsColimit.unop @[deprecated] alias isColimitConeUnop := IsLimit.unop @[simps] def isLimitConeLeftOpOfCocone (F : J ⥤ Cᵒᵖ) {c : Cocone F} (hc : IsColimit c) : IsLimit (coneLeftOpOfCocone c) where lift s := (hc.desc (coconeOfConeLeftOp s)).unop fac s j := Quiver.Hom.op_inj <| by simp only [coneLeftOpOfCocone_π_app, op_comp, Quiver.Hom.op_unop, IsColimit.fac, coconeOfConeLeftOp_ι_app, op_unop] uniq s m w := by refine Quiver.Hom.op_inj (hc.hom_ext fun j => Quiver.Hom.unop_inj ?_) simpa only [Quiver.Hom.op_unop, IsColimit.fac, coconeOfConeLeftOp_ι_app] using w (op j) #align category_theory.limits.is_limit_cone_left_op_of_cocone CategoryTheory.Limits.isLimitConeLeftOpOfCocone @[simps] def isColimitCoconeLeftOpOfCone (F : J ⥤ Cᵒᵖ) {c : Cone F} (hc : IsLimit c) : IsColimit (coconeLeftOpOfCone c) where desc s := (hc.lift (coneOfCoconeLeftOp s)).unop fac s j := Quiver.Hom.op_inj <| by simp only [coconeLeftOpOfCone_ι_app, op_comp, Quiver.Hom.op_unop, IsLimit.fac, coneOfCoconeLeftOp_π_app, op_unop] uniq s m w := by refine Quiver.Hom.op_inj (hc.hom_ext fun j => Quiver.Hom.unop_inj ?_) simpa only [Quiver.Hom.op_unop, IsLimit.fac, coneOfCoconeLeftOp_π_app] using w (op j) #align category_theory.limits.is_colimit_cocone_left_op_of_cone CategoryTheory.Limits.isColimitCoconeLeftOpOfCone @[simps] def isLimitConeRightOpOfCocone (F : Jᵒᵖ ⥤ C) {c : Cocone F} (hc : IsColimit c) : IsLimit (coneRightOpOfCocone c) where lift s := (hc.desc (coconeOfConeRightOp s)).op fac s j := Quiver.Hom.unop_inj (by simp) uniq s m w := by refine Quiver.Hom.unop_inj (hc.hom_ext fun j => Quiver.Hom.op_inj ?_) simpa only [Quiver.Hom.unop_op, IsColimit.fac] using w (unop j) #align category_theory.limits.is_limit_cone_right_op_of_cocone CategoryTheory.Limits.isLimitConeRightOpOfCocone @[simps] def isColimitCoconeRightOpOfCone (F : Jᵒᵖ ⥤ C) {c : Cone F} (hc : IsLimit c) : IsColimit (coconeRightOpOfCone c) where desc s := (hc.lift (coneOfCoconeRightOp s)).op fac s j := Quiver.Hom.unop_inj (by simp) uniq s m w := by refine Quiver.Hom.unop_inj (hc.hom_ext fun j => Quiver.Hom.op_inj ?_) simpa only [Quiver.Hom.unop_op, IsLimit.fac] using w (unop j) #align category_theory.limits.is_colimit_cocone_right_op_of_cone CategoryTheory.Limits.isColimitCoconeRightOpOfCone @[simps] def isLimitConeUnopOfCocone (F : Jᵒᵖ ⥤ Cᵒᵖ) {c : Cocone F} (hc : IsColimit c) : IsLimit (coneUnopOfCocone c) where lift s := (hc.desc (coconeOfConeUnop s)).unop fac s j := Quiver.Hom.op_inj (by simp) uniq s m w := by refine Quiver.Hom.op_inj (hc.hom_ext fun j => Quiver.Hom.unop_inj ?_) simpa only [Quiver.Hom.op_unop, IsColimit.fac] using w (unop j) #align category_theory.limits.is_limit_cone_unop_of_cocone CategoryTheory.Limits.isLimitConeUnopOfCocone @[simps] def isColimitCoconeUnopOfCone (F : Jᵒᵖ ⥤ Cᵒᵖ) {c : Cone F} (hc : IsLimit c) : IsColimit (coconeUnopOfCone c) where desc s := (hc.lift (coneOfCoconeUnop s)).unop fac s j := Quiver.Hom.op_inj (by simp) uniq s m w := by refine Quiver.Hom.op_inj (hc.hom_ext fun j => Quiver.Hom.unop_inj ?_) simpa only [Quiver.Hom.op_unop, IsLimit.fac] using w (unop j) #align category_theory.limits.is_colimit_cocone_unop_of_cone CategoryTheory.Limits.isColimitCoconeUnopOfCone @[simps] def isLimitConeOfCoconeLeftOp (F : J ⥤ Cᵒᵖ) {c : Cocone F.leftOp} (hc : IsColimit c) : IsLimit (coneOfCoconeLeftOp c) where lift s := (hc.desc (coconeLeftOpOfCone s)).op fac s j := Quiver.Hom.unop_inj <| by simp only [coneOfCoconeLeftOp_π_app, unop_comp, Quiver.Hom.unop_op, IsColimit.fac, coconeLeftOpOfCone_ι_app, unop_op] uniq s m w := by refine Quiver.Hom.unop_inj (hc.hom_ext fun j => Quiver.Hom.op_inj ?_) simpa only [Quiver.Hom.unop_op, IsColimit.fac, coneOfCoconeLeftOp_π_app] using w (unop j) #align category_theory.limits.is_limit_cone_of_cocone_left_op CategoryTheory.Limits.isLimitConeOfCoconeLeftOp @[simps] def isColimitCoconeOfConeLeftOp (F : J ⥤ Cᵒᵖ) {c : Cone F.leftOp} (hc : IsLimit c) : IsColimit (coconeOfConeLeftOp c) where desc s := (hc.lift (coneLeftOpOfCocone s)).op fac s j := Quiver.Hom.unop_inj <| by simp only [coconeOfConeLeftOp_ι_app, unop_comp, Quiver.Hom.unop_op, IsLimit.fac, coneLeftOpOfCocone_π_app, unop_op] uniq s m w := by refine Quiver.Hom.unop_inj (hc.hom_ext fun j => Quiver.Hom.op_inj ?_) simpa only [Quiver.Hom.unop_op, IsLimit.fac, coconeOfConeLeftOp_ι_app] using w (unop j) #align category_theory.limits.is_colimit_cocone_of_cone_left_op CategoryTheory.Limits.isColimitCoconeOfConeLeftOp @[simps] def isLimitConeOfCoconeRightOp (F : Jᵒᵖ ⥤ C) {c : Cocone F.rightOp} (hc : IsColimit c) : IsLimit (coneOfCoconeRightOp c) where lift s := (hc.desc (coconeRightOpOfCone s)).unop fac s j := Quiver.Hom.op_inj (by simp) uniq s m w := by refine Quiver.Hom.op_inj (hc.hom_ext fun j => Quiver.Hom.unop_inj ?_) simpa only [Quiver.Hom.op_unop, IsColimit.fac] using w (op j) #align category_theory.limits.is_limit_cone_of_cocone_right_op CategoryTheory.Limits.isLimitConeOfCoconeRightOp @[simps] def isColimitCoconeOfConeRightOp (F : Jᵒᵖ ⥤ C) {c : Cone F.rightOp} (hc : IsLimit c) : IsColimit (coconeOfConeRightOp c) where desc s := (hc.lift (coneRightOpOfCocone s)).unop fac s j := Quiver.Hom.op_inj (by simp) uniq s m w := by refine Quiver.Hom.op_inj (hc.hom_ext fun j => Quiver.Hom.unop_inj ?_) simpa only [Quiver.Hom.op_unop, IsLimit.fac] using w (op j) #align category_theory.limits.is_colimit_cocone_of_cone_right_op CategoryTheory.Limits.isColimitCoconeOfConeRightOp @[simps] def isLimitConeOfCoconeUnop (F : Jᵒᵖ ⥤ Cᵒᵖ) {c : Cocone F.unop} (hc : IsColimit c) : IsLimit (coneOfCoconeUnop c) where lift s := (hc.desc (coconeUnopOfCone s)).op fac s j := Quiver.Hom.unop_inj (by simp) uniq s m w := by refine Quiver.Hom.unop_inj (hc.hom_ext fun j => Quiver.Hom.op_inj ?_) simpa only [Quiver.Hom.unop_op, IsColimit.fac] using w (op j) #align category_theory.limits.is_limit_cone_of_cocone_unop CategoryTheory.Limits.isLimitConeOfCoconeUnop @[simps] def isColimitConeOfCoconeUnop (F : Jᵒᵖ ⥤ Cᵒᵖ) {c : Cone F.unop} (hc : IsLimit c) : IsColimit (coconeOfConeUnop c) where desc s := (hc.lift (coneUnopOfCocone s)).op fac s j := Quiver.Hom.unop_inj (by simp) uniq s m w := by refine Quiver.Hom.unop_inj (hc.hom_ext fun j => Quiver.Hom.op_inj ?_) simpa only [Quiver.Hom.unop_op, IsLimit.fac] using w (op j) #align category_theory.limits.is_colimit_cone_of_cocone_unop CategoryTheory.Limits.isColimitConeOfCoconeUnop theorem hasLimit_of_hasColimit_leftOp (F : J ⥤ Cᵒᵖ) [HasColimit F.leftOp] : HasLimit F := HasLimit.mk { cone := coneOfCoconeLeftOp (colimit.cocone F.leftOp) isLimit := isLimitConeOfCoconeLeftOp _ (colimit.isColimit _) } #align category_theory.limits.has_limit_of_has_colimit_left_op CategoryTheory.Limits.hasLimit_of_hasColimit_leftOp theorem hasLimit_of_hasColimit_op (F : J ⥤ C) [HasColimit F.op] : HasLimit F := HasLimit.mk { cone := (colimit.cocone F.op).unop isLimit := (colimit.isColimit _).unop } theorem hasLimit_op_of_hasColimit (F : J ⥤ C) [HasColimit F] : HasLimit F.op := HasLimit.mk { cone := (colimit.cocone F).op isLimit := (colimit.isColimit _).op } #align category_theory.limits.has_limit_of_has_colimit_op CategoryTheory.Limits.hasLimit_of_hasColimit_op theorem hasLimitsOfShape_op_of_hasColimitsOfShape [HasColimitsOfShape Jᵒᵖ C] : HasLimitsOfShape J Cᵒᵖ := { has_limit := fun F => hasLimit_of_hasColimit_leftOp F } #align category_theory.limits.has_limits_of_shape_op_of_has_colimits_of_shape CategoryTheory.Limits.hasLimitsOfShape_op_of_hasColimitsOfShape theorem hasLimitsOfShape_of_hasColimitsOfShape_op [HasColimitsOfShape Jᵒᵖ Cᵒᵖ] : HasLimitsOfShape J C := { has_limit := fun F => hasLimit_of_hasColimit_op F } #align category_theory.limits.has_limits_of_shape_of_has_colimits_of_shape_op CategoryTheory.Limits.hasLimitsOfShape_of_hasColimitsOfShape_op attribute [local instance] hasLimitsOfShape_op_of_hasColimitsOfShape instance hasLimits_op_of_hasColimits [HasColimits C] : HasLimits Cᵒᵖ := ⟨fun _ => inferInstance⟩ #align category_theory.limits.has_limits_op_of_has_colimits CategoryTheory.Limits.hasLimits_op_of_hasColimits theorem hasLimits_of_hasColimits_op [HasColimits Cᵒᵖ] : HasLimits C := { has_limits_of_shape := fun _ _ => hasLimitsOfShape_of_hasColimitsOfShape_op } #align category_theory.limits.has_limits_of_has_colimits_op CategoryTheory.Limits.hasLimits_of_hasColimits_op instance has_cofiltered_limits_op_of_has_filtered_colimits [HasFilteredColimitsOfSize.{v₂, u₂} C] : HasCofilteredLimitsOfSize.{v₂, u₂} Cᵒᵖ where HasLimitsOfShape _ _ _ := hasLimitsOfShape_op_of_hasColimitsOfShape #align category_theory.limits.has_cofiltered_limits_op_of_has_filtered_colimits CategoryTheory.Limits.has_cofiltered_limits_op_of_has_filtered_colimits theorem has_cofiltered_limits_of_has_filtered_colimits_op [HasFilteredColimitsOfSize.{v₂, u₂} Cᵒᵖ] : HasCofilteredLimitsOfSize.{v₂, u₂} C := { HasLimitsOfShape := fun _ _ _ => hasLimitsOfShape_of_hasColimitsOfShape_op } #align category_theory.limits.has_cofiltered_limits_of_has_filtered_colimits_op CategoryTheory.Limits.has_cofiltered_limits_of_has_filtered_colimits_op theorem hasColimit_of_hasLimit_leftOp (F : J ⥤ Cᵒᵖ) [HasLimit F.leftOp] : HasColimit F := HasColimit.mk { cocone := coconeOfConeLeftOp (limit.cone F.leftOp) isColimit := isColimitCoconeOfConeLeftOp _ (limit.isLimit _) } #align category_theory.limits.has_colimit_of_has_limit_left_op CategoryTheory.Limits.hasColimit_of_hasLimit_leftOp theorem hasColimit_of_hasLimit_op (F : J ⥤ C) [HasLimit F.op] : HasColimit F := HasColimit.mk { cocone := (limit.cone F.op).unop isColimit := (limit.isLimit _).unop } #align category_theory.limits.has_colimit_of_has_limit_op CategoryTheory.Limits.hasColimit_of_hasLimit_op theorem hasColimit_op_of_hasLimit (F : J ⥤ C) [HasLimit F] : HasColimit F.op := HasColimit.mk { cocone := (limit.cone F).op isColimit := (limit.isLimit _).op } instance hasColimitsOfShape_op_of_hasLimitsOfShape [HasLimitsOfShape Jᵒᵖ C] : HasColimitsOfShape J Cᵒᵖ where has_colimit F := hasColimit_of_hasLimit_leftOp F #align category_theory.limits.has_colimits_of_shape_op_of_has_limits_of_shape CategoryTheory.Limits.hasColimitsOfShape_op_of_hasLimitsOfShape theorem hasColimitsOfShape_of_hasLimitsOfShape_op [HasLimitsOfShape Jᵒᵖ Cᵒᵖ] : HasColimitsOfShape J C := { has_colimit := fun F => hasColimit_of_hasLimit_op F } #align category_theory.limits.has_colimits_of_shape_of_has_limits_of_shape_op CategoryTheory.Limits.hasColimitsOfShape_of_hasLimitsOfShape_op instance hasColimits_op_of_hasLimits [HasLimits C] : HasColimits Cᵒᵖ := ⟨fun _ => inferInstance⟩ #align category_theory.limits.has_colimits_op_of_has_limits CategoryTheory.Limits.hasColimits_op_of_hasLimits theorem hasColimits_of_hasLimits_op [HasLimits Cᵒᵖ] : HasColimits C := { has_colimits_of_shape := fun _ _ => hasColimitsOfShape_of_hasLimitsOfShape_op } #align category_theory.limits.has_colimits_of_has_limits_op CategoryTheory.Limits.hasColimits_of_hasLimits_op instance has_filtered_colimits_op_of_has_cofiltered_limits [HasCofilteredLimitsOfSize.{v₂, u₂} C] : HasFilteredColimitsOfSize.{v₂, u₂} Cᵒᵖ where HasColimitsOfShape _ _ _ := inferInstance #align category_theory.limits.has_filtered_colimits_op_of_has_cofiltered_limits CategoryTheory.Limits.has_filtered_colimits_op_of_has_cofiltered_limits theorem has_filtered_colimits_of_has_cofiltered_limits_op [HasCofilteredLimitsOfSize.{v₂, u₂} Cᵒᵖ] : HasFilteredColimitsOfSize.{v₂, u₂} C := { HasColimitsOfShape := fun _ _ _ => hasColimitsOfShape_of_hasLimitsOfShape_op } #align category_theory.limits.has_filtered_colimits_of_has_cofiltered_limits_op CategoryTheory.Limits.has_filtered_colimits_of_has_cofiltered_limits_op variable (X : Type v₂) instance hasCoproductsOfShape_opposite [HasProductsOfShape X C] : HasCoproductsOfShape X Cᵒᵖ := by haveI : HasLimitsOfShape (Discrete X)ᵒᵖ C := hasLimitsOfShape_of_equivalence (Discrete.opposite X).symm infer_instance #align category_theory.limits.has_coproducts_of_shape_opposite CategoryTheory.Limits.hasCoproductsOfShape_opposite theorem hasCoproductsOfShape_of_opposite [HasProductsOfShape X Cᵒᵖ] : HasCoproductsOfShape X C := haveI : HasLimitsOfShape (Discrete X)ᵒᵖ Cᵒᵖ := hasLimitsOfShape_of_equivalence (Discrete.opposite X).symm hasColimitsOfShape_of_hasLimitsOfShape_op #align category_theory.limits.has_coproducts_of_shape_of_opposite CategoryTheory.Limits.hasCoproductsOfShape_of_opposite instance hasProductsOfShape_opposite [HasCoproductsOfShape X C] : HasProductsOfShape X Cᵒᵖ := by haveI : HasColimitsOfShape (Discrete X)ᵒᵖ C := hasColimitsOfShape_of_equivalence (Discrete.opposite X).symm infer_instance #align category_theory.limits.has_products_of_shape_opposite CategoryTheory.Limits.hasProductsOfShape_opposite theorem hasProductsOfShape_of_opposite [HasCoproductsOfShape X Cᵒᵖ] : HasProductsOfShape X C := haveI : HasColimitsOfShape (Discrete X)ᵒᵖ Cᵒᵖ := hasColimitsOfShape_of_equivalence (Discrete.opposite X).symm hasLimitsOfShape_of_hasColimitsOfShape_op #align category_theory.limits.has_products_of_shape_of_opposite CategoryTheory.Limits.hasProductsOfShape_of_opposite instance hasProducts_opposite [HasCoproducts.{v₂} C] : HasProducts.{v₂} Cᵒᵖ := fun _ => inferInstance #align category_theory.limits.has_products_opposite CategoryTheory.Limits.hasProducts_opposite theorem hasProducts_of_opposite [HasCoproducts.{v₂} Cᵒᵖ] : HasProducts.{v₂} C := fun X => hasProductsOfShape_of_opposite X #align category_theory.limits.has_products_of_opposite CategoryTheory.Limits.hasProducts_of_opposite instance hasCoproducts_opposite [HasProducts.{v₂} C] : HasCoproducts.{v₂} Cᵒᵖ := fun _ => inferInstance #align category_theory.limits.has_coproducts_opposite CategoryTheory.Limits.hasCoproducts_opposite theorem hasCoproducts_of_opposite [HasProducts.{v₂} Cᵒᵖ] : HasCoproducts.{v₂} C := fun X => hasCoproductsOfShape_of_opposite X #align category_theory.limits.has_coproducts_of_opposite CategoryTheory.Limits.hasCoproducts_of_opposite instance hasFiniteCoproducts_opposite [HasFiniteProducts C] : HasFiniteCoproducts Cᵒᵖ where out _ := Limits.hasCoproductsOfShape_opposite _ #align category_theory.limits.has_finite_coproducts_opposite CategoryTheory.Limits.hasFiniteCoproducts_opposite theorem hasFiniteCoproducts_of_opposite [HasFiniteProducts Cᵒᵖ] : HasFiniteCoproducts C := { out := fun _ => hasCoproductsOfShape_of_opposite _ } #align category_theory.limits.has_finite_coproducts_of_opposite CategoryTheory.Limits.hasFiniteCoproducts_of_opposite instance hasFiniteProducts_opposite [HasFiniteCoproducts C] : HasFiniteProducts Cᵒᵖ where out _ := inferInstance #align category_theory.limits.has_finite_products_opposite CategoryTheory.Limits.hasFiniteProducts_opposite theorem hasFiniteProducts_of_opposite [HasFiniteCoproducts Cᵒᵖ] : HasFiniteProducts C := { out := fun _ => hasProductsOfShape_of_opposite _ } #align category_theory.limits.has_finite_products_of_opposite CategoryTheory.Limits.hasFiniteProducts_of_opposite instance hasEqualizers_opposite [HasCoequalizers C] : HasEqualizers Cᵒᵖ := by haveI : HasColimitsOfShape WalkingParallelPairᵒᵖ C := hasColimitsOfShape_of_equivalence walkingParallelPairOpEquiv infer_instance #align category_theory.limits.has_equalizers_opposite CategoryTheory.Limits.hasEqualizers_opposite instance hasCoequalizers_opposite [HasEqualizers C] : HasCoequalizers Cᵒᵖ := by haveI : HasLimitsOfShape WalkingParallelPairᵒᵖ C := hasLimitsOfShape_of_equivalence walkingParallelPairOpEquiv infer_instance #align category_theory.limits.has_coequalizers_opposite CategoryTheory.Limits.hasCoequalizers_opposite instance hasFiniteColimits_opposite [HasFiniteLimits C] : HasFiniteColimits Cᵒᵖ := ⟨fun _ _ _ => inferInstance⟩ #align category_theory.limits.has_finite_colimits_opposite CategoryTheory.Limits.hasFiniteColimits_opposite instance hasFiniteLimits_opposite [HasFiniteColimits C] : HasFiniteLimits Cᵒᵖ := ⟨fun _ _ _ => inferInstance⟩ #align category_theory.limits.has_finite_limits_opposite CategoryTheory.Limits.hasFiniteLimits_opposite instance hasPullbacks_opposite [HasPushouts C] : HasPullbacks Cᵒᵖ := by haveI : HasColimitsOfShape WalkingCospanᵒᵖ C := hasColimitsOfShape_of_equivalence walkingCospanOpEquiv.symm apply hasLimitsOfShape_op_of_hasColimitsOfShape #align category_theory.limits.has_pullbacks_opposite CategoryTheory.Limits.hasPullbacks_opposite instance hasPushouts_opposite [HasPullbacks C] : HasPushouts Cᵒᵖ := by haveI : HasLimitsOfShape WalkingSpanᵒᵖ C := hasLimitsOfShape_of_equivalence walkingSpanOpEquiv.symm infer_instance #align category_theory.limits.has_pushouts_opposite CategoryTheory.Limits.hasPushouts_opposite @[simps!] def spanOp {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : span f.op g.op ≅ walkingCospanOpEquiv.inverse ⋙ (cospan f g).op := NatIso.ofComponents (by rintro (_ | _ | _) <;> rfl) (by rintro (_ | _ | _) (_ | _ | _) f <;> cases f <;> aesop_cat) #align category_theory.limits.span_op CategoryTheory.Limits.spanOp @[simps!] def opCospan {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : (cospan f g).op ≅ walkingCospanOpEquiv.functor ⋙ span f.op g.op := calc (cospan f g).op ≅ 𝟭 _ ⋙ (cospan f g).op := by rfl _ ≅ (walkingCospanOpEquiv.functor ⋙ walkingCospanOpEquiv.inverse) ⋙ (cospan f g).op := (isoWhiskerRight walkingCospanOpEquiv.unitIso _) _ ≅ walkingCospanOpEquiv.functor ⋙ walkingCospanOpEquiv.inverse ⋙ (cospan f g).op := (Functor.associator _ _ _) _ ≅ walkingCospanOpEquiv.functor ⋙ span f.op g.op := isoWhiskerLeft _ (spanOp f g).symm #align category_theory.limits.op_cospan CategoryTheory.Limits.opCospan @[simps!] def cospanOp {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : cospan f.op g.op ≅ walkingSpanOpEquiv.inverse ⋙ (span f g).op := NatIso.ofComponents (by rintro (_ | _ | _) <;> rfl) (by rintro (_ | _ | _) (_ | _ | _) f <;> cases f <;> aesop_cat) #align category_theory.limits.cospan_op CategoryTheory.Limits.cospanOp @[simps!] def opSpan {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : (span f g).op ≅ walkingSpanOpEquiv.functor ⋙ cospan f.op g.op := calc (span f g).op ≅ 𝟭 _ ⋙ (span f g).op := by rfl _ ≅ (walkingSpanOpEquiv.functor ⋙ walkingSpanOpEquiv.inverse) ⋙ (span f g).op := (isoWhiskerRight walkingSpanOpEquiv.unitIso _) _ ≅ walkingSpanOpEquiv.functor ⋙ walkingSpanOpEquiv.inverse ⋙ (span f g).op := (Functor.associator _ _ _) _ ≅ walkingSpanOpEquiv.functor ⋙ cospan f.op g.op := isoWhiskerLeft _ (cospanOp f g).symm #align category_theory.limits.op_span CategoryTheory.Limits.opSpan namespace PushoutCocone -- Porting note: it was originally @[simps (config := lemmasOnly)] @[simps!] def unop {X Y Z : Cᵒᵖ} {f : X ⟶ Y} {g : X ⟶ Z} (c : PushoutCocone f g) : PullbackCone f.unop g.unop := Cocone.unop ((Cocones.precompose (opCospan f.unop g.unop).hom).obj (Cocone.whisker walkingCospanOpEquiv.functor c)) #align category_theory.limits.pushout_cocone.unop CategoryTheory.Limits.PushoutCocone.unop -- Porting note (#10618): removed simp attribute as the equality can already be obtained by simp
Mathlib/CategoryTheory/Limits/Opposites.lean
624
625
theorem unop_fst {X Y Z : Cᵒᵖ} {f : X ⟶ Y} {g : X ⟶ Z} (c : PushoutCocone f g) : c.unop.fst = c.inl.unop := by
simp
import Mathlib.Algebra.Associated import Mathlib.Algebra.Star.Unitary import Mathlib.RingTheory.Int.Basic import Mathlib.RingTheory.PrincipalIdealDomain import Mathlib.Tactic.Ring #align_import number_theory.zsqrtd.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" @[ext] structure Zsqrtd (d : ℤ) where re : ℤ im : ℤ deriving DecidableEq #align zsqrtd Zsqrtd #align zsqrtd.ext Zsqrtd.ext_iff prefix:100 "ℤ√" => Zsqrtd namespace Zsqrtd section variable {d : ℤ} def ofInt (n : ℤ) : ℤ√d := ⟨n, 0⟩ #align zsqrtd.of_int Zsqrtd.ofInt theorem ofInt_re (n : ℤ) : (ofInt n : ℤ√d).re = n := rfl #align zsqrtd.of_int_re Zsqrtd.ofInt_re theorem ofInt_im (n : ℤ) : (ofInt n : ℤ√d).im = 0 := rfl #align zsqrtd.of_int_im Zsqrtd.ofInt_im instance : Zero (ℤ√d) := ⟨ofInt 0⟩ @[simp] theorem zero_re : (0 : ℤ√d).re = 0 := rfl #align zsqrtd.zero_re Zsqrtd.zero_re @[simp] theorem zero_im : (0 : ℤ√d).im = 0 := rfl #align zsqrtd.zero_im Zsqrtd.zero_im instance : Inhabited (ℤ√d) := ⟨0⟩ instance : One (ℤ√d) := ⟨ofInt 1⟩ @[simp] theorem one_re : (1 : ℤ√d).re = 1 := rfl #align zsqrtd.one_re Zsqrtd.one_re @[simp] theorem one_im : (1 : ℤ√d).im = 0 := rfl #align zsqrtd.one_im Zsqrtd.one_im def sqrtd : ℤ√d := ⟨0, 1⟩ #align zsqrtd.sqrtd Zsqrtd.sqrtd @[simp] theorem sqrtd_re : (sqrtd : ℤ√d).re = 0 := rfl #align zsqrtd.sqrtd_re Zsqrtd.sqrtd_re @[simp] theorem sqrtd_im : (sqrtd : ℤ√d).im = 1 := rfl #align zsqrtd.sqrtd_im Zsqrtd.sqrtd_im instance : Add (ℤ√d) := ⟨fun z w => ⟨z.1 + w.1, z.2 + w.2⟩⟩ @[simp] theorem add_def (x y x' y' : ℤ) : (⟨x, y⟩ + ⟨x', y'⟩ : ℤ√d) = ⟨x + x', y + y'⟩ := rfl #align zsqrtd.add_def Zsqrtd.add_def @[simp] theorem add_re (z w : ℤ√d) : (z + w).re = z.re + w.re := rfl #align zsqrtd.add_re Zsqrtd.add_re @[simp] theorem add_im (z w : ℤ√d) : (z + w).im = z.im + w.im := rfl #align zsqrtd.add_im Zsqrtd.add_im #noalign zsqrtd.bit0_re #noalign zsqrtd.bit0_im #noalign zsqrtd.bit1_re #noalign zsqrtd.bit1_im instance : Neg (ℤ√d) := ⟨fun z => ⟨-z.1, -z.2⟩⟩ @[simp] theorem neg_re (z : ℤ√d) : (-z).re = -z.re := rfl #align zsqrtd.neg_re Zsqrtd.neg_re @[simp] theorem neg_im (z : ℤ√d) : (-z).im = -z.im := rfl #align zsqrtd.neg_im Zsqrtd.neg_im instance : Mul (ℤ√d) := ⟨fun z w => ⟨z.1 * w.1 + d * z.2 * w.2, z.1 * w.2 + z.2 * w.1⟩⟩ @[simp] theorem mul_re (z w : ℤ√d) : (z * w).re = z.re * w.re + d * z.im * w.im := rfl #align zsqrtd.mul_re Zsqrtd.mul_re @[simp] theorem mul_im (z w : ℤ√d) : (z * w).im = z.re * w.im + z.im * w.re := rfl #align zsqrtd.mul_im Zsqrtd.mul_im instance addCommGroup : AddCommGroup (ℤ√d) := by refine { add := (· + ·) zero := (0 : ℤ√d) sub := fun a b => a + -b neg := Neg.neg nsmul := @nsmulRec (ℤ√d) ⟨0⟩ ⟨(· + ·)⟩ zsmul := @zsmulRec (ℤ√d) ⟨0⟩ ⟨(· + ·)⟩ ⟨Neg.neg⟩ (@nsmulRec (ℤ√d) ⟨0⟩ ⟨(· + ·)⟩) add_assoc := ?_ zero_add := ?_ add_zero := ?_ add_left_neg := ?_ add_comm := ?_ } <;> intros <;> ext <;> simp [add_comm, add_left_comm] @[simp] theorem sub_re (z w : ℤ√d) : (z - w).re = z.re - w.re := rfl @[simp] theorem sub_im (z w : ℤ√d) : (z - w).im = z.im - w.im := rfl instance addGroupWithOne : AddGroupWithOne (ℤ√d) := { Zsqrtd.addCommGroup with natCast := fun n => ofInt n intCast := ofInt one := 1 } instance commRing : CommRing (ℤ√d) := by refine { Zsqrtd.addGroupWithOne with mul := (· * ·) npow := @npowRec (ℤ√d) ⟨1⟩ ⟨(· * ·)⟩, add_comm := ?_ left_distrib := ?_ right_distrib := ?_ zero_mul := ?_ mul_zero := ?_ mul_assoc := ?_ one_mul := ?_ mul_one := ?_ mul_comm := ?_ } <;> intros <;> ext <;> simp <;> ring instance : AddMonoid (ℤ√d) := by infer_instance instance : Monoid (ℤ√d) := by infer_instance instance : CommMonoid (ℤ√d) := by infer_instance instance : CommSemigroup (ℤ√d) := by infer_instance instance : Semigroup (ℤ√d) := by infer_instance instance : AddCommSemigroup (ℤ√d) := by infer_instance instance : AddSemigroup (ℤ√d) := by infer_instance instance : CommSemiring (ℤ√d) := by infer_instance instance : Semiring (ℤ√d) := by infer_instance instance : Ring (ℤ√d) := by infer_instance instance : Distrib (ℤ√d) := by infer_instance instance : Star (ℤ√d) where star z := ⟨z.1, -z.2⟩ @[simp] theorem star_mk (x y : ℤ) : star (⟨x, y⟩ : ℤ√d) = ⟨x, -y⟩ := rfl #align zsqrtd.star_mk Zsqrtd.star_mk @[simp] theorem star_re (z : ℤ√d) : (star z).re = z.re := rfl #align zsqrtd.star_re Zsqrtd.star_re @[simp] theorem star_im (z : ℤ√d) : (star z).im = -z.im := rfl #align zsqrtd.star_im Zsqrtd.star_im instance : StarRing (ℤ√d) where star_involutive x := Zsqrtd.ext _ _ rfl (neg_neg _) star_mul a b := by ext <;> simp <;> ring star_add a b := Zsqrtd.ext _ _ rfl (neg_add _ _) -- Porting note: proof was `by decide` instance nontrivial : Nontrivial (ℤ√d) := ⟨⟨0, 1, (Zsqrtd.ext_iff 0 1).not.mpr (by simp)⟩⟩ @[simp] theorem natCast_re (n : ℕ) : (n : ℤ√d).re = n := rfl #align zsqrtd.coe_nat_re Zsqrtd.natCast_re @[simp] theorem ofNat_re (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n) : ℤ√d).re = n := rfl @[simp] theorem natCast_im (n : ℕ) : (n : ℤ√d).im = 0 := rfl #align zsqrtd.coe_nat_im Zsqrtd.natCast_im @[simp] theorem ofNat_im (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n) : ℤ√d).im = 0 := rfl theorem natCast_val (n : ℕ) : (n : ℤ√d) = ⟨n, 0⟩ := rfl #align zsqrtd.coe_nat_val Zsqrtd.natCast_val @[simp] theorem intCast_re (n : ℤ) : (n : ℤ√d).re = n := by cases n <;> rfl #align zsqrtd.coe_int_re Zsqrtd.intCast_re @[simp] theorem intCast_im (n : ℤ) : (n : ℤ√d).im = 0 := by cases n <;> rfl #align zsqrtd.coe_int_im Zsqrtd.intCast_im theorem intCast_val (n : ℤ) : (n : ℤ√d) = ⟨n, 0⟩ := by ext <;> simp #align zsqrtd.coe_int_val Zsqrtd.intCast_val instance : CharZero (ℤ√d) where cast_injective m n := by simp [Zsqrtd.ext_iff] @[simp] theorem ofInt_eq_intCast (n : ℤ) : (ofInt n : ℤ√d) = n := by ext <;> simp [ofInt_re, ofInt_im] #align zsqrtd.of_int_eq_coe Zsqrtd.ofInt_eq_intCast @[deprecated (since := "2024-04-05")] alias coe_nat_re := natCast_re @[deprecated (since := "2024-04-05")] alias coe_nat_im := natCast_im @[deprecated (since := "2024-04-05")] alias coe_nat_val := natCast_val @[deprecated (since := "2024-04-05")] alias coe_int_re := intCast_re @[deprecated (since := "2024-04-05")] alias coe_int_im := intCast_im @[deprecated (since := "2024-04-05")] alias coe_int_val := intCast_val @[deprecated (since := "2024-04-05")] alias ofInt_eq_coe := ofInt_eq_intCast @[simp] theorem smul_val (n x y : ℤ) : (n : ℤ√d) * ⟨x, y⟩ = ⟨n * x, n * y⟩ := by ext <;> simp #align zsqrtd.smul_val Zsqrtd.smul_val theorem smul_re (a : ℤ) (b : ℤ√d) : (↑a * b).re = a * b.re := by simp #align zsqrtd.smul_re Zsqrtd.smul_re theorem smul_im (a : ℤ) (b : ℤ√d) : (↑a * b).im = a * b.im := by simp #align zsqrtd.smul_im Zsqrtd.smul_im @[simp] theorem muld_val (x y : ℤ) : sqrtd (d := d) * ⟨x, y⟩ = ⟨d * y, x⟩ := by ext <;> simp #align zsqrtd.muld_val Zsqrtd.muld_val @[simp] theorem dmuld : sqrtd (d := d) * sqrtd (d := d) = d := by ext <;> simp #align zsqrtd.dmuld Zsqrtd.dmuld @[simp] theorem smuld_val (n x y : ℤ) : sqrtd * (n : ℤ√d) * ⟨x, y⟩ = ⟨d * n * y, n * x⟩ := by ext <;> simp #align zsqrtd.smuld_val Zsqrtd.smuld_val theorem decompose {x y : ℤ} : (⟨x, y⟩ : ℤ√d) = x + sqrtd (d := d) * y := by ext <;> simp #align zsqrtd.decompose Zsqrtd.decompose theorem mul_star {x y : ℤ} : (⟨x, y⟩ * star ⟨x, y⟩ : ℤ√d) = x * x - d * y * y := by ext <;> simp [sub_eq_add_neg, mul_comm] #align zsqrtd.mul_star Zsqrtd.mul_star @[deprecated (since := "2024-05-25")] alias coe_int_add := Int.cast_add @[deprecated (since := "2024-05-25")] alias coe_int_sub := Int.cast_sub @[deprecated (since := "2024-05-25")] alias coe_int_mul := Int.cast_mul @[deprecated (since := "2024-05-25")] alias coe_int_inj := Int.cast_inj theorem intCast_dvd (z : ℤ) (a : ℤ√d) : ↑z ∣ a ↔ z ∣ a.re ∧ z ∣ a.im := by constructor · rintro ⟨x, rfl⟩ simp only [add_zero, intCast_re, zero_mul, mul_im, dvd_mul_right, and_self_iff, mul_re, mul_zero, intCast_im] · rintro ⟨⟨r, hr⟩, ⟨i, hi⟩⟩ use ⟨r, i⟩ rw [smul_val, Zsqrtd.ext_iff] exact ⟨hr, hi⟩ #align zsqrtd.coe_int_dvd_iff Zsqrtd.intCast_dvd @[simp, norm_cast] theorem intCast_dvd_intCast (a b : ℤ) : (a : ℤ√d) ∣ b ↔ a ∣ b := by rw [intCast_dvd] constructor · rintro ⟨hre, -⟩ rwa [intCast_re] at hre · rw [intCast_re, intCast_im] exact fun hc => ⟨hc, dvd_zero a⟩ #align zsqrtd.coe_int_dvd_coe_int Zsqrtd.intCast_dvd_intCast @[deprecated (since := "2024-05-25")] alias coe_int_dvd_iff := intCast_dvd @[deprecated (since := "2024-05-25")] alias coe_int_dvd_coe_int := intCast_dvd_intCast protected theorem eq_of_smul_eq_smul_left {a : ℤ} {b c : ℤ√d} (ha : a ≠ 0) (h : ↑a * b = a * c) : b = c := by rw [Zsqrtd.ext_iff] at h ⊢ apply And.imp _ _ h <;> simpa only [smul_re, smul_im] using mul_left_cancel₀ ha #align zsqrtd.eq_of_smul_eq_smul_left Zsqrtd.eq_of_smul_eq_smul_left def SqLe (a c b d : ℕ) : Prop := c * a * a ≤ d * b * b #align zsqrtd.sq_le Zsqrtd.SqLe theorem sqLe_of_le {c d x y z w : ℕ} (xz : z ≤ x) (yw : y ≤ w) (xy : SqLe x c y d) : SqLe z c w d := le_trans (mul_le_mul (Nat.mul_le_mul_left _ xz) xz (Nat.zero_le _) (Nat.zero_le _)) <| le_trans xy (mul_le_mul (Nat.mul_le_mul_left _ yw) yw (Nat.zero_le _) (Nat.zero_le _)) #align zsqrtd.sq_le_of_le Zsqrtd.sqLe_of_le theorem sqLe_add_mixed {c d x y z w : ℕ} (xy : SqLe x c y d) (zw : SqLe z c w d) : c * (x * z) ≤ d * (y * w) := Nat.mul_self_le_mul_self_iff.1 <| by simpa [mul_comm, mul_left_comm] using mul_le_mul xy zw (Nat.zero_le _) (Nat.zero_le _) #align zsqrtd.sq_le_add_mixed Zsqrtd.sqLe_add_mixed theorem sqLe_add {c d x y z w : ℕ} (xy : SqLe x c y d) (zw : SqLe z c w d) : SqLe (x + z) c (y + w) d := by have xz := sqLe_add_mixed xy zw simp? [SqLe, mul_assoc] at xy zw says simp only [SqLe, mul_assoc] at xy zw simp [SqLe, mul_add, mul_comm, mul_left_comm, add_le_add, *] #align zsqrtd.sq_le_add Zsqrtd.sqLe_add theorem sqLe_cancel {c d x y z w : ℕ} (zw : SqLe y d x c) (h : SqLe (x + z) c (y + w) d) : SqLe z c w d := by apply le_of_not_gt intro l refine not_le_of_gt ?_ h simp only [SqLe, mul_add, mul_comm, mul_left_comm, add_assoc, gt_iff_lt] have hm := sqLe_add_mixed zw (le_of_lt l) simp only [SqLe, mul_assoc, gt_iff_lt] at l zw exact lt_of_le_of_lt (add_le_add_right zw _) (add_lt_add_left (add_lt_add_of_le_of_lt hm (add_lt_add_of_le_of_lt hm l)) _) #align zsqrtd.sq_le_cancel Zsqrtd.sqLe_cancel theorem sqLe_smul {c d x y : ℕ} (n : ℕ) (xy : SqLe x c y d) : SqLe (n * x) c (n * y) d := by simpa [SqLe, mul_left_comm, mul_assoc] using Nat.mul_le_mul_left (n * n) xy #align zsqrtd.sq_le_smul Zsqrtd.sqLe_smul
Mathlib/NumberTheory/Zsqrtd/Basic.lean
446
459
theorem sqLe_mul {d x y z w : ℕ} : (SqLe x 1 y d → SqLe z 1 w d → SqLe (x * w + y * z) d (x * z + d * y * w) 1) ∧ (SqLe x 1 y d → SqLe w d z 1 → SqLe (x * z + d * y * w) 1 (x * w + y * z) d) ∧ (SqLe y d x 1 → SqLe z 1 w d → SqLe (x * z + d * y * w) 1 (x * w + y * z) d) ∧ (SqLe y d x 1 → SqLe w d z 1 → SqLe (x * w + y * z) d (x * z + d * y * w) 1) := by
refine ⟨?_, ?_, ?_, ?_⟩ <;> · intro xy zw have := Int.mul_nonneg (sub_nonneg_of_le (Int.ofNat_le_ofNat_of_le xy)) (sub_nonneg_of_le (Int.ofNat_le_ofNat_of_le zw)) refine Int.le_of_ofNat_le_ofNat (le_of_sub_nonneg ?_) convert this using 1 simp only [one_mul, Int.ofNat_add, Int.ofNat_mul] ring
import Mathlib.Algebra.Group.Ext import Mathlib.CategoryTheory.Simple import Mathlib.CategoryTheory.Linear.Basic import Mathlib.CategoryTheory.Endomorphism import Mathlib.FieldTheory.IsAlgClosed.Spectrum #align_import category_theory.preadditive.schur from "leanprover-community/mathlib"@"58a272265b5e05f258161260dd2c5d247213cbd3" namespace CategoryTheory open CategoryTheory.Limits variable {C : Type*} [Category C] variable [Preadditive C] -- See also `epi_of_nonzero_to_simple`, which does not require `Preadditive C`. theorem mono_of_nonzero_from_simple [HasKernels C] {X Y : C} [Simple X] {f : X ⟶ Y} (w : f ≠ 0) : Mono f := Preadditive.mono_of_kernel_zero (kernel_zero_of_nonzero_from_simple w) #align category_theory.mono_of_nonzero_from_simple CategoryTheory.mono_of_nonzero_from_simple theorem isIso_of_hom_simple [HasKernels C] {X Y : C} [Simple X] [Simple Y] {f : X ⟶ Y} (w : f ≠ 0) : IsIso f := haveI := mono_of_nonzero_from_simple w isIso_of_mono_of_nonzero w #align category_theory.is_iso_of_hom_simple CategoryTheory.isIso_of_hom_simple theorem isIso_iff_nonzero [HasKernels C] {X Y : C} [Simple X] [Simple Y] (f : X ⟶ Y) : IsIso f ↔ f ≠ 0 := ⟨fun I => by intro h apply id_nonzero X simp only [← IsIso.hom_inv_id f, h, zero_comp], fun w => isIso_of_hom_simple w⟩ #align category_theory.is_iso_iff_nonzero CategoryTheory.isIso_iff_nonzero open scoped Classical in noncomputable instance [HasKernels C] {X : C} [Simple X] : DivisionRing (End X) where inv f := if h : f = 0 then 0 else haveI := isIso_of_hom_simple h; inv f exists_pair_ne := ⟨𝟙 X, 0, id_nonzero _⟩ inv_zero := dif_pos rfl mul_inv_cancel f hf := by dsimp rw [dif_neg hf] haveI := isIso_of_hom_simple hf exact IsIso.inv_hom_id f nnqsmul := _ qsmul := _ open FiniteDimensional section variable (𝕜 : Type*) [DivisionRing 𝕜] theorem finrank_hom_simple_simple_eq_zero_of_not_iso [HasKernels C] [Linear 𝕜 C] {X Y : C} [Simple X] [Simple Y] (h : (X ≅ Y) → False) : finrank 𝕜 (X ⟶ Y) = 0 := haveI := subsingleton_of_forall_eq (0 : X ⟶ Y) fun f => by have p := not_congr (isIso_iff_nonzero f) simp only [Classical.not_not, Ne] at p exact p.mp fun _ => h (asIso f) finrank_zero_of_subsingleton #align category_theory.finrank_hom_simple_simple_eq_zero_of_not_iso CategoryTheory.finrank_hom_simple_simple_eq_zero_of_not_iso end variable (𝕜 : Type*) [Field 𝕜] variable [IsAlgClosed 𝕜] [Linear 𝕜 C] -- Porting note: the defeq issue in lean3 described below is no longer a problem in Lean4. -- In the proof below we have some difficulty using `I : FiniteDimensional 𝕜 (X ⟶ X)` -- where we need a `FiniteDimensional 𝕜 (End X)`. -- These are definitionally equal, but without eta reduction Lean can't see this. -- To get around this, we use `convert I`, -- then check the various instances agree field-by-field, -- We prove this with the explicit `isIso_iff_nonzero` assumption, -- rather than just `[Simple X]`, as this form is useful for -- Müger's formulation of semisimplicity. theorem finrank_endomorphism_eq_one {X : C} (isIso_iff_nonzero : ∀ f : X ⟶ X, IsIso f ↔ f ≠ 0) [I : FiniteDimensional 𝕜 (X ⟶ X)] : finrank 𝕜 (X ⟶ X) = 1 := by have id_nonzero := (isIso_iff_nonzero (𝟙 X)).mp (by infer_instance) refine finrank_eq_one (𝟙 X) id_nonzero ?_ intro f have : Nontrivial (End X) := nontrivial_of_ne _ _ id_nonzero have : FiniteDimensional 𝕜 (End X) := I obtain ⟨c, nu⟩ := spectrum.nonempty_of_isAlgClosed_of_finiteDimensional 𝕜 (End.of f) use c rw [spectrum.mem_iff, IsUnit.sub_iff, isUnit_iff_isIso, isIso_iff_nonzero, Ne, Classical.not_not, sub_eq_zero, Algebra.algebraMap_eq_smul_one] at nu exact nu.symm #align category_theory.finrank_endomorphism_eq_one CategoryTheory.finrank_endomorphism_eq_one variable [HasKernels C] theorem finrank_endomorphism_simple_eq_one (X : C) [Simple X] [FiniteDimensional 𝕜 (X ⟶ X)] : finrank 𝕜 (X ⟶ X) = 1 := finrank_endomorphism_eq_one 𝕜 isIso_iff_nonzero #align category_theory.finrank_endomorphism_simple_eq_one CategoryTheory.finrank_endomorphism_simple_eq_one theorem endomorphism_simple_eq_smul_id {X : C} [Simple X] [FiniteDimensional 𝕜 (X ⟶ X)] (f : X ⟶ X) : ∃ c : 𝕜, c • 𝟙 X = f := (finrank_eq_one_iff_of_nonzero' (𝟙 X) (id_nonzero X)).mp (finrank_endomorphism_simple_eq_one 𝕜 X) f #align category_theory.endomorphism_simple_eq_smul_id CategoryTheory.endomorphism_simple_eq_smul_id noncomputable def fieldEndOfFiniteDimensional (X : C) [Simple X] [I : FiniteDimensional 𝕜 (X ⟶ X)] : Field (End X) := by classical exact { (inferInstance : DivisionRing (End X)) with mul_comm := fun f g => by obtain ⟨c, rfl⟩ := endomorphism_simple_eq_smul_id 𝕜 f obtain ⟨d, rfl⟩ := endomorphism_simple_eq_smul_id 𝕜 g simp [← mul_smul, mul_comm c d] } #align category_theory.field_End_of_finite_dimensional CategoryTheory.fieldEndOfFiniteDimensional -- There is a symmetric argument that uses `[FiniteDimensional 𝕜 (Y ⟶ Y)]` instead, -- but we don't bother proving that here. theorem finrank_hom_simple_simple_le_one (X Y : C) [FiniteDimensional 𝕜 (X ⟶ X)] [Simple X] [Simple Y] : finrank 𝕜 (X ⟶ Y) ≤ 1 := by obtain (h|h) := subsingleton_or_nontrivial (X ⟶ Y) · rw [finrank_zero_of_subsingleton] exact zero_le_one · obtain ⟨f, nz⟩ := (nontrivial_iff_exists_ne 0).mp h haveI fi := (isIso_iff_nonzero f).mpr nz refine finrank_le_one f ?_ intro g obtain ⟨c, w⟩ := endomorphism_simple_eq_smul_id 𝕜 (g ≫ inv f) exact ⟨c, by simpa using w =≫ f⟩ #align category_theory.finrank_hom_simple_simple_le_one CategoryTheory.finrank_hom_simple_simple_le_one theorem finrank_hom_simple_simple_eq_one_iff (X Y : C) [FiniteDimensional 𝕜 (X ⟶ X)] [FiniteDimensional 𝕜 (X ⟶ Y)] [Simple X] [Simple Y] : finrank 𝕜 (X ⟶ Y) = 1 ↔ Nonempty (X ≅ Y) := by fconstructor · intro h rw [finrank_eq_one_iff'] at h obtain ⟨f, nz, -⟩ := h rw [← isIso_iff_nonzero] at nz exact ⟨asIso f⟩ · rintro ⟨f⟩ have le_one := finrank_hom_simple_simple_le_one 𝕜 X Y have zero_lt : 0 < finrank 𝕜 (X ⟶ Y) := finrank_pos_iff_exists_ne_zero.mpr ⟨f.hom, (isIso_iff_nonzero f.hom).mp inferInstance⟩ omega #align category_theory.finrank_hom_simple_simple_eq_one_iff CategoryTheory.finrank_hom_simple_simple_eq_one_iff theorem finrank_hom_simple_simple_eq_zero_iff (X Y : C) [FiniteDimensional 𝕜 (X ⟶ X)] [FiniteDimensional 𝕜 (X ⟶ Y)] [Simple X] [Simple Y] : finrank 𝕜 (X ⟶ Y) = 0 ↔ IsEmpty (X ≅ Y) := by rw [← not_nonempty_iff, ← not_congr (finrank_hom_simple_simple_eq_one_iff 𝕜 X Y)] refine ⟨fun h => by rw [h]; simp, fun h => ?_⟩ have := finrank_hom_simple_simple_le_one 𝕜 X Y interval_cases finrank 𝕜 (X ⟶ Y) · rfl · exact False.elim (h rfl) #align category_theory.finrank_hom_simple_simple_eq_zero_iff CategoryTheory.finrank_hom_simple_simple_eq_zero_iff open scoped Classical
Mathlib/CategoryTheory/Preadditive/Schur.lean
206
210
theorem finrank_hom_simple_simple (X Y : C) [∀ X Y : C, FiniteDimensional 𝕜 (X ⟶ Y)] [Simple X] [Simple Y] : finrank 𝕜 (X ⟶ Y) = if Nonempty (X ≅ Y) then 1 else 0 := by
split_ifs with h · exact (finrank_hom_simple_simple_eq_one_iff 𝕜 X Y).2 h · exact (finrank_hom_simple_simple_eq_zero_iff 𝕜 X Y).2 (not_nonempty_iff.mp h)
import Mathlib.NumberTheory.Padics.PadicIntegers import Mathlib.RingTheory.ZMod #align_import number_theory.padics.ring_homs from "leanprover-community/mathlib"@"565eb991e264d0db702722b4bde52ee5173c9950" noncomputable section open scoped Classical open Nat LocalRing Padic namespace PadicInt variable {p : ℕ} [hp_prime : Fact p.Prime] section RingHoms variable (p) (r : ℚ) def modPart : ℤ := r.num * gcdA r.den p % p #align padic_int.mod_part PadicInt.modPart variable {p} theorem modPart_lt_p : modPart p r < p := by convert Int.emod_lt _ _ · simp · exact mod_cast hp_prime.1.ne_zero #align padic_int.mod_part_lt_p PadicInt.modPart_lt_p theorem modPart_nonneg : 0 ≤ modPart p r := Int.emod_nonneg _ <| mod_cast hp_prime.1.ne_zero #align padic_int.mod_part_nonneg PadicInt.modPart_nonneg theorem isUnit_den (r : ℚ) (h : ‖(r : ℚ_[p])‖ ≤ 1) : IsUnit (r.den : ℤ_[p]) := by rw [isUnit_iff] apply le_antisymm (r.den : ℤ_[p]).2 rw [← not_lt, coe_natCast] intro norm_denom_lt have hr : ‖(r * r.den : ℚ_[p])‖ = ‖(r.num : ℚ_[p])‖ := by congr rw_mod_cast [@Rat.mul_den_eq_num r] rw [padicNormE.mul] at hr have key : ‖(r.num : ℚ_[p])‖ < 1 := by calc _ = _ := hr.symm _ < 1 * 1 := mul_lt_mul' h norm_denom_lt (norm_nonneg _) zero_lt_one _ = 1 := mul_one 1 have : ↑p ∣ r.num ∧ (p : ℤ) ∣ r.den := by simp only [← norm_int_lt_one_iff_dvd, ← padic_norm_e_of_padicInt] exact ⟨key, norm_denom_lt⟩ apply hp_prime.1.not_dvd_one rwa [← r.reduced.gcd_eq_one, Nat.dvd_gcd_iff, ← Int.natCast_dvd, ← Int.natCast_dvd_natCast] #align padic_int.is_unit_denom PadicInt.isUnit_den theorem norm_sub_modPart_aux (r : ℚ) (h : ‖(r : ℚ_[p])‖ ≤ 1) : ↑p ∣ r.num - r.num * r.den.gcdA p % p * ↑r.den := by rw [← ZMod.intCast_zmod_eq_zero_iff_dvd] simp only [Int.cast_natCast, ZMod.natCast_mod, Int.cast_mul, Int.cast_sub] have := congr_arg (fun x => x % p : ℤ → ZMod p) (gcd_eq_gcd_ab r.den p) simp only [Int.cast_natCast, CharP.cast_eq_zero, EuclideanDomain.mod_zero, Int.cast_add, Int.cast_mul, zero_mul, add_zero] at this push_cast rw [mul_right_comm, mul_assoc, ← this] suffices rdcp : r.den.Coprime p by rw [rdcp.gcd_eq_one] simp only [mul_one, cast_one, sub_self] apply Coprime.symm apply (coprime_or_dvd_of_prime hp_prime.1 _).resolve_right rw [← Int.natCast_dvd_natCast, ← norm_int_lt_one_iff_dvd, not_lt] apply ge_of_eq rw [← isUnit_iff] exact isUnit_den r h #align padic_int.norm_sub_mod_part_aux PadicInt.norm_sub_modPart_aux theorem norm_sub_modPart (h : ‖(r : ℚ_[p])‖ ≤ 1) : ‖(⟨r, h⟩ - modPart p r : ℤ_[p])‖ < 1 := by let n := modPart p r rw [norm_lt_one_iff_dvd, ← (isUnit_den r h).dvd_mul_right] suffices ↑p ∣ r.num - n * r.den by convert (Int.castRingHom ℤ_[p]).map_dvd this simp only [sub_mul, Int.cast_natCast, eq_intCast, Int.cast_mul, sub_left_inj, Int.cast_sub] apply Subtype.coe_injective simp only [coe_mul, Subtype.coe_mk, coe_natCast] rw_mod_cast [@Rat.mul_den_eq_num r] rfl exact norm_sub_modPart_aux r h #align padic_int.norm_sub_mod_part PadicInt.norm_sub_modPart theorem exists_mem_range_of_norm_rat_le_one (h : ‖(r : ℚ_[p])‖ ≤ 1) : ∃ n : ℤ, 0 ≤ n ∧ n < p ∧ ‖(⟨r, h⟩ - n : ℤ_[p])‖ < 1 := ⟨modPart p r, modPart_nonneg _, modPart_lt_p _, norm_sub_modPart _ h⟩ #align padic_int.exists_mem_range_of_norm_rat_le_one PadicInt.exists_mem_range_of_norm_rat_le_one theorem zmod_congr_of_sub_mem_span_aux (n : ℕ) (x : ℤ_[p]) (a b : ℤ) (ha : x - a ∈ (Ideal.span {(p : ℤ_[p]) ^ n})) (hb : x - b ∈ (Ideal.span {(p : ℤ_[p]) ^ n})) : (a : ZMod (p ^ n)) = b := by rw [Ideal.mem_span_singleton] at ha hb rw [← sub_eq_zero, ← Int.cast_sub, ZMod.intCast_zmod_eq_zero_iff_dvd, Int.natCast_pow] rw [← dvd_neg, neg_sub] at ha have := dvd_add ha hb rwa [sub_eq_add_neg, sub_eq_add_neg, add_assoc, neg_add_cancel_left, ← sub_eq_add_neg, ← Int.cast_sub, pow_p_dvd_int_iff] at this #align padic_int.zmod_congr_of_sub_mem_span_aux PadicInt.zmod_congr_of_sub_mem_span_aux theorem zmod_congr_of_sub_mem_span (n : ℕ) (x : ℤ_[p]) (a b : ℕ) (ha : x - a ∈ (Ideal.span {(p : ℤ_[p]) ^ n})) (hb : x - b ∈ (Ideal.span {(p : ℤ_[p]) ^ n})) : (a : ZMod (p ^ n)) = b := by simpa using zmod_congr_of_sub_mem_span_aux n x a b ha hb #align padic_int.zmod_congr_of_sub_mem_span PadicInt.zmod_congr_of_sub_mem_span theorem zmod_congr_of_sub_mem_max_ideal (x : ℤ_[p]) (m n : ℕ) (hm : x - m ∈ maximalIdeal ℤ_[p]) (hn : x - n ∈ maximalIdeal ℤ_[p]) : (m : ZMod p) = n := by rw [maximalIdeal_eq_span_p] at hm hn have := zmod_congr_of_sub_mem_span_aux 1 x m n simp only [pow_one] at this specialize this hm hn apply_fun ZMod.castHom (show p ∣ p ^ 1 by rw [pow_one]) (ZMod p) at this simp only [map_intCast] at this simpa only [Int.cast_natCast] using this #align padic_int.zmod_congr_of_sub_mem_max_ideal PadicInt.zmod_congr_of_sub_mem_max_ideal variable (x : ℤ_[p]) theorem exists_mem_range : ∃ n : ℕ, n < p ∧ x - n ∈ maximalIdeal ℤ_[p] := by simp only [maximalIdeal_eq_span_p, Ideal.mem_span_singleton, ← norm_lt_one_iff_dvd] obtain ⟨r, hr⟩ := rat_dense p (x : ℚ_[p]) zero_lt_one have H : ‖(r : ℚ_[p])‖ ≤ 1 := by rw [norm_sub_rev] at hr calc _ = ‖(r : ℚ_[p]) - x + x‖ := by ring_nf _ ≤ _ := padicNormE.nonarchimedean _ _ _ ≤ _ := max_le (le_of_lt hr) x.2 obtain ⟨n, hzn, hnp, hn⟩ := exists_mem_range_of_norm_rat_le_one r H lift n to ℕ using hzn use n constructor · exact mod_cast hnp simp only [norm_def, coe_sub, Subtype.coe_mk, coe_natCast] at hn ⊢ rw [show (x - n : ℚ_[p]) = x - r + (r - n) by ring] apply lt_of_le_of_lt (padicNormE.nonarchimedean _ _) apply max_lt hr simpa using hn #align padic_int.exists_mem_range PadicInt.exists_mem_range def zmodRepr : ℕ := Classical.choose (exists_mem_range x) #align padic_int.zmod_repr PadicInt.zmodRepr theorem zmodRepr_spec : zmodRepr x < p ∧ x - zmodRepr x ∈ maximalIdeal ℤ_[p] := Classical.choose_spec (exists_mem_range x) #align padic_int.zmod_repr_spec PadicInt.zmodRepr_spec theorem zmodRepr_lt_p : zmodRepr x < p := (zmodRepr_spec _).1 #align padic_int.zmod_repr_lt_p PadicInt.zmodRepr_lt_p theorem sub_zmodRepr_mem : x - zmodRepr x ∈ maximalIdeal ℤ_[p] := (zmodRepr_spec _).2 #align padic_int.sub_zmod_repr_mem PadicInt.sub_zmodRepr_mem def toZModHom (v : ℕ) (f : ℤ_[p] → ℕ) (f_spec : ∀ x, x - f x ∈ (Ideal.span {↑v} : Ideal ℤ_[p])) (f_congr : ∀ (x : ℤ_[p]) (a b : ℕ), x - a ∈ (Ideal.span {↑v} : Ideal ℤ_[p]) → x - b ∈ (Ideal.span {↑v} : Ideal ℤ_[p]) → (a : ZMod v) = b) : ℤ_[p] →+* ZMod v where toFun x := f x map_zero' := by dsimp only rw [f_congr (0 : ℤ_[p]) _ 0, cast_zero] · exact f_spec _ · simp only [sub_zero, cast_zero, Submodule.zero_mem] map_one' := by dsimp only rw [f_congr (1 : ℤ_[p]) _ 1, cast_one] · exact f_spec _ · simp only [sub_self, cast_one, Submodule.zero_mem] map_add' := by intro x y dsimp only rw [f_congr (x + y) _ (f x + f y), cast_add] · exact f_spec _ · convert Ideal.add_mem _ (f_spec x) (f_spec y) using 1 rw [cast_add] ring map_mul' := by intro x y dsimp only rw [f_congr (x * y) _ (f x * f y), cast_mul] · exact f_spec _ · let I : Ideal ℤ_[p] := Ideal.span {↑v} convert I.add_mem (I.mul_mem_left x (f_spec y)) (I.mul_mem_right ↑(f y) (f_spec x)) using 1 rw [cast_mul] ring #align padic_int.to_zmod_hom PadicInt.toZModHom def toZMod : ℤ_[p] →+* ZMod p := toZModHom p zmodRepr (by rw [← maximalIdeal_eq_span_p] exact sub_zmodRepr_mem) (by rw [← maximalIdeal_eq_span_p] exact zmod_congr_of_sub_mem_max_ideal) #align padic_int.to_zmod PadicInt.toZMod theorem toZMod_spec : x - (ZMod.cast (toZMod x) : ℤ_[p]) ∈ maximalIdeal ℤ_[p] := by convert sub_zmodRepr_mem x using 2 dsimp [toZMod, toZModHom] rcases Nat.exists_eq_add_of_lt hp_prime.1.pos with ⟨p', rfl⟩ change ↑((_ : ZMod (0 + p' + 1)).val) = (_ : ℤ_[0 + p' + 1]) simp only [ZMod.val_natCast, add_zero, add_def, Nat.cast_inj, zero_add] apply mod_eq_of_lt simpa only [zero_add] using zmodRepr_lt_p x #align padic_int.to_zmod_spec PadicInt.toZMod_spec theorem ker_toZMod : RingHom.ker (toZMod : ℤ_[p] →+* ZMod p) = maximalIdeal ℤ_[p] := by ext x rw [RingHom.mem_ker] constructor · intro h simpa only [h, ZMod.cast_zero, sub_zero] using toZMod_spec x · intro h rw [← sub_zero x] at h dsimp [toZMod, toZModHom] convert zmod_congr_of_sub_mem_max_ideal x _ 0 _ h · norm_cast · apply sub_zmodRepr_mem #align padic_int.ker_to_zmod PadicInt.ker_toZMod -- Porting note: removing irreducible solves a lot of problems noncomputable def appr : ℤ_[p] → ℕ → ℕ | _x, 0 => 0 | x, n + 1 => let y := x - appr x n if hy : y = 0 then appr x n else let u := (unitCoeff hy : ℤ_[p]) appr x n + p ^ n * (toZMod ((u * (p : ℤ_[p]) ^ (y.valuation - n).natAbs) : ℤ_[p])).val #align padic_int.appr PadicInt.appr theorem appr_lt (x : ℤ_[p]) (n : ℕ) : x.appr n < p ^ n := by induction' n with n ih generalizing x · simp only [appr, zero_eq, _root_.pow_zero, zero_lt_one] simp only [appr, map_natCast, ZMod.natCast_self, RingHom.map_pow, Int.natAbs, RingHom.map_mul] have hp : p ^ n < p ^ (n + 1) := by apply pow_lt_pow_right hp_prime.1.one_lt (lt_add_one n) split_ifs with h · apply lt_trans (ih _) hp · calc _ < p ^ n + p ^ n * (p - 1) := ?_ _ = p ^ (n + 1) := ?_ · apply add_lt_add_of_lt_of_le (ih _) apply Nat.mul_le_mul_left apply le_pred_of_lt apply ZMod.val_lt · rw [mul_tsub, mul_one, ← _root_.pow_succ] apply add_tsub_cancel_of_le (le_of_lt hp) #align padic_int.appr_lt PadicInt.appr_lt theorem appr_mono (x : ℤ_[p]) : Monotone x.appr := by apply monotone_nat_of_le_succ intro n dsimp [appr] split_ifs; · rfl apply Nat.le_add_right #align padic_int.appr_mono PadicInt.appr_mono theorem dvd_appr_sub_appr (x : ℤ_[p]) (m n : ℕ) (h : m ≤ n) : p ^ m ∣ x.appr n - x.appr m := by obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le h; clear h induction' k with k ih · simp only [zero_eq, add_zero, le_refl, tsub_eq_zero_of_le, ne_eq, Nat.isUnit_iff, dvd_zero] rw [← add_assoc] dsimp [appr] split_ifs with h · exact ih rw [add_comm, add_tsub_assoc_of_le (appr_mono _ (Nat.le_add_right m k))] apply dvd_add _ ih apply dvd_mul_of_dvd_left apply pow_dvd_pow _ (Nat.le_add_right m k) #align padic_int.dvd_appr_sub_appr PadicInt.dvd_appr_sub_appr theorem appr_spec (n : ℕ) : ∀ x : ℤ_[p], x - appr x n ∈ Ideal.span {(p : ℤ_[p]) ^ n} := by simp only [Ideal.mem_span_singleton] induction' n with n ih · simp only [zero_eq, _root_.pow_zero, isUnit_one, IsUnit.dvd, forall_const] intro x dsimp only [appr] split_ifs with h · rw [h] apply dvd_zero push_cast rw [sub_add_eq_sub_sub] obtain ⟨c, hc⟩ := ih x simp only [map_natCast, ZMod.natCast_self, RingHom.map_pow, RingHom.map_mul, ZMod.natCast_val] have hc' : c ≠ 0 := by rintro rfl simp only [mul_zero] at hc contradiction conv_rhs => congr simp only [hc] rw [show (x - (appr x n : ℤ_[p])).valuation = ((p : ℤ_[p]) ^ n * c).valuation by rw [hc]] rw [valuation_p_pow_mul _ _ hc', add_sub_cancel_left, _root_.pow_succ, ← mul_sub] apply mul_dvd_mul_left obtain hc0 | hc0 := eq_or_ne c.valuation.natAbs 0 · simp only [hc0, mul_one, _root_.pow_zero] rw [mul_comm, unitCoeff_spec h] at hc suffices c = unitCoeff h by rw [← this, ← Ideal.mem_span_singleton, ← maximalIdeal_eq_span_p] apply toZMod_spec obtain ⟨c, rfl⟩ : IsUnit c := by -- TODO: write a `CanLift` instance for units rw [Int.natAbs_eq_zero] at hc0 rw [isUnit_iff, norm_eq_pow_val hc', hc0, neg_zero, zpow_zero] rw [DiscreteValuationRing.unit_mul_pow_congr_unit _ _ _ _ _ hc] exact irreducible_p · simp only [zero_pow hc0, sub_zero, ZMod.cast_zero, mul_zero] rw [unitCoeff_spec hc'] exact (dvd_pow_self (p : ℤ_[p]) hc0).mul_left _ #align padic_int.appr_spec PadicInt.appr_spec def toZModPow (n : ℕ) : ℤ_[p] →+* ZMod (p ^ n) := toZModHom (p ^ n) (fun x => appr x n) (by intros rw [Nat.cast_pow] exact appr_spec n _) (by intro x a b ha hb apply zmod_congr_of_sub_mem_span n x a b · simpa using ha · simpa using hb) #align padic_int.to_zmod_pow PadicInt.toZModPow theorem ker_toZModPow (n : ℕ) : RingHom.ker (toZModPow n : ℤ_[p] →+* ZMod (p ^ n)) = Ideal.span {(p : ℤ_[p]) ^ n} := by ext x rw [RingHom.mem_ker] constructor · intro h suffices x.appr n = 0 by convert appr_spec n x simp only [this, sub_zero, cast_zero] dsimp [toZModPow, toZModHom] at h rw [ZMod.natCast_zmod_eq_zero_iff_dvd] at h apply eq_zero_of_dvd_of_lt h (appr_lt _ _) · intro h rw [← sub_zero x] at h dsimp [toZModPow, toZModHom] rw [zmod_congr_of_sub_mem_span n x _ 0 _ h, cast_zero] apply appr_spec #align padic_int.ker_to_zmod_pow PadicInt.ker_toZModPow -- @[simp] -- Porting note: not in simpNF theorem zmod_cast_comp_toZModPow (m n : ℕ) (h : m ≤ n) : (ZMod.castHom (pow_dvd_pow p h) (ZMod (p ^ m))).comp (@toZModPow p _ n) = @toZModPow p _ m := by apply ZMod.ringHom_eq_of_ker_eq ext x rw [RingHom.mem_ker, RingHom.mem_ker] simp only [Function.comp_apply, ZMod.castHom_apply, RingHom.coe_comp] simp only [toZModPow, toZModHom, RingHom.coe_mk] dsimp rw [ZMod.cast_natCast (pow_dvd_pow p h), zmod_congr_of_sub_mem_span m (x.appr n) (x.appr n) (x.appr m)] · rw [sub_self] apply Ideal.zero_mem _ · rw [Ideal.mem_span_singleton] rcases dvd_appr_sub_appr x m n h with ⟨c, hc⟩ use c rw [← Nat.cast_sub (appr_mono _ h), hc, Nat.cast_mul, Nat.cast_pow] #align padic_int.zmod_cast_comp_to_zmod_pow PadicInt.zmod_cast_comp_toZModPow @[simp] theorem cast_toZModPow (m n : ℕ) (h : m ≤ n) (x : ℤ_[p]) : ZMod.cast (toZModPow n x) = toZModPow m x := by rw [← zmod_cast_comp_toZModPow _ _ h] rfl #align padic_int.cast_to_zmod_pow PadicInt.cast_toZModPow
Mathlib/NumberTheory/Padics/RingHoms.lean
450
459
theorem denseRange_natCast : DenseRange (Nat.cast : ℕ → ℤ_[p]) := by
intro x rw [Metric.mem_closure_range_iff] intro ε hε obtain ⟨n, hn⟩ := exists_pow_neg_lt p hε use x.appr n rw [dist_eq_norm] apply lt_of_le_of_lt _ hn rw [norm_le_pow_iff_mem_span_pow] apply appr_spec
import Mathlib.Order.Ideal #align_import order.pfilter from "leanprover-community/mathlib"@"740acc0e6f9adf4423f92a485d0456fc271482da" open OrderDual namespace Order structure PFilter (P : Type*) [Preorder P] where dual : Ideal Pᵒᵈ #align order.pfilter Order.PFilter variable {P : Type*} def IsPFilter [Preorder P] (F : Set P) : Prop := IsIdeal (OrderDual.ofDual ⁻¹' F) #align order.is_pfilter Order.IsPFilter theorem IsPFilter.of_def [Preorder P] {F : Set P} (nonempty : F.Nonempty) (directed : DirectedOn (· ≥ ·) F) (mem_of_le : ∀ {x y : P}, x ≤ y → x ∈ F → y ∈ F) : IsPFilter F := ⟨fun _ _ _ _ => mem_of_le ‹_› ‹_›, nonempty, directed⟩ #align order.is_pfilter.of_def Order.IsPFilter.of_def def IsPFilter.toPFilter [Preorder P] {F : Set P} (h : IsPFilter F) : PFilter P := ⟨h.toIdeal⟩ #align order.is_pfilter.to_pfilter Order.IsPFilter.toPFilter namespace PFilter section Preorder variable [Preorder P] {x y : P} (F s t : PFilter P) instance [Inhabited P] : Inhabited (PFilter P) := ⟨⟨default⟩⟩ instance : SetLike (PFilter P) P where coe F := toDual ⁻¹' F.dual.carrier coe_injective' := fun ⟨_⟩ ⟨_⟩ h => congr_arg mk <| Ideal.ext h #align order.pfilter.mem_coe SetLike.mem_coeₓ theorem isPFilter : IsPFilter (F : Set P) := F.dual.isIdeal #align order.pfilter.is_pfilter Order.PFilter.isPFilter protected theorem nonempty : (F : Set P).Nonempty := F.dual.nonempty #align order.pfilter.nonempty Order.PFilter.nonempty theorem directed : DirectedOn (· ≥ ·) (F : Set P) := F.dual.directed #align order.pfilter.directed Order.PFilter.directed theorem mem_of_le {F : PFilter P} : x ≤ y → x ∈ F → y ∈ F := fun h => F.dual.lower h #align order.pfilter.mem_of_le Order.PFilter.mem_of_le @[ext] theorem ext (h : (s : Set P) = t) : s = t := SetLike.ext' h #align order.pfilter.ext Order.PFilter.ext @[trans] theorem mem_of_mem_of_le {F G : PFilter P} (hx : x ∈ F) (hle : F ≤ G) : x ∈ G := hle hx #align order.pfilter.mem_of_mem_of_le Order.PFilter.mem_of_mem_of_le def principal (p : P) : PFilter P := ⟨Ideal.principal (toDual p)⟩ #align order.pfilter.principal Order.PFilter.principal @[simp] theorem mem_mk (x : P) (I : Ideal Pᵒᵈ) : x ∈ (⟨I⟩ : PFilter P) ↔ toDual x ∈ I := Iff.rfl #align order.pfilter.mem_def Order.PFilter.mem_mk @[simp] theorem principal_le_iff {F : PFilter P} : principal x ≤ F ↔ x ∈ F := Ideal.principal_le_iff (x := toDual x) #align order.pfilter.principal_le_iff Order.PFilter.principal_le_iff @[simp] theorem mem_principal : x ∈ principal y ↔ y ≤ x := Iff.rfl #align order.pfilter.mem_principal Order.PFilter.mem_principal
Mathlib/Order/PFilter.lean
120
120
theorem principal_le_principal_iff {p q : P} : principal q ≤ principal p ↔ p ≤ q := by
simp
import Mathlib.Data.Fin.Tuple.Basic import Mathlib.Data.List.Join #align_import data.list.of_fn from "leanprover-community/mathlib"@"bf27744463e9620ca4e4ebe951fe83530ae6949b" universe u variable {α : Type u} open Nat namespace List #noalign list.length_of_fn_aux @[simp] theorem length_ofFn_go {n} (f : Fin n → α) (i j h) : length (ofFn.go f i j h) = i := by induction i generalizing j <;> simp_all [ofFn.go] @[simp] theorem length_ofFn {n} (f : Fin n → α) : length (ofFn f) = n := by simp [ofFn, length_ofFn_go] #align list.length_of_fn List.length_ofFn #noalign list.nth_of_fn_aux theorem get_ofFn_go {n} (f : Fin n → α) (i j h) (k) (hk) : get (ofFn.go f i j h) ⟨k, hk⟩ = f ⟨j + k, by simp at hk; omega⟩ := by let i+1 := i cases k <;> simp [ofFn.go, get_ofFn_go (i := i)] congr 2; omega -- Porting note (#10756): new theorem @[simp] theorem get_ofFn {n} (f : Fin n → α) (i) : get (ofFn f) i = f (Fin.cast (by simp) i) := by cases i; simp [ofFn, get_ofFn_go] @[simp] theorem get?_ofFn {n} (f : Fin n → α) (i) : get? (ofFn f) i = ofFnNthVal f i := if h : i < (ofFn f).length then by rw [get?_eq_get h, get_ofFn] · simp only [length_ofFn] at h; simp [ofFnNthVal, h] else by rw [ofFnNthVal, dif_neg] <;> simpa using h #align list.nth_of_fn List.get?_ofFn set_option linter.deprecated false in @[deprecated get_ofFn (since := "2023-01-17")] theorem nthLe_ofFn {n} (f : Fin n → α) (i : Fin n) : nthLe (ofFn f) i ((length_ofFn f).symm ▸ i.2) = f i := by simp [nthLe] #align list.nth_le_of_fn List.nthLe_ofFn set_option linter.deprecated false in @[simp, deprecated get_ofFn (since := "2023-01-17")] theorem nthLe_ofFn' {n} (f : Fin n → α) {i : ℕ} (h : i < (ofFn f).length) : nthLe (ofFn f) i h = f ⟨i, length_ofFn f ▸ h⟩ := nthLe_ofFn f ⟨i, length_ofFn f ▸ h⟩ #align list.nth_le_of_fn' List.nthLe_ofFn' @[simp] theorem map_ofFn {β : Type*} {n : ℕ} (f : Fin n → α) (g : α → β) : map g (ofFn f) = ofFn (g ∘ f) := ext_get (by simp) fun i h h' => by simp #align list.map_of_fn List.map_ofFn -- Porting note: we don't have Array' in mathlib4 -- -- theorem array_eq_of_fn {n} (a : Array' n α) : a.toList = ofFn a.read := -- by -- suffices ∀ {m h l}, DArray.revIterateAux a (fun i => cons) m h l = -- ofFnAux (DArray.read a) m h l -- from this -- intros; induction' m with m IH generalizing l; · rfl -- simp only [DArray.revIterateAux, of_fn_aux, IH] -- #align list.array_eq_of_fn List.array_eq_of_fn @[congr] theorem ofFn_congr {m n : ℕ} (h : m = n) (f : Fin m → α) : ofFn f = ofFn fun i : Fin n => f (Fin.cast h.symm i) := by subst h simp_rw [Fin.cast_refl, id] #align list.of_fn_congr List.ofFn_congr @[simp] theorem ofFn_zero (f : Fin 0 → α) : ofFn f = [] := ext_get (by simp) (fun i hi₁ hi₂ => by contradiction) #align list.of_fn_zero List.ofFn_zero @[simp] theorem ofFn_succ {n} (f : Fin (succ n) → α) : ofFn f = f 0 :: ofFn fun i => f i.succ := ext_get (by simp) (fun i hi₁ hi₂ => by cases i · simp; rfl · simp) #align list.of_fn_succ List.ofFn_succ theorem ofFn_succ' {n} (f : Fin (succ n) → α) : ofFn f = (ofFn fun i => f (Fin.castSucc i)).concat (f (Fin.last _)) := by induction' n with n IH · rw [ofFn_zero, concat_nil, ofFn_succ, ofFn_zero] rfl · rw [ofFn_succ, IH, ofFn_succ, concat_cons, Fin.castSucc_zero] congr #align list.of_fn_succ' List.ofFn_succ' @[simp] theorem ofFn_eq_nil_iff {n : ℕ} {f : Fin n → α} : ofFn f = [] ↔ n = 0 := by cases n <;> simp only [ofFn_zero, ofFn_succ, eq_self_iff_true, Nat.succ_ne_zero] #align list.of_fn_eq_nil_iff List.ofFn_eq_nil_iff
Mathlib/Data/List/OfFn.lean
139
141
theorem last_ofFn {n : ℕ} (f : Fin n → α) (h : ofFn f ≠ []) (hn : n - 1 < n := Nat.pred_lt <| ofFn_eq_nil_iff.not.mp h) : getLast (ofFn f) h = f ⟨n - 1, hn⟩ := by
simp [getLast_eq_get]
import Mathlib.Algebra.Ring.Int import Mathlib.Data.Nat.Bitwise import Mathlib.Data.Nat.Size #align_import data.int.bitwise from "leanprover-community/mathlib"@"0743cc5d9d86bcd1bba10f480e948a257d65056f" #align_import init.data.int.bitwise from "leanprover-community/lean"@"855e5b74e3a52a40552e8f067169d747d48743fd" namespace Int def div2 : ℤ → ℤ | (n : ℕ) => n.div2 | -[n +1] => negSucc n.div2 #align int.div2 Int.div2 def bodd : ℤ → Bool | (n : ℕ) => n.bodd | -[n +1] => not (n.bodd) #align int.bodd Int.bodd -- Porting note: `bit0, bit1` deprecated, do we need to adapt `bit`? set_option linter.deprecated false in def bit (b : Bool) : ℤ → ℤ := cond b bit1 bit0 #align int.bit Int.bit def testBit : ℤ → ℕ → Bool | (m : ℕ), n => Nat.testBit m n | -[m +1], n => !(Nat.testBit m n) #align int.test_bit Int.testBit def natBitwise (f : Bool → Bool → Bool) (m n : ℕ) : ℤ := cond (f false false) -[ Nat.bitwise (fun x y => not (f x y)) m n +1] (Nat.bitwise f m n) #align int.nat_bitwise Int.natBitwise def bitwise (f : Bool → Bool → Bool) : ℤ → ℤ → ℤ | (m : ℕ), (n : ℕ) => natBitwise f m n | (m : ℕ), -[n +1] => natBitwise (fun x y => f x (not y)) m n | -[m +1], (n : ℕ) => natBitwise (fun x y => f (not x) y) m n | -[m +1], -[n +1] => natBitwise (fun x y => f (not x) (not y)) m n #align int.bitwise Int.bitwise def lnot : ℤ → ℤ | (m : ℕ) => -[m +1] | -[m +1] => m #align int.lnot Int.lnot def lor : ℤ → ℤ → ℤ | (m : ℕ), (n : ℕ) => m ||| n | (m : ℕ), -[n +1] => -[Nat.ldiff n m +1] | -[m +1], (n : ℕ) => -[Nat.ldiff m n +1] | -[m +1], -[n +1] => -[m &&& n +1] #align int.lor Int.lor def land : ℤ → ℤ → ℤ | (m : ℕ), (n : ℕ) => m &&& n | (m : ℕ), -[n +1] => Nat.ldiff m n | -[m +1], (n : ℕ) => Nat.ldiff n m | -[m +1], -[n +1] => -[m ||| n +1] #align int.land Int.land -- Porting note: I don't know why `Nat.ldiff` got the prime, but I'm matching this change here def ldiff : ℤ → ℤ → ℤ | (m : ℕ), (n : ℕ) => Nat.ldiff m n | (m : ℕ), -[n +1] => m &&& n | -[m +1], (n : ℕ) => -[m ||| n +1] | -[m +1], -[n +1] => Nat.ldiff n m #align int.ldiff Int.ldiff -- Porting note: I don't know why `Nat.xor'` got the prime, but I'm matching this change here protected def xor : ℤ → ℤ → ℤ | (m : ℕ), (n : ℕ) => (m ^^^ n) | (m : ℕ), -[n +1] => -[(m ^^^ n) +1] | -[m +1], (n : ℕ) => -[(m ^^^ n) +1] | -[m +1], -[n +1] => (m ^^^ n) #align int.lxor Int.xor instance : ShiftLeft ℤ where shiftLeft | (m : ℕ), (n : ℕ) => Nat.shiftLeft' false m n | (m : ℕ), -[n +1] => m >>> (Nat.succ n) | -[m +1], (n : ℕ) => -[Nat.shiftLeft' true m n +1] | -[m +1], -[n +1] => -[m >>> (Nat.succ n) +1] #align int.shiftl ShiftLeft.shiftLeft instance : ShiftRight ℤ where shiftRight m n := m <<< (-n) #align int.shiftr ShiftRight.shiftRight @[simp] theorem bodd_zero : bodd 0 = false := rfl #align int.bodd_zero Int.bodd_zero @[simp] theorem bodd_one : bodd 1 = true := rfl #align int.bodd_one Int.bodd_one theorem bodd_two : bodd 2 = false := rfl #align int.bodd_two Int.bodd_two @[simp, norm_cast] theorem bodd_coe (n : ℕ) : Int.bodd n = Nat.bodd n := rfl #align int.bodd_coe Int.bodd_coe @[simp] theorem bodd_subNatNat (m n : ℕ) : bodd (subNatNat m n) = xor m.bodd n.bodd := by apply subNatNat_elim m n fun m n i => bodd i = xor m.bodd n.bodd <;> intros i j <;> simp only [Int.bodd, Int.bodd_coe, Nat.bodd_add] <;> cases Nat.bodd i <;> simp #align int.bodd_sub_nat_nat Int.bodd_subNatNat @[simp] theorem bodd_negOfNat (n : ℕ) : bodd (negOfNat n) = n.bodd := by cases n <;> simp (config := {decide := true}) rfl #align int.bodd_neg_of_nat Int.bodd_negOfNat @[simp] theorem bodd_neg (n : ℤ) : bodd (-n) = bodd n := by cases n with | ofNat => rw [← negOfNat_eq, bodd_negOfNat] simp | negSucc n => rw [neg_negSucc, bodd_coe, Nat.bodd_succ] change (!Nat.bodd n) = !(bodd n) rw [bodd_coe] -- Porting note: Heavily refactored proof, used to work all with `simp`: -- `cases n <;> simp [Neg.neg, Int.natCast_eq_ofNat, Int.neg, bodd, -of_nat_eq_coe]` #align int.bodd_neg Int.bodd_neg @[simp] theorem bodd_add (m n : ℤ) : bodd (m + n) = xor (bodd m) (bodd n) := by cases' m with m m <;> cases' n with n n <;> simp only [ofNat_eq_coe, ofNat_add_negSucc, negSucc_add_ofNat, negSucc_add_negSucc, bodd_subNatNat] <;> simp only [negSucc_coe, bodd_neg, bodd_coe, ← Nat.bodd_add, Bool.xor_comm, ← Nat.cast_add] rw [← Nat.succ_add, add_assoc] -- Porting note: Heavily refactored proof, used to work all with `simp`: -- `by cases m with m m; cases n with n n; unfold has_add.add;` -- `simp [int.add, -of_nat_eq_coe, bool.xor_comm]` #align int.bodd_add Int.bodd_add @[simp] theorem bodd_mul (m n : ℤ) : bodd (m * n) = (bodd m && bodd n) := by cases' m with m m <;> cases' n with n n <;> simp only [ofNat_eq_coe, ofNat_mul_negSucc, negSucc_mul_ofNat, ofNat_mul_ofNat, negSucc_mul_negSucc] <;> simp only [negSucc_coe, bodd_neg, bodd_coe, ← Nat.bodd_mul] -- Porting note: Heavily refactored proof, used to be: -- `by cases m with m m; cases n with n n;` -- `simp [← int.mul_def, int.mul, -of_nat_eq_coe, bool.xor_comm]` #align int.bodd_mul Int.bodd_mul theorem bodd_add_div2 : ∀ n, cond (bodd n) 1 0 + 2 * div2 n = n | (n : ℕ) => by rw [show (cond (bodd n) 1 0 : ℤ) = (cond (bodd n) 1 0 : ℕ) by cases bodd n <;> rfl] exact congr_arg ofNat n.bodd_add_div2 | -[n+1] => by refine Eq.trans ?_ (congr_arg negSucc n.bodd_add_div2) dsimp [bodd]; cases Nat.bodd n <;> dsimp [cond, not, div2, Int.mul] · change -[2 * Nat.div2 n+1] = _ rw [zero_add] · rw [zero_add, add_comm] rfl #align int.bodd_add_div2 Int.bodd_add_div2 theorem div2_val : ∀ n, div2 n = n / 2 | (n : ℕ) => congr_arg ofNat n.div2_val | -[n+1] => congr_arg negSucc n.div2_val #align int.div2_val Int.div2_val section deprecated set_option linter.deprecated false @[deprecated] theorem bit0_val (n : ℤ) : bit0 n = 2 * n := (two_mul _).symm #align int.bit0_val Int.bit0_val @[deprecated] theorem bit1_val (n : ℤ) : bit1 n = 2 * n + 1 := congr_arg (· + (1 : ℤ)) (bit0_val _) #align int.bit1_val Int.bit1_val theorem bit_val (b n) : bit b n = 2 * n + cond b 1 0 := by cases b · apply (bit0_val n).trans (add_zero _).symm · apply bit1_val #align int.bit_val Int.bit_val theorem bit_decomp (n : ℤ) : bit (bodd n) (div2 n) = n := (bit_val _ _).trans <| (add_comm _ _).trans <| bodd_add_div2 _ #align int.bit_decomp Int.bit_decomp def bitCasesOn.{u} {C : ℤ → Sort u} (n) (h : ∀ b n, C (bit b n)) : C n := by rw [← bit_decomp n] apply h #align int.bit_cases_on Int.bitCasesOn @[simp] theorem bit_zero : bit false 0 = 0 := rfl #align int.bit_zero Int.bit_zero @[simp] theorem bit_coe_nat (b) (n : ℕ) : bit b n = Nat.bit b n := by rw [bit_val, Nat.bit_val] cases b <;> rfl #align int.bit_coe_nat Int.bit_coe_nat @[simp] theorem bit_negSucc (b) (n : ℕ) : bit b -[n+1] = -[Nat.bit (not b) n+1] := by rw [bit_val, Nat.bit_val] cases b <;> rfl #align int.bit_neg_succ Int.bit_negSucc @[simp] theorem bodd_bit (b n) : bodd (bit b n) = b := by rw [bit_val] cases b <;> cases bodd n <;> simp [(show bodd 2 = false by rfl)] #align int.bodd_bit Int.bodd_bit @[simp, deprecated] theorem bodd_bit0 (n : ℤ) : bodd (bit0 n) = false := bodd_bit false n #align int.bodd_bit0 Int.bodd_bit0 @[simp, deprecated] theorem bodd_bit1 (n : ℤ) : bodd (bit1 n) = true := bodd_bit true n #align int.bodd_bit1 Int.bodd_bit1 @[deprecated] theorem bit0_ne_bit1 (m n : ℤ) : bit0 m ≠ bit1 n := mt (congr_arg bodd) <| by simp #align int.bit0_ne_bit1 Int.bit0_ne_bit1 @[deprecated] theorem bit1_ne_bit0 (m n : ℤ) : bit1 m ≠ bit0 n := (bit0_ne_bit1 _ _).symm #align int.bit1_ne_bit0 Int.bit1_ne_bit0 @[deprecated]
Mathlib/Data/Int/Bitwise.lean
289
289
theorem bit1_ne_zero (m : ℤ) : bit1 m ≠ 0 := by
simpa only [bit0_zero] using bit1_ne_bit0 m 0
import Mathlib.Algebra.ModEq import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.Archimedean import Mathlib.Algebra.Periodic import Mathlib.Data.Int.SuccPred import Mathlib.GroupTheory.QuotientGroup import Mathlib.Order.Circular import Mathlib.Data.List.TFAE import Mathlib.Data.Set.Lattice #align_import algebra.order.to_interval_mod from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec" noncomputable section section LinearOrderedAddCommGroup variable {α : Type*} [LinearOrderedAddCommGroup α] [hα : Archimedean α] {p : α} (hp : 0 < p) {a b c : α} {n : ℤ} def toIcoDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ico hp b a).choose #align to_Ico_div toIcoDiv theorem sub_toIcoDiv_zsmul_mem_Ico (a b : α) : b - toIcoDiv hp a b • p ∈ Set.Ico a (a + p) := (existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.1 #align sub_to_Ico_div_zsmul_mem_Ico sub_toIcoDiv_zsmul_mem_Ico theorem toIcoDiv_eq_of_sub_zsmul_mem_Ico (h : b - n • p ∈ Set.Ico a (a + p)) : toIcoDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.2 _ h).symm #align to_Ico_div_eq_of_sub_zsmul_mem_Ico toIcoDiv_eq_of_sub_zsmul_mem_Ico def toIocDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose #align to_Ioc_div toIocDiv theorem sub_toIocDiv_zsmul_mem_Ioc (a b : α) : b - toIocDiv hp a b • p ∈ Set.Ioc a (a + p) := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.1 #align sub_to_Ioc_div_zsmul_mem_Ioc sub_toIocDiv_zsmul_mem_Ioc theorem toIocDiv_eq_of_sub_zsmul_mem_Ioc (h : b - n • p ∈ Set.Ioc a (a + p)) : toIocDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.2 _ h).symm #align to_Ioc_div_eq_of_sub_zsmul_mem_Ioc toIocDiv_eq_of_sub_zsmul_mem_Ioc def toIcoMod (a b : α) : α := b - toIcoDiv hp a b • p #align to_Ico_mod toIcoMod def toIocMod (a b : α) : α := b - toIocDiv hp a b • p #align to_Ioc_mod toIocMod theorem toIcoMod_mem_Ico (a b : α) : toIcoMod hp a b ∈ Set.Ico a (a + p) := sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_mod_mem_Ico toIcoMod_mem_Ico theorem toIcoMod_mem_Ico' (b : α) : toIcoMod hp 0 b ∈ Set.Ico 0 p := by convert toIcoMod_mem_Ico hp 0 b exact (zero_add p).symm #align to_Ico_mod_mem_Ico' toIcoMod_mem_Ico' theorem toIocMod_mem_Ioc (a b : α) : toIocMod hp a b ∈ Set.Ioc a (a + p) := sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_mod_mem_Ioc toIocMod_mem_Ioc theorem left_le_toIcoMod (a b : α) : a ≤ toIcoMod hp a b := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).1 #align left_le_to_Ico_mod left_le_toIcoMod theorem left_lt_toIocMod (a b : α) : a < toIocMod hp a b := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).1 #align left_lt_to_Ioc_mod left_lt_toIocMod theorem toIcoMod_lt_right (a b : α) : toIcoMod hp a b < a + p := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).2 #align to_Ico_mod_lt_right toIcoMod_lt_right theorem toIocMod_le_right (a b : α) : toIocMod hp a b ≤ a + p := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).2 #align to_Ioc_mod_le_right toIocMod_le_right @[simp] theorem self_sub_toIcoDiv_zsmul (a b : α) : b - toIcoDiv hp a b • p = toIcoMod hp a b := rfl #align self_sub_to_Ico_div_zsmul self_sub_toIcoDiv_zsmul @[simp] theorem self_sub_toIocDiv_zsmul (a b : α) : b - toIocDiv hp a b • p = toIocMod hp a b := rfl #align self_sub_to_Ioc_div_zsmul self_sub_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_self (a b : α) : toIcoDiv hp a b • p - b = -toIcoMod hp a b := by rw [toIcoMod, neg_sub] #align to_Ico_div_zsmul_sub_self toIcoDiv_zsmul_sub_self @[simp] theorem toIocDiv_zsmul_sub_self (a b : α) : toIocDiv hp a b • p - b = -toIocMod hp a b := by rw [toIocMod, neg_sub] #align to_Ioc_div_zsmul_sub_self toIocDiv_zsmul_sub_self @[simp] theorem toIcoMod_sub_self (a b : α) : toIcoMod hp a b - b = -toIcoDiv hp a b • p := by rw [toIcoMod, sub_sub_cancel_left, neg_smul] #align to_Ico_mod_sub_self toIcoMod_sub_self @[simp] theorem toIocMod_sub_self (a b : α) : toIocMod hp a b - b = -toIocDiv hp a b • p := by rw [toIocMod, sub_sub_cancel_left, neg_smul] #align to_Ioc_mod_sub_self toIocMod_sub_self @[simp] theorem self_sub_toIcoMod (a b : α) : b - toIcoMod hp a b = toIcoDiv hp a b • p := by rw [toIcoMod, sub_sub_cancel] #align self_sub_to_Ico_mod self_sub_toIcoMod @[simp] theorem self_sub_toIocMod (a b : α) : b - toIocMod hp a b = toIocDiv hp a b • p := by rw [toIocMod, sub_sub_cancel] #align self_sub_to_Ioc_mod self_sub_toIocMod @[simp] theorem toIcoMod_add_toIcoDiv_zsmul (a b : α) : toIcoMod hp a b + toIcoDiv hp a b • p = b := by rw [toIcoMod, sub_add_cancel] #align to_Ico_mod_add_to_Ico_div_zsmul toIcoMod_add_toIcoDiv_zsmul @[simp] theorem toIocMod_add_toIocDiv_zsmul (a b : α) : toIocMod hp a b + toIocDiv hp a b • p = b := by rw [toIocMod, sub_add_cancel] #align to_Ioc_mod_add_to_Ioc_div_zsmul toIocMod_add_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_toIcoMod (a b : α) : toIcoDiv hp a b • p + toIcoMod hp a b = b := by rw [add_comm, toIcoMod_add_toIcoDiv_zsmul] #align to_Ico_div_zsmul_sub_to_Ico_mod toIcoDiv_zsmul_sub_toIcoMod @[simp] theorem toIocDiv_zsmul_sub_toIocMod (a b : α) : toIocDiv hp a b • p + toIocMod hp a b = b := by rw [add_comm, toIocMod_add_toIocDiv_zsmul] #align to_Ioc_div_zsmul_sub_to_Ioc_mod toIocDiv_zsmul_sub_toIocMod theorem toIcoMod_eq_iff : toIcoMod hp a b = c ↔ c ∈ Set.Ico a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by refine ⟨fun h => ⟨h ▸ toIcoMod_mem_Ico hp a b, toIcoDiv hp a b, h ▸ (toIcoMod_add_toIcoDiv_zsmul _ _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIcoDiv_eq_of_sub_zsmul_mem_Ico hp hc, toIcoMod] #align to_Ico_mod_eq_iff toIcoMod_eq_iff theorem toIocMod_eq_iff : toIocMod hp a b = c ↔ c ∈ Set.Ioc a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by refine ⟨fun h => ⟨h ▸ toIocMod_mem_Ioc hp a b, toIocDiv hp a b, h ▸ (toIocMod_add_toIocDiv_zsmul hp _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIocDiv_eq_of_sub_zsmul_mem_Ioc hp hc, toIocMod] #align to_Ioc_mod_eq_iff toIocMod_eq_iff @[simp] theorem toIcoDiv_apply_left (a : α) : toIcoDiv hp a a = 0 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_left toIcoDiv_apply_left @[simp] theorem toIocDiv_apply_left (a : α) : toIocDiv hp a a = -1 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_left toIocDiv_apply_left @[simp] theorem toIcoMod_apply_left (a : α) : toIcoMod hp a a = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ico_mod_apply_left toIcoMod_apply_left @[simp] theorem toIocMod_apply_left (a : α) : toIocMod hp a a = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, -1, by simp⟩ #align to_Ioc_mod_apply_left toIocMod_apply_left theorem toIcoDiv_apply_right (a : α) : toIcoDiv hp a (a + p) = 1 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_right toIcoDiv_apply_right theorem toIocDiv_apply_right (a : α) : toIocDiv hp a (a + p) = 0 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_right toIocDiv_apply_right theorem toIcoMod_apply_right (a : α) : toIcoMod hp a (a + p) = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 1, by simp⟩ #align to_Ico_mod_apply_right toIcoMod_apply_right theorem toIocMod_apply_right (a : α) : toIocMod hp a (a + p) = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ioc_mod_apply_right toIocMod_apply_right @[simp] theorem toIcoDiv_add_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b + m • p) = toIcoDiv hp a b + m := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul toIcoDiv_add_zsmul @[simp] theorem toIcoDiv_add_zsmul' (a b : α) (m : ℤ) : toIcoDiv hp (a + m • p) b = toIcoDiv hp a b - m := by refine toIcoDiv_eq_of_sub_zsmul_mem_Ico _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul' toIcoDiv_add_zsmul' @[simp] theorem toIocDiv_add_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b + m • p) = toIocDiv hp a b + m := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul toIocDiv_add_zsmul @[simp] theorem toIocDiv_add_zsmul' (a b : α) (m : ℤ) : toIocDiv hp (a + m • p) b = toIocDiv hp a b - m := by refine toIocDiv_eq_of_sub_zsmul_mem_Ioc _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul' toIocDiv_add_zsmul' @[simp] theorem toIcoDiv_zsmul_add (a b : α) (m : ℤ) : toIcoDiv hp a (m • p + b) = m + toIcoDiv hp a b := by rw [add_comm, toIcoDiv_add_zsmul, add_comm] #align to_Ico_div_zsmul_add toIcoDiv_zsmul_add @[simp] theorem toIocDiv_zsmul_add (a b : α) (m : ℤ) : toIocDiv hp a (m • p + b) = m + toIocDiv hp a b := by rw [add_comm, toIocDiv_add_zsmul, add_comm] #align to_Ioc_div_zsmul_add toIocDiv_zsmul_add @[simp] theorem toIcoDiv_sub_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b - m • p) = toIcoDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul, sub_eq_add_neg] #align to_Ico_div_sub_zsmul toIcoDiv_sub_zsmul @[simp] theorem toIcoDiv_sub_zsmul' (a b : α) (m : ℤ) : toIcoDiv hp (a - m • p) b = toIcoDiv hp a b + m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul', sub_neg_eq_add] #align to_Ico_div_sub_zsmul' toIcoDiv_sub_zsmul' @[simp] theorem toIocDiv_sub_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b - m • p) = toIocDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul, sub_eq_add_neg] #align to_Ioc_div_sub_zsmul toIocDiv_sub_zsmul @[simp] theorem toIocDiv_sub_zsmul' (a b : α) (m : ℤ) : toIocDiv hp (a - m • p) b = toIocDiv hp a b + m := by rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul', sub_neg_eq_add] #align to_Ioc_div_sub_zsmul' toIocDiv_sub_zsmul' @[simp] theorem toIcoDiv_add_right (a b : α) : toIcoDiv hp a (b + p) = toIcoDiv hp a b + 1 := by simpa only [one_zsmul] using toIcoDiv_add_zsmul hp a b 1 #align to_Ico_div_add_right toIcoDiv_add_right @[simp] theorem toIcoDiv_add_right' (a b : α) : toIcoDiv hp (a + p) b = toIcoDiv hp a b - 1 := by simpa only [one_zsmul] using toIcoDiv_add_zsmul' hp a b 1 #align to_Ico_div_add_right' toIcoDiv_add_right' @[simp]
Mathlib/Algebra/Order/ToIntervalMod.lean
309
310
theorem toIocDiv_add_right (a b : α) : toIocDiv hp a (b + p) = toIocDiv hp a b + 1 := by
simpa only [one_zsmul] using toIocDiv_add_zsmul hp a b 1
import Mathlib.Analysis.NormedSpace.Multilinear.Basic #align_import analysis.normed_space.multilinear from "leanprover-community/mathlib"@"f40476639bac089693a489c9e354ebd75dc0f886" suppress_compilation noncomputable section open NNReal Finset Metric ContinuousMultilinearMap Fin Function universe u v v' wE wE₁ wE' wEi wG wG' variable {𝕜 : Type u} {ι : Type v} {ι' : Type v'} {n : ℕ} {E : ι → Type wE} {E₁ : ι → Type wE₁} {E' : ι' → Type wE'} {Ei : Fin n.succ → Type wEi} {G : Type wG} {G' : Type wG'} [Fintype ι] [Fintype ι'] [NontriviallyNormedField 𝕜] [∀ i, NormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)] [∀ i, NormedAddCommGroup (E₁ i)] [∀ i, NormedSpace 𝕜 (E₁ i)] [∀ i, NormedAddCommGroup (E' i)] [∀ i, NormedSpace 𝕜 (E' i)] [∀ i, NormedAddCommGroup (Ei i)] [∀ i, NormedSpace 𝕜 (Ei i)] [NormedAddCommGroup G] [NormedSpace 𝕜 G] [NormedAddCommGroup G'] [NormedSpace 𝕜 G'] theorem ContinuousLinearMap.norm_map_tail_le (f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) (m : ∀ i, Ei i) : ‖f (m 0) (tail m)‖ ≤ ‖f‖ * ∏ i, ‖m i‖ := calc ‖f (m 0) (tail m)‖ ≤ ‖f (m 0)‖ * ∏ i, ‖(tail m) i‖ := (f (m 0)).le_opNorm _ _ ≤ ‖f‖ * ‖m 0‖ * ∏ i, ‖tail m i‖ := mul_le_mul_of_nonneg_right (f.le_opNorm _) <| by positivity _ = ‖f‖ * (‖m 0‖ * ∏ i, ‖(tail m) i‖) := by ring _ = ‖f‖ * ∏ i, ‖m i‖ := by rw [prod_univ_succ] rfl #align continuous_linear_map.norm_map_tail_le ContinuousLinearMap.norm_map_tail_le theorem ContinuousMultilinearMap.norm_map_init_le (f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G)) (m : ∀ i, Ei i) : ‖f (init m) (m (last n))‖ ≤ ‖f‖ * ∏ i, ‖m i‖ := calc ‖f (init m) (m (last n))‖ ≤ ‖f (init m)‖ * ‖m (last n)‖ := (f (init m)).le_opNorm _ _ ≤ (‖f‖ * ∏ i, ‖(init m) i‖) * ‖m (last n)‖ := (mul_le_mul_of_nonneg_right (f.le_opNorm _) (norm_nonneg _)) _ = ‖f‖ * ((∏ i, ‖(init m) i‖) * ‖m (last n)‖) := mul_assoc _ _ _ _ = ‖f‖ * ∏ i, ‖m i‖ := by rw [prod_univ_castSucc] rfl #align continuous_multilinear_map.norm_map_init_le ContinuousMultilinearMap.norm_map_init_le theorem ContinuousMultilinearMap.norm_map_cons_le (f : ContinuousMultilinearMap 𝕜 Ei G) (x : Ei 0) (m : ∀ i : Fin n, Ei i.succ) : ‖f (cons x m)‖ ≤ ‖f‖ * ‖x‖ * ∏ i, ‖m i‖ := calc ‖f (cons x m)‖ ≤ ‖f‖ * ∏ i, ‖cons x m i‖ := f.le_opNorm _ _ = ‖f‖ * ‖x‖ * ∏ i, ‖m i‖ := by rw [prod_univ_succ] simp [mul_assoc] #align continuous_multilinear_map.norm_map_cons_le ContinuousMultilinearMap.norm_map_cons_le theorem ContinuousMultilinearMap.norm_map_snoc_le (f : ContinuousMultilinearMap 𝕜 Ei G) (m : ∀ i : Fin n, Ei <| castSucc i) (x : Ei (last n)) : ‖f (snoc m x)‖ ≤ (‖f‖ * ∏ i, ‖m i‖) * ‖x‖ := calc ‖f (snoc m x)‖ ≤ ‖f‖ * ∏ i, ‖snoc m x i‖ := f.le_opNorm _ _ = (‖f‖ * ∏ i, ‖m i‖) * ‖x‖ := by rw [prod_univ_castSucc] simp [mul_assoc] #align continuous_multilinear_map.norm_map_snoc_le ContinuousMultilinearMap.norm_map_snoc_le def ContinuousLinearMap.uncurryLeft (f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) : ContinuousMultilinearMap 𝕜 Ei G := (@LinearMap.uncurryLeft 𝕜 n Ei G _ _ _ _ _ (ContinuousMultilinearMap.toMultilinearMapLinear.comp f.toLinearMap)).mkContinuous ‖f‖ fun m => by exact ContinuousLinearMap.norm_map_tail_le f m #align continuous_linear_map.uncurry_left ContinuousLinearMap.uncurryLeft @[simp] theorem ContinuousLinearMap.uncurryLeft_apply (f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) (m : ∀ i, Ei i) : f.uncurryLeft m = f (m 0) (tail m) := rfl #align continuous_linear_map.uncurry_left_apply ContinuousLinearMap.uncurryLeft_apply def ContinuousMultilinearMap.curryLeft (f : ContinuousMultilinearMap 𝕜 Ei G) : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G := LinearMap.mkContinuous { -- define a linear map into `n` continuous multilinear maps -- from an `n+1` continuous multilinear map toFun := fun x => (f.toMultilinearMap.curryLeft x).mkContinuous (‖f‖ * ‖x‖) (f.norm_map_cons_le x) map_add' := fun x y => by ext m exact f.cons_add m x y map_smul' := fun c x => by ext m exact f.cons_smul m c x }-- then register its continuity thanks to its boundedness properties. ‖f‖ fun x => by rw [LinearMap.coe_mk, AddHom.coe_mk] exact MultilinearMap.mkContinuous_norm_le _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) _ #align continuous_multilinear_map.curry_left ContinuousMultilinearMap.curryLeft @[simp] theorem ContinuousMultilinearMap.curryLeft_apply (f : ContinuousMultilinearMap 𝕜 Ei G) (x : Ei 0) (m : ∀ i : Fin n, Ei i.succ) : f.curryLeft x m = f (cons x m) := rfl #align continuous_multilinear_map.curry_left_apply ContinuousMultilinearMap.curryLeft_apply @[simp] theorem ContinuousLinearMap.curry_uncurryLeft (f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) : f.uncurryLeft.curryLeft = f := by ext m x rw [ContinuousMultilinearMap.curryLeft_apply, ContinuousLinearMap.uncurryLeft_apply, tail_cons, cons_zero] #align continuous_linear_map.curry_uncurry_left ContinuousLinearMap.curry_uncurryLeft @[simp] theorem ContinuousMultilinearMap.uncurry_curryLeft (f : ContinuousMultilinearMap 𝕜 Ei G) : f.curryLeft.uncurryLeft = f := ContinuousMultilinearMap.toMultilinearMap_injective <| f.toMultilinearMap.uncurry_curryLeft #align continuous_multilinear_map.uncurry_curry_left ContinuousMultilinearMap.uncurry_curryLeft variable (𝕜 Ei G) def continuousMultilinearCurryLeftEquiv : (Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 Ei G := LinearIsometryEquiv.ofBounds { toFun := ContinuousLinearMap.uncurryLeft map_add' := fun f₁ f₂ => by ext m rfl map_smul' := fun c f => by ext m rfl invFun := ContinuousMultilinearMap.curryLeft left_inv := ContinuousLinearMap.curry_uncurryLeft right_inv := ContinuousMultilinearMap.uncurry_curryLeft } (fun f => by simp only [LinearEquiv.coe_mk] exact MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _) (fun f => by simp only [LinearEquiv.coe_symm_mk] exact LinearMap.mkContinuous_norm_le _ (norm_nonneg f) _) #align continuous_multilinear_curry_left_equiv continuousMultilinearCurryLeftEquiv variable {𝕜 Ei G} @[simp] theorem continuousMultilinearCurryLeftEquiv_apply (f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) (v : ∀ i, Ei i) : continuousMultilinearCurryLeftEquiv 𝕜 Ei G f v = f (v 0) (tail v) := rfl #align continuous_multilinear_curry_left_equiv_apply continuousMultilinearCurryLeftEquiv_apply @[simp] theorem continuousMultilinearCurryLeftEquiv_symm_apply (f : ContinuousMultilinearMap 𝕜 Ei G) (x : Ei 0) (v : ∀ i : Fin n, Ei i.succ) : (continuousMultilinearCurryLeftEquiv 𝕜 Ei G).symm f x v = f (cons x v) := rfl #align continuous_multilinear_curry_left_equiv_symm_apply continuousMultilinearCurryLeftEquiv_symm_apply @[simp] theorem ContinuousMultilinearMap.curryLeft_norm (f : ContinuousMultilinearMap 𝕜 Ei G) : ‖f.curryLeft‖ = ‖f‖ := (continuousMultilinearCurryLeftEquiv 𝕜 Ei G).symm.norm_map f #align continuous_multilinear_map.curry_left_norm ContinuousMultilinearMap.curryLeft_norm @[simp] theorem ContinuousLinearMap.uncurryLeft_norm (f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) : ‖f.uncurryLeft‖ = ‖f‖ := (continuousMultilinearCurryLeftEquiv 𝕜 Ei G).norm_map f #align continuous_linear_map.uncurry_left_norm ContinuousLinearMap.uncurryLeft_norm def ContinuousMultilinearMap.uncurryRight (f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G)) : ContinuousMultilinearMap 𝕜 Ei G := let f' : MultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →ₗ[𝕜] G) := { toFun := fun m => (f m).toLinearMap map_add' := fun m i x y => by simp map_smul' := fun m i c x => by simp } (@MultilinearMap.uncurryRight 𝕜 n Ei G _ _ _ _ _ f').mkContinuous ‖f‖ fun m => f.norm_map_init_le m #align continuous_multilinear_map.uncurry_right ContinuousMultilinearMap.uncurryRight @[simp] theorem ContinuousMultilinearMap.uncurryRight_apply (f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G)) (m : ∀ i, Ei i) : f.uncurryRight m = f (init m) (m (last n)) := rfl #align continuous_multilinear_map.uncurry_right_apply ContinuousMultilinearMap.uncurryRight_apply def ContinuousMultilinearMap.curryRight (f : ContinuousMultilinearMap 𝕜 Ei G) : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G) := let f' : MultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G) := { toFun := fun m => (f.toMultilinearMap.curryRight m).mkContinuous (‖f‖ * ∏ i, ‖m i‖) fun x => f.norm_map_snoc_le m x map_add' := fun m i x y => by ext simp map_smul' := fun m i c x => by ext simp } f'.mkContinuous ‖f‖ fun m => by simp only [f', MultilinearMap.coe_mk] exact LinearMap.mkContinuous_norm_le _ (by positivity) _ #align continuous_multilinear_map.curry_right ContinuousMultilinearMap.curryRight @[simp] theorem ContinuousMultilinearMap.curryRight_apply (f : ContinuousMultilinearMap 𝕜 Ei G) (m : ∀ i : Fin n, Ei <| castSucc i) (x : Ei (last n)) : f.curryRight m x = f (snoc m x) := rfl #align continuous_multilinear_map.curry_right_apply ContinuousMultilinearMap.curryRight_apply @[simp] theorem ContinuousMultilinearMap.curry_uncurryRight (f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G)) : f.uncurryRight.curryRight = f := by ext m x rw [ContinuousMultilinearMap.curryRight_apply, ContinuousMultilinearMap.uncurryRight_apply, snoc_last, init_snoc] #align continuous_multilinear_map.curry_uncurry_right ContinuousMultilinearMap.curry_uncurryRight @[simp] theorem ContinuousMultilinearMap.uncurry_curryRight (f : ContinuousMultilinearMap 𝕜 Ei G) : f.curryRight.uncurryRight = f := by ext m rw [uncurryRight_apply, curryRight_apply, snoc_init_self] #align continuous_multilinear_map.uncurry_curry_right ContinuousMultilinearMap.uncurry_curryRight variable (𝕜 Ei G) def continuousMultilinearCurryRightEquiv : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G) ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 Ei G := LinearIsometryEquiv.ofBounds { toFun := ContinuousMultilinearMap.uncurryRight map_add' := fun f₁ f₂ => by ext m rfl map_smul' := fun c f => by ext m rfl invFun := ContinuousMultilinearMap.curryRight left_inv := ContinuousMultilinearMap.curry_uncurryRight right_inv := ContinuousMultilinearMap.uncurry_curryRight } (fun f => by simp only [uncurryRight, LinearEquiv.coe_mk] exact MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _) fun f => by simp only [curryRight, LinearEquiv.coe_symm_mk] exact MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _ #align continuous_multilinear_curry_right_equiv continuousMultilinearCurryRightEquiv variable (n G') def continuousMultilinearCurryRightEquiv' : (G[×n]→L[𝕜] G →L[𝕜] G') ≃ₗᵢ[𝕜] G[×n.succ]→L[𝕜] G' := continuousMultilinearCurryRightEquiv 𝕜 (fun _ => G) G' #align continuous_multilinear_curry_right_equiv' continuousMultilinearCurryRightEquiv' variable {n 𝕜 G Ei G'} @[simp] theorem continuousMultilinearCurryRightEquiv_apply (f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G)) (v : ∀ i, Ei i) : (continuousMultilinearCurryRightEquiv 𝕜 Ei G) f v = f (init v) (v (last n)) := rfl #align continuous_multilinear_curry_right_equiv_apply continuousMultilinearCurryRightEquiv_apply @[simp] theorem continuousMultilinearCurryRightEquiv_symm_apply (f : ContinuousMultilinearMap 𝕜 Ei G) (v : ∀ i : Fin n, Ei <| castSucc i) (x : Ei (last n)) : (continuousMultilinearCurryRightEquiv 𝕜 Ei G).symm f v x = f (snoc v x) := rfl #align continuous_multilinear_curry_right_equiv_symm_apply continuousMultilinearCurryRightEquiv_symm_apply @[simp] theorem continuousMultilinearCurryRightEquiv_apply' (f : G[×n]→L[𝕜] G →L[𝕜] G') (v : Fin (n + 1) → G) : continuousMultilinearCurryRightEquiv' 𝕜 n G G' f v = f (init v) (v (last n)) := rfl #align continuous_multilinear_curry_right_equiv_apply' continuousMultilinearCurryRightEquiv_apply' @[simp] theorem continuousMultilinearCurryRightEquiv_symm_apply' (f : G[×n.succ]→L[𝕜] G') (v : Fin n → G) (x : G) : (continuousMultilinearCurryRightEquiv' 𝕜 n G G').symm f v x = f (snoc v x) := rfl #align continuous_multilinear_curry_right_equiv_symm_apply' continuousMultilinearCurryRightEquiv_symm_apply' @[simp] theorem ContinuousMultilinearMap.curryRight_norm (f : ContinuousMultilinearMap 𝕜 Ei G) : ‖f.curryRight‖ = ‖f‖ := (continuousMultilinearCurryRightEquiv 𝕜 Ei G).symm.norm_map f #align continuous_multilinear_map.curry_right_norm ContinuousMultilinearMap.curryRight_norm @[simp] theorem ContinuousMultilinearMap.uncurryRight_norm (f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G)) : ‖f.uncurryRight‖ = ‖f‖ := (continuousMultilinearCurryRightEquiv 𝕜 Ei G).norm_map f #align continuous_multilinear_map.uncurry_right_norm ContinuousMultilinearMap.uncurryRight_norm section def ContinuousMultilinearMap.uncurry0 (f : ContinuousMultilinearMap 𝕜 (fun _ : Fin 0 => G) G') : G' := f 0 #align continuous_multilinear_map.uncurry0 ContinuousMultilinearMap.uncurry0 variable (𝕜 G) def ContinuousMultilinearMap.curry0 (x : G') : G[×0]→L[𝕜] G' := ContinuousMultilinearMap.constOfIsEmpty 𝕜 _ x #align continuous_multilinear_map.curry0 ContinuousMultilinearMap.curry0 variable {G} @[simp] theorem ContinuousMultilinearMap.curry0_apply (x : G') (m : Fin 0 → G) : ContinuousMultilinearMap.curry0 𝕜 G x m = x := rfl #align continuous_multilinear_map.curry0_apply ContinuousMultilinearMap.curry0_apply variable {𝕜} @[simp] theorem ContinuousMultilinearMap.uncurry0_apply (f : G[×0]→L[𝕜] G') : f.uncurry0 = f 0 := rfl #align continuous_multilinear_map.uncurry0_apply ContinuousMultilinearMap.uncurry0_apply @[simp] theorem ContinuousMultilinearMap.apply_zero_curry0 (f : G[×0]→L[𝕜] G') {x : Fin 0 → G} : ContinuousMultilinearMap.curry0 𝕜 G (f x) = f := by ext m simp [Subsingleton.elim x m] #align continuous_multilinear_map.apply_zero_curry0 ContinuousMultilinearMap.apply_zero_curry0 theorem ContinuousMultilinearMap.uncurry0_curry0 (f : G[×0]→L[𝕜] G') : ContinuousMultilinearMap.curry0 𝕜 G f.uncurry0 = f := by simp #align continuous_multilinear_map.uncurry0_curry0 ContinuousMultilinearMap.uncurry0_curry0 variable (𝕜 G) theorem ContinuousMultilinearMap.curry0_uncurry0 (x : G') : (ContinuousMultilinearMap.curry0 𝕜 G x).uncurry0 = x := rfl #align continuous_multilinear_map.curry0_uncurry0 ContinuousMultilinearMap.curry0_uncurry0 @[simp] theorem ContinuousMultilinearMap.curry0_norm (x : G') : ‖ContinuousMultilinearMap.curry0 𝕜 G x‖ = ‖x‖ := norm_constOfIsEmpty _ _ _ #align continuous_multilinear_map.curry0_norm ContinuousMultilinearMap.curry0_norm variable {𝕜 G} @[simp] theorem ContinuousMultilinearMap.fin0_apply_norm (f : G[×0]→L[𝕜] G') {x : Fin 0 → G} : ‖f x‖ = ‖f‖ := by obtain rfl : x = 0 := Subsingleton.elim _ _ refine le_antisymm (by simpa using f.le_opNorm 0) ?_ have : ‖ContinuousMultilinearMap.curry0 𝕜 G f.uncurry0‖ ≤ ‖f.uncurry0‖ := ContinuousMultilinearMap.opNorm_le_bound _ (norm_nonneg _) fun m => by simp [-ContinuousMultilinearMap.apply_zero_curry0] simpa [-Matrix.zero_empty] using this #align continuous_multilinear_map.fin0_apply_norm ContinuousMultilinearMap.fin0_apply_norm theorem ContinuousMultilinearMap.uncurry0_norm (f : G[×0]→L[𝕜] G') : ‖f.uncurry0‖ = ‖f‖ := by simp #align continuous_multilinear_map.uncurry0_norm ContinuousMultilinearMap.uncurry0_norm variable (𝕜 G G') def continuousMultilinearCurryFin0 : (G[×0]→L[𝕜] G') ≃ₗᵢ[𝕜] G' where toFun f := ContinuousMultilinearMap.uncurry0 f invFun f := ContinuousMultilinearMap.curry0 𝕜 G f map_add' _ _ := rfl map_smul' _ _ := rfl left_inv := ContinuousMultilinearMap.uncurry0_curry0 right_inv := ContinuousMultilinearMap.curry0_uncurry0 𝕜 G norm_map' := ContinuousMultilinearMap.uncurry0_norm #align continuous_multilinear_curry_fin0 continuousMultilinearCurryFin0 variable {𝕜 G G'} @[simp] theorem continuousMultilinearCurryFin0_apply (f : G[×0]→L[𝕜] G') : continuousMultilinearCurryFin0 𝕜 G G' f = f 0 := rfl #align continuous_multilinear_curry_fin0_apply continuousMultilinearCurryFin0_apply @[simp] theorem continuousMultilinearCurryFin0_symm_apply (x : G') (v : Fin 0 → G) : (continuousMultilinearCurryFin0 𝕜 G G').symm x v = x := rfl #align continuous_multilinear_curry_fin0_symm_apply continuousMultilinearCurryFin0_symm_apply end variable (𝕜 G G') def continuousMultilinearCurryFin1 : (G[×1]→L[𝕜] G') ≃ₗᵢ[𝕜] G →L[𝕜] G' := (continuousMultilinearCurryRightEquiv 𝕜 (fun _ : Fin 1 => G) G').symm.trans (continuousMultilinearCurryFin0 𝕜 G (G →L[𝕜] G')) #align continuous_multilinear_curry_fin1 continuousMultilinearCurryFin1 variable {𝕜 G G'} @[simp] theorem continuousMultilinearCurryFin1_apply (f : G[×1]→L[𝕜] G') (x : G) : continuousMultilinearCurryFin1 𝕜 G G' f x = f (Fin.snoc 0 x) := rfl #align continuous_multilinear_curry_fin1_apply continuousMultilinearCurryFin1_apply @[simp] theorem continuousMultilinearCurryFin1_symm_apply (f : G →L[𝕜] G') (v : Fin 1 → G) : (continuousMultilinearCurryFin1 𝕜 G G').symm f v = f (v 0) := rfl #align continuous_multilinear_curry_fin1_symm_apply continuousMultilinearCurryFin1_symm_apply namespace ContinuousMultilinearMap variable (𝕜 G G') @[simp]
Mathlib/Analysis/NormedSpace/Multilinear/Curry.lean
531
535
theorem norm_domDomCongr (σ : ι ≃ ι') (f : ContinuousMultilinearMap 𝕜 (fun _ : ι => G) G') : ‖domDomCongr σ f‖ = ‖f‖ := by
simp only [norm_def, LinearEquiv.coe_mk, ← σ.prod_comp, (σ.arrowCongr (Equiv.refl G)).surjective.forall, domDomCongr_apply, Equiv.arrowCongr_apply, Equiv.coe_refl, id_comp, comp_apply, Equiv.symm_apply_apply, id]
import Mathlib.Analysis.InnerProductSpace.TwoDim import Mathlib.Geometry.Euclidean.Angle.Unoriented.Basic #align_import geometry.euclidean.angle.oriented.basic from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" noncomputable section open FiniteDimensional Complex open scoped Real RealInnerProductSpace ComplexConjugate namespace Orientation attribute [local instance] Complex.finrank_real_complex_fact variable {V V' : Type*} variable [NormedAddCommGroup V] [NormedAddCommGroup V'] variable [InnerProductSpace ℝ V] [InnerProductSpace ℝ V'] variable [Fact (finrank ℝ V = 2)] [Fact (finrank ℝ V' = 2)] (o : Orientation ℝ V (Fin 2)) local notation "ω" => o.areaForm def oangle (x y : V) : Real.Angle := Complex.arg (o.kahler x y) #align orientation.oangle Orientation.oangle theorem continuousAt_oangle {x : V × V} (hx1 : x.1 ≠ 0) (hx2 : x.2 ≠ 0) : ContinuousAt (fun y : V × V => o.oangle y.1 y.2) x := by refine (Complex.continuousAt_arg_coe_angle ?_).comp ?_ · exact o.kahler_ne_zero hx1 hx2 exact ((continuous_ofReal.comp continuous_inner).add ((continuous_ofReal.comp o.areaForm'.continuous₂).mul continuous_const)).continuousAt #align orientation.continuous_at_oangle Orientation.continuousAt_oangle @[simp] theorem oangle_zero_left (x : V) : o.oangle 0 x = 0 := by simp [oangle] #align orientation.oangle_zero_left Orientation.oangle_zero_left @[simp] theorem oangle_zero_right (x : V) : o.oangle x 0 = 0 := by simp [oangle] #align orientation.oangle_zero_right Orientation.oangle_zero_right @[simp] theorem oangle_self (x : V) : o.oangle x x = 0 := by rw [oangle, kahler_apply_self, ← ofReal_pow] convert QuotientAddGroup.mk_zero (AddSubgroup.zmultiples (2 * π)) apply arg_ofReal_of_nonneg positivity #align orientation.oangle_self Orientation.oangle_self theorem left_ne_zero_of_oangle_ne_zero {x y : V} (h : o.oangle x y ≠ 0) : x ≠ 0 := by rintro rfl; simp at h #align orientation.left_ne_zero_of_oangle_ne_zero Orientation.left_ne_zero_of_oangle_ne_zero theorem right_ne_zero_of_oangle_ne_zero {x y : V} (h : o.oangle x y ≠ 0) : y ≠ 0 := by rintro rfl; simp at h #align orientation.right_ne_zero_of_oangle_ne_zero Orientation.right_ne_zero_of_oangle_ne_zero theorem ne_of_oangle_ne_zero {x y : V} (h : o.oangle x y ≠ 0) : x ≠ y := by rintro rfl; simp at h #align orientation.ne_of_oangle_ne_zero Orientation.ne_of_oangle_ne_zero theorem left_ne_zero_of_oangle_eq_pi {x y : V} (h : o.oangle x y = π) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : o.oangle x y ≠ 0) #align orientation.left_ne_zero_of_oangle_eq_pi Orientation.left_ne_zero_of_oangle_eq_pi theorem right_ne_zero_of_oangle_eq_pi {x y : V} (h : o.oangle x y = π) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : o.oangle x y ≠ 0) #align orientation.right_ne_zero_of_oangle_eq_pi Orientation.right_ne_zero_of_oangle_eq_pi theorem ne_of_oangle_eq_pi {x y : V} (h : o.oangle x y = π) : x ≠ y := o.ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : o.oangle x y ≠ 0) #align orientation.ne_of_oangle_eq_pi Orientation.ne_of_oangle_eq_pi theorem left_ne_zero_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.left_ne_zero_of_oangle_eq_pi_div_two Orientation.left_ne_zero_of_oangle_eq_pi_div_two theorem right_ne_zero_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.right_ne_zero_of_oangle_eq_pi_div_two Orientation.right_ne_zero_of_oangle_eq_pi_div_two theorem ne_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : x ≠ y := o.ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.ne_of_oangle_eq_pi_div_two Orientation.ne_of_oangle_eq_pi_div_two theorem left_ne_zero_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.left_ne_zero_of_oangle_eq_neg_pi_div_two Orientation.left_ne_zero_of_oangle_eq_neg_pi_div_two theorem right_ne_zero_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.right_ne_zero_of_oangle_eq_neg_pi_div_two Orientation.right_ne_zero_of_oangle_eq_neg_pi_div_two theorem ne_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : x ≠ y := o.ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.ne_of_oangle_eq_neg_pi_div_two Orientation.ne_of_oangle_eq_neg_pi_div_two theorem left_ne_zero_of_oangle_sign_ne_zero {x y : V} (h : (o.oangle x y).sign ≠ 0) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align orientation.left_ne_zero_of_oangle_sign_ne_zero Orientation.left_ne_zero_of_oangle_sign_ne_zero theorem right_ne_zero_of_oangle_sign_ne_zero {x y : V} (h : (o.oangle x y).sign ≠ 0) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align orientation.right_ne_zero_of_oangle_sign_ne_zero Orientation.right_ne_zero_of_oangle_sign_ne_zero theorem ne_of_oangle_sign_ne_zero {x y : V} (h : (o.oangle x y).sign ≠ 0) : x ≠ y := o.ne_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align orientation.ne_of_oangle_sign_ne_zero Orientation.ne_of_oangle_sign_ne_zero theorem left_ne_zero_of_oangle_sign_eq_one {x y : V} (h : (o.oangle x y).sign = 1) : x ≠ 0 := o.left_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.left_ne_zero_of_oangle_sign_eq_one Orientation.left_ne_zero_of_oangle_sign_eq_one theorem right_ne_zero_of_oangle_sign_eq_one {x y : V} (h : (o.oangle x y).sign = 1) : y ≠ 0 := o.right_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.right_ne_zero_of_oangle_sign_eq_one Orientation.right_ne_zero_of_oangle_sign_eq_one theorem ne_of_oangle_sign_eq_one {x y : V} (h : (o.oangle x y).sign = 1) : x ≠ y := o.ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.ne_of_oangle_sign_eq_one Orientation.ne_of_oangle_sign_eq_one theorem left_ne_zero_of_oangle_sign_eq_neg_one {x y : V} (h : (o.oangle x y).sign = -1) : x ≠ 0 := o.left_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.left_ne_zero_of_oangle_sign_eq_neg_one Orientation.left_ne_zero_of_oangle_sign_eq_neg_one theorem right_ne_zero_of_oangle_sign_eq_neg_one {x y : V} (h : (o.oangle x y).sign = -1) : y ≠ 0 := o.right_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.right_ne_zero_of_oangle_sign_eq_neg_one Orientation.right_ne_zero_of_oangle_sign_eq_neg_one theorem ne_of_oangle_sign_eq_neg_one {x y : V} (h : (o.oangle x y).sign = -1) : x ≠ y := o.ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.ne_of_oangle_sign_eq_neg_one Orientation.ne_of_oangle_sign_eq_neg_one theorem oangle_rev (x y : V) : o.oangle y x = -o.oangle x y := by simp only [oangle, o.kahler_swap y x, Complex.arg_conj_coe_angle] #align orientation.oangle_rev Orientation.oangle_rev @[simp] theorem oangle_add_oangle_rev (x y : V) : o.oangle x y + o.oangle y x = 0 := by simp [o.oangle_rev y x] #align orientation.oangle_add_oangle_rev Orientation.oangle_add_oangle_rev theorem oangle_neg_left {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : o.oangle (-x) y = o.oangle x y + π := by simp only [oangle, map_neg] convert Complex.arg_neg_coe_angle _ exact o.kahler_ne_zero hx hy #align orientation.oangle_neg_left Orientation.oangle_neg_left theorem oangle_neg_right {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : o.oangle x (-y) = o.oangle x y + π := by simp only [oangle, map_neg] convert Complex.arg_neg_coe_angle _ exact o.kahler_ne_zero hx hy #align orientation.oangle_neg_right Orientation.oangle_neg_right @[simp] theorem two_zsmul_oangle_neg_left (x y : V) : (2 : ℤ) • o.oangle (-x) y = (2 : ℤ) • o.oangle x y := by by_cases hx : x = 0 · simp [hx] · by_cases hy : y = 0 · simp [hy] · simp [o.oangle_neg_left hx hy] #align orientation.two_zsmul_oangle_neg_left Orientation.two_zsmul_oangle_neg_left @[simp] theorem two_zsmul_oangle_neg_right (x y : V) : (2 : ℤ) • o.oangle x (-y) = (2 : ℤ) • o.oangle x y := by by_cases hx : x = 0 · simp [hx] · by_cases hy : y = 0 · simp [hy] · simp [o.oangle_neg_right hx hy] #align orientation.two_zsmul_oangle_neg_right Orientation.two_zsmul_oangle_neg_right @[simp] theorem oangle_neg_neg (x y : V) : o.oangle (-x) (-y) = o.oangle x y := by simp [oangle] #align orientation.oangle_neg_neg Orientation.oangle_neg_neg theorem oangle_neg_left_eq_neg_right (x y : V) : o.oangle (-x) y = o.oangle x (-y) := by rw [← neg_neg y, oangle_neg_neg, neg_neg] #align orientation.oangle_neg_left_eq_neg_right Orientation.oangle_neg_left_eq_neg_right @[simp] theorem oangle_neg_self_left {x : V} (hx : x ≠ 0) : o.oangle (-x) x = π := by simp [oangle_neg_left, hx] #align orientation.oangle_neg_self_left Orientation.oangle_neg_self_left @[simp] theorem oangle_neg_self_right {x : V} (hx : x ≠ 0) : o.oangle x (-x) = π := by simp [oangle_neg_right, hx] #align orientation.oangle_neg_self_right Orientation.oangle_neg_self_right -- @[simp] -- Porting note (#10618): simp can prove this theorem two_zsmul_oangle_neg_self_left (x : V) : (2 : ℤ) • o.oangle (-x) x = 0 := by by_cases hx : x = 0 <;> simp [hx] #align orientation.two_zsmul_oangle_neg_self_left Orientation.two_zsmul_oangle_neg_self_left -- @[simp] -- Porting note (#10618): simp can prove this theorem two_zsmul_oangle_neg_self_right (x : V) : (2 : ℤ) • o.oangle x (-x) = 0 := by by_cases hx : x = 0 <;> simp [hx] #align orientation.two_zsmul_oangle_neg_self_right Orientation.two_zsmul_oangle_neg_self_right @[simp] theorem oangle_add_oangle_rev_neg_left (x y : V) : o.oangle (-x) y + o.oangle (-y) x = 0 := by rw [oangle_neg_left_eq_neg_right, oangle_rev, add_left_neg] #align orientation.oangle_add_oangle_rev_neg_left Orientation.oangle_add_oangle_rev_neg_left @[simp] theorem oangle_add_oangle_rev_neg_right (x y : V) : o.oangle x (-y) + o.oangle y (-x) = 0 := by rw [o.oangle_rev (-x), oangle_neg_left_eq_neg_right, add_neg_self] #align orientation.oangle_add_oangle_rev_neg_right Orientation.oangle_add_oangle_rev_neg_right @[simp] theorem oangle_smul_left_of_pos (x y : V) {r : ℝ} (hr : 0 < r) : o.oangle (r • x) y = o.oangle x y := by simp [oangle, Complex.arg_real_mul _ hr] #align orientation.oangle_smul_left_of_pos Orientation.oangle_smul_left_of_pos @[simp] theorem oangle_smul_right_of_pos (x y : V) {r : ℝ} (hr : 0 < r) : o.oangle x (r • y) = o.oangle x y := by simp [oangle, Complex.arg_real_mul _ hr] #align orientation.oangle_smul_right_of_pos Orientation.oangle_smul_right_of_pos @[simp] theorem oangle_smul_left_of_neg (x y : V) {r : ℝ} (hr : r < 0) : o.oangle (r • x) y = o.oangle (-x) y := by rw [← neg_neg r, neg_smul, ← smul_neg, o.oangle_smul_left_of_pos _ _ (neg_pos_of_neg hr)] #align orientation.oangle_smul_left_of_neg Orientation.oangle_smul_left_of_neg @[simp] theorem oangle_smul_right_of_neg (x y : V) {r : ℝ} (hr : r < 0) : o.oangle x (r • y) = o.oangle x (-y) := by rw [← neg_neg r, neg_smul, ← smul_neg, o.oangle_smul_right_of_pos _ _ (neg_pos_of_neg hr)] #align orientation.oangle_smul_right_of_neg Orientation.oangle_smul_right_of_neg @[simp] theorem oangle_smul_left_self_of_nonneg (x : V) {r : ℝ} (hr : 0 ≤ r) : o.oangle (r • x) x = 0 := by rcases hr.lt_or_eq with (h | h) · simp [h] · simp [h.symm] #align orientation.oangle_smul_left_self_of_nonneg Orientation.oangle_smul_left_self_of_nonneg @[simp] theorem oangle_smul_right_self_of_nonneg (x : V) {r : ℝ} (hr : 0 ≤ r) : o.oangle x (r • x) = 0 := by rcases hr.lt_or_eq with (h | h) · simp [h] · simp [h.symm] #align orientation.oangle_smul_right_self_of_nonneg Orientation.oangle_smul_right_self_of_nonneg @[simp] theorem oangle_smul_smul_self_of_nonneg (x : V) {r₁ r₂ : ℝ} (hr₁ : 0 ≤ r₁) (hr₂ : 0 ≤ r₂) : o.oangle (r₁ • x) (r₂ • x) = 0 := by rcases hr₁.lt_or_eq with (h | h) · simp [h, hr₂] · simp [h.symm] #align orientation.oangle_smul_smul_self_of_nonneg Orientation.oangle_smul_smul_self_of_nonneg @[simp] theorem two_zsmul_oangle_smul_left_of_ne_zero (x y : V) {r : ℝ} (hr : r ≠ 0) : (2 : ℤ) • o.oangle (r • x) y = (2 : ℤ) • o.oangle x y := by rcases hr.lt_or_lt with (h | h) <;> simp [h] #align orientation.two_zsmul_oangle_smul_left_of_ne_zero Orientation.two_zsmul_oangle_smul_left_of_ne_zero @[simp] theorem two_zsmul_oangle_smul_right_of_ne_zero (x y : V) {r : ℝ} (hr : r ≠ 0) : (2 : ℤ) • o.oangle x (r • y) = (2 : ℤ) • o.oangle x y := by rcases hr.lt_or_lt with (h | h) <;> simp [h] #align orientation.two_zsmul_oangle_smul_right_of_ne_zero Orientation.two_zsmul_oangle_smul_right_of_ne_zero @[simp] theorem two_zsmul_oangle_smul_left_self (x : V) {r : ℝ} : (2 : ℤ) • o.oangle (r • x) x = 0 := by rcases lt_or_le r 0 with (h | h) <;> simp [h] #align orientation.two_zsmul_oangle_smul_left_self Orientation.two_zsmul_oangle_smul_left_self @[simp] theorem two_zsmul_oangle_smul_right_self (x : V) {r : ℝ} : (2 : ℤ) • o.oangle x (r • x) = 0 := by rcases lt_or_le r 0 with (h | h) <;> simp [h] #align orientation.two_zsmul_oangle_smul_right_self Orientation.two_zsmul_oangle_smul_right_self @[simp] theorem two_zsmul_oangle_smul_smul_self (x : V) {r₁ r₂ : ℝ} : (2 : ℤ) • o.oangle (r₁ • x) (r₂ • x) = 0 := by by_cases h : r₁ = 0 <;> simp [h] #align orientation.two_zsmul_oangle_smul_smul_self Orientation.two_zsmul_oangle_smul_smul_self theorem two_zsmul_oangle_left_of_span_eq {x y : V} (z : V) (h : (ℝ ∙ x) = ℝ ∙ y) : (2 : ℤ) • o.oangle x z = (2 : ℤ) • o.oangle y z := by rw [Submodule.span_singleton_eq_span_singleton] at h rcases h with ⟨r, rfl⟩ exact (o.two_zsmul_oangle_smul_left_of_ne_zero _ _ (Units.ne_zero _)).symm #align orientation.two_zsmul_oangle_left_of_span_eq Orientation.two_zsmul_oangle_left_of_span_eq theorem two_zsmul_oangle_right_of_span_eq (x : V) {y z : V} (h : (ℝ ∙ y) = ℝ ∙ z) : (2 : ℤ) • o.oangle x y = (2 : ℤ) • o.oangle x z := by rw [Submodule.span_singleton_eq_span_singleton] at h rcases h with ⟨r, rfl⟩ exact (o.two_zsmul_oangle_smul_right_of_ne_zero _ _ (Units.ne_zero _)).symm #align orientation.two_zsmul_oangle_right_of_span_eq Orientation.two_zsmul_oangle_right_of_span_eq theorem two_zsmul_oangle_of_span_eq_of_span_eq {w x y z : V} (hwx : (ℝ ∙ w) = ℝ ∙ x) (hyz : (ℝ ∙ y) = ℝ ∙ z) : (2 : ℤ) • o.oangle w y = (2 : ℤ) • o.oangle x z := by rw [o.two_zsmul_oangle_left_of_span_eq y hwx, o.two_zsmul_oangle_right_of_span_eq x hyz] #align orientation.two_zsmul_oangle_of_span_eq_of_span_eq Orientation.two_zsmul_oangle_of_span_eq_of_span_eq theorem oangle_eq_zero_iff_oangle_rev_eq_zero {x y : V} : o.oangle x y = 0 ↔ o.oangle y x = 0 := by rw [oangle_rev, neg_eq_zero] #align orientation.oangle_eq_zero_iff_oangle_rev_eq_zero Orientation.oangle_eq_zero_iff_oangle_rev_eq_zero theorem oangle_eq_zero_iff_sameRay {x y : V} : o.oangle x y = 0 ↔ SameRay ℝ x y := by rw [oangle, kahler_apply_apply, Complex.arg_coe_angle_eq_iff_eq_toReal, Real.Angle.toReal_zero, Complex.arg_eq_zero_iff] simpa using o.nonneg_inner_and_areaForm_eq_zero_iff_sameRay x y #align orientation.oangle_eq_zero_iff_same_ray Orientation.oangle_eq_zero_iff_sameRay theorem oangle_eq_pi_iff_oangle_rev_eq_pi {x y : V} : o.oangle x y = π ↔ o.oangle y x = π := by rw [oangle_rev, neg_eq_iff_eq_neg, Real.Angle.neg_coe_pi] #align orientation.oangle_eq_pi_iff_oangle_rev_eq_pi Orientation.oangle_eq_pi_iff_oangle_rev_eq_pi theorem oangle_eq_pi_iff_sameRay_neg {x y : V} : o.oangle x y = π ↔ x ≠ 0 ∧ y ≠ 0 ∧ SameRay ℝ x (-y) := by rw [← o.oangle_eq_zero_iff_sameRay] constructor · intro h by_cases hx : x = 0; · simp [hx, Real.Angle.pi_ne_zero.symm] at h by_cases hy : y = 0; · simp [hy, Real.Angle.pi_ne_zero.symm] at h refine ⟨hx, hy, ?_⟩ rw [o.oangle_neg_right hx hy, h, Real.Angle.coe_pi_add_coe_pi] · rintro ⟨hx, hy, h⟩ rwa [o.oangle_neg_right hx hy, ← Real.Angle.sub_coe_pi_eq_add_coe_pi, sub_eq_zero] at h #align orientation.oangle_eq_pi_iff_same_ray_neg Orientation.oangle_eq_pi_iff_sameRay_neg theorem oangle_eq_zero_or_eq_pi_iff_not_linearIndependent {x y : V} : o.oangle x y = 0 ∨ o.oangle x y = π ↔ ¬LinearIndependent ℝ ![x, y] := by rw [oangle_eq_zero_iff_sameRay, oangle_eq_pi_iff_sameRay_neg, sameRay_or_ne_zero_and_sameRay_neg_iff_not_linearIndependent] #align orientation.oangle_eq_zero_or_eq_pi_iff_not_linear_independent Orientation.oangle_eq_zero_or_eq_pi_iff_not_linearIndependent theorem oangle_eq_zero_or_eq_pi_iff_right_eq_smul {x y : V} : o.oangle x y = 0 ∨ o.oangle x y = π ↔ x = 0 ∨ ∃ r : ℝ, y = r • x := by rw [oangle_eq_zero_iff_sameRay, oangle_eq_pi_iff_sameRay_neg] refine ⟨fun h => ?_, fun h => ?_⟩ · rcases h with (h | ⟨-, -, h⟩) · by_cases hx : x = 0; · simp [hx] obtain ⟨r, -, rfl⟩ := h.exists_nonneg_left hx exact Or.inr ⟨r, rfl⟩ · by_cases hx : x = 0; · simp [hx] obtain ⟨r, -, hy⟩ := h.exists_nonneg_left hx refine Or.inr ⟨-r, ?_⟩ simp [hy] · rcases h with (rfl | ⟨r, rfl⟩); · simp by_cases hx : x = 0; · simp [hx] rcases lt_trichotomy r 0 with (hr | hr | hr) · rw [← neg_smul] exact Or.inr ⟨hx, smul_ne_zero hr.ne hx, SameRay.sameRay_pos_smul_right x (Left.neg_pos_iff.2 hr)⟩ · simp [hr] · exact Or.inl (SameRay.sameRay_pos_smul_right x hr) #align orientation.oangle_eq_zero_or_eq_pi_iff_right_eq_smul Orientation.oangle_eq_zero_or_eq_pi_iff_right_eq_smul theorem oangle_ne_zero_and_ne_pi_iff_linearIndependent {x y : V} : o.oangle x y ≠ 0 ∧ o.oangle x y ≠ π ↔ LinearIndependent ℝ ![x, y] := by rw [← not_or, ← not_iff_not, Classical.not_not, oangle_eq_zero_or_eq_pi_iff_not_linearIndependent] #align orientation.oangle_ne_zero_and_ne_pi_iff_linear_independent Orientation.oangle_ne_zero_and_ne_pi_iff_linearIndependent theorem eq_iff_norm_eq_and_oangle_eq_zero (x y : V) : x = y ↔ ‖x‖ = ‖y‖ ∧ o.oangle x y = 0 := by rw [oangle_eq_zero_iff_sameRay] constructor · rintro rfl simp; rfl · rcases eq_or_ne y 0 with (rfl | hy) · simp rintro ⟨h₁, h₂⟩ obtain ⟨r, hr, rfl⟩ := h₂.exists_nonneg_right hy have : ‖y‖ ≠ 0 := by simpa using hy obtain rfl : r = 1 := by apply mul_right_cancel₀ this simpa [norm_smul, _root_.abs_of_nonneg hr] using h₁ simp #align orientation.eq_iff_norm_eq_and_oangle_eq_zero Orientation.eq_iff_norm_eq_and_oangle_eq_zero theorem eq_iff_oangle_eq_zero_of_norm_eq {x y : V} (h : ‖x‖ = ‖y‖) : x = y ↔ o.oangle x y = 0 := ⟨fun he => ((o.eq_iff_norm_eq_and_oangle_eq_zero x y).1 he).2, fun ha => (o.eq_iff_norm_eq_and_oangle_eq_zero x y).2 ⟨h, ha⟩⟩ #align orientation.eq_iff_oangle_eq_zero_of_norm_eq Orientation.eq_iff_oangle_eq_zero_of_norm_eq theorem eq_iff_norm_eq_of_oangle_eq_zero {x y : V} (h : o.oangle x y = 0) : x = y ↔ ‖x‖ = ‖y‖ := ⟨fun he => ((o.eq_iff_norm_eq_and_oangle_eq_zero x y).1 he).1, fun hn => (o.eq_iff_norm_eq_and_oangle_eq_zero x y).2 ⟨hn, h⟩⟩ #align orientation.eq_iff_norm_eq_of_oangle_eq_zero Orientation.eq_iff_norm_eq_of_oangle_eq_zero @[simp] theorem oangle_add {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x y + o.oangle y z = o.oangle x z := by simp_rw [oangle] rw [← Complex.arg_mul_coe_angle, o.kahler_mul y x z] · congr 1 convert Complex.arg_real_mul _ (_ : 0 < ‖y‖ ^ 2) using 2 · norm_cast · have : 0 < ‖y‖ := by simpa using hy positivity · exact o.kahler_ne_zero hx hy · exact o.kahler_ne_zero hy hz #align orientation.oangle_add Orientation.oangle_add @[simp] theorem oangle_add_swap {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle y z + o.oangle x y = o.oangle x z := by rw [add_comm, o.oangle_add hx hy hz] #align orientation.oangle_add_swap Orientation.oangle_add_swap @[simp] theorem oangle_sub_left {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x z - o.oangle x y = o.oangle y z := by rw [sub_eq_iff_eq_add, o.oangle_add_swap hx hy hz] #align orientation.oangle_sub_left Orientation.oangle_sub_left @[simp] theorem oangle_sub_right {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x z - o.oangle y z = o.oangle x y := by rw [sub_eq_iff_eq_add, o.oangle_add hx hy hz] #align orientation.oangle_sub_right Orientation.oangle_sub_right @[simp] theorem oangle_add_cyc3 {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x y + o.oangle y z + o.oangle z x = 0 := by simp [hx, hy, hz] #align orientation.oangle_add_cyc3 Orientation.oangle_add_cyc3 @[simp] theorem oangle_add_cyc3_neg_left {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle (-x) y + o.oangle (-y) z + o.oangle (-z) x = π := by rw [o.oangle_neg_left hx hy, o.oangle_neg_left hy hz, o.oangle_neg_left hz hx, show o.oangle x y + π + (o.oangle y z + π) + (o.oangle z x + π) = o.oangle x y + o.oangle y z + o.oangle z x + (π + π + π : Real.Angle) by abel, o.oangle_add_cyc3 hx hy hz, Real.Angle.coe_pi_add_coe_pi, zero_add, zero_add] #align orientation.oangle_add_cyc3_neg_left Orientation.oangle_add_cyc3_neg_left @[simp] theorem oangle_add_cyc3_neg_right {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x (-y) + o.oangle y (-z) + o.oangle z (-x) = π := by simp_rw [← oangle_neg_left_eq_neg_right, o.oangle_add_cyc3_neg_left hx hy hz] #align orientation.oangle_add_cyc3_neg_right Orientation.oangle_add_cyc3_neg_right theorem oangle_sub_eq_oangle_sub_rev_of_norm_eq {x y : V} (h : ‖x‖ = ‖y‖) : o.oangle x (x - y) = o.oangle (y - x) y := by simp [oangle, h] #align orientation.oangle_sub_eq_oangle_sub_rev_of_norm_eq Orientation.oangle_sub_eq_oangle_sub_rev_of_norm_eq theorem oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq {x y : V} (hn : x ≠ y) (h : ‖x‖ = ‖y‖) : o.oangle y x = π - (2 : ℤ) • o.oangle (y - x) y := by rw [two_zsmul] nth_rw 1 [← o.oangle_sub_eq_oangle_sub_rev_of_norm_eq h] rw [eq_sub_iff_add_eq, ← oangle_neg_neg, ← add_assoc] have hy : y ≠ 0 := by rintro rfl rw [norm_zero, norm_eq_zero] at h exact hn h have hx : x ≠ 0 := norm_ne_zero_iff.1 (h.symm ▸ norm_ne_zero_iff.2 hy) convert o.oangle_add_cyc3_neg_right (neg_ne_zero.2 hy) hx (sub_ne_zero_of_ne hn.symm) using 1 simp #align orientation.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq Orientation.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq @[simp] theorem oangle_map (x y : V') (f : V ≃ₗᵢ[ℝ] V') : (Orientation.map (Fin 2) f.toLinearEquiv o).oangle x y = o.oangle (f.symm x) (f.symm y) := by simp [oangle, o.kahler_map] #align orientation.oangle_map Orientation.oangle_map @[simp] protected theorem _root_.Complex.oangle (w z : ℂ) : Complex.orientation.oangle w z = Complex.arg (conj w * z) := by simp [oangle] #align complex.oangle Complex.oangle theorem oangle_map_complex (f : V ≃ₗᵢ[ℝ] ℂ) (hf : Orientation.map (Fin 2) f.toLinearEquiv o = Complex.orientation) (x y : V) : o.oangle x y = Complex.arg (conj (f x) * f y) := by rw [← Complex.oangle, ← hf, o.oangle_map] iterate 2 rw [LinearIsometryEquiv.symm_apply_apply] #align orientation.oangle_map_complex Orientation.oangle_map_complex theorem oangle_neg_orientation_eq_neg (x y : V) : (-o).oangle x y = -o.oangle x y := by simp [oangle] #align orientation.oangle_neg_orientation_eq_neg Orientation.oangle_neg_orientation_eq_neg theorem inner_eq_norm_mul_norm_mul_cos_oangle (x y : V) : ⟪x, y⟫ = ‖x‖ * ‖y‖ * Real.Angle.cos (o.oangle x y) := by by_cases hx : x = 0; · simp [hx] by_cases hy : y = 0; · simp [hy] have : ‖x‖ ≠ 0 := by simpa using hx have : ‖y‖ ≠ 0 := by simpa using hy rw [oangle, Real.Angle.cos_coe, Complex.cos_arg, o.abs_kahler] · simp only [kahler_apply_apply, real_smul, add_re, ofReal_re, mul_re, I_re, ofReal_im] field_simp · exact o.kahler_ne_zero hx hy #align orientation.inner_eq_norm_mul_norm_mul_cos_oangle Orientation.inner_eq_norm_mul_norm_mul_cos_oangle theorem cos_oangle_eq_inner_div_norm_mul_norm {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : Real.Angle.cos (o.oangle x y) = ⟪x, y⟫ / (‖x‖ * ‖y‖) := by rw [o.inner_eq_norm_mul_norm_mul_cos_oangle] field_simp [norm_ne_zero_iff.2 hx, norm_ne_zero_iff.2 hy] #align orientation.cos_oangle_eq_inner_div_norm_mul_norm Orientation.cos_oangle_eq_inner_div_norm_mul_norm theorem cos_oangle_eq_cos_angle {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : Real.Angle.cos (o.oangle x y) = Real.cos (InnerProductGeometry.angle x y) := by rw [o.cos_oangle_eq_inner_div_norm_mul_norm hx hy, InnerProductGeometry.cos_angle] #align orientation.cos_oangle_eq_cos_angle Orientation.cos_oangle_eq_cos_angle theorem oangle_eq_angle_or_eq_neg_angle {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : o.oangle x y = InnerProductGeometry.angle x y ∨ o.oangle x y = -InnerProductGeometry.angle x y := Real.Angle.cos_eq_real_cos_iff_eq_or_eq_neg.1 <| o.cos_oangle_eq_cos_angle hx hy #align orientation.oangle_eq_angle_or_eq_neg_angle Orientation.oangle_eq_angle_or_eq_neg_angle theorem angle_eq_abs_oangle_toReal {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : InnerProductGeometry.angle x y = |(o.oangle x y).toReal| := by have h0 := InnerProductGeometry.angle_nonneg x y have hpi := InnerProductGeometry.angle_le_pi x y rcases o.oangle_eq_angle_or_eq_neg_angle hx hy with (h | h) · rw [h, eq_comm, Real.Angle.abs_toReal_coe_eq_self_iff] exact ⟨h0, hpi⟩ · rw [h, eq_comm, Real.Angle.abs_toReal_neg_coe_eq_self_iff] exact ⟨h0, hpi⟩ #align orientation.angle_eq_abs_oangle_to_real Orientation.angle_eq_abs_oangle_toReal theorem eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero {x y : V} (h : (o.oangle x y).sign = 0) : x = 0 ∨ y = 0 ∨ InnerProductGeometry.angle x y = 0 ∨ InnerProductGeometry.angle x y = π := by by_cases hx : x = 0; · simp [hx] by_cases hy : y = 0; · simp [hy] rw [o.angle_eq_abs_oangle_toReal hx hy] rw [Real.Angle.sign_eq_zero_iff] at h rcases h with (h | h) <;> simp [h, Real.pi_pos.le] #align orientation.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero Orientation.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero theorem oangle_eq_of_angle_eq_of_sign_eq {w x y z : V} (h : InnerProductGeometry.angle w x = InnerProductGeometry.angle y z) (hs : (o.oangle w x).sign = (o.oangle y z).sign) : o.oangle w x = o.oangle y z := by by_cases h0 : (w = 0 ∨ x = 0) ∨ y = 0 ∨ z = 0 · have hs' : (o.oangle w x).sign = 0 ∧ (o.oangle y z).sign = 0 := by rcases h0 with ((rfl | rfl) | rfl | rfl) · simpa using hs.symm · simpa using hs.symm · simpa using hs · simpa using hs rcases hs' with ⟨hswx, hsyz⟩ have h' : InnerProductGeometry.angle w x = π / 2 ∧ InnerProductGeometry.angle y z = π / 2 := by rcases h0 with ((rfl | rfl) | rfl | rfl) · simpa using h.symm · simpa using h.symm · simpa using h · simpa using h rcases h' with ⟨hwx, hyz⟩ have hpi : π / 2 ≠ π := by intro hpi rw [div_eq_iff, eq_comm, ← sub_eq_zero, mul_two, add_sub_cancel_right] at hpi · exact Real.pi_pos.ne.symm hpi · exact two_ne_zero have h0wx : w = 0 ∨ x = 0 := by have h0' := o.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero hswx simpa [hwx, Real.pi_pos.ne.symm, hpi] using h0' have h0yz : y = 0 ∨ z = 0 := by have h0' := o.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero hsyz simpa [hyz, Real.pi_pos.ne.symm, hpi] using h0' rcases h0wx with (h0wx | h0wx) <;> rcases h0yz with (h0yz | h0yz) <;> simp [h0wx, h0yz] · push_neg at h0 rw [Real.Angle.eq_iff_abs_toReal_eq_of_sign_eq hs] rwa [o.angle_eq_abs_oangle_toReal h0.1.1 h0.1.2, o.angle_eq_abs_oangle_toReal h0.2.1 h0.2.2] at h #align orientation.oangle_eq_of_angle_eq_of_sign_eq Orientation.oangle_eq_of_angle_eq_of_sign_eq theorem angle_eq_iff_oangle_eq_of_sign_eq {w x y z : V} (hw : w ≠ 0) (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) (hs : (o.oangle w x).sign = (o.oangle y z).sign) : InnerProductGeometry.angle w x = InnerProductGeometry.angle y z ↔ o.oangle w x = o.oangle y z := by refine ⟨fun h => o.oangle_eq_of_angle_eq_of_sign_eq h hs, fun h => ?_⟩ rw [o.angle_eq_abs_oangle_toReal hw hx, o.angle_eq_abs_oangle_toReal hy hz, h] #align orientation.angle_eq_iff_oangle_eq_of_sign_eq Orientation.angle_eq_iff_oangle_eq_of_sign_eq theorem oangle_eq_angle_of_sign_eq_one {x y : V} (h : (o.oangle x y).sign = 1) : o.oangle x y = InnerProductGeometry.angle x y := by by_cases hx : x = 0; · exfalso; simp [hx] at h by_cases hy : y = 0; · exfalso; simp [hy] at h refine (o.oangle_eq_angle_or_eq_neg_angle hx hy).resolve_right ?_ intro hxy rw [hxy, Real.Angle.sign_neg, neg_eq_iff_eq_neg, ← SignType.neg_iff, ← not_le] at h exact h (Real.Angle.sign_coe_nonneg_of_nonneg_of_le_pi (InnerProductGeometry.angle_nonneg _ _) (InnerProductGeometry.angle_le_pi _ _)) #align orientation.oangle_eq_angle_of_sign_eq_one Orientation.oangle_eq_angle_of_sign_eq_one theorem oangle_eq_neg_angle_of_sign_eq_neg_one {x y : V} (h : (o.oangle x y).sign = -1) : o.oangle x y = -InnerProductGeometry.angle x y := by by_cases hx : x = 0; · exfalso; simp [hx] at h by_cases hy : y = 0; · exfalso; simp [hy] at h refine (o.oangle_eq_angle_or_eq_neg_angle hx hy).resolve_left ?_ intro hxy rw [hxy, ← SignType.neg_iff, ← not_le] at h exact h (Real.Angle.sign_coe_nonneg_of_nonneg_of_le_pi (InnerProductGeometry.angle_nonneg _ _) (InnerProductGeometry.angle_le_pi _ _)) #align orientation.oangle_eq_neg_angle_of_sign_eq_neg_one Orientation.oangle_eq_neg_angle_of_sign_eq_neg_one theorem oangle_eq_zero_iff_angle_eq_zero {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : o.oangle x y = 0 ↔ InnerProductGeometry.angle x y = 0 := by refine ⟨fun h => ?_, fun h => ?_⟩ · simpa [o.angle_eq_abs_oangle_toReal hx hy] · have ha := o.oangle_eq_angle_or_eq_neg_angle hx hy rw [h] at ha simpa using ha #align orientation.oangle_eq_zero_iff_angle_eq_zero Orientation.oangle_eq_zero_iff_angle_eq_zero theorem oangle_eq_pi_iff_angle_eq_pi {x y : V} : o.oangle x y = π ↔ InnerProductGeometry.angle x y = π := by by_cases hx : x = 0 · simp [hx, Real.Angle.pi_ne_zero.symm, div_eq_mul_inv, mul_right_eq_self₀, not_or, Real.pi_ne_zero] by_cases hy : y = 0 · simp [hy, Real.Angle.pi_ne_zero.symm, div_eq_mul_inv, mul_right_eq_self₀, not_or, Real.pi_ne_zero] refine ⟨fun h => ?_, fun h => ?_⟩ · rw [o.angle_eq_abs_oangle_toReal hx hy, h] simp [Real.pi_pos.le] · have ha := o.oangle_eq_angle_or_eq_neg_angle hx hy rw [h] at ha simpa using ha #align orientation.oangle_eq_pi_iff_angle_eq_pi Orientation.oangle_eq_pi_iff_angle_eq_pi theorem eq_zero_or_oangle_eq_iff_inner_eq_zero {x y : V} : x = 0 ∨ y = 0 ∨ o.oangle x y = (π / 2 : ℝ) ∨ o.oangle x y = (-π / 2 : ℝ) ↔ ⟪x, y⟫ = 0 := by by_cases hx : x = 0; · simp [hx] by_cases hy : y = 0; · simp [hy] rw [InnerProductGeometry.inner_eq_zero_iff_angle_eq_pi_div_two, or_iff_right hx, or_iff_right hy] refine ⟨fun h => ?_, fun h => ?_⟩ · rwa [o.angle_eq_abs_oangle_toReal hx hy, Real.Angle.abs_toReal_eq_pi_div_two_iff] · convert o.oangle_eq_angle_or_eq_neg_angle hx hy using 2 <;> rw [h] simp only [neg_div, Real.Angle.coe_neg] #align orientation.eq_zero_or_oangle_eq_iff_inner_eq_zero Orientation.eq_zero_or_oangle_eq_iff_inner_eq_zero theorem inner_eq_zero_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : ⟪x, y⟫ = 0 := o.eq_zero_or_oangle_eq_iff_inner_eq_zero.1 <| Or.inr <| Or.inr <| Or.inl h #align orientation.inner_eq_zero_of_oangle_eq_pi_div_two Orientation.inner_eq_zero_of_oangle_eq_pi_div_two theorem inner_rev_eq_zero_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : ⟪y, x⟫ = 0 := by rw [real_inner_comm, o.inner_eq_zero_of_oangle_eq_pi_div_two h] #align orientation.inner_rev_eq_zero_of_oangle_eq_pi_div_two Orientation.inner_rev_eq_zero_of_oangle_eq_pi_div_two theorem inner_eq_zero_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : ⟪x, y⟫ = 0 := o.eq_zero_or_oangle_eq_iff_inner_eq_zero.1 <| Or.inr <| Or.inr <| Or.inr h #align orientation.inner_eq_zero_of_oangle_eq_neg_pi_div_two Orientation.inner_eq_zero_of_oangle_eq_neg_pi_div_two theorem inner_rev_eq_zero_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : ⟪y, x⟫ = 0 := by rw [real_inner_comm, o.inner_eq_zero_of_oangle_eq_neg_pi_div_two h] #align orientation.inner_rev_eq_zero_of_oangle_eq_neg_pi_div_two Orientation.inner_rev_eq_zero_of_oangle_eq_neg_pi_div_two @[simp] theorem oangle_sign_neg_left (x y : V) : (o.oangle (-x) y).sign = -(o.oangle x y).sign := by by_cases hx : x = 0; · simp [hx] by_cases hy : y = 0; · simp [hy] rw [o.oangle_neg_left hx hy, Real.Angle.sign_add_pi] #align orientation.oangle_sign_neg_left Orientation.oangle_sign_neg_left @[simp] theorem oangle_sign_neg_right (x y : V) : (o.oangle x (-y)).sign = -(o.oangle x y).sign := by by_cases hx : x = 0; · simp [hx] by_cases hy : y = 0; · simp [hy] rw [o.oangle_neg_right hx hy, Real.Angle.sign_add_pi] #align orientation.oangle_sign_neg_right Orientation.oangle_sign_neg_right @[simp] theorem oangle_sign_smul_left (x y : V) (r : ℝ) : (o.oangle (r • x) y).sign = SignType.sign r * (o.oangle x y).sign := by rcases lt_trichotomy r 0 with (h | h | h) <;> simp [h] #align orientation.oangle_sign_smul_left Orientation.oangle_sign_smul_left @[simp]
Mathlib/Geometry/Euclidean/Angle/Oriented/Basic.lean
848
850
theorem oangle_sign_smul_right (x y : V) (r : ℝ) : (o.oangle x (r • y)).sign = SignType.sign r * (o.oangle x y).sign := by
rcases lt_trichotomy r 0 with (h | h | h) <;> simp [h]
import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Analysis.Normed.Group.Basic import Mathlib.Topology.Instances.NNReal #align_import analysis.normed.group.infinite_sum from "leanprover-community/mathlib"@"9a59dcb7a2d06bf55da57b9030169219980660cd" open Topology NNReal open Finset Filter Metric variable {ι α E F : Type*} [SeminormedAddCommGroup E] [SeminormedAddCommGroup F] theorem cauchySeq_finset_iff_vanishing_norm {f : ι → E} : (CauchySeq fun s : Finset ι => ∑ i ∈ s, f i) ↔ ∀ ε > (0 : ℝ), ∃ s : Finset ι, ∀ t, Disjoint t s → ‖∑ i ∈ t, f i‖ < ε := by rw [cauchySeq_finset_iff_sum_vanishing, nhds_basis_ball.forall_iff] · simp only [ball_zero_eq, Set.mem_setOf_eq] · rintro s t hst ⟨s', hs'⟩ exact ⟨s', fun t' ht' => hst <| hs' _ ht'⟩ #align cauchy_seq_finset_iff_vanishing_norm cauchySeq_finset_iff_vanishing_norm theorem summable_iff_vanishing_norm [CompleteSpace E] {f : ι → E} : Summable f ↔ ∀ ε > (0 : ℝ), ∃ s : Finset ι, ∀ t, Disjoint t s → ‖∑ i ∈ t, f i‖ < ε := by rw [summable_iff_cauchySeq_finset, cauchySeq_finset_iff_vanishing_norm] #align summable_iff_vanishing_norm summable_iff_vanishing_norm theorem cauchySeq_finset_of_norm_bounded_eventually {f : ι → E} {g : ι → ℝ} (hg : Summable g) (h : ∀ᶠ i in cofinite, ‖f i‖ ≤ g i) : CauchySeq fun s => ∑ i ∈ s, f i := by refine cauchySeq_finset_iff_vanishing_norm.2 fun ε hε => ?_ rcases summable_iff_vanishing_norm.1 hg ε hε with ⟨s, hs⟩ classical refine ⟨s ∪ h.toFinset, fun t ht => ?_⟩ have : ∀ i ∈ t, ‖f i‖ ≤ g i := by intro i hi simp only [disjoint_left, mem_union, not_or, h.mem_toFinset, Set.mem_compl_iff, Classical.not_not] at ht exact (ht hi).2 calc ‖∑ i ∈ t, f i‖ ≤ ∑ i ∈ t, g i := norm_sum_le_of_le _ this _ ≤ ‖∑ i ∈ t, g i‖ := le_abs_self _ _ < ε := hs _ (ht.mono_right le_sup_left) #align cauchy_seq_finset_of_norm_bounded_eventually cauchySeq_finset_of_norm_bounded_eventually theorem cauchySeq_finset_of_norm_bounded {f : ι → E} (g : ι → ℝ) (hg : Summable g) (h : ∀ i, ‖f i‖ ≤ g i) : CauchySeq fun s : Finset ι => ∑ i ∈ s, f i := cauchySeq_finset_of_norm_bounded_eventually hg <| eventually_of_forall h #align cauchy_seq_finset_of_norm_bounded cauchySeq_finset_of_norm_bounded theorem cauchySeq_range_of_norm_bounded {f : ℕ → E} (g : ℕ → ℝ) (hg : CauchySeq fun n => ∑ i ∈ range n, g i) (hf : ∀ i, ‖f i‖ ≤ g i) : CauchySeq fun n => ∑ i ∈ range n, f i := by refine Metric.cauchySeq_iff'.2 fun ε hε => ?_ refine (Metric.cauchySeq_iff'.1 hg ε hε).imp fun N hg n hn => ?_ specialize hg n hn rw [dist_eq_norm, ← sum_Ico_eq_sub _ hn] at hg ⊢ calc ‖∑ k ∈ Ico N n, f k‖ ≤ ∑ k ∈ _, ‖f k‖ := norm_sum_le _ _ _ ≤ ∑ k ∈ _, g k := sum_le_sum fun x _ => hf x _ ≤ ‖∑ k ∈ _, g k‖ := le_abs_self _ _ < ε := hg #align cauchy_seq_range_of_norm_bounded cauchySeq_range_of_norm_bounded theorem cauchySeq_finset_of_summable_norm {f : ι → E} (hf : Summable fun a => ‖f a‖) : CauchySeq fun s : Finset ι => ∑ a ∈ s, f a := cauchySeq_finset_of_norm_bounded _ hf fun _i => le_rfl #align cauchy_seq_finset_of_summable_norm cauchySeq_finset_of_summable_norm theorem hasSum_of_subseq_of_summable {f : ι → E} (hf : Summable fun a => ‖f a‖) {s : α → Finset ι} {p : Filter α} [NeBot p] (hs : Tendsto s p atTop) {a : E} (ha : Tendsto (fun b => ∑ i ∈ s b, f i) p (𝓝 a)) : HasSum f a := tendsto_nhds_of_cauchySeq_of_subseq (cauchySeq_finset_of_summable_norm hf) hs ha #align has_sum_of_subseq_of_summable hasSum_of_subseq_of_summable theorem hasSum_iff_tendsto_nat_of_summable_norm {f : ℕ → E} {a : E} (hf : Summable fun i => ‖f i‖) : HasSum f a ↔ Tendsto (fun n : ℕ => ∑ i ∈ range n, f i) atTop (𝓝 a) := ⟨fun h => h.tendsto_sum_nat, fun h => hasSum_of_subseq_of_summable hf tendsto_finset_range h⟩ #align has_sum_iff_tendsto_nat_of_summable_norm hasSum_iff_tendsto_nat_of_summable_norm theorem Summable.of_norm_bounded [CompleteSpace E] {f : ι → E} (g : ι → ℝ) (hg : Summable g) (h : ∀ i, ‖f i‖ ≤ g i) : Summable f := by rw [summable_iff_cauchySeq_finset] exact cauchySeq_finset_of_norm_bounded g hg h #align summable_of_norm_bounded Summable.of_norm_bounded theorem HasSum.norm_le_of_bounded {f : ι → E} {g : ι → ℝ} {a : E} {b : ℝ} (hf : HasSum f a) (hg : HasSum g b) (h : ∀ i, ‖f i‖ ≤ g i) : ‖a‖ ≤ b := by classical exact le_of_tendsto_of_tendsto' hf.norm hg fun _s ↦ norm_sum_le_of_le _ fun i _hi ↦ h i #align has_sum.norm_le_of_bounded HasSum.norm_le_of_bounded
Mathlib/Analysis/Normed/Group/InfiniteSum.lean
127
132
theorem tsum_of_norm_bounded {f : ι → E} {g : ι → ℝ} {a : ℝ} (hg : HasSum g a) (h : ∀ i, ‖f i‖ ≤ g i) : ‖∑' i : ι, f i‖ ≤ a := by
by_cases hf : Summable f · exact hf.hasSum.norm_le_of_bounded hg h · rw [tsum_eq_zero_of_not_summable hf, norm_zero] classical exact ge_of_tendsto' hg fun s => sum_nonneg fun i _hi => (norm_nonneg _).trans (h i)
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
Mathlib/Geometry/Euclidean/Basic.lean
612
617
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₁]
import Mathlib.LinearAlgebra.Matrix.DotProduct import Mathlib.LinearAlgebra.Determinant import Mathlib.LinearAlgebra.Matrix.Diagonal #align_import data.matrix.rank from "leanprover-community/mathlib"@"17219820a8aa8abe85adf5dfde19af1dd1bd8ae7" open Matrix namespace Matrix open FiniteDimensional variable {l m n o R : Type*} [Fintype n] [Fintype o] section CommRing variable [CommRing R] noncomputable def rank (A : Matrix m n R) : ℕ := finrank R <| LinearMap.range A.mulVecLin #align matrix.rank Matrix.rank @[simp]
Mathlib/Data/Matrix/Rank.lean
49
51
theorem rank_one [StrongRankCondition R] [DecidableEq n] : rank (1 : Matrix n n R) = Fintype.card n := by
rw [rank, mulVecLin_one, LinearMap.range_id, finrank_top, finrank_pi]
import Mathlib.Algebra.GroupWithZero.Units.Basic import Mathlib.Algebra.Group.Semiconj.Units import Mathlib.Init.Classical #align_import algebra.group_with_zero.semiconj from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" assert_not_exists DenselyOrdered variable {α M₀ G₀ M₀' G₀' F F' : Type*} namespace SemiconjBy @[simp] theorem zero_right [MulZeroClass G₀] (a : G₀) : SemiconjBy a 0 0 := by simp only [SemiconjBy, mul_zero, zero_mul] #align semiconj_by.zero_right SemiconjBy.zero_right @[simp]
Mathlib/Algebra/GroupWithZero/Semiconj.lean
29
30
theorem zero_left [MulZeroClass G₀] (x y : G₀) : SemiconjBy 0 x y := by
simp only [SemiconjBy, mul_zero, zero_mul]
import Mathlib.Algebra.Module.BigOperators import Mathlib.Data.Fintype.BigOperators import Mathlib.LinearAlgebra.AffineSpace.AffineMap import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace import Mathlib.LinearAlgebra.Finsupp import Mathlib.Tactic.FinCases #align_import linear_algebra.affine_space.combination from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0" noncomputable section open Affine namespace Finset theorem univ_fin2 : (univ : Finset (Fin 2)) = {0, 1} := by ext x fin_cases x <;> simp #align finset.univ_fin2 Finset.univ_fin2 variable {k : Type*} {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V] variable [S : AffineSpace V P] variable {ι : Type*} (s : Finset ι) variable {ι₂ : Type*} (s₂ : Finset ι₂) def weightedVSubOfPoint (p : ι → P) (b : P) : (ι → k) →ₗ[k] V := ∑ i ∈ s, (LinearMap.proj i : (ι → k) →ₗ[k] k).smulRight (p i -ᵥ b) #align finset.weighted_vsub_of_point Finset.weightedVSubOfPoint @[simp] theorem weightedVSubOfPoint_apply (w : ι → k) (p : ι → P) (b : P) : s.weightedVSubOfPoint p b w = ∑ i ∈ s, w i • (p i -ᵥ b) := by simp [weightedVSubOfPoint, LinearMap.sum_apply] #align finset.weighted_vsub_of_point_apply Finset.weightedVSubOfPoint_apply @[simp (high)] theorem weightedVSubOfPoint_apply_const (w : ι → k) (p : P) (b : P) : s.weightedVSubOfPoint (fun _ => p) b w = (∑ i ∈ s, w i) • (p -ᵥ b) := by rw [weightedVSubOfPoint_apply, sum_smul] #align finset.weighted_vsub_of_point_apply_const Finset.weightedVSubOfPoint_apply_const theorem weightedVSubOfPoint_congr {w₁ w₂ : ι → k} (hw : ∀ i ∈ s, w₁ i = w₂ i) {p₁ p₂ : ι → P} (hp : ∀ i ∈ s, p₁ i = p₂ i) (b : P) : s.weightedVSubOfPoint p₁ b w₁ = s.weightedVSubOfPoint p₂ b w₂ := by simp_rw [weightedVSubOfPoint_apply] refine sum_congr rfl fun i hi => ?_ rw [hw i hi, hp i hi] #align finset.weighted_vsub_of_point_congr Finset.weightedVSubOfPoint_congr theorem weightedVSubOfPoint_eq_of_weights_eq (p : ι → P) (j : ι) (w₁ w₂ : ι → k) (hw : ∀ i, i ≠ j → w₁ i = w₂ i) : s.weightedVSubOfPoint p (p j) w₁ = s.weightedVSubOfPoint p (p j) w₂ := by simp only [Finset.weightedVSubOfPoint_apply] congr ext i rcases eq_or_ne i j with h | h · simp [h] · simp [hw i h] #align finset.weighted_vsub_of_point_eq_of_weights_eq Finset.weightedVSubOfPoint_eq_of_weights_eq theorem weightedVSubOfPoint_eq_of_sum_eq_zero (w : ι → k) (p : ι → P) (h : ∑ i ∈ s, w i = 0) (b₁ b₂ : P) : s.weightedVSubOfPoint p b₁ w = s.weightedVSubOfPoint p b₂ w := by apply eq_of_sub_eq_zero rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← sum_sub_distrib] conv_lhs => congr · skip · ext rw [← smul_sub, vsub_sub_vsub_cancel_left] rw [← sum_smul, h, zero_smul] #align finset.weighted_vsub_of_point_eq_of_sum_eq_zero Finset.weightedVSubOfPoint_eq_of_sum_eq_zero theorem weightedVSubOfPoint_vadd_eq_of_sum_eq_one (w : ι → k) (p : ι → P) (h : ∑ i ∈ s, w i = 1) (b₁ b₂ : P) : s.weightedVSubOfPoint p b₁ w +ᵥ b₁ = s.weightedVSubOfPoint p b₂ w +ᵥ b₂ := by erw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← @vsub_eq_zero_iff_eq V, vadd_vsub_assoc, vsub_vadd_eq_vsub_sub, ← add_sub_assoc, add_comm, add_sub_assoc, ← sum_sub_distrib] conv_lhs => congr · skip · congr · skip · ext rw [← smul_sub, vsub_sub_vsub_cancel_left] rw [← sum_smul, h, one_smul, vsub_add_vsub_cancel, vsub_self] #align finset.weighted_vsub_of_point_vadd_eq_of_sum_eq_one Finset.weightedVSubOfPoint_vadd_eq_of_sum_eq_one @[simp (high)] theorem weightedVSubOfPoint_erase [DecidableEq ι] (w : ι → k) (p : ι → P) (i : ι) : (s.erase i).weightedVSubOfPoint p (p i) w = s.weightedVSubOfPoint p (p i) w := by rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply] apply sum_erase rw [vsub_self, smul_zero] #align finset.weighted_vsub_of_point_erase Finset.weightedVSubOfPoint_erase @[simp (high)] theorem weightedVSubOfPoint_insert [DecidableEq ι] (w : ι → k) (p : ι → P) (i : ι) : (insert i s).weightedVSubOfPoint p (p i) w = s.weightedVSubOfPoint p (p i) w := by rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply] apply sum_insert_zero rw [vsub_self, smul_zero] #align finset.weighted_vsub_of_point_insert Finset.weightedVSubOfPoint_insert theorem weightedVSubOfPoint_indicator_subset (w : ι → k) (p : ι → P) (b : P) {s₁ s₂ : Finset ι} (h : s₁ ⊆ s₂) : s₁.weightedVSubOfPoint p b w = s₂.weightedVSubOfPoint p b (Set.indicator (↑s₁) w) := by rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply] exact Eq.symm <| sum_indicator_subset_of_eq_zero w (fun i wi => wi • (p i -ᵥ b : V)) h fun i => zero_smul k _ #align finset.weighted_vsub_of_point_indicator_subset Finset.weightedVSubOfPoint_indicator_subset theorem weightedVSubOfPoint_map (e : ι₂ ↪ ι) (w : ι → k) (p : ι → P) (b : P) : (s₂.map e).weightedVSubOfPoint p b w = s₂.weightedVSubOfPoint (p ∘ e) b (w ∘ e) := by simp_rw [weightedVSubOfPoint_apply] exact Finset.sum_map _ _ _ #align finset.weighted_vsub_of_point_map Finset.weightedVSubOfPoint_map theorem sum_smul_vsub_eq_weightedVSubOfPoint_sub (w : ι → k) (p₁ p₂ : ι → P) (b : P) : (∑ i ∈ s, w i • (p₁ i -ᵥ p₂ i)) = s.weightedVSubOfPoint p₁ b w - s.weightedVSubOfPoint p₂ b w := by simp_rw [weightedVSubOfPoint_apply, ← sum_sub_distrib, ← smul_sub, vsub_sub_vsub_cancel_right] #align finset.sum_smul_vsub_eq_weighted_vsub_of_point_sub Finset.sum_smul_vsub_eq_weightedVSubOfPoint_sub theorem sum_smul_vsub_const_eq_weightedVSubOfPoint_sub (w : ι → k) (p₁ : ι → P) (p₂ b : P) : (∑ i ∈ s, w i • (p₁ i -ᵥ p₂)) = s.weightedVSubOfPoint p₁ b w - (∑ i ∈ s, w i) • (p₂ -ᵥ b) := by rw [sum_smul_vsub_eq_weightedVSubOfPoint_sub, weightedVSubOfPoint_apply_const] #align finset.sum_smul_vsub_const_eq_weighted_vsub_of_point_sub Finset.sum_smul_vsub_const_eq_weightedVSubOfPoint_sub
Mathlib/LinearAlgebra/AffineSpace/Combination.lean
194
196
theorem sum_smul_const_vsub_eq_sub_weightedVSubOfPoint (w : ι → k) (p₂ : ι → P) (p₁ b : P) : (∑ i ∈ s, w i • (p₁ -ᵥ p₂ i)) = (∑ i ∈ s, w i) • (p₁ -ᵥ b) - s.weightedVSubOfPoint p₂ b w := by
rw [sum_smul_vsub_eq_weightedVSubOfPoint_sub, weightedVSubOfPoint_apply_const]
import Mathlib.Topology.Sets.Opens #align_import topology.local_at_target from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open TopologicalSpace Set Filter open Topology Filter variable {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] {f : α → β} variable {s : Set β} {ι : Type*} {U : ι → Opens β} (hU : iSup U = ⊤) theorem Set.restrictPreimage_inducing (s : Set β) (h : Inducing f) : Inducing (s.restrictPreimage f) := by simp_rw [← inducing_subtype_val.of_comp_iff, inducing_iff_nhds, restrictPreimage, MapsTo.coe_restrict, restrict_eq, ← @Filter.comap_comap _ _ _ _ _ f, Function.comp_apply] at h ⊢ intro a rw [← h, ← inducing_subtype_val.nhds_eq_comap] #align set.restrict_preimage_inducing Set.restrictPreimage_inducing alias Inducing.restrictPreimage := Set.restrictPreimage_inducing #align inducing.restrict_preimage Inducing.restrictPreimage theorem Set.restrictPreimage_embedding (s : Set β) (h : Embedding f) : Embedding (s.restrictPreimage f) := ⟨h.1.restrictPreimage s, h.2.restrictPreimage s⟩ #align set.restrict_preimage_embedding Set.restrictPreimage_embedding alias Embedding.restrictPreimage := Set.restrictPreimage_embedding #align embedding.restrict_preimage Embedding.restrictPreimage theorem Set.restrictPreimage_openEmbedding (s : Set β) (h : OpenEmbedding f) : OpenEmbedding (s.restrictPreimage f) := ⟨h.1.restrictPreimage s, (s.range_restrictPreimage f).symm ▸ continuous_subtype_val.isOpen_preimage _ h.isOpen_range⟩ #align set.restrict_preimage_open_embedding Set.restrictPreimage_openEmbedding alias OpenEmbedding.restrictPreimage := Set.restrictPreimage_openEmbedding #align open_embedding.restrict_preimage OpenEmbedding.restrictPreimage theorem Set.restrictPreimage_closedEmbedding (s : Set β) (h : ClosedEmbedding f) : ClosedEmbedding (s.restrictPreimage f) := ⟨h.1.restrictPreimage s, (s.range_restrictPreimage f).symm ▸ inducing_subtype_val.isClosed_preimage _ h.isClosed_range⟩ #align set.restrict_preimage_closed_embedding Set.restrictPreimage_closedEmbedding alias ClosedEmbedding.restrictPreimage := Set.restrictPreimage_closedEmbedding #align closed_embedding.restrict_preimage ClosedEmbedding.restrictPreimage theorem IsClosedMap.restrictPreimage (H : IsClosedMap f) (s : Set β) : IsClosedMap (s.restrictPreimage f) := by intro t suffices ∀ u, IsClosed u → Subtype.val ⁻¹' u = t → ∃ v, IsClosed v ∧ Subtype.val ⁻¹' v = s.restrictPreimage f '' t by simpa [isClosed_induced_iff] exact fun u hu e => ⟨f '' u, H u hu, by simp [← e, image_restrictPreimage]⟩ @[deprecated (since := "2024-04-02")] theorem Set.restrictPreimage_isClosedMap (s : Set β) (H : IsClosedMap f) : IsClosedMap (s.restrictPreimage f) := H.restrictPreimage s theorem IsOpenMap.restrictPreimage (H : IsOpenMap f) (s : Set β) : IsOpenMap (s.restrictPreimage f) := by intro t suffices ∀ u, IsOpen u → Subtype.val ⁻¹' u = t → ∃ v, IsOpen v ∧ Subtype.val ⁻¹' v = s.restrictPreimage f '' t by simpa [isOpen_induced_iff] exact fun u hu e => ⟨f '' u, H u hu, by simp [← e, image_restrictPreimage]⟩ @[deprecated (since := "2024-04-02")] theorem Set.restrictPreimage_isOpenMap (s : Set β) (H : IsOpenMap f) : IsOpenMap (s.restrictPreimage f) := H.restrictPreimage s theorem isOpen_iff_inter_of_iSup_eq_top (s : Set β) : IsOpen s ↔ ∀ i, IsOpen (s ∩ U i) := by constructor · exact fun H i => H.inter (U i).2 · intro H have : ⋃ i, (U i : Set β) = Set.univ := by convert congr_arg (SetLike.coe) hU simp rw [← s.inter_univ, ← this, Set.inter_iUnion] exact isOpen_iUnion H #align is_open_iff_inter_of_supr_eq_top isOpen_iff_inter_of_iSup_eq_top theorem isOpen_iff_coe_preimage_of_iSup_eq_top (s : Set β) : IsOpen s ↔ ∀ i, IsOpen ((↑) ⁻¹' s : Set (U i)) := by -- Porting note: rewrote to avoid ´simp´ issues rw [isOpen_iff_inter_of_iSup_eq_top hU s] refine forall_congr' fun i => ?_ rw [(U _).2.openEmbedding_subtype_val.open_iff_image_open] erw [Set.image_preimage_eq_inter_range] rw [Subtype.range_coe, Opens.carrier_eq_coe] #align is_open_iff_coe_preimage_of_supr_eq_top isOpen_iff_coe_preimage_of_iSup_eq_top
Mathlib/Topology/LocalAtTarget.lean
111
113
theorem isClosed_iff_coe_preimage_of_iSup_eq_top (s : Set β) : IsClosed s ↔ ∀ i, IsClosed ((↑) ⁻¹' s : Set (U i)) := by
simpa using isOpen_iff_coe_preimage_of_iSup_eq_top hU sᶜ
import Mathlib.Order.Interval.Set.UnorderedInterval import Mathlib.Algebra.Order.Interval.Set.Monoid import Mathlib.Data.Set.Pointwise.Basic import Mathlib.Algebra.Order.Field.Basic import Mathlib.Algebra.Order.Group.MinMax #align_import data.set.pointwise.interval from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" open Interval Pointwise variable {α : Type*} namespace Set section OrderedAddCommGroup variable [OrderedAddCommGroup α] (a b c : α) @[simp] theorem preimage_const_add_Ici : (fun x => a + x) ⁻¹' Ici b = Ici (b - a) := ext fun _x => sub_le_iff_le_add'.symm #align set.preimage_const_add_Ici Set.preimage_const_add_Ici @[simp] theorem preimage_const_add_Ioi : (fun x => a + x) ⁻¹' Ioi b = Ioi (b - a) := ext fun _x => sub_lt_iff_lt_add'.symm #align set.preimage_const_add_Ioi Set.preimage_const_add_Ioi @[simp] theorem preimage_const_add_Iic : (fun x => a + x) ⁻¹' Iic b = Iic (b - a) := ext fun _x => le_sub_iff_add_le'.symm #align set.preimage_const_add_Iic Set.preimage_const_add_Iic @[simp] theorem preimage_const_add_Iio : (fun x => a + x) ⁻¹' Iio b = Iio (b - a) := ext fun _x => lt_sub_iff_add_lt'.symm #align set.preimage_const_add_Iio Set.preimage_const_add_Iio @[simp] theorem preimage_const_add_Icc : (fun x => a + x) ⁻¹' Icc b c = Icc (b - a) (c - a) := by simp [← Ici_inter_Iic] #align set.preimage_const_add_Icc Set.preimage_const_add_Icc @[simp] theorem preimage_const_add_Ico : (fun x => a + x) ⁻¹' Ico b c = Ico (b - a) (c - a) := by simp [← Ici_inter_Iio] #align set.preimage_const_add_Ico Set.preimage_const_add_Ico @[simp] theorem preimage_const_add_Ioc : (fun x => a + x) ⁻¹' Ioc b c = Ioc (b - a) (c - a) := by simp [← Ioi_inter_Iic] #align set.preimage_const_add_Ioc Set.preimage_const_add_Ioc @[simp] theorem preimage_const_add_Ioo : (fun x => a + x) ⁻¹' Ioo b c = Ioo (b - a) (c - a) := by simp [← Ioi_inter_Iio] #align set.preimage_const_add_Ioo Set.preimage_const_add_Ioo @[simp] theorem preimage_add_const_Ici : (fun x => x + a) ⁻¹' Ici b = Ici (b - a) := ext fun _x => sub_le_iff_le_add.symm #align set.preimage_add_const_Ici Set.preimage_add_const_Ici @[simp] theorem preimage_add_const_Ioi : (fun x => x + a) ⁻¹' Ioi b = Ioi (b - a) := ext fun _x => sub_lt_iff_lt_add.symm #align set.preimage_add_const_Ioi Set.preimage_add_const_Ioi @[simp] theorem preimage_add_const_Iic : (fun x => x + a) ⁻¹' Iic b = Iic (b - a) := ext fun _x => le_sub_iff_add_le.symm #align set.preimage_add_const_Iic Set.preimage_add_const_Iic @[simp] theorem preimage_add_const_Iio : (fun x => x + a) ⁻¹' Iio b = Iio (b - a) := ext fun _x => lt_sub_iff_add_lt.symm #align set.preimage_add_const_Iio Set.preimage_add_const_Iio @[simp] theorem preimage_add_const_Icc : (fun x => x + a) ⁻¹' Icc b c = Icc (b - a) (c - a) := by simp [← Ici_inter_Iic] #align set.preimage_add_const_Icc Set.preimage_add_const_Icc @[simp] theorem preimage_add_const_Ico : (fun x => x + a) ⁻¹' Ico b c = Ico (b - a) (c - a) := by simp [← Ici_inter_Iio] #align set.preimage_add_const_Ico Set.preimage_add_const_Ico @[simp] theorem preimage_add_const_Ioc : (fun x => x + a) ⁻¹' Ioc b c = Ioc (b - a) (c - a) := by simp [← Ioi_inter_Iic] #align set.preimage_add_const_Ioc Set.preimage_add_const_Ioc @[simp] theorem preimage_add_const_Ioo : (fun x => x + a) ⁻¹' Ioo b c = Ioo (b - a) (c - a) := by simp [← Ioi_inter_Iio] #align set.preimage_add_const_Ioo Set.preimage_add_const_Ioo @[simp] theorem preimage_neg_Ici : -Ici a = Iic (-a) := ext fun _x => le_neg #align set.preimage_neg_Ici Set.preimage_neg_Ici @[simp] theorem preimage_neg_Iic : -Iic a = Ici (-a) := ext fun _x => neg_le #align set.preimage_neg_Iic Set.preimage_neg_Iic @[simp] theorem preimage_neg_Ioi : -Ioi a = Iio (-a) := ext fun _x => lt_neg #align set.preimage_neg_Ioi Set.preimage_neg_Ioi @[simp] theorem preimage_neg_Iio : -Iio a = Ioi (-a) := ext fun _x => neg_lt #align set.preimage_neg_Iio Set.preimage_neg_Iio @[simp] theorem preimage_neg_Icc : -Icc a b = Icc (-b) (-a) := by simp [← Ici_inter_Iic, inter_comm] #align set.preimage_neg_Icc Set.preimage_neg_Icc @[simp] theorem preimage_neg_Ico : -Ico a b = Ioc (-b) (-a) := by simp [← Ici_inter_Iio, ← Ioi_inter_Iic, inter_comm] #align set.preimage_neg_Ico Set.preimage_neg_Ico @[simp] theorem preimage_neg_Ioc : -Ioc a b = Ico (-b) (-a) := by simp [← Ioi_inter_Iic, ← Ici_inter_Iio, inter_comm] #align set.preimage_neg_Ioc Set.preimage_neg_Ioc @[simp] theorem preimage_neg_Ioo : -Ioo a b = Ioo (-b) (-a) := by simp [← Ioi_inter_Iio, inter_comm] #align set.preimage_neg_Ioo Set.preimage_neg_Ioo @[simp] theorem preimage_sub_const_Ici : (fun x => x - a) ⁻¹' Ici b = Ici (b + a) := by simp [sub_eq_add_neg] #align set.preimage_sub_const_Ici Set.preimage_sub_const_Ici @[simp] theorem preimage_sub_const_Ioi : (fun x => x - a) ⁻¹' Ioi b = Ioi (b + a) := by simp [sub_eq_add_neg] #align set.preimage_sub_const_Ioi Set.preimage_sub_const_Ioi @[simp] theorem preimage_sub_const_Iic : (fun x => x - a) ⁻¹' Iic b = Iic (b + a) := by simp [sub_eq_add_neg] #align set.preimage_sub_const_Iic Set.preimage_sub_const_Iic @[simp] theorem preimage_sub_const_Iio : (fun x => x - a) ⁻¹' Iio b = Iio (b + a) := by simp [sub_eq_add_neg] #align set.preimage_sub_const_Iio Set.preimage_sub_const_Iio @[simp] theorem preimage_sub_const_Icc : (fun x => x - a) ⁻¹' Icc b c = Icc (b + a) (c + a) := by simp [sub_eq_add_neg] #align set.preimage_sub_const_Icc Set.preimage_sub_const_Icc @[simp] theorem preimage_sub_const_Ico : (fun x => x - a) ⁻¹' Ico b c = Ico (b + a) (c + a) := by simp [sub_eq_add_neg] #align set.preimage_sub_const_Ico Set.preimage_sub_const_Ico @[simp] theorem preimage_sub_const_Ioc : (fun x => x - a) ⁻¹' Ioc b c = Ioc (b + a) (c + a) := by simp [sub_eq_add_neg] #align set.preimage_sub_const_Ioc Set.preimage_sub_const_Ioc @[simp] theorem preimage_sub_const_Ioo : (fun x => x - a) ⁻¹' Ioo b c = Ioo (b + a) (c + a) := by simp [sub_eq_add_neg] #align set.preimage_sub_const_Ioo Set.preimage_sub_const_Ioo @[simp] theorem preimage_const_sub_Ici : (fun x => a - x) ⁻¹' Ici b = Iic (a - b) := ext fun _x => le_sub_comm #align set.preimage_const_sub_Ici Set.preimage_const_sub_Ici @[simp] theorem preimage_const_sub_Iic : (fun x => a - x) ⁻¹' Iic b = Ici (a - b) := ext fun _x => sub_le_comm #align set.preimage_const_sub_Iic Set.preimage_const_sub_Iic @[simp] theorem preimage_const_sub_Ioi : (fun x => a - x) ⁻¹' Ioi b = Iio (a - b) := ext fun _x => lt_sub_comm #align set.preimage_const_sub_Ioi Set.preimage_const_sub_Ioi @[simp] theorem preimage_const_sub_Iio : (fun x => a - x) ⁻¹' Iio b = Ioi (a - b) := ext fun _x => sub_lt_comm #align set.preimage_const_sub_Iio Set.preimage_const_sub_Iio @[simp] theorem preimage_const_sub_Icc : (fun x => a - x) ⁻¹' Icc b c = Icc (a - c) (a - b) := by simp [← Ici_inter_Iic, inter_comm] #align set.preimage_const_sub_Icc Set.preimage_const_sub_Icc @[simp] theorem preimage_const_sub_Ico : (fun x => a - x) ⁻¹' Ico b c = Ioc (a - c) (a - b) := by simp [← Ioi_inter_Iic, ← Ici_inter_Iio, inter_comm] #align set.preimage_const_sub_Ico Set.preimage_const_sub_Ico @[simp] theorem preimage_const_sub_Ioc : (fun x => a - x) ⁻¹' Ioc b c = Ico (a - c) (a - b) := by simp [← Ioi_inter_Iic, ← Ici_inter_Iio, inter_comm] #align set.preimage_const_sub_Ioc Set.preimage_const_sub_Ioc @[simp] theorem preimage_const_sub_Ioo : (fun x => a - x) ⁻¹' Ioo b c = Ioo (a - c) (a - b) := by simp [← Ioi_inter_Iio, inter_comm] #align set.preimage_const_sub_Ioo Set.preimage_const_sub_Ioo -- @[simp] -- Porting note (#10618): simp can prove this modulo `add_comm` theorem image_const_add_Iic : (fun x => a + x) '' Iic b = Iic (a + b) := by simp [add_comm] #align set.image_const_add_Iic Set.image_const_add_Iic -- @[simp] -- Porting note (#10618): simp can prove this modulo `add_comm` theorem image_const_add_Iio : (fun x => a + x) '' Iio b = Iio (a + b) := by simp [add_comm] #align set.image_const_add_Iio Set.image_const_add_Iio -- @[simp] -- Porting note (#10618): simp can prove this theorem image_add_const_Iic : (fun x => x + a) '' Iic b = Iic (b + a) := by simp #align set.image_add_const_Iic Set.image_add_const_Iic -- @[simp] -- Porting note (#10618): simp can prove this theorem image_add_const_Iio : (fun x => x + a) '' Iio b = Iio (b + a) := by simp #align set.image_add_const_Iio Set.image_add_const_Iio theorem image_neg_Ici : Neg.neg '' Ici a = Iic (-a) := by simp #align set.image_neg_Ici Set.image_neg_Ici theorem image_neg_Iic : Neg.neg '' Iic a = Ici (-a) := by simp #align set.image_neg_Iic Set.image_neg_Iic
Mathlib/Data/Set/Pointwise/Interval.lean
381
381
theorem image_neg_Ioi : Neg.neg '' Ioi a = Iio (-a) := by
simp
import Mathlib.Data.Set.Function import Mathlib.Logic.Equiv.Defs import Mathlib.Tactic.Core import Mathlib.Tactic.Attr.Core #align_import logic.equiv.local_equiv from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" open Lean Meta Elab Tactic def mfld_cfg : Simps.Config where attrs := [`mfld_simps] fullyApplied := false #align mfld_cfg mfld_cfg open Function Set variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} structure PartialEquiv (α : Type*) (β : Type*) where toFun : α → β invFun : β → α source : Set α target : Set β map_source' : ∀ ⦃x⦄, x ∈ source → toFun x ∈ target map_target' : ∀ ⦃x⦄, x ∈ target → invFun x ∈ source left_inv' : ∀ ⦃x⦄, x ∈ source → invFun (toFun x) = x right_inv' : ∀ ⦃x⦄, x ∈ target → toFun (invFun x) = x #align local_equiv PartialEquiv attribute [coe] PartialEquiv.toFun namespace PartialEquiv variable (e : PartialEquiv α β) (e' : PartialEquiv β γ) instance [Inhabited α] [Inhabited β] : Inhabited (PartialEquiv α β) := ⟨⟨const α default, const β default, ∅, ∅, mapsTo_empty _ _, mapsTo_empty _ _, eqOn_empty _ _, eqOn_empty _ _⟩⟩ @[symm] protected def symm : PartialEquiv β α where toFun := e.invFun invFun := e.toFun source := e.target target := e.source map_source' := e.map_target' map_target' := e.map_source' left_inv' := e.right_inv' right_inv' := e.left_inv' #align local_equiv.symm PartialEquiv.symm instance : CoeFun (PartialEquiv α β) fun _ => α → β := ⟨PartialEquiv.toFun⟩ def Simps.symm_apply (e : PartialEquiv α β) : β → α := e.symm #align local_equiv.simps.symm_apply PartialEquiv.Simps.symm_apply initialize_simps_projections PartialEquiv (toFun → apply, invFun → symm_apply) -- Porting note: this can be proven with `dsimp only` -- @[simp, mfld_simps] -- theorem coe_mk (f : α → β) (g s t ml mr il ir) : -- (PartialEquiv.mk f g s t ml mr il ir : α → β) = f := by dsimp only -- #align local_equiv.coe_mk PartialEquiv.coe_mk #noalign local_equiv.coe_mk @[simp, mfld_simps] theorem coe_symm_mk (f : α → β) (g s t ml mr il ir) : ((PartialEquiv.mk f g s t ml mr il ir).symm : β → α) = g := rfl #align local_equiv.coe_symm_mk PartialEquiv.coe_symm_mk -- Porting note: this is now a syntactic tautology -- @[simp, mfld_simps] -- theorem toFun_as_coe : e.toFun = e := rfl -- #align local_equiv.to_fun_as_coe PartialEquiv.toFun_as_coe #noalign local_equiv.to_fun_as_coe @[simp, mfld_simps] theorem invFun_as_coe : e.invFun = e.symm := rfl #align local_equiv.inv_fun_as_coe PartialEquiv.invFun_as_coe @[simp, mfld_simps] theorem map_source {x : α} (h : x ∈ e.source) : e x ∈ e.target := e.map_source' h #align local_equiv.map_source PartialEquiv.map_source lemma map_source'' : e '' e.source ⊆ e.target := fun _ ⟨_, hx, hex⟩ ↦ mem_of_eq_of_mem (id hex.symm) (e.map_source' hx) @[simp, mfld_simps] theorem map_target {x : β} (h : x ∈ e.target) : e.symm x ∈ e.source := e.map_target' h #align local_equiv.map_target PartialEquiv.map_target @[simp, mfld_simps] theorem left_inv {x : α} (h : x ∈ e.source) : e.symm (e x) = x := e.left_inv' h #align local_equiv.left_inv PartialEquiv.left_inv @[simp, mfld_simps] theorem right_inv {x : β} (h : x ∈ e.target) : e (e.symm x) = x := e.right_inv' h #align local_equiv.right_inv PartialEquiv.right_inv theorem eq_symm_apply {x : α} {y : β} (hx : x ∈ e.source) (hy : y ∈ e.target) : x = e.symm y ↔ e x = y := ⟨fun h => by rw [← e.right_inv hy, h], fun h => by rw [← e.left_inv hx, h]⟩ #align local_equiv.eq_symm_apply PartialEquiv.eq_symm_apply protected theorem mapsTo : MapsTo e e.source e.target := fun _ => e.map_source #align local_equiv.maps_to PartialEquiv.mapsTo theorem symm_mapsTo : MapsTo e.symm e.target e.source := e.symm.mapsTo #align local_equiv.symm_maps_to PartialEquiv.symm_mapsTo protected theorem leftInvOn : LeftInvOn e.symm e e.source := fun _ => e.left_inv #align local_equiv.left_inv_on PartialEquiv.leftInvOn protected theorem rightInvOn : RightInvOn e.symm e e.target := fun _ => e.right_inv #align local_equiv.right_inv_on PartialEquiv.rightInvOn protected theorem invOn : InvOn e.symm e e.source e.target := ⟨e.leftInvOn, e.rightInvOn⟩ #align local_equiv.inv_on PartialEquiv.invOn protected theorem injOn : InjOn e e.source := e.leftInvOn.injOn #align local_equiv.inj_on PartialEquiv.injOn protected theorem bijOn : BijOn e e.source e.target := e.invOn.bijOn e.mapsTo e.symm_mapsTo #align local_equiv.bij_on PartialEquiv.bijOn protected theorem surjOn : SurjOn e e.source e.target := e.bijOn.surjOn #align local_equiv.surj_on PartialEquiv.surjOn @[simps (config := .asFn)] def _root_.Equiv.toPartialEquivOfImageEq (e : α ≃ β) (s : Set α) (t : Set β) (h : e '' s = t) : PartialEquiv α β where toFun := e invFun := e.symm source := s target := t map_source' x hx := h ▸ mem_image_of_mem _ hx map_target' x hx := by subst t rcases hx with ⟨x, hx, rfl⟩ rwa [e.symm_apply_apply] left_inv' x _ := e.symm_apply_apply x right_inv' x _ := e.apply_symm_apply x @[simps! (config := mfld_cfg)] def _root_.Equiv.toPartialEquiv (e : α ≃ β) : PartialEquiv α β := e.toPartialEquivOfImageEq univ univ <| by rw [image_univ, e.surjective.range_eq] #align equiv.to_local_equiv Equiv.toPartialEquiv #align equiv.to_local_equiv_symm_apply Equiv.toPartialEquiv_symm_apply #align equiv.to_local_equiv_target Equiv.toPartialEquiv_target #align equiv.to_local_equiv_apply Equiv.toPartialEquiv_apply #align equiv.to_local_equiv_source Equiv.toPartialEquiv_source instance inhabitedOfEmpty [IsEmpty α] [IsEmpty β] : Inhabited (PartialEquiv α β) := ⟨((Equiv.equivEmpty α).trans (Equiv.equivEmpty β).symm).toPartialEquiv⟩ #align local_equiv.inhabited_of_empty PartialEquiv.inhabitedOfEmpty @[simps (config := .asFn)] def copy (e : PartialEquiv α β) (f : α → β) (hf : ⇑e = f) (g : β → α) (hg : ⇑e.symm = g) (s : Set α) (hs : e.source = s) (t : Set β) (ht : e.target = t) : PartialEquiv α β where toFun := f invFun := g source := s target := t map_source' _ := ht ▸ hs ▸ hf ▸ e.map_source map_target' _ := hs ▸ ht ▸ hg ▸ e.map_target left_inv' _ := hs ▸ hf ▸ hg ▸ e.left_inv right_inv' _ := ht ▸ hf ▸ hg ▸ e.right_inv #align local_equiv.copy PartialEquiv.copy #align local_equiv.copy_source PartialEquiv.copy_source #align local_equiv.copy_apply PartialEquiv.copy_apply #align local_equiv.copy_symm_apply PartialEquiv.copy_symm_apply #align local_equiv.copy_target PartialEquiv.copy_target
Mathlib/Logic/Equiv/PartialEquiv.lean
305
310
theorem copy_eq (e : PartialEquiv α β) (f : α → β) (hf : ⇑e = f) (g : β → α) (hg : ⇑e.symm = g) (s : Set α) (hs : e.source = s) (t : Set β) (ht : e.target = t) : e.copy f hf g hg s hs t ht = e := by
substs f g s t cases e rfl
import Mathlib.CategoryTheory.Limits.Filtered import Mathlib.CategoryTheory.Limits.Shapes.FiniteProducts import Mathlib.CategoryTheory.Limits.Shapes.Kernels import Mathlib.CategoryTheory.DiscreteCategory #align_import category_theory.limits.opposites from "leanprover-community/mathlib"@"ac3ae212f394f508df43e37aa093722fa9b65d31" universe v₁ v₂ u₁ u₂ noncomputable section open CategoryTheory open CategoryTheory.Functor open Opposite namespace CategoryTheory.Limits variable {C : Type u₁} [Category.{v₁} C] variable {J : Type u₂} [Category.{v₂} J] #align category_theory.limits.is_limit_cocone_op CategoryTheory.Limits.IsColimit.op #align category_theory.limits.is_colimit_cone_op CategoryTheory.Limits.IsLimit.op #align category_theory.limits.is_limit_cocone_unop CategoryTheory.Limits.IsColimit.unop #align category_theory.limits.is_colimit_cone_unop CategoryTheory.Limits.IsLimit.unop -- 2024-03-26 @[deprecated] alias isLimitCoconeOp := IsColimit.op @[deprecated] alias isColimitConeOp := IsLimit.op @[deprecated] alias isLimitCoconeUnop := IsColimit.unop @[deprecated] alias isColimitConeUnop := IsLimit.unop @[simps] def isLimitConeLeftOpOfCocone (F : J ⥤ Cᵒᵖ) {c : Cocone F} (hc : IsColimit c) : IsLimit (coneLeftOpOfCocone c) where lift s := (hc.desc (coconeOfConeLeftOp s)).unop fac s j := Quiver.Hom.op_inj <| by simp only [coneLeftOpOfCocone_π_app, op_comp, Quiver.Hom.op_unop, IsColimit.fac, coconeOfConeLeftOp_ι_app, op_unop] uniq s m w := by refine Quiver.Hom.op_inj (hc.hom_ext fun j => Quiver.Hom.unop_inj ?_) simpa only [Quiver.Hom.op_unop, IsColimit.fac, coconeOfConeLeftOp_ι_app] using w (op j) #align category_theory.limits.is_limit_cone_left_op_of_cocone CategoryTheory.Limits.isLimitConeLeftOpOfCocone @[simps] def isColimitCoconeLeftOpOfCone (F : J ⥤ Cᵒᵖ) {c : Cone F} (hc : IsLimit c) : IsColimit (coconeLeftOpOfCone c) where desc s := (hc.lift (coneOfCoconeLeftOp s)).unop fac s j := Quiver.Hom.op_inj <| by simp only [coconeLeftOpOfCone_ι_app, op_comp, Quiver.Hom.op_unop, IsLimit.fac, coneOfCoconeLeftOp_π_app, op_unop] uniq s m w := by refine Quiver.Hom.op_inj (hc.hom_ext fun j => Quiver.Hom.unop_inj ?_) simpa only [Quiver.Hom.op_unop, IsLimit.fac, coneOfCoconeLeftOp_π_app] using w (op j) #align category_theory.limits.is_colimit_cocone_left_op_of_cone CategoryTheory.Limits.isColimitCoconeLeftOpOfCone @[simps] def isLimitConeRightOpOfCocone (F : Jᵒᵖ ⥤ C) {c : Cocone F} (hc : IsColimit c) : IsLimit (coneRightOpOfCocone c) where lift s := (hc.desc (coconeOfConeRightOp s)).op fac s j := Quiver.Hom.unop_inj (by simp) uniq s m w := by refine Quiver.Hom.unop_inj (hc.hom_ext fun j => Quiver.Hom.op_inj ?_) simpa only [Quiver.Hom.unop_op, IsColimit.fac] using w (unop j) #align category_theory.limits.is_limit_cone_right_op_of_cocone CategoryTheory.Limits.isLimitConeRightOpOfCocone @[simps] def isColimitCoconeRightOpOfCone (F : Jᵒᵖ ⥤ C) {c : Cone F} (hc : IsLimit c) : IsColimit (coconeRightOpOfCone c) where desc s := (hc.lift (coneOfCoconeRightOp s)).op fac s j := Quiver.Hom.unop_inj (by simp) uniq s m w := by refine Quiver.Hom.unop_inj (hc.hom_ext fun j => Quiver.Hom.op_inj ?_) simpa only [Quiver.Hom.unop_op, IsLimit.fac] using w (unop j) #align category_theory.limits.is_colimit_cocone_right_op_of_cone CategoryTheory.Limits.isColimitCoconeRightOpOfCone @[simps] def isLimitConeUnopOfCocone (F : Jᵒᵖ ⥤ Cᵒᵖ) {c : Cocone F} (hc : IsColimit c) : IsLimit (coneUnopOfCocone c) where lift s := (hc.desc (coconeOfConeUnop s)).unop fac s j := Quiver.Hom.op_inj (by simp) uniq s m w := by refine Quiver.Hom.op_inj (hc.hom_ext fun j => Quiver.Hom.unop_inj ?_) simpa only [Quiver.Hom.op_unop, IsColimit.fac] using w (unop j) #align category_theory.limits.is_limit_cone_unop_of_cocone CategoryTheory.Limits.isLimitConeUnopOfCocone @[simps] def isColimitCoconeUnopOfCone (F : Jᵒᵖ ⥤ Cᵒᵖ) {c : Cone F} (hc : IsLimit c) : IsColimit (coconeUnopOfCone c) where desc s := (hc.lift (coneOfCoconeUnop s)).unop fac s j := Quiver.Hom.op_inj (by simp) uniq s m w := by refine Quiver.Hom.op_inj (hc.hom_ext fun j => Quiver.Hom.unop_inj ?_) simpa only [Quiver.Hom.op_unop, IsLimit.fac] using w (unop j) #align category_theory.limits.is_colimit_cocone_unop_of_cone CategoryTheory.Limits.isColimitCoconeUnopOfCone @[simps] def isLimitConeOfCoconeLeftOp (F : J ⥤ Cᵒᵖ) {c : Cocone F.leftOp} (hc : IsColimit c) : IsLimit (coneOfCoconeLeftOp c) where lift s := (hc.desc (coconeLeftOpOfCone s)).op fac s j := Quiver.Hom.unop_inj <| by simp only [coneOfCoconeLeftOp_π_app, unop_comp, Quiver.Hom.unop_op, IsColimit.fac, coconeLeftOpOfCone_ι_app, unop_op] uniq s m w := by refine Quiver.Hom.unop_inj (hc.hom_ext fun j => Quiver.Hom.op_inj ?_) simpa only [Quiver.Hom.unop_op, IsColimit.fac, coneOfCoconeLeftOp_π_app] using w (unop j) #align category_theory.limits.is_limit_cone_of_cocone_left_op CategoryTheory.Limits.isLimitConeOfCoconeLeftOp @[simps] def isColimitCoconeOfConeLeftOp (F : J ⥤ Cᵒᵖ) {c : Cone F.leftOp} (hc : IsLimit c) : IsColimit (coconeOfConeLeftOp c) where desc s := (hc.lift (coneLeftOpOfCocone s)).op fac s j := Quiver.Hom.unop_inj <| by simp only [coconeOfConeLeftOp_ι_app, unop_comp, Quiver.Hom.unop_op, IsLimit.fac, coneLeftOpOfCocone_π_app, unop_op] uniq s m w := by refine Quiver.Hom.unop_inj (hc.hom_ext fun j => Quiver.Hom.op_inj ?_) simpa only [Quiver.Hom.unop_op, IsLimit.fac, coconeOfConeLeftOp_ι_app] using w (unop j) #align category_theory.limits.is_colimit_cocone_of_cone_left_op CategoryTheory.Limits.isColimitCoconeOfConeLeftOp @[simps] def isLimitConeOfCoconeRightOp (F : Jᵒᵖ ⥤ C) {c : Cocone F.rightOp} (hc : IsColimit c) : IsLimit (coneOfCoconeRightOp c) where lift s := (hc.desc (coconeRightOpOfCone s)).unop fac s j := Quiver.Hom.op_inj (by simp) uniq s m w := by refine Quiver.Hom.op_inj (hc.hom_ext fun j => Quiver.Hom.unop_inj ?_) simpa only [Quiver.Hom.op_unop, IsColimit.fac] using w (op j) #align category_theory.limits.is_limit_cone_of_cocone_right_op CategoryTheory.Limits.isLimitConeOfCoconeRightOp @[simps] def isColimitCoconeOfConeRightOp (F : Jᵒᵖ ⥤ C) {c : Cone F.rightOp} (hc : IsLimit c) : IsColimit (coconeOfConeRightOp c) where desc s := (hc.lift (coneRightOpOfCocone s)).unop fac s j := Quiver.Hom.op_inj (by simp) uniq s m w := by refine Quiver.Hom.op_inj (hc.hom_ext fun j => Quiver.Hom.unop_inj ?_) simpa only [Quiver.Hom.op_unop, IsLimit.fac] using w (op j) #align category_theory.limits.is_colimit_cocone_of_cone_right_op CategoryTheory.Limits.isColimitCoconeOfConeRightOp @[simps] def isLimitConeOfCoconeUnop (F : Jᵒᵖ ⥤ Cᵒᵖ) {c : Cocone F.unop} (hc : IsColimit c) : IsLimit (coneOfCoconeUnop c) where lift s := (hc.desc (coconeUnopOfCone s)).op fac s j := Quiver.Hom.unop_inj (by simp) uniq s m w := by refine Quiver.Hom.unop_inj (hc.hom_ext fun j => Quiver.Hom.op_inj ?_) simpa only [Quiver.Hom.unop_op, IsColimit.fac] using w (op j) #align category_theory.limits.is_limit_cone_of_cocone_unop CategoryTheory.Limits.isLimitConeOfCoconeUnop @[simps] def isColimitConeOfCoconeUnop (F : Jᵒᵖ ⥤ Cᵒᵖ) {c : Cone F.unop} (hc : IsLimit c) : IsColimit (coconeOfConeUnop c) where desc s := (hc.lift (coneUnopOfCocone s)).op fac s j := Quiver.Hom.unop_inj (by simp) uniq s m w := by refine Quiver.Hom.unop_inj (hc.hom_ext fun j => Quiver.Hom.op_inj ?_) simpa only [Quiver.Hom.unop_op, IsLimit.fac] using w (op j) #align category_theory.limits.is_colimit_cone_of_cocone_unop CategoryTheory.Limits.isColimitConeOfCoconeUnop theorem hasLimit_of_hasColimit_leftOp (F : J ⥤ Cᵒᵖ) [HasColimit F.leftOp] : HasLimit F := HasLimit.mk { cone := coneOfCoconeLeftOp (colimit.cocone F.leftOp) isLimit := isLimitConeOfCoconeLeftOp _ (colimit.isColimit _) } #align category_theory.limits.has_limit_of_has_colimit_left_op CategoryTheory.Limits.hasLimit_of_hasColimit_leftOp theorem hasLimit_of_hasColimit_op (F : J ⥤ C) [HasColimit F.op] : HasLimit F := HasLimit.mk { cone := (colimit.cocone F.op).unop isLimit := (colimit.isColimit _).unop } theorem hasLimit_op_of_hasColimit (F : J ⥤ C) [HasColimit F] : HasLimit F.op := HasLimit.mk { cone := (colimit.cocone F).op isLimit := (colimit.isColimit _).op } #align category_theory.limits.has_limit_of_has_colimit_op CategoryTheory.Limits.hasLimit_of_hasColimit_op theorem hasLimitsOfShape_op_of_hasColimitsOfShape [HasColimitsOfShape Jᵒᵖ C] : HasLimitsOfShape J Cᵒᵖ := { has_limit := fun F => hasLimit_of_hasColimit_leftOp F } #align category_theory.limits.has_limits_of_shape_op_of_has_colimits_of_shape CategoryTheory.Limits.hasLimitsOfShape_op_of_hasColimitsOfShape theorem hasLimitsOfShape_of_hasColimitsOfShape_op [HasColimitsOfShape Jᵒᵖ Cᵒᵖ] : HasLimitsOfShape J C := { has_limit := fun F => hasLimit_of_hasColimit_op F } #align category_theory.limits.has_limits_of_shape_of_has_colimits_of_shape_op CategoryTheory.Limits.hasLimitsOfShape_of_hasColimitsOfShape_op attribute [local instance] hasLimitsOfShape_op_of_hasColimitsOfShape instance hasLimits_op_of_hasColimits [HasColimits C] : HasLimits Cᵒᵖ := ⟨fun _ => inferInstance⟩ #align category_theory.limits.has_limits_op_of_has_colimits CategoryTheory.Limits.hasLimits_op_of_hasColimits theorem hasLimits_of_hasColimits_op [HasColimits Cᵒᵖ] : HasLimits C := { has_limits_of_shape := fun _ _ => hasLimitsOfShape_of_hasColimitsOfShape_op } #align category_theory.limits.has_limits_of_has_colimits_op CategoryTheory.Limits.hasLimits_of_hasColimits_op instance has_cofiltered_limits_op_of_has_filtered_colimits [HasFilteredColimitsOfSize.{v₂, u₂} C] : HasCofilteredLimitsOfSize.{v₂, u₂} Cᵒᵖ where HasLimitsOfShape _ _ _ := hasLimitsOfShape_op_of_hasColimitsOfShape #align category_theory.limits.has_cofiltered_limits_op_of_has_filtered_colimits CategoryTheory.Limits.has_cofiltered_limits_op_of_has_filtered_colimits theorem has_cofiltered_limits_of_has_filtered_colimits_op [HasFilteredColimitsOfSize.{v₂, u₂} Cᵒᵖ] : HasCofilteredLimitsOfSize.{v₂, u₂} C := { HasLimitsOfShape := fun _ _ _ => hasLimitsOfShape_of_hasColimitsOfShape_op } #align category_theory.limits.has_cofiltered_limits_of_has_filtered_colimits_op CategoryTheory.Limits.has_cofiltered_limits_of_has_filtered_colimits_op theorem hasColimit_of_hasLimit_leftOp (F : J ⥤ Cᵒᵖ) [HasLimit F.leftOp] : HasColimit F := HasColimit.mk { cocone := coconeOfConeLeftOp (limit.cone F.leftOp) isColimit := isColimitCoconeOfConeLeftOp _ (limit.isLimit _) } #align category_theory.limits.has_colimit_of_has_limit_left_op CategoryTheory.Limits.hasColimit_of_hasLimit_leftOp theorem hasColimit_of_hasLimit_op (F : J ⥤ C) [HasLimit F.op] : HasColimit F := HasColimit.mk { cocone := (limit.cone F.op).unop isColimit := (limit.isLimit _).unop } #align category_theory.limits.has_colimit_of_has_limit_op CategoryTheory.Limits.hasColimit_of_hasLimit_op theorem hasColimit_op_of_hasLimit (F : J ⥤ C) [HasLimit F] : HasColimit F.op := HasColimit.mk { cocone := (limit.cone F).op isColimit := (limit.isLimit _).op } instance hasColimitsOfShape_op_of_hasLimitsOfShape [HasLimitsOfShape Jᵒᵖ C] : HasColimitsOfShape J Cᵒᵖ where has_colimit F := hasColimit_of_hasLimit_leftOp F #align category_theory.limits.has_colimits_of_shape_op_of_has_limits_of_shape CategoryTheory.Limits.hasColimitsOfShape_op_of_hasLimitsOfShape theorem hasColimitsOfShape_of_hasLimitsOfShape_op [HasLimitsOfShape Jᵒᵖ Cᵒᵖ] : HasColimitsOfShape J C := { has_colimit := fun F => hasColimit_of_hasLimit_op F } #align category_theory.limits.has_colimits_of_shape_of_has_limits_of_shape_op CategoryTheory.Limits.hasColimitsOfShape_of_hasLimitsOfShape_op instance hasColimits_op_of_hasLimits [HasLimits C] : HasColimits Cᵒᵖ := ⟨fun _ => inferInstance⟩ #align category_theory.limits.has_colimits_op_of_has_limits CategoryTheory.Limits.hasColimits_op_of_hasLimits theorem hasColimits_of_hasLimits_op [HasLimits Cᵒᵖ] : HasColimits C := { has_colimits_of_shape := fun _ _ => hasColimitsOfShape_of_hasLimitsOfShape_op } #align category_theory.limits.has_colimits_of_has_limits_op CategoryTheory.Limits.hasColimits_of_hasLimits_op instance has_filtered_colimits_op_of_has_cofiltered_limits [HasCofilteredLimitsOfSize.{v₂, u₂} C] : HasFilteredColimitsOfSize.{v₂, u₂} Cᵒᵖ where HasColimitsOfShape _ _ _ := inferInstance #align category_theory.limits.has_filtered_colimits_op_of_has_cofiltered_limits CategoryTheory.Limits.has_filtered_colimits_op_of_has_cofiltered_limits theorem has_filtered_colimits_of_has_cofiltered_limits_op [HasCofilteredLimitsOfSize.{v₂, u₂} Cᵒᵖ] : HasFilteredColimitsOfSize.{v₂, u₂} C := { HasColimitsOfShape := fun _ _ _ => hasColimitsOfShape_of_hasLimitsOfShape_op } #align category_theory.limits.has_filtered_colimits_of_has_cofiltered_limits_op CategoryTheory.Limits.has_filtered_colimits_of_has_cofiltered_limits_op variable (X : Type v₂) instance hasCoproductsOfShape_opposite [HasProductsOfShape X C] : HasCoproductsOfShape X Cᵒᵖ := by haveI : HasLimitsOfShape (Discrete X)ᵒᵖ C := hasLimitsOfShape_of_equivalence (Discrete.opposite X).symm infer_instance #align category_theory.limits.has_coproducts_of_shape_opposite CategoryTheory.Limits.hasCoproductsOfShape_opposite theorem hasCoproductsOfShape_of_opposite [HasProductsOfShape X Cᵒᵖ] : HasCoproductsOfShape X C := haveI : HasLimitsOfShape (Discrete X)ᵒᵖ Cᵒᵖ := hasLimitsOfShape_of_equivalence (Discrete.opposite X).symm hasColimitsOfShape_of_hasLimitsOfShape_op #align category_theory.limits.has_coproducts_of_shape_of_opposite CategoryTheory.Limits.hasCoproductsOfShape_of_opposite instance hasProductsOfShape_opposite [HasCoproductsOfShape X C] : HasProductsOfShape X Cᵒᵖ := by haveI : HasColimitsOfShape (Discrete X)ᵒᵖ C := hasColimitsOfShape_of_equivalence (Discrete.opposite X).symm infer_instance #align category_theory.limits.has_products_of_shape_opposite CategoryTheory.Limits.hasProductsOfShape_opposite theorem hasProductsOfShape_of_opposite [HasCoproductsOfShape X Cᵒᵖ] : HasProductsOfShape X C := haveI : HasColimitsOfShape (Discrete X)ᵒᵖ Cᵒᵖ := hasColimitsOfShape_of_equivalence (Discrete.opposite X).symm hasLimitsOfShape_of_hasColimitsOfShape_op #align category_theory.limits.has_products_of_shape_of_opposite CategoryTheory.Limits.hasProductsOfShape_of_opposite instance hasProducts_opposite [HasCoproducts.{v₂} C] : HasProducts.{v₂} Cᵒᵖ := fun _ => inferInstance #align category_theory.limits.has_products_opposite CategoryTheory.Limits.hasProducts_opposite theorem hasProducts_of_opposite [HasCoproducts.{v₂} Cᵒᵖ] : HasProducts.{v₂} C := fun X => hasProductsOfShape_of_opposite X #align category_theory.limits.has_products_of_opposite CategoryTheory.Limits.hasProducts_of_opposite instance hasCoproducts_opposite [HasProducts.{v₂} C] : HasCoproducts.{v₂} Cᵒᵖ := fun _ => inferInstance #align category_theory.limits.has_coproducts_opposite CategoryTheory.Limits.hasCoproducts_opposite theorem hasCoproducts_of_opposite [HasProducts.{v₂} Cᵒᵖ] : HasCoproducts.{v₂} C := fun X => hasCoproductsOfShape_of_opposite X #align category_theory.limits.has_coproducts_of_opposite CategoryTheory.Limits.hasCoproducts_of_opposite instance hasFiniteCoproducts_opposite [HasFiniteProducts C] : HasFiniteCoproducts Cᵒᵖ where out _ := Limits.hasCoproductsOfShape_opposite _ #align category_theory.limits.has_finite_coproducts_opposite CategoryTheory.Limits.hasFiniteCoproducts_opposite theorem hasFiniteCoproducts_of_opposite [HasFiniteProducts Cᵒᵖ] : HasFiniteCoproducts C := { out := fun _ => hasCoproductsOfShape_of_opposite _ } #align category_theory.limits.has_finite_coproducts_of_opposite CategoryTheory.Limits.hasFiniteCoproducts_of_opposite instance hasFiniteProducts_opposite [HasFiniteCoproducts C] : HasFiniteProducts Cᵒᵖ where out _ := inferInstance #align category_theory.limits.has_finite_products_opposite CategoryTheory.Limits.hasFiniteProducts_opposite theorem hasFiniteProducts_of_opposite [HasFiniteCoproducts Cᵒᵖ] : HasFiniteProducts C := { out := fun _ => hasProductsOfShape_of_opposite _ } #align category_theory.limits.has_finite_products_of_opposite CategoryTheory.Limits.hasFiniteProducts_of_opposite instance hasEqualizers_opposite [HasCoequalizers C] : HasEqualizers Cᵒᵖ := by haveI : HasColimitsOfShape WalkingParallelPairᵒᵖ C := hasColimitsOfShape_of_equivalence walkingParallelPairOpEquiv infer_instance #align category_theory.limits.has_equalizers_opposite CategoryTheory.Limits.hasEqualizers_opposite instance hasCoequalizers_opposite [HasEqualizers C] : HasCoequalizers Cᵒᵖ := by haveI : HasLimitsOfShape WalkingParallelPairᵒᵖ C := hasLimitsOfShape_of_equivalence walkingParallelPairOpEquiv infer_instance #align category_theory.limits.has_coequalizers_opposite CategoryTheory.Limits.hasCoequalizers_opposite instance hasFiniteColimits_opposite [HasFiniteLimits C] : HasFiniteColimits Cᵒᵖ := ⟨fun _ _ _ => inferInstance⟩ #align category_theory.limits.has_finite_colimits_opposite CategoryTheory.Limits.hasFiniteColimits_opposite instance hasFiniteLimits_opposite [HasFiniteColimits C] : HasFiniteLimits Cᵒᵖ := ⟨fun _ _ _ => inferInstance⟩ #align category_theory.limits.has_finite_limits_opposite CategoryTheory.Limits.hasFiniteLimits_opposite instance hasPullbacks_opposite [HasPushouts C] : HasPullbacks Cᵒᵖ := by haveI : HasColimitsOfShape WalkingCospanᵒᵖ C := hasColimitsOfShape_of_equivalence walkingCospanOpEquiv.symm apply hasLimitsOfShape_op_of_hasColimitsOfShape #align category_theory.limits.has_pullbacks_opposite CategoryTheory.Limits.hasPullbacks_opposite instance hasPushouts_opposite [HasPullbacks C] : HasPushouts Cᵒᵖ := by haveI : HasLimitsOfShape WalkingSpanᵒᵖ C := hasLimitsOfShape_of_equivalence walkingSpanOpEquiv.symm infer_instance #align category_theory.limits.has_pushouts_opposite CategoryTheory.Limits.hasPushouts_opposite @[simps!] def spanOp {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : span f.op g.op ≅ walkingCospanOpEquiv.inverse ⋙ (cospan f g).op := NatIso.ofComponents (by rintro (_ | _ | _) <;> rfl) (by rintro (_ | _ | _) (_ | _ | _) f <;> cases f <;> aesop_cat) #align category_theory.limits.span_op CategoryTheory.Limits.spanOp @[simps!] def opCospan {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : (cospan f g).op ≅ walkingCospanOpEquiv.functor ⋙ span f.op g.op := calc (cospan f g).op ≅ 𝟭 _ ⋙ (cospan f g).op := by rfl _ ≅ (walkingCospanOpEquiv.functor ⋙ walkingCospanOpEquiv.inverse) ⋙ (cospan f g).op := (isoWhiskerRight walkingCospanOpEquiv.unitIso _) _ ≅ walkingCospanOpEquiv.functor ⋙ walkingCospanOpEquiv.inverse ⋙ (cospan f g).op := (Functor.associator _ _ _) _ ≅ walkingCospanOpEquiv.functor ⋙ span f.op g.op := isoWhiskerLeft _ (spanOp f g).symm #align category_theory.limits.op_cospan CategoryTheory.Limits.opCospan @[simps!] def cospanOp {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : cospan f.op g.op ≅ walkingSpanOpEquiv.inverse ⋙ (span f g).op := NatIso.ofComponents (by rintro (_ | _ | _) <;> rfl) (by rintro (_ | _ | _) (_ | _ | _) f <;> cases f <;> aesop_cat) #align category_theory.limits.cospan_op CategoryTheory.Limits.cospanOp @[simps!] def opSpan {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : (span f g).op ≅ walkingSpanOpEquiv.functor ⋙ cospan f.op g.op := calc (span f g).op ≅ 𝟭 _ ⋙ (span f g).op := by rfl _ ≅ (walkingSpanOpEquiv.functor ⋙ walkingSpanOpEquiv.inverse) ⋙ (span f g).op := (isoWhiskerRight walkingSpanOpEquiv.unitIso _) _ ≅ walkingSpanOpEquiv.functor ⋙ walkingSpanOpEquiv.inverse ⋙ (span f g).op := (Functor.associator _ _ _) _ ≅ walkingSpanOpEquiv.functor ⋙ cospan f.op g.op := isoWhiskerLeft _ (cospanOp f g).symm #align category_theory.limits.op_span CategoryTheory.Limits.opSpan namespace PushoutCocone -- Porting note: it was originally @[simps (config := lemmasOnly)] @[simps!] def unop {X Y Z : Cᵒᵖ} {f : X ⟶ Y} {g : X ⟶ Z} (c : PushoutCocone f g) : PullbackCone f.unop g.unop := Cocone.unop ((Cocones.precompose (opCospan f.unop g.unop).hom).obj (Cocone.whisker walkingCospanOpEquiv.functor c)) #align category_theory.limits.pushout_cocone.unop CategoryTheory.Limits.PushoutCocone.unop -- Porting note (#10618): removed simp attribute as the equality can already be obtained by simp theorem unop_fst {X Y Z : Cᵒᵖ} {f : X ⟶ Y} {g : X ⟶ Z} (c : PushoutCocone f g) : c.unop.fst = c.inl.unop := by simp #align category_theory.limits.pushout_cocone.unop_fst CategoryTheory.Limits.PushoutCocone.unop_fst -- Porting note (#10618): removed simp attribute as the equality can already be obtained by simp theorem unop_snd {X Y Z : Cᵒᵖ} {f : X ⟶ Y} {g : X ⟶ Z} (c : PushoutCocone f g) : c.unop.snd = c.inr.unop := by aesop_cat #align category_theory.limits.pushout_cocone.unop_snd CategoryTheory.Limits.PushoutCocone.unop_snd -- Porting note: it was originally @[simps (config := lemmasOnly)] @[simps!] def op {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} (c : PushoutCocone f g) : PullbackCone f.op g.op := (Cones.postcompose (cospanOp f g).symm.hom).obj (Cone.whisker walkingSpanOpEquiv.inverse (Cocone.op c)) #align category_theory.limits.pushout_cocone.op CategoryTheory.Limits.PushoutCocone.op -- Porting note (#10618): removed simp attribute as the equality can already be obtained by simp theorem op_fst {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} (c : PushoutCocone f g) : c.op.fst = c.inl.op := by aesop_cat #align category_theory.limits.pushout_cocone.op_fst CategoryTheory.Limits.PushoutCocone.op_fst -- Porting note (#10618): removed simp attribute as the equality can already be obtained by simp
Mathlib/CategoryTheory/Limits/Opposites.lean
647
648
theorem op_snd {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} (c : PushoutCocone f g) : c.op.snd = c.inr.op := by
aesop_cat
import Mathlib.Analysis.NormedSpace.Multilinear.Basic import Mathlib.Analysis.NormedSpace.Units import Mathlib.Analysis.NormedSpace.OperatorNorm.Completeness import Mathlib.Analysis.NormedSpace.OperatorNorm.Mul #align_import analysis.normed_space.bounded_linear_maps from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a" noncomputable section open Topology open Filter (Tendsto) open Metric ContinuousLinearMap variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] structure IsBoundedLinearMap (𝕜 : Type*) [NormedField 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] (f : E → F) extends IsLinearMap 𝕜 f : Prop where bound : ∃ M, 0 < M ∧ ∀ x : E, ‖f x‖ ≤ M * ‖x‖ #align is_bounded_linear_map IsBoundedLinearMap theorem IsLinearMap.with_bound {f : E → F} (hf : IsLinearMap 𝕜 f) (M : ℝ) (h : ∀ x : E, ‖f x‖ ≤ M * ‖x‖) : IsBoundedLinearMap 𝕜 f := ⟨hf, by_cases (fun (this : M ≤ 0) => ⟨1, zero_lt_one, fun x => (h x).trans <| mul_le_mul_of_nonneg_right (this.trans zero_le_one) (norm_nonneg x)⟩) fun (this : ¬M ≤ 0) => ⟨M, lt_of_not_ge this, h⟩⟩ #align is_linear_map.with_bound IsLinearMap.with_bound theorem ContinuousLinearMap.isBoundedLinearMap (f : E →L[𝕜] F) : IsBoundedLinearMap 𝕜 f := { f.toLinearMap.isLinear with bound := f.bound } #align continuous_linear_map.is_bounded_linear_map ContinuousLinearMap.isBoundedLinearMap namespace IsBoundedLinearMap def toLinearMap (f : E → F) (h : IsBoundedLinearMap 𝕜 f) : E →ₗ[𝕜] F := IsLinearMap.mk' _ h.toIsLinearMap #align is_bounded_linear_map.to_linear_map IsBoundedLinearMap.toLinearMap def toContinuousLinearMap {f : E → F} (hf : IsBoundedLinearMap 𝕜 f) : E →L[𝕜] F := { toLinearMap f hf with cont := let ⟨C, _, hC⟩ := hf.bound AddMonoidHomClass.continuous_of_bound (toLinearMap f hf) C hC } #align is_bounded_linear_map.to_continuous_linear_map IsBoundedLinearMap.toContinuousLinearMap theorem zero : IsBoundedLinearMap 𝕜 fun _ : E => (0 : F) := (0 : E →ₗ[𝕜] F).isLinear.with_bound 0 <| by simp [le_refl] #align is_bounded_linear_map.zero IsBoundedLinearMap.zero theorem id : IsBoundedLinearMap 𝕜 fun x : E => x := LinearMap.id.isLinear.with_bound 1 <| by simp [le_refl] #align is_bounded_linear_map.id IsBoundedLinearMap.id theorem fst : IsBoundedLinearMap 𝕜 fun x : E × F => x.1 := by refine (LinearMap.fst 𝕜 E F).isLinear.with_bound 1 fun x => ?_ rw [one_mul] exact le_max_left _ _ #align is_bounded_linear_map.fst IsBoundedLinearMap.fst theorem snd : IsBoundedLinearMap 𝕜 fun x : E × F => x.2 := by refine (LinearMap.snd 𝕜 E F).isLinear.with_bound 1 fun x => ?_ rw [one_mul] exact le_max_right _ _ #align is_bounded_linear_map.snd IsBoundedLinearMap.snd variable {f g : E → F} theorem smul (c : 𝕜) (hf : IsBoundedLinearMap 𝕜 f) : IsBoundedLinearMap 𝕜 (c • f) := let ⟨hlf, M, _, hM⟩ := hf (c • hlf.mk' f).isLinear.with_bound (‖c‖ * M) fun x => calc ‖c • f x‖ = ‖c‖ * ‖f x‖ := norm_smul c (f x) _ ≤ ‖c‖ * (M * ‖x‖) := mul_le_mul_of_nonneg_left (hM _) (norm_nonneg _) _ = ‖c‖ * M * ‖x‖ := (mul_assoc _ _ _).symm #align is_bounded_linear_map.smul IsBoundedLinearMap.smul theorem neg (hf : IsBoundedLinearMap 𝕜 f) : IsBoundedLinearMap 𝕜 fun e => -f e := by rw [show (fun e => -f e) = fun e => (-1 : 𝕜) • f e by funext; simp] exact smul (-1) hf #align is_bounded_linear_map.neg IsBoundedLinearMap.neg theorem add (hf : IsBoundedLinearMap 𝕜 f) (hg : IsBoundedLinearMap 𝕜 g) : IsBoundedLinearMap 𝕜 fun e => f e + g e := let ⟨hlf, Mf, _, hMf⟩ := hf let ⟨hlg, Mg, _, hMg⟩ := hg (hlf.mk' _ + hlg.mk' _).isLinear.with_bound (Mf + Mg) fun x => calc ‖f x + g x‖ ≤ Mf * ‖x‖ + Mg * ‖x‖ := norm_add_le_of_le (hMf x) (hMg x) _ ≤ (Mf + Mg) * ‖x‖ := by rw [add_mul] #align is_bounded_linear_map.add IsBoundedLinearMap.add
Mathlib/Analysis/NormedSpace/BoundedLinearMaps.lean
155
156
theorem sub (hf : IsBoundedLinearMap 𝕜 f) (hg : IsBoundedLinearMap 𝕜 g) : IsBoundedLinearMap 𝕜 fun e => f e - g e := by
simpa [sub_eq_add_neg] using add hf (neg hg)
import Mathlib.RingTheory.IntegralClosure import Mathlib.RingTheory.FractionalIdeal.Basic #align_import ring_theory.fractional_ideal from "leanprover-community/mathlib"@"ed90a7d327c3a5caf65a6faf7e8a0d63c4605df7" open IsLocalization Pointwise nonZeroDivisors namespace FractionalIdeal open Set Submodule variable {R : Type*} [CommRing R] {S : Submonoid R} {P : Type*} [CommRing P] variable [Algebra R P] [loc : IsLocalization S P] section variable {P' : Type*} [CommRing P'] [Algebra R P'] [loc' : IsLocalization S P'] variable {P'' : Type*} [CommRing P''] [Algebra R P''] [loc'' : IsLocalization S P''] theorem _root_.IsFractional.map (g : P →ₐ[R] P') {I : Submodule R P} : IsFractional S I → IsFractional S (Submodule.map g.toLinearMap I) | ⟨a, a_nonzero, hI⟩ => ⟨a, a_nonzero, fun b hb => by obtain ⟨b', b'_mem, hb'⟩ := Submodule.mem_map.mp hb rw [AlgHom.toLinearMap_apply] at hb' obtain ⟨x, hx⟩ := hI b' b'_mem use x rw [← g.commutes, hx, g.map_smul, hb']⟩ #align is_fractional.map IsFractional.map def map (g : P →ₐ[R] P') : FractionalIdeal S P → FractionalIdeal S P' := fun I => ⟨Submodule.map g.toLinearMap I, I.isFractional.map g⟩ #align fractional_ideal.map FractionalIdeal.map @[simp, norm_cast] theorem coe_map (g : P →ₐ[R] P') (I : FractionalIdeal S P) : ↑(map g I) = Submodule.map g.toLinearMap I := rfl #align fractional_ideal.coe_map FractionalIdeal.coe_map @[simp] theorem mem_map {I : FractionalIdeal S P} {g : P →ₐ[R] P'} {y : P'} : y ∈ I.map g ↔ ∃ x, x ∈ I ∧ g x = y := Submodule.mem_map #align fractional_ideal.mem_map FractionalIdeal.mem_map variable (I J : FractionalIdeal S P) (g : P →ₐ[R] P') @[simp] theorem map_id : I.map (AlgHom.id _ _) = I := coeToSubmodule_injective (Submodule.map_id (I : Submodule R P)) #align fractional_ideal.map_id FractionalIdeal.map_id @[simp] theorem map_comp (g' : P' →ₐ[R] P'') : I.map (g'.comp g) = (I.map g).map g' := coeToSubmodule_injective (Submodule.map_comp g.toLinearMap g'.toLinearMap I) #align fractional_ideal.map_comp FractionalIdeal.map_comp @[simp, norm_cast] theorem map_coeIdeal (I : Ideal R) : (I : FractionalIdeal S P).map g = I := by ext x simp only [mem_coeIdeal] constructor · rintro ⟨_, ⟨y, hy, rfl⟩, rfl⟩ exact ⟨y, hy, (g.commutes y).symm⟩ · rintro ⟨y, hy, rfl⟩ exact ⟨_, ⟨y, hy, rfl⟩, g.commutes y⟩ #align fractional_ideal.map_coe_ideal FractionalIdeal.map_coeIdeal @[simp] theorem map_one : (1 : FractionalIdeal S P).map g = 1 := map_coeIdeal g ⊤ #align fractional_ideal.map_one FractionalIdeal.map_one @[simp] theorem map_zero : (0 : FractionalIdeal S P).map g = 0 := map_coeIdeal g 0 #align fractional_ideal.map_zero FractionalIdeal.map_zero @[simp] theorem map_add : (I + J).map g = I.map g + J.map g := coeToSubmodule_injective (Submodule.map_sup _ _ _) #align fractional_ideal.map_add FractionalIdeal.map_add @[simp] theorem map_mul : (I * J).map g = I.map g * J.map g := by simp only [mul_def] exact coeToSubmodule_injective (Submodule.map_mul _ _ _) #align fractional_ideal.map_mul FractionalIdeal.map_mul @[simp] theorem map_map_symm (g : P ≃ₐ[R] P') : (I.map (g : P →ₐ[R] P')).map (g.symm : P' →ₐ[R] P) = I := by rw [← map_comp, g.symm_comp, map_id] #align fractional_ideal.map_map_symm FractionalIdeal.map_map_symm @[simp] theorem map_symm_map (I : FractionalIdeal S P') (g : P ≃ₐ[R] P') : (I.map (g.symm : P' →ₐ[R] P)).map (g : P →ₐ[R] P') = I := by rw [← map_comp, g.comp_symm, map_id] #align fractional_ideal.map_symm_map FractionalIdeal.map_symm_map theorem map_mem_map {f : P →ₐ[R] P'} (h : Function.Injective f) {x : P} {I : FractionalIdeal S P} : f x ∈ map f I ↔ x ∈ I := mem_map.trans ⟨fun ⟨_, hx', x'_eq⟩ => h x'_eq ▸ hx', fun h => ⟨x, h, rfl⟩⟩ #align fractional_ideal.map_mem_map FractionalIdeal.map_mem_map theorem map_injective (f : P →ₐ[R] P') (h : Function.Injective f) : Function.Injective (map f : FractionalIdeal S P → FractionalIdeal S P') := fun _ _ hIJ => ext fun _ => (map_mem_map h).symm.trans (hIJ.symm ▸ map_mem_map h) #align fractional_ideal.map_injective FractionalIdeal.map_injective def mapEquiv (g : P ≃ₐ[R] P') : FractionalIdeal S P ≃+* FractionalIdeal S P' where toFun := map g invFun := map g.symm map_add' I J := map_add I J _ map_mul' I J := map_mul I J _ left_inv I := by rw [← map_comp, AlgEquiv.symm_comp, map_id] right_inv I := by rw [← map_comp, AlgEquiv.comp_symm, map_id] #align fractional_ideal.map_equiv FractionalIdeal.mapEquiv @[simp] theorem coeFun_mapEquiv (g : P ≃ₐ[R] P') : (mapEquiv g : FractionalIdeal S P → FractionalIdeal S P') = map g := rfl #align fractional_ideal.coe_fun_map_equiv FractionalIdeal.coeFun_mapEquiv @[simp] theorem mapEquiv_apply (g : P ≃ₐ[R] P') (I : FractionalIdeal S P) : mapEquiv g I = map (↑g) I := rfl #align fractional_ideal.map_equiv_apply FractionalIdeal.mapEquiv_apply @[simp] theorem mapEquiv_symm (g : P ≃ₐ[R] P') : ((mapEquiv g).symm : FractionalIdeal S P' ≃+* _) = mapEquiv g.symm := rfl #align fractional_ideal.map_equiv_symm FractionalIdeal.mapEquiv_symm @[simp] theorem mapEquiv_refl : mapEquiv AlgEquiv.refl = RingEquiv.refl (FractionalIdeal S P) := RingEquiv.ext fun x => by simp #align fractional_ideal.map_equiv_refl FractionalIdeal.mapEquiv_refl theorem isFractional_span_iff {s : Set P} : IsFractional S (span R s) ↔ ∃ a ∈ S, ∀ b : P, b ∈ s → IsInteger R (a • b) := ⟨fun ⟨a, a_mem, h⟩ => ⟨a, a_mem, fun b hb => h b (subset_span hb)⟩, fun ⟨a, a_mem, h⟩ => ⟨a, a_mem, fun b hb => span_induction hb h (by rw [smul_zero] exact isInteger_zero) (fun x y hx hy => by rw [smul_add] exact isInteger_add hx hy) fun s x hx => by rw [smul_comm] exact isInteger_smul hx⟩⟩ #align fractional_ideal.is_fractional_span_iff FractionalIdeal.isFractional_span_iff theorem isFractional_of_fg {I : Submodule R P} (hI : I.FG) : IsFractional S I := by rcases hI with ⟨I, rfl⟩ rcases exist_integer_multiples_of_finset S I with ⟨⟨s, hs1⟩, hs⟩ rw [isFractional_span_iff] exact ⟨s, hs1, hs⟩ #align fractional_ideal.is_fractional_of_fg FractionalIdeal.isFractional_of_fg theorem mem_span_mul_finite_of_mem_mul {I J : FractionalIdeal S P} {x : P} (hx : x ∈ I * J) : ∃ T T' : Finset P, (T : Set P) ⊆ I ∧ (T' : Set P) ⊆ J ∧ x ∈ span R (T * T' : Set P) := Submodule.mem_span_mul_finite_of_mem_mul (by simpa using mem_coe.mpr hx) #align fractional_ideal.mem_span_mul_finite_of_mem_mul FractionalIdeal.mem_span_mul_finite_of_mem_mul variable (S) theorem coeIdeal_fg (inj : Function.Injective (algebraMap R P)) (I : Ideal R) : FG ((I : FractionalIdeal S P) : Submodule R P) ↔ I.FG := coeSubmodule_fg _ inj _ #align fractional_ideal.coe_ideal_fg FractionalIdeal.coeIdeal_fg variable {S} theorem fg_unit (I : (FractionalIdeal S P)ˣ) : FG (I : Submodule R P) := Submodule.fg_unit <| Units.map (coeSubmoduleHom S P).toMonoidHom I #align fractional_ideal.fg_unit FractionalIdeal.fg_unit theorem fg_of_isUnit (I : FractionalIdeal S P) (h : IsUnit I) : FG (I : Submodule R P) := fg_unit h.unit #align fractional_ideal.fg_of_is_unit FractionalIdeal.fg_of_isUnit theorem _root_.Ideal.fg_of_isUnit (inj : Function.Injective (algebraMap R P)) (I : Ideal R) (h : IsUnit (I : FractionalIdeal S P)) : I.FG := by rw [← coeIdeal_fg S inj I] exact FractionalIdeal.fg_of_isUnit I h #align ideal.fg_of_is_unit Ideal.fg_of_isUnit variable (S P P') noncomputable irreducible_def canonicalEquiv : FractionalIdeal S P ≃+* FractionalIdeal S P' := mapEquiv { ringEquivOfRingEquiv P P' (RingEquiv.refl R) (show S.map _ = S by rw [RingEquiv.toMonoidHom_refl, Submonoid.map_id]) with commutes' := fun r => ringEquivOfRingEquiv_eq _ _ } #align fractional_ideal.canonical_equiv FractionalIdeal.canonicalEquiv @[simp] theorem mem_canonicalEquiv_apply {I : FractionalIdeal S P} {x : P'} : x ∈ canonicalEquiv S P P' I ↔ ∃ y ∈ I, IsLocalization.map P' (RingHom.id R) (fun y (hy : y ∈ S) => show RingHom.id R y ∈ S from hy) (y : P) = x := by rw [canonicalEquiv, mapEquiv_apply, mem_map] exact ⟨fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩, fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩⟩ #align fractional_ideal.mem_canonical_equiv_apply FractionalIdeal.mem_canonicalEquiv_apply @[simp] theorem canonicalEquiv_symm : (canonicalEquiv S P P').symm = canonicalEquiv S P' P := RingEquiv.ext fun I => SetLike.ext_iff.mpr fun x => by rw [mem_canonicalEquiv_apply, canonicalEquiv, mapEquiv_symm, mapEquiv_apply, mem_map] exact ⟨fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩, fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩⟩ #align fractional_ideal.canonical_equiv_symm FractionalIdeal.canonicalEquiv_symm theorem canonicalEquiv_flip (I) : canonicalEquiv S P P' (canonicalEquiv S P' P I) = I := by rw [← canonicalEquiv_symm]; erw [RingEquiv.apply_symm_apply] #align fractional_ideal.canonical_equiv_flip FractionalIdeal.canonicalEquiv_flip @[simp] theorem canonicalEquiv_canonicalEquiv (P'' : Type*) [CommRing P''] [Algebra R P''] [IsLocalization S P''] (I : FractionalIdeal S P) : canonicalEquiv S P' P'' (canonicalEquiv S P P' I) = canonicalEquiv S P P'' I := by ext simp only [IsLocalization.map_map, RingHomInvPair.comp_eq₂, mem_canonicalEquiv_apply, exists_prop, exists_exists_and_eq_and] #align fractional_ideal.canonical_equiv_canonical_equiv FractionalIdeal.canonicalEquiv_canonicalEquiv theorem canonicalEquiv_trans_canonicalEquiv (P'' : Type*) [CommRing P''] [Algebra R P''] [IsLocalization S P''] : (canonicalEquiv S P P').trans (canonicalEquiv S P' P'') = canonicalEquiv S P P'' := RingEquiv.ext (canonicalEquiv_canonicalEquiv S P P' P'') #align fractional_ideal.canonical_equiv_trans_canonical_equiv FractionalIdeal.canonicalEquiv_trans_canonicalEquiv @[simp] theorem canonicalEquiv_coeIdeal (I : Ideal R) : canonicalEquiv S P P' I = I := by ext simp [IsLocalization.map_eq] #align fractional_ideal.canonical_equiv_coe_ideal FractionalIdeal.canonicalEquiv_coeIdeal @[simp] theorem canonicalEquiv_self : canonicalEquiv S P P = RingEquiv.refl _ := by rw [← canonicalEquiv_trans_canonicalEquiv S P P] convert (canonicalEquiv S P P).symm_trans_self exact (canonicalEquiv_symm S P P).symm #align fractional_ideal.canonical_equiv_self FractionalIdeal.canonicalEquiv_self end section PrincipalIdeal variable {R₁ : Type*} [CommRing R₁] {K : Type*} [Field K] variable [Algebra R₁ K] [IsFractionRing R₁ K] open scoped Classical variable (R₁) -- Porting note: `@[simps]` generated a `Subtype.val` coercion instead of a -- `FractionalIdeal.coeToSubmodule` coercion def spanFinset {ι : Type*} (s : Finset ι) (f : ι → K) : FractionalIdeal R₁⁰ K := ⟨Submodule.span R₁ (f '' s), by obtain ⟨a', ha'⟩ := IsLocalization.exist_integer_multiples R₁⁰ s f refine ⟨a', a'.2, fun x hx => Submodule.span_induction hx ?_ ?_ ?_ ?_⟩ · rintro _ ⟨i, hi, rfl⟩ exact ha' i hi · rw [smul_zero] exact IsLocalization.isInteger_zero · intro x y hx hy rw [smul_add] exact IsLocalization.isInteger_add hx hy · intro c x hx rw [smul_comm] exact IsLocalization.isInteger_smul hx⟩ #align fractional_ideal.span_finset FractionalIdeal.spanFinset @[simp] lemma spanFinset_coe {ι : Type*} (s : Finset ι) (f : ι → K) : (spanFinset R₁ s f : Submodule R₁ K) = Submodule.span R₁ (f '' s) := rfl variable {R₁} @[simp] theorem spanFinset_eq_zero {ι : Type*} {s : Finset ι} {f : ι → K} : spanFinset R₁ s f = 0 ↔ ∀ j ∈ s, f j = 0 := by simp only [← coeToSubmodule_inj, spanFinset_coe, coe_zero, Submodule.span_eq_bot, Set.mem_image, Finset.mem_coe, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] #align fractional_ideal.span_finset_eq_zero FractionalIdeal.spanFinset_eq_zero theorem spanFinset_ne_zero {ι : Type*} {s : Finset ι} {f : ι → K} : spanFinset R₁ s f ≠ 0 ↔ ∃ j ∈ s, f j ≠ 0 := by simp #align fractional_ideal.span_finset_ne_zero FractionalIdeal.spanFinset_ne_zero open Submodule.IsPrincipal theorem isFractional_span_singleton (x : P) : IsFractional S (span R {x} : Submodule R P) := let ⟨a, ha⟩ := exists_integer_multiple S x isFractional_span_iff.mpr ⟨a, a.2, fun _ hx' => (Set.mem_singleton_iff.mp hx').symm ▸ ha⟩ #align fractional_ideal.is_fractional_span_singleton FractionalIdeal.isFractional_span_singleton variable (S) irreducible_def spanSingleton (x : P) : FractionalIdeal S P := ⟨span R {x}, isFractional_span_singleton x⟩ #align fractional_ideal.span_singleton FractionalIdeal.spanSingleton -- local attribute [semireducible] span_singleton @[simp] theorem coe_spanSingleton (x : P) : (spanSingleton S x : Submodule R P) = span R {x} := by rw [spanSingleton] rfl #align fractional_ideal.coe_span_singleton FractionalIdeal.coe_spanSingleton @[simp] theorem mem_spanSingleton {x y : P} : x ∈ spanSingleton S y ↔ ∃ z : R, z • y = x := by rw [spanSingleton] exact Submodule.mem_span_singleton #align fractional_ideal.mem_span_singleton FractionalIdeal.mem_spanSingleton theorem mem_spanSingleton_self (x : P) : x ∈ spanSingleton S x := (mem_spanSingleton S).mpr ⟨1, one_smul _ _⟩ #align fractional_ideal.mem_span_singleton_self FractionalIdeal.mem_spanSingleton_self variable (P) in theorem den_mul_self_eq_num' (I : FractionalIdeal S P) : spanSingleton S (algebraMap R P I.den) * I = I.num := by apply coeToSubmodule_injective dsimp only rw [coe_mul, ← smul_eq_mul, coe_spanSingleton, smul_eq_mul, Submodule.span_singleton_mul] convert I.den_mul_self_eq_num using 1 ext erw [Set.mem_smul_set, Set.mem_smul_set] simp [Algebra.smul_def] variable {S} @[simp] theorem spanSingleton_le_iff_mem {x : P} {I : FractionalIdeal S P} : spanSingleton S x ≤ I ↔ x ∈ I := by rw [← coe_le_coe, coe_spanSingleton, Submodule.span_singleton_le_iff_mem, mem_coe] #align fractional_ideal.span_singleton_le_iff_mem FractionalIdeal.spanSingleton_le_iff_mem theorem spanSingleton_eq_spanSingleton [NoZeroSMulDivisors R P] {x y : P} : spanSingleton S x = spanSingleton S y ↔ ∃ z : Rˣ, z • x = y := by rw [← Submodule.span_singleton_eq_span_singleton, spanSingleton, spanSingleton] exact Subtype.mk_eq_mk #align fractional_ideal.span_singleton_eq_span_singleton FractionalIdeal.spanSingleton_eq_spanSingleton theorem eq_spanSingleton_of_principal (I : FractionalIdeal S P) [IsPrincipal (I : Submodule R P)] : I = spanSingleton S (generator (I : Submodule R P)) := by -- Porting note: this used to be `coeToSubmodule_injective (span_singleton_generator ↑I).symm` -- but Lean 4 struggled to unify everything. Turned it into an explicit `rw`. rw [spanSingleton, ← coeToSubmodule_inj, coe_mk, span_singleton_generator] #align fractional_ideal.eq_span_singleton_of_principal FractionalIdeal.eq_spanSingleton_of_principal theorem isPrincipal_iff (I : FractionalIdeal S P) : IsPrincipal (I : Submodule R P) ↔ ∃ x, I = spanSingleton S x := ⟨fun h => ⟨@generator _ _ _ _ _ (↑I) h, @eq_spanSingleton_of_principal _ _ _ _ _ _ _ I h⟩, fun ⟨x, hx⟩ => { principal' := ⟨x, Eq.trans (congr_arg _ hx) (coe_spanSingleton _ x)⟩ }⟩ #align fractional_ideal.is_principal_iff FractionalIdeal.isPrincipal_iff @[simp] theorem spanSingleton_zero : spanSingleton S (0 : P) = 0 := by ext simp [Submodule.mem_span_singleton, eq_comm] #align fractional_ideal.span_singleton_zero FractionalIdeal.spanSingleton_zero theorem spanSingleton_eq_zero_iff {y : P} : spanSingleton S y = 0 ↔ y = 0 := ⟨fun h => span_eq_bot.mp (by simpa using congr_arg Subtype.val h : span R {y} = ⊥) y (mem_singleton y), fun h => by simp [h]⟩ #align fractional_ideal.span_singleton_eq_zero_iff FractionalIdeal.spanSingleton_eq_zero_iff theorem spanSingleton_ne_zero_iff {y : P} : spanSingleton S y ≠ 0 ↔ y ≠ 0 := not_congr spanSingleton_eq_zero_iff #align fractional_ideal.span_singleton_ne_zero_iff FractionalIdeal.spanSingleton_ne_zero_iff @[simp] theorem spanSingleton_one : spanSingleton S (1 : P) = 1 := by ext refine (mem_spanSingleton S).trans ((exists_congr ?_).trans (mem_one_iff S).symm) intro x' rw [Algebra.smul_def, mul_one] #align fractional_ideal.span_singleton_one FractionalIdeal.spanSingleton_one @[simp] theorem spanSingleton_mul_spanSingleton (x y : P) : spanSingleton S x * spanSingleton S y = spanSingleton S (x * y) := by apply coeToSubmodule_injective simp only [coe_mul, coe_spanSingleton, span_mul_span, singleton_mul_singleton] #align fractional_ideal.span_singleton_mul_span_singleton FractionalIdeal.spanSingleton_mul_spanSingleton @[simp]
Mathlib/RingTheory/FractionalIdeal/Operations.lean
715
718
theorem spanSingleton_pow (x : P) (n : ℕ) : spanSingleton S x ^ n = spanSingleton S (x ^ n) := by
induction' n with n hn · rw [pow_zero, pow_zero, spanSingleton_one] · rw [pow_succ, hn, spanSingleton_mul_spanSingleton, pow_succ]
import Mathlib.Algebra.Ring.Parity import Mathlib.Combinatorics.SimpleGraph.Connectivity #align_import combinatorics.simple_graph.trails from "leanprover-community/mathlib"@"edaaaa4a5774e6623e0ddd919b2f2db49c65add4" namespace SimpleGraph variable {V : Type*} {G : SimpleGraph V} namespace Walk abbrev IsTrail.edgesFinset {u v : V} {p : G.Walk u v} (h : p.IsTrail) : Finset (Sym2 V) := ⟨p.edges, h.edges_nodup⟩ #align simple_graph.walk.is_trail.edges_finset SimpleGraph.Walk.IsTrail.edgesFinset variable [DecidableEq V] theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) : Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by induction' p with u u v w huv p ih · simp · rw [cons_isTrail_iff] at ht specialize ih ht.1 simp only [List.countP_cons, Ne, edges_cons, Sym2.mem_iff] split_ifs with h · rw [decide_eq_true_eq] at h obtain (rfl | rfl) := h · rw [Nat.even_add_one, ih] simp only [huv.ne, imp_false, Ne, not_false_iff, true_and_iff, not_forall, Classical.not_not, exists_prop, eq_self_iff_true, not_true, false_and_iff, and_iff_right_iff_imp] rintro rfl rfl exact G.loopless _ huv · rw [Nat.even_add_one, ih, ← not_iff_not] simp only [huv.ne.symm, Ne, eq_self_iff_true, not_true, false_and_iff, not_forall, not_false_iff, exists_prop, and_true_iff, Classical.not_not, true_and_iff, iff_and_self] rintro rfl exact huv.ne · rw [decide_eq_true_eq, not_or] at h simp only [h.1, h.2, not_false_iff, true_and_iff, add_zero, Ne] at ih ⊢ rw [ih] constructor <;> · rintro h' h'' rfl simp only [imp_false, eq_self_iff_true, not_true, Classical.not_not] at h' cases h' simp only [not_true, and_false, false_and] at h #align simple_graph.walk.is_trail.even_countp_edges_iff SimpleGraph.Walk.IsTrail.even_countP_edges_iff def IsEulerian {u v : V} (p : G.Walk u v) : Prop := ∀ e, e ∈ G.edgeSet → p.edges.count e = 1 #align simple_graph.walk.is_eulerian SimpleGraph.Walk.IsEulerian theorem IsEulerian.isTrail {u v : V} {p : G.Walk u v} (h : p.IsEulerian) : p.IsTrail := by rw [isTrail_def, List.nodup_iff_count_le_one] intro e by_cases he : e ∈ p.edges · exact (h e (edges_subset_edgeSet _ he)).le · simp [he] #align simple_graph.walk.is_eulerian.is_trail SimpleGraph.Walk.IsEulerian.isTrail theorem IsEulerian.mem_edges_iff {u v : V} {p : G.Walk u v} (h : p.IsEulerian) {e : Sym2 V} : e ∈ p.edges ↔ e ∈ G.edgeSet := ⟨ fun h => p.edges_subset_edgeSet h , fun he => by simpa [Nat.succ_le] using (h e he).ge ⟩ #align simple_graph.walk.is_eulerian.mem_edges_iff SimpleGraph.Walk.IsEulerian.mem_edges_iff def IsEulerian.fintypeEdgeSet {u v : V} {p : G.Walk u v} (h : p.IsEulerian) : Fintype G.edgeSet := Fintype.ofFinset h.isTrail.edgesFinset fun e => by simp only [Finset.mem_mk, Multiset.mem_coe, h.mem_edges_iff] #align simple_graph.walk.is_eulerian.fintype_edge_set SimpleGraph.Walk.IsEulerian.fintypeEdgeSet theorem IsTrail.isEulerian_of_forall_mem {u v : V} {p : G.Walk u v} (h : p.IsTrail) (hc : ∀ e, e ∈ G.edgeSet → e ∈ p.edges) : p.IsEulerian := fun e he => List.count_eq_one_of_mem h.edges_nodup (hc e he) #align simple_graph.walk.is_trail.is_eulerian_of_forall_mem SimpleGraph.Walk.IsTrail.isEulerian_of_forall_mem theorem isEulerian_iff {u v : V} (p : G.Walk u v) : p.IsEulerian ↔ p.IsTrail ∧ ∀ e, e ∈ G.edgeSet → e ∈ p.edges := by constructor · intro h exact ⟨h.isTrail, fun _ => h.mem_edges_iff.mpr⟩ · rintro ⟨h, hl⟩ exact h.isEulerian_of_forall_mem hl #align simple_graph.walk.is_eulerian_iff SimpleGraph.Walk.isEulerian_iff theorem IsEulerian.edgesFinset_eq [Fintype G.edgeSet] {u v : V} {p : G.Walk u v} (h : p.IsEulerian) : h.isTrail.edgesFinset = G.edgeFinset := by ext e simp [h.mem_edges_iff] #align simple_graph.walk.is_eulerian.edges_finset_eq SimpleGraph.Walk.IsEulerian.edgesFinset_eq theorem IsEulerian.even_degree_iff {x u v : V} {p : G.Walk u v} (ht : p.IsEulerian) [Fintype V] [DecidableRel G.Adj] : Even (G.degree x) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by convert ht.isTrail.even_countP_edges_iff x rw [← Multiset.coe_countP, Multiset.countP_eq_card_filter, ← card_incidenceFinset_eq_degree] change Multiset.card _ = _ congr 1 convert_to _ = (ht.isTrail.edgesFinset.filter (Membership.mem x)).val have : Fintype G.edgeSet := fintypeEdgeSet ht rw [ht.edgesFinset_eq, G.incidenceFinset_eq_filter x] #align simple_graph.walk.is_eulerian.even_degree_iff SimpleGraph.Walk.IsEulerian.even_degree_iff theorem IsEulerian.card_filter_odd_degree [Fintype V] [DecidableRel G.Adj] {u v : V} {p : G.Walk u v} (ht : p.IsEulerian) {s} (h : s = (Finset.univ : Finset V).filter fun v => Odd (G.degree v)) : s.card = 0 ∨ s.card = 2 := by subst s simp only [Nat.odd_iff_not_even, Finset.card_eq_zero] simp only [ht.even_degree_iff, Ne, not_forall, not_and, Classical.not_not, exists_prop] obtain rfl | hn := eq_or_ne u v · left simp · right convert_to _ = ({u, v} : Finset V).card · simp [hn] · congr ext x simp [hn, imp_iff_not_or] #align simple_graph.walk.is_eulerian.card_filter_odd_degree SimpleGraph.Walk.IsEulerian.card_filter_odd_degree
Mathlib/Combinatorics/SimpleGraph/Trails.lean
163
169
theorem IsEulerian.card_odd_degree [Fintype V] [DecidableRel G.Adj] {u v : V} {p : G.Walk u v} (ht : p.IsEulerian) : Fintype.card { v : V | Odd (G.degree v) } = 0 ∨ Fintype.card { v : V | Odd (G.degree v) } = 2 := by
rw [← Set.toFinset_card] apply IsEulerian.card_filter_odd_degree ht ext v simp
import Mathlib.Data.Finsupp.Multiset import Mathlib.Data.Nat.GCD.BigOperators import Mathlib.Data.Nat.PrimeFin import Mathlib.NumberTheory.Padics.PadicVal import Mathlib.Order.Interval.Finset.Nat #align_import data.nat.factorization.basic from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" -- Workaround for lean4#2038 attribute [-instance] instBEqNat open Nat Finset List Finsupp namespace Nat variable {a b m n p : ℕ} def factorization (n : ℕ) : ℕ →₀ ℕ where support := n.primeFactors toFun p := if p.Prime then padicValNat p n else 0 mem_support_toFun := by simp [not_or]; aesop #align nat.factorization Nat.factorization @[simp] lemma support_factorization (n : ℕ) : (factorization n).support = n.primeFactors := rfl theorem factorization_def (n : ℕ) {p : ℕ} (pp : p.Prime) : n.factorization p = padicValNat p n := by simpa [factorization] using absurd pp #align nat.factorization_def Nat.factorization_def @[simp] theorem factors_count_eq {n p : ℕ} : n.factors.count p = n.factorization p := by rcases n.eq_zero_or_pos with (rfl | hn0) · simp [factorization, count] if pp : p.Prime then ?_ else rw [count_eq_zero_of_not_mem (mt prime_of_mem_factors pp)] simp [factorization, pp] simp only [factorization_def _ pp] apply _root_.le_antisymm · rw [le_padicValNat_iff_replicate_subperm_factors pp hn0.ne'] exact List.le_count_iff_replicate_sublist.mp le_rfl |>.subperm · rw [← lt_add_one_iff, lt_iff_not_ge, ge_iff_le, le_padicValNat_iff_replicate_subperm_factors pp hn0.ne'] intro h have := h.count_le p simp at this #align nat.factors_count_eq Nat.factors_count_eq theorem factorization_eq_factors_multiset (n : ℕ) : n.factorization = Multiset.toFinsupp (n.factors : Multiset ℕ) := by ext p simp #align nat.factorization_eq_factors_multiset Nat.factorization_eq_factors_multiset theorem multiplicity_eq_factorization {n p : ℕ} (pp : p.Prime) (hn : n ≠ 0) : multiplicity p n = n.factorization p := by simp [factorization, pp, padicValNat_def' pp.ne_one hn.bot_lt] #align nat.multiplicity_eq_factorization Nat.multiplicity_eq_factorization @[simp]
Mathlib/Data/Nat/Factorization/Basic.lean
99
102
theorem factorization_prod_pow_eq_self {n : ℕ} (hn : n ≠ 0) : n.factorization.prod (· ^ ·) = n := by
rw [factorization_eq_factors_multiset n] simp only [← prod_toMultiset, factorization, Multiset.prod_coe, Multiset.toFinsupp_toMultiset] exact prod_factors hn
import Mathlib.AlgebraicTopology.DoldKan.FunctorN #align_import algebraic_topology.dold_kan.normalized from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504" open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Subobject CategoryTheory.Idempotents DoldKan noncomputable section namespace AlgebraicTopology namespace DoldKan universe v variable {A : Type*} [Category A] [Abelian A] {X : SimplicialObject A} theorem HigherFacesVanish.inclusionOfMooreComplexMap (n : ℕ) : HigherFacesVanish (n + 1) ((inclusionOfMooreComplexMap X).f (n + 1)) := fun j _ => by dsimp [AlgebraicTopology.inclusionOfMooreComplexMap, NormalizedMooreComplex.objX] rw [← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ j (by simp only [Finset.mem_univ])), assoc, kernelSubobject_arrow_comp, comp_zero] set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.higher_faces_vanish.inclusion_of_Moore_complex_map AlgebraicTopology.DoldKan.HigherFacesVanish.inclusionOfMooreComplexMap theorem factors_normalizedMooreComplex_PInfty (n : ℕ) : Subobject.Factors (NormalizedMooreComplex.objX X n) (PInfty.f n) := by rcases n with _|n · apply top_factors · rw [PInfty_f, NormalizedMooreComplex.objX, finset_inf_factors] intro i _ apply kernelSubobject_factors exact (HigherFacesVanish.of_P (n + 1) n) i le_add_self set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.factors_normalized_Moore_complex_P_infty AlgebraicTopology.DoldKan.factors_normalizedMooreComplex_PInfty @[simps!] def PInftyToNormalizedMooreComplex (X : SimplicialObject A) : K[X] ⟶ N[X] := ChainComplex.ofHom _ _ _ _ _ _ (fun n => factorThru _ _ (factors_normalizedMooreComplex_PInfty n)) fun n => by rw [← cancel_mono (NormalizedMooreComplex.objX X n).arrow, assoc, assoc, factorThru_arrow, ← inclusionOfMooreComplexMap_f, ← normalizedMooreComplex_objD, ← (inclusionOfMooreComplexMap X).comm (n + 1) n, inclusionOfMooreComplexMap_f, factorThru_arrow_assoc, ← alternatingFaceMapComplex_obj_d] exact PInfty.comm (n + 1) n set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.P_infty_to_normalized_Moore_complex AlgebraicTopology.DoldKan.PInftyToNormalizedMooreComplex @[reassoc (attr := simp)] theorem PInftyToNormalizedMooreComplex_comp_inclusionOfMooreComplexMap (X : SimplicialObject A) : PInftyToNormalizedMooreComplex X ≫ inclusionOfMooreComplexMap X = PInfty := by aesop_cat set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.P_infty_to_normalized_Moore_complex_comp_inclusion_of_Moore_complex_map AlgebraicTopology.DoldKan.PInftyToNormalizedMooreComplex_comp_inclusionOfMooreComplexMap @[reassoc (attr := simp)] theorem PInftyToNormalizedMooreComplex_naturality {X Y : SimplicialObject A} (f : X ⟶ Y) : AlternatingFaceMapComplex.map f ≫ PInftyToNormalizedMooreComplex Y = PInftyToNormalizedMooreComplex X ≫ NormalizedMooreComplex.map f := by aesop_cat set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.P_infty_to_normalized_Moore_complex_naturality AlgebraicTopology.DoldKan.PInftyToNormalizedMooreComplex_naturality @[reassoc (attr := simp)]
Mathlib/AlgebraicTopology/DoldKan/Normalized.lean
91
92
theorem PInfty_comp_PInftyToNormalizedMooreComplex (X : SimplicialObject A) : PInfty ≫ PInftyToNormalizedMooreComplex X = PInftyToNormalizedMooreComplex X := by
aesop_cat
import Mathlib.CategoryTheory.Limits.Shapes.ZeroMorphisms import Mathlib.CategoryTheory.Limits.Shapes.Kernels import Mathlib.CategoryTheory.Abelian.Basic import Mathlib.CategoryTheory.Subobject.Lattice import Mathlib.Order.Atoms #align_import category_theory.simple from "leanprover-community/mathlib"@"4ed0bcaef698011b0692b93a042a2282f490f6b6" noncomputable section open CategoryTheory.Limits namespace CategoryTheory universe v u variable {C : Type u} [Category.{v} C] section variable [HasZeroMorphisms C] class Simple (X : C) : Prop where mono_isIso_iff_nonzero : ∀ {Y : C} (f : Y ⟶ X) [Mono f], IsIso f ↔ f ≠ 0 #align category_theory.simple CategoryTheory.Simple theorem isIso_of_mono_of_nonzero {X Y : C} [Simple Y] {f : X ⟶ Y} [Mono f] (w : f ≠ 0) : IsIso f := (Simple.mono_isIso_iff_nonzero f).mpr w #align category_theory.is_iso_of_mono_of_nonzero CategoryTheory.isIso_of_mono_of_nonzero
Mathlib/CategoryTheory/Simple.lean
61
77
theorem Simple.of_iso {X Y : C} [Simple Y] (i : X ≅ Y) : Simple X := { mono_isIso_iff_nonzero := fun f m => by haveI : Mono (f ≫ i.hom) := mono_comp _ _ constructor · intro h w have j : IsIso (f ≫ i.hom) := by
infer_instance rw [Simple.mono_isIso_iff_nonzero] at j subst w simp at j · intro h have j : IsIso (f ≫ i.hom) := by apply isIso_of_mono_of_nonzero intro w apply h simpa using (cancel_mono i.inv).2 w rw [← Category.comp_id f, ← i.hom_inv_id, ← Category.assoc] infer_instance }
import Mathlib.Data.Set.Subsingleton import Mathlib.Logic.Equiv.Defs import Mathlib.Algebra.Group.Defs #align_import data.part from "leanprover-community/mathlib"@"80c43012d26f63026d362c3aba28f3c3bafb07e6" open Function structure Part.{u} (α : Type u) : Type u where Dom : Prop get : Dom → α #align part Part namespace Part variable {α : Type*} {β : Type*} {γ : Type*} def toOption (o : Part α) [Decidable o.Dom] : Option α := if h : Dom o then some (o.get h) else none #align part.to_option Part.toOption @[simp] lemma toOption_isSome (o : Part α) [Decidable o.Dom] : o.toOption.isSome ↔ o.Dom := by by_cases h : o.Dom <;> simp [h, toOption] #align part.to_option_is_some Part.toOption_isSome @[simp] lemma toOption_isNone (o : Part α) [Decidable o.Dom] : o.toOption.isNone ↔ ¬o.Dom := by by_cases h : o.Dom <;> simp [h, toOption] #align part.to_option_is_none Part.toOption_isNone theorem ext' : ∀ {o p : Part α}, (o.Dom ↔ p.Dom) → (∀ h₁ h₂, o.get h₁ = p.get h₂) → o = p | ⟨od, o⟩, ⟨pd, p⟩, H1, H2 => by have t : od = pd := propext H1 cases t; rw [show o = p from funext fun p => H2 p p] #align part.ext' Part.ext' @[simp] theorem eta : ∀ o : Part α, (⟨o.Dom, fun h => o.get h⟩ : Part α) = o | ⟨_, _⟩ => rfl #align part.eta Part.eta protected def Mem (a : α) (o : Part α) : Prop := ∃ h, o.get h = a #align part.mem Part.Mem instance : Membership α (Part α) := ⟨Part.Mem⟩ theorem mem_eq (a : α) (o : Part α) : (a ∈ o) = ∃ h, o.get h = a := rfl #align part.mem_eq Part.mem_eq theorem dom_iff_mem : ∀ {o : Part α}, o.Dom ↔ ∃ y, y ∈ o | ⟨_, f⟩ => ⟨fun h => ⟨f h, h, rfl⟩, fun ⟨_, h, rfl⟩ => h⟩ #align part.dom_iff_mem Part.dom_iff_mem theorem get_mem {o : Part α} (h) : get o h ∈ o := ⟨_, rfl⟩ #align part.get_mem Part.get_mem @[simp] theorem mem_mk_iff {p : Prop} {o : p → α} {a : α} : a ∈ Part.mk p o ↔ ∃ h, o h = a := Iff.rfl #align part.mem_mk_iff Part.mem_mk_iff @[ext] theorem ext {o p : Part α} (H : ∀ a, a ∈ o ↔ a ∈ p) : o = p := (ext' ⟨fun h => ((H _).1 ⟨h, rfl⟩).fst, fun h => ((H _).2 ⟨h, rfl⟩).fst⟩) fun _ _ => ((H _).2 ⟨_, rfl⟩).snd #align part.ext Part.ext def none : Part α := ⟨False, False.rec⟩ #align part.none Part.none instance : Inhabited (Part α) := ⟨none⟩ @[simp] theorem not_mem_none (a : α) : a ∉ @none α := fun h => h.fst #align part.not_mem_none Part.not_mem_none def some (a : α) : Part α := ⟨True, fun _ => a⟩ #align part.some Part.some @[simp] theorem some_dom (a : α) : (some a).Dom := trivial #align part.some_dom Part.some_dom theorem mem_unique : ∀ {a b : α} {o : Part α}, a ∈ o → b ∈ o → a = b | _, _, ⟨_, _⟩, ⟨_, rfl⟩, ⟨_, rfl⟩ => rfl #align part.mem_unique Part.mem_unique theorem Mem.left_unique : Relator.LeftUnique ((· ∈ ·) : α → Part α → Prop) := fun _ _ _ => mem_unique #align part.mem.left_unique Part.Mem.left_unique theorem get_eq_of_mem {o : Part α} {a} (h : a ∈ o) (h') : get o h' = a := mem_unique ⟨_, rfl⟩ h #align part.get_eq_of_mem Part.get_eq_of_mem protected theorem subsingleton (o : Part α) : Set.Subsingleton { a | a ∈ o } := fun _ ha _ hb => mem_unique ha hb #align part.subsingleton Part.subsingleton @[simp] theorem get_some {a : α} (ha : (some a).Dom) : get (some a) ha = a := rfl #align part.get_some Part.get_some theorem mem_some (a : α) : a ∈ some a := ⟨trivial, rfl⟩ #align part.mem_some Part.mem_some @[simp] theorem mem_some_iff {a b} : b ∈ (some a : Part α) ↔ b = a := ⟨fun ⟨_, e⟩ => e.symm, fun e => ⟨trivial, e.symm⟩⟩ #align part.mem_some_iff Part.mem_some_iff theorem eq_some_iff {a : α} {o : Part α} : o = some a ↔ a ∈ o := ⟨fun e => e.symm ▸ mem_some _, fun ⟨h, e⟩ => e ▸ ext' (iff_true_intro h) fun _ _ => rfl⟩ #align part.eq_some_iff Part.eq_some_iff theorem eq_none_iff {o : Part α} : o = none ↔ ∀ a, a ∉ o := ⟨fun e => e.symm ▸ not_mem_none, fun h => ext (by simpa)⟩ #align part.eq_none_iff Part.eq_none_iff theorem eq_none_iff' {o : Part α} : o = none ↔ ¬o.Dom := ⟨fun e => e.symm ▸ id, fun h => eq_none_iff.2 fun _ h' => h h'.fst⟩ #align part.eq_none_iff' Part.eq_none_iff' @[simp] theorem not_none_dom : ¬(none : Part α).Dom := id #align part.not_none_dom Part.not_none_dom @[simp] theorem some_ne_none (x : α) : some x ≠ none := by intro h exact true_ne_false (congr_arg Dom h) #align part.some_ne_none Part.some_ne_none @[simp] theorem none_ne_some (x : α) : none ≠ some x := (some_ne_none x).symm #align part.none_ne_some Part.none_ne_some theorem ne_none_iff {o : Part α} : o ≠ none ↔ ∃ x, o = some x := by constructor · rw [Ne, eq_none_iff', not_not] exact fun h => ⟨o.get h, eq_some_iff.2 (get_mem h)⟩ · rintro ⟨x, rfl⟩ apply some_ne_none #align part.ne_none_iff Part.ne_none_iff theorem eq_none_or_eq_some (o : Part α) : o = none ∨ ∃ x, o = some x := or_iff_not_imp_left.2 ne_none_iff.1 #align part.eq_none_or_eq_some Part.eq_none_or_eq_some theorem some_injective : Injective (@Part.some α) := fun _ _ h => congr_fun (eq_of_heq (Part.mk.inj h).2) trivial #align part.some_injective Part.some_injective @[simp] theorem some_inj {a b : α} : Part.some a = some b ↔ a = b := some_injective.eq_iff #align part.some_inj Part.some_inj @[simp] theorem some_get {a : Part α} (ha : a.Dom) : Part.some (Part.get a ha) = a := Eq.symm (eq_some_iff.2 ⟨ha, rfl⟩) #align part.some_get Part.some_get theorem get_eq_iff_eq_some {a : Part α} {ha : a.Dom} {b : α} : a.get ha = b ↔ a = some b := ⟨fun h => by simp [h.symm], fun h => by simp [h]⟩ #align part.get_eq_iff_eq_some Part.get_eq_iff_eq_some theorem get_eq_get_of_eq (a : Part α) (ha : a.Dom) {b : Part α} (h : a = b) : a.get ha = b.get (h ▸ ha) := by congr #align part.get_eq_get_of_eq Part.get_eq_get_of_eq theorem get_eq_iff_mem {o : Part α} {a : α} (h : o.Dom) : o.get h = a ↔ a ∈ o := ⟨fun H => ⟨h, H⟩, fun ⟨_, H⟩ => H⟩ #align part.get_eq_iff_mem Part.get_eq_iff_mem theorem eq_get_iff_mem {o : Part α} {a : α} (h : o.Dom) : a = o.get h ↔ a ∈ o := eq_comm.trans (get_eq_iff_mem h) #align part.eq_get_iff_mem Part.eq_get_iff_mem @[simp] theorem none_toOption [Decidable (@none α).Dom] : (none : Part α).toOption = Option.none := dif_neg id #align part.none_to_option Part.none_toOption @[simp] theorem some_toOption (a : α) [Decidable (some a).Dom] : (some a).toOption = Option.some a := dif_pos trivial #align part.some_to_option Part.some_toOption instance noneDecidable : Decidable (@none α).Dom := instDecidableFalse #align part.none_decidable Part.noneDecidable instance someDecidable (a : α) : Decidable (some a).Dom := instDecidableTrue #align part.some_decidable Part.someDecidable def getOrElse (a : Part α) [Decidable a.Dom] (d : α) := if ha : a.Dom then a.get ha else d #align part.get_or_else Part.getOrElse theorem getOrElse_of_dom (a : Part α) (h : a.Dom) [Decidable a.Dom] (d : α) : getOrElse a d = a.get h := dif_pos h #align part.get_or_else_of_dom Part.getOrElse_of_dom theorem getOrElse_of_not_dom (a : Part α) (h : ¬a.Dom) [Decidable a.Dom] (d : α) : getOrElse a d = d := dif_neg h #align part.get_or_else_of_not_dom Part.getOrElse_of_not_dom @[simp] theorem getOrElse_none (d : α) [Decidable (none : Part α).Dom] : getOrElse none d = d := none.getOrElse_of_not_dom not_none_dom d #align part.get_or_else_none Part.getOrElse_none @[simp] theorem getOrElse_some (a : α) (d : α) [Decidable (some a).Dom] : getOrElse (some a) d = a := (some a).getOrElse_of_dom (some_dom a) d #align part.get_or_else_some Part.getOrElse_some -- Porting note: removed `simp` theorem mem_toOption {o : Part α} [Decidable o.Dom] {a : α} : a ∈ toOption o ↔ a ∈ o := by unfold toOption by_cases h : o.Dom <;> simp [h] · exact ⟨fun h => ⟨_, h⟩, fun ⟨_, h⟩ => h⟩ · exact mt Exists.fst h #align part.mem_to_option Part.mem_toOption -- Porting note (#10756): new theorem, like `mem_toOption` but with LHS in `simp` normal form @[simp] theorem toOption_eq_some_iff {o : Part α} [Decidable o.Dom] {a : α} : toOption o = Option.some a ↔ a ∈ o := by rw [← Option.mem_def, mem_toOption] protected theorem Dom.toOption {o : Part α} [Decidable o.Dom] (h : o.Dom) : o.toOption = o.get h := dif_pos h #align part.dom.to_option Part.Dom.toOption theorem toOption_eq_none_iff {a : Part α} [Decidable a.Dom] : a.toOption = Option.none ↔ ¬a.Dom := Ne.dite_eq_right_iff fun _ => Option.some_ne_none _ #align part.to_option_eq_none_iff Part.toOption_eq_none_iff theorem elim_toOption {α β : Type*} (a : Part α) [Decidable a.Dom] (b : β) (f : α → β) : a.toOption.elim b f = if h : a.Dom then f (a.get h) else b := by split_ifs with h · rw [h.toOption] rfl · rw [Part.toOption_eq_none_iff.2 h] rfl #align part.elim_to_option Part.elim_toOption @[coe] def ofOption : Option α → Part α | Option.none => none | Option.some a => some a #align part.of_option Part.ofOption @[simp] theorem mem_ofOption {a : α} : ∀ {o : Option α}, a ∈ ofOption o ↔ a ∈ o | Option.none => ⟨fun h => h.fst.elim, fun h => Option.noConfusion h⟩ | Option.some _ => ⟨fun h => congr_arg Option.some h.snd, fun h => ⟨trivial, Option.some.inj h⟩⟩ #align part.mem_of_option Part.mem_ofOption @[simp] theorem ofOption_dom {α} : ∀ o : Option α, (ofOption o).Dom ↔ o.isSome | Option.none => by simp [ofOption, none] | Option.some a => by simp [ofOption] #align part.of_option_dom Part.ofOption_dom theorem ofOption_eq_get {α} (o : Option α) : ofOption o = ⟨_, @Option.get _ o⟩ := Part.ext' (ofOption_dom o) fun h₁ h₂ => by cases o · simp at h₂ · rfl #align part.of_option_eq_get Part.ofOption_eq_get instance : Coe (Option α) (Part α) := ⟨ofOption⟩ theorem mem_coe {a : α} {o : Option α} : a ∈ (o : Part α) ↔ a ∈ o := mem_ofOption #align part.mem_coe Part.mem_coe @[simp] theorem coe_none : (@Option.none α : Part α) = none := rfl #align part.coe_none Part.coe_none @[simp] theorem coe_some (a : α) : (Option.some a : Part α) = some a := rfl #align part.coe_some Part.coe_some @[elab_as_elim] protected theorem induction_on {P : Part α → Prop} (a : Part α) (hnone : P none) (hsome : ∀ a : α, P (some a)) : P a := (Classical.em a.Dom).elim (fun h => Part.some_get h ▸ hsome _) fun h => (eq_none_iff'.2 h).symm ▸ hnone #align part.induction_on Part.induction_on instance ofOptionDecidable : ∀ o : Option α, Decidable (ofOption o).Dom | Option.none => Part.noneDecidable | Option.some a => Part.someDecidable a #align part.of_option_decidable Part.ofOptionDecidable @[simp] theorem to_ofOption (o : Option α) : toOption (ofOption o) = o := by cases o <;> rfl #align part.to_of_option Part.to_ofOption @[simp] theorem of_toOption (o : Part α) [Decidable o.Dom] : ofOption (toOption o) = o := ext fun _ => mem_ofOption.trans mem_toOption #align part.of_to_option Part.of_toOption noncomputable def equivOption : Part α ≃ Option α := haveI := Classical.dec ⟨fun o => toOption o, ofOption, fun o => of_toOption o, fun o => Eq.trans (by dsimp; congr) (to_ofOption o)⟩ #align part.equiv_option Part.equivOption instance : PartialOrder (Part α) where le x y := ∀ i, i ∈ x → i ∈ y le_refl x y := id le_trans x y z f g i := g _ ∘ f _ le_antisymm x y f g := Part.ext fun z => ⟨f _, g _⟩ instance : OrderBot (Part α) where bot := none bot_le := by rintro x _ ⟨⟨_⟩, _⟩ theorem le_total_of_le_of_le {x y : Part α} (z : Part α) (hx : x ≤ z) (hy : y ≤ z) : x ≤ y ∨ y ≤ x := by rcases Part.eq_none_or_eq_some x with (h | ⟨b, h₀⟩) · rw [h] left apply OrderBot.bot_le _ right; intro b' h₁ rw [Part.eq_some_iff] at h₀ have hx := hx _ h₀; have hy := hy _ h₁ have hx := Part.mem_unique hx hy; subst hx exact h₀ #align part.le_total_of_le_of_le Part.le_total_of_le_of_le def assert (p : Prop) (f : p → Part α) : Part α := ⟨∃ h : p, (f h).Dom, fun ha => (f ha.fst).get ha.snd⟩ #align part.assert Part.assert protected def bind (f : Part α) (g : α → Part β) : Part β := assert (Dom f) fun b => g (f.get b) #align part.bind Part.bind @[simps] def map (f : α → β) (o : Part α) : Part β := ⟨o.Dom, f ∘ o.get⟩ #align part.map Part.map #align part.map_dom Part.map_Dom #align part.map_get Part.map_get theorem mem_map (f : α → β) {o : Part α} : ∀ {a}, a ∈ o → f a ∈ map f o | _, ⟨_, rfl⟩ => ⟨_, rfl⟩ #align part.mem_map Part.mem_map @[simp] theorem mem_map_iff (f : α → β) {o : Part α} {b} : b ∈ map f o ↔ ∃ a ∈ o, f a = b := ⟨fun hb => match b, hb with | _, ⟨_, rfl⟩ => ⟨_, ⟨_, rfl⟩, rfl⟩, fun ⟨_, h₁, h₂⟩ => h₂ ▸ mem_map f h₁⟩ #align part.mem_map_iff Part.mem_map_iff @[simp] theorem map_none (f : α → β) : map f none = none := eq_none_iff.2 fun a => by simp #align part.map_none Part.map_none @[simp] theorem map_some (f : α → β) (a : α) : map f (some a) = some (f a) := eq_some_iff.2 <| mem_map f <| mem_some _ #align part.map_some Part.map_some theorem mem_assert {p : Prop} {f : p → Part α} : ∀ {a} (h : p), a ∈ f h → a ∈ assert p f | _, x, ⟨h, rfl⟩ => ⟨⟨x, h⟩, rfl⟩ #align part.mem_assert Part.mem_assert @[simp] theorem mem_assert_iff {p : Prop} {f : p → Part α} {a} : a ∈ assert p f ↔ ∃ h : p, a ∈ f h := ⟨fun ha => match a, ha with | _, ⟨_, rfl⟩ => ⟨_, ⟨_, rfl⟩⟩, fun ⟨_, h⟩ => mem_assert _ h⟩ #align part.mem_assert_iff Part.mem_assert_iff theorem assert_pos {p : Prop} {f : p → Part α} (h : p) : assert p f = f h := by dsimp [assert] cases h' : f h simp only [h', mk.injEq, h, exists_prop_of_true, true_and] apply Function.hfunext · simp only [h, h', exists_prop_of_true] · aesop #align part.assert_pos Part.assert_pos
Mathlib/Data/Part.lean
479
484
theorem assert_neg {p : Prop} {f : p → Part α} (h : ¬p) : assert p f = none := by
dsimp [assert, none]; congr · simp only [h, not_false_iff, exists_prop_of_false] · apply Function.hfunext · simp only [h, not_false_iff, exists_prop_of_false] simp at *
import Mathlib.Algebra.ModEq import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.Archimedean import Mathlib.Algebra.Periodic import Mathlib.Data.Int.SuccPred import Mathlib.GroupTheory.QuotientGroup import Mathlib.Order.Circular import Mathlib.Data.List.TFAE import Mathlib.Data.Set.Lattice #align_import algebra.order.to_interval_mod from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec" noncomputable section section LinearOrderedAddCommGroup variable {α : Type*} [LinearOrderedAddCommGroup α] [hα : Archimedean α] {p : α} (hp : 0 < p) {a b c : α} {n : ℤ} def toIcoDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ico hp b a).choose #align to_Ico_div toIcoDiv theorem sub_toIcoDiv_zsmul_mem_Ico (a b : α) : b - toIcoDiv hp a b • p ∈ Set.Ico a (a + p) := (existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.1 #align sub_to_Ico_div_zsmul_mem_Ico sub_toIcoDiv_zsmul_mem_Ico theorem toIcoDiv_eq_of_sub_zsmul_mem_Ico (h : b - n • p ∈ Set.Ico a (a + p)) : toIcoDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.2 _ h).symm #align to_Ico_div_eq_of_sub_zsmul_mem_Ico toIcoDiv_eq_of_sub_zsmul_mem_Ico def toIocDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose #align to_Ioc_div toIocDiv theorem sub_toIocDiv_zsmul_mem_Ioc (a b : α) : b - toIocDiv hp a b • p ∈ Set.Ioc a (a + p) := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.1 #align sub_to_Ioc_div_zsmul_mem_Ioc sub_toIocDiv_zsmul_mem_Ioc theorem toIocDiv_eq_of_sub_zsmul_mem_Ioc (h : b - n • p ∈ Set.Ioc a (a + p)) : toIocDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.2 _ h).symm #align to_Ioc_div_eq_of_sub_zsmul_mem_Ioc toIocDiv_eq_of_sub_zsmul_mem_Ioc def toIcoMod (a b : α) : α := b - toIcoDiv hp a b • p #align to_Ico_mod toIcoMod def toIocMod (a b : α) : α := b - toIocDiv hp a b • p #align to_Ioc_mod toIocMod theorem toIcoMod_mem_Ico (a b : α) : toIcoMod hp a b ∈ Set.Ico a (a + p) := sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_mod_mem_Ico toIcoMod_mem_Ico theorem toIcoMod_mem_Ico' (b : α) : toIcoMod hp 0 b ∈ Set.Ico 0 p := by convert toIcoMod_mem_Ico hp 0 b exact (zero_add p).symm #align to_Ico_mod_mem_Ico' toIcoMod_mem_Ico' theorem toIocMod_mem_Ioc (a b : α) : toIocMod hp a b ∈ Set.Ioc a (a + p) := sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_mod_mem_Ioc toIocMod_mem_Ioc theorem left_le_toIcoMod (a b : α) : a ≤ toIcoMod hp a b := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).1 #align left_le_to_Ico_mod left_le_toIcoMod theorem left_lt_toIocMod (a b : α) : a < toIocMod hp a b := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).1 #align left_lt_to_Ioc_mod left_lt_toIocMod theorem toIcoMod_lt_right (a b : α) : toIcoMod hp a b < a + p := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).2 #align to_Ico_mod_lt_right toIcoMod_lt_right theorem toIocMod_le_right (a b : α) : toIocMod hp a b ≤ a + p := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).2 #align to_Ioc_mod_le_right toIocMod_le_right @[simp] theorem self_sub_toIcoDiv_zsmul (a b : α) : b - toIcoDiv hp a b • p = toIcoMod hp a b := rfl #align self_sub_to_Ico_div_zsmul self_sub_toIcoDiv_zsmul @[simp] theorem self_sub_toIocDiv_zsmul (a b : α) : b - toIocDiv hp a b • p = toIocMod hp a b := rfl #align self_sub_to_Ioc_div_zsmul self_sub_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_self (a b : α) : toIcoDiv hp a b • p - b = -toIcoMod hp a b := by rw [toIcoMod, neg_sub] #align to_Ico_div_zsmul_sub_self toIcoDiv_zsmul_sub_self @[simp] theorem toIocDiv_zsmul_sub_self (a b : α) : toIocDiv hp a b • p - b = -toIocMod hp a b := by rw [toIocMod, neg_sub] #align to_Ioc_div_zsmul_sub_self toIocDiv_zsmul_sub_self @[simp] theorem toIcoMod_sub_self (a b : α) : toIcoMod hp a b - b = -toIcoDiv hp a b • p := by rw [toIcoMod, sub_sub_cancel_left, neg_smul] #align to_Ico_mod_sub_self toIcoMod_sub_self @[simp] theorem toIocMod_sub_self (a b : α) : toIocMod hp a b - b = -toIocDiv hp a b • p := by rw [toIocMod, sub_sub_cancel_left, neg_smul] #align to_Ioc_mod_sub_self toIocMod_sub_self @[simp] theorem self_sub_toIcoMod (a b : α) : b - toIcoMod hp a b = toIcoDiv hp a b • p := by rw [toIcoMod, sub_sub_cancel] #align self_sub_to_Ico_mod self_sub_toIcoMod @[simp] theorem self_sub_toIocMod (a b : α) : b - toIocMod hp a b = toIocDiv hp a b • p := by rw [toIocMod, sub_sub_cancel] #align self_sub_to_Ioc_mod self_sub_toIocMod @[simp] theorem toIcoMod_add_toIcoDiv_zsmul (a b : α) : toIcoMod hp a b + toIcoDiv hp a b • p = b := by rw [toIcoMod, sub_add_cancel] #align to_Ico_mod_add_to_Ico_div_zsmul toIcoMod_add_toIcoDiv_zsmul @[simp] theorem toIocMod_add_toIocDiv_zsmul (a b : α) : toIocMod hp a b + toIocDiv hp a b • p = b := by rw [toIocMod, sub_add_cancel] #align to_Ioc_mod_add_to_Ioc_div_zsmul toIocMod_add_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_toIcoMod (a b : α) : toIcoDiv hp a b • p + toIcoMod hp a b = b := by rw [add_comm, toIcoMod_add_toIcoDiv_zsmul] #align to_Ico_div_zsmul_sub_to_Ico_mod toIcoDiv_zsmul_sub_toIcoMod @[simp] theorem toIocDiv_zsmul_sub_toIocMod (a b : α) : toIocDiv hp a b • p + toIocMod hp a b = b := by rw [add_comm, toIocMod_add_toIocDiv_zsmul] #align to_Ioc_div_zsmul_sub_to_Ioc_mod toIocDiv_zsmul_sub_toIocMod theorem toIcoMod_eq_iff : toIcoMod hp a b = c ↔ c ∈ Set.Ico a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by refine ⟨fun h => ⟨h ▸ toIcoMod_mem_Ico hp a b, toIcoDiv hp a b, h ▸ (toIcoMod_add_toIcoDiv_zsmul _ _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIcoDiv_eq_of_sub_zsmul_mem_Ico hp hc, toIcoMod] #align to_Ico_mod_eq_iff toIcoMod_eq_iff theorem toIocMod_eq_iff : toIocMod hp a b = c ↔ c ∈ Set.Ioc a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by refine ⟨fun h => ⟨h ▸ toIocMod_mem_Ioc hp a b, toIocDiv hp a b, h ▸ (toIocMod_add_toIocDiv_zsmul hp _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIocDiv_eq_of_sub_zsmul_mem_Ioc hp hc, toIocMod] #align to_Ioc_mod_eq_iff toIocMod_eq_iff @[simp] theorem toIcoDiv_apply_left (a : α) : toIcoDiv hp a a = 0 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_left toIcoDiv_apply_left @[simp] theorem toIocDiv_apply_left (a : α) : toIocDiv hp a a = -1 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_left toIocDiv_apply_left @[simp] theorem toIcoMod_apply_left (a : α) : toIcoMod hp a a = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ico_mod_apply_left toIcoMod_apply_left @[simp] theorem toIocMod_apply_left (a : α) : toIocMod hp a a = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, -1, by simp⟩ #align to_Ioc_mod_apply_left toIocMod_apply_left theorem toIcoDiv_apply_right (a : α) : toIcoDiv hp a (a + p) = 1 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_right toIcoDiv_apply_right theorem toIocDiv_apply_right (a : α) : toIocDiv hp a (a + p) = 0 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_right toIocDiv_apply_right theorem toIcoMod_apply_right (a : α) : toIcoMod hp a (a + p) = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 1, by simp⟩ #align to_Ico_mod_apply_right toIcoMod_apply_right theorem toIocMod_apply_right (a : α) : toIocMod hp a (a + p) = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ioc_mod_apply_right toIocMod_apply_right @[simp] theorem toIcoDiv_add_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b + m • p) = toIcoDiv hp a b + m := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul toIcoDiv_add_zsmul @[simp] theorem toIcoDiv_add_zsmul' (a b : α) (m : ℤ) : toIcoDiv hp (a + m • p) b = toIcoDiv hp a b - m := by refine toIcoDiv_eq_of_sub_zsmul_mem_Ico _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul' toIcoDiv_add_zsmul' @[simp] theorem toIocDiv_add_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b + m • p) = toIocDiv hp a b + m := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul toIocDiv_add_zsmul @[simp] theorem toIocDiv_add_zsmul' (a b : α) (m : ℤ) : toIocDiv hp (a + m • p) b = toIocDiv hp a b - m := by refine toIocDiv_eq_of_sub_zsmul_mem_Ioc _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul' toIocDiv_add_zsmul' @[simp] theorem toIcoDiv_zsmul_add (a b : α) (m : ℤ) : toIcoDiv hp a (m • p + b) = m + toIcoDiv hp a b := by rw [add_comm, toIcoDiv_add_zsmul, add_comm] #align to_Ico_div_zsmul_add toIcoDiv_zsmul_add @[simp] theorem toIocDiv_zsmul_add (a b : α) (m : ℤ) : toIocDiv hp a (m • p + b) = m + toIocDiv hp a b := by rw [add_comm, toIocDiv_add_zsmul, add_comm] #align to_Ioc_div_zsmul_add toIocDiv_zsmul_add @[simp] theorem toIcoDiv_sub_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b - m • p) = toIcoDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul, sub_eq_add_neg] #align to_Ico_div_sub_zsmul toIcoDiv_sub_zsmul @[simp] theorem toIcoDiv_sub_zsmul' (a b : α) (m : ℤ) : toIcoDiv hp (a - m • p) b = toIcoDiv hp a b + m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul', sub_neg_eq_add] #align to_Ico_div_sub_zsmul' toIcoDiv_sub_zsmul' @[simp] theorem toIocDiv_sub_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b - m • p) = toIocDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul, sub_eq_add_neg] #align to_Ioc_div_sub_zsmul toIocDiv_sub_zsmul @[simp] theorem toIocDiv_sub_zsmul' (a b : α) (m : ℤ) : toIocDiv hp (a - m • p) b = toIocDiv hp a b + m := by rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul', sub_neg_eq_add] #align to_Ioc_div_sub_zsmul' toIocDiv_sub_zsmul' @[simp] theorem toIcoDiv_add_right (a b : α) : toIcoDiv hp a (b + p) = toIcoDiv hp a b + 1 := by simpa only [one_zsmul] using toIcoDiv_add_zsmul hp a b 1 #align to_Ico_div_add_right toIcoDiv_add_right @[simp] theorem toIcoDiv_add_right' (a b : α) : toIcoDiv hp (a + p) b = toIcoDiv hp a b - 1 := by simpa only [one_zsmul] using toIcoDiv_add_zsmul' hp a b 1 #align to_Ico_div_add_right' toIcoDiv_add_right' @[simp] theorem toIocDiv_add_right (a b : α) : toIocDiv hp a (b + p) = toIocDiv hp a b + 1 := by simpa only [one_zsmul] using toIocDiv_add_zsmul hp a b 1 #align to_Ioc_div_add_right toIocDiv_add_right @[simp] theorem toIocDiv_add_right' (a b : α) : toIocDiv hp (a + p) b = toIocDiv hp a b - 1 := by simpa only [one_zsmul] using toIocDiv_add_zsmul' hp a b 1 #align to_Ioc_div_add_right' toIocDiv_add_right' @[simp] theorem toIcoDiv_add_left (a b : α) : toIcoDiv hp a (p + b) = toIcoDiv hp a b + 1 := by rw [add_comm, toIcoDiv_add_right] #align to_Ico_div_add_left toIcoDiv_add_left @[simp] theorem toIcoDiv_add_left' (a b : α) : toIcoDiv hp (p + a) b = toIcoDiv hp a b - 1 := by rw [add_comm, toIcoDiv_add_right'] #align to_Ico_div_add_left' toIcoDiv_add_left' @[simp] theorem toIocDiv_add_left (a b : α) : toIocDiv hp a (p + b) = toIocDiv hp a b + 1 := by rw [add_comm, toIocDiv_add_right] #align to_Ioc_div_add_left toIocDiv_add_left @[simp] theorem toIocDiv_add_left' (a b : α) : toIocDiv hp (p + a) b = toIocDiv hp a b - 1 := by rw [add_comm, toIocDiv_add_right'] #align to_Ioc_div_add_left' toIocDiv_add_left' @[simp] theorem toIcoDiv_sub (a b : α) : toIcoDiv hp a (b - p) = toIcoDiv hp a b - 1 := by simpa only [one_zsmul] using toIcoDiv_sub_zsmul hp a b 1 #align to_Ico_div_sub toIcoDiv_sub @[simp] theorem toIcoDiv_sub' (a b : α) : toIcoDiv hp (a - p) b = toIcoDiv hp a b + 1 := by simpa only [one_zsmul] using toIcoDiv_sub_zsmul' hp a b 1 #align to_Ico_div_sub' toIcoDiv_sub' @[simp] theorem toIocDiv_sub (a b : α) : toIocDiv hp a (b - p) = toIocDiv hp a b - 1 := by simpa only [one_zsmul] using toIocDiv_sub_zsmul hp a b 1 #align to_Ioc_div_sub toIocDiv_sub @[simp] theorem toIocDiv_sub' (a b : α) : toIocDiv hp (a - p) b = toIocDiv hp a b + 1 := by simpa only [one_zsmul] using toIocDiv_sub_zsmul' hp a b 1 #align to_Ioc_div_sub' toIocDiv_sub' theorem toIcoDiv_sub_eq_toIcoDiv_add (a b c : α) : toIcoDiv hp a (b - c) = toIcoDiv hp (a + c) b := by apply toIcoDiv_eq_of_sub_zsmul_mem_Ico rw [← sub_right_comm, Set.sub_mem_Ico_iff_left, add_right_comm] exact sub_toIcoDiv_zsmul_mem_Ico hp (a + c) b #align to_Ico_div_sub_eq_to_Ico_div_add toIcoDiv_sub_eq_toIcoDiv_add theorem toIocDiv_sub_eq_toIocDiv_add (a b c : α) : toIocDiv hp a (b - c) = toIocDiv hp (a + c) b := by apply toIocDiv_eq_of_sub_zsmul_mem_Ioc rw [← sub_right_comm, Set.sub_mem_Ioc_iff_left, add_right_comm] exact sub_toIocDiv_zsmul_mem_Ioc hp (a + c) b #align to_Ioc_div_sub_eq_to_Ioc_div_add toIocDiv_sub_eq_toIocDiv_add theorem toIcoDiv_sub_eq_toIcoDiv_add' (a b c : α) : toIcoDiv hp (a - c) b = toIcoDiv hp a (b + c) := by rw [← sub_neg_eq_add, toIcoDiv_sub_eq_toIcoDiv_add, sub_eq_add_neg] #align to_Ico_div_sub_eq_to_Ico_div_add' toIcoDiv_sub_eq_toIcoDiv_add' theorem toIocDiv_sub_eq_toIocDiv_add' (a b c : α) : toIocDiv hp (a - c) b = toIocDiv hp a (b + c) := by rw [← sub_neg_eq_add, toIocDiv_sub_eq_toIocDiv_add, sub_eq_add_neg] #align to_Ioc_div_sub_eq_to_Ioc_div_add' toIocDiv_sub_eq_toIocDiv_add' theorem toIcoDiv_neg (a b : α) : toIcoDiv hp a (-b) = -(toIocDiv hp (-a) b + 1) := by suffices toIcoDiv hp a (-b) = -toIocDiv hp (-(a + p)) b by rwa [neg_add, ← sub_eq_add_neg, toIocDiv_sub_eq_toIocDiv_add', toIocDiv_add_right] at this rw [← neg_eq_iff_eq_neg, eq_comm] apply toIocDiv_eq_of_sub_zsmul_mem_Ioc obtain ⟨hc, ho⟩ := sub_toIcoDiv_zsmul_mem_Ico hp a (-b) rw [← neg_lt_neg_iff, neg_sub' (-b), neg_neg, ← neg_smul] at ho rw [← neg_le_neg_iff, neg_sub' (-b), neg_neg, ← neg_smul] at hc refine ⟨ho, hc.trans_eq ?_⟩ rw [neg_add, neg_add_cancel_right] #align to_Ico_div_neg toIcoDiv_neg theorem toIcoDiv_neg' (a b : α) : toIcoDiv hp (-a) b = -(toIocDiv hp a (-b) + 1) := by simpa only [neg_neg] using toIcoDiv_neg hp (-a) (-b) #align to_Ico_div_neg' toIcoDiv_neg' theorem toIocDiv_neg (a b : α) : toIocDiv hp a (-b) = -(toIcoDiv hp (-a) b + 1) := by rw [← neg_neg b, toIcoDiv_neg, neg_neg, neg_neg, neg_add', neg_neg, add_sub_cancel_right] #align to_Ioc_div_neg toIocDiv_neg theorem toIocDiv_neg' (a b : α) : toIocDiv hp (-a) b = -(toIcoDiv hp a (-b) + 1) := by simpa only [neg_neg] using toIocDiv_neg hp (-a) (-b) #align to_Ioc_div_neg' toIocDiv_neg' @[simp] theorem toIcoMod_add_zsmul (a b : α) (m : ℤ) : toIcoMod hp a (b + m • p) = toIcoMod hp a b := by rw [toIcoMod, toIcoDiv_add_zsmul, toIcoMod, add_smul] abel #align to_Ico_mod_add_zsmul toIcoMod_add_zsmul @[simp]
Mathlib/Algebra/Order/ToIntervalMod.lean
413
415
theorem toIcoMod_add_zsmul' (a b : α) (m : ℤ) : toIcoMod hp (a + m • p) b = toIcoMod hp a b + m • p := by
simp only [toIcoMod, toIcoDiv_add_zsmul', sub_smul, sub_add]
import Mathlib.Algebra.GeomSum import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Algebra.Ring.Int import Mathlib.NumberTheory.Padics.PadicVal import Mathlib.RingTheory.Ideal.Quotient #align_import number_theory.multiplicity from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" open Ideal Ideal.Quotient Finset variable {R : Type*} {n : ℕ} section CommRing variable [CommRing R] {a b x y : R} theorem dvd_geom_sum₂_iff_of_dvd_sub {x y p : R} (h : p ∣ x - y) : (p ∣ ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i)) ↔ p ∣ n * y ^ (n - 1) := by rw [← mem_span_singleton, ← Ideal.Quotient.eq] at h simp only [← mem_span_singleton, ← eq_zero_iff_mem, RingHom.map_geom_sum₂, h, geom_sum₂_self, _root_.map_mul, map_pow, map_natCast] #align dvd_geom_sum₂_iff_of_dvd_sub dvd_geom_sum₂_iff_of_dvd_sub
Mathlib/NumberTheory/Multiplicity.lean
46
48
theorem dvd_geom_sum₂_iff_of_dvd_sub' {x y p : R} (h : p ∣ x - y) : (p ∣ ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i)) ↔ p ∣ n * x ^ (n - 1) := by
rw [geom_sum₂_comm, dvd_geom_sum₂_iff_of_dvd_sub]; simpa using h.neg_right
import Mathlib.Algebra.GeomSum import Mathlib.Algebra.Order.Archimedean import Mathlib.Algebra.Order.CauSeq.Basic #align_import data.real.cau_seq from "leanprover-community/mathlib"@"9116dd6709f303dcf781632e15fdef382b0fc579" open Finset IsAbsoluteValue namespace IsCauSeq variable {α β : Type*} [LinearOrderedField α] [Ring β] {abv : β → α} [IsAbsoluteValue abv] {f g : ℕ → β} {a : ℕ → α} lemma of_abv_le (n : ℕ) (hm : ∀ m, n ≤ m → abv (f m) ≤ a m) : IsCauSeq abs (fun n ↦ ∑ i ∈ range n, a i) → IsCauSeq abv fun n ↦ ∑ i ∈ range n, f i := by intro hg ε ε0 cases' hg (ε / 2) (div_pos ε0 (by norm_num)) with i hi exists max n i intro j ji have hi₁ := hi j (le_trans (le_max_right n i) ji) have hi₂ := hi (max n i) (le_max_right n i) have sub_le := abs_sub_le (∑ k ∈ range j, a k) (∑ k ∈ range i, a k) (∑ k ∈ range (max n i), a k) have := add_lt_add hi₁ hi₂ rw [abs_sub_comm (∑ k ∈ range (max n i), a k), add_halves ε] at this refine lt_of_le_of_lt (le_trans (le_trans ?_ (le_abs_self _)) sub_le) this generalize hk : j - max n i = k clear this hi₂ hi₁ hi ε0 ε hg sub_le rw [tsub_eq_iff_eq_add_of_le ji] at hk rw [hk] dsimp only clear hk ji j induction' k with k' hi · simp [abv_zero abv] simp only [Nat.succ_add, Nat.succ_eq_add_one, Finset.sum_range_succ_comm] simp only [add_assoc, sub_eq_add_neg] refine le_trans (abv_add _ _ _) ?_ simp only [sub_eq_add_neg] at hi exact add_le_add (hm _ (le_add_of_nonneg_of_le (Nat.zero_le _) (le_max_left _ _))) hi #align is_cau_series_of_abv_le_cau IsCauSeq.of_abv_le lemma of_abv (hf : IsCauSeq abs fun m ↦ ∑ n ∈ range m, abv (f n)) : IsCauSeq abv fun m ↦ ∑ n ∈ range m, f n := hf.of_abv_le 0 fun _ _ ↦ le_rfl #align is_cau_series_of_abv_cau IsCauSeq.of_abv
Mathlib/Algebra/Order/CauSeq/BigOperators.lean
57
141
theorem _root_.cauchy_product (ha : IsCauSeq abs fun m ↦ ∑ n ∈ range m, abv (f n)) (hb : IsCauSeq abv fun m ↦ ∑ n ∈ range m, g n) (ε : α) (ε0 : 0 < ε) : ∃ i : ℕ, ∀ j ≥ i, abv ((∑ k ∈ range j, f k) * ∑ k ∈ range j, g k - ∑ n ∈ range j, ∑ m ∈ range (n + 1), f m * g (n - m)) < ε := by
let ⟨P, hP⟩ := ha.bounded let ⟨Q, hQ⟩ := hb.bounded have hP0 : 0 < P := lt_of_le_of_lt (abs_nonneg _) (hP 0) have hPε0 : 0 < ε / (2 * P) := div_pos ε0 (mul_pos (show (2 : α) > 0 by norm_num) hP0) let ⟨N, hN⟩ := hb.cauchy₂ hPε0 have hQε0 : 0 < ε / (4 * Q) := div_pos ε0 (mul_pos (show (0 : α) < 4 by norm_num) (lt_of_le_of_lt (abv_nonneg _ _) (hQ 0))) let ⟨M, hM⟩ := ha.cauchy₂ hQε0 refine ⟨2 * (max N M + 1), fun K hK ↦ ?_⟩ have h₁ : (∑ m ∈ range K, ∑ k ∈ range (m + 1), f k * g (m - k)) = ∑ m ∈ range K, ∑ n ∈ range (K - m), f m * g n := by simpa using sum_range_diag_flip K fun m n ↦ f m * g n have h₂ : (fun i ↦ ∑ k ∈ range (K - i), f i * g k) = fun i ↦ f i * ∑ k ∈ range (K - i), g k := by simp [Finset.mul_sum] have h₃ : ∑ i ∈ range K, f i * ∑ k ∈ range (K - i), g k = ∑ i ∈ range K, f i * (∑ k ∈ range (K - i), g k - ∑ k ∈ range K, g k) + ∑ i ∈ range K, f i * ∑ k ∈ range K, g k := by rw [← sum_add_distrib]; simp [(mul_add _ _ _).symm] have two_mul_two : (4 : α) = 2 * 2 := by norm_num have hQ0 : Q ≠ 0 := fun h ↦ by simp [h, lt_irrefl] at hQε0 have h2Q0 : 2 * Q ≠ 0 := mul_ne_zero two_ne_zero hQ0 have hε : ε / (2 * P) * P + ε / (4 * Q) * (2 * Q) = ε := by rw [← div_div, div_mul_cancel₀ _ (Ne.symm (ne_of_lt hP0)), two_mul_two, mul_assoc, ← div_div, div_mul_cancel₀ _ h2Q0, add_halves] have hNMK : max N M + 1 < K := lt_of_lt_of_le (by rw [two_mul]; exact lt_add_of_pos_left _ (Nat.succ_pos _)) hK have hKN : N < K := calc N ≤ max N M := le_max_left _ _ _ < max N M + 1 := Nat.lt_succ_self _ _ < K := hNMK have hsumlesum : (∑ i ∈ range (max N M + 1), abv (f i) * abv ((∑ k ∈ range (K - i), g k) - ∑ k ∈ range K, g k)) ≤ ∑ i ∈ range (max N M + 1), abv (f i) * (ε / (2 * P)) := by gcongr with m hmJ refine le_of_lt $ hN (K - m) (le_tsub_of_add_le_left $ hK.trans' ?_) K hKN.le rw [two_mul] gcongr · exact (mem_range.1 hmJ).le · exact Nat.le_succ_of_le (le_max_left _ _) have hsumltP : (∑ n ∈ range (max N M + 1), abv (f n)) < P := calc (∑ n ∈ range (max N M + 1), abv (f n)) = |∑ n ∈ range (max N M + 1), abv (f n)| := Eq.symm (abs_of_nonneg (sum_nonneg fun x _ ↦ abv_nonneg abv (f x))) _ < P := hP (max N M + 1) rw [h₁, h₂, h₃, sum_mul, ← sub_sub, sub_right_comm, sub_self, zero_sub, abv_neg abv] refine lt_of_le_of_lt (IsAbsoluteValue.abv_sum _ _ _) ?_ suffices (∑ i ∈ range (max N M + 1), abv (f i) * abv ((∑ k ∈ range (K - i), g k) - ∑ k ∈ range K, g k)) + ((∑ i ∈ range K, abv (f i) * abv ((∑ k ∈ range (K - i), g k) - ∑ k ∈ range K, g k)) - ∑ i ∈ range (max N M + 1), abv (f i) * abv ((∑ k ∈ range (K - i), g k) - ∑ k ∈ range K, g k)) < ε / (2 * P) * P + ε / (4 * Q) * (2 * Q) by rw [hε] at this simpa [abv_mul abv] using this gcongr · exact lt_of_le_of_lt hsumlesum (by rw [← sum_mul, mul_comm]; gcongr) rw [sum_range_sub_sum_range (le_of_lt hNMK)] calc (∑ i ∈ (range K).filter fun k ↦ max N M + 1 ≤ k, abv (f i) * abv ((∑ k ∈ range (K - i), g k) - ∑ k ∈ range K, g k)) ≤ ∑ i ∈ (range K).filter fun k ↦ max N M + 1 ≤ k, abv (f i) * (2 * Q) := by gcongr rw [sub_eq_add_neg] refine le_trans (abv_add _ _ _) ?_ rw [two_mul, abv_neg abv] gcongr <;> exact le_of_lt (hQ _) _ < ε / (4 * Q) * (2 * Q) := by rw [← sum_mul, ← sum_range_sub_sum_range (le_of_lt hNMK)] have := lt_of_le_of_lt (abv_nonneg _ _) (hQ 0) gcongr exact (le_abs_self _).trans_lt $ hM _ ((Nat.le_succ_of_le (le_max_right _ _)).trans hNMK.le) _ $ Nat.le_succ_of_le $ le_max_right _ _
import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.MvPolynomial.Rename import Mathlib.Algebra.MvPolynomial.Degrees import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" noncomputable section open Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp [f, g] rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp [f, g] rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section variable (S₁ S₂ S₃) def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum @[simp] theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C @[simp] theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X @[simp] theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv @[simps!] def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right @[simps!] def optionEquivLeft : MvPolynomial (Option S₁) R ≃ₐ[R] Polynomial (MvPolynomial S₁ R) := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim Polynomial.X fun s => Polynomial.C (X s)) (Polynomial.aevalTower (MvPolynomial.rename some) (X none)) (by ext : 2 <;> simp) (by ext i : 2; cases i <;> simp) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft lemma optionEquivLeft_X_some (x : S₁) : optionEquivLeft R S₁ (X (some x)) = Polynomial.C (X x) := by simp only [optionEquivLeft_apply, aeval_X] lemma optionEquivLeft_X_none : optionEquivLeft R S₁ (X none) = Polynomial.X := by simp only [optionEquivLeft_apply, aeval_X] lemma optionEquivLeft_C (r : R) : optionEquivLeft R S₁ (C r) = Polynomial.C (C r) := by simp only [optionEquivLeft_apply, aeval_C, Polynomial.algebraMap_apply, algebraMap_eq] end @[simps!] def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight lemma optionEquivRight_X_some (x : S₁) : optionEquivRight R S₁ (X (some x)) = X x := by simp only [optionEquivRight_apply, aeval_X] lemma optionEquivRight_X_none : optionEquivRight R S₁ (X none) = C Polynomial.X := by simp only [optionEquivRight_apply, aeval_X] lemma optionEquivRight_C (r : R) : optionEquivRight R S₁ (C r) = C (Polynomial.C r) := by simp only [optionEquivRight_apply, aeval_C, algebraMap_apply, Polynomial.algebraMap_eq] variable (n : ℕ) def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine Fin.cases ?_ ?_ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine RingHom.ext fun x => ?_ rw [RingHom.comp_apply] refine (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) ?_) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R}
Mathlib/Algebra/MvPolynomial/Equiv.lean
373
373
theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by
simp
import Mathlib.LinearAlgebra.FiniteDimensional #align_import linear_algebra.projective_space.basic from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23" variable (K V : Type*) [DivisionRing K] [AddCommGroup V] [Module K V] def projectivizationSetoid : Setoid { v : V // v ≠ 0 } := (MulAction.orbitRel Kˣ V).comap (↑) #align projectivization_setoid projectivizationSetoid def Projectivization := Quotient (projectivizationSetoid K V) #align projectivization Projectivization scoped[LinearAlgebra.Projectivization] notation "ℙ" => Projectivization namespace Projectivization open scoped LinearAlgebra.Projectivization variable {V} def mk (v : V) (hv : v ≠ 0) : ℙ K V := Quotient.mk'' ⟨v, hv⟩ #align projectivization.mk Projectivization.mk def mk' (v : { v : V // v ≠ 0 }) : ℙ K V := Quotient.mk'' v #align projectivization.mk' Projectivization.mk' @[simp] theorem mk'_eq_mk (v : { v : V // v ≠ 0 }) : mk' K v = mk K ↑v v.2 := rfl #align projectivization.mk'_eq_mk Projectivization.mk'_eq_mk instance [Nontrivial V] : Nonempty (ℙ K V) := let ⟨v, hv⟩ := exists_ne (0 : V) ⟨mk K v hv⟩ variable {K} protected noncomputable def rep (v : ℙ K V) : V := v.out' #align projectivization.rep Projectivization.rep theorem rep_nonzero (v : ℙ K V) : v.rep ≠ 0 := v.out'.2 #align projectivization.rep_nonzero Projectivization.rep_nonzero @[simp] theorem mk_rep (v : ℙ K V) : mk K v.rep v.rep_nonzero = v := Quotient.out_eq' _ #align projectivization.mk_rep Projectivization.mk_rep open FiniteDimensional protected def submodule (v : ℙ K V) : Submodule K V := (Quotient.liftOn' v fun v => K ∙ (v : V)) <| by rintro ⟨a, ha⟩ ⟨b, hb⟩ ⟨x, rfl : x • b = a⟩ exact Submodule.span_singleton_group_smul_eq _ x _ #align projectivization.submodule Projectivization.submodule variable (K) theorem mk_eq_mk_iff (v w : V) (hv : v ≠ 0) (hw : w ≠ 0) : mk K v hv = mk K w hw ↔ ∃ a : Kˣ, a • w = v := Quotient.eq'' #align projectivization.mk_eq_mk_iff Projectivization.mk_eq_mk_iff theorem mk_eq_mk_iff' (v w : V) (hv : v ≠ 0) (hw : w ≠ 0) : mk K v hv = mk K w hw ↔ ∃ a : K, a • w = v := by rw [mk_eq_mk_iff K v w hv hw] constructor · rintro ⟨a, ha⟩ exact ⟨a, ha⟩ · rintro ⟨a, ha⟩ refine ⟨Units.mk0 a fun c => hv.symm ?_, ha⟩ rwa [c, zero_smul] at ha #align projectivization.mk_eq_mk_iff' Projectivization.mk_eq_mk_iff' theorem exists_smul_eq_mk_rep (v : V) (hv : v ≠ 0) : ∃ a : Kˣ, a • v = (mk K v hv).rep := (mk_eq_mk_iff K _ _ (rep_nonzero _) hv).1 (mk_rep _) #align projectivization.exists_smul_eq_mk_rep Projectivization.exists_smul_eq_mk_rep variable {K} @[elab_as_elim] theorem ind {P : ℙ K V → Prop} (h : ∀ (v : V) (h : v ≠ 0), P (mk K v h)) : ∀ p, P p := Quotient.ind' <| Subtype.rec <| h #align projectivization.ind Projectivization.ind @[simp] theorem submodule_mk (v : V) (hv : v ≠ 0) : (mk K v hv).submodule = K ∙ v := rfl #align projectivization.submodule_mk Projectivization.submodule_mk theorem submodule_eq (v : ℙ K V) : v.submodule = K ∙ v.rep := by conv_lhs => rw [← v.mk_rep] rfl #align projectivization.submodule_eq Projectivization.submodule_eq theorem finrank_submodule (v : ℙ K V) : finrank K v.submodule = 1 := by rw [submodule_eq] exact finrank_span_singleton v.rep_nonzero #align projectivization.finrank_submodule Projectivization.finrank_submodule instance (v : ℙ K V) : FiniteDimensional K v.submodule := by rw [← v.mk_rep] change FiniteDimensional K (K ∙ v.rep) infer_instance theorem submodule_injective : Function.Injective (Projectivization.submodule : ℙ K V → Submodule K V) := fun u v h ↦ by induction' u using ind with u hu induction' v using ind with v hv rw [submodule_mk, submodule_mk, Submodule.span_singleton_eq_span_singleton] at h exact ((mk_eq_mk_iff K v u hv hu).2 h).symm #align projectivization.submodule_injective Projectivization.submodule_injective variable (K V) noncomputable def equivSubmodule : ℙ K V ≃ { H : Submodule K V // finrank K H = 1 } := (Equiv.ofInjective _ submodule_injective).trans <| .subtypeEquiv (.refl _) fun H ↦ by refine ⟨fun ⟨v, hv⟩ ↦ hv ▸ v.finrank_submodule, fun h ↦ ?_⟩ rcases finrank_eq_one_iff'.1 h with ⟨v : H, hv₀, hv : ∀ w : H, _⟩ use mk K (v : V) (Subtype.coe_injective.ne hv₀) rw [submodule_mk, SetLike.ext'_iff, Submodule.span_singleton_eq_range] refine (Set.range_subset_iff.2 fun _ ↦ H.smul_mem _ v.2).antisymm fun x hx ↦ ?_ rcases hv ⟨x, hx⟩ with ⟨c, hc⟩ exact ⟨c, congr_arg Subtype.val hc⟩ #align projectivization.equiv_submodule Projectivization.equivSubmodule variable {K V} noncomputable def mk'' (H : Submodule K V) (h : finrank K H = 1) : ℙ K V := (equivSubmodule K V).symm ⟨H, h⟩ #align projectivization.mk'' Projectivization.mk'' @[simp] theorem submodule_mk'' (H : Submodule K V) (h : finrank K H = 1) : (mk'' H h).submodule = H := congr_arg Subtype.val <| (equivSubmodule K V).apply_symm_apply ⟨H, h⟩ #align projectivization.submodule_mk'' Projectivization.submodule_mk'' @[simp] theorem mk''_submodule (v : ℙ K V) : mk'' v.submodule v.finrank_submodule = v := (equivSubmodule K V).symm_apply_apply v #align projectivization.mk''_submodule Projectivization.mk''_submodule section Map variable {L W : Type*} [DivisionRing L] [AddCommGroup W] [Module L W] def map {σ : K →+* L} (f : V →ₛₗ[σ] W) (hf : Function.Injective f) : ℙ K V → ℙ L W := Quotient.map' (fun v => ⟨f v, fun c => v.2 (hf (by simp [c]))⟩) (by rintro ⟨u, hu⟩ ⟨v, hv⟩ ⟨a, ha⟩ use Units.map σ.toMonoidHom a dsimp at ha ⊢ erw [← f.map_smulₛₗ, ha]) #align projectivization.map Projectivization.map theorem map_mk {σ : K →+* L} (f : V →ₛₗ[σ] W) (hf : Function.Injective f) (v : V) (hv : v ≠ 0) : map f hf (mk K v hv) = mk L (f v) (map_zero f ▸ hf.ne hv) := rfl theorem map_injective {σ : K →+* L} {τ : L →+* K} [RingHomInvPair σ τ] (f : V →ₛₗ[σ] W) (hf : Function.Injective f) : Function.Injective (map f hf) := fun u v h ↦ by induction' u using ind with u hu; induction' v using ind with v hv simp only [map_mk, mk_eq_mk_iff'] at h ⊢ rcases h with ⟨a, ha⟩ refine ⟨τ a, hf ?_⟩ rwa [f.map_smulₛₗ, RingHomInvPair.comp_apply_eq₂] #align projectivization.map_injective Projectivization.map_injective @[simp]
Mathlib/LinearAlgebra/Projectivization/Basic.lean
222
224
theorem map_id : map (LinearMap.id : V →ₗ[K] V) (LinearEquiv.refl K V).injective = id := by
ext ⟨v⟩ rfl
import Mathlib.Algebra.Polynomial.Degree.Definitions import Mathlib.Algebra.Polynomial.Induction #align_import data.polynomial.eval from "leanprover-community/mathlib"@"728baa2f54e6062c5879a3e397ac6bac323e506f" set_option linter.uppercaseLean3 false noncomputable section open Finset AddMonoidAlgebra open Polynomial namespace Polynomial universe u v w y variable {R : Type u} {S : Type v} {T : Type w} {ι : Type y} {a b : R} {m n : ℕ} section Semiring variable [Semiring R] {p q r : R[X]} section variable [Semiring S] variable (f : R →+* S) (x : S) irreducible_def eval₂ (p : R[X]) : S := p.sum fun e a => f a * x ^ e #align polynomial.eval₂ Polynomial.eval₂ theorem eval₂_eq_sum {f : R →+* S} {x : S} : p.eval₂ f x = p.sum fun e a => f a * x ^ e := by rw [eval₂_def] #align polynomial.eval₂_eq_sum Polynomial.eval₂_eq_sum theorem eval₂_congr {R S : Type*} [Semiring R] [Semiring S] {f g : R →+* S} {s t : S} {φ ψ : R[X]} : f = g → s = t → φ = ψ → eval₂ f s φ = eval₂ g t ψ := by rintro rfl rfl rfl; rfl #align polynomial.eval₂_congr Polynomial.eval₂_congr @[simp] theorem eval₂_at_zero : p.eval₂ f 0 = f (coeff p 0) := by simp (config := { contextual := true }) only [eval₂_eq_sum, zero_pow_eq, mul_ite, mul_zero, mul_one, sum, Classical.not_not, mem_support_iff, sum_ite_eq', ite_eq_left_iff, RingHom.map_zero, imp_true_iff, eq_self_iff_true] #align polynomial.eval₂_at_zero Polynomial.eval₂_at_zero @[simp] theorem eval₂_zero : (0 : R[X]).eval₂ f x = 0 := by simp [eval₂_eq_sum] #align polynomial.eval₂_zero Polynomial.eval₂_zero @[simp] theorem eval₂_C : (C a).eval₂ f x = f a := by simp [eval₂_eq_sum] #align polynomial.eval₂_C Polynomial.eval₂_C @[simp] theorem eval₂_X : X.eval₂ f x = x := by simp [eval₂_eq_sum] #align polynomial.eval₂_X Polynomial.eval₂_X @[simp] theorem eval₂_monomial {n : ℕ} {r : R} : (monomial n r).eval₂ f x = f r * x ^ n := by simp [eval₂_eq_sum] #align polynomial.eval₂_monomial Polynomial.eval₂_monomial @[simp] theorem eval₂_X_pow {n : ℕ} : (X ^ n).eval₂ f x = x ^ n := by rw [X_pow_eq_monomial] convert eval₂_monomial f x (n := n) (r := 1) simp #align polynomial.eval₂_X_pow Polynomial.eval₂_X_pow @[simp] theorem eval₂_add : (p + q).eval₂ f x = p.eval₂ f x + q.eval₂ f x := by simp only [eval₂_eq_sum] apply sum_add_index <;> simp [add_mul] #align polynomial.eval₂_add Polynomial.eval₂_add @[simp] theorem eval₂_one : (1 : R[X]).eval₂ f x = 1 := by rw [← C_1, eval₂_C, f.map_one] #align polynomial.eval₂_one Polynomial.eval₂_one set_option linter.deprecated false in @[simp] theorem eval₂_bit0 : (bit0 p).eval₂ f x = bit0 (p.eval₂ f x) := by rw [bit0, eval₂_add, bit0] #align polynomial.eval₂_bit0 Polynomial.eval₂_bit0 set_option linter.deprecated false in @[simp] theorem eval₂_bit1 : (bit1 p).eval₂ f x = bit1 (p.eval₂ f x) := by rw [bit1, eval₂_add, eval₂_bit0, eval₂_one, bit1] #align polynomial.eval₂_bit1 Polynomial.eval₂_bit1 @[simp]
Mathlib/Algebra/Polynomial/Eval.lean
110
115
theorem eval₂_smul (g : R →+* S) (p : R[X]) (x : S) {s : R} : eval₂ g x (s • p) = g s * eval₂ g x p := by
have A : p.natDegree < p.natDegree.succ := Nat.lt_succ_self _ have B : (s • p).natDegree < p.natDegree.succ := (natDegree_smul_le _ _).trans_lt A rw [eval₂_eq_sum, eval₂_eq_sum, sum_over_range' _ _ _ A, sum_over_range' _ _ _ B] <;> simp [mul_sum, mul_assoc]
import Mathlib.Data.Fintype.Option import Mathlib.Topology.Separation import Mathlib.Topology.Sets.Opens #align_import topology.alexandroff from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" open Set Filter Topology variable {X : Type*} def OnePoint (X : Type*) := Option X #align alexandroff OnePoint instance [Repr X] : Repr (OnePoint X) := ⟨fun o _ => match o with | none => "∞" | some a => "↑" ++ repr a⟩ namespace OnePoint @[match_pattern] def infty : OnePoint X := none #align alexandroff.infty OnePoint.infty @[inherit_doc] scoped notation "∞" => OnePoint.infty @[coe, match_pattern] def some : X → OnePoint X := Option.some instance : CoeTC X (OnePoint X) := ⟨some⟩ instance : Inhabited (OnePoint X) := ⟨∞⟩ instance [Fintype X] : Fintype (OnePoint X) := inferInstanceAs (Fintype (Option X)) instance infinite [Infinite X] : Infinite (OnePoint X) := inferInstanceAs (Infinite (Option X)) #align alexandroff.infinite OnePoint.infinite theorem coe_injective : Function.Injective ((↑) : X → OnePoint X) := Option.some_injective X #align alexandroff.coe_injective OnePoint.coe_injective @[norm_cast] theorem coe_eq_coe {x y : X} : (x : OnePoint X) = y ↔ x = y := coe_injective.eq_iff #align alexandroff.coe_eq_coe OnePoint.coe_eq_coe @[simp] theorem coe_ne_infty (x : X) : (x : OnePoint X) ≠ ∞ := nofun #align alexandroff.coe_ne_infty OnePoint.coe_ne_infty @[simp] theorem infty_ne_coe (x : X) : ∞ ≠ (x : OnePoint X) := nofun #align alexandroff.infty_ne_coe OnePoint.infty_ne_coe @[elab_as_elim] protected def rec {C : OnePoint X → Sort*} (h₁ : C ∞) (h₂ : ∀ x : X, C x) : ∀ z : OnePoint X, C z | ∞ => h₁ | (x : X) => h₂ x #align alexandroff.rec OnePoint.rec theorem isCompl_range_coe_infty : IsCompl (range ((↑) : X → OnePoint X)) {∞} := isCompl_range_some_none X #align alexandroff.is_compl_range_coe_infty OnePoint.isCompl_range_coe_infty -- Porting note: moved @[simp] to a new lemma theorem range_coe_union_infty : range ((↑) : X → OnePoint X) ∪ {∞} = univ := range_some_union_none X #align alexandroff.range_coe_union_infty OnePoint.range_coe_union_infty @[simp] theorem insert_infty_range_coe : insert ∞ (range (@some X)) = univ := insert_none_range_some _ @[simp] theorem range_coe_inter_infty : range ((↑) : X → OnePoint X) ∩ {∞} = ∅ := range_some_inter_none X #align alexandroff.range_coe_inter_infty OnePoint.range_coe_inter_infty @[simp] theorem compl_range_coe : (range ((↑) : X → OnePoint X))ᶜ = {∞} := compl_range_some X #align alexandroff.compl_range_coe OnePoint.compl_range_coe theorem compl_infty : ({∞}ᶜ : Set (OnePoint X)) = range ((↑) : X → OnePoint X) := (@isCompl_range_coe_infty X).symm.compl_eq #align alexandroff.compl_infty OnePoint.compl_infty theorem compl_image_coe (s : Set X) : ((↑) '' s : Set (OnePoint X))ᶜ = (↑) '' sᶜ ∪ {∞} := by rw [coe_injective.compl_image_eq, compl_range_coe] #align alexandroff.compl_image_coe OnePoint.compl_image_coe theorem ne_infty_iff_exists {x : OnePoint X} : x ≠ ∞ ↔ ∃ y : X, (y : OnePoint X) = x := by induction x using OnePoint.rec <;> simp #align alexandroff.ne_infty_iff_exists OnePoint.ne_infty_iff_exists instance canLift : CanLift (OnePoint X) X (↑) fun x => x ≠ ∞ := WithTop.canLift #align alexandroff.can_lift OnePoint.canLift theorem not_mem_range_coe_iff {x : OnePoint X} : x ∉ range some ↔ x = ∞ := by rw [← mem_compl_iff, compl_range_coe, mem_singleton_iff] #align alexandroff.not_mem_range_coe_iff OnePoint.not_mem_range_coe_iff theorem infty_not_mem_range_coe : ∞ ∉ range ((↑) : X → OnePoint X) := not_mem_range_coe_iff.2 rfl #align alexandroff.infty_not_mem_range_coe OnePoint.infty_not_mem_range_coe theorem infty_not_mem_image_coe {s : Set X} : ∞ ∉ ((↑) : X → OnePoint X) '' s := not_mem_subset (image_subset_range _ _) infty_not_mem_range_coe #align alexandroff.infty_not_mem_image_coe OnePoint.infty_not_mem_image_coe @[simp] theorem coe_preimage_infty : ((↑) : X → OnePoint X) ⁻¹' {∞} = ∅ := by ext simp #align alexandroff.coe_preimage_infty OnePoint.coe_preimage_infty variable [TopologicalSpace X] instance : TopologicalSpace (OnePoint X) where IsOpen s := (∞ ∈ s → IsCompact (((↑) : X → OnePoint X) ⁻¹' s)ᶜ) ∧ IsOpen (((↑) : X → OnePoint X) ⁻¹' s) isOpen_univ := by simp isOpen_inter s t := by rintro ⟨hms, hs⟩ ⟨hmt, ht⟩ refine ⟨?_, hs.inter ht⟩ rintro ⟨hms', hmt'⟩ simpa [compl_inter] using (hms hms').union (hmt hmt') isOpen_sUnion S ho := by suffices IsOpen ((↑) ⁻¹' ⋃₀ S : Set X) by refine ⟨?_, this⟩ rintro ⟨s, hsS : s ∈ S, hs : ∞ ∈ s⟩ refine IsCompact.of_isClosed_subset ((ho s hsS).1 hs) this.isClosed_compl ?_ exact compl_subset_compl.mpr (preimage_mono <| subset_sUnion_of_mem hsS) rw [preimage_sUnion] exact isOpen_biUnion fun s hs => (ho s hs).2 variable {s : Set (OnePoint X)} {t : Set X} theorem isOpen_def : IsOpen s ↔ (∞ ∈ s → IsCompact ((↑) ⁻¹' s : Set X)ᶜ) ∧ IsOpen ((↑) ⁻¹' s : Set X) := Iff.rfl #align alexandroff.is_open_def OnePoint.isOpen_def theorem isOpen_iff_of_mem' (h : ∞ ∈ s) : IsOpen s ↔ IsCompact ((↑) ⁻¹' s : Set X)ᶜ ∧ IsOpen ((↑) ⁻¹' s : Set X) := by simp [isOpen_def, h] #align alexandroff.is_open_iff_of_mem' OnePoint.isOpen_iff_of_mem' theorem isOpen_iff_of_mem (h : ∞ ∈ s) : IsOpen s ↔ IsClosed ((↑) ⁻¹' s : Set X)ᶜ ∧ IsCompact ((↑) ⁻¹' s : Set X)ᶜ := by simp only [isOpen_iff_of_mem' h, isClosed_compl_iff, and_comm] #align alexandroff.is_open_iff_of_mem OnePoint.isOpen_iff_of_mem theorem isOpen_iff_of_not_mem (h : ∞ ∉ s) : IsOpen s ↔ IsOpen ((↑) ⁻¹' s : Set X) := by simp [isOpen_def, h] #align alexandroff.is_open_iff_of_not_mem OnePoint.isOpen_iff_of_not_mem theorem isClosed_iff_of_mem (h : ∞ ∈ s) : IsClosed s ↔ IsClosed ((↑) ⁻¹' s : Set X) := by have : ∞ ∉ sᶜ := fun H => H h rw [← isOpen_compl_iff, isOpen_iff_of_not_mem this, ← isOpen_compl_iff, preimage_compl] #align alexandroff.is_closed_iff_of_mem OnePoint.isClosed_iff_of_mem theorem isClosed_iff_of_not_mem (h : ∞ ∉ s) : IsClosed s ↔ IsClosed ((↑) ⁻¹' s : Set X) ∧ IsCompact ((↑) ⁻¹' s : Set X) := by rw [← isOpen_compl_iff, isOpen_iff_of_mem (mem_compl h), ← preimage_compl, compl_compl] #align alexandroff.is_closed_iff_of_not_mem OnePoint.isClosed_iff_of_not_mem @[simp] theorem isOpen_image_coe {s : Set X} : IsOpen ((↑) '' s : Set (OnePoint X)) ↔ IsOpen s := by rw [isOpen_iff_of_not_mem infty_not_mem_image_coe, preimage_image_eq _ coe_injective] #align alexandroff.is_open_image_coe OnePoint.isOpen_image_coe
Mathlib/Topology/Compactification/OnePoint.lean
240
243
theorem isOpen_compl_image_coe {s : Set X} : IsOpen ((↑) '' s : Set (OnePoint X))ᶜ ↔ IsClosed s ∧ IsCompact s := by
rw [isOpen_iff_of_mem, ← preimage_compl, compl_compl, preimage_image_eq _ coe_injective] exact infty_not_mem_image_coe
import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics import Mathlib.Analysis.Asymptotics.AsymptoticEquivalent import Mathlib.Analysis.Asymptotics.SpecificAsymptotics #align_import analysis.special_functions.compare_exp from "leanprover-community/mathlib"@"0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8" open Asymptotics Filter Function open scoped Topology namespace Complex structure IsExpCmpFilter (l : Filter ℂ) : Prop where tendsto_re : Tendsto re l atTop isBigO_im_pow_re : ∀ n : ℕ, (fun z : ℂ => z.im ^ n) =O[l] fun z => Real.exp z.re #align complex.is_exp_cmp_filter Complex.IsExpCmpFilter namespace IsExpCmpFilter variable {l : Filter ℂ} theorem of_isBigO_im_re_rpow (hre : Tendsto re l atTop) (r : ℝ) (hr : im =O[l] fun z => z.re ^ r) : IsExpCmpFilter l := ⟨hre, fun n => IsLittleO.isBigO <| calc (fun z : ℂ => z.im ^ n) =O[l] fun z => (z.re ^ r) ^ n := hr.pow n _ =ᶠ[l] fun z => z.re ^ (r * n) := ((hre.eventually_ge_atTop 0).mono fun z hz => by simp only [Real.rpow_mul hz r n, Real.rpow_natCast]) _ =o[l] fun z => Real.exp z.re := (isLittleO_rpow_exp_atTop _).comp_tendsto hre ⟩ set_option linter.uppercaseLean3 false in #align complex.is_exp_cmp_filter.of_is_O_im_re_rpow Complex.IsExpCmpFilter.of_isBigO_im_re_rpow theorem of_isBigO_im_re_pow (hre : Tendsto re l atTop) (n : ℕ) (hr : im =O[l] fun z => z.re ^ n) : IsExpCmpFilter l := of_isBigO_im_re_rpow hre n <| mod_cast hr set_option linter.uppercaseLean3 false in #align complex.is_exp_cmp_filter.of_is_O_im_re_pow Complex.IsExpCmpFilter.of_isBigO_im_re_pow theorem of_boundedUnder_abs_im (hre : Tendsto re l atTop) (him : IsBoundedUnder (· ≤ ·) l fun z => |z.im|) : IsExpCmpFilter l := of_isBigO_im_re_pow hre 0 <| by simpa only [pow_zero] using him.isBigO_const (f := im) one_ne_zero #align complex.is_exp_cmp_filter.of_bounded_under_abs_im Complex.IsExpCmpFilter.of_boundedUnder_abs_im theorem of_boundedUnder_im (hre : Tendsto re l atTop) (him_le : IsBoundedUnder (· ≤ ·) l im) (him_ge : IsBoundedUnder (· ≥ ·) l im) : IsExpCmpFilter l := of_boundedUnder_abs_im hre <| isBoundedUnder_le_abs.2 ⟨him_le, him_ge⟩ #align complex.is_exp_cmp_filter.of_bounded_under_im Complex.IsExpCmpFilter.of_boundedUnder_im theorem eventually_ne (hl : IsExpCmpFilter l) : ∀ᶠ w : ℂ in l, w ≠ 0 := hl.tendsto_re.eventually_ne_atTop' _ #align complex.is_exp_cmp_filter.eventually_ne Complex.IsExpCmpFilter.eventually_ne theorem tendsto_abs_re (hl : IsExpCmpFilter l) : Tendsto (fun z : ℂ => |z.re|) l atTop := tendsto_abs_atTop_atTop.comp hl.tendsto_re #align complex.is_exp_cmp_filter.tendsto_abs_re Complex.IsExpCmpFilter.tendsto_abs_re theorem tendsto_abs (hl : IsExpCmpFilter l) : Tendsto abs l atTop := tendsto_atTop_mono abs_re_le_abs hl.tendsto_abs_re #align complex.is_exp_cmp_filter.tendsto_abs Complex.IsExpCmpFilter.tendsto_abs theorem isLittleO_log_re_re (hl : IsExpCmpFilter l) : (fun z => Real.log z.re) =o[l] re := Real.isLittleO_log_id_atTop.comp_tendsto hl.tendsto_re #align complex.is_exp_cmp_filter.is_o_log_re_re Complex.IsExpCmpFilter.isLittleO_log_re_re theorem isLittleO_im_pow_exp_re (hl : IsExpCmpFilter l) (n : ℕ) : (fun z : ℂ => z.im ^ n) =o[l] fun z => Real.exp z.re := flip IsLittleO.of_pow two_ne_zero <| calc (fun z : ℂ ↦ (z.im ^ n) ^ 2) = (fun z ↦ z.im ^ (2 * n)) := by simp only [pow_mul'] _ =O[l] fun z ↦ Real.exp z.re := hl.isBigO_im_pow_re _ _ = fun z ↦ (Real.exp z.re) ^ 1 := by simp only [pow_one] _ =o[l] fun z ↦ (Real.exp z.re) ^ 2 := (isLittleO_pow_pow_atTop_of_lt one_lt_two).comp_tendsto <| Real.tendsto_exp_atTop.comp hl.tendsto_re #align complex.is_exp_cmp_filter.is_o_im_pow_exp_re Complex.IsExpCmpFilter.isLittleO_im_pow_exp_re theorem abs_im_pow_eventuallyLE_exp_re (hl : IsExpCmpFilter l) (n : ℕ) : (fun z : ℂ => |z.im| ^ n) ≤ᶠ[l] fun z => Real.exp z.re := by simpa using (hl.isLittleO_im_pow_exp_re n).bound zero_lt_one #align complex.is_exp_cmp_filter.abs_im_pow_eventually_le_exp_re Complex.IsExpCmpFilter.abs_im_pow_eventuallyLE_exp_re theorem isLittleO_log_abs_re (hl : IsExpCmpFilter l) : (fun z => Real.log (abs z)) =o[l] re := calc (fun z => Real.log (abs z)) =O[l] fun z => Real.log (√2) + Real.log (max z.re |z.im|) := IsBigO.of_bound 1 <| (hl.tendsto_re.eventually_ge_atTop 1).mono fun z hz => by have h2 : 0 < √2 := by simp have hz' : 1 ≤ abs z := hz.trans (re_le_abs z) have hm₀ : 0 < max z.re |z.im| := lt_max_iff.2 (Or.inl <| one_pos.trans_le hz) rw [one_mul, Real.norm_eq_abs, _root_.abs_of_nonneg (Real.log_nonneg hz')] refine le_trans ?_ (le_abs_self _) rw [← Real.log_mul, Real.log_le_log_iff, ← _root_.abs_of_nonneg (le_trans zero_le_one hz)] exacts [abs_le_sqrt_two_mul_max z, one_pos.trans_le hz', mul_pos h2 hm₀, h2.ne', hm₀.ne'] _ =o[l] re := IsLittleO.add (isLittleO_const_left.2 <| Or.inr <| hl.tendsto_abs_re) <| isLittleO_iff_nat_mul_le.2 fun n => by filter_upwards [isLittleO_iff_nat_mul_le'.1 hl.isLittleO_log_re_re n, hl.abs_im_pow_eventuallyLE_exp_re n, hl.tendsto_re.eventually_gt_atTop 1] with z hre him h₁ rcases le_total |z.im| z.re with hle | hle · rwa [max_eq_left hle] · have H : 1 < |z.im| := h₁.trans_le hle norm_cast at * rwa [max_eq_right hle, Real.norm_eq_abs, Real.norm_eq_abs, abs_of_pos (Real.log_pos H), ← Real.log_pow, Real.log_le_iff_le_exp (pow_pos (one_pos.trans H) _), abs_of_pos (one_pos.trans h₁)] #align complex.is_exp_cmp_filter.is_o_log_abs_re Complex.IsExpCmpFilter.isLittleO_log_abs_re lemma isTheta_cpow_exp_re_mul_log (hl : IsExpCmpFilter l) (a : ℂ) : (· ^ a) =Θ[l] fun z ↦ Real.exp (re a * Real.log (abs z)) := calc (fun z => z ^ a) =Θ[l] (fun z : ℂ => (abs z ^ re a)) := isTheta_cpow_const_rpow fun _ _ => hl.eventually_ne _ =ᶠ[l] fun z => Real.exp (re a * Real.log (abs z)) := (hl.eventually_ne.mono fun z hz => by simp only [Real.rpow_def_of_pos, abs.pos hz, mul_comm]) theorem isLittleO_cpow_exp (hl : IsExpCmpFilter l) (a : ℂ) {b : ℝ} (hb : 0 < b) : (fun z => z ^ a) =o[l] fun z => exp (b * z) := calc (fun z => z ^ a) =Θ[l] fun z => Real.exp (re a * Real.log (abs z)) := hl.isTheta_cpow_exp_re_mul_log a _ =o[l] fun z => exp (b * z) := IsLittleO.of_norm_right <| by simp only [norm_eq_abs, abs_exp, re_ofReal_mul, Real.isLittleO_exp_comp_exp_comp] refine (IsEquivalent.refl.sub_isLittleO ?_).symm.tendsto_atTop (hl.tendsto_re.const_mul_atTop hb) exact (hl.isLittleO_log_abs_re.const_mul_left _).const_mul_right hb.ne' #align complex.is_exp_cmp_filter.is_o_cpow_exp Complex.IsExpCmpFilter.isLittleO_cpow_exp theorem isLittleO_cpow_mul_exp {b₁ b₂ : ℝ} (hl : IsExpCmpFilter l) (hb : b₁ < b₂) (a₁ a₂ : ℂ) : (fun z => z ^ a₁ * exp (b₁ * z)) =o[l] fun z => z ^ a₂ * exp (b₂ * z) := calc (fun z => z ^ a₁ * exp (b₁ * z)) =ᶠ[l] fun z => z ^ a₂ * exp (b₁ * z) * z ^ (a₁ - a₂) := hl.eventually_ne.mono fun z hz => by simp only rw [mul_right_comm, ← cpow_add _ _ hz, add_sub_cancel] _ =o[l] fun z => z ^ a₂ * exp (b₁ * z) * exp (↑(b₂ - b₁) * z) := ((isBigO_refl (fun z => z ^ a₂ * exp (b₁ * z)) l).mul_isLittleO <| hl.isLittleO_cpow_exp _ (sub_pos.2 hb)) _ =ᶠ[l] fun z => z ^ a₂ * exp (b₂ * z) := by simp only [ofReal_sub, sub_mul, mul_assoc, ← exp_add, add_sub_cancel] norm_cast #align complex.is_exp_cmp_filter.is_o_cpow_mul_exp Complex.IsExpCmpFilter.isLittleO_cpow_mul_exp
Mathlib/Analysis/SpecialFunctions/CompareExp.lean
200
201
theorem isLittleO_exp_cpow (hl : IsExpCmpFilter l) (a : ℂ) {b : ℝ} (hb : b < 0) : (fun z => exp (b * z)) =o[l] fun z => z ^ a := by
simpa using hl.isLittleO_cpow_mul_exp hb 0 a
import Mathlib.Computability.DFA import Mathlib.Data.Fintype.Powerset #align_import computability.NFA from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514" open Set open Computability universe u v -- Porting note: Required as `NFA` is used in mathlib3 set_option linter.uppercaseLean3 false structure NFA (α : Type u) (σ : Type v) where step : σ → α → Set σ start : Set σ accept : Set σ #align NFA NFA variable {α : Type u} {σ σ' : Type v} (M : NFA α σ) namespace NFA instance : Inhabited (NFA α σ) := ⟨NFA.mk (fun _ _ => ∅) ∅ ∅⟩ def stepSet (S : Set σ) (a : α) : Set σ := ⋃ s ∈ S, M.step s a #align NFA.step_set NFA.stepSet
Mathlib/Computability/NFA.lean
53
54
theorem mem_stepSet (s : σ) (S : Set σ) (a : α) : s ∈ M.stepSet S a ↔ ∃ t ∈ S, s ∈ M.step t a := by
simp [stepSet]
import Mathlib.Combinatorics.Quiver.Path import Mathlib.Combinatorics.Quiver.Push #align_import combinatorics.quiver.symmetric from "leanprover-community/mathlib"@"706d88f2b8fdfeb0b22796433d7a6c1a010af9f2" universe v u w v' namespace Quiver -- Porting note: no hasNonemptyInstance linter yet def Symmetrify (V : Type*) := V #align quiver.symmetrify Quiver.Symmetrify instance symmetrifyQuiver (V : Type u) [Quiver V] : Quiver (Symmetrify V) := ⟨fun a b : V ↦ Sum (a ⟶ b) (b ⟶ a)⟩ variable (U V W : Type*) [Quiver.{u + 1} U] [Quiver.{v + 1} V] [Quiver.{w + 1} W] class HasReverse where reverse' : ∀ {a b : V}, (a ⟶ b) → (b ⟶ a) #align quiver.has_reverse Quiver.HasReverse def reverse {V} [Quiver.{v + 1} V] [HasReverse V] {a b : V} : (a ⟶ b) → (b ⟶ a) := HasReverse.reverse' #align quiver.reverse Quiver.reverse class HasInvolutiveReverse extends HasReverse V where inv' : ∀ {a b : V} (f : a ⟶ b), reverse (reverse f) = f #align quiver.has_involutive_reverse Quiver.HasInvolutiveReverse variable {U V W} @[simp] theorem reverse_reverse [h : HasInvolutiveReverse V] {a b : V} (f : a ⟶ b) : reverse (reverse f) = f := by apply h.inv' #align quiver.reverse_reverse Quiver.reverse_reverse @[simp] theorem reverse_inj [h : HasInvolutiveReverse V] {a b : V} (f g : a ⟶ b) : reverse f = reverse g ↔ f = g := by constructor · rintro h simpa using congr_arg Quiver.reverse h · rintro h congr #align quiver.reverse_inj Quiver.reverse_inj theorem eq_reverse_iff [h : HasInvolutiveReverse V] {a b : V} (f : a ⟶ b) (g : b ⟶ a) : f = reverse g ↔ reverse f = g := by rw [← reverse_inj, reverse_reverse] #align quiver.eq_reverse_iff Quiver.eq_reverse_iff instance : HasReverse (Symmetrify V) := ⟨fun e => e.swap⟩ instance : HasInvolutiveReverse (Symmetrify V) where toHasReverse := ⟨fun e ↦ e.swap⟩ inv' e := congr_fun Sum.swap_swap_eq e @[simp] theorem symmetrify_reverse {a b : Symmetrify V} (e : a ⟶ b) : reverse e = e.swap := rfl #align quiver.symmetrify_reverse Quiver.symmetrify_reverse section Paths abbrev Hom.toPos {X Y : V} (f : X ⟶ Y) : (Quiver.symmetrifyQuiver V).Hom X Y := Sum.inl f #align quiver.hom.to_pos Quiver.Hom.toPos abbrev Hom.toNeg {X Y : V} (f : X ⟶ Y) : (Quiver.symmetrifyQuiver V).Hom Y X := Sum.inr f #align quiver.hom.to_neg Quiver.Hom.toNeg @[simp] def Path.reverse [HasReverse V] {a : V} : ∀ {b}, Path a b → Path b a | _, Path.nil => Path.nil | _, Path.cons p e => (Quiver.reverse e).toPath.comp p.reverse #align quiver.path.reverse Quiver.Path.reverse @[simp] theorem Path.reverse_toPath [HasReverse V] {a b : V} (f : a ⟶ b) : f.toPath.reverse = (Quiver.reverse f).toPath := rfl #align quiver.path.reverse_to_path Quiver.Path.reverse_toPath @[simp] theorem Path.reverse_comp [HasReverse V] {a b c : V} (p : Path a b) (q : Path b c) : (p.comp q).reverse = q.reverse.comp p.reverse := by induction' q with _ _ _ _ h · simp · simp [h] #align quiver.path.reverse_comp Quiver.Path.reverse_comp @[simp]
Mathlib/Combinatorics/Quiver/Symmetric.lean
158
163
theorem Path.reverse_reverse [h : HasInvolutiveReverse V] {a b : V} (p : Path a b) : p.reverse.reverse = p := by
induction' p with _ _ _ _ h · simp · rw [Path.reverse, Path.reverse_comp, h, Path.reverse_toPath, Quiver.reverse_reverse] rfl
import Mathlib.Topology.Constructions #align_import topology.continuous_on from "leanprover-community/mathlib"@"d4f691b9e5f94cfc64639973f3544c95f8d5d494" open Set Filter Function Topology Filter variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} variable [TopologicalSpace α] @[simp] theorem nhds_bind_nhdsWithin {a : α} {s : Set α} : ((𝓝 a).bind fun x => 𝓝[s] x) = 𝓝[s] a := bind_inf_principal.trans <| congr_arg₂ _ nhds_bind_nhds rfl #align nhds_bind_nhds_within nhds_bind_nhdsWithin @[simp] theorem eventually_nhds_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝 a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := Filter.ext_iff.1 nhds_bind_nhdsWithin { x | p x } #align eventually_nhds_nhds_within eventually_nhds_nhdsWithin theorem eventually_nhdsWithin_iff {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ x in 𝓝[s] a, p x) ↔ ∀ᶠ x in 𝓝 a, x ∈ s → p x := eventually_inf_principal #align eventually_nhds_within_iff eventually_nhdsWithin_iff theorem frequently_nhdsWithin_iff {z : α} {s : Set α} {p : α → Prop} : (∃ᶠ x in 𝓝[s] z, p x) ↔ ∃ᶠ x in 𝓝 z, p x ∧ x ∈ s := frequently_inf_principal.trans <| by simp only [and_comm] #align frequently_nhds_within_iff frequently_nhdsWithin_iff theorem mem_closure_ne_iff_frequently_within {z : α} {s : Set α} : z ∈ closure (s \ {z}) ↔ ∃ᶠ x in 𝓝[≠] z, x ∈ s := by simp [mem_closure_iff_frequently, frequently_nhdsWithin_iff] #align mem_closure_ne_iff_frequently_within mem_closure_ne_iff_frequently_within @[simp] theorem eventually_nhdsWithin_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝[s] a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := by refine ⟨fun h => ?_, fun h => (eventually_nhds_nhdsWithin.2 h).filter_mono inf_le_left⟩ simp only [eventually_nhdsWithin_iff] at h ⊢ exact h.mono fun x hx hxs => (hx hxs).self_of_nhds hxs #align eventually_nhds_within_nhds_within eventually_nhdsWithin_nhdsWithin theorem nhdsWithin_eq (a : α) (s : Set α) : 𝓝[s] a = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (t ∩ s) := ((nhds_basis_opens a).inf_principal s).eq_biInf #align nhds_within_eq nhdsWithin_eq theorem nhdsWithin_univ (a : α) : 𝓝[Set.univ] a = 𝓝 a := by rw [nhdsWithin, principal_univ, inf_top_eq] #align nhds_within_univ nhdsWithin_univ theorem nhdsWithin_hasBasis {p : β → Prop} {s : β → Set α} {a : α} (h : (𝓝 a).HasBasis p s) (t : Set α) : (𝓝[t] a).HasBasis p fun i => s i ∩ t := h.inf_principal t #align nhds_within_has_basis nhdsWithin_hasBasis theorem nhdsWithin_basis_open (a : α) (t : Set α) : (𝓝[t] a).HasBasis (fun u => a ∈ u ∧ IsOpen u) fun u => u ∩ t := nhdsWithin_hasBasis (nhds_basis_opens a) t #align nhds_within_basis_open nhdsWithin_basis_open theorem mem_nhdsWithin {t : Set α} {a : α} {s : Set α} : t ∈ 𝓝[s] a ↔ ∃ u, IsOpen u ∧ a ∈ u ∧ u ∩ s ⊆ t := by simpa only [and_assoc, and_left_comm] using (nhdsWithin_basis_open a s).mem_iff #align mem_nhds_within mem_nhdsWithin theorem mem_nhdsWithin_iff_exists_mem_nhds_inter {t : Set α} {a : α} {s : Set α} : t ∈ 𝓝[s] a ↔ ∃ u ∈ 𝓝 a, u ∩ s ⊆ t := (nhdsWithin_hasBasis (𝓝 a).basis_sets s).mem_iff #align mem_nhds_within_iff_exists_mem_nhds_inter mem_nhdsWithin_iff_exists_mem_nhds_inter theorem diff_mem_nhdsWithin_compl {x : α} {s : Set α} (hs : s ∈ 𝓝 x) (t : Set α) : s \ t ∈ 𝓝[tᶜ] x := diff_mem_inf_principal_compl hs t #align diff_mem_nhds_within_compl diff_mem_nhdsWithin_compl theorem diff_mem_nhdsWithin_diff {x : α} {s t : Set α} (hs : s ∈ 𝓝[t] x) (t' : Set α) : s \ t' ∈ 𝓝[t \ t'] x := by rw [nhdsWithin, diff_eq, diff_eq, ← inf_principal, ← inf_assoc] exact inter_mem_inf hs (mem_principal_self _) #align diff_mem_nhds_within_diff diff_mem_nhdsWithin_diff theorem nhds_of_nhdsWithin_of_nhds {s t : Set α} {a : α} (h1 : s ∈ 𝓝 a) (h2 : t ∈ 𝓝[s] a) : t ∈ 𝓝 a := by rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.mp h2 with ⟨_, Hw, hw⟩ exact (𝓝 a).sets_of_superset ((𝓝 a).inter_sets Hw h1) hw #align nhds_of_nhds_within_of_nhds nhds_of_nhdsWithin_of_nhds theorem mem_nhdsWithin_iff_eventually {s t : Set α} {x : α} : t ∈ 𝓝[s] x ↔ ∀ᶠ y in 𝓝 x, y ∈ s → y ∈ t := eventually_inf_principal #align mem_nhds_within_iff_eventually mem_nhdsWithin_iff_eventually theorem mem_nhdsWithin_iff_eventuallyEq {s t : Set α} {x : α} : t ∈ 𝓝[s] x ↔ s =ᶠ[𝓝 x] (s ∩ t : Set α) := by simp_rw [mem_nhdsWithin_iff_eventually, eventuallyEq_set, mem_inter_iff, iff_self_and] #align mem_nhds_within_iff_eventually_eq mem_nhdsWithin_iff_eventuallyEq theorem nhdsWithin_eq_iff_eventuallyEq {s t : Set α} {x : α} : 𝓝[s] x = 𝓝[t] x ↔ s =ᶠ[𝓝 x] t := set_eventuallyEq_iff_inf_principal.symm #align nhds_within_eq_iff_eventually_eq nhdsWithin_eq_iff_eventuallyEq theorem nhdsWithin_le_iff {s t : Set α} {x : α} : 𝓝[s] x ≤ 𝓝[t] x ↔ t ∈ 𝓝[s] x := set_eventuallyLE_iff_inf_principal_le.symm.trans set_eventuallyLE_iff_mem_inf_principal #align nhds_within_le_iff nhdsWithin_le_iff -- Porting note: golfed, dropped an unneeded assumption theorem preimage_nhdsWithin_coinduced' {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t) (hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) : π ⁻¹' s ∈ 𝓝[t] a := by lift a to t using h replace hs : (fun x : t => π x) ⁻¹' s ∈ 𝓝 a := preimage_nhds_coinduced hs rwa [← map_nhds_subtype_val, mem_map] #align preimage_nhds_within_coinduced' preimage_nhdsWithin_coinduced'ₓ theorem mem_nhdsWithin_of_mem_nhds {s t : Set α} {a : α} (h : s ∈ 𝓝 a) : s ∈ 𝓝[t] a := mem_inf_of_left h #align mem_nhds_within_of_mem_nhds mem_nhdsWithin_of_mem_nhds theorem self_mem_nhdsWithin {a : α} {s : Set α} : s ∈ 𝓝[s] a := mem_inf_of_right (mem_principal_self s) #align self_mem_nhds_within self_mem_nhdsWithin theorem eventually_mem_nhdsWithin {a : α} {s : Set α} : ∀ᶠ x in 𝓝[s] a, x ∈ s := self_mem_nhdsWithin #align eventually_mem_nhds_within eventually_mem_nhdsWithin theorem inter_mem_nhdsWithin (s : Set α) {t : Set α} {a : α} (h : t ∈ 𝓝 a) : s ∩ t ∈ 𝓝[s] a := inter_mem self_mem_nhdsWithin (mem_inf_of_left h) #align inter_mem_nhds_within inter_mem_nhdsWithin theorem nhdsWithin_mono (a : α) {s t : Set α} (h : s ⊆ t) : 𝓝[s] a ≤ 𝓝[t] a := inf_le_inf_left _ (principal_mono.mpr h) #align nhds_within_mono nhdsWithin_mono theorem pure_le_nhdsWithin {a : α} {s : Set α} (ha : a ∈ s) : pure a ≤ 𝓝[s] a := le_inf (pure_le_nhds a) (le_principal_iff.2 ha) #align pure_le_nhds_within pure_le_nhdsWithin theorem mem_of_mem_nhdsWithin {a : α} {s t : Set α} (ha : a ∈ s) (ht : t ∈ 𝓝[s] a) : a ∈ t := pure_le_nhdsWithin ha ht #align mem_of_mem_nhds_within mem_of_mem_nhdsWithin theorem Filter.Eventually.self_of_nhdsWithin {p : α → Prop} {s : Set α} {x : α} (h : ∀ᶠ y in 𝓝[s] x, p y) (hx : x ∈ s) : p x := mem_of_mem_nhdsWithin hx h #align filter.eventually.self_of_nhds_within Filter.Eventually.self_of_nhdsWithin theorem tendsto_const_nhdsWithin {l : Filter β} {s : Set α} {a : α} (ha : a ∈ s) : Tendsto (fun _ : β => a) l (𝓝[s] a) := tendsto_const_pure.mono_right <| pure_le_nhdsWithin ha #align tendsto_const_nhds_within tendsto_const_nhdsWithin theorem nhdsWithin_restrict'' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝[s] a) : 𝓝[s] a = 𝓝[s ∩ t] a := le_antisymm (le_inf inf_le_left (le_principal_iff.mpr (inter_mem self_mem_nhdsWithin h))) (inf_le_inf_left _ (principal_mono.mpr Set.inter_subset_left)) #align nhds_within_restrict'' nhdsWithin_restrict'' theorem nhdsWithin_restrict' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝 a) : 𝓝[s] a = 𝓝[s ∩ t] a := nhdsWithin_restrict'' s <| mem_inf_of_left h #align nhds_within_restrict' nhdsWithin_restrict' theorem nhdsWithin_restrict {a : α} (s : Set α) {t : Set α} (h₀ : a ∈ t) (h₁ : IsOpen t) : 𝓝[s] a = 𝓝[s ∩ t] a := nhdsWithin_restrict' s (IsOpen.mem_nhds h₁ h₀) #align nhds_within_restrict nhdsWithin_restrict theorem nhdsWithin_le_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[t] a ≤ 𝓝[s] a := nhdsWithin_le_iff.mpr h #align nhds_within_le_of_mem nhdsWithin_le_of_mem theorem nhdsWithin_le_nhds {a : α} {s : Set α} : 𝓝[s] a ≤ 𝓝 a := by rw [← nhdsWithin_univ] apply nhdsWithin_le_of_mem exact univ_mem #align nhds_within_le_nhds nhdsWithin_le_nhds theorem nhdsWithin_eq_nhdsWithin' {a : α} {s t u : Set α} (hs : s ∈ 𝓝 a) (h₂ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict' t hs, nhdsWithin_restrict' u hs, h₂] #align nhds_within_eq_nhds_within' nhdsWithin_eq_nhdsWithin' theorem nhdsWithin_eq_nhdsWithin {a : α} {s t u : Set α} (h₀ : a ∈ s) (h₁ : IsOpen s) (h₂ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict t h₀ h₁, nhdsWithin_restrict u h₀ h₁, h₂] #align nhds_within_eq_nhds_within nhdsWithin_eq_nhdsWithin @[simp] theorem nhdsWithin_eq_nhds {a : α} {s : Set α} : 𝓝[s] a = 𝓝 a ↔ s ∈ 𝓝 a := inf_eq_left.trans le_principal_iff #align nhds_within_eq_nhds nhdsWithin_eq_nhds theorem IsOpen.nhdsWithin_eq {a : α} {s : Set α} (h : IsOpen s) (ha : a ∈ s) : 𝓝[s] a = 𝓝 a := nhdsWithin_eq_nhds.2 <| h.mem_nhds ha #align is_open.nhds_within_eq IsOpen.nhdsWithin_eq theorem preimage_nhds_within_coinduced {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t) (ht : IsOpen t) (hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) : π ⁻¹' s ∈ 𝓝 a := by rw [← ht.nhdsWithin_eq h] exact preimage_nhdsWithin_coinduced' h hs #align preimage_nhds_within_coinduced preimage_nhds_within_coinduced @[simp] theorem nhdsWithin_empty (a : α) : 𝓝[∅] a = ⊥ := by rw [nhdsWithin, principal_empty, inf_bot_eq] #align nhds_within_empty nhdsWithin_empty theorem nhdsWithin_union (a : α) (s t : Set α) : 𝓝[s ∪ t] a = 𝓝[s] a ⊔ 𝓝[t] a := by delta nhdsWithin rw [← inf_sup_left, sup_principal] #align nhds_within_union nhdsWithin_union theorem nhdsWithin_biUnion {ι} {I : Set ι} (hI : I.Finite) (s : ι → Set α) (a : α) : 𝓝[⋃ i ∈ I, s i] a = ⨆ i ∈ I, 𝓝[s i] a := Set.Finite.induction_on hI (by simp) fun _ _ hT ↦ by simp only [hT, nhdsWithin_union, iSup_insert, biUnion_insert] #align nhds_within_bUnion nhdsWithin_biUnion theorem nhdsWithin_sUnion {S : Set (Set α)} (hS : S.Finite) (a : α) : 𝓝[⋃₀ S] a = ⨆ s ∈ S, 𝓝[s] a := by rw [sUnion_eq_biUnion, nhdsWithin_biUnion hS] #align nhds_within_sUnion nhdsWithin_sUnion theorem nhdsWithin_iUnion {ι} [Finite ι] (s : ι → Set α) (a : α) : 𝓝[⋃ i, s i] a = ⨆ i, 𝓝[s i] a := by rw [← sUnion_range, nhdsWithin_sUnion (finite_range s), iSup_range] #align nhds_within_Union nhdsWithin_iUnion theorem nhdsWithin_inter (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓝[t] a := by delta nhdsWithin rw [inf_left_comm, inf_assoc, inf_principal, ← inf_assoc, inf_idem] #align nhds_within_inter nhdsWithin_inter theorem nhdsWithin_inter' (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓟 t := by delta nhdsWithin rw [← inf_principal, inf_assoc] #align nhds_within_inter' nhdsWithin_inter' theorem nhdsWithin_inter_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[s ∩ t] a = 𝓝[t] a := by rw [nhdsWithin_inter, inf_eq_right] exact nhdsWithin_le_of_mem h #align nhds_within_inter_of_mem nhdsWithin_inter_of_mem theorem nhdsWithin_inter_of_mem' {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) : 𝓝[s ∩ t] a = 𝓝[s] a := by rw [inter_comm, nhdsWithin_inter_of_mem h] #align nhds_within_inter_of_mem' nhdsWithin_inter_of_mem' @[simp] theorem nhdsWithin_singleton (a : α) : 𝓝[{a}] a = pure a := by rw [nhdsWithin, principal_singleton, inf_eq_right.2 (pure_le_nhds a)] #align nhds_within_singleton nhdsWithin_singleton @[simp] theorem nhdsWithin_insert (a : α) (s : Set α) : 𝓝[insert a s] a = pure a ⊔ 𝓝[s] a := by rw [← singleton_union, nhdsWithin_union, nhdsWithin_singleton] #align nhds_within_insert nhdsWithin_insert theorem mem_nhdsWithin_insert {a : α} {s t : Set α} : t ∈ 𝓝[insert a s] a ↔ a ∈ t ∧ t ∈ 𝓝[s] a := by simp #align mem_nhds_within_insert mem_nhdsWithin_insert theorem insert_mem_nhdsWithin_insert {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) : insert a t ∈ 𝓝[insert a s] a := by simp [mem_of_superset h] #align insert_mem_nhds_within_insert insert_mem_nhdsWithin_insert theorem insert_mem_nhds_iff {a : α} {s : Set α} : insert a s ∈ 𝓝 a ↔ s ∈ 𝓝[≠] a := by simp only [nhdsWithin, mem_inf_principal, mem_compl_iff, mem_singleton_iff, or_iff_not_imp_left, insert_def] #align insert_mem_nhds_iff insert_mem_nhds_iff @[simp] theorem nhdsWithin_compl_singleton_sup_pure (a : α) : 𝓝[≠] a ⊔ pure a = 𝓝 a := by rw [← nhdsWithin_singleton, ← nhdsWithin_union, compl_union_self, nhdsWithin_univ] #align nhds_within_compl_singleton_sup_pure nhdsWithin_compl_singleton_sup_pure theorem nhdsWithin_prod {α : Type*} [TopologicalSpace α] {β : Type*} [TopologicalSpace β] {s u : Set α} {t v : Set β} {a : α} {b : β} (hu : u ∈ 𝓝[s] a) (hv : v ∈ 𝓝[t] b) : u ×ˢ v ∈ 𝓝[s ×ˢ t] (a, b) := by rw [nhdsWithin_prod_eq] exact prod_mem_prod hu hv #align nhds_within_prod nhdsWithin_prod theorem nhdsWithin_pi_eq' {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi I s] x = ⨅ i, comap (fun x => x i) (𝓝 (x i) ⊓ ⨅ (_ : i ∈ I), 𝓟 (s i)) := by simp only [nhdsWithin, nhds_pi, Filter.pi, comap_inf, comap_iInf, pi_def, comap_principal, ← iInf_principal_finite hI, ← iInf_inf_eq] #align nhds_within_pi_eq' nhdsWithin_pi_eq' theorem nhdsWithin_pi_eq {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi I s] x = (⨅ i ∈ I, comap (fun x => x i) (𝓝[s i] x i)) ⊓ ⨅ (i) (_ : i ∉ I), comap (fun x => x i) (𝓝 (x i)) := by simp only [nhdsWithin, nhds_pi, Filter.pi, pi_def, ← iInf_principal_finite hI, comap_inf, comap_principal, eval] rw [iInf_split _ fun i => i ∈ I, inf_right_comm] simp only [iInf_inf_eq] #align nhds_within_pi_eq nhdsWithin_pi_eq theorem nhdsWithin_pi_univ_eq {ι : Type*} {α : ι → Type*} [Finite ι] [∀ i, TopologicalSpace (α i)] (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi univ s] x = ⨅ i, comap (fun x => x i) (𝓝[s i] x i) := by simpa [nhdsWithin] using nhdsWithin_pi_eq finite_univ s x #align nhds_within_pi_univ_eq nhdsWithin_pi_univ_eq theorem nhdsWithin_pi_eq_bot {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : 𝓝[pi I s] x = ⊥ ↔ ∃ i ∈ I, 𝓝[s i] x i = ⊥ := by simp only [nhdsWithin, nhds_pi, pi_inf_principal_pi_eq_bot] #align nhds_within_pi_eq_bot nhdsWithin_pi_eq_bot theorem nhdsWithin_pi_neBot {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : (𝓝[pi I s] x).NeBot ↔ ∀ i ∈ I, (𝓝[s i] x i).NeBot := by simp [neBot_iff, nhdsWithin_pi_eq_bot] #align nhds_within_pi_ne_bot nhdsWithin_pi_neBot theorem Filter.Tendsto.piecewise_nhdsWithin {f g : α → β} {t : Set α} [∀ x, Decidable (x ∈ t)] {a : α} {s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ t] a) l) (h₁ : Tendsto g (𝓝[s ∩ tᶜ] a) l) : Tendsto (piecewise t f g) (𝓝[s] a) l := by apply Tendsto.piecewise <;> rwa [← nhdsWithin_inter'] #align filter.tendsto.piecewise_nhds_within Filter.Tendsto.piecewise_nhdsWithin theorem Filter.Tendsto.if_nhdsWithin {f g : α → β} {p : α → Prop} [DecidablePred p] {a : α} {s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ { x | p x }] a) l) (h₁ : Tendsto g (𝓝[s ∩ { x | ¬p x }] a) l) : Tendsto (fun x => if p x then f x else g x) (𝓝[s] a) l := h₀.piecewise_nhdsWithin h₁ #align filter.tendsto.if_nhds_within Filter.Tendsto.if_nhdsWithin theorem map_nhdsWithin (f : α → β) (a : α) (s : Set α) : map f (𝓝[s] a) = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (f '' (t ∩ s)) := ((nhdsWithin_basis_open a s).map f).eq_biInf #align map_nhds_within map_nhdsWithin theorem tendsto_nhdsWithin_mono_left {f : α → β} {a : α} {s t : Set α} {l : Filter β} (hst : s ⊆ t) (h : Tendsto f (𝓝[t] a) l) : Tendsto f (𝓝[s] a) l := h.mono_left <| nhdsWithin_mono a hst #align tendsto_nhds_within_mono_left tendsto_nhdsWithin_mono_left theorem tendsto_nhdsWithin_mono_right {f : β → α} {l : Filter β} {a : α} {s t : Set α} (hst : s ⊆ t) (h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝[t] a) := h.mono_right (nhdsWithin_mono a hst) #align tendsto_nhds_within_mono_right tendsto_nhdsWithin_mono_right theorem tendsto_nhdsWithin_of_tendsto_nhds {f : α → β} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f (𝓝 a) l) : Tendsto f (𝓝[s] a) l := h.mono_left inf_le_left #align tendsto_nhds_within_of_tendsto_nhds tendsto_nhdsWithin_of_tendsto_nhds theorem eventually_mem_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f l (𝓝[s] a)) : ∀ᶠ i in l, f i ∈ s := by simp_rw [nhdsWithin_eq, tendsto_iInf, mem_setOf_eq, tendsto_principal, mem_inter_iff, eventually_and] at h exact (h univ ⟨mem_univ a, isOpen_univ⟩).2 #align eventually_mem_of_tendsto_nhds_within eventually_mem_of_tendsto_nhdsWithin theorem tendsto_nhds_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝 a) := h.mono_right nhdsWithin_le_nhds #align tendsto_nhds_of_tendsto_nhds_within tendsto_nhds_of_tendsto_nhdsWithin theorem nhdsWithin_neBot_of_mem {s : Set α} {x : α} (hx : x ∈ s) : NeBot (𝓝[s] x) := mem_closure_iff_nhdsWithin_neBot.1 <| subset_closure hx #align nhds_within_ne_bot_of_mem nhdsWithin_neBot_of_mem theorem IsClosed.mem_of_nhdsWithin_neBot {s : Set α} (hs : IsClosed s) {x : α} (hx : NeBot <| 𝓝[s] x) : x ∈ s := hs.closure_eq ▸ mem_closure_iff_nhdsWithin_neBot.2 hx #align is_closed.mem_of_nhds_within_ne_bot IsClosed.mem_of_nhdsWithin_neBot theorem DenseRange.nhdsWithin_neBot {ι : Type*} {f : ι → α} (h : DenseRange f) (x : α) : NeBot (𝓝[range f] x) := mem_closure_iff_clusterPt.1 (h x) #align dense_range.nhds_within_ne_bot DenseRange.nhdsWithin_neBot theorem mem_closure_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : x ∈ closure (pi I s) ↔ ∀ i ∈ I, x i ∈ closure (s i) := by simp only [mem_closure_iff_nhdsWithin_neBot, nhdsWithin_pi_neBot] #align mem_closure_pi mem_closure_pi theorem closure_pi_set {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] (I : Set ι) (s : ∀ i, Set (α i)) : closure (pi I s) = pi I fun i => closure (s i) := Set.ext fun _ => mem_closure_pi #align closure_pi_set closure_pi_set theorem dense_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {s : ∀ i, Set (α i)} (I : Set ι) (hs : ∀ i ∈ I, Dense (s i)) : Dense (pi I s) := by simp only [dense_iff_closure_eq, closure_pi_set, pi_congr rfl fun i hi => (hs i hi).closure_eq, pi_univ] #align dense_pi dense_pi theorem eventuallyEq_nhdsWithin_iff {f g : α → β} {s : Set α} {a : α} : f =ᶠ[𝓝[s] a] g ↔ ∀ᶠ x in 𝓝 a, x ∈ s → f x = g x := mem_inf_principal #align eventually_eq_nhds_within_iff eventuallyEq_nhdsWithin_iff theorem eventuallyEq_nhdsWithin_of_eqOn {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) : f =ᶠ[𝓝[s] a] g := mem_inf_of_right h #align eventually_eq_nhds_within_of_eq_on eventuallyEq_nhdsWithin_of_eqOn theorem Set.EqOn.eventuallyEq_nhdsWithin {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) : f =ᶠ[𝓝[s] a] g := eventuallyEq_nhdsWithin_of_eqOn h #align set.eq_on.eventually_eq_nhds_within Set.EqOn.eventuallyEq_nhdsWithin theorem tendsto_nhdsWithin_congr {f g : α → β} {s : Set α} {a : α} {l : Filter β} (hfg : ∀ x ∈ s, f x = g x) (hf : Tendsto f (𝓝[s] a) l) : Tendsto g (𝓝[s] a) l := (tendsto_congr' <| eventuallyEq_nhdsWithin_of_eqOn hfg).1 hf #align tendsto_nhds_within_congr tendsto_nhdsWithin_congr theorem eventually_nhdsWithin_of_forall {s : Set α} {a : α} {p : α → Prop} (h : ∀ x ∈ s, p x) : ∀ᶠ x in 𝓝[s] a, p x := mem_inf_of_right h #align eventually_nhds_within_of_forall eventually_nhdsWithin_of_forall theorem tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within {a : α} {l : Filter β} {s : Set α} (f : β → α) (h1 : Tendsto f l (𝓝 a)) (h2 : ∀ᶠ x in l, f x ∈ s) : Tendsto f l (𝓝[s] a) := tendsto_inf.2 ⟨h1, tendsto_principal.2 h2⟩ #align tendsto_nhds_within_of_tendsto_nhds_of_eventually_within tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within theorem tendsto_nhdsWithin_iff {a : α} {l : Filter β} {s : Set α} {f : β → α} : Tendsto f l (𝓝[s] a) ↔ Tendsto f l (𝓝 a) ∧ ∀ᶠ n in l, f n ∈ s := ⟨fun h => ⟨tendsto_nhds_of_tendsto_nhdsWithin h, eventually_mem_of_tendsto_nhdsWithin h⟩, fun h => tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ h.1 h.2⟩ #align tendsto_nhds_within_iff tendsto_nhdsWithin_iff @[simp] theorem tendsto_nhdsWithin_range {a : α} {l : Filter β} {f : β → α} : Tendsto f l (𝓝[range f] a) ↔ Tendsto f l (𝓝 a) := ⟨fun h => h.mono_right inf_le_left, fun h => tendsto_inf.2 ⟨h, tendsto_principal.2 <| eventually_of_forall mem_range_self⟩⟩ #align tendsto_nhds_within_range tendsto_nhdsWithin_range theorem Filter.EventuallyEq.eq_of_nhdsWithin {s : Set α} {f g : α → β} {a : α} (h : f =ᶠ[𝓝[s] a] g) (hmem : a ∈ s) : f a = g a := h.self_of_nhdsWithin hmem #align filter.eventually_eq.eq_of_nhds_within Filter.EventuallyEq.eq_of_nhdsWithin theorem eventually_nhdsWithin_of_eventually_nhds {α : Type*} [TopologicalSpace α] {s : Set α} {a : α} {p : α → Prop} (h : ∀ᶠ x in 𝓝 a, p x) : ∀ᶠ x in 𝓝[s] a, p x := mem_nhdsWithin_of_mem_nhds h #align eventually_nhds_within_of_eventually_nhds eventually_nhdsWithin_of_eventually_nhds theorem mem_nhdsWithin_subtype {s : Set α} {a : { x // x ∈ s }} {t u : Set { x // x ∈ s }} : t ∈ 𝓝[u] a ↔ t ∈ comap ((↑) : s → α) (𝓝[(↑) '' u] a) := by rw [nhdsWithin, nhds_subtype, principal_subtype, ← comap_inf, ← nhdsWithin] #align mem_nhds_within_subtype mem_nhdsWithin_subtype theorem nhdsWithin_subtype (s : Set α) (a : { x // x ∈ s }) (t : Set { x // x ∈ s }) : 𝓝[t] a = comap ((↑) : s → α) (𝓝[(↑) '' t] a) := Filter.ext fun _ => mem_nhdsWithin_subtype #align nhds_within_subtype nhdsWithin_subtype theorem nhdsWithin_eq_map_subtype_coe {s : Set α} {a : α} (h : a ∈ s) : 𝓝[s] a = map ((↑) : s → α) (𝓝 ⟨a, h⟩) := (map_nhds_subtype_val ⟨a, h⟩).symm #align nhds_within_eq_map_subtype_coe nhdsWithin_eq_map_subtype_coe theorem mem_nhds_subtype_iff_nhdsWithin {s : Set α} {a : s} {t : Set s} : t ∈ 𝓝 a ↔ (↑) '' t ∈ 𝓝[s] (a : α) := by rw [← map_nhds_subtype_val, image_mem_map_iff Subtype.val_injective] #align mem_nhds_subtype_iff_nhds_within mem_nhds_subtype_iff_nhdsWithin theorem preimage_coe_mem_nhds_subtype {s t : Set α} {a : s} : (↑) ⁻¹' t ∈ 𝓝 a ↔ t ∈ 𝓝[s] ↑a := by rw [← map_nhds_subtype_val, mem_map] #align preimage_coe_mem_nhds_subtype preimage_coe_mem_nhds_subtype theorem eventually_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) : (∀ᶠ x : s in 𝓝 a, P x) ↔ ∀ᶠ x in 𝓝[s] a, P x := preimage_coe_mem_nhds_subtype theorem frequently_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) : (∃ᶠ x : s in 𝓝 a, P x) ↔ ∃ᶠ x in 𝓝[s] a, P x := eventually_nhds_subtype_iff s a (¬ P ·) |>.not theorem tendsto_nhdsWithin_iff_subtype {s : Set α} {a : α} (h : a ∈ s) (f : α → β) (l : Filter β) : Tendsto f (𝓝[s] a) l ↔ Tendsto (s.restrict f) (𝓝 ⟨a, h⟩) l := by rw [nhdsWithin_eq_map_subtype_coe h, tendsto_map'_iff]; rfl #align tendsto_nhds_within_iff_subtype tendsto_nhdsWithin_iff_subtype variable [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ] theorem ContinuousWithinAt.tendsto {f : α → β} {s : Set α} {x : α} (h : ContinuousWithinAt f s x) : Tendsto f (𝓝[s] x) (𝓝 (f x)) := h #align continuous_within_at.tendsto ContinuousWithinAt.tendsto theorem ContinuousOn.continuousWithinAt {f : α → β} {s : Set α} {x : α} (hf : ContinuousOn f s) (hx : x ∈ s) : ContinuousWithinAt f s x := hf x hx #align continuous_on.continuous_within_at ContinuousOn.continuousWithinAt theorem continuousWithinAt_univ (f : α → β) (x : α) : ContinuousWithinAt f Set.univ x ↔ ContinuousAt f x := by rw [ContinuousAt, ContinuousWithinAt, nhdsWithin_univ] #align continuous_within_at_univ continuousWithinAt_univ theorem continuous_iff_continuousOn_univ {f : α → β} : Continuous f ↔ ContinuousOn f univ := by simp [continuous_iff_continuousAt, ContinuousOn, ContinuousAt, ContinuousWithinAt, nhdsWithin_univ] #align continuous_iff_continuous_on_univ continuous_iff_continuousOn_univ theorem continuousWithinAt_iff_continuousAt_restrict (f : α → β) {x : α} {s : Set α} (h : x ∈ s) : ContinuousWithinAt f s x ↔ ContinuousAt (s.restrict f) ⟨x, h⟩ := tendsto_nhdsWithin_iff_subtype h f _ #align continuous_within_at_iff_continuous_at_restrict continuousWithinAt_iff_continuousAt_restrict theorem ContinuousWithinAt.tendsto_nhdsWithin {f : α → β} {x : α} {s : Set α} {t : Set β} (h : ContinuousWithinAt f s x) (ht : MapsTo f s t) : Tendsto f (𝓝[s] x) (𝓝[t] f x) := tendsto_inf.2 ⟨h, tendsto_principal.2 <| mem_inf_of_right <| mem_principal.2 <| ht⟩ #align continuous_within_at.tendsto_nhds_within ContinuousWithinAt.tendsto_nhdsWithin theorem ContinuousWithinAt.tendsto_nhdsWithin_image {f : α → β} {x : α} {s : Set α} (h : ContinuousWithinAt f s x) : Tendsto f (𝓝[s] x) (𝓝[f '' s] f x) := h.tendsto_nhdsWithin (mapsTo_image _ _) #align continuous_within_at.tendsto_nhds_within_image ContinuousWithinAt.tendsto_nhdsWithin_image theorem ContinuousWithinAt.prod_map {f : α → γ} {g : β → δ} {s : Set α} {t : Set β} {x : α} {y : β} (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g t y) : ContinuousWithinAt (Prod.map f g) (s ×ˢ t) (x, y) := by unfold ContinuousWithinAt at * rw [nhdsWithin_prod_eq, Prod.map, nhds_prod_eq] exact hf.prod_map hg #align continuous_within_at.prod_map ContinuousWithinAt.prod_map theorem continuousWithinAt_prod_of_discrete_left [DiscreteTopology α] {f : α × β → γ} {s : Set (α × β)} {x : α × β} : ContinuousWithinAt f s x ↔ ContinuousWithinAt (f ⟨x.1, ·⟩) {b | (x.1, b) ∈ s} x.2 := by rw [← x.eta]; simp_rw [ContinuousWithinAt, nhdsWithin, nhds_prod_eq, nhds_discrete, pure_prod, ← map_inf_principal_preimage]; rfl theorem continuousWithinAt_prod_of_discrete_right [DiscreteTopology β] {f : α × β → γ} {s : Set (α × β)} {x : α × β} : ContinuousWithinAt f s x ↔ ContinuousWithinAt (f ⟨·, x.2⟩) {a | (a, x.2) ∈ s} x.1 := by rw [← x.eta]; simp_rw [ContinuousWithinAt, nhdsWithin, nhds_prod_eq, nhds_discrete, prod_pure, ← map_inf_principal_preimage]; rfl theorem continuousAt_prod_of_discrete_left [DiscreteTopology α] {f : α × β → γ} {x : α × β} : ContinuousAt f x ↔ ContinuousAt (f ⟨x.1, ·⟩) x.2 := by simp_rw [← continuousWithinAt_univ]; exact continuousWithinAt_prod_of_discrete_left theorem continuousAt_prod_of_discrete_right [DiscreteTopology β] {f : α × β → γ} {x : α × β} : ContinuousAt f x ↔ ContinuousAt (f ⟨·, x.2⟩) x.1 := by simp_rw [← continuousWithinAt_univ]; exact continuousWithinAt_prod_of_discrete_right theorem continuousOn_prod_of_discrete_left [DiscreteTopology α] {f : α × β → γ} {s : Set (α × β)} : ContinuousOn f s ↔ ∀ a, ContinuousOn (f ⟨a, ·⟩) {b | (a, b) ∈ s} := by simp_rw [ContinuousOn, Prod.forall, continuousWithinAt_prod_of_discrete_left]; rfl theorem continuousOn_prod_of_discrete_right [DiscreteTopology β] {f : α × β → γ} {s : Set (α × β)} : ContinuousOn f s ↔ ∀ b, ContinuousOn (f ⟨·, b⟩) {a | (a, b) ∈ s} := by simp_rw [ContinuousOn, Prod.forall, continuousWithinAt_prod_of_discrete_right]; apply forall_swap theorem continuous_prod_of_discrete_left [DiscreteTopology α] {f : α × β → γ} : Continuous f ↔ ∀ a, Continuous (f ⟨a, ·⟩) := by simp_rw [continuous_iff_continuousOn_univ]; exact continuousOn_prod_of_discrete_left theorem continuous_prod_of_discrete_right [DiscreteTopology β] {f : α × β → γ} : Continuous f ↔ ∀ b, Continuous (f ⟨·, b⟩) := by simp_rw [continuous_iff_continuousOn_univ]; exact continuousOn_prod_of_discrete_right theorem isOpenMap_prod_of_discrete_left [DiscreteTopology α] {f : α × β → γ} : IsOpenMap f ↔ ∀ a, IsOpenMap (f ⟨a, ·⟩) := by simp_rw [isOpenMap_iff_nhds_le, Prod.forall, nhds_prod_eq, nhds_discrete, pure_prod, map_map] rfl theorem isOpenMap_prod_of_discrete_right [DiscreteTopology β] {f : α × β → γ} : IsOpenMap f ↔ ∀ b, IsOpenMap (f ⟨·, b⟩) := by simp_rw [isOpenMap_iff_nhds_le, Prod.forall, forall_swap (α := α) (β := β), nhds_prod_eq, nhds_discrete, prod_pure, map_map]; rfl theorem continuousWithinAt_pi {ι : Type*} {π : ι → Type*} [∀ i, TopologicalSpace (π i)] {f : α → ∀ i, π i} {s : Set α} {x : α} : ContinuousWithinAt f s x ↔ ∀ i, ContinuousWithinAt (fun y => f y i) s x := tendsto_pi_nhds #align continuous_within_at_pi continuousWithinAt_pi theorem continuousOn_pi {ι : Type*} {π : ι → Type*} [∀ i, TopologicalSpace (π i)] {f : α → ∀ i, π i} {s : Set α} : ContinuousOn f s ↔ ∀ i, ContinuousOn (fun y => f y i) s := ⟨fun h i x hx => tendsto_pi_nhds.1 (h x hx) i, fun h x hx => tendsto_pi_nhds.2 fun i => h i x hx⟩ #align continuous_on_pi continuousOn_pi @[fun_prop] theorem continuousOn_pi' {ι : Type*} {π : ι → Type*} [∀ i, TopologicalSpace (π i)] {f : α → ∀ i, π i} {s : Set α} (hf : ∀ i, ContinuousOn (fun y => f y i) s) : ContinuousOn f s := continuousOn_pi.2 hf theorem ContinuousWithinAt.fin_insertNth {n} {π : Fin (n + 1) → Type*} [∀ i, TopologicalSpace (π i)] (i : Fin (n + 1)) {f : α → π i} {a : α} {s : Set α} (hf : ContinuousWithinAt f s a) {g : α → ∀ j : Fin n, π (i.succAbove j)} (hg : ContinuousWithinAt g s a) : ContinuousWithinAt (fun a => i.insertNth (f a) (g a)) s a := hf.tendsto.fin_insertNth i hg #align continuous_within_at.fin_insert_nth ContinuousWithinAt.fin_insertNth nonrec theorem ContinuousOn.fin_insertNth {n} {π : Fin (n + 1) → Type*} [∀ i, TopologicalSpace (π i)] (i : Fin (n + 1)) {f : α → π i} {s : Set α} (hf : ContinuousOn f s) {g : α → ∀ j : Fin n, π (i.succAbove j)} (hg : ContinuousOn g s) : ContinuousOn (fun a => i.insertNth (f a) (g a)) s := fun a ha => (hf a ha).fin_insertNth i (hg a ha) #align continuous_on.fin_insert_nth ContinuousOn.fin_insertNth theorem continuousOn_iff {f : α → β} {s : Set α} : ContinuousOn f s ↔ ∀ x ∈ s, ∀ t : Set β, IsOpen t → f x ∈ t → ∃ u, IsOpen u ∧ x ∈ u ∧ u ∩ s ⊆ f ⁻¹' t := by simp only [ContinuousOn, ContinuousWithinAt, tendsto_nhds, mem_nhdsWithin] #align continuous_on_iff continuousOn_iff theorem continuousOn_iff_continuous_restrict {f : α → β} {s : Set α} : ContinuousOn f s ↔ Continuous (s.restrict f) := by rw [ContinuousOn, continuous_iff_continuousAt]; constructor · rintro h ⟨x, xs⟩ exact (continuousWithinAt_iff_continuousAt_restrict f xs).mp (h x xs) intro h x xs exact (continuousWithinAt_iff_continuousAt_restrict f xs).mpr (h ⟨x, xs⟩) #align continuous_on_iff_continuous_restrict continuousOn_iff_continuous_restrict -- Porting note: 2 new lemmas alias ⟨ContinuousOn.restrict, _⟩ := continuousOn_iff_continuous_restrict theorem ContinuousOn.restrict_mapsTo {f : α → β} {s : Set α} {t : Set β} (hf : ContinuousOn f s) (ht : MapsTo f s t) : Continuous (ht.restrict f s t) := hf.restrict.codRestrict _ theorem continuousOn_iff' {f : α → β} {s : Set α} : ContinuousOn f s ↔ ∀ t : Set β, IsOpen t → ∃ u, IsOpen u ∧ f ⁻¹' t ∩ s = u ∩ s := by have : ∀ t, IsOpen (s.restrict f ⁻¹' t) ↔ ∃ u : Set α, IsOpen u ∧ f ⁻¹' t ∩ s = u ∩ s := by intro t rw [isOpen_induced_iff, Set.restrict_eq, Set.preimage_comp] simp only [Subtype.preimage_coe_eq_preimage_coe_iff] constructor <;> · rintro ⟨u, ou, useq⟩ exact ⟨u, ou, by simpa only [Set.inter_comm, eq_comm] using useq⟩ rw [continuousOn_iff_continuous_restrict, continuous_def]; simp only [this] #align continuous_on_iff' continuousOn_iff' theorem ContinuousOn.mono_dom {α β : Type*} {t₁ t₂ : TopologicalSpace α} {t₃ : TopologicalSpace β} (h₁ : t₂ ≤ t₁) {s : Set α} {f : α → β} (h₂ : @ContinuousOn α β t₁ t₃ f s) : @ContinuousOn α β t₂ t₃ f s := fun x hx _u hu => map_mono (inf_le_inf_right _ <| nhds_mono h₁) (h₂ x hx hu) #align continuous_on.mono_dom ContinuousOn.mono_dom theorem ContinuousOn.mono_rng {α β : Type*} {t₁ : TopologicalSpace α} {t₂ t₃ : TopologicalSpace β} (h₁ : t₂ ≤ t₃) {s : Set α} {f : α → β} (h₂ : @ContinuousOn α β t₁ t₂ f s) : @ContinuousOn α β t₁ t₃ f s := fun x hx _u hu => h₂ x hx <| nhds_mono h₁ hu #align continuous_on.mono_rng ContinuousOn.mono_rng theorem continuousOn_iff_isClosed {f : α → β} {s : Set α} : ContinuousOn f s ↔ ∀ t : Set β, IsClosed t → ∃ u, IsClosed u ∧ f ⁻¹' t ∩ s = u ∩ s := by have : ∀ t, IsClosed (s.restrict f ⁻¹' t) ↔ ∃ u : Set α, IsClosed u ∧ f ⁻¹' t ∩ s = u ∩ s := by intro t rw [isClosed_induced_iff, Set.restrict_eq, Set.preimage_comp] simp only [Subtype.preimage_coe_eq_preimage_coe_iff, eq_comm, Set.inter_comm s] rw [continuousOn_iff_continuous_restrict, continuous_iff_isClosed]; simp only [this] #align continuous_on_iff_is_closed continuousOn_iff_isClosed theorem ContinuousOn.prod_map {f : α → γ} {g : β → δ} {s : Set α} {t : Set β} (hf : ContinuousOn f s) (hg : ContinuousOn g t) : ContinuousOn (Prod.map f g) (s ×ˢ t) := fun ⟨x, y⟩ ⟨hx, hy⟩ => ContinuousWithinAt.prod_map (hf x hx) (hg y hy) #align continuous_on.prod_map ContinuousOn.prod_map theorem continuous_of_cover_nhds {ι : Sort*} {f : α → β} {s : ι → Set α} (hs : ∀ x : α, ∃ i, s i ∈ 𝓝 x) (hf : ∀ i, ContinuousOn f (s i)) : Continuous f := continuous_iff_continuousAt.mpr fun x ↦ let ⟨i, hi⟩ := hs x; by rw [ContinuousAt, ← nhdsWithin_eq_nhds.2 hi] exact hf _ _ (mem_of_mem_nhds hi) #align continuous_of_cover_nhds continuous_of_cover_nhds theorem continuousOn_empty (f : α → β) : ContinuousOn f ∅ := fun _ => False.elim #align continuous_on_empty continuousOn_empty @[simp] theorem continuousOn_singleton (f : α → β) (a : α) : ContinuousOn f {a} := forall_eq.2 <| by simpa only [ContinuousWithinAt, nhdsWithin_singleton, tendsto_pure_left] using fun s => mem_of_mem_nhds #align continuous_on_singleton continuousOn_singleton theorem Set.Subsingleton.continuousOn {s : Set α} (hs : s.Subsingleton) (f : α → β) : ContinuousOn f s := hs.induction_on (continuousOn_empty f) (continuousOn_singleton f) #align set.subsingleton.continuous_on Set.Subsingleton.continuousOn theorem nhdsWithin_le_comap {x : α} {s : Set α} {f : α → β} (ctsf : ContinuousWithinAt f s x) : 𝓝[s] x ≤ comap f (𝓝[f '' s] f x) := ctsf.tendsto_nhdsWithin_image.le_comap #align nhds_within_le_comap nhdsWithin_le_comap @[simp] theorem comap_nhdsWithin_range {α} (f : α → β) (y : β) : comap f (𝓝[range f] y) = comap f (𝓝 y) := comap_inf_principal_range #align comap_nhds_within_range comap_nhdsWithin_range theorem ContinuousWithinAt.mono {f : α → β} {s t : Set α} {x : α} (h : ContinuousWithinAt f t x) (hs : s ⊆ t) : ContinuousWithinAt f s x := h.mono_left (nhdsWithin_mono x hs) #align continuous_within_at.mono ContinuousWithinAt.mono theorem ContinuousWithinAt.mono_of_mem {f : α → β} {s t : Set α} {x : α} (h : ContinuousWithinAt f t x) (hs : t ∈ 𝓝[s] x) : ContinuousWithinAt f s x := h.mono_left (nhdsWithin_le_of_mem hs) #align continuous_within_at.mono_of_mem ContinuousWithinAt.mono_of_mem theorem continuousWithinAt_congr_nhds {f : α → β} {s t : Set α} {x : α} (h : 𝓝[s] x = 𝓝[t] x) : ContinuousWithinAt f s x ↔ ContinuousWithinAt f t x := by simp only [ContinuousWithinAt, h]
Mathlib/Topology/ContinuousOn.lean
751
753
theorem continuousWithinAt_inter' {f : α → β} {s t : Set α} {x : α} (h : t ∈ 𝓝[s] x) : ContinuousWithinAt f (s ∩ t) x ↔ ContinuousWithinAt f s x := by
simp [ContinuousWithinAt, nhdsWithin_restrict'' s h]
import Mathlib.Topology.EMetricSpace.Basic #align_import topology.metric_space.metric_separated from "leanprover-community/mathlib"@"57ac39bd365c2f80589a700f9fbb664d3a1a30c2" open EMetric Set noncomputable section def IsMetricSeparated {X : Type*} [EMetricSpace X] (s t : Set X) := ∃ r, r ≠ 0 ∧ ∀ x ∈ s, ∀ y ∈ t, r ≤ edist x y #align is_metric_separated IsMetricSeparated namespace IsMetricSeparated variable {X : Type*} [EMetricSpace X] {s t : Set X} {x y : X} @[symm] theorem symm (h : IsMetricSeparated s t) : IsMetricSeparated t s := let ⟨r, r0, hr⟩ := h ⟨r, r0, fun y hy x hx => edist_comm x y ▸ hr x hx y hy⟩ #align is_metric_separated.symm IsMetricSeparated.symm theorem comm : IsMetricSeparated s t ↔ IsMetricSeparated t s := ⟨symm, symm⟩ #align is_metric_separated.comm IsMetricSeparated.comm @[simp] theorem empty_left (s : Set X) : IsMetricSeparated ∅ s := ⟨1, one_ne_zero, fun _x => False.elim⟩ #align is_metric_separated.empty_left IsMetricSeparated.empty_left @[simp] theorem empty_right (s : Set X) : IsMetricSeparated s ∅ := (empty_left s).symm #align is_metric_separated.empty_right IsMetricSeparated.empty_right protected theorem disjoint (h : IsMetricSeparated s t) : Disjoint s t := let ⟨r, r0, hr⟩ := h Set.disjoint_left.mpr fun x hx1 hx2 => r0 <| by simpa using hr x hx1 x hx2 #align is_metric_separated.disjoint IsMetricSeparated.disjoint theorem subset_compl_right (h : IsMetricSeparated s t) : s ⊆ tᶜ := fun _ hs ht => h.disjoint.le_bot ⟨hs, ht⟩ #align is_metric_separated.subset_compl_right IsMetricSeparated.subset_compl_right @[mono] theorem mono {s' t'} (hs : s ⊆ s') (ht : t ⊆ t') : IsMetricSeparated s' t' → IsMetricSeparated s t := fun ⟨r, r0, hr⟩ => ⟨r, r0, fun x hx y hy => hr x (hs hx) y (ht hy)⟩ #align is_metric_separated.mono IsMetricSeparated.mono theorem mono_left {s'} (h' : IsMetricSeparated s' t) (hs : s ⊆ s') : IsMetricSeparated s t := h'.mono hs Subset.rfl #align is_metric_separated.mono_left IsMetricSeparated.mono_left theorem mono_right {t'} (h' : IsMetricSeparated s t') (ht : t ⊆ t') : IsMetricSeparated s t := h'.mono Subset.rfl ht #align is_metric_separated.mono_right IsMetricSeparated.mono_right theorem union_left {s'} (h : IsMetricSeparated s t) (h' : IsMetricSeparated s' t) : IsMetricSeparated (s ∪ s') t := by rcases h, h' with ⟨⟨r, r0, hr⟩, ⟨r', r0', hr'⟩⟩ refine ⟨min r r', ?_, fun x hx y hy => hx.elim ?_ ?_⟩ · rw [← pos_iff_ne_zero] at r0 r0' ⊢ exact lt_min r0 r0' · exact fun hx => (min_le_left _ _).trans (hr _ hx _ hy) · exact fun hx => (min_le_right _ _).trans (hr' _ hx _ hy) #align is_metric_separated.union_left IsMetricSeparated.union_left @[simp] theorem union_left_iff {s'} : IsMetricSeparated (s ∪ s') t ↔ IsMetricSeparated s t ∧ IsMetricSeparated s' t := ⟨fun h => ⟨h.mono_left subset_union_left, h.mono_left subset_union_right⟩, fun h => h.1.union_left h.2⟩ #align is_metric_separated.union_left_iff IsMetricSeparated.union_left_iff theorem union_right {t'} (h : IsMetricSeparated s t) (h' : IsMetricSeparated s t') : IsMetricSeparated s (t ∪ t') := (h.symm.union_left h'.symm).symm #align is_metric_separated.union_right IsMetricSeparated.union_right @[simp] theorem union_right_iff {t'} : IsMetricSeparated s (t ∪ t') ↔ IsMetricSeparated s t ∧ IsMetricSeparated s t' := comm.trans <| union_left_iff.trans <| and_congr comm comm #align is_metric_separated.union_right_iff IsMetricSeparated.union_right_iff
Mathlib/Topology/MetricSpace/MetricSeparated.lean
106
109
theorem finite_iUnion_left_iff {ι : Type*} {I : Set ι} (hI : I.Finite) {s : ι → Set X} {t : Set X} : IsMetricSeparated (⋃ i ∈ I, s i) t ↔ ∀ i ∈ I, IsMetricSeparated (s i) t := by
refine Finite.induction_on hI (by simp) @fun i I _ _ hI => ?_ rw [biUnion_insert, forall_mem_insert, union_left_iff, hI]
import Mathlib.RingTheory.Valuation.ValuationRing import Mathlib.RingTheory.Localization.AsSubring import Mathlib.Algebra.Ring.Subring.Pointwise import Mathlib.AlgebraicGeometry.PrimeSpectrum.Basic #align_import ring_theory.valuation.valuation_subring from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" universe u open scoped Classical noncomputable section variable (K : Type u) [Field K] structure ValuationSubring extends Subring K where mem_or_inv_mem' : ∀ x : K, x ∈ carrier ∨ x⁻¹ ∈ carrier #align valuation_subring ValuationSubring namespace ValuationSubring variable {K} variable (A : ValuationSubring K) instance : SetLike (ValuationSubring K) K where coe A := A.toSubring coe_injective' := by intro ⟨_, _⟩ ⟨_, _⟩ h replace h := SetLike.coe_injective' h congr @[simp, nolint simpNF] -- Porting note (#10959): simp cannot prove that theorem mem_carrier (x : K) : x ∈ A.carrier ↔ x ∈ A := Iff.refl _ #align valuation_subring.mem_carrier ValuationSubring.mem_carrier @[simp] theorem mem_toSubring (x : K) : x ∈ A.toSubring ↔ x ∈ A := Iff.refl _ #align valuation_subring.mem_to_subring ValuationSubring.mem_toSubring @[ext] theorem ext (A B : ValuationSubring K) (h : ∀ x, x ∈ A ↔ x ∈ B) : A = B := SetLike.ext h #align valuation_subring.ext ValuationSubring.ext theorem zero_mem : (0 : K) ∈ A := A.toSubring.zero_mem #align valuation_subring.zero_mem ValuationSubring.zero_mem theorem one_mem : (1 : K) ∈ A := A.toSubring.one_mem #align valuation_subring.one_mem ValuationSubring.one_mem theorem add_mem (x y : K) : x ∈ A → y ∈ A → x + y ∈ A := A.toSubring.add_mem #align valuation_subring.add_mem ValuationSubring.add_mem theorem mul_mem (x y : K) : x ∈ A → y ∈ A → x * y ∈ A := A.toSubring.mul_mem #align valuation_subring.mul_mem ValuationSubring.mul_mem theorem neg_mem (x : K) : x ∈ A → -x ∈ A := A.toSubring.neg_mem #align valuation_subring.neg_mem ValuationSubring.neg_mem theorem mem_or_inv_mem (x : K) : x ∈ A ∨ x⁻¹ ∈ A := A.mem_or_inv_mem' _ #align valuation_subring.mem_or_inv_mem ValuationSubring.mem_or_inv_mem instance : SubringClass (ValuationSubring K) K where zero_mem := zero_mem add_mem {_} a b := add_mem _ a b one_mem := one_mem mul_mem {_} a b := mul_mem _ a b neg_mem {_} x := neg_mem _ x theorem toSubring_injective : Function.Injective (toSubring : ValuationSubring K → Subring K) := fun x y h => by cases x; cases y; congr #align valuation_subring.to_subring_injective ValuationSubring.toSubring_injective instance : CommRing A := show CommRing A.toSubring by infer_instance instance : IsDomain A := show IsDomain A.toSubring by infer_instance instance : Top (ValuationSubring K) := Top.mk <| { (⊤ : Subring K) with mem_or_inv_mem' := fun _ => Or.inl trivial } theorem mem_top (x : K) : x ∈ (⊤ : ValuationSubring K) := trivial #align valuation_subring.mem_top ValuationSubring.mem_top theorem le_top : A ≤ ⊤ := fun _a _ha => mem_top _ #align valuation_subring.le_top ValuationSubring.le_top instance : OrderTop (ValuationSubring K) where top := ⊤ le_top := le_top instance : Inhabited (ValuationSubring K) := ⟨⊤⟩ instance : ValuationRing A where cond' a b := by by_cases h : (b : K) = 0 · use 0 left ext simp [h] by_cases h : (a : K) = 0 · use 0; right ext simp [h] cases' A.mem_or_inv_mem (a / b) with hh hh · use ⟨a / b, hh⟩ right ext field_simp · rw [show (a / b : K)⁻¹ = b / a by field_simp] at hh use ⟨b / a, hh⟩; left ext field_simp instance : Algebra A K := show Algebra A.toSubring K by infer_instance -- Porting note: Somehow it cannot find this instance and I'm too lazy to debug. wrong prio? instance localRing : LocalRing A := ValuationRing.localRing A @[simp] theorem algebraMap_apply (a : A) : algebraMap A K a = a := rfl #align valuation_subring.algebra_map_apply ValuationSubring.algebraMap_apply instance : IsFractionRing A K where map_units' := fun ⟨y, hy⟩ => (Units.mk0 (y : K) fun c => nonZeroDivisors.ne_zero hy <| Subtype.ext c).isUnit surj' z := by by_cases h : z = 0; · use (0, 1); simp [h] cases' A.mem_or_inv_mem z with hh hh · use (⟨z, hh⟩, 1); simp · refine ⟨⟨1, ⟨⟨_, hh⟩, ?_⟩⟩, mul_inv_cancel h⟩ exact mem_nonZeroDivisors_iff_ne_zero.2 fun c => h (inv_eq_zero.mp (congr_arg Subtype.val c)) exists_of_eq {a b} h := ⟨1, by ext; simpa using h⟩ def ValueGroup := ValuationRing.ValueGroup A K -- deriving LinearOrderedCommGroupWithZero #align valuation_subring.value_group ValuationSubring.ValueGroup -- Porting note: see https://github.com/leanprover-community/mathlib4/issues/5020 instance : LinearOrderedCommGroupWithZero (ValueGroup A) := by unfold ValueGroup infer_instance def valuation : Valuation K A.ValueGroup := ValuationRing.valuation A K #align valuation_subring.valuation ValuationSubring.valuation instance inhabitedValueGroup : Inhabited A.ValueGroup := ⟨A.valuation 0⟩ #align valuation_subring.inhabited_value_group ValuationSubring.inhabitedValueGroup theorem valuation_le_one (a : A) : A.valuation a ≤ 1 := (ValuationRing.mem_integer_iff A K _).2 ⟨a, rfl⟩ #align valuation_subring.valuation_le_one ValuationSubring.valuation_le_one theorem mem_of_valuation_le_one (x : K) (h : A.valuation x ≤ 1) : x ∈ A := let ⟨a, ha⟩ := (ValuationRing.mem_integer_iff A K x).1 h ha ▸ a.2 #align valuation_subring.mem_of_valuation_le_one ValuationSubring.mem_of_valuation_le_one theorem valuation_le_one_iff (x : K) : A.valuation x ≤ 1 ↔ x ∈ A := ⟨mem_of_valuation_le_one _ _, fun ha => A.valuation_le_one ⟨x, ha⟩⟩ #align valuation_subring.valuation_le_one_iff ValuationSubring.valuation_le_one_iff theorem valuation_eq_iff (x y : K) : A.valuation x = A.valuation y ↔ ∃ a : Aˣ, (a : K) * y = x := Quotient.eq'' #align valuation_subring.valuation_eq_iff ValuationSubring.valuation_eq_iff theorem valuation_le_iff (x y : K) : A.valuation x ≤ A.valuation y ↔ ∃ a : A, (a : K) * y = x := Iff.rfl #align valuation_subring.valuation_le_iff ValuationSubring.valuation_le_iff theorem valuation_surjective : Function.Surjective A.valuation := surjective_quot_mk _ #align valuation_subring.valuation_surjective ValuationSubring.valuation_surjective theorem valuation_unit (a : Aˣ) : A.valuation a = 1 := by rw [← A.valuation.map_one, valuation_eq_iff]; use a; simp #align valuation_subring.valuation_unit ValuationSubring.valuation_unit theorem valuation_eq_one_iff (a : A) : IsUnit a ↔ A.valuation a = 1 := ⟨fun h => A.valuation_unit h.unit, fun h => by have ha : (a : K) ≠ 0 := by intro c rw [c, A.valuation.map_zero] at h exact zero_ne_one h have ha' : (a : K)⁻¹ ∈ A := by rw [← valuation_le_one_iff, map_inv₀, h, inv_one] apply isUnit_of_mul_eq_one a ⟨a⁻¹, ha'⟩; ext; field_simp⟩ #align valuation_subring.valuation_eq_one_iff ValuationSubring.valuation_eq_one_iff theorem valuation_lt_one_or_eq_one (a : A) : A.valuation a < 1 ∨ A.valuation a = 1 := lt_or_eq_of_le (A.valuation_le_one a) #align valuation_subring.valuation_lt_one_or_eq_one ValuationSubring.valuation_lt_one_or_eq_one theorem valuation_lt_one_iff (a : A) : a ∈ LocalRing.maximalIdeal A ↔ A.valuation a < 1 := by rw [LocalRing.mem_maximalIdeal] dsimp [nonunits]; rw [valuation_eq_one_iff] exact (A.valuation_le_one a).lt_iff_ne.symm #align valuation_subring.valuation_lt_one_iff ValuationSubring.valuation_lt_one_iff def ofSubring (R : Subring K) (hR : ∀ x : K, x ∈ R ∨ x⁻¹ ∈ R) : ValuationSubring K := { R with mem_or_inv_mem' := hR } #align valuation_subring.of_subring ValuationSubring.ofSubring @[simp] theorem mem_ofSubring (R : Subring K) (hR : ∀ x : K, x ∈ R ∨ x⁻¹ ∈ R) (x : K) : x ∈ ofSubring R hR ↔ x ∈ R := Iff.refl _ #align valuation_subring.mem_of_subring ValuationSubring.mem_ofSubring def ofLE (R : ValuationSubring K) (S : Subring K) (h : R.toSubring ≤ S) : ValuationSubring K := { S with mem_or_inv_mem' := fun x => (R.mem_or_inv_mem x).imp (@h x) (@h _) } #align valuation_subring.of_le ValuationSubring.ofLE section Order instance : SemilatticeSup (ValuationSubring K) := { (inferInstance : PartialOrder (ValuationSubring K)) with sup := fun R S => ofLE R (R.toSubring ⊔ S.toSubring) <| le_sup_left le_sup_left := fun R S _ hx => (le_sup_left : R.toSubring ≤ R.toSubring ⊔ S.toSubring) hx le_sup_right := fun R S _ hx => (le_sup_right : S.toSubring ≤ R.toSubring ⊔ S.toSubring) hx sup_le := fun R S T hR hT _ hx => (sup_le hR hT : R.toSubring ⊔ S.toSubring ≤ T.toSubring) hx } def inclusion (R S : ValuationSubring K) (h : R ≤ S) : R →+* S := Subring.inclusion h #align valuation_subring.inclusion ValuationSubring.inclusion def subtype (R : ValuationSubring K) : R →+* K := Subring.subtype R.toSubring #align valuation_subring.subtype ValuationSubring.subtype def mapOfLE (R S : ValuationSubring K) (h : R ≤ S) : R.ValueGroup →*₀ S.ValueGroup where toFun := Quotient.map' id fun x y ⟨u, hu⟩ => ⟨Units.map (R.inclusion S h).toMonoidHom u, hu⟩ map_zero' := rfl map_one' := rfl map_mul' := by rintro ⟨⟩ ⟨⟩; rfl #align valuation_subring.map_of_le ValuationSubring.mapOfLE @[mono]
Mathlib/RingTheory/Valuation/ValuationSubring.lean
269
270
theorem monotone_mapOfLE (R S : ValuationSubring K) (h : R ≤ S) : Monotone (R.mapOfLE S h) := by
rintro ⟨⟩ ⟨⟩ ⟨a, ha⟩; exact ⟨R.inclusion S h a, ha⟩
import Mathlib.Analysis.Convolution import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup import Mathlib.Analysis.Analytic.IsolatedZeros import Mathlib.Analysis.Complex.CauchyIntegral #align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090" noncomputable section set_option linter.uppercaseLean3 false open Filter intervalIntegral Set Real MeasureTheory open scoped Nat Topology Real section BetaIntegral namespace Complex noncomputable def betaIntegral (u v : ℂ) : ℂ := ∫ x : ℝ in (0)..1, (x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ (v - 1) #align complex.beta_integral Complex.betaIntegral theorem betaIntegral_convergent_left {u : ℂ} (hu : 0 < re u) (v : ℂ) : IntervalIntegrable (fun x => (x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ (v - 1) : ℝ → ℂ) volume 0 (1 / 2) := by apply IntervalIntegrable.mul_continuousOn · refine intervalIntegral.intervalIntegrable_cpow' ?_ rwa [sub_re, one_re, ← zero_sub, sub_lt_sub_iff_right] · apply ContinuousAt.continuousOn intro x hx rw [uIcc_of_le (by positivity : (0 : ℝ) ≤ 1 / 2)] at hx apply ContinuousAt.cpow · exact (continuous_const.sub continuous_ofReal).continuousAt · exact continuousAt_const · norm_cast exact ofReal_mem_slitPlane.2 <| by linarith only [hx.2] #align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
Mathlib/Analysis/SpecialFunctions/Gamma/Beta.lean
80
90
theorem betaIntegral_convergent {u v : ℂ} (hu : 0 < re u) (hv : 0 < re v) : IntervalIntegrable (fun x => (x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ (v - 1) : ℝ → ℂ) volume 0 1 := by
refine (betaIntegral_convergent_left hu v).trans ?_ rw [IntervalIntegrable.iff_comp_neg] convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1 · ext1 x conv_lhs => rw [mul_comm] congr 2 <;> · push_cast; ring · norm_num · norm_num
import Mathlib.MeasureTheory.Function.ConditionalExpectation.CondexpL1 #align_import measure_theory.function.conditional_expectation.basic from "leanprover-community/mathlib"@"d8bbb04e2d2a44596798a9207ceefc0fb236e41e" open TopologicalSpace MeasureTheory.Lp Filter open scoped ENNReal Topology MeasureTheory namespace MeasureTheory variable {α F F' 𝕜 : Type*} {p : ℝ≥0∞} [RCLike 𝕜] -- 𝕜 for ℝ or ℂ -- F for a Lp submodule [NormedAddCommGroup F] [NormedSpace 𝕜 F] -- F' for integrals on a Lp submodule [NormedAddCommGroup F'] [NormedSpace 𝕜 F'] [NormedSpace ℝ F'] [CompleteSpace F'] open scoped Classical variable {m m0 : MeasurableSpace α} {μ : Measure α} {f g : α → F'} {s : Set α} noncomputable irreducible_def condexp (m : MeasurableSpace α) {m0 : MeasurableSpace α} (μ : Measure α) (f : α → F') : α → F' := if hm : m ≤ m0 then if h : SigmaFinite (μ.trim hm) ∧ Integrable f μ then if StronglyMeasurable[m] f then f else (@aestronglyMeasurable'_condexpL1 _ _ _ _ _ m m0 μ hm h.1 _).mk (@condexpL1 _ _ _ _ _ _ _ hm μ h.1 f) else 0 else 0 #align measure_theory.condexp MeasureTheory.condexp -- We define notation `μ[f|m]` for the conditional expectation of `f` with respect to `m`. scoped notation μ "[" f "|" m "]" => MeasureTheory.condexp m μ f theorem condexp_of_not_le (hm_not : ¬m ≤ m0) : μ[f|m] = 0 := by rw [condexp, dif_neg hm_not] #align measure_theory.condexp_of_not_le MeasureTheory.condexp_of_not_le theorem condexp_of_not_sigmaFinite (hm : m ≤ m0) (hμm_not : ¬SigmaFinite (μ.trim hm)) : μ[f|m] = 0 := by rw [condexp, dif_pos hm, dif_neg]; push_neg; exact fun h => absurd h hμm_not #align measure_theory.condexp_of_not_sigma_finite MeasureTheory.condexp_of_not_sigmaFinite theorem condexp_of_sigmaFinite (hm : m ≤ m0) [hμm : SigmaFinite (μ.trim hm)] : μ[f|m] = if Integrable f μ then if StronglyMeasurable[m] f then f else aestronglyMeasurable'_condexpL1.mk (condexpL1 hm μ f) else 0 := by rw [condexp, dif_pos hm] simp only [hμm, Ne, true_and_iff] by_cases hf : Integrable f μ · rw [dif_pos hf, if_pos hf] · rw [dif_neg hf, if_neg hf] #align measure_theory.condexp_of_sigma_finite MeasureTheory.condexp_of_sigmaFinite theorem condexp_of_stronglyMeasurable (hm : m ≤ m0) [hμm : SigmaFinite (μ.trim hm)] {f : α → F'} (hf : StronglyMeasurable[m] f) (hfi : Integrable f μ) : μ[f|m] = f := by rw [condexp_of_sigmaFinite hm, if_pos hfi, if_pos hf] #align measure_theory.condexp_of_strongly_measurable MeasureTheory.condexp_of_stronglyMeasurable theorem condexp_const (hm : m ≤ m0) (c : F') [IsFiniteMeasure μ] : μ[fun _ : α => c|m] = fun _ => c := condexp_of_stronglyMeasurable hm (@stronglyMeasurable_const _ _ m _ _) (integrable_const c) #align measure_theory.condexp_const MeasureTheory.condexp_const theorem condexp_ae_eq_condexpL1 (hm : m ≤ m0) [hμm : SigmaFinite (μ.trim hm)] (f : α → F') : μ[f|m] =ᵐ[μ] condexpL1 hm μ f := by rw [condexp_of_sigmaFinite hm] by_cases hfi : Integrable f μ · rw [if_pos hfi] by_cases hfm : StronglyMeasurable[m] f · rw [if_pos hfm] exact (condexpL1_of_aestronglyMeasurable' (StronglyMeasurable.aeStronglyMeasurable' hfm) hfi).symm · rw [if_neg hfm] exact (AEStronglyMeasurable'.ae_eq_mk aestronglyMeasurable'_condexpL1).symm rw [if_neg hfi, condexpL1_undef hfi] exact (coeFn_zero _ _ _).symm set_option linter.uppercaseLean3 false in #align measure_theory.condexp_ae_eq_condexp_L1 MeasureTheory.condexp_ae_eq_condexpL1 theorem condexp_ae_eq_condexpL1CLM (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (hf : Integrable f μ) : μ[f|m] =ᵐ[μ] condexpL1CLM F' hm μ (hf.toL1 f) := by refine (condexp_ae_eq_condexpL1 hm f).trans (eventually_of_forall fun x => ?_) rw [condexpL1_eq hf] set_option linter.uppercaseLean3 false in #align measure_theory.condexp_ae_eq_condexp_L1_clm MeasureTheory.condexp_ae_eq_condexpL1CLM theorem condexp_undef (hf : ¬Integrable f μ) : μ[f|m] = 0 := by by_cases hm : m ≤ m0 swap; · rw [condexp_of_not_le hm] by_cases hμm : SigmaFinite (μ.trim hm) swap; · rw [condexp_of_not_sigmaFinite hm hμm] haveI : SigmaFinite (μ.trim hm) := hμm rw [condexp_of_sigmaFinite, if_neg hf] #align measure_theory.condexp_undef MeasureTheory.condexp_undef @[simp] theorem condexp_zero : μ[(0 : α → F')|m] = 0 := by by_cases hm : m ≤ m0 swap; · rw [condexp_of_not_le hm] by_cases hμm : SigmaFinite (μ.trim hm) swap; · rw [condexp_of_not_sigmaFinite hm hμm] haveI : SigmaFinite (μ.trim hm) := hμm exact condexp_of_stronglyMeasurable hm (@stronglyMeasurable_zero _ _ m _ _) (integrable_zero _ _ _) #align measure_theory.condexp_zero MeasureTheory.condexp_zero theorem stronglyMeasurable_condexp : StronglyMeasurable[m] (μ[f|m]) := by by_cases hm : m ≤ m0 swap; · rw [condexp_of_not_le hm]; exact stronglyMeasurable_zero by_cases hμm : SigmaFinite (μ.trim hm) swap; · rw [condexp_of_not_sigmaFinite hm hμm]; exact stronglyMeasurable_zero haveI : SigmaFinite (μ.trim hm) := hμm rw [condexp_of_sigmaFinite hm] split_ifs with hfi hfm · exact hfm · exact AEStronglyMeasurable'.stronglyMeasurable_mk _ · exact stronglyMeasurable_zero #align measure_theory.strongly_measurable_condexp MeasureTheory.stronglyMeasurable_condexp theorem condexp_congr_ae (h : f =ᵐ[μ] g) : μ[f|m] =ᵐ[μ] μ[g|m] := by by_cases hm : m ≤ m0 swap; · simp_rw [condexp_of_not_le hm]; rfl by_cases hμm : SigmaFinite (μ.trim hm) swap; · simp_rw [condexp_of_not_sigmaFinite hm hμm]; rfl haveI : SigmaFinite (μ.trim hm) := hμm exact (condexp_ae_eq_condexpL1 hm f).trans (Filter.EventuallyEq.trans (by rw [condexpL1_congr_ae hm h]) (condexp_ae_eq_condexpL1 hm g).symm) #align measure_theory.condexp_congr_ae MeasureTheory.condexp_congr_ae theorem condexp_of_aestronglyMeasurable' (hm : m ≤ m0) [hμm : SigmaFinite (μ.trim hm)] {f : α → F'} (hf : AEStronglyMeasurable' m f μ) (hfi : Integrable f μ) : μ[f|m] =ᵐ[μ] f := by refine ((condexp_congr_ae hf.ae_eq_mk).trans ?_).trans hf.ae_eq_mk.symm rw [condexp_of_stronglyMeasurable hm hf.stronglyMeasurable_mk ((integrable_congr hf.ae_eq_mk).mp hfi)] #align measure_theory.condexp_of_ae_strongly_measurable' MeasureTheory.condexp_of_aestronglyMeasurable' theorem integrable_condexp : Integrable (μ[f|m]) μ := by by_cases hm : m ≤ m0 swap; · rw [condexp_of_not_le hm]; exact integrable_zero _ _ _ by_cases hμm : SigmaFinite (μ.trim hm) swap; · rw [condexp_of_not_sigmaFinite hm hμm]; exact integrable_zero _ _ _ haveI : SigmaFinite (μ.trim hm) := hμm exact (integrable_condexpL1 f).congr (condexp_ae_eq_condexpL1 hm f).symm #align measure_theory.integrable_condexp MeasureTheory.integrable_condexp theorem setIntegral_condexp (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (hf : Integrable f μ) (hs : MeasurableSet[m] s) : ∫ x in s, (μ[f|m]) x ∂μ = ∫ x in s, f x ∂μ := by rw [setIntegral_congr_ae (hm s hs) ((condexp_ae_eq_condexpL1 hm f).mono fun x hx _ => hx)] exact setIntegral_condexpL1 hf hs #align measure_theory.set_integral_condexp MeasureTheory.setIntegral_condexp @[deprecated (since := "2024-04-17")] alias set_integral_condexp := setIntegral_condexp theorem integral_condexp (hm : m ≤ m0) [hμm : SigmaFinite (μ.trim hm)] (hf : Integrable f μ) : ∫ x, (μ[f|m]) x ∂μ = ∫ x, f x ∂μ := by suffices ∫ x in Set.univ, (μ[f|m]) x ∂μ = ∫ x in Set.univ, f x ∂μ by simp_rw [integral_univ] at this; exact this exact setIntegral_condexp hm hf (@MeasurableSet.univ _ m) #align measure_theory.integral_condexp MeasureTheory.integral_condexp theorem ae_eq_condexp_of_forall_setIntegral_eq (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] {f g : α → F'} (hf : Integrable f μ) (hg_int_finite : ∀ s, MeasurableSet[m] s → μ s < ∞ → IntegrableOn g s μ) (hg_eq : ∀ s : Set α, MeasurableSet[m] s → μ s < ∞ → ∫ x in s, g x ∂μ = ∫ x in s, f x ∂μ) (hgm : AEStronglyMeasurable' m g μ) : g =ᵐ[μ] μ[f|m] := by refine ae_eq_of_forall_setIntegral_eq_of_sigmaFinite' hm hg_int_finite (fun s _ _ => integrable_condexp.integrableOn) (fun s hs hμs => ?_) hgm (StronglyMeasurable.aeStronglyMeasurable' stronglyMeasurable_condexp) rw [hg_eq s hs hμs, setIntegral_condexp hm hf hs] #align measure_theory.ae_eq_condexp_of_forall_set_integral_eq MeasureTheory.ae_eq_condexp_of_forall_setIntegral_eq @[deprecated (since := "2024-04-17")] alias ae_eq_condexp_of_forall_set_integral_eq := ae_eq_condexp_of_forall_setIntegral_eq theorem condexp_bot' [hμ : NeZero μ] (f : α → F') : μ[f|⊥] = fun _ => (μ Set.univ).toReal⁻¹ • ∫ x, f x ∂μ := by by_cases hμ_finite : IsFiniteMeasure μ swap · have h : ¬SigmaFinite (μ.trim bot_le) := by rwa [sigmaFinite_trim_bot_iff] rw [not_isFiniteMeasure_iff] at hμ_finite rw [condexp_of_not_sigmaFinite bot_le h] simp only [hμ_finite, ENNReal.top_toReal, inv_zero, zero_smul] rfl by_cases hf : Integrable f μ swap; · rw [integral_undef hf, smul_zero, condexp_undef hf]; rfl have h_meas : StronglyMeasurable[⊥] (μ[f|⊥]) := stronglyMeasurable_condexp obtain ⟨c, h_eq⟩ := stronglyMeasurable_bot_iff.mp h_meas rw [h_eq] have h_integral : ∫ x, (μ[f|⊥]) x ∂μ = ∫ x, f x ∂μ := integral_condexp bot_le hf simp_rw [h_eq, integral_const] at h_integral rw [← h_integral, ← smul_assoc, smul_eq_mul, inv_mul_cancel, one_smul] rw [Ne, ENNReal.toReal_eq_zero_iff, not_or] exact ⟨NeZero.ne _, measure_ne_top μ Set.univ⟩ #align measure_theory.condexp_bot' MeasureTheory.condexp_bot' theorem condexp_bot_ae_eq (f : α → F') : μ[f|⊥] =ᵐ[μ] fun _ => (μ Set.univ).toReal⁻¹ • ∫ x, f x ∂μ := by rcases eq_zero_or_neZero μ with rfl | hμ · rw [ae_zero]; exact eventually_bot · exact eventually_of_forall <| congr_fun (condexp_bot' f) #align measure_theory.condexp_bot_ae_eq MeasureTheory.condexp_bot_ae_eq theorem condexp_bot [IsProbabilityMeasure μ] (f : α → F') : μ[f|⊥] = fun _ => ∫ x, f x ∂μ := by refine (condexp_bot' f).trans ?_; rw [measure_univ, ENNReal.one_toReal, inv_one, one_smul] #align measure_theory.condexp_bot MeasureTheory.condexp_bot theorem condexp_add (hf : Integrable f μ) (hg : Integrable g μ) : μ[f + g|m] =ᵐ[μ] μ[f|m] + μ[g|m] := by by_cases hm : m ≤ m0 swap; · simp_rw [condexp_of_not_le hm]; simp by_cases hμm : SigmaFinite (μ.trim hm) swap; · simp_rw [condexp_of_not_sigmaFinite hm hμm]; simp haveI : SigmaFinite (μ.trim hm) := hμm refine (condexp_ae_eq_condexpL1 hm _).trans ?_ rw [condexpL1_add hf hg] exact (coeFn_add _ _).trans ((condexp_ae_eq_condexpL1 hm _).symm.add (condexp_ae_eq_condexpL1 hm _).symm) #align measure_theory.condexp_add MeasureTheory.condexp_add theorem condexp_finset_sum {ι : Type*} {s : Finset ι} {f : ι → α → F'} (hf : ∀ i ∈ s, Integrable (f i) μ) : μ[∑ i ∈ s, f i|m] =ᵐ[μ] ∑ i ∈ s, μ[f i|m] := by induction' s using Finset.induction_on with i s his heq hf · rw [Finset.sum_empty, Finset.sum_empty, condexp_zero] · rw [Finset.sum_insert his, Finset.sum_insert his] exact (condexp_add (hf i <| Finset.mem_insert_self i s) <| integrable_finset_sum' _ fun j hmem => hf j <| Finset.mem_insert_of_mem hmem).trans ((EventuallyEq.refl _ _).add (heq fun j hmem => hf j <| Finset.mem_insert_of_mem hmem)) #align measure_theory.condexp_finset_sum MeasureTheory.condexp_finset_sum
Mathlib/MeasureTheory/Function/ConditionalExpectation/Basic.lean
308
318
theorem condexp_smul (c : 𝕜) (f : α → F') : μ[c • f|m] =ᵐ[μ] c • μ[f|m] := by
by_cases hm : m ≤ m0 swap; · simp_rw [condexp_of_not_le hm]; simp by_cases hμm : SigmaFinite (μ.trim hm) swap; · simp_rw [condexp_of_not_sigmaFinite hm hμm]; simp haveI : SigmaFinite (μ.trim hm) := hμm refine (condexp_ae_eq_condexpL1 hm _).trans ?_ rw [condexpL1_smul c f] refine (@condexp_ae_eq_condexpL1 _ _ _ _ _ m _ _ hm _ f).mp ?_ refine (coeFn_smul c (condexpL1 hm μ f)).mono fun x hx1 hx2 => ?_ simp only [hx1, hx2, Pi.smul_apply]
import Mathlib.Algebra.Group.Subgroup.Basic import Mathlib.Algebra.Order.Archimedean import Mathlib.Data.Set.Lattice #align_import group_theory.archimedean from "leanprover-community/mathlib"@"f93c11933efbc3c2f0299e47b8ff83e9b539cbf6" open Set variable {G : Type*} [LinearOrderedAddCommGroup G] [Archimedean G]
Mathlib/GroupTheory/Archimedean.lean
40
54
theorem AddSubgroup.cyclic_of_min {H : AddSubgroup G} {a : G} (ha : IsLeast { g : G | g ∈ H ∧ 0 < g } a) : H = AddSubgroup.closure {a} := by
obtain ⟨⟨a_in, a_pos⟩, a_min⟩ := ha refine le_antisymm ?_ (H.closure_le.mpr <| by simp [a_in]) intro g g_in obtain ⟨k, ⟨nonneg, lt⟩, _⟩ := existsUnique_zsmul_near_of_pos' a_pos g have h_zero : g - k • a = 0 := by by_contra h have h : a ≤ g - k • a := by refine a_min ⟨?_, ?_⟩ · exact AddSubgroup.sub_mem H g_in (AddSubgroup.zsmul_mem H a_in k) · exact lt_of_le_of_ne nonneg (Ne.symm h) have h' : ¬a ≤ g - k • a := not_le.mpr lt contradiction simp [sub_eq_zero.mp h_zero, AddSubgroup.mem_closure_singleton]
import Mathlib.Analysis.NormedSpace.FiniteDimension import Mathlib.Analysis.RCLike.Basic #align_import data.is_R_or_C.lemmas from "leanprover-community/mathlib"@"468b141b14016d54b479eb7a0fff1e360b7e3cf6" variable {K E : Type*} [RCLike K] namespace RCLike @[simp, rclike_simps]
Mathlib/Analysis/RCLike/Lemmas.lean
71
74
theorem reCLM_norm : ‖(reCLM : K →L[ℝ] ℝ)‖ = 1 := by
apply le_antisymm (LinearMap.mkContinuous_norm_le _ zero_le_one _) convert ContinuousLinearMap.ratio_le_opNorm (reCLM : K →L[ℝ] ℝ) (1 : K) simp
import Mathlib.Analysis.NormedSpace.PiTensorProduct.ProjectiveSeminorm import Mathlib.LinearAlgebra.Isomorphisms universe uι u𝕜 uE uF variable {ι : Type uι} [Fintype ι] variable {𝕜 : Type u𝕜} [NontriviallyNormedField 𝕜] variable {E : ι → Type uE} [∀ i, SeminormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)] variable {F : Type uF} [SeminormedAddCommGroup F] [NormedSpace 𝕜 F] open scoped TensorProduct namespace PiTensorProduct section seminorm variable (F) in @[simps!] noncomputable def toDualContinuousMultilinearMap : (⨂[𝕜] i, E i) →ₗ[𝕜] ContinuousMultilinearMap 𝕜 E F →L[𝕜] F where toFun x := LinearMap.mkContinuous ((LinearMap.flip (lift (R := 𝕜) (s := E) (E := F)).toLinearMap x) ∘ₗ ContinuousMultilinearMap.toMultilinearMapLinear) (projectiveSeminorm x) (fun _ ↦ by simp only [LinearMap.coe_comp, Function.comp_apply, ContinuousMultilinearMap.toMultilinearMapLinear_apply, LinearMap.flip_apply, LinearEquiv.coe_coe] exact norm_eval_le_projectiveSeminorm _ _ _) map_add' x y := by ext _ simp only [map_add, LinearMap.mkContinuous_apply, LinearMap.coe_comp, Function.comp_apply, ContinuousMultilinearMap.toMultilinearMapLinear_apply, LinearMap.add_apply, LinearMap.flip_apply, LinearEquiv.coe_coe, ContinuousLinearMap.add_apply] map_smul' a x := by ext _ simp only [map_smul, LinearMap.mkContinuous_apply, LinearMap.coe_comp, Function.comp_apply, ContinuousMultilinearMap.toMultilinearMapLinear_apply, LinearMap.smul_apply, LinearMap.flip_apply, LinearEquiv.coe_coe, RingHom.id_apply, ContinuousLinearMap.coe_smul', Pi.smul_apply] theorem toDualContinuousMultilinearMap_le_projectiveSeminorm (x : ⨂[𝕜] i, E i) : ‖toDualContinuousMultilinearMap F x‖ ≤ projectiveSeminorm x := by simp only [toDualContinuousMultilinearMap, LinearMap.coe_mk, AddHom.coe_mk] apply LinearMap.mkContinuous_norm_le _ (apply_nonneg _ _) noncomputable irreducible_def injectiveSeminorm : Seminorm 𝕜 (⨂[𝕜] i, E i) := sSup {p | ∃ (G : Type (max uι u𝕜 uE)) (_ : SeminormedAddCommGroup G) (_ : NormedSpace 𝕜 G), p = Seminorm.comp (normSeminorm 𝕜 (ContinuousMultilinearMap 𝕜 E G →L[𝕜] G)) (toDualContinuousMultilinearMap G (𝕜 := 𝕜) (E := E))} lemma dualSeminorms_bounded : BddAbove {p | ∃ (G : Type (max uι u𝕜 uE)) (_ : SeminormedAddCommGroup G) (_ : NormedSpace 𝕜 G), p = Seminorm.comp (normSeminorm 𝕜 (ContinuousMultilinearMap 𝕜 E G →L[𝕜] G)) (toDualContinuousMultilinearMap G (𝕜 := 𝕜) (E := E))} := by existsi projectiveSeminorm rw [mem_upperBounds] simp only [Set.mem_setOf_eq, forall_exists_index] intro p G _ _ hp rw [hp] intro x simp only [Seminorm.comp_apply, coe_normSeminorm] exact toDualContinuousMultilinearMap_le_projectiveSeminorm _ theorem injectiveSeminorm_apply (x : ⨂[𝕜] i, E i) : injectiveSeminorm x = ⨆ p : {p | ∃ (G : Type (max uι u𝕜 uE)) (_ : SeminormedAddCommGroup G) (_ : NormedSpace 𝕜 G), p = Seminorm.comp (normSeminorm 𝕜 (ContinuousMultilinearMap 𝕜 E G →L[𝕜] G)) (toDualContinuousMultilinearMap G (𝕜 := 𝕜) (E := E))}, p.1 x := by simp [injectiveSeminorm] exact Seminorm.sSup_apply dualSeminorms_bounded theorem norm_eval_le_injectiveSeminorm (f : ContinuousMultilinearMap 𝕜 E F) (x : ⨂[𝕜] i, E i) : ‖lift f.toMultilinearMap x‖ ≤ ‖f‖ * injectiveSeminorm x := by set G := (⨂[𝕜] i, E i) ⧸ LinearMap.ker (lift f.toMultilinearMap) set G' := LinearMap.range (lift f.toMultilinearMap) set e := LinearMap.quotKerEquivRange (lift f.toMultilinearMap) letI := SeminormedAddCommGroup.induced G G' e letI := NormedSpace.induced 𝕜 G G' e set f'₀ := lift.symm (e.symm.toLinearMap ∘ₗ LinearMap.rangeRestrict (lift f.toMultilinearMap)) have hf'₀ : ∀ (x : Π (i : ι), E i), ‖f'₀ x‖ ≤ ‖f‖ * ∏ i, ‖x i‖ := fun x ↦ by change ‖e (f'₀ x)‖ ≤ _ simp only [lift_symm, LinearMap.compMultilinearMap_apply, LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, LinearEquiv.apply_symm_apply, Submodule.coe_norm, LinearMap.codRestrict_apply, lift.tprod, ContinuousMultilinearMap.coe_coe, e, f'₀] exact f.le_opNorm x set f' := MultilinearMap.mkContinuous f'₀ ‖f‖ hf'₀ have hnorm : ‖f'‖ ≤ ‖f‖ := (f'.opNorm_le_iff (norm_nonneg f)).mpr hf'₀ have heq : e (lift f'.toMultilinearMap x) = lift f.toMultilinearMap x := by induction' x using PiTensorProduct.induction_on with a m _ _ hx hy · simp only [lift_symm, map_smul, lift.tprod, ContinuousMultilinearMap.coe_coe, MultilinearMap.coe_mkContinuous, LinearMap.compMultilinearMap_apply, LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, LinearEquiv.apply_symm_apply, SetLike.val_smul, LinearMap.codRestrict_apply, f', f'₀] · simp only [map_add, AddSubmonoid.coe_add, Submodule.coe_toAddSubmonoid, hx, hy] suffices h : ‖lift f'.toMultilinearMap x‖ ≤ ‖f'‖ * injectiveSeminorm x by change ‖(e (lift f'.toMultilinearMap x)).1‖ ≤ _ at h rw [heq] at h exact le_trans h (mul_le_mul_of_nonneg_right hnorm (apply_nonneg _ _)) have hle : Seminorm.comp (normSeminorm 𝕜 (ContinuousMultilinearMap 𝕜 E G →L[𝕜] G)) (toDualContinuousMultilinearMap G (𝕜 := 𝕜) (E := E)) ≤ injectiveSeminorm := by simp only [injectiveSeminorm] refine le_csSup dualSeminorms_bounded ?_ rw [Set.mem_setOf] existsi G, inferInstance, inferInstance rfl refine le_trans ?_ (mul_le_mul_of_nonneg_left (hle x) (norm_nonneg f')) simp only [Seminorm.comp_apply, coe_normSeminorm, ← toDualContinuousMultilinearMap_apply_apply] rw [mul_comm] exact ContinuousLinearMap.le_opNorm _ _
Mathlib/Analysis/NormedSpace/PiTensorProduct/InjectiveSeminorm.lean
204
219
theorem injectiveSeminorm_le_projectiveSeminorm : injectiveSeminorm (𝕜 := 𝕜) (E := E) ≤ projectiveSeminorm := by
rw [injectiveSeminorm] refine csSup_le ?_ ?_ · existsi 0 simp only [Set.mem_setOf_eq] existsi PUnit, inferInstance, inferInstance ext x simp only [Seminorm.zero_apply, Seminorm.comp_apply, coe_normSeminorm] have heq : toDualContinuousMultilinearMap PUnit x = 0 := by ext _ rw [heq, norm_zero] · intro p hp simp only [Set.mem_setOf_eq] at hp obtain ⟨G, _, _, h⟩ := hp rw [h]; intro x; simp only [Seminorm.comp_apply, coe_normSeminorm] exact toDualContinuousMultilinearMap_le_projectiveSeminorm _
import Mathlib.Data.Nat.Multiplicity import Mathlib.Data.ZMod.Algebra import Mathlib.RingTheory.WittVector.Basic import Mathlib.RingTheory.WittVector.IsPoly import Mathlib.FieldTheory.Perfect #align_import ring_theory.witt_vector.frobenius from "leanprover-community/mathlib"@"0723536a0522d24fc2f159a096fb3304bef77472" namespace WittVector variable {p : ℕ} {R S : Type*} [hp : Fact p.Prime] [CommRing R] [CommRing S] local notation "𝕎" => WittVector p -- type as `\bbW` noncomputable section open MvPolynomial Finset variable (p) def frobeniusPolyRat (n : ℕ) : MvPolynomial ℕ ℚ := bind₁ (wittPolynomial p ℚ ∘ fun n => n + 1) (xInTermsOfW p ℚ n) #align witt_vector.frobenius_poly_rat WittVector.frobeniusPolyRat theorem bind₁_frobeniusPolyRat_wittPolynomial (n : ℕ) : bind₁ (frobeniusPolyRat p) (wittPolynomial p ℚ n) = wittPolynomial p ℚ (n + 1) := by delta frobeniusPolyRat rw [← bind₁_bind₁, bind₁_xInTermsOfW_wittPolynomial, bind₁_X_right, Function.comp_apply] #align witt_vector.bind₁_frobenius_poly_rat_witt_polynomial WittVector.bind₁_frobeniusPolyRat_wittPolynomial private def pnat_multiplicity (n : ℕ+) : ℕ := (multiplicity p n).get <| multiplicity.finite_nat_iff.mpr <| ⟨ne_of_gt hp.1.one_lt, n.2⟩ local notation "v" => pnat_multiplicity noncomputable def frobeniusPolyAux : ℕ → MvPolynomial ℕ ℤ | n => X (n + 1) - ∑ i : Fin n, have _ := i.is_lt ∑ j ∈ range (p ^ (n - i)), (((X (i : ℕ) ^ p) ^ (p ^ (n - (i : ℕ)) - (j + 1)) : MvPolynomial ℕ ℤ) * (frobeniusPolyAux i) ^ (j + 1)) * C (((p ^ (n - i)).choose (j + 1) / (p ^ (n - i - v p ⟨j + 1, Nat.succ_pos j⟩)) * ↑p ^ (j - v p ⟨j + 1, Nat.succ_pos j⟩) : ℕ) : ℤ) #align witt_vector.frobenius_poly_aux WittVector.frobeniusPolyAux theorem frobeniusPolyAux_eq (n : ℕ) : frobeniusPolyAux p n = X (n + 1) - ∑ i ∈ range n, ∑ j ∈ range (p ^ (n - i)), (X i ^ p) ^ (p ^ (n - i) - (j + 1)) * frobeniusPolyAux p i ^ (j + 1) * C ↑((p ^ (n - i)).choose (j + 1) / p ^ (n - i - v p ⟨j + 1, Nat.succ_pos j⟩) * ↑p ^ (j - v p ⟨j + 1, Nat.succ_pos j⟩) : ℕ) := by rw [frobeniusPolyAux, ← Fin.sum_univ_eq_sum_range] #align witt_vector.frobenius_poly_aux_eq WittVector.frobeniusPolyAux_eq def frobeniusPoly (n : ℕ) : MvPolynomial ℕ ℤ := X n ^ p + C (p : ℤ) * frobeniusPolyAux p n #align witt_vector.frobenius_poly WittVector.frobeniusPoly theorem map_frobeniusPoly.key₁ (n j : ℕ) (hj : j < p ^ n) : p ^ (n - v p ⟨j + 1, j.succ_pos⟩) ∣ (p ^ n).choose (j + 1) := by apply multiplicity.pow_dvd_of_le_multiplicity rw [hp.out.multiplicity_choose_prime_pow hj j.succ_ne_zero] rfl #align witt_vector.map_frobenius_poly.key₁ WittVector.map_frobeniusPoly.key₁ theorem map_frobeniusPoly.key₂ {n i j : ℕ} (hi : i ≤ n) (hj : j < p ^ (n - i)) : j - v p ⟨j + 1, j.succ_pos⟩ + n = i + j + (n - i - v p ⟨j + 1, j.succ_pos⟩) := by generalize h : v p ⟨j + 1, j.succ_pos⟩ = m rsuffices ⟨h₁, h₂⟩ : m ≤ n - i ∧ m ≤ j · rw [tsub_add_eq_add_tsub h₂, add_comm i j, add_tsub_assoc_of_le (h₁.trans (Nat.sub_le n i)), add_assoc, tsub_right_comm, add_comm i, tsub_add_cancel_of_le (le_tsub_of_add_le_right ((le_tsub_iff_left hi).mp h₁))] have hle : p ^ m ≤ j + 1 := h ▸ Nat.le_of_dvd j.succ_pos (multiplicity.pow_multiplicity_dvd _) exact ⟨(pow_le_pow_iff_right hp.1.one_lt).1 (hle.trans hj), Nat.le_of_lt_succ ((Nat.lt_pow_self hp.1.one_lt m).trans_le hle)⟩ #align witt_vector.map_frobenius_poly.key₂ WittVector.map_frobeniusPoly.key₂ theorem map_frobeniusPoly (n : ℕ) : MvPolynomial.map (Int.castRingHom ℚ) (frobeniusPoly p n) = frobeniusPolyRat p n := by rw [frobeniusPoly, RingHom.map_add, RingHom.map_mul, RingHom.map_pow, map_C, map_X, eq_intCast, Int.cast_natCast, frobeniusPolyRat] refine Nat.strong_induction_on n ?_; clear n intro n IH rw [xInTermsOfW_eq] simp only [AlgHom.map_sum, AlgHom.map_sub, AlgHom.map_mul, AlgHom.map_pow, bind₁_C_right] have h1 : (p : ℚ) ^ n * ⅟ (p : ℚ) ^ n = 1 := by rw [← mul_pow, mul_invOf_self, one_pow] rw [bind₁_X_right, Function.comp_apply, wittPolynomial_eq_sum_C_mul_X_pow, sum_range_succ, sum_range_succ, tsub_self, add_tsub_cancel_left, pow_zero, pow_one, pow_one, sub_mul, add_mul, add_mul, mul_right_comm, mul_right_comm (C ((p : ℚ) ^ (n + 1))), ← C_mul, ← C_mul, pow_succ', mul_assoc (p : ℚ) ((p : ℚ) ^ n), h1, mul_one, C_1, one_mul, add_comm _ (X n ^ p), add_assoc, ← add_sub, add_right_inj, frobeniusPolyAux_eq, RingHom.map_sub, map_X, mul_sub, sub_eq_add_neg, add_comm _ (C (p : ℚ) * X (n + 1)), ← add_sub, add_right_inj, neg_eq_iff_eq_neg, neg_sub, eq_comm] simp only [map_sum, mul_sum, sum_mul, ← sum_sub_distrib] apply sum_congr rfl intro i hi rw [mem_range] at hi rw [← IH i hi] clear IH rw [add_comm (X i ^ p), add_pow, sum_range_succ', pow_zero, tsub_zero, Nat.choose_zero_right, one_mul, Nat.cast_one, mul_one, mul_add, add_mul, Nat.succ_sub (le_of_lt hi), Nat.succ_eq_add_one (n - i), pow_succ', pow_mul, add_sub_cancel_right, mul_sum, sum_mul] apply sum_congr rfl intro j hj rw [mem_range] at hj rw [RingHom.map_mul, RingHom.map_mul, RingHom.map_pow, RingHom.map_pow, RingHom.map_pow, RingHom.map_pow, RingHom.map_pow, map_C, map_X, mul_pow] rw [mul_comm (C (p : ℚ) ^ i), mul_comm _ ((X i ^ p) ^ _), mul_comm (C (p : ℚ) ^ (j + 1)), mul_comm (C (p : ℚ))] simp only [mul_assoc] apply congr_arg apply congr_arg rw [← C_eq_coe_nat] simp only [← RingHom.map_pow, ← C_mul] rw [C_inj] simp only [invOf_eq_inv, eq_intCast, inv_pow, Int.cast_natCast, Nat.cast_mul, Int.cast_mul] rw [Rat.natCast_div _ _ (map_frobeniusPoly.key₁ p (n - i) j hj)] simp only [Nat.cast_pow, pow_add, pow_one] suffices (((p ^ (n - i)).choose (j + 1): ℚ) * (p : ℚ) ^ (j - v p ⟨j + 1, j.succ_pos⟩) * ↑p * (p ^ n : ℚ)) = (p : ℚ) ^ j * p * ↑((p ^ (n - i)).choose (j + 1) * p ^ i) * (p : ℚ) ^ (n - i - v p ⟨j + 1, j.succ_pos⟩) by have aux : ∀ k : ℕ, (p : ℚ)^ k ≠ 0 := by intro; apply pow_ne_zero; exact mod_cast hp.1.ne_zero simpa [aux, -one_div, -pow_eq_zero_iff', field_simps] using this.symm rw [mul_comm _ (p : ℚ), mul_assoc, mul_assoc, ← pow_add, map_frobeniusPoly.key₂ p hi.le hj, Nat.cast_mul, Nat.cast_pow] ring #align witt_vector.map_frobenius_poly WittVector.map_frobeniusPoly theorem frobeniusPoly_zmod (n : ℕ) : MvPolynomial.map (Int.castRingHom (ZMod p)) (frobeniusPoly p n) = X n ^ p := by rw [frobeniusPoly, RingHom.map_add, RingHom.map_pow, RingHom.map_mul, map_X, map_C] simp only [Int.cast_natCast, add_zero, eq_intCast, ZMod.natCast_self, zero_mul, C_0] #align witt_vector.frobenius_poly_zmod WittVector.frobeniusPoly_zmod @[simp] theorem bind₁_frobeniusPoly_wittPolynomial (n : ℕ) : bind₁ (frobeniusPoly p) (wittPolynomial p ℤ n) = wittPolynomial p ℤ (n + 1) := by apply MvPolynomial.map_injective (Int.castRingHom ℚ) Int.cast_injective simp only [map_bind₁, map_frobeniusPoly, bind₁_frobeniusPolyRat_wittPolynomial, map_wittPolynomial] #align witt_vector.bind₁_frobenius_poly_witt_polynomial WittVector.bind₁_frobeniusPoly_wittPolynomial variable {p} def frobeniusFun (x : 𝕎 R) : 𝕎 R := mk p fun n => MvPolynomial.aeval x.coeff (frobeniusPoly p n) #align witt_vector.frobenius_fun WittVector.frobeniusFun theorem coeff_frobeniusFun (x : 𝕎 R) (n : ℕ) : coeff (frobeniusFun x) n = MvPolynomial.aeval x.coeff (frobeniusPoly p n) := by rw [frobeniusFun, coeff_mk] #align witt_vector.coeff_frobenius_fun WittVector.coeff_frobeniusFun variable (p) -- Porting note: replaced `@[is_poly]` with `instance`. instance frobeniusFun_isPoly : IsPoly p fun R _Rcr => @frobeniusFun p R _ _Rcr := ⟨⟨frobeniusPoly p, by intros; funext n; apply coeff_frobeniusFun⟩⟩ #align witt_vector.frobenius_fun_is_poly WittVector.frobeniusFun_isPoly variable {p} @[ghost_simps]
Mathlib/RingTheory/WittVector/Frobenius.lean
236
239
theorem ghostComponent_frobeniusFun (n : ℕ) (x : 𝕎 R) : ghostComponent n (frobeniusFun x) = ghostComponent (n + 1) x := by
simp only [ghostComponent_apply, frobeniusFun, coeff_mk, ← bind₁_frobeniusPoly_wittPolynomial, aeval_bind₁]
import Mathlib.Order.Interval.Finset.Nat #align_import data.fin.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29" assert_not_exists MonoidWithZero open Finset Fin Function namespace Fin variable (n : ℕ) instance instLocallyFiniteOrder : LocallyFiniteOrder (Fin n) := OrderIso.locallyFiniteOrder Fin.orderIsoSubtype instance instLocallyFiniteOrderBot : LocallyFiniteOrderBot (Fin n) := OrderIso.locallyFiniteOrderBot Fin.orderIsoSubtype instance instLocallyFiniteOrderTop : ∀ n, LocallyFiniteOrderTop (Fin n) | 0 => IsEmpty.toLocallyFiniteOrderTop | _ + 1 => inferInstance variable {n} (a b : Fin n) theorem Icc_eq_finset_subtype : Icc a b = (Icc (a : ℕ) b).fin n := rfl #align fin.Icc_eq_finset_subtype Fin.Icc_eq_finset_subtype theorem Ico_eq_finset_subtype : Ico a b = (Ico (a : ℕ) b).fin n := rfl #align fin.Ico_eq_finset_subtype Fin.Ico_eq_finset_subtype theorem Ioc_eq_finset_subtype : Ioc a b = (Ioc (a : ℕ) b).fin n := rfl #align fin.Ioc_eq_finset_subtype Fin.Ioc_eq_finset_subtype theorem Ioo_eq_finset_subtype : Ioo a b = (Ioo (a : ℕ) b).fin n := rfl #align fin.Ioo_eq_finset_subtype Fin.Ioo_eq_finset_subtype theorem uIcc_eq_finset_subtype : uIcc a b = (uIcc (a : ℕ) b).fin n := rfl #align fin.uIcc_eq_finset_subtype Fin.uIcc_eq_finset_subtype @[simp] theorem map_valEmbedding_Icc : (Icc a b).map Fin.valEmbedding = Icc ↑a ↑b := by simp [Icc_eq_finset_subtype, Finset.fin, Finset.map_map, Icc_filter_lt_of_lt_right] #align fin.map_subtype_embedding_Icc Fin.map_valEmbedding_Icc @[simp] theorem map_valEmbedding_Ico : (Ico a b).map Fin.valEmbedding = Ico ↑a ↑b := by simp [Ico_eq_finset_subtype, Finset.fin, Finset.map_map] #align fin.map_subtype_embedding_Ico Fin.map_valEmbedding_Ico @[simp]
Mathlib/Order/Interval/Finset/Fin.lean
89
90
theorem map_valEmbedding_Ioc : (Ioc a b).map Fin.valEmbedding = Ioc ↑a ↑b := by
simp [Ioc_eq_finset_subtype, Finset.fin, Finset.map_map, Ioc_filter_lt_of_lt_right]
import Mathlib.Data.Finset.Image #align_import data.finset.card from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" assert_not_exists MonoidWithZero -- TODO: After a lot more work, -- assert_not_exists OrderedCommMonoid open Function Multiset Nat variable {α β R : Type*} namespace Finset variable {s t : Finset α} {a b : α} def card (s : Finset α) : ℕ := Multiset.card s.1 #align finset.card Finset.card theorem card_def (s : Finset α) : s.card = Multiset.card s.1 := rfl #align finset.card_def Finset.card_def @[simp] lemma card_val (s : Finset α) : Multiset.card s.1 = s.card := rfl #align finset.card_val Finset.card_val @[simp] theorem card_mk {m nodup} : (⟨m, nodup⟩ : Finset α).card = Multiset.card m := rfl #align finset.card_mk Finset.card_mk @[simp] theorem card_empty : card (∅ : Finset α) = 0 := rfl #align finset.card_empty Finset.card_empty @[gcongr] theorem card_le_card : s ⊆ t → s.card ≤ t.card := Multiset.card_le_card ∘ val_le_iff.mpr #align finset.card_le_of_subset Finset.card_le_card @[mono] theorem card_mono : Monotone (@card α) := by apply card_le_card #align finset.card_mono Finset.card_mono @[simp] lemma card_eq_zero : s.card = 0 ↔ s = ∅ := card_eq_zero.trans val_eq_zero lemma card_ne_zero : s.card ≠ 0 ↔ s.Nonempty := card_eq_zero.ne.trans nonempty_iff_ne_empty.symm lemma card_pos : 0 < s.card ↔ s.Nonempty := Nat.pos_iff_ne_zero.trans card_ne_zero #align finset.card_eq_zero Finset.card_eq_zero #align finset.card_pos Finset.card_pos alias ⟨_, Nonempty.card_pos⟩ := card_pos alias ⟨_, Nonempty.card_ne_zero⟩ := card_ne_zero #align finset.nonempty.card_pos Finset.Nonempty.card_pos theorem card_ne_zero_of_mem (h : a ∈ s) : s.card ≠ 0 := (not_congr card_eq_zero).2 <| ne_empty_of_mem h #align finset.card_ne_zero_of_mem Finset.card_ne_zero_of_mem @[simp] theorem card_singleton (a : α) : card ({a} : Finset α) = 1 := Multiset.card_singleton _ #align finset.card_singleton Finset.card_singleton theorem card_singleton_inter [DecidableEq α] : ({a} ∩ s).card ≤ 1 := by cases' Finset.decidableMem a s with h h · simp [Finset.singleton_inter_of_not_mem h] · simp [Finset.singleton_inter_of_mem h] #align finset.card_singleton_inter Finset.card_singleton_inter @[simp] theorem card_cons (h : a ∉ s) : (s.cons a h).card = s.card + 1 := Multiset.card_cons _ _ #align finset.card_cons Finset.card_cons section InsertErase variable [DecidableEq α] @[simp] theorem card_insert_of_not_mem (h : a ∉ s) : (insert a s).card = s.card + 1 := by rw [← cons_eq_insert _ _ h, card_cons] #align finset.card_insert_of_not_mem Finset.card_insert_of_not_mem
Mathlib/Data/Finset/Card.lean
111
111
theorem card_insert_of_mem (h : a ∈ s) : card (insert a s) = s.card := by
rw [insert_eq_of_mem h]
import Batteries.Tactic.Lint.Basic import Mathlib.Algebra.Order.Monoid.Unbundled.Basic import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Algebra.Order.ZeroLEOne import Mathlib.Data.Nat.Cast.Order import Mathlib.Init.Data.Int.Order set_option autoImplicit true namespace Linarith theorem lt_irrefl {α : Type u} [Preorder α] {a : α} : ¬a < a := _root_.lt_irrefl a
Mathlib/Tactic/Linarith/Lemmas.lean
27
28
theorem eq_of_eq_of_eq {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (hb : b = 0) : a + b = 0 := by
simp [*]
import Mathlib.Data.Finset.Sort import Mathlib.Data.Fin.VecNotation import Mathlib.Data.Sign import Mathlib.LinearAlgebra.AffineSpace.Combination import Mathlib.LinearAlgebra.AffineSpace.AffineEquiv import Mathlib.LinearAlgebra.Basis.VectorSpace #align_import linear_algebra.affine_space.independent from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0" noncomputable section open Finset Function open scoped Affine section AffineIndependent variable (k : Type*) {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V] variable [AffineSpace V P] {ι : Type*} def AffineIndependent (p : ι → P) : Prop := ∀ (s : Finset ι) (w : ι → k), ∑ i ∈ s, w i = 0 → s.weightedVSub p w = (0 : V) → ∀ i ∈ s, w i = 0 #align affine_independent AffineIndependent theorem affineIndependent_def (p : ι → P) : AffineIndependent k p ↔ ∀ (s : Finset ι) (w : ι → k), ∑ i ∈ s, w i = 0 → s.weightedVSub p w = (0 : V) → ∀ i ∈ s, w i = 0 := Iff.rfl #align affine_independent_def affineIndependent_def theorem affineIndependent_of_subsingleton [Subsingleton ι] (p : ι → P) : AffineIndependent k p := fun _ _ h _ i hi => Fintype.eq_of_subsingleton_of_sum_eq h i hi #align affine_independent_of_subsingleton affineIndependent_of_subsingleton theorem affineIndependent_iff_of_fintype [Fintype ι] (p : ι → P) : AffineIndependent k p ↔ ∀ w : ι → k, ∑ i, w i = 0 → Finset.univ.weightedVSub p w = (0 : V) → ∀ i, w i = 0 := by constructor · exact fun h w hw hs i => h Finset.univ w hw hs i (Finset.mem_univ _) · intro h s w hw hs i hi rw [Finset.weightedVSub_indicator_subset _ _ (Finset.subset_univ s)] at hs rw [← Finset.sum_indicator_subset _ (Finset.subset_univ s)] at hw replace h := h ((↑s : Set ι).indicator w) hw hs i simpa [hi] using h #align affine_independent_iff_of_fintype affineIndependent_iff_of_fintype theorem affineIndependent_iff_linearIndependent_vsub (p : ι → P) (i1 : ι) : AffineIndependent k p ↔ LinearIndependent k fun i : { x // x ≠ i1 } => (p i -ᵥ p i1 : V) := by classical constructor · intro h rw [linearIndependent_iff'] intro s g hg i hi set f : ι → k := fun x => if hx : x = i1 then -∑ y ∈ s, g y else g ⟨x, hx⟩ with hfdef let s2 : Finset ι := insert i1 (s.map (Embedding.subtype _)) have hfg : ∀ x : { x // x ≠ i1 }, g x = f x := by intro x rw [hfdef] dsimp only erw [dif_neg x.property, Subtype.coe_eta] rw [hfg] have hf : ∑ ι ∈ s2, f ι = 0 := by rw [Finset.sum_insert (Finset.not_mem_map_subtype_of_not_property s (Classical.not_not.2 rfl)), Finset.sum_subtype_map_embedding fun x _ => (hfg x).symm] rw [hfdef] dsimp only rw [dif_pos rfl] exact neg_add_self _ have hs2 : s2.weightedVSub p f = (0 : V) := by set f2 : ι → V := fun x => f x • (p x -ᵥ p i1) with hf2def set g2 : { x // x ≠ i1 } → V := fun x => g x • (p x -ᵥ p i1) have hf2g2 : ∀ x : { x // x ≠ i1 }, f2 x = g2 x := by simp only [g2, hf2def] refine fun x => ?_ rw [hfg] rw [Finset.weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero s2 f p hf (p i1), Finset.weightedVSubOfPoint_insert, Finset.weightedVSubOfPoint_apply, Finset.sum_subtype_map_embedding fun x _ => hf2g2 x] exact hg exact h s2 f hf hs2 i (Finset.mem_insert_of_mem (Finset.mem_map.2 ⟨i, hi, rfl⟩)) · intro h rw [linearIndependent_iff'] at h intro s w hw hs i hi rw [Finset.weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero s w p hw (p i1), ← s.weightedVSubOfPoint_erase w p i1, Finset.weightedVSubOfPoint_apply] at hs let f : ι → V := fun i => w i • (p i -ᵥ p i1) have hs2 : (∑ i ∈ (s.erase i1).subtype fun i => i ≠ i1, f i) = 0 := by rw [← hs] convert Finset.sum_subtype_of_mem f fun x => Finset.ne_of_mem_erase have h2 := h ((s.erase i1).subtype fun i => i ≠ i1) (fun x => w x) hs2 simp_rw [Finset.mem_subtype] at h2 have h2b : ∀ i ∈ s, i ≠ i1 → w i = 0 := fun i his hi => h2 ⟨i, hi⟩ (Finset.mem_erase_of_ne_of_mem hi his) exact Finset.eq_zero_of_sum_eq_zero hw h2b i hi #align affine_independent_iff_linear_independent_vsub affineIndependent_iff_linearIndependent_vsub theorem affineIndependent_set_iff_linearIndependent_vsub {s : Set P} {p₁ : P} (hp₁ : p₁ ∈ s) : AffineIndependent k (fun p => p : s → P) ↔ LinearIndependent k (fun v => v : (fun p => (p -ᵥ p₁ : V)) '' (s \ {p₁}) → V) := by rw [affineIndependent_iff_linearIndependent_vsub k (fun p => p : s → P) ⟨p₁, hp₁⟩] constructor · intro h have hv : ∀ v : (fun p => (p -ᵥ p₁ : V)) '' (s \ {p₁}), (v : V) +ᵥ p₁ ∈ s \ {p₁} := fun v => (vsub_left_injective p₁).mem_set_image.1 ((vadd_vsub (v : V) p₁).symm ▸ v.property) let f : (fun p : P => (p -ᵥ p₁ : V)) '' (s \ {p₁}) → { x : s // x ≠ ⟨p₁, hp₁⟩ } := fun x => ⟨⟨(x : V) +ᵥ p₁, Set.mem_of_mem_diff (hv x)⟩, fun hx => Set.not_mem_of_mem_diff (hv x) (Subtype.ext_iff.1 hx)⟩ convert h.comp f fun x1 x2 hx => Subtype.ext (vadd_right_cancel p₁ (Subtype.ext_iff.1 (Subtype.ext_iff.1 hx))) ext v exact (vadd_vsub (v : V) p₁).symm · intro h let f : { x : s // x ≠ ⟨p₁, hp₁⟩ } → (fun p : P => (p -ᵥ p₁ : V)) '' (s \ {p₁}) := fun x => ⟨((x : s) : P) -ᵥ p₁, ⟨x, ⟨⟨(x : s).property, fun hx => x.property (Subtype.ext hx)⟩, rfl⟩⟩⟩ convert h.comp f fun x1 x2 hx => Subtype.ext (Subtype.ext (vsub_left_cancel (Subtype.ext_iff.1 hx))) #align affine_independent_set_iff_linear_independent_vsub affineIndependent_set_iff_linearIndependent_vsub
Mathlib/LinearAlgebra/AffineSpace/Independent.lean
164
173
theorem linearIndependent_set_iff_affineIndependent_vadd_union_singleton {s : Set V} (hs : ∀ v ∈ s, v ≠ (0 : V)) (p₁ : P) : LinearIndependent k (fun v => v : s → V) ↔ AffineIndependent k (fun p => p : ({p₁} ∪ (fun v => v +ᵥ p₁) '' s : Set P) → P) := by
rw [affineIndependent_set_iff_linearIndependent_vsub k (Set.mem_union_left _ (Set.mem_singleton p₁))] have h : (fun p => (p -ᵥ p₁ : V)) '' (({p₁} ∪ (fun v => v +ᵥ p₁) '' s) \ {p₁}) = s := by simp_rw [Set.union_diff_left, Set.image_diff (vsub_left_injective p₁), Set.image_image, Set.image_singleton, vsub_self, vadd_vsub, Set.image_id'] exact Set.diff_singleton_eq_self fun h => hs 0 h rfl rw [h]
import Mathlib.Computability.Halting import Mathlib.Computability.TuringMachine import Mathlib.Data.Num.Lemmas import Mathlib.Tactic.DeriveFintype #align_import computability.tm_to_partrec from "leanprover-community/mathlib"@"6155d4351090a6fad236e3d2e4e0e4e7342668e8" open Function (update) open Relation namespace Turing namespace ToPartrec inductive Code | zero' | succ | tail | cons : Code → Code → Code | comp : Code → Code → Code | case : Code → Code → Code | fix : Code → Code deriving DecidableEq, Inhabited #align turing.to_partrec.code Turing.ToPartrec.Code #align turing.to_partrec.code.zero' Turing.ToPartrec.Code.zero' #align turing.to_partrec.code.succ Turing.ToPartrec.Code.succ #align turing.to_partrec.code.tail Turing.ToPartrec.Code.tail #align turing.to_partrec.code.cons Turing.ToPartrec.Code.cons #align turing.to_partrec.code.comp Turing.ToPartrec.Code.comp #align turing.to_partrec.code.case Turing.ToPartrec.Code.case #align turing.to_partrec.code.fix Turing.ToPartrec.Code.fix def Code.eval : Code → List ℕ →. List ℕ | Code.zero' => fun v => pure (0 :: v) | Code.succ => fun v => pure [v.headI.succ] | Code.tail => fun v => pure v.tail | Code.cons f fs => fun v => do let n ← Code.eval f v let ns ← Code.eval fs v pure (n.headI :: ns) | Code.comp f g => fun v => g.eval v >>= f.eval | Code.case f g => fun v => v.headI.rec (f.eval v.tail) fun y _ => g.eval (y::v.tail) | Code.fix f => PFun.fix fun v => (f.eval v).map fun v => if v.headI = 0 then Sum.inl v.tail else Sum.inr v.tail #align turing.to_partrec.code.eval Turing.ToPartrec.Code.eval namespace Code @[simp] theorem zero'_eval : zero'.eval = fun v => pure (0 :: v) := by simp [eval] @[simp] theorem succ_eval : succ.eval = fun v => pure [v.headI.succ] := by simp [eval] @[simp] theorem tail_eval : tail.eval = fun v => pure v.tail := by simp [eval] @[simp] theorem cons_eval (f fs) : (cons f fs).eval = fun v => do { let n ← Code.eval f v let ns ← Code.eval fs v pure (n.headI :: ns) } := by simp [eval] @[simp] theorem comp_eval (f g) : (comp f g).eval = fun v => g.eval v >>= f.eval := by simp [eval] @[simp] theorem case_eval (f g) : (case f g).eval = fun v => v.headI.rec (f.eval v.tail) fun y _ => g.eval (y::v.tail) := by simp [eval] @[simp] theorem fix_eval (f) : (fix f).eval = PFun.fix fun v => (f.eval v).map fun v => if v.headI = 0 then Sum.inl v.tail else Sum.inr v.tail := by simp [eval] def nil : Code := tail.comp succ #align turing.to_partrec.code.nil Turing.ToPartrec.Code.nil @[simp] theorem nil_eval (v) : nil.eval v = pure [] := by simp [nil] #align turing.to_partrec.code.nil_eval Turing.ToPartrec.Code.nil_eval def id : Code := tail.comp zero' #align turing.to_partrec.code.id Turing.ToPartrec.Code.id @[simp] theorem id_eval (v) : id.eval v = pure v := by simp [id] #align turing.to_partrec.code.id_eval Turing.ToPartrec.Code.id_eval def head : Code := cons id nil #align turing.to_partrec.code.head Turing.ToPartrec.Code.head @[simp] theorem head_eval (v) : head.eval v = pure [v.headI] := by simp [head] #align turing.to_partrec.code.head_eval Turing.ToPartrec.Code.head_eval def zero : Code := cons zero' nil #align turing.to_partrec.code.zero Turing.ToPartrec.Code.zero @[simp] theorem zero_eval (v) : zero.eval v = pure [0] := by simp [zero] #align turing.to_partrec.code.zero_eval Turing.ToPartrec.Code.zero_eval def pred : Code := case zero head #align turing.to_partrec.code.pred Turing.ToPartrec.Code.pred @[simp] theorem pred_eval (v) : pred.eval v = pure [v.headI.pred] := by simp [pred]; cases v.headI <;> simp #align turing.to_partrec.code.pred_eval Turing.ToPartrec.Code.pred_eval def rfind (f : Code) : Code := comp pred <| comp (fix <| cons f <| cons succ tail) zero' #align turing.to_partrec.code.rfind Turing.ToPartrec.Code.rfind def prec (f g : Code) : Code := let G := cons tail <| cons succ <| cons (comp pred tail) <| cons (comp g <| cons id <| comp tail tail) <| comp tail <| comp tail tail let F := case id <| comp (comp (comp tail tail) (fix G)) zero' cons (comp F (cons head <| cons (comp f tail) tail)) nil #align turing.to_partrec.code.prec Turing.ToPartrec.Code.prec attribute [-simp] Part.bind_eq_bind Part.map_eq_map Part.pure_eq_some theorem exists_code.comp {m n} {f : Vector ℕ n →. ℕ} {g : Fin n → Vector ℕ m →. ℕ} (hf : ∃ c : Code, ∀ v : Vector ℕ n, c.eval v.1 = pure <$> f v) (hg : ∀ i, ∃ c : Code, ∀ v : Vector ℕ m, c.eval v.1 = pure <$> g i v) : ∃ c : Code, ∀ v : Vector ℕ m, c.eval v.1 = pure <$> ((Vector.mOfFn fun i => g i v) >>= f) := by rsuffices ⟨cg, hg⟩ : ∃ c : Code, ∀ v : Vector ℕ m, c.eval v.1 = Subtype.val <$> Vector.mOfFn fun i => g i v · obtain ⟨cf, hf⟩ := hf exact ⟨cf.comp cg, fun v => by simp [hg, hf, map_bind, seq_bind_eq, Function.comp] rfl⟩ clear hf f; induction' n with n IH · exact ⟨nil, fun v => by simp [Vector.mOfFn, Bind.bind]; rfl⟩ · obtain ⟨cg, hg₁⟩ := hg 0 obtain ⟨cl, hl⟩ := IH fun i => hg i.succ exact ⟨cons cg cl, fun v => by simp [Vector.mOfFn, hg₁, map_bind, seq_bind_eq, bind_assoc, (· ∘ ·), hl] rfl⟩ #align turing.to_partrec.code.exists_code.comp Turing.ToPartrec.Code.exists_code.comp
Mathlib/Computability/TMToPartrec.lean
285
390
theorem exists_code {n} {f : Vector ℕ n →. ℕ} (hf : Nat.Partrec' f) : ∃ c : Code, ∀ v : Vector ℕ n, c.eval v.1 = pure <$> f v := by
induction hf with | prim hf => induction hf with | zero => exact ⟨zero', fun ⟨[], _⟩ => rfl⟩ | succ => exact ⟨succ, fun ⟨[v], _⟩ => rfl⟩ | get i => refine Fin.succRec (fun n => ?_) (fun n i IH => ?_) i · exact ⟨head, fun ⟨List.cons a as, _⟩ => by simp [Bind.bind]; rfl⟩ · obtain ⟨c, h⟩ := IH exact ⟨c.comp tail, fun v => by simpa [← Vector.get_tail, Bind.bind] using h v.tail⟩ | comp g hf hg IHf IHg => simpa [Part.bind_eq_bind] using exists_code.comp IHf IHg | @prec n f g _ _ IHf IHg => obtain ⟨cf, hf⟩ := IHf obtain ⟨cg, hg⟩ := IHg simp only [Part.map_eq_map, Part.map_some, PFun.coe_val] at hf hg refine ⟨prec cf cg, fun v => ?_⟩ rw [← v.cons_head_tail] specialize hf v.tail replace hg := fun a b => hg (a ::ᵥ b ::ᵥ v.tail) simp only [Vector.cons_val, Vector.tail_val] at hf hg simp only [Part.map_eq_map, Part.map_some, Vector.cons_val, Vector.tail_cons, Vector.head_cons, PFun.coe_val, Vector.tail_val] simp only [← Part.pure_eq_some] at hf hg ⊢ induction' v.head with n _ <;> simp [prec, hf, Part.bind_assoc, ← Part.bind_some_eq_map, Part.bind_some, show ∀ x, pure x = [x] from fun _ => rfl, Bind.bind, Functor.map] suffices ∀ a b, a + b = n → (n.succ :: 0 :: g (n ::ᵥ Nat.rec (f v.tail) (fun y IH => g (y ::ᵥ IH ::ᵥ v.tail)) n ::ᵥ v.tail) :: v.val.tail : List ℕ) ∈ PFun.fix (fun v : List ℕ => Part.bind (cg.eval (v.headI :: v.tail.tail)) (fun x => Part.some (if v.tail.headI = 0 then Sum.inl (v.headI.succ :: v.tail.headI.pred :: x.headI :: v.tail.tail.tail : List ℕ) else Sum.inr (v.headI.succ :: v.tail.headI.pred :: x.headI :: v.tail.tail.tail)))) (a :: b :: Nat.rec (f v.tail) (fun y IH => g (y ::ᵥ IH ::ᵥ v.tail)) a :: v.val.tail) by erw [Part.eq_some_iff.2 (this 0 n (zero_add n))] simp only [List.headI, Part.bind_some, List.tail_cons] intro a b e induction' b with b IH generalizing a · refine PFun.mem_fix_iff.2 (Or.inl <| Part.eq_some_iff.1 ?_) simp only [hg, ← e, Part.bind_some, List.tail_cons, pure] rfl · refine PFun.mem_fix_iff.2 (Or.inr ⟨_, ?_, IH (a + 1) (by rwa [add_right_comm])⟩) simp only [hg, eval, Part.bind_some, Nat.rec_add_one, List.tail_nil, List.tail_cons, pure] exact Part.mem_some_iff.2 rfl | comp g _ _ IHf IHg => exact exists_code.comp IHf IHg | @rfind n f _ IHf => obtain ⟨cf, hf⟩ := IHf; refine ⟨rfind cf, fun v => ?_⟩ replace hf := fun a => hf (a ::ᵥ v) simp only [Part.map_eq_map, Part.map_some, Vector.cons_val, PFun.coe_val, show ∀ x, pure x = [x] from fun _ => rfl] at hf ⊢ refine Part.ext fun x => ?_ simp only [rfind, Part.bind_eq_bind, Part.pure_eq_some, Part.map_eq_map, Part.bind_some, exists_prop, cons_eval, comp_eval, fix_eval, tail_eval, succ_eval, zero'_eval, List.headI_nil, List.headI_cons, pred_eval, Part.map_some, false_eq_decide_iff, Part.mem_bind_iff, List.length, Part.mem_map_iff, Nat.mem_rfind, List.tail_nil, List.tail_cons, true_eq_decide_iff, Part.mem_some_iff, Part.map_bind] constructor · rintro ⟨v', h1, rfl⟩ suffices ∀ v₁ : List ℕ, v' ∈ PFun.fix (fun v => (cf.eval v).bind fun y => Part.some <| if y.headI = 0 then Sum.inl (v.headI.succ :: v.tail) else Sum.inr (v.headI.succ :: v.tail)) v₁ → ∀ n, (v₁ = n :: v.val) → (∀ m < n, ¬f (m ::ᵥ v) = 0) → ∃ a : ℕ, (f (a ::ᵥ v) = 0 ∧ ∀ {m : ℕ}, m < a → ¬f (m ::ᵥ v) = 0) ∧ [a] = [v'.headI.pred] by exact this _ h1 0 rfl (by rintro _ ⟨⟩) clear h1 intro v₀ h1 refine PFun.fixInduction h1 fun v₁ h2 IH => ?_ clear h1 rintro n rfl hm have := PFun.mem_fix_iff.1 h2 simp only [hf, Part.bind_some] at this split_ifs at this with h · simp only [List.headI_nil, List.headI_cons, exists_false, or_false_iff, Part.mem_some_iff, List.tail_cons, false_and_iff, Sum.inl.injEq] at this subst this exact ⟨_, ⟨h, @(hm)⟩, rfl⟩ · refine IH (n.succ::v.val) (by simp_all) _ rfl fun m h' => ?_ obtain h | rfl := Nat.lt_succ_iff_lt_or_eq.1 h' exacts [hm _ h, h] · rintro ⟨n, ⟨hn, hm⟩, rfl⟩ refine ⟨n.succ::v.1, ?_, rfl⟩ have : (n.succ::v.1 : List ℕ) ∈ PFun.fix (fun v => (cf.eval v).bind fun y => Part.some <| if y.headI = 0 then Sum.inl (v.headI.succ :: v.tail) else Sum.inr (v.headI.succ :: v.tail)) (n::v.val) := PFun.mem_fix_iff.2 (Or.inl (by simp [hf, hn])) generalize (n.succ :: v.1 : List ℕ) = w at this ⊢ clear hn induction' n with n IH · exact this refine IH (fun {m} h' => hm (Nat.lt_succ_of_lt h')) (PFun.mem_fix_iff.2 (Or.inr ⟨_, ?_, this⟩)) simp only [hf, hm n.lt_succ_self, Part.bind_some, List.headI, eq_self_iff_true, if_false, Part.mem_some_iff, and_self_iff, List.tail_cons]
import Mathlib.Combinatorics.Enumerative.DoubleCounting import Mathlib.Combinatorics.SimpleGraph.AdjMatrix import Mathlib.Combinatorics.SimpleGraph.Basic import Mathlib.Data.Set.Finite #align_import combinatorics.simple_graph.strongly_regular from "leanprover-community/mathlib"@"2b35fc7bea4640cb75e477e83f32fbd538920822" open Finset universe u namespace SimpleGraph variable {V : Type u} [Fintype V] [DecidableEq V] variable (G : SimpleGraph V) [DecidableRel G.Adj] structure IsSRGWith (n k ℓ μ : ℕ) : Prop where card : Fintype.card V = n regular : G.IsRegularOfDegree k of_adj : ∀ v w : V, G.Adj v w → Fintype.card (G.commonNeighbors v w) = ℓ of_not_adj : Pairwise fun v w => ¬G.Adj v w → Fintype.card (G.commonNeighbors v w) = μ set_option linter.uppercaseLean3 false in #align simple_graph.is_SRG_with SimpleGraph.IsSRGWith variable {G} {n k ℓ μ : ℕ} theorem bot_strongly_regular : (⊥ : SimpleGraph V).IsSRGWith (Fintype.card V) 0 ℓ 0 where card := rfl regular := bot_degree of_adj := fun v w h => h.elim of_not_adj := fun v w _h => by simp only [card_eq_zero, Fintype.card_ofFinset, forall_true_left, not_false_iff, bot_adj] ext simp [mem_commonNeighbors] #align simple_graph.bot_strongly_regular SimpleGraph.bot_strongly_regular theorem IsSRGWith.top : (⊤ : SimpleGraph V).IsSRGWith (Fintype.card V) (Fintype.card V - 1) (Fintype.card V - 2) μ where card := rfl regular := IsRegularOfDegree.top of_adj := fun v w h => by rw [card_commonNeighbors_top] exact h of_not_adj := fun v w h h' => False.elim (h' ((top_adj v w).2 h)) set_option linter.uppercaseLean3 false in #align simple_graph.is_SRG_with.top SimpleGraph.IsSRGWith.top theorem IsSRGWith.card_neighborFinset_union_eq {v w : V} (h : G.IsSRGWith n k ℓ μ) : (G.neighborFinset v ∪ G.neighborFinset w).card = 2 * k - Fintype.card (G.commonNeighbors v w) := by apply Nat.add_right_cancel (m := Fintype.card (G.commonNeighbors v w)) rw [Nat.sub_add_cancel, ← Set.toFinset_card] -- Porting note: Set.toFinset_inter needs workaround to use unification to solve for one of the -- instance arguments: · simp [commonNeighbors, @Set.toFinset_inter _ _ _ _ _ _ (_), ← neighborFinset_def, Finset.card_union_add_card_inter, card_neighborFinset_eq_degree, h.regular.degree_eq, two_mul] · apply le_trans (card_commonNeighbors_le_degree_left _ _ _) simp [h.regular.degree_eq, two_mul] set_option linter.uppercaseLean3 false in #align simple_graph.is_SRG_with.card_neighbor_finset_union_eq SimpleGraph.IsSRGWith.card_neighborFinset_union_eq
Mathlib/Combinatorics/SimpleGraph/StronglyRegular.lean
102
106
theorem IsSRGWith.card_neighborFinset_union_of_not_adj {v w : V} (h : G.IsSRGWith n k ℓ μ) (hne : v ≠ w) (ha : ¬G.Adj v w) : (G.neighborFinset v ∪ G.neighborFinset w).card = 2 * k - μ := by
rw [← h.of_not_adj hne ha] apply h.card_neighborFinset_union_eq
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 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 #align real.exp_log_of_neg Real.exp_log_of_neg theorem le_exp_log (x : ℝ) : x ≤ exp (log x) := by by_cases h_zero : x = 0 · rw [h_zero, log, dif_pos rfl, exp_zero] exact zero_le_one · rw [exp_log_eq_abs h_zero] exact le_abs_self _ #align real.le_exp_log Real.le_exp_log @[simp] theorem log_exp (x : ℝ) : log (exp x) = x := exp_injective <| exp_log (exp_pos x) #align real.log_exp Real.log_exp theorem surjOn_log : SurjOn log (Ioi 0) univ := fun x _ => ⟨exp x, exp_pos x, log_exp x⟩ #align real.surj_on_log Real.surjOn_log theorem log_surjective : Surjective log := fun x => ⟨exp x, log_exp x⟩ #align real.log_surjective Real.log_surjective @[simp] theorem range_log : range log = univ := log_surjective.range_eq #align real.range_log Real.range_log @[simp] theorem log_zero : log 0 = 0 := dif_pos rfl #align real.log_zero Real.log_zero @[simp] theorem log_one : log 1 = 0 := exp_injective <| by rw [exp_log zero_lt_one, exp_zero] #align real.log_one Real.log_one @[simp] theorem log_abs (x : ℝ) : log |x| = log x := by by_cases h : x = 0 · simp [h] · rw [← exp_eq_exp, exp_log_eq_abs h, exp_log_eq_abs (abs_pos.2 h).ne', abs_abs] #align real.log_abs Real.log_abs @[simp] theorem log_neg_eq_log (x : ℝ) : log (-x) = log x := by rw [← log_abs x, ← log_abs (-x), abs_neg] #align real.log_neg_eq_log Real.log_neg_eq_log theorem sinh_log {x : ℝ} (hx : 0 < x) : sinh (log x) = (x - x⁻¹) / 2 := by rw [sinh_eq, exp_neg, exp_log hx] #align real.sinh_log Real.sinh_log
Mathlib/Analysis/SpecialFunctions/Log/Basic.lean
118
119
theorem cosh_log {x : ℝ} (hx : 0 < x) : cosh (log x) = (x + x⁻¹) / 2 := by
rw [cosh_eq, exp_neg, exp_log hx]
import Mathlib.Algebra.Group.Support import Mathlib.Order.WellFoundedSet #align_import ring_theory.hahn_series from "leanprover-community/mathlib"@"a484a7d0eade4e1268f4fb402859b6686037f965" set_option linter.uppercaseLean3 false open Finset Function open scoped Classical noncomputable section @[ext] structure HahnSeries (Γ : Type*) (R : Type*) [PartialOrder Γ] [Zero R] where coeff : Γ → R isPWO_support' : (Function.support coeff).IsPWO #align hahn_series HahnSeries variable {Γ : Type*} {R : Type*} namespace HahnSeries section Zero variable [PartialOrder Γ] [Zero R] theorem coeff_injective : Injective (coeff : HahnSeries Γ R → Γ → R) := HahnSeries.ext #align hahn_series.coeff_injective HahnSeries.coeff_injective @[simp] theorem coeff_inj {x y : HahnSeries Γ R} : x.coeff = y.coeff ↔ x = y := coeff_injective.eq_iff #align hahn_series.coeff_inj HahnSeries.coeff_inj nonrec def support (x : HahnSeries Γ R) : Set Γ := support x.coeff #align hahn_series.support HahnSeries.support @[simp] theorem isPWO_support (x : HahnSeries Γ R) : x.support.IsPWO := x.isPWO_support' #align hahn_series.is_pwo_support HahnSeries.isPWO_support @[simp] theorem isWF_support (x : HahnSeries Γ R) : x.support.IsWF := x.isPWO_support.isWF #align hahn_series.is_wf_support HahnSeries.isWF_support @[simp] theorem mem_support (x : HahnSeries Γ R) (a : Γ) : a ∈ x.support ↔ x.coeff a ≠ 0 := Iff.refl _ #align hahn_series.mem_support HahnSeries.mem_support instance : Zero (HahnSeries Γ R) := ⟨{ coeff := 0 isPWO_support' := by simp }⟩ instance : Inhabited (HahnSeries Γ R) := ⟨0⟩ instance [Subsingleton R] : Subsingleton (HahnSeries Γ R) := ⟨fun a b => a.ext b (Subsingleton.elim _ _)⟩ @[simp] theorem zero_coeff {a : Γ} : (0 : HahnSeries Γ R).coeff a = 0 := rfl #align hahn_series.zero_coeff HahnSeries.zero_coeff @[simp] theorem coeff_fun_eq_zero_iff {x : HahnSeries Γ R} : x.coeff = 0 ↔ x = 0 := coeff_injective.eq_iff' rfl #align hahn_series.coeff_fun_eq_zero_iff HahnSeries.coeff_fun_eq_zero_iff theorem ne_zero_of_coeff_ne_zero {x : HahnSeries Γ R} {g : Γ} (h : x.coeff g ≠ 0) : x ≠ 0 := mt (fun x0 => (x0.symm ▸ zero_coeff : x.coeff g = 0)) h #align hahn_series.ne_zero_of_coeff_ne_zero HahnSeries.ne_zero_of_coeff_ne_zero @[simp] theorem support_zero : support (0 : HahnSeries Γ R) = ∅ := Function.support_zero #align hahn_series.support_zero HahnSeries.support_zero @[simp] nonrec theorem support_nonempty_iff {x : HahnSeries Γ R} : x.support.Nonempty ↔ x ≠ 0 := by rw [support, support_nonempty_iff, Ne, coeff_fun_eq_zero_iff] #align hahn_series.support_nonempty_iff HahnSeries.support_nonempty_iff @[simp] theorem support_eq_empty_iff {x : HahnSeries Γ R} : x.support = ∅ ↔ x = 0 := support_eq_empty_iff.trans coeff_fun_eq_zero_iff #align hahn_series.support_eq_empty_iff HahnSeries.support_eq_empty_iff def ofIterate {Γ' : Type*} [PartialOrder Γ'] (x : HahnSeries Γ (HahnSeries Γ' R)) : HahnSeries (Γ ×ₗ Γ') R where coeff := fun g => coeff (coeff x g.1) g.2 isPWO_support' := by refine Set.PartiallyWellOrderedOn.subsetProdLex ?_ ?_ · refine Set.IsPWO.mono x.isPWO_support' ?_ simp_rw [Set.image_subset_iff, support_subset_iff, Set.mem_preimage, Function.mem_support] exact fun _ ↦ ne_zero_of_coeff_ne_zero · exact fun a => by simpa [Function.mem_support, ne_eq] using (x.coeff a).isPWO_support' @[simp] lemma mk_eq_zero (f : Γ → R) (h) : HahnSeries.mk f h = 0 ↔ f = 0 := by rw [HahnSeries.ext_iff] rfl def toIterate {Γ' : Type*} [PartialOrder Γ'] (x : HahnSeries (Γ ×ₗ Γ') R) : HahnSeries Γ (HahnSeries Γ' R) where coeff := fun g => { coeff := fun g' => coeff x (g, g') isPWO_support' := Set.PartiallyWellOrderedOn.fiberProdLex x.isPWO_support' g } isPWO_support' := by have h₁ : (Function.support fun g => HahnSeries.mk (fun g' => x.coeff (g, g')) (Set.PartiallyWellOrderedOn.fiberProdLex x.isPWO_support' g)) = Function.support fun g => fun g' => x.coeff (g, g') := by simp only [Function.support, ne_eq, mk_eq_zero] rw [h₁, Function.support_curry' x.coeff] exact Set.PartiallyWellOrderedOn.imageProdLex x.isPWO_support' @[simps] def iterateEquiv {Γ' : Type*} [PartialOrder Γ'] : HahnSeries Γ (HahnSeries Γ' R) ≃ HahnSeries (Γ ×ₗ Γ') R where toFun := ofIterate invFun := toIterate left_inv := congrFun rfl right_inv := congrFun rfl def single (a : Γ) : ZeroHom R (HahnSeries Γ R) where toFun r := { coeff := Pi.single a r isPWO_support' := (Set.isPWO_singleton a).mono Pi.support_single_subset } map_zero' := HahnSeries.ext _ _ (Pi.single_zero _) #align hahn_series.single HahnSeries.single variable {a b : Γ} {r : R} @[simp] theorem single_coeff_same (a : Γ) (r : R) : (single a r).coeff a = r := Pi.single_eq_same (f := fun _ => R) a r #align hahn_series.single_coeff_same HahnSeries.single_coeff_same @[simp] theorem single_coeff_of_ne (h : b ≠ a) : (single a r).coeff b = 0 := Pi.single_eq_of_ne (f := fun _ => R) h r #align hahn_series.single_coeff_of_ne HahnSeries.single_coeff_of_ne theorem single_coeff : (single a r).coeff b = if b = a then r else 0 := by split_ifs with h <;> simp [h] #align hahn_series.single_coeff HahnSeries.single_coeff @[simp] theorem support_single_of_ne (h : r ≠ 0) : support (single a r) = {a} := Pi.support_single_of_ne h #align hahn_series.support_single_of_ne HahnSeries.support_single_of_ne theorem support_single_subset : support (single a r) ⊆ {a} := Pi.support_single_subset #align hahn_series.support_single_subset HahnSeries.support_single_subset theorem eq_of_mem_support_single {b : Γ} (h : b ∈ support (single a r)) : b = a := support_single_subset h #align hahn_series.eq_of_mem_support_single HahnSeries.eq_of_mem_support_single --@[simp] Porting note (#10618): simp can prove it theorem single_eq_zero : single a (0 : R) = 0 := (single a).map_zero #align hahn_series.single_eq_zero HahnSeries.single_eq_zero theorem single_injective (a : Γ) : Function.Injective (single a : R → HahnSeries Γ R) := fun r s rs => by rw [← single_coeff_same a r, ← single_coeff_same a s, rs] #align hahn_series.single_injective HahnSeries.single_injective theorem single_ne_zero (h : r ≠ 0) : single a r ≠ 0 := fun con => h (single_injective a (con.trans single_eq_zero.symm)) #align hahn_series.single_ne_zero HahnSeries.single_ne_zero @[simp] theorem single_eq_zero_iff {a : Γ} {r : R} : single a r = 0 ↔ r = 0 := map_eq_zero_iff _ <| single_injective a #align hahn_series.single_eq_zero_iff HahnSeries.single_eq_zero_iff instance [Nonempty Γ] [Nontrivial R] : Nontrivial (HahnSeries Γ R) := ⟨by obtain ⟨r, s, rs⟩ := exists_pair_ne R inhabit Γ refine ⟨single default r, single default s, fun con => rs ?_⟩ rw [← single_coeff_same (default : Γ) r, con, single_coeff_same]⟩ section Order def orderTop (x : HahnSeries Γ R) : WithTop Γ := if h : x = 0 then ⊤ else x.isWF_support.min (support_nonempty_iff.2 h) @[simp] theorem orderTop_zero : orderTop (0 : HahnSeries Γ R) = ⊤ := dif_pos rfl theorem orderTop_of_ne {x : HahnSeries Γ R} (hx : x ≠ 0) : orderTop x = x.isWF_support.min (support_nonempty_iff.2 hx) := dif_neg hx @[simp] theorem ne_zero_iff_orderTop {x : HahnSeries Γ R} : x ≠ 0 ↔ orderTop x ≠ ⊤ := by constructor · exact fun hx => Eq.mpr (congrArg (fun h ↦ h ≠ ⊤) (orderTop_of_ne hx)) WithTop.coe_ne_top · contrapose! simp_all only [orderTop_zero, implies_true] theorem orderTop_eq_top_iff {x : HahnSeries Γ R} : orderTop x = ⊤ ↔ x = 0 := by constructor · contrapose! exact ne_zero_iff_orderTop.mp · simp_all only [orderTop_zero, implies_true] theorem untop_orderTop_of_ne_zero {x : HahnSeries Γ R} (hx : x ≠ 0) : WithTop.untop x.orderTop (ne_zero_iff_orderTop.mp hx) = x.isWF_support.min (support_nonempty_iff.2 hx) := WithTop.coe_inj.mp ((WithTop.coe_untop (orderTop x) (ne_zero_iff_orderTop.mp hx)).trans (orderTop_of_ne hx)) theorem coeff_orderTop_ne {x : HahnSeries Γ R} {g : Γ} (hg : x.orderTop = g) : x.coeff g ≠ 0 := by have h : orderTop x ≠ ⊤ := by simp_all only [ne_eq, WithTop.coe_ne_top, not_false_eq_true] have hx : x ≠ 0 := ne_zero_iff_orderTop.mpr h rw [orderTop_of_ne hx, WithTop.coe_eq_coe] at hg rw [← hg] exact x.isWF_support.min_mem (support_nonempty_iff.2 hx) theorem orderTop_le_of_coeff_ne_zero {Γ} [LinearOrder Γ] {x : HahnSeries Γ R} {g : Γ} (h : x.coeff g ≠ 0) : x.orderTop ≤ g := by rw [orderTop_of_ne (ne_zero_of_coeff_ne_zero h), WithTop.coe_le_coe] exact Set.IsWF.min_le _ _ ((mem_support _ _).2 h) @[simp] theorem orderTop_single (h : r ≠ 0) : (single a r).orderTop = a := (orderTop_of_ne (single_ne_zero h)).trans (WithTop.coe_inj.mpr (support_single_subset ((single a r).isWF_support.min_mem (support_nonempty_iff.2 (single_ne_zero h))))) theorem coeff_eq_zero_of_lt_orderTop {x : HahnSeries Γ R} {i : Γ} (hi : i < x.orderTop) : x.coeff i = 0 := by rcases eq_or_ne x 0 with (rfl | hx) · exact zero_coeff contrapose! hi rw [← mem_support] at hi rw [orderTop_of_ne hx, WithTop.coe_lt_coe] exact Set.IsWF.not_lt_min _ _ hi variable [Zero Γ] def order (x : HahnSeries Γ R) : Γ := if h : x = 0 then 0 else x.isWF_support.min (support_nonempty_iff.2 h) #align hahn_series.order HahnSeries.order @[simp] theorem order_zero : order (0 : HahnSeries Γ R) = 0 := dif_pos rfl #align hahn_series.order_zero HahnSeries.order_zero theorem order_of_ne {x : HahnSeries Γ R} (hx : x ≠ 0) : order x = x.isWF_support.min (support_nonempty_iff.2 hx) := dif_neg hx #align hahn_series.order_of_ne HahnSeries.order_of_ne theorem order_eq_orderTop_of_ne {x : HahnSeries Γ R} (hx : x ≠ 0) : order x = orderTop x := by rw [order_of_ne hx, orderTop_of_ne hx]
Mathlib/RingTheory/HahnSeries/Basic.lean
313
315
theorem coeff_order_ne_zero {x : HahnSeries Γ R} (hx : x ≠ 0) : x.coeff x.order ≠ 0 := by
rw [order_of_ne hx] exact x.isWF_support.min_mem (support_nonempty_iff.2 hx)
import Mathlib.Data.Matrix.Basic variable {l m n o : Type*} universe u v w variable {R : Type*} {α : Type v} {β : Type w} namespace Matrix def col (w : m → α) : Matrix m Unit α := of fun x _ => w x #align matrix.col Matrix.col -- TODO: set as an equation lemma for `col`, see mathlib4#3024 @[simp] theorem col_apply (w : m → α) (i j) : col w i j = w i := rfl #align matrix.col_apply Matrix.col_apply def row (v : n → α) : Matrix Unit n α := of fun _ y => v y #align matrix.row Matrix.row -- TODO: set as an equation lemma for `row`, see mathlib4#3024 @[simp] theorem row_apply (v : n → α) (i j) : row v i j = v j := rfl #align matrix.row_apply Matrix.row_apply theorem col_injective : Function.Injective (col : (m → α) → _) := fun _x _y h => funext fun i => congr_fun₂ h i () @[simp] theorem col_inj {v w : m → α} : col v = col w ↔ v = w := col_injective.eq_iff @[simp] theorem col_zero [Zero α] : col (0 : m → α) = 0 := rfl @[simp] theorem col_eq_zero [Zero α] (v : m → α) : col v = 0 ↔ v = 0 := col_inj @[simp] theorem col_add [Add α] (v w : m → α) : col (v + w) = col v + col w := by ext rfl #align matrix.col_add Matrix.col_add @[simp] theorem col_smul [SMul R α] (x : R) (v : m → α) : col (x • v) = x • col v := by ext rfl #align matrix.col_smul Matrix.col_smul theorem row_injective : Function.Injective (row : (n → α) → _) := fun _x _y h => funext fun j => congr_fun₂ h () j @[simp] theorem row_inj {v w : n → α} : row v = row w ↔ v = w := row_injective.eq_iff @[simp] theorem row_zero [Zero α] : row (0 : n → α) = 0 := rfl @[simp] theorem row_eq_zero [Zero α] (v : n → α) : row v = 0 ↔ v = 0 := row_inj @[simp] theorem row_add [Add α] (v w : m → α) : row (v + w) = row v + row w := by ext rfl #align matrix.row_add Matrix.row_add @[simp] theorem row_smul [SMul R α] (x : R) (v : m → α) : row (x • v) = x • row v := by ext rfl #align matrix.row_smul Matrix.row_smul @[simp] theorem transpose_col (v : m → α) : (Matrix.col v)ᵀ = Matrix.row v := by ext rfl #align matrix.transpose_col Matrix.transpose_col @[simp] theorem transpose_row (v : m → α) : (Matrix.row v)ᵀ = Matrix.col v := by ext rfl #align matrix.transpose_row Matrix.transpose_row @[simp] theorem conjTranspose_col [Star α] (v : m → α) : (col v)ᴴ = row (star v) := by ext rfl #align matrix.conj_transpose_col Matrix.conjTranspose_col @[simp] theorem conjTranspose_row [Star α] (v : m → α) : (row v)ᴴ = col (star v) := by ext rfl #align matrix.conj_transpose_row Matrix.conjTranspose_row theorem row_vecMul [Fintype m] [NonUnitalNonAssocSemiring α] (M : Matrix m n α) (v : m → α) : Matrix.row (v ᵥ* M) = Matrix.row v * M := by ext rfl #align matrix.row_vec_mul Matrix.row_vecMul theorem col_vecMul [Fintype m] [NonUnitalNonAssocSemiring α] (M : Matrix m n α) (v : m → α) : Matrix.col (v ᵥ* M) = (Matrix.row v * M)ᵀ := by ext rfl #align matrix.col_vec_mul Matrix.col_vecMul theorem col_mulVec [Fintype n] [NonUnitalNonAssocSemiring α] (M : Matrix m n α) (v : n → α) : Matrix.col (M *ᵥ v) = M * Matrix.col v := by ext rfl #align matrix.col_mul_vec Matrix.col_mulVec theorem row_mulVec [Fintype n] [NonUnitalNonAssocSemiring α] (M : Matrix m n α) (v : n → α) : Matrix.row (M *ᵥ v) = (M * Matrix.col v)ᵀ := by ext rfl #align matrix.row_mul_vec Matrix.row_mulVec @[simp] theorem row_mul_col_apply [Fintype m] [Mul α] [AddCommMonoid α] (v w : m → α) (i j) : (row v * col w) i j = v ⬝ᵥ w := rfl #align matrix.row_mul_col_apply Matrix.row_mul_col_apply @[simp] theorem diag_col_mul_row [Mul α] [AddCommMonoid α] (a b : n → α) : diag (col a * row b) = a * b := by ext simp [Matrix.mul_apply, col, row] #align matrix.diag_col_mul_row Matrix.diag_col_mul_row theorem vecMulVec_eq [Mul α] [AddCommMonoid α] (w : m → α) (v : n → α) : vecMulVec w v = col w * row v := by ext simp only [vecMulVec, mul_apply, Fintype.univ_punit, Finset.sum_singleton] rfl #align matrix.vec_mul_vec_eq Matrix.vecMulVec_eq def updateRow [DecidableEq m] (M : Matrix m n α) (i : m) (b : n → α) : Matrix m n α := of <| Function.update M i b #align matrix.update_row Matrix.updateRow def updateColumn [DecidableEq n] (M : Matrix m n α) (j : n) (b : m → α) : Matrix m n α := of fun i => Function.update (M i) j (b i) #align matrix.update_column Matrix.updateColumn variable {M : Matrix m n α} {i : m} {j : n} {b : n → α} {c : m → α} @[simp] theorem updateRow_self [DecidableEq m] : updateRow M i b i = b := -- Porting note: (implicit arg) added `(β := _)` Function.update_same (β := fun _ => (n → α)) i b M #align matrix.update_row_self Matrix.updateRow_self @[simp] theorem updateColumn_self [DecidableEq n] : updateColumn M j c i j = c i := -- Porting note: (implicit arg) added `(β := _)` Function.update_same (β := fun _ => α) j (c i) (M i) #align matrix.update_column_self Matrix.updateColumn_self @[simp] theorem updateRow_ne [DecidableEq m] {i' : m} (i_ne : i' ≠ i) : updateRow M i b i' = M i' := -- Porting note: (implicit arg) added `(β := _)` Function.update_noteq (β := fun _ => (n → α)) i_ne b M #align matrix.update_row_ne Matrix.updateRow_ne @[simp] theorem updateColumn_ne [DecidableEq n] {j' : n} (j_ne : j' ≠ j) : updateColumn M j c i j' = M i j' := -- Porting note: (implicit arg) added `(β := _)` Function.update_noteq (β := fun _ => α) j_ne (c i) (M i) #align matrix.update_column_ne Matrix.updateColumn_ne theorem updateRow_apply [DecidableEq m] {i' : m} : updateRow M i b i' j = if i' = i then b j else M i' j := by by_cases h : i' = i · rw [h, updateRow_self, if_pos rfl] · rw [updateRow_ne h, if_neg h] #align matrix.update_row_apply Matrix.updateRow_apply theorem updateColumn_apply [DecidableEq n] {j' : n} : updateColumn M j c i j' = if j' = j then c i else M i j' := by by_cases h : j' = j · rw [h, updateColumn_self, if_pos rfl] · rw [updateColumn_ne h, if_neg h] #align matrix.update_column_apply Matrix.updateColumn_apply @[simp] theorem updateColumn_subsingleton [Subsingleton n] (A : Matrix m n R) (i : n) (b : m → R) : A.updateColumn i b = (col b).submatrix id (Function.const n ()) := by ext x y simp [updateColumn_apply, Subsingleton.elim i y] #align matrix.update_column_subsingleton Matrix.updateColumn_subsingleton @[simp] theorem updateRow_subsingleton [Subsingleton m] (A : Matrix m n R) (i : m) (b : n → R) : A.updateRow i b = (row b).submatrix (Function.const m ()) id := by ext x y simp [updateColumn_apply, Subsingleton.elim i x] #align matrix.update_row_subsingleton Matrix.updateRow_subsingleton theorem map_updateRow [DecidableEq m] (f : α → β) : map (updateRow M i b) f = updateRow (M.map f) i (f ∘ b) := by ext rw [updateRow_apply, map_apply, map_apply, updateRow_apply] exact apply_ite f _ _ _ #align matrix.map_update_row Matrix.map_updateRow theorem map_updateColumn [DecidableEq n] (f : α → β) : map (updateColumn M j c) f = updateColumn (M.map f) j (f ∘ c) := by ext rw [updateColumn_apply, map_apply, map_apply, updateColumn_apply] exact apply_ite f _ _ _ #align matrix.map_update_column Matrix.map_updateColumn theorem updateRow_transpose [DecidableEq n] : updateRow Mᵀ j c = (updateColumn M j c)ᵀ := by ext rw [transpose_apply, updateRow_apply, updateColumn_apply] rfl #align matrix.update_row_transpose Matrix.updateRow_transpose theorem updateColumn_transpose [DecidableEq m] : updateColumn Mᵀ i b = (updateRow M i b)ᵀ := by ext rw [transpose_apply, updateRow_apply, updateColumn_apply] rfl #align matrix.update_column_transpose Matrix.updateColumn_transpose theorem updateRow_conjTranspose [DecidableEq n] [Star α] : updateRow Mᴴ j (star c) = (updateColumn M j c)ᴴ := by rw [conjTranspose, conjTranspose, transpose_map, transpose_map, updateRow_transpose, map_updateColumn] rfl #align matrix.update_row_conj_transpose Matrix.updateRow_conjTranspose
Mathlib/Data/Matrix/RowCol.lean
261
265
theorem updateColumn_conjTranspose [DecidableEq m] [Star α] : updateColumn Mᴴ i (star b) = (updateRow M i b)ᴴ := by
rw [conjTranspose, conjTranspose, transpose_map, transpose_map, updateColumn_transpose, map_updateRow] rfl
import Mathlib.Data.Fintype.Option import Mathlib.Data.Fintype.Prod import Mathlib.Data.Fintype.Pi import Mathlib.Data.Vector.Basic import Mathlib.Data.PFun import Mathlib.Logic.Function.Iterate import Mathlib.Order.Basic import Mathlib.Tactic.ApplyFun #align_import computability.turing_machine from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" assert_not_exists MonoidWithZero open Relation open Nat (iterate) open Function (update iterate_succ iterate_succ_apply iterate_succ' iterate_succ_apply' iterate_zero_apply) namespace Turing def BlankExtends {Γ} [Inhabited Γ] (l₁ l₂ : List Γ) : Prop := ∃ n, l₂ = l₁ ++ List.replicate n default #align turing.blank_extends Turing.BlankExtends @[refl] theorem BlankExtends.refl {Γ} [Inhabited Γ] (l : List Γ) : BlankExtends l l := ⟨0, by simp⟩ #align turing.blank_extends.refl Turing.BlankExtends.refl @[trans] theorem BlankExtends.trans {Γ} [Inhabited Γ] {l₁ l₂ l₃ : List Γ} : BlankExtends l₁ l₂ → BlankExtends l₂ l₃ → BlankExtends l₁ l₃ := by rintro ⟨i, rfl⟩ ⟨j, rfl⟩ exact ⟨i + j, by simp [List.replicate_add]⟩ #align turing.blank_extends.trans Turing.BlankExtends.trans theorem BlankExtends.below_of_le {Γ} [Inhabited Γ] {l l₁ l₂ : List Γ} : BlankExtends l l₁ → BlankExtends l l₂ → l₁.length ≤ l₂.length → BlankExtends l₁ l₂ := by rintro ⟨i, rfl⟩ ⟨j, rfl⟩ h; use j - i simp only [List.length_append, Nat.add_le_add_iff_left, List.length_replicate] at h simp only [← List.replicate_add, Nat.add_sub_cancel' h, List.append_assoc] #align turing.blank_extends.below_of_le Turing.BlankExtends.below_of_le def BlankExtends.above {Γ} [Inhabited Γ] {l l₁ l₂ : List Γ} (h₁ : BlankExtends l l₁) (h₂ : BlankExtends l l₂) : { l' // BlankExtends l₁ l' ∧ BlankExtends l₂ l' } := if h : l₁.length ≤ l₂.length then ⟨l₂, h₁.below_of_le h₂ h, BlankExtends.refl _⟩ else ⟨l₁, BlankExtends.refl _, h₂.below_of_le h₁ (le_of_not_ge h)⟩ #align turing.blank_extends.above Turing.BlankExtends.above theorem BlankExtends.above_of_le {Γ} [Inhabited Γ] {l l₁ l₂ : List Γ} : BlankExtends l₁ l → BlankExtends l₂ l → l₁.length ≤ l₂.length → BlankExtends l₁ l₂ := by rintro ⟨i, rfl⟩ ⟨j, e⟩ h; use i - j refine List.append_cancel_right (e.symm.trans ?_) rw [List.append_assoc, ← List.replicate_add, Nat.sub_add_cancel] apply_fun List.length at e simp only [List.length_append, List.length_replicate] at e rwa [← Nat.add_le_add_iff_left, e, Nat.add_le_add_iff_right] #align turing.blank_extends.above_of_le Turing.BlankExtends.above_of_le def BlankRel {Γ} [Inhabited Γ] (l₁ l₂ : List Γ) : Prop := BlankExtends l₁ l₂ ∨ BlankExtends l₂ l₁ #align turing.blank_rel Turing.BlankRel @[refl] theorem BlankRel.refl {Γ} [Inhabited Γ] (l : List Γ) : BlankRel l l := Or.inl (BlankExtends.refl _) #align turing.blank_rel.refl Turing.BlankRel.refl @[symm] theorem BlankRel.symm {Γ} [Inhabited Γ] {l₁ l₂ : List Γ} : BlankRel l₁ l₂ → BlankRel l₂ l₁ := Or.symm #align turing.blank_rel.symm Turing.BlankRel.symm @[trans] theorem BlankRel.trans {Γ} [Inhabited Γ] {l₁ l₂ l₃ : List Γ} : BlankRel l₁ l₂ → BlankRel l₂ l₃ → BlankRel l₁ l₃ := by rintro (h₁ | h₁) (h₂ | h₂) · exact Or.inl (h₁.trans h₂) · rcases le_total l₁.length l₃.length with h | h · exact Or.inl (h₁.above_of_le h₂ h) · exact Or.inr (h₂.above_of_le h₁ h) · rcases le_total l₁.length l₃.length with h | h · exact Or.inl (h₁.below_of_le h₂ h) · exact Or.inr (h₂.below_of_le h₁ h) · exact Or.inr (h₂.trans h₁) #align turing.blank_rel.trans Turing.BlankRel.trans def BlankRel.above {Γ} [Inhabited Γ] {l₁ l₂ : List Γ} (h : BlankRel l₁ l₂) : { l // BlankExtends l₁ l ∧ BlankExtends l₂ l } := by refine if hl : l₁.length ≤ l₂.length then ⟨l₂, Or.elim h id fun h' ↦ ?_, BlankExtends.refl _⟩ else ⟨l₁, BlankExtends.refl _, Or.elim h (fun h' ↦ ?_) id⟩ · exact (BlankExtends.refl _).above_of_le h' hl · exact (BlankExtends.refl _).above_of_le h' (le_of_not_ge hl) #align turing.blank_rel.above Turing.BlankRel.above def BlankRel.below {Γ} [Inhabited Γ] {l₁ l₂ : List Γ} (h : BlankRel l₁ l₂) : { l // BlankExtends l l₁ ∧ BlankExtends l l₂ } := by refine if hl : l₁.length ≤ l₂.length then ⟨l₁, BlankExtends.refl _, Or.elim h id fun h' ↦ ?_⟩ else ⟨l₂, Or.elim h (fun h' ↦ ?_) id, BlankExtends.refl _⟩ · exact (BlankExtends.refl _).above_of_le h' hl · exact (BlankExtends.refl _).above_of_le h' (le_of_not_ge hl) #align turing.blank_rel.below Turing.BlankRel.below theorem BlankRel.equivalence (Γ) [Inhabited Γ] : Equivalence (@BlankRel Γ _) := ⟨BlankRel.refl, @BlankRel.symm _ _, @BlankRel.trans _ _⟩ #align turing.blank_rel.equivalence Turing.BlankRel.equivalence def BlankRel.setoid (Γ) [Inhabited Γ] : Setoid (List Γ) := ⟨_, BlankRel.equivalence _⟩ #align turing.blank_rel.setoid Turing.BlankRel.setoid def ListBlank (Γ) [Inhabited Γ] := Quotient (BlankRel.setoid Γ) #align turing.list_blank Turing.ListBlank instance ListBlank.inhabited {Γ} [Inhabited Γ] : Inhabited (ListBlank Γ) := ⟨Quotient.mk'' []⟩ #align turing.list_blank.inhabited Turing.ListBlank.inhabited instance ListBlank.hasEmptyc {Γ} [Inhabited Γ] : EmptyCollection (ListBlank Γ) := ⟨Quotient.mk'' []⟩ #align turing.list_blank.has_emptyc Turing.ListBlank.hasEmptyc -- Porting note: Removed `@[elab_as_elim]` protected abbrev ListBlank.liftOn {Γ} [Inhabited Γ] {α} (l : ListBlank Γ) (f : List Γ → α) (H : ∀ a b, BlankExtends a b → f a = f b) : α := l.liftOn' f <| by rintro a b (h | h) <;> [exact H _ _ h; exact (H _ _ h).symm] #align turing.list_blank.lift_on Turing.ListBlank.liftOn def ListBlank.mk {Γ} [Inhabited Γ] : List Γ → ListBlank Γ := Quotient.mk'' #align turing.list_blank.mk Turing.ListBlank.mk @[elab_as_elim] protected theorem ListBlank.induction_on {Γ} [Inhabited Γ] {p : ListBlank Γ → Prop} (q : ListBlank Γ) (h : ∀ a, p (ListBlank.mk a)) : p q := Quotient.inductionOn' q h #align turing.list_blank.induction_on Turing.ListBlank.induction_on def ListBlank.head {Γ} [Inhabited Γ] (l : ListBlank Γ) : Γ := by apply l.liftOn List.headI rintro a _ ⟨i, rfl⟩ cases a · cases i <;> rfl rfl #align turing.list_blank.head Turing.ListBlank.head @[simp] theorem ListBlank.head_mk {Γ} [Inhabited Γ] (l : List Γ) : ListBlank.head (ListBlank.mk l) = l.headI := rfl #align turing.list_blank.head_mk Turing.ListBlank.head_mk def ListBlank.tail {Γ} [Inhabited Γ] (l : ListBlank Γ) : ListBlank Γ := by apply l.liftOn (fun l ↦ ListBlank.mk l.tail) rintro a _ ⟨i, rfl⟩ refine Quotient.sound' (Or.inl ?_) cases a · cases' i with i <;> [exact ⟨0, rfl⟩; exact ⟨i, rfl⟩] exact ⟨i, rfl⟩ #align turing.list_blank.tail Turing.ListBlank.tail @[simp] theorem ListBlank.tail_mk {Γ} [Inhabited Γ] (l : List Γ) : ListBlank.tail (ListBlank.mk l) = ListBlank.mk l.tail := rfl #align turing.list_blank.tail_mk Turing.ListBlank.tail_mk def ListBlank.cons {Γ} [Inhabited Γ] (a : Γ) (l : ListBlank Γ) : ListBlank Γ := by apply l.liftOn (fun l ↦ ListBlank.mk (List.cons a l)) rintro _ _ ⟨i, rfl⟩ exact Quotient.sound' (Or.inl ⟨i, rfl⟩) #align turing.list_blank.cons Turing.ListBlank.cons @[simp] theorem ListBlank.cons_mk {Γ} [Inhabited Γ] (a : Γ) (l : List Γ) : ListBlank.cons a (ListBlank.mk l) = ListBlank.mk (a :: l) := rfl #align turing.list_blank.cons_mk Turing.ListBlank.cons_mk @[simp] theorem ListBlank.head_cons {Γ} [Inhabited Γ] (a : Γ) : ∀ l : ListBlank Γ, (l.cons a).head = a := Quotient.ind' fun _ ↦ rfl #align turing.list_blank.head_cons Turing.ListBlank.head_cons @[simp] theorem ListBlank.tail_cons {Γ} [Inhabited Γ] (a : Γ) : ∀ l : ListBlank Γ, (l.cons a).tail = l := Quotient.ind' fun _ ↦ rfl #align turing.list_blank.tail_cons Turing.ListBlank.tail_cons @[simp] theorem ListBlank.cons_head_tail {Γ} [Inhabited Γ] : ∀ l : ListBlank Γ, l.tail.cons l.head = l := by apply Quotient.ind' refine fun l ↦ Quotient.sound' (Or.inr ?_) cases l · exact ⟨1, rfl⟩ · rfl #align turing.list_blank.cons_head_tail Turing.ListBlank.cons_head_tail theorem ListBlank.exists_cons {Γ} [Inhabited Γ] (l : ListBlank Γ) : ∃ a l', l = ListBlank.cons a l' := ⟨_, _, (ListBlank.cons_head_tail _).symm⟩ #align turing.list_blank.exists_cons Turing.ListBlank.exists_cons def ListBlank.nth {Γ} [Inhabited Γ] (l : ListBlank Γ) (n : ℕ) : Γ := by apply l.liftOn (fun l ↦ List.getI l n) rintro l _ ⟨i, rfl⟩ cases' lt_or_le n _ with h h · rw [List.getI_append _ _ _ h] rw [List.getI_eq_default _ h] rcases le_or_lt _ n with h₂ | h₂ · rw [List.getI_eq_default _ h₂] rw [List.getI_eq_get _ h₂, List.get_append_right' h, List.get_replicate] #align turing.list_blank.nth Turing.ListBlank.nth @[simp] theorem ListBlank.nth_mk {Γ} [Inhabited Γ] (l : List Γ) (n : ℕ) : (ListBlank.mk l).nth n = l.getI n := rfl #align turing.list_blank.nth_mk Turing.ListBlank.nth_mk @[simp] theorem ListBlank.nth_zero {Γ} [Inhabited Γ] (l : ListBlank Γ) : l.nth 0 = l.head := by conv => lhs; rw [← ListBlank.cons_head_tail l] exact Quotient.inductionOn' l.tail fun l ↦ rfl #align turing.list_blank.nth_zero Turing.ListBlank.nth_zero @[simp] theorem ListBlank.nth_succ {Γ} [Inhabited Γ] (l : ListBlank Γ) (n : ℕ) : l.nth (n + 1) = l.tail.nth n := by conv => lhs; rw [← ListBlank.cons_head_tail l] exact Quotient.inductionOn' l.tail fun l ↦ rfl #align turing.list_blank.nth_succ Turing.ListBlank.nth_succ @[ext] theorem ListBlank.ext {Γ} [i : Inhabited Γ] {L₁ L₂ : ListBlank Γ} : (∀ i, L₁.nth i = L₂.nth i) → L₁ = L₂ := by refine ListBlank.induction_on L₁ fun l₁ ↦ ListBlank.induction_on L₂ fun l₂ H ↦ ?_ wlog h : l₁.length ≤ l₂.length · cases le_total l₁.length l₂.length <;> [skip; symm] <;> apply this <;> try assumption intro rw [H] refine Quotient.sound' (Or.inl ⟨l₂.length - l₁.length, ?_⟩) refine List.ext_get ?_ fun i h h₂ ↦ Eq.symm ?_ · simp only [Nat.add_sub_cancel' h, List.length_append, List.length_replicate] simp only [ListBlank.nth_mk] at H cases' lt_or_le i l₁.length with h' h' · simp only [List.get_append _ h', List.get?_eq_get h, List.get?_eq_get h', ← List.getI_eq_get _ h, ← List.getI_eq_get _ h', H] · simp only [List.get_append_right' h', List.get_replicate, List.get?_eq_get h, List.get?_len_le h', ← List.getI_eq_default _ h', H, List.getI_eq_get _ h] #align turing.list_blank.ext Turing.ListBlank.ext @[simp] def ListBlank.modifyNth {Γ} [Inhabited Γ] (f : Γ → Γ) : ℕ → ListBlank Γ → ListBlank Γ | 0, L => L.tail.cons (f L.head) | n + 1, L => (L.tail.modifyNth f n).cons L.head #align turing.list_blank.modify_nth Turing.ListBlank.modifyNth theorem ListBlank.nth_modifyNth {Γ} [Inhabited Γ] (f : Γ → Γ) (n i) (L : ListBlank Γ) : (L.modifyNth f n).nth i = if i = n then f (L.nth i) else L.nth i := by induction' n with n IH generalizing i L · cases i <;> simp only [ListBlank.nth_zero, if_true, ListBlank.head_cons, ListBlank.modifyNth, ListBlank.nth_succ, if_false, ListBlank.tail_cons, Nat.zero_eq] · cases i · rw [if_neg (Nat.succ_ne_zero _).symm] simp only [ListBlank.nth_zero, ListBlank.head_cons, ListBlank.modifyNth, Nat.zero_eq] · simp only [IH, ListBlank.modifyNth, ListBlank.nth_succ, ListBlank.tail_cons, Nat.succ.injEq] #align turing.list_blank.nth_modify_nth Turing.ListBlank.nth_modifyNth structure PointedMap.{u, v} (Γ : Type u) (Γ' : Type v) [Inhabited Γ] [Inhabited Γ'] : Type max u v where f : Γ → Γ' map_pt' : f default = default #align turing.pointed_map Turing.PointedMap instance {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] : Inhabited (PointedMap Γ Γ') := ⟨⟨default, rfl⟩⟩ instance {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] : CoeFun (PointedMap Γ Γ') fun _ ↦ Γ → Γ' := ⟨PointedMap.f⟩ -- @[simp] -- Porting note (#10685): dsimp can prove this theorem PointedMap.mk_val {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : Γ → Γ') (pt) : (PointedMap.mk f pt : Γ → Γ') = f := rfl #align turing.pointed_map.mk_val Turing.PointedMap.mk_val @[simp] theorem PointedMap.map_pt {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') : f default = default := PointedMap.map_pt' _ #align turing.pointed_map.map_pt Turing.PointedMap.map_pt @[simp] theorem PointedMap.headI_map {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : List Γ) : (l.map f).headI = f l.headI := by cases l <;> [exact (PointedMap.map_pt f).symm; rfl] #align turing.pointed_map.head_map Turing.PointedMap.headI_map def ListBlank.map {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : ListBlank Γ) : ListBlank Γ' := by apply l.liftOn (fun l ↦ ListBlank.mk (List.map f l)) rintro l _ ⟨i, rfl⟩; refine Quotient.sound' (Or.inl ⟨i, ?_⟩) simp only [PointedMap.map_pt, List.map_append, List.map_replicate] #align turing.list_blank.map Turing.ListBlank.map @[simp] theorem ListBlank.map_mk {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : List Γ) : (ListBlank.mk l).map f = ListBlank.mk (l.map f) := rfl #align turing.list_blank.map_mk Turing.ListBlank.map_mk @[simp] theorem ListBlank.head_map {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : ListBlank Γ) : (l.map f).head = f l.head := by conv => lhs; rw [← ListBlank.cons_head_tail l] exact Quotient.inductionOn' l fun a ↦ rfl #align turing.list_blank.head_map Turing.ListBlank.head_map @[simp] theorem ListBlank.tail_map {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : ListBlank Γ) : (l.map f).tail = l.tail.map f := by conv => lhs; rw [← ListBlank.cons_head_tail l] exact Quotient.inductionOn' l fun a ↦ rfl #align turing.list_blank.tail_map Turing.ListBlank.tail_map @[simp] theorem ListBlank.map_cons {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : ListBlank Γ) (a : Γ) : (l.cons a).map f = (l.map f).cons (f a) := by refine (ListBlank.cons_head_tail _).symm.trans ?_ simp only [ListBlank.head_map, ListBlank.head_cons, ListBlank.tail_map, ListBlank.tail_cons] #align turing.list_blank.map_cons Turing.ListBlank.map_cons @[simp] theorem ListBlank.nth_map {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : ListBlank Γ) (n : ℕ) : (l.map f).nth n = f (l.nth n) := by refine l.inductionOn fun l ↦ ?_ -- Porting note: Added `suffices` to get `simp` to work. suffices ((mk l).map f).nth n = f ((mk l).nth n) by exact this simp only [List.get?_map, ListBlank.map_mk, ListBlank.nth_mk, List.getI_eq_iget_get?] cases l.get? n · exact f.2.symm · rfl #align turing.list_blank.nth_map Turing.ListBlank.nth_map def proj {ι : Type*} {Γ : ι → Type*} [∀ i, Inhabited (Γ i)] (i : ι) : PointedMap (∀ i, Γ i) (Γ i) := ⟨fun a ↦ a i, rfl⟩ #align turing.proj Turing.proj theorem proj_map_nth {ι : Type*} {Γ : ι → Type*} [∀ i, Inhabited (Γ i)] (i : ι) (L n) : (ListBlank.map (@proj ι Γ _ i) L).nth n = L.nth n i := by rw [ListBlank.nth_map]; rfl #align turing.proj_map_nth Turing.proj_map_nth theorem ListBlank.map_modifyNth {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (F : PointedMap Γ Γ') (f : Γ → Γ) (f' : Γ' → Γ') (H : ∀ x, F (f x) = f' (F x)) (n) (L : ListBlank Γ) : (L.modifyNth f n).map F = (L.map F).modifyNth f' n := by induction' n with n IH generalizing L <;> simp only [*, ListBlank.head_map, ListBlank.modifyNth, ListBlank.map_cons, ListBlank.tail_map] #align turing.list_blank.map_modify_nth Turing.ListBlank.map_modifyNth @[simp] def ListBlank.append {Γ} [Inhabited Γ] : List Γ → ListBlank Γ → ListBlank Γ | [], L => L | a :: l, L => ListBlank.cons a (ListBlank.append l L) #align turing.list_blank.append Turing.ListBlank.append @[simp] theorem ListBlank.append_mk {Γ} [Inhabited Γ] (l₁ l₂ : List Γ) : ListBlank.append l₁ (ListBlank.mk l₂) = ListBlank.mk (l₁ ++ l₂) := by induction l₁ <;> simp only [*, ListBlank.append, List.nil_append, List.cons_append, ListBlank.cons_mk] #align turing.list_blank.append_mk Turing.ListBlank.append_mk theorem ListBlank.append_assoc {Γ} [Inhabited Γ] (l₁ l₂ : List Γ) (l₃ : ListBlank Γ) : ListBlank.append (l₁ ++ l₂) l₃ = ListBlank.append l₁ (ListBlank.append l₂ l₃) := by refine l₃.inductionOn fun l ↦ ?_ -- Porting note: Added `suffices` to get `simp` to work. suffices append (l₁ ++ l₂) (mk l) = append l₁ (append l₂ (mk l)) by exact this simp only [ListBlank.append_mk, List.append_assoc] #align turing.list_blank.append_assoc Turing.ListBlank.append_assoc def ListBlank.bind {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (l : ListBlank Γ) (f : Γ → List Γ') (hf : ∃ n, f default = List.replicate n default) : ListBlank Γ' := by apply l.liftOn (fun l ↦ ListBlank.mk (List.bind l f)) rintro l _ ⟨i, rfl⟩; cases' hf with n e; refine Quotient.sound' (Or.inl ⟨i * n, ?_⟩) rw [List.append_bind, mul_comm]; congr induction' i with i IH · rfl simp only [IH, e, List.replicate_add, Nat.mul_succ, add_comm, List.replicate_succ, List.cons_bind] #align turing.list_blank.bind Turing.ListBlank.bind @[simp] theorem ListBlank.bind_mk {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (l : List Γ) (f : Γ → List Γ') (hf) : (ListBlank.mk l).bind f hf = ListBlank.mk (l.bind f) := rfl #align turing.list_blank.bind_mk Turing.ListBlank.bind_mk @[simp] theorem ListBlank.cons_bind {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (a : Γ) (l : ListBlank Γ) (f : Γ → List Γ') (hf) : (l.cons a).bind f hf = (l.bind f hf).append (f a) := by refine l.inductionOn fun l ↦ ?_ -- Porting note: Added `suffices` to get `simp` to work. suffices ((mk l).cons a).bind f hf = ((mk l).bind f hf).append (f a) by exact this simp only [ListBlank.append_mk, ListBlank.bind_mk, ListBlank.cons_mk, List.cons_bind] #align turing.list_blank.cons_bind Turing.ListBlank.cons_bind structure Tape (Γ : Type*) [Inhabited Γ] where head : Γ left : ListBlank Γ right : ListBlank Γ #align turing.tape Turing.Tape instance Tape.inhabited {Γ} [Inhabited Γ] : Inhabited (Tape Γ) := ⟨by constructor <;> apply default⟩ #align turing.tape.inhabited Turing.Tape.inhabited inductive Dir | left | right deriving DecidableEq, Inhabited #align turing.dir Turing.Dir def Tape.left₀ {Γ} [Inhabited Γ] (T : Tape Γ) : ListBlank Γ := T.left.cons T.head #align turing.tape.left₀ Turing.Tape.left₀ def Tape.right₀ {Γ} [Inhabited Γ] (T : Tape Γ) : ListBlank Γ := T.right.cons T.head #align turing.tape.right₀ Turing.Tape.right₀ def Tape.move {Γ} [Inhabited Γ] : Dir → Tape Γ → Tape Γ | Dir.left, ⟨a, L, R⟩ => ⟨L.head, L.tail, R.cons a⟩ | Dir.right, ⟨a, L, R⟩ => ⟨R.head, L.cons a, R.tail⟩ #align turing.tape.move Turing.Tape.move @[simp] theorem Tape.move_left_right {Γ} [Inhabited Γ] (T : Tape Γ) : (T.move Dir.left).move Dir.right = T := by cases T; simp [Tape.move] #align turing.tape.move_left_right Turing.Tape.move_left_right @[simp] theorem Tape.move_right_left {Γ} [Inhabited Γ] (T : Tape Γ) : (T.move Dir.right).move Dir.left = T := by cases T; simp [Tape.move] #align turing.tape.move_right_left Turing.Tape.move_right_left def Tape.mk' {Γ} [Inhabited Γ] (L R : ListBlank Γ) : Tape Γ := ⟨R.head, L, R.tail⟩ #align turing.tape.mk' Turing.Tape.mk' @[simp] theorem Tape.mk'_left {Γ} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).left = L := rfl #align turing.tape.mk'_left Turing.Tape.mk'_left @[simp] theorem Tape.mk'_head {Γ} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).head = R.head := rfl #align turing.tape.mk'_head Turing.Tape.mk'_head @[simp] theorem Tape.mk'_right {Γ} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).right = R.tail := rfl #align turing.tape.mk'_right Turing.Tape.mk'_right @[simp] theorem Tape.mk'_right₀ {Γ} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).right₀ = R := ListBlank.cons_head_tail _ #align turing.tape.mk'_right₀ Turing.Tape.mk'_right₀ @[simp] theorem Tape.mk'_left_right₀ {Γ} [Inhabited Γ] (T : Tape Γ) : Tape.mk' T.left T.right₀ = T := by cases T simp only [Tape.right₀, Tape.mk', ListBlank.head_cons, ListBlank.tail_cons, eq_self_iff_true, and_self_iff] #align turing.tape.mk'_left_right₀ Turing.Tape.mk'_left_right₀ theorem Tape.exists_mk' {Γ} [Inhabited Γ] (T : Tape Γ) : ∃ L R, T = Tape.mk' L R := ⟨_, _, (Tape.mk'_left_right₀ _).symm⟩ #align turing.tape.exists_mk' Turing.Tape.exists_mk' @[simp] theorem Tape.move_left_mk' {Γ} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).move Dir.left = Tape.mk' L.tail (R.cons L.head) := by simp only [Tape.move, Tape.mk', ListBlank.head_cons, eq_self_iff_true, ListBlank.cons_head_tail, and_self_iff, ListBlank.tail_cons] #align turing.tape.move_left_mk' Turing.Tape.move_left_mk' @[simp] theorem Tape.move_right_mk' {Γ} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).move Dir.right = Tape.mk' (L.cons R.head) R.tail := by simp only [Tape.move, Tape.mk', ListBlank.head_cons, eq_self_iff_true, ListBlank.cons_head_tail, and_self_iff, ListBlank.tail_cons] #align turing.tape.move_right_mk' Turing.Tape.move_right_mk' def Tape.mk₂ {Γ} [Inhabited Γ] (L R : List Γ) : Tape Γ := Tape.mk' (ListBlank.mk L) (ListBlank.mk R) #align turing.tape.mk₂ Turing.Tape.mk₂ def Tape.mk₁ {Γ} [Inhabited Γ] (l : List Γ) : Tape Γ := Tape.mk₂ [] l #align turing.tape.mk₁ Turing.Tape.mk₁ def Tape.nth {Γ} [Inhabited Γ] (T : Tape Γ) : ℤ → Γ | 0 => T.head | (n + 1 : ℕ) => T.right.nth n | -(n + 1 : ℕ) => T.left.nth n #align turing.tape.nth Turing.Tape.nth @[simp] theorem Tape.nth_zero {Γ} [Inhabited Γ] (T : Tape Γ) : T.nth 0 = T.1 := rfl #align turing.tape.nth_zero Turing.Tape.nth_zero theorem Tape.right₀_nth {Γ} [Inhabited Γ] (T : Tape Γ) (n : ℕ) : T.right₀.nth n = T.nth n := by cases n <;> simp only [Tape.nth, Tape.right₀, Int.ofNat_zero, ListBlank.nth_zero, ListBlank.nth_succ, ListBlank.head_cons, ListBlank.tail_cons, Nat.zero_eq] #align turing.tape.right₀_nth Turing.Tape.right₀_nth @[simp] theorem Tape.mk'_nth_nat {Γ} [Inhabited Γ] (L R : ListBlank Γ) (n : ℕ) : (Tape.mk' L R).nth n = R.nth n := by rw [← Tape.right₀_nth, Tape.mk'_right₀] #align turing.tape.mk'_nth_nat Turing.Tape.mk'_nth_nat @[simp] theorem Tape.move_left_nth {Γ} [Inhabited Γ] : ∀ (T : Tape Γ) (i : ℤ), (T.move Dir.left).nth i = T.nth (i - 1) | ⟨_, L, _⟩, -(n + 1 : ℕ) => (ListBlank.nth_succ _ _).symm | ⟨_, L, _⟩, 0 => (ListBlank.nth_zero _).symm | ⟨a, L, R⟩, 1 => (ListBlank.nth_zero _).trans (ListBlank.head_cons _ _) | ⟨a, L, R⟩, (n + 1 : ℕ) + 1 => by rw [add_sub_cancel_right] change (R.cons a).nth (n + 1) = R.nth n rw [ListBlank.nth_succ, ListBlank.tail_cons] #align turing.tape.move_left_nth Turing.Tape.move_left_nth @[simp] theorem Tape.move_right_nth {Γ} [Inhabited Γ] (T : Tape Γ) (i : ℤ) : (T.move Dir.right).nth i = T.nth (i + 1) := by conv => rhs; rw [← T.move_right_left] rw [Tape.move_left_nth, add_sub_cancel_right] #align turing.tape.move_right_nth Turing.Tape.move_right_nth @[simp] theorem Tape.move_right_n_head {Γ} [Inhabited Γ] (T : Tape Γ) (i : ℕ) : ((Tape.move Dir.right)^[i] T).head = T.nth i := by induction i generalizing T · rfl · simp only [*, Tape.move_right_nth, Int.ofNat_succ, iterate_succ, Function.comp_apply] #align turing.tape.move_right_n_head Turing.Tape.move_right_n_head def Tape.write {Γ} [Inhabited Γ] (b : Γ) (T : Tape Γ) : Tape Γ := { T with head := b } #align turing.tape.write Turing.Tape.write @[simp] theorem Tape.write_self {Γ} [Inhabited Γ] : ∀ T : Tape Γ, T.write T.1 = T := by rintro ⟨⟩; rfl #align turing.tape.write_self Turing.Tape.write_self @[simp] theorem Tape.write_nth {Γ} [Inhabited Γ] (b : Γ) : ∀ (T : Tape Γ) {i : ℤ}, (T.write b).nth i = if i = 0 then b else T.nth i | _, 0 => rfl | _, (_ + 1 : ℕ) => rfl | _, -(_ + 1 : ℕ) => rfl #align turing.tape.write_nth Turing.Tape.write_nth @[simp] theorem Tape.write_mk' {Γ} [Inhabited Γ] (a b : Γ) (L R : ListBlank Γ) : (Tape.mk' L (R.cons a)).write b = Tape.mk' L (R.cons b) := by simp only [Tape.write, Tape.mk', ListBlank.head_cons, ListBlank.tail_cons, eq_self_iff_true, and_self_iff] #align turing.tape.write_mk' Turing.Tape.write_mk' def Tape.map {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (T : Tape Γ) : Tape Γ' := ⟨f T.1, T.2.map f, T.3.map f⟩ #align turing.tape.map Turing.Tape.map @[simp] theorem Tape.map_fst {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') : ∀ T : Tape Γ, (T.map f).1 = f T.1 := by rintro ⟨⟩; rfl #align turing.tape.map_fst Turing.Tape.map_fst @[simp] theorem Tape.map_write {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (b : Γ) : ∀ T : Tape Γ, (T.write b).map f = (T.map f).write (f b) := by rintro ⟨⟩; rfl #align turing.tape.map_write Turing.Tape.map_write -- Porting note: `simpNF` complains about LHS does not simplify when using the simp lemma on -- itself, but it does indeed. @[simp, nolint simpNF] theorem Tape.write_move_right_n {Γ} [Inhabited Γ] (f : Γ → Γ) (L R : ListBlank Γ) (n : ℕ) : ((Tape.move Dir.right)^[n] (Tape.mk' L R)).write (f (R.nth n)) = (Tape.move Dir.right)^[n] (Tape.mk' L (R.modifyNth f n)) := by induction' n with n IH generalizing L R · simp only [ListBlank.nth_zero, ListBlank.modifyNth, iterate_zero_apply, Nat.zero_eq] rw [← Tape.write_mk', ListBlank.cons_head_tail] simp only [ListBlank.head_cons, ListBlank.nth_succ, ListBlank.modifyNth, Tape.move_right_mk', ListBlank.tail_cons, iterate_succ_apply, IH] #align turing.tape.write_move_right_n Turing.Tape.write_move_right_n theorem Tape.map_move {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (T : Tape Γ) (d) : (T.move d).map f = (T.map f).move d := by cases T cases d <;> simp only [Tape.move, Tape.map, ListBlank.head_map, eq_self_iff_true, ListBlank.map_cons, and_self_iff, ListBlank.tail_map] #align turing.tape.map_move Turing.Tape.map_move theorem Tape.map_mk' {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (L R : ListBlank Γ) : (Tape.mk' L R).map f = Tape.mk' (L.map f) (R.map f) := by simp only [Tape.mk', Tape.map, ListBlank.head_map, eq_self_iff_true, and_self_iff, ListBlank.tail_map] #align turing.tape.map_mk' Turing.Tape.map_mk' theorem Tape.map_mk₂ {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (L R : List Γ) : (Tape.mk₂ L R).map f = Tape.mk₂ (L.map f) (R.map f) := by simp only [Tape.mk₂, Tape.map_mk', ListBlank.map_mk] #align turing.tape.map_mk₂ Turing.Tape.map_mk₂ theorem Tape.map_mk₁ {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : List Γ) : (Tape.mk₁ l).map f = Tape.mk₁ (l.map f) := Tape.map_mk₂ _ _ _ #align turing.tape.map_mk₁ Turing.Tape.map_mk₁ def eval {σ} (f : σ → Option σ) : σ → Part σ := PFun.fix fun s ↦ Part.some <| (f s).elim (Sum.inl s) Sum.inr #align turing.eval Turing.eval def Reaches {σ} (f : σ → Option σ) : σ → σ → Prop := ReflTransGen fun a b ↦ b ∈ f a #align turing.reaches Turing.Reaches def Reaches₁ {σ} (f : σ → Option σ) : σ → σ → Prop := TransGen fun a b ↦ b ∈ f a #align turing.reaches₁ Turing.Reaches₁ theorem reaches₁_eq {σ} {f : σ → Option σ} {a b c} (h : f a = f b) : Reaches₁ f a c ↔ Reaches₁ f b c := TransGen.head'_iff.trans (TransGen.head'_iff.trans <| by rw [h]).symm #align turing.reaches₁_eq Turing.reaches₁_eq theorem reaches_total {σ} {f : σ → Option σ} {a b c} (hab : Reaches f a b) (hac : Reaches f a c) : Reaches f b c ∨ Reaches f c b := ReflTransGen.total_of_right_unique (fun _ _ _ ↦ Option.mem_unique) hab hac #align turing.reaches_total Turing.reaches_total theorem reaches₁_fwd {σ} {f : σ → Option σ} {a b c} (h₁ : Reaches₁ f a c) (h₂ : b ∈ f a) : Reaches f b c := by rcases TransGen.head'_iff.1 h₁ with ⟨b', hab, hbc⟩ cases Option.mem_unique hab h₂; exact hbc #align turing.reaches₁_fwd Turing.reaches₁_fwd def Reaches₀ {σ} (f : σ → Option σ) (a b : σ) : Prop := ∀ c, Reaches₁ f b c → Reaches₁ f a c #align turing.reaches₀ Turing.Reaches₀ theorem Reaches₀.trans {σ} {f : σ → Option σ} {a b c : σ} (h₁ : Reaches₀ f a b) (h₂ : Reaches₀ f b c) : Reaches₀ f a c | _, h₃ => h₁ _ (h₂ _ h₃) #align turing.reaches₀.trans Turing.Reaches₀.trans @[refl] theorem Reaches₀.refl {σ} {f : σ → Option σ} (a : σ) : Reaches₀ f a a | _, h => h #align turing.reaches₀.refl Turing.Reaches₀.refl theorem Reaches₀.single {σ} {f : σ → Option σ} {a b : σ} (h : b ∈ f a) : Reaches₀ f a b | _, h₂ => h₂.head h #align turing.reaches₀.single Turing.Reaches₀.single theorem Reaches₀.head {σ} {f : σ → Option σ} {a b c : σ} (h : b ∈ f a) (h₂ : Reaches₀ f b c) : Reaches₀ f a c := (Reaches₀.single h).trans h₂ #align turing.reaches₀.head Turing.Reaches₀.head theorem Reaches₀.tail {σ} {f : σ → Option σ} {a b c : σ} (h₁ : Reaches₀ f a b) (h : c ∈ f b) : Reaches₀ f a c := h₁.trans (Reaches₀.single h) #align turing.reaches₀.tail Turing.Reaches₀.tail theorem reaches₀_eq {σ} {f : σ → Option σ} {a b} (e : f a = f b) : Reaches₀ f a b | _, h => (reaches₁_eq e).2 h #align turing.reaches₀_eq Turing.reaches₀_eq theorem Reaches₁.to₀ {σ} {f : σ → Option σ} {a b : σ} (h : Reaches₁ f a b) : Reaches₀ f a b | _, h₂ => h.trans h₂ #align turing.reaches₁.to₀ Turing.Reaches₁.to₀ theorem Reaches.to₀ {σ} {f : σ → Option σ} {a b : σ} (h : Reaches f a b) : Reaches₀ f a b | _, h₂ => h₂.trans_right h #align turing.reaches.to₀ Turing.Reaches.to₀ theorem Reaches₀.tail' {σ} {f : σ → Option σ} {a b c : σ} (h : Reaches₀ f a b) (h₂ : c ∈ f b) : Reaches₁ f a c := h _ (TransGen.single h₂) #align turing.reaches₀.tail' Turing.Reaches₀.tail' @[elab_as_elim] def evalInduction {σ} {f : σ → Option σ} {b : σ} {C : σ → Sort*} {a : σ} (h : b ∈ eval f a) (H : ∀ a, b ∈ eval f a → (∀ a', f a = some a' → C a') → C a) : C a := PFun.fixInduction h fun a' ha' h' ↦ H _ ha' fun b' e ↦ h' _ <| Part.mem_some_iff.2 <| by rw [e]; rfl #align turing.eval_induction Turing.evalInduction theorem mem_eval {σ} {f : σ → Option σ} {a b} : b ∈ eval f a ↔ Reaches f a b ∧ f b = none := by refine ⟨fun h ↦ ?_, fun ⟨h₁, h₂⟩ ↦ ?_⟩ · -- Porting note: Explicitly specify `c`. refine @evalInduction _ _ _ (fun a ↦ Reaches f a b ∧ f b = none) _ h fun a h IH ↦ ?_ cases' e : f a with a' · rw [Part.mem_unique h (PFun.mem_fix_iff.2 <| Or.inl <| Part.mem_some_iff.2 <| by rw [e] <;> rfl)] exact ⟨ReflTransGen.refl, e⟩ · rcases PFun.mem_fix_iff.1 h with (h | ⟨_, h, _⟩) <;> rw [e] at h <;> cases Part.mem_some_iff.1 h cases' IH a' e with h₁ h₂ exact ⟨ReflTransGen.head e h₁, h₂⟩ · refine ReflTransGen.head_induction_on h₁ ?_ fun h _ IH ↦ ?_ · refine PFun.mem_fix_iff.2 (Or.inl ?_) rw [h₂] apply Part.mem_some · refine PFun.mem_fix_iff.2 (Or.inr ⟨_, ?_, IH⟩) rw [h] apply Part.mem_some #align turing.mem_eval Turing.mem_eval theorem eval_maximal₁ {σ} {f : σ → Option σ} {a b} (h : b ∈ eval f a) (c) : ¬Reaches₁ f b c | bc => by let ⟨_, b0⟩ := mem_eval.1 h let ⟨b', h', _⟩ := TransGen.head'_iff.1 bc cases b0.symm.trans h' #align turing.eval_maximal₁ Turing.eval_maximal₁ theorem eval_maximal {σ} {f : σ → Option σ} {a b} (h : b ∈ eval f a) {c} : Reaches f b c ↔ c = b := let ⟨_, b0⟩ := mem_eval.1 h reflTransGen_iff_eq fun b' h' ↦ by cases b0.symm.trans h' #align turing.eval_maximal Turing.eval_maximal theorem reaches_eval {σ} {f : σ → Option σ} {a b} (ab : Reaches f a b) : eval f a = eval f b := by refine Part.ext fun _ ↦ ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · have ⟨ac, c0⟩ := mem_eval.1 h exact mem_eval.2 ⟨(or_iff_left_of_imp fun cb ↦ (eval_maximal h).1 cb ▸ ReflTransGen.refl).1 (reaches_total ab ac), c0⟩ · have ⟨bc, c0⟩ := mem_eval.1 h exact mem_eval.2 ⟨ab.trans bc, c0⟩ #align turing.reaches_eval Turing.reaches_eval def Respects {σ₁ σ₂} (f₁ : σ₁ → Option σ₁) (f₂ : σ₂ → Option σ₂) (tr : σ₁ → σ₂ → Prop) := ∀ ⦃a₁ a₂⦄, tr a₁ a₂ → (match f₁ a₁ with | some b₁ => ∃ b₂, tr b₁ b₂ ∧ Reaches₁ f₂ a₂ b₂ | none => f₂ a₂ = none : Prop) #align turing.respects Turing.Respects theorem tr_reaches₁ {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂ → Prop} (H : Respects f₁ f₂ tr) {a₁ a₂} (aa : tr a₁ a₂) {b₁} (ab : Reaches₁ f₁ a₁ b₁) : ∃ b₂, tr b₁ b₂ ∧ Reaches₁ f₂ a₂ b₂ := by induction' ab with c₁ ac c₁ d₁ _ cd IH · have := H aa rwa [show f₁ a₁ = _ from ac] at this · rcases IH with ⟨c₂, cc, ac₂⟩ have := H cc rw [show f₁ c₁ = _ from cd] at this rcases this with ⟨d₂, dd, cd₂⟩ exact ⟨_, dd, ac₂.trans cd₂⟩ #align turing.tr_reaches₁ Turing.tr_reaches₁ theorem tr_reaches {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂ → Prop} (H : Respects f₁ f₂ tr) {a₁ a₂} (aa : tr a₁ a₂) {b₁} (ab : Reaches f₁ a₁ b₁) : ∃ b₂, tr b₁ b₂ ∧ Reaches f₂ a₂ b₂ := by rcases reflTransGen_iff_eq_or_transGen.1 ab with (rfl | ab) · exact ⟨_, aa, ReflTransGen.refl⟩ · have ⟨b₂, bb, h⟩ := tr_reaches₁ H aa ab exact ⟨b₂, bb, h.to_reflTransGen⟩ #align turing.tr_reaches Turing.tr_reaches
Mathlib/Computability/TuringMachine.lean
909
926
theorem tr_reaches_rev {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂ → Prop} (H : Respects f₁ f₂ tr) {a₁ a₂} (aa : tr a₁ a₂) {b₂} (ab : Reaches f₂ a₂ b₂) : ∃ c₁ c₂, Reaches f₂ b₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ := by
induction' ab with c₂ d₂ _ cd IH · exact ⟨_, _, ReflTransGen.refl, aa, ReflTransGen.refl⟩ · rcases IH with ⟨e₁, e₂, ce, ee, ae⟩ rcases ReflTransGen.cases_head ce with (rfl | ⟨d', cd', de⟩) · have := H ee revert this cases' eg : f₁ e₁ with g₁ <;> simp only [Respects, and_imp, exists_imp] · intro c0 cases cd.symm.trans c0 · intro g₂ gg cg rcases TransGen.head'_iff.1 cg with ⟨d', cd', dg⟩ cases Option.mem_unique cd cd' exact ⟨_, _, dg, gg, ae.tail eg⟩ · cases Option.mem_unique cd cd' exact ⟨_, _, de, ee, ae⟩
import Mathlib.Analysis.Convex.Hull import Mathlib.LinearAlgebra.AffineSpace.Independent #align_import analysis.convex.simplicial_complex.basic from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" open Finset Set variable (𝕜 E : Type*) {ι : Type*} [OrderedRing 𝕜] [AddCommGroup E] [Module 𝕜 E] namespace Geometry -- TODO: update to new binder order? not sure what binder order is correct for `down_closed`. @[ext] structure SimplicialComplex where faces : Set (Finset E) not_empty_mem : ∅ ∉ faces indep : ∀ {s}, s ∈ faces → AffineIndependent 𝕜 ((↑) : s → E) down_closed : ∀ {s t}, s ∈ faces → t ⊆ s → t ≠ ∅ → t ∈ faces inter_subset_convexHull : ∀ {s t}, s ∈ faces → t ∈ faces → convexHull 𝕜 ↑s ∩ convexHull 𝕜 ↑t ⊆ convexHull 𝕜 (s ∩ t : Set E) #align geometry.simplicial_complex Geometry.SimplicialComplex namespace SimplicialComplex variable {𝕜 E} variable {K : SimplicialComplex 𝕜 E} {s t : Finset E} {x : E} instance : Membership (Finset E) (SimplicialComplex 𝕜 E) := ⟨fun s K => s ∈ K.faces⟩ def space (K : SimplicialComplex 𝕜 E) : Set E := ⋃ s ∈ K.faces, convexHull 𝕜 (s : Set E) #align geometry.simplicial_complex.space Geometry.SimplicialComplex.space -- Porting note: Expanded `∃ s ∈ K.faces` to get the type to match more closely with Lean 3 theorem mem_space_iff : x ∈ K.space ↔ ∃ s ∈ K.faces, x ∈ convexHull 𝕜 (s : Set E) := by simp [space] #align geometry.simplicial_complex.mem_space_iff Geometry.SimplicialComplex.mem_space_iff -- Porting note: Original proof was `:= subset_biUnion_of_mem hs` theorem convexHull_subset_space (hs : s ∈ K.faces) : convexHull 𝕜 ↑s ⊆ K.space := by convert subset_biUnion_of_mem hs rfl #align geometry.simplicial_complex.convex_hull_subset_space Geometry.SimplicialComplex.convexHull_subset_space protected theorem subset_space (hs : s ∈ K.faces) : (s : Set E) ⊆ K.space := (subset_convexHull 𝕜 _).trans <| convexHull_subset_space hs #align geometry.simplicial_complex.subset_space Geometry.SimplicialComplex.subset_space theorem convexHull_inter_convexHull (hs : s ∈ K.faces) (ht : t ∈ K.faces) : convexHull 𝕜 ↑s ∩ convexHull 𝕜 ↑t = convexHull 𝕜 (s ∩ t : Set E) := (K.inter_subset_convexHull hs ht).antisymm <| subset_inter (convexHull_mono Set.inter_subset_left) <| convexHull_mono Set.inter_subset_right #align geometry.simplicial_complex.convex_hull_inter_convex_hull Geometry.SimplicialComplex.convexHull_inter_convexHull
Mathlib/Analysis/Convex/SimplicialComplex/Basic.lean
110
119
theorem disjoint_or_exists_inter_eq_convexHull (hs : s ∈ K.faces) (ht : t ∈ K.faces) : Disjoint (convexHull 𝕜 (s : Set E)) (convexHull 𝕜 ↑t) ∨ ∃ u ∈ K.faces, convexHull 𝕜 (s : Set E) ∩ convexHull 𝕜 ↑t = convexHull 𝕜 ↑u := by
classical by_contra! h refine h.2 (s ∩ t) (K.down_closed hs inter_subset_left fun hst => h.1 <| disjoint_iff_inf_le.mpr <| (K.inter_subset_convexHull hs ht).trans ?_) ?_ · rw [← coe_inter, hst, coe_empty, convexHull_empty] rfl · rw [coe_inter, convexHull_inter_convexHull hs ht]
import Mathlib.Analysis.Convex.Between import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic import Mathlib.MeasureTheory.Measure.Lebesgue.Basic import Mathlib.Topology.MetricSpace.Holder import Mathlib.Topology.MetricSpace.MetricSeparated #align_import measure_theory.measure.hausdorff from "leanprover-community/mathlib"@"3d5c4a7a5fb0d982f97ed953161264f1dbd90ead" open scoped NNReal ENNReal Topology open EMetric Set Function Filter Encodable FiniteDimensional TopologicalSpace noncomputable section variable {ι X Y : Type*} [EMetricSpace X] [EMetricSpace Y] namespace MeasureTheory namespace OuterMeasure def IsMetric (μ : OuterMeasure X) : Prop := ∀ s t : Set X, IsMetricSeparated s t → μ (s ∪ t) = μ s + μ t #align measure_theory.outer_measure.is_metric MeasureTheory.OuterMeasure.IsMetric def mkMetric'.pre (m : Set X → ℝ≥0∞) (r : ℝ≥0∞) : OuterMeasure X := boundedBy <| extend fun s (_ : diam s ≤ r) => m s #align measure_theory.outer_measure.mk_metric'.pre MeasureTheory.OuterMeasure.mkMetric'.pre def mkMetric' (m : Set X → ℝ≥0∞) : OuterMeasure X := ⨆ r > 0, mkMetric'.pre m r #align measure_theory.outer_measure.mk_metric' MeasureTheory.OuterMeasure.mkMetric' def mkMetric (m : ℝ≥0∞ → ℝ≥0∞) : OuterMeasure X := mkMetric' fun s => m (diam s) #align measure_theory.outer_measure.mk_metric MeasureTheory.OuterMeasure.mkMetric namespace mkMetric' variable {m : Set X → ℝ≥0∞} {r : ℝ≥0∞} {μ : OuterMeasure X} {s : Set X}
Mathlib/MeasureTheory/Measure/Hausdorff.lean
270
271
theorem le_pre : μ ≤ pre m r ↔ ∀ s : Set X, diam s ≤ r → μ s ≤ m s := by
simp only [pre, le_boundedBy, extend, le_iInf_iff]
import Batteries.Data.RBMap.Basic import Batteries.Tactic.SeqFocus namespace Batteries namespace RBNode open RBColor attribute [simp] All theorem All.trivial (H : ∀ {x : α}, p x) : ∀ {t : RBNode α}, t.All p | nil => _root_.trivial | node .. => ⟨H, All.trivial H, All.trivial H⟩ theorem All_and {t : RBNode α} : t.All (fun a => p a ∧ q a) ↔ t.All p ∧ t.All q := by induction t <;> simp [*, and_assoc, and_left_comm] protected theorem cmpLT.flip (h₁ : cmpLT cmp x y) : cmpLT (flip cmp) y x := ⟨have : TransCmp cmp := inferInstanceAs (TransCmp (flip (flip cmp))); h₁.1⟩ theorem cmpLT.trans (h₁ : cmpLT cmp x y) (h₂ : cmpLT cmp y z) : cmpLT cmp x z := ⟨TransCmp.lt_trans h₁.1 h₂.1⟩ theorem cmpLT.trans_l {cmp x y} (H : cmpLT cmp x y) {t : RBNode α} (h : t.All (cmpLT cmp y ·)) : t.All (cmpLT cmp x ·) := h.imp fun h => H.trans h theorem cmpLT.trans_r {cmp x y} (H : cmpLT cmp x y) {a : RBNode α} (h : a.All (cmpLT cmp · x)) : a.All (cmpLT cmp · y) := h.imp fun h => h.trans H theorem cmpEq.lt_congr_left (H : cmpEq cmp x y) : cmpLT cmp x z ↔ cmpLT cmp y z := ⟨fun ⟨h⟩ => ⟨TransCmp.cmp_congr_left H.1 ▸ h⟩, fun ⟨h⟩ => ⟨TransCmp.cmp_congr_left H.1 ▸ h⟩⟩ theorem cmpEq.lt_congr_right (H : cmpEq cmp y z) : cmpLT cmp x y ↔ cmpLT cmp x z := ⟨fun ⟨h⟩ => ⟨TransCmp.cmp_congr_right H.1 ▸ h⟩, fun ⟨h⟩ => ⟨TransCmp.cmp_congr_right H.1 ▸ h⟩⟩ @[simp] theorem reverse_reverse (t : RBNode α) : t.reverse.reverse = t := by induction t <;> simp [*] theorem reverse_eq_iff {t t' : RBNode α} : t.reverse = t' ↔ t = t'.reverse := by constructor <;> rintro rfl <;> simp @[simp] theorem reverse_balance1 (l : RBNode α) (v : α) (r : RBNode α) : (balance1 l v r).reverse = balance2 r.reverse v l.reverse := by unfold balance1 balance2; split <;> simp · rw [balance2.match_1.eq_2]; simp [reverse_eq_iff]; intros; solve_by_elim · rw [balance2.match_1.eq_3] <;> (simp [reverse_eq_iff]; intros; solve_by_elim) @[simp] theorem reverse_balance2 (l : RBNode α) (v : α) (r : RBNode α) : (balance2 l v r).reverse = balance1 r.reverse v l.reverse := by refine Eq.trans ?_ (reverse_reverse _); rw [reverse_balance1]; simp @[simp] theorem All.reverse {t : RBNode α} : t.reverse.All p ↔ t.All p := by induction t <;> simp [*, and_comm] protected theorem Ordered.reverse : ∀ {t : RBNode α}, t.Ordered cmp → t.reverse.Ordered (flip cmp) | .nil, _ => ⟨⟩ | .node .., ⟨lv, vr, hl, hr⟩ => ⟨(All.reverse.2 vr).imp cmpLT.flip, (All.reverse.2 lv).imp cmpLT.flip, hr.reverse, hl.reverse⟩ protected theorem Balanced.reverse {t : RBNode α} : t.Balanced c n → t.reverse.Balanced c n | .nil => .nil | .black hl hr => .black hr.reverse hl.reverse | .red hl hr => .red hr.reverse hl.reverse protected theorem Ordered.balance1 {l : RBNode α} {v : α} {r : RBNode α} (lv : l.All (cmpLT cmp · v)) (vr : r.All (cmpLT cmp v ·)) (hl : l.Ordered cmp) (hr : r.Ordered cmp) : (balance1 l v r).Ordered cmp := by unfold balance1; split · next a x b y c => have ⟨yv, _, cv⟩ := lv; have ⟨xy, yc, hx, hc⟩ := hl exact ⟨xy, ⟨yv, yc, yv.trans_l vr⟩, hx, cv, vr, hc, hr⟩ · next a x b y c _ => have ⟨_, _, yv, _, cv⟩ := lv; have ⟨ax, ⟨xy, xb, _⟩, ha, by_, yc, hb, hc⟩ := hl exact ⟨⟨xy, xy.trans_r ax, by_⟩, ⟨yv, yc, yv.trans_l vr⟩, ⟨ax, xb, ha, hb⟩, cv, vr, hc, hr⟩ · exact ⟨lv, vr, hl, hr⟩ @[simp] theorem balance1_All {l : RBNode α} {v : α} {r : RBNode α} : (balance1 l v r).All p ↔ p v ∧ l.All p ∧ r.All p := by unfold balance1; split <;> simp [and_assoc, and_left_comm] protected theorem Ordered.balance2 {l : RBNode α} {v : α} {r : RBNode α} (lv : l.All (cmpLT cmp · v)) (vr : r.All (cmpLT cmp v ·)) (hl : l.Ordered cmp) (hr : r.Ordered cmp) : (balance2 l v r).Ordered cmp := by rw [← reverse_reverse (balance2 ..), reverse_balance2] exact .reverse <| hr.reverse.balance1 ((All.reverse.2 vr).imp cmpLT.flip) ((All.reverse.2 lv).imp cmpLT.flip) hl.reverse @[simp] theorem balance2_All {l : RBNode α} {v : α} {r : RBNode α} : (balance2 l v r).All p ↔ p v ∧ l.All p ∧ r.All p := by unfold balance2; split <;> simp [and_assoc, and_left_comm] @[simp] theorem reverse_setBlack {t : RBNode α} : (setBlack t).reverse = setBlack t.reverse := by unfold setBlack; split <;> simp protected theorem Ordered.setBlack {t : RBNode α} : (setBlack t).Ordered cmp ↔ t.Ordered cmp := by unfold setBlack; split <;> simp [Ordered] protected theorem Balanced.setBlack : t.Balanced c n → ∃ n', (setBlack t).Balanced black n' | .nil => ⟨_, .nil⟩ | .black hl hr | .red hl hr => ⟨_, hl.black hr⟩ theorem setBlack_idem {t : RBNode α} : t.setBlack.setBlack = t.setBlack := by cases t <;> rfl @[simp] theorem reverse_ins [inst : @OrientedCmp α cmp] {t : RBNode α} : (ins cmp x t).reverse = ins (flip cmp) x t.reverse := by induction t <;> [skip; (rename_i c a y b iha ihb; cases c)] <;> simp [ins, flip] <;> rw [← inst.symm x y] <;> split <;> simp [*, Ordering.swap, iha, ihb] protected theorem All.ins {x : α} {t : RBNode α} (h₁ : p x) (h₂ : t.All p) : (ins cmp x t).All p := by induction t <;> unfold ins <;> try simp [*] split <;> cases ‹_=_› <;> split <;> simp at h₂ <;> simp [*] protected theorem Ordered.ins : ∀ {t : RBNode α}, t.Ordered cmp → (ins cmp x t).Ordered cmp | nil, _ => ⟨⟨⟩, ⟨⟩, ⟨⟩, ⟨⟩⟩ | node red a y b, ⟨ay, yb, ha, hb⟩ => by unfold ins; split · next h => exact ⟨ay.ins ⟨h⟩, yb, ha.ins, hb⟩ · next h => exact ⟨ay, yb.ins ⟨OrientedCmp.cmp_eq_gt.1 h⟩, ha, hb.ins⟩ · next h => exact (⟨ ay.imp fun ⟨h'⟩ => ⟨(TransCmp.cmp_congr_right h).trans h'⟩, yb.imp fun ⟨h'⟩ => ⟨(TransCmp.cmp_congr_left h).trans h'⟩, ha, hb⟩) | node black a y b, ⟨ay, yb, ha, hb⟩ => by unfold ins; split · next h => exact ha.ins.balance1 (ay.ins ⟨h⟩) yb hb · next h => exact ha.balance2 ay (yb.ins ⟨OrientedCmp.cmp_eq_gt.1 h⟩) hb.ins · next h => exact (⟨ ay.imp fun ⟨h'⟩ => ⟨(TransCmp.cmp_congr_right h).trans h'⟩, yb.imp fun ⟨h'⟩ => ⟨(TransCmp.cmp_congr_left h).trans h'⟩, ha, hb⟩) @[simp] theorem isRed_reverse {t : RBNode α} : t.reverse.isRed = t.isRed := by cases t <;> simp [isRed] @[simp] theorem reverse_insert [inst : @OrientedCmp α cmp] {t : RBNode α} : (insert cmp t x).reverse = insert (flip cmp) t.reverse x := by simp [insert] <;> split <;> simp
.lake/packages/batteries/Batteries/Data/RBMap/WF.lean
154
156
theorem insert_setBlack {t : RBNode α} : (t.insert cmp v).setBlack = (t.ins cmp v).setBlack := by
unfold insert; split <;> simp [setBlack_idem]