Context stringlengths 57 6.04k | file_name stringlengths 21 79 | start int64 14 1.49k | end int64 18 1.5k | theorem stringlengths 25 1.55k | proof stringlengths 5 7.36k | num_lines int64 1 150 |
|---|---|---|---|---|---|---|
import Mathlib.Algebra.Order.Field.Pi
import Mathlib.Algebra.Order.UpperLower
import Mathlib.Analysis.Normed.Group.Pointwise
import Mathlib.Analysis.Normed.Order.Basic
import Mathlib.Data.Real.Sqrt
import Mathlib.Topology.Algebra.Order.UpperLower
import Mathlib.Topology.MetricSpace.Sequences
#align_import analysis.normed.order.upper_lower from "leanprover-community/mathlib"@"b1abe23ae96fef89ad30d9f4362c307f72a55010"
open Bornology Function Metric Set
open scoped Pointwise
variable {α ι : Type*}
section Finite
variable [Finite ι] {s : Set (ι → ℝ)} {x y : ι → ℝ}
| Mathlib/Analysis/Normed/Order/UpperLower.lean | 94 | 109 | theorem IsUpperSet.mem_interior_of_forall_lt (hs : IsUpperSet s) (hx : x ∈ closure s)
(h : ∀ i, x i < y i) : y ∈ interior s := by |
cases nonempty_fintype ι
obtain ⟨ε, hε, hxy⟩ := Pi.exists_forall_pos_add_lt h
obtain ⟨z, hz, hxz⟩ := Metric.mem_closure_iff.1 hx _ hε
rw [dist_pi_lt_iff hε] at hxz
have hyz : ∀ i, z i < y i := by
refine fun i => (hxy _).trans_le' (sub_le_iff_le_add'.1 <| (le_abs_self _).trans ?_)
rw [← Real.norm_eq_abs, ← dist_eq_norm']
exact (hxz _).le
obtain ⟨δ, hδ, hyz⟩ := Pi.exists_forall_pos_add_lt hyz
refine mem_interior.2 ⟨ball y δ, ?_, isOpen_ball, mem_ball_self hδ⟩
rintro w hw
refine hs (fun i => ?_) hz
simp_rw [ball_pi _ hδ, Real.ball_eq_Ioo] at hw
exact ((lt_sub_iff_add_lt.2 <| hyz _).trans (hw _ <| mem_univ _).1).le
| 14 |
import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics
import Mathlib.NumberTheory.Liouville.Basic
import Mathlib.Topology.Instances.Irrational
#align_import number_theory.liouville.liouville_with from "leanprover-community/mathlib"@"0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8"
open Filter Metric Real Set
open scoped Filter Topology
def LiouvilleWith (p x : ℝ) : Prop :=
∃ C, ∃ᶠ n : ℕ in atTop, ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < C / n ^ p
#align liouville_with LiouvilleWith
theorem liouvilleWith_one (x : ℝ) : LiouvilleWith 1 x := by
use 2
refine ((eventually_gt_atTop 0).mono fun n hn => ?_).frequently
have hn' : (0 : ℝ) < n := by simpa
have : x < ↑(⌊x * ↑n⌋ + 1) / ↑n := by
rw [lt_div_iff hn', Int.cast_add, Int.cast_one];
exact Int.lt_floor_add_one _
refine ⟨⌊x * n⌋ + 1, this.ne, ?_⟩
rw [abs_sub_comm, abs_of_pos (sub_pos.2 this), rpow_one, sub_lt_iff_lt_add',
add_div_eq_mul_add_div _ _ hn'.ne']
gcongr
calc _ ≤ x * n + 1 := by push_cast; gcongr; apply Int.floor_le
_ < x * n + 2 := by linarith
#align liouville_with_one liouvilleWith_one
namespace LiouvilleWith
variable {p q x y : ℝ} {r : ℚ} {m : ℤ} {n : ℕ}
theorem exists_pos (h : LiouvilleWith p x) :
∃ (C : ℝ) (_h₀ : 0 < C),
∃ᶠ n : ℕ in atTop, 1 ≤ n ∧ ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < C / n ^ p := by
rcases h with ⟨C, hC⟩
refine ⟨max C 1, zero_lt_one.trans_le <| le_max_right _ _, ?_⟩
refine ((eventually_ge_atTop 1).and_frequently hC).mono ?_
rintro n ⟨hle, m, hne, hlt⟩
refine ⟨hle, m, hne, hlt.trans_le ?_⟩
gcongr
apply le_max_left
#align liouville_with.exists_pos LiouvilleWith.exists_pos
theorem mono (h : LiouvilleWith p x) (hle : q ≤ p) : LiouvilleWith q x := by
rcases h.exists_pos with ⟨C, hC₀, hC⟩
refine ⟨C, hC.mono ?_⟩; rintro n ⟨hn, m, hne, hlt⟩
refine ⟨m, hne, hlt.trans_le <| ?_⟩
gcongr
exact_mod_cast hn
#align liouville_with.mono LiouvilleWith.mono
theorem frequently_lt_rpow_neg (h : LiouvilleWith p x) (hlt : q < p) :
∃ᶠ n : ℕ in atTop, ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < n ^ (-q) := by
rcases h.exists_pos with ⟨C, _hC₀, hC⟩
have : ∀ᶠ n : ℕ in atTop, C < n ^ (p - q) := by
simpa only [(· ∘ ·), neg_sub, one_div] using
((tendsto_rpow_atTop (sub_pos.2 hlt)).comp tendsto_natCast_atTop_atTop).eventually
(eventually_gt_atTop C)
refine (this.and_frequently hC).mono ?_
rintro n ⟨hnC, hn, m, hne, hlt⟩
replace hn : (0 : ℝ) < n := Nat.cast_pos.2 hn
refine ⟨m, hne, hlt.trans <| (div_lt_iff <| rpow_pos_of_pos hn _).2 ?_⟩
rwa [mul_comm, ← rpow_add hn, ← sub_eq_add_neg]
#align liouville_with.frequently_lt_rpow_neg LiouvilleWith.frequently_lt_rpow_neg
| Mathlib/NumberTheory/Liouville/LiouvilleWith.lean | 114 | 128 | theorem mul_rat (h : LiouvilleWith p x) (hr : r ≠ 0) : LiouvilleWith p (x * r) := by |
rcases h.exists_pos with ⟨C, _hC₀, hC⟩
refine ⟨r.den ^ p * (|r| * C), (tendsto_id.nsmul_atTop r.pos).frequently (hC.mono ?_)⟩
rintro n ⟨_hn, m, hne, hlt⟩
have A : (↑(r.num * m) : ℝ) / ↑(r.den • id n) = m / n * r := by
simp [← div_mul_div_comm, ← r.cast_def, mul_comm]
refine ⟨r.num * m, ?_, ?_⟩
· rw [A]; simp [hne, hr]
· rw [A, ← sub_mul, abs_mul]
simp only [smul_eq_mul, id, Nat.cast_mul]
calc _ < C / ↑n ^ p * |↑r| := by gcongr
_ = ↑r.den ^ p * (↑|r| * C) / (↑r.den * ↑n) ^ p := ?_
rw [mul_rpow, mul_div_mul_left, mul_comm, mul_div_assoc]
· simp only [Rat.cast_abs, le_refl]
all_goals positivity
| 14 |
import Mathlib.Data.ZMod.Basic
import Mathlib.GroupTheory.Exponent
#align_import group_theory.specific_groups.dihedral from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
inductive DihedralGroup (n : ℕ) : Type
| r : ZMod n → DihedralGroup n
| sr : ZMod n → DihedralGroup n
deriving DecidableEq
#align dihedral_group DihedralGroup
namespace DihedralGroup
variable {n : ℕ}
private def mul : DihedralGroup n → DihedralGroup n → DihedralGroup n
| r i, r j => r (i + j)
| r i, sr j => sr (j - i)
| sr i, r j => sr (i + j)
| sr i, sr j => r (j - i)
private def one : DihedralGroup n :=
r 0
instance : Inhabited (DihedralGroup n) :=
⟨one⟩
private def inv : DihedralGroup n → DihedralGroup n
| r i => r (-i)
| sr i => sr i
instance : Group (DihedralGroup n) where
mul := mul
mul_assoc := by rintro (a | a) (b | b) (c | c) <;> simp only [(· * ·), mul] <;> ring_nf
one := one
one_mul := by
rintro (a | a)
· exact congr_arg r (zero_add a)
· exact congr_arg sr (sub_zero a)
mul_one := by
rintro (a | a)
· exact congr_arg r (add_zero a)
· exact congr_arg sr (add_zero a)
inv := inv
mul_left_inv := by
rintro (a | a)
· exact congr_arg r (neg_add_self a)
· exact congr_arg r (sub_self a)
@[simp]
theorem r_mul_r (i j : ZMod n) : r i * r j = r (i + j) :=
rfl
#align dihedral_group.r_mul_r DihedralGroup.r_mul_r
@[simp]
theorem r_mul_sr (i j : ZMod n) : r i * sr j = sr (j - i) :=
rfl
#align dihedral_group.r_mul_sr DihedralGroup.r_mul_sr
@[simp]
theorem sr_mul_r (i j : ZMod n) : sr i * r j = sr (i + j) :=
rfl
#align dihedral_group.sr_mul_r DihedralGroup.sr_mul_r
@[simp]
theorem sr_mul_sr (i j : ZMod n) : sr i * sr j = r (j - i) :=
rfl
#align dihedral_group.sr_mul_sr DihedralGroup.sr_mul_sr
theorem one_def : (1 : DihedralGroup n) = r 0 :=
rfl
#align dihedral_group.one_def DihedralGroup.one_def
private def fintypeHelper : Sum (ZMod n) (ZMod n) ≃ DihedralGroup n where
invFun i := match i with
| r j => Sum.inl j
| sr j => Sum.inr j
toFun i := match i with
| Sum.inl j => r j
| Sum.inr j => sr j
left_inv := by rintro (x | x) <;> rfl
right_inv := by rintro (x | x) <;> rfl
instance [NeZero n] : Fintype (DihedralGroup n) :=
Fintype.ofEquiv _ fintypeHelper
instance : Infinite (DihedralGroup 0) :=
DihedralGroup.fintypeHelper.infinite_iff.mp inferInstance
instance : Nontrivial (DihedralGroup n) :=
⟨⟨r 0, sr 0, by simp_rw [ne_eq, not_false_eq_true]⟩⟩
theorem card [NeZero n] : Fintype.card (DihedralGroup n) = 2 * n := by
rw [← Fintype.card_eq.mpr ⟨fintypeHelper⟩, Fintype.card_sum, ZMod.card, two_mul]
#align dihedral_group.card DihedralGroup.card
theorem nat_card : Nat.card (DihedralGroup n) = 2 * n := by
cases n
· rw [Nat.card_eq_zero_of_infinite]
· rw [Nat.card_eq_fintype_card, card]
@[simp]
theorem r_one_pow (k : ℕ) : (r 1 : DihedralGroup n) ^ k = r k := by
induction' k with k IH
· rw [Nat.cast_zero]
rfl
· rw [pow_succ', IH, r_mul_r]
congr 1
norm_cast
rw [Nat.one_add]
#align dihedral_group.r_one_pow DihedralGroup.r_one_pow
-- @[simp] -- Porting note: simp changes the goal to `r 0 = 1`. `r_one_pow_n` is no longer useful.
theorem r_one_pow_n : r (1 : ZMod n) ^ n = 1 := by
rw [r_one_pow, one_def]
congr 1
exact ZMod.natCast_self _
#align dihedral_group.r_one_pow_n DihedralGroup.r_one_pow_n
-- @[simp] -- Porting note: simp changes the goal to `r 0 = 1`. `sr_mul_self` is no longer useful.
theorem sr_mul_self (i : ZMod n) : sr i * sr i = 1 := by rw [sr_mul_sr, sub_self, one_def]
#align dihedral_group.sr_mul_self DihedralGroup.sr_mul_self
@[simp]
theorem orderOf_sr (i : ZMod n) : orderOf (sr i) = 2 := by
apply orderOf_eq_prime
· rw [sq, sr_mul_self]
· -- Porting note: Previous proof was `decide`
revert n
simp_rw [one_def, ne_eq, forall_const, not_false_eq_true]
#align dihedral_group.order_of_sr DihedralGroup.orderOf_sr
@[simp]
| Mathlib/GroupTheory/SpecificGroups/Dihedral.lean | 170 | 184 | theorem orderOf_r_one : orderOf (r 1 : DihedralGroup n) = n := by |
rcases eq_zero_or_neZero n with (rfl | hn)
· rw [orderOf_eq_zero_iff']
intro n hn
rw [r_one_pow, one_def]
apply mt r.inj
simpa using hn.ne'
· apply (Nat.le_of_dvd (NeZero.pos n) <|
orderOf_dvd_of_pow_eq_one <| @r_one_pow_n n).lt_or_eq.resolve_left
intro h
have h1 : (r 1 : DihedralGroup n) ^ orderOf (r 1) = 1 := pow_orderOf_eq_one _
rw [r_one_pow] at h1
injection h1 with h2
rw [← ZMod.val_eq_zero, ZMod.val_natCast, Nat.mod_eq_of_lt h] at h2
exact absurd h2.symm (orderOf_pos _).ne
| 14 |
import Mathlib.Init.Core
import Mathlib.RingTheory.Polynomial.Cyclotomic.Roots
import Mathlib.NumberTheory.NumberField.Basic
import Mathlib.FieldTheory.Galois
#align_import number_theory.cyclotomic.basic from "leanprover-community/mathlib"@"4b05d3f4f0601dca8abf99c4ec99187682ed0bba"
open Polynomial Algebra FiniteDimensional Set
universe u v w z
variable (n : ℕ+) (S T : Set ℕ+) (A : Type u) (B : Type v) (K : Type w) (L : Type z)
variable [CommRing A] [CommRing B] [Algebra A B]
variable [Field K] [Field L] [Algebra K L]
noncomputable section
@[mk_iff]
class IsCyclotomicExtension : Prop where
exists_prim_root {n : ℕ+} (ha : n ∈ S) : ∃ r : B, IsPrimitiveRoot r n
adjoin_roots : ∀ x : B, x ∈ adjoin A {b : B | ∃ n : ℕ+, n ∈ S ∧ b ^ (n : ℕ) = 1}
#align is_cyclotomic_extension IsCyclotomicExtension
namespace IsCyclotomicExtension
section Basic
theorem iff_adjoin_eq_top :
IsCyclotomicExtension S A B ↔
(∀ n : ℕ+, n ∈ S → ∃ r : B, IsPrimitiveRoot r n) ∧
adjoin A {b : B | ∃ n : ℕ+, n ∈ S ∧ b ^ (n : ℕ) = 1} = ⊤ :=
⟨fun h => ⟨fun _ => h.exists_prim_root, Algebra.eq_top_iff.2 h.adjoin_roots⟩, fun h =>
⟨h.1 _, Algebra.eq_top_iff.1 h.2⟩⟩
#align is_cyclotomic_extension.iff_adjoin_eq_top IsCyclotomicExtension.iff_adjoin_eq_top
theorem iff_singleton :
IsCyclotomicExtension {n} A B ↔
(∃ r : B, IsPrimitiveRoot r n) ∧ ∀ x, x ∈ adjoin A {b : B | b ^ (n : ℕ) = 1} := by
simp [isCyclotomicExtension_iff]
#align is_cyclotomic_extension.iff_singleton IsCyclotomicExtension.iff_singleton
theorem empty [h : IsCyclotomicExtension ∅ A B] : (⊥ : Subalgebra A B) = ⊤ := by
simpa [Algebra.eq_top_iff, isCyclotomicExtension_iff] using h
#align is_cyclotomic_extension.empty IsCyclotomicExtension.empty
theorem singleton_one [h : IsCyclotomicExtension {1} A B] : (⊥ : Subalgebra A B) = ⊤ :=
Algebra.eq_top_iff.2 fun x => by
simpa [adjoin_singleton_one] using ((isCyclotomicExtension_iff _ _ _).1 h).2 x
#align is_cyclotomic_extension.singleton_one IsCyclotomicExtension.singleton_one
variable {A B}
theorem singleton_zero_of_bot_eq_top (h : (⊥ : Subalgebra A B) = ⊤) :
IsCyclotomicExtension ∅ A B := by
-- Porting note: Lean3 is able to infer `A`.
refine (iff_adjoin_eq_top _ A _).2
⟨fun s hs => by simp at hs, _root_.eq_top_iff.2 fun x hx => ?_⟩
rw [← h] at hx
simpa using hx
#align is_cyclotomic_extension.singleton_zero_of_bot_eq_top IsCyclotomicExtension.singleton_zero_of_bot_eq_top
variable (A B)
theorem trans (C : Type w) [CommRing C] [Algebra A C] [Algebra B C] [IsScalarTower A B C]
[hS : IsCyclotomicExtension S A B] [hT : IsCyclotomicExtension T B C]
(h : Function.Injective (algebraMap B C)) : IsCyclotomicExtension (S ∪ T) A C := by
refine ⟨fun hn => ?_, fun x => ?_⟩
· cases' hn with hn hn
· obtain ⟨b, hb⟩ := ((isCyclotomicExtension_iff _ _ _).1 hS).1 hn
refine ⟨algebraMap B C b, ?_⟩
exact hb.map_of_injective h
· exact ((isCyclotomicExtension_iff _ _ _).1 hT).1 hn
· refine adjoin_induction (((isCyclotomicExtension_iff T B _).1 hT).2 x)
(fun c ⟨n, hn⟩ => subset_adjoin ⟨n, Or.inr hn.1, hn.2⟩) (fun b => ?_)
(fun x y hx hy => Subalgebra.add_mem _ hx hy) fun x y hx hy => Subalgebra.mul_mem _ hx hy
let f := IsScalarTower.toAlgHom A B C
have hb : f b ∈ (adjoin A {b : B | ∃ a : ℕ+, a ∈ S ∧ b ^ (a : ℕ) = 1}).map f :=
⟨b, ((isCyclotomicExtension_iff _ _ _).1 hS).2 b, rfl⟩
rw [IsScalarTower.toAlgHom_apply, ← adjoin_image] at hb
refine adjoin_mono (fun y hy => ?_) hb
obtain ⟨b₁, ⟨⟨n, hn⟩, h₁⟩⟩ := hy
exact ⟨n, ⟨mem_union_left T hn.1, by rw [← h₁, ← AlgHom.map_pow, hn.2, AlgHom.map_one]⟩⟩
#align is_cyclotomic_extension.trans IsCyclotomicExtension.trans
@[nontriviality]
| Mathlib/NumberTheory/Cyclotomic/Basic.lean | 154 | 168 | theorem subsingleton_iff [Subsingleton B] : IsCyclotomicExtension S A B ↔ S = { } ∨ S = {1} := by |
have : Subsingleton (Subalgebra A B) := inferInstance
constructor
· rintro ⟨hprim, -⟩
rw [← subset_singleton_iff_eq]
intro t ht
obtain ⟨ζ, hζ⟩ := hprim ht
rw [mem_singleton_iff, ← PNat.coe_eq_one_iff]
exact mod_cast hζ.unique (IsPrimitiveRoot.of_subsingleton ζ)
· rintro (rfl | rfl)
-- Porting note: `R := A` was not needed.
· exact ⟨fun h => h.elim, fun x => by convert (mem_top (R := A) : x ∈ ⊤)⟩
· rw [iff_singleton]
exact ⟨⟨0, IsPrimitiveRoot.of_subsingleton 0⟩,
fun x => by convert (mem_top (R := A) : x ∈ ⊤)⟩
| 14 |
import Mathlib.Algebra.Ring.Idempotents
import Mathlib.Analysis.Normed.Group.Basic
import Mathlib.Order.Basic
import Mathlib.Tactic.NoncommRing
#align_import analysis.normed_space.M_structure from "leanprover-community/mathlib"@"d11893b411025250c8e61ff2f12ccbd7ee35ab15"
variable (X : Type*) [NormedAddCommGroup X]
variable {M : Type*} [Ring M] [Module M X]
-- Porting note: Mathlib3 uses names with uppercase 'L' for L-projections
set_option linter.uppercaseLean3 false
structure IsLprojection (P : M) : Prop where
proj : IsIdempotentElem P
Lnorm : ∀ x : X, ‖x‖ = ‖P • x‖ + ‖(1 - P) • x‖
#align is_Lprojection IsLprojection
structure IsMprojection (P : M) : Prop where
proj : IsIdempotentElem P
Mnorm : ∀ x : X, ‖x‖ = max ‖P • x‖ ‖(1 - P) • x‖
#align is_Mprojection IsMprojection
variable {X}
namespace IsLprojection
-- Porting note: The literature always uses uppercase 'L' for L-projections
theorem Lcomplement {P : M} (h : IsLprojection X P) : IsLprojection X (1 - P) :=
⟨h.proj.one_sub, fun x => by
rw [add_comm, sub_sub_cancel]
exact h.Lnorm x⟩
#align is_Lprojection.Lcomplement IsLprojection.Lcomplement
theorem Lcomplement_iff (P : M) : IsLprojection X P ↔ IsLprojection X (1 - P) :=
⟨Lcomplement, fun h => sub_sub_cancel 1 P ▸ h.Lcomplement⟩
#align is_Lprojection.Lcomplement_iff IsLprojection.Lcomplement_iff
theorem commute [FaithfulSMul M X] {P Q : M} (h₁ : IsLprojection X P) (h₂ : IsLprojection X Q) :
Commute P Q := by
have PR_eq_RPR : ∀ R : M, IsLprojection X R → P * R = R * P * R := fun R h₃ => by
-- Porting note: Needed to fix function, which changes indent of following lines
refine @eq_of_smul_eq_smul _ X _ _ _ _ fun x => by
rw [← norm_sub_eq_zero_iff]
have e1 : ‖R • x‖ ≥ ‖R • x‖ + 2 • ‖(P * R) • x - (R * P * R) • x‖ :=
calc
‖R • x‖ = ‖R • P • R • x‖ + ‖(1 - R) • P • R • x‖ +
(‖(R * R) • x - R • P • R • x‖ + ‖(1 - R) • (1 - P) • R • x‖) := by
rw [h₁.Lnorm, h₃.Lnorm, h₃.Lnorm ((1 - P) • R • x), sub_smul 1 P, one_smul, smul_sub,
mul_smul]
_ = ‖R • P • R • x‖ + ‖(1 - R) • P • R • x‖ +
(‖R • x - R • P • R • x‖ + ‖((1 - R) * R) • x - (1 - R) • P • R • x‖) := by
rw [h₃.proj.eq, sub_smul 1 P, one_smul, smul_sub, mul_smul]
_ = ‖R • P • R • x‖ + ‖(1 - R) • P • R • x‖ +
(‖R • x - R • P • R • x‖ + ‖(1 - R) • P • R • x‖) := by
rw [sub_mul, h₃.proj.eq, one_mul, sub_self, zero_smul, zero_sub, norm_neg]
_ = ‖R • P • R • x‖ + ‖R • x - R • P • R • x‖ + 2 • ‖(1 - R) • P • R • x‖ := by abel
_ ≥ ‖R • x‖ + 2 • ‖(P * R) • x - (R * P * R) • x‖ := by
rw [GE.ge]
have :=
add_le_add_right (norm_le_insert' (R • x) (R • P • R • x)) (2 • ‖(1 - R) • P • R • x‖)
simpa only [mul_smul, sub_smul, one_smul] using this
rw [GE.ge] at e1
-- Porting note: Bump index in nth_rewrite
nth_rewrite 2 [← add_zero ‖R • x‖] at e1
rw [add_le_add_iff_left, two_smul, ← two_mul] at e1
rw [le_antisymm_iff]
refine ⟨?_, norm_nonneg _⟩
rwa [← mul_zero (2 : ℝ), mul_le_mul_left (show (0 : ℝ) < 2 by norm_num)] at e1
have QP_eq_QPQ : Q * P = Q * P * Q := by
have e1 : P * (1 - Q) = P * (1 - Q) - (Q * P - Q * P * Q) :=
calc
P * (1 - Q) = (1 - Q) * P * (1 - Q) := by rw [PR_eq_RPR (1 - Q) h₂.Lcomplement]
_ = P * (1 - Q) - (Q * P - Q * P * Q) := by noncomm_ring
rwa [eq_sub_iff_add_eq, add_right_eq_self, sub_eq_zero] at e1
show P * Q = Q * P
rw [QP_eq_QPQ, PR_eq_RPR Q h₂]
#align is_Lprojection.commute IsLprojection.commute
| Mathlib/Analysis/NormedSpace/MStructure.lean | 147 | 162 | theorem mul [FaithfulSMul M X] {P Q : M} (h₁ : IsLprojection X P) (h₂ : IsLprojection X Q) :
IsLprojection X (P * Q) := by |
refine ⟨IsIdempotentElem.mul_of_commute (h₁.commute h₂) h₁.proj h₂.proj, ?_⟩
intro x
refine le_antisymm ?_ ?_
· calc
‖x‖ = ‖(P * Q) • x + (x - (P * Q) • x)‖ := by rw [add_sub_cancel ((P * Q) • x) x]
_ ≤ ‖(P * Q) • x‖ + ‖x - (P * Q) • x‖ := by apply norm_add_le
_ = ‖(P * Q) • x‖ + ‖(1 - P * Q) • x‖ := by rw [sub_smul, one_smul]
· calc
‖x‖ = ‖P • Q • x‖ + (‖Q • x - P • Q • x‖ + ‖x - Q • x‖) := by
rw [h₂.Lnorm x, h₁.Lnorm (Q • x), sub_smul, one_smul, sub_smul, one_smul, add_assoc]
_ ≥ ‖P • Q • x‖ + ‖Q • x - P • Q • x + (x - Q • x)‖ :=
((add_le_add_iff_left ‖P • Q • x‖).mpr (norm_add_le (Q • x - P • Q • x) (x - Q • x)))
_ = ‖(P * Q) • x‖ + ‖(1 - P * Q) • x‖ := by
rw [sub_add_sub_cancel', sub_smul, one_smul, mul_smul]
| 14 |
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
| Mathlib/RingTheory/ClassGroup.lean | 126 | 144 | 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
| 14 |
import Mathlib.Analysis.Calculus.Deriv.Inv
import Mathlib.Analysis.Calculus.Deriv.Polynomial
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
import Mathlib.Analysis.SpecialFunctions.PolynomialExp
#align_import analysis.calculus.bump_function_inner from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
noncomputable section
open scoped Classical Topology
open Polynomial Real Filter Set Function
open scoped Polynomial
def expNegInvGlue (x : ℝ) : ℝ :=
if x ≤ 0 then 0 else exp (-x⁻¹)
#align exp_neg_inv_glue expNegInvGlue
namespace expNegInvGlue
theorem zero_of_nonpos {x : ℝ} (hx : x ≤ 0) : expNegInvGlue x = 0 := by simp [expNegInvGlue, hx]
#align exp_neg_inv_glue.zero_of_nonpos expNegInvGlue.zero_of_nonpos
@[simp] -- Porting note (#10756): new lemma
protected theorem zero : expNegInvGlue 0 = 0 := zero_of_nonpos le_rfl
theorem pos_of_pos {x : ℝ} (hx : 0 < x) : 0 < expNegInvGlue x := by
simp [expNegInvGlue, not_le.2 hx, exp_pos]
#align exp_neg_inv_glue.pos_of_pos expNegInvGlue.pos_of_pos
theorem nonneg (x : ℝ) : 0 ≤ expNegInvGlue x := by
cases le_or_gt x 0 with
| inl h => exact ge_of_eq (zero_of_nonpos h)
| inr h => exact le_of_lt (pos_of_pos h)
#align exp_neg_inv_glue.nonneg expNegInvGlue.nonneg
-- Porting note (#10756): new lemma
@[simp] theorem zero_iff_nonpos {x : ℝ} : expNegInvGlue x = 0 ↔ x ≤ 0 :=
⟨fun h ↦ not_lt.mp fun h' ↦ (pos_of_pos h').ne' h, zero_of_nonpos⟩
#noalign exp_neg_inv_glue.P_aux
#noalign exp_neg_inv_glue.f_aux
#noalign exp_neg_inv_glue.f_aux_zero_eq
#noalign exp_neg_inv_glue.f_aux_deriv
#noalign exp_neg_inv_glue.f_aux_deriv_pos
#noalign exp_neg_inv_glue.f_aux_limit
#noalign exp_neg_inv_glue.f_aux_deriv_zero
#noalign exp_neg_inv_glue.f_aux_has_deriv_at
theorem tendsto_polynomial_inv_mul_zero (p : ℝ[X]) :
Tendsto (fun x ↦ p.eval x⁻¹ * expNegInvGlue x) (𝓝 0) (𝓝 0) := by
simp only [expNegInvGlue, mul_ite, mul_zero]
refine tendsto_const_nhds.if ?_
simp only [not_le]
have : Tendsto (fun x ↦ p.eval x⁻¹ / exp x⁻¹) (𝓝[>] 0) (𝓝 0) :=
p.tendsto_div_exp_atTop.comp tendsto_inv_zero_atTop
refine this.congr' <| mem_of_superset self_mem_nhdsWithin fun x hx ↦ ?_
simp [expNegInvGlue, hx.out.not_le, exp_neg, div_eq_mul_inv]
| Mathlib/Analysis/SpecialFunctions/SmoothTransition.lean | 101 | 117 | theorem hasDerivAt_polynomial_eval_inv_mul (p : ℝ[X]) (x : ℝ) :
HasDerivAt (fun x ↦ p.eval x⁻¹ * expNegInvGlue x)
((X ^ 2 * (p - derivative (R := ℝ) p)).eval x⁻¹ * expNegInvGlue x) x := by |
rcases lt_trichotomy x 0 with hx | rfl | hx
· rw [zero_of_nonpos hx.le, mul_zero]
refine (hasDerivAt_const _ 0).congr_of_eventuallyEq ?_
filter_upwards [gt_mem_nhds hx] with y hy
rw [zero_of_nonpos hy.le, mul_zero]
· rw [expNegInvGlue.zero, mul_zero, hasDerivAt_iff_tendsto_slope]
refine ((tendsto_polynomial_inv_mul_zero (p * X)).mono_left inf_le_left).congr fun x ↦ ?_
simp [slope_def_field, div_eq_mul_inv, mul_right_comm]
· have := ((p.hasDerivAt x⁻¹).mul (hasDerivAt_neg _).exp).comp x (hasDerivAt_inv hx.ne')
convert this.congr_of_eventuallyEq _ using 1
· simp [expNegInvGlue, hx.not_le]
ring
· filter_upwards [lt_mem_nhds hx] with y hy
simp [expNegInvGlue, hy.not_le]
| 14 |
import Mathlib.MeasureTheory.Integral.Periodic
import Mathlib.Data.ZMod.Quotient
#align_import measure_theory.group.add_circle from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
open Set Function Filter MeasureTheory MeasureTheory.Measure Metric
open scoped MeasureTheory Pointwise Topology ENNReal
namespace AddCircle
variable {T : ℝ} [hT : Fact (0 < T)]
| Mathlib/MeasureTheory/Group/AddCircle.lean | 34 | 48 | theorem closedBall_ae_eq_ball {x : AddCircle T} {ε : ℝ} : closedBall x ε =ᵐ[volume] ball x ε := by |
rcases le_or_lt ε 0 with hε | hε
· rw [ball_eq_empty.mpr hε, ae_eq_empty, volume_closedBall,
min_eq_right (by linarith [hT.out] : 2 * ε ≤ T), ENNReal.ofReal_eq_zero]
exact mul_nonpos_of_nonneg_of_nonpos zero_le_two hε
· suffices volume (closedBall x ε) ≤ volume (ball x ε) by
exact (ae_eq_of_subset_of_measure_ge ball_subset_closedBall this measurableSet_ball
(measure_ne_top _ _)).symm
have : Tendsto (fun δ => volume (closedBall x δ)) (𝓝[<] ε) (𝓝 <| volume (closedBall x ε)) := by
simp_rw [volume_closedBall]
refine ENNReal.tendsto_ofReal (Tendsto.min tendsto_const_nhds <| Tendsto.const_mul _ ?_)
convert (@monotone_id ℝ _).tendsto_nhdsWithin_Iio ε
simp
refine le_of_tendsto this (mem_nhdsWithin_Iio_iff_exists_Ioo_subset.mpr ⟨0, hε, fun r hr => ?_⟩)
exact measure_mono (closedBall_subset_ball hr.2)
| 14 |
import Mathlib.Analysis.Convex.Topology
import Mathlib.Analysis.NormedSpace.Pointwise
import Mathlib.Analysis.Seminorm
import Mathlib.Analysis.LocallyConvex.Bounded
import Mathlib.Analysis.RCLike.Basic
#align_import analysis.convex.gauge from "leanprover-community/mathlib"@"373b03b5b9d0486534edbe94747f23cb3712f93d"
open NormedField Set
open scoped Pointwise Topology NNReal
noncomputable section
variable {𝕜 E F : Type*}
section AddCommGroup
variable [AddCommGroup E] [Module ℝ E]
def gauge (s : Set E) (x : E) : ℝ :=
sInf { r : ℝ | 0 < r ∧ x ∈ r • s }
#align gauge gauge
variable {s t : Set E} {x : E} {a : ℝ}
theorem gauge_def : gauge s x = sInf ({ r ∈ Set.Ioi (0 : ℝ) | x ∈ r • s }) :=
rfl
#align gauge_def gauge_def
theorem gauge_def' : gauge s x = sInf {r ∈ Set.Ioi (0 : ℝ) | r⁻¹ • x ∈ s} := by
congrm sInf {r | ?_}
exact and_congr_right fun hr => mem_smul_set_iff_inv_smul_mem₀ hr.ne' _ _
#align gauge_def' gauge_def'
private theorem gauge_set_bddBelow : BddBelow { r : ℝ | 0 < r ∧ x ∈ r • s } :=
⟨0, fun _ hr => hr.1.le⟩
theorem Absorbent.gauge_set_nonempty (absorbs : Absorbent ℝ s) :
{ r : ℝ | 0 < r ∧ x ∈ r • s }.Nonempty :=
let ⟨r, hr₁, hr₂⟩ := (absorbs x).exists_pos
⟨r, hr₁, hr₂ r (Real.norm_of_nonneg hr₁.le).ge rfl⟩
#align absorbent.gauge_set_nonempty Absorbent.gauge_set_nonempty
theorem gauge_mono (hs : Absorbent ℝ s) (h : s ⊆ t) : gauge t ≤ gauge s := fun _ =>
csInf_le_csInf gauge_set_bddBelow hs.gauge_set_nonempty fun _ hr => ⟨hr.1, smul_set_mono h hr.2⟩
#align gauge_mono gauge_mono
theorem exists_lt_of_gauge_lt (absorbs : Absorbent ℝ s) (h : gauge s x < a) :
∃ b, 0 < b ∧ b < a ∧ x ∈ b • s := by
obtain ⟨b, ⟨hb, hx⟩, hba⟩ := exists_lt_of_csInf_lt absorbs.gauge_set_nonempty h
exact ⟨b, hb, hba, hx⟩
#align exists_lt_of_gauge_lt exists_lt_of_gauge_lt
@[simp]
theorem gauge_zero : gauge s 0 = 0 := by
rw [gauge_def']
by_cases h : (0 : E) ∈ s
· simp only [smul_zero, sep_true, h, csInf_Ioi]
· simp only [smul_zero, sep_false, h, Real.sInf_empty]
#align gauge_zero gauge_zero
@[simp]
theorem gauge_zero' : gauge (0 : Set E) = 0 := by
ext x
rw [gauge_def']
obtain rfl | hx := eq_or_ne x 0
· simp only [csInf_Ioi, mem_zero, Pi.zero_apply, eq_self_iff_true, sep_true, smul_zero]
· simp only [mem_zero, Pi.zero_apply, inv_eq_zero, smul_eq_zero]
convert Real.sInf_empty
exact eq_empty_iff_forall_not_mem.2 fun r hr => hr.2.elim (ne_of_gt hr.1) hx
#align gauge_zero' gauge_zero'
@[simp]
theorem gauge_empty : gauge (∅ : Set E) = 0 := by
ext
simp only [gauge_def', Real.sInf_empty, mem_empty_iff_false, Pi.zero_apply, sep_false]
#align gauge_empty gauge_empty
theorem gauge_of_subset_zero (h : s ⊆ 0) : gauge s = 0 := by
obtain rfl | rfl := subset_singleton_iff_eq.1 h
exacts [gauge_empty, gauge_zero']
#align gauge_of_subset_zero gauge_of_subset_zero
theorem gauge_nonneg (x : E) : 0 ≤ gauge s x :=
Real.sInf_nonneg _ fun _ hx => hx.1.le
#align gauge_nonneg gauge_nonneg
theorem gauge_neg (symmetric : ∀ x ∈ s, -x ∈ s) (x : E) : gauge s (-x) = gauge s x := by
have : ∀ x, -x ∈ s ↔ x ∈ s := fun x => ⟨fun h => by simpa using symmetric _ h, symmetric x⟩
simp_rw [gauge_def', smul_neg, this]
#align gauge_neg gauge_neg
theorem gauge_neg_set_neg (x : E) : gauge (-s) (-x) = gauge s x := by
simp_rw [gauge_def', smul_neg, neg_mem_neg]
#align gauge_neg_set_neg gauge_neg_set_neg
theorem gauge_neg_set_eq_gauge_neg (x : E) : gauge (-s) x = gauge s (-x) := by
rw [← gauge_neg_set_neg, neg_neg]
#align gauge_neg_set_eq_gauge_neg gauge_neg_set_eq_gauge_neg
theorem gauge_le_of_mem (ha : 0 ≤ a) (hx : x ∈ a • s) : gauge s x ≤ a := by
obtain rfl | ha' := ha.eq_or_lt
· rw [mem_singleton_iff.1 (zero_smul_set_subset _ hx), gauge_zero]
· exact csInf_le gauge_set_bddBelow ⟨ha', hx⟩
#align gauge_le_of_mem gauge_le_of_mem
| Mathlib/Analysis/Convex/Gauge.lean | 148 | 163 | theorem gauge_le_eq (hs₁ : Convex ℝ s) (hs₀ : (0 : E) ∈ s) (hs₂ : Absorbent ℝ s) (ha : 0 ≤ a) :
{ x | gauge s x ≤ a } = ⋂ (r : ℝ) (_ : a < r), r • s := by |
ext x
simp_rw [Set.mem_iInter, Set.mem_setOf_eq]
refine ⟨fun h r hr => ?_, fun h => le_of_forall_pos_lt_add fun ε hε => ?_⟩
· have hr' := ha.trans_lt hr
rw [mem_smul_set_iff_inv_smul_mem₀ hr'.ne']
obtain ⟨δ, δ_pos, hδr, hδ⟩ := exists_lt_of_gauge_lt hs₂ (h.trans_lt hr)
suffices (r⁻¹ * δ) • δ⁻¹ • x ∈ s by rwa [smul_smul, mul_inv_cancel_right₀ δ_pos.ne'] at this
rw [mem_smul_set_iff_inv_smul_mem₀ δ_pos.ne'] at hδ
refine hs₁.smul_mem_of_zero_mem hs₀ hδ ⟨by positivity, ?_⟩
rw [inv_mul_le_iff hr', mul_one]
exact hδr.le
· have hε' := (lt_add_iff_pos_right a).2 (half_pos hε)
exact
(gauge_le_of_mem (ha.trans hε'.le) <| h _ hε').trans_lt (add_lt_add_left (half_lt_self hε) _)
| 14 |
import Mathlib.Algebra.MvPolynomial.Supported
import Mathlib.RingTheory.WittVector.Truncated
#align_import ring_theory.witt_vector.mul_coeff from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4"
noncomputable section
namespace WittVector
variable (p : ℕ) [hp : Fact p.Prime]
variable {k : Type*} [CommRing k]
local notation "𝕎" => WittVector p
-- Porting note: new notation
local notation "𝕄" => MvPolynomial (Fin 2 × ℕ) ℤ
open Finset MvPolynomial
def wittPolyProd (n : ℕ) : 𝕄 :=
rename (Prod.mk (0 : Fin 2)) (wittPolynomial p ℤ n) *
rename (Prod.mk (1 : Fin 2)) (wittPolynomial p ℤ n)
#align witt_vector.witt_poly_prod WittVector.wittPolyProd
theorem wittPolyProd_vars (n : ℕ) : (wittPolyProd p n).vars ⊆ univ ×ˢ range (n + 1) := by
rw [wittPolyProd]
apply Subset.trans (vars_mul _ _)
refine union_subset ?_ ?_ <;>
· refine Subset.trans (vars_rename _ _) ?_
simp [wittPolynomial_vars, image_subset_iff]
#align witt_vector.witt_poly_prod_vars WittVector.wittPolyProd_vars
def wittPolyProdRemainder (n : ℕ) : 𝕄 :=
∑ i ∈ range n, (p : 𝕄) ^ i * wittMul p i ^ p ^ (n - i)
#align witt_vector.witt_poly_prod_remainder WittVector.wittPolyProdRemainder
theorem wittPolyProdRemainder_vars (n : ℕ) :
(wittPolyProdRemainder p n).vars ⊆ univ ×ˢ range n := by
rw [wittPolyProdRemainder]
refine Subset.trans (vars_sum_subset _ _) ?_
rw [biUnion_subset]
intro x hx
apply Subset.trans (vars_mul _ _)
refine union_subset ?_ ?_
· apply Subset.trans (vars_pow _ _)
have : (p : 𝕄) = C (p : ℤ) := by simp only [Int.cast_natCast, eq_intCast]
rw [this, vars_C]
apply empty_subset
· apply Subset.trans (vars_pow _ _)
apply Subset.trans (wittMul_vars _ _)
apply product_subset_product (Subset.refl _)
simp only [mem_range, range_subset] at hx ⊢
exact hx
#align witt_vector.witt_poly_prod_remainder_vars WittVector.wittPolyProdRemainder_vars
def remainder (n : ℕ) : 𝕄 :=
(∑ x ∈ range (n + 1),
(rename (Prod.mk 0)) ((monomial (Finsupp.single x (p ^ (n + 1 - x)))) ((p : ℤ) ^ x))) *
∑ x ∈ range (n + 1),
(rename (Prod.mk 1)) ((monomial (Finsupp.single x (p ^ (n + 1 - x)))) ((p : ℤ) ^ x))
#align witt_vector.remainder WittVector.remainder
theorem remainder_vars (n : ℕ) : (remainder p n).vars ⊆ univ ×ˢ range (n + 1) := by
rw [remainder]
apply Subset.trans (vars_mul _ _)
refine union_subset ?_ ?_ <;>
· refine Subset.trans (vars_sum_subset _ _) ?_
rw [biUnion_subset]
intro x hx
rw [rename_monomial, vars_monomial, Finsupp.mapDomain_single]
· apply Subset.trans Finsupp.support_single_subset
simpa using mem_range.mp hx
· apply pow_ne_zero
exact mod_cast hp.out.ne_zero
#align witt_vector.remainder_vars WittVector.remainder_vars
def polyOfInterest (n : ℕ) : 𝕄 :=
wittMul p (n + 1) + (p : 𝕄) ^ (n + 1) * X (0, n + 1) * X (1, n + 1) -
X (0, n + 1) * rename (Prod.mk (1 : Fin 2)) (wittPolynomial p ℤ (n + 1)) -
X (1, n + 1) * rename (Prod.mk (0 : Fin 2)) (wittPolynomial p ℤ (n + 1))
#align witt_vector.poly_of_interest WittVector.polyOfInterest
| Mathlib/RingTheory/WittVector/MulCoeff.lean | 120 | 135 | theorem mul_polyOfInterest_aux1 (n : ℕ) :
∑ i ∈ range (n + 1), (p : 𝕄) ^ i * wittMul p i ^ p ^ (n - i) = wittPolyProd p n := by |
simp only [wittPolyProd]
convert wittStructureInt_prop p (X (0 : Fin 2) * X 1) n using 1
· simp only [wittPolynomial, wittMul]
rw [AlgHom.map_sum]
congr 1 with i
congr 1
have hsupp : (Finsupp.single i (p ^ (n - i))).support = {i} := by
rw [Finsupp.support_eq_singleton]
simp only [and_true_iff, Finsupp.single_eq_same, eq_self_iff_true, Ne]
exact pow_ne_zero _ hp.out.ne_zero
simp only [bind₁_monomial, hsupp, Int.cast_natCast, prod_singleton, eq_intCast,
Finsupp.single_eq_same, C_pow, mul_eq_mul_left_iff, true_or_iff, eq_self_iff_true,
Int.cast_pow]
· simp only [map_mul, bind₁_X_right]
| 14 |
import Mathlib.Analysis.Calculus.FormalMultilinearSeries
import Mathlib.Analysis.SpecificLimits.Normed
import Mathlib.Logic.Equiv.Fin
import Mathlib.Topology.Algebra.InfiniteSum.Module
#align_import analysis.analytic.basic from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514"
noncomputable section
variable {𝕜 E F G : Type*}
open scoped Classical
open Topology NNReal Filter ENNReal
open Set Filter Asymptotics
variable [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedAddCommGroup F]
[NormedSpace 𝕜 F] [NormedAddCommGroup G] [NormedSpace 𝕜 G]
namespace FormalMultilinearSeries
variable (p : FormalMultilinearSeries 𝕜 E F) {r : ℝ≥0}
def radius (p : FormalMultilinearSeries 𝕜 E F) : ℝ≥0∞ :=
⨆ (r : ℝ≥0) (C : ℝ) (_ : ∀ n, ‖p n‖ * (r : ℝ) ^ n ≤ C), (r : ℝ≥0∞)
#align formal_multilinear_series.radius FormalMultilinearSeries.radius
theorem le_radius_of_bound (C : ℝ) {r : ℝ≥0} (h : ∀ n : ℕ, ‖p n‖ * (r : ℝ) ^ n ≤ C) :
(r : ℝ≥0∞) ≤ p.radius :=
le_iSup_of_le r <| le_iSup_of_le C <| le_iSup (fun _ => (r : ℝ≥0∞)) h
#align formal_multilinear_series.le_radius_of_bound FormalMultilinearSeries.le_radius_of_bound
theorem le_radius_of_bound_nnreal (C : ℝ≥0) {r : ℝ≥0} (h : ∀ n : ℕ, ‖p n‖₊ * r ^ n ≤ C) :
(r : ℝ≥0∞) ≤ p.radius :=
p.le_radius_of_bound C fun n => mod_cast h n
#align formal_multilinear_series.le_radius_of_bound_nnreal FormalMultilinearSeries.le_radius_of_bound_nnreal
theorem le_radius_of_isBigO (h : (fun n => ‖p n‖ * (r : ℝ) ^ n) =O[atTop] fun _ => (1 : ℝ)) :
↑r ≤ p.radius :=
Exists.elim (isBigO_one_nat_atTop_iff.1 h) fun C hC =>
p.le_radius_of_bound C fun n => (le_abs_self _).trans (hC n)
set_option linter.uppercaseLean3 false in
#align formal_multilinear_series.le_radius_of_is_O FormalMultilinearSeries.le_radius_of_isBigO
theorem le_radius_of_eventually_le (C) (h : ∀ᶠ n in atTop, ‖p n‖ * (r : ℝ) ^ n ≤ C) :
↑r ≤ p.radius :=
p.le_radius_of_isBigO <| IsBigO.of_bound C <| h.mono fun n hn => by simpa
#align formal_multilinear_series.le_radius_of_eventually_le FormalMultilinearSeries.le_radius_of_eventually_le
theorem le_radius_of_summable_nnnorm (h : Summable fun n => ‖p n‖₊ * r ^ n) : ↑r ≤ p.radius :=
p.le_radius_of_bound_nnreal (∑' n, ‖p n‖₊ * r ^ n) fun _ => le_tsum' h _
#align formal_multilinear_series.le_radius_of_summable_nnnorm FormalMultilinearSeries.le_radius_of_summable_nnnorm
theorem le_radius_of_summable (h : Summable fun n => ‖p n‖ * (r : ℝ) ^ n) : ↑r ≤ p.radius :=
p.le_radius_of_summable_nnnorm <| by
simp only [← coe_nnnorm] at h
exact mod_cast h
#align formal_multilinear_series.le_radius_of_summable FormalMultilinearSeries.le_radius_of_summable
theorem radius_eq_top_of_forall_nnreal_isBigO
(h : ∀ r : ℝ≥0, (fun n => ‖p n‖ * (r : ℝ) ^ n) =O[atTop] fun _ => (1 : ℝ)) : p.radius = ∞ :=
ENNReal.eq_top_of_forall_nnreal_le fun r => p.le_radius_of_isBigO (h r)
set_option linter.uppercaseLean3 false in
#align formal_multilinear_series.radius_eq_top_of_forall_nnreal_is_O FormalMultilinearSeries.radius_eq_top_of_forall_nnreal_isBigO
theorem radius_eq_top_of_eventually_eq_zero (h : ∀ᶠ n in atTop, p n = 0) : p.radius = ∞ :=
p.radius_eq_top_of_forall_nnreal_isBigO fun r =>
(isBigO_zero _ _).congr' (h.mono fun n hn => by simp [hn]) EventuallyEq.rfl
#align formal_multilinear_series.radius_eq_top_of_eventually_eq_zero FormalMultilinearSeries.radius_eq_top_of_eventually_eq_zero
theorem radius_eq_top_of_forall_image_add_eq_zero (n : ℕ) (hn : ∀ m, p (m + n) = 0) :
p.radius = ∞ :=
p.radius_eq_top_of_eventually_eq_zero <|
mem_atTop_sets.2 ⟨n, fun _ hk => tsub_add_cancel_of_le hk ▸ hn _⟩
#align formal_multilinear_series.radius_eq_top_of_forall_image_add_eq_zero FormalMultilinearSeries.radius_eq_top_of_forall_image_add_eq_zero
@[simp]
theorem constFormalMultilinearSeries_radius {v : F} :
(constFormalMultilinearSeries 𝕜 E v).radius = ⊤ :=
(constFormalMultilinearSeries 𝕜 E v).radius_eq_top_of_forall_image_add_eq_zero 1
(by simp [constFormalMultilinearSeries])
#align formal_multilinear_series.const_formal_multilinear_series_radius FormalMultilinearSeries.constFormalMultilinearSeries_radius
| Mathlib/Analysis/Analytic/Basic.lean | 187 | 202 | theorem isLittleO_of_lt_radius (h : ↑r < p.radius) :
∃ a ∈ Ioo (0 : ℝ) 1, (fun n => ‖p n‖ * (r : ℝ) ^ n) =o[atTop] (a ^ ·) := by |
have := (TFAE_exists_lt_isLittleO_pow (fun n => ‖p n‖ * (r : ℝ) ^ n) 1).out 1 4
rw [this]
-- Porting note: was
-- rw [(TFAE_exists_lt_isLittleO_pow (fun n => ‖p n‖ * (r : ℝ) ^ n) 1).out 1 4]
simp only [radius, lt_iSup_iff] at h
rcases h with ⟨t, C, hC, rt⟩
rw [ENNReal.coe_lt_coe, ← NNReal.coe_lt_coe] at rt
have : 0 < (t : ℝ) := r.coe_nonneg.trans_lt rt
rw [← div_lt_one this] at rt
refine ⟨_, rt, C, Or.inr zero_lt_one, fun n => ?_⟩
calc
|‖p n‖ * (r : ℝ) ^ n| = ‖p n‖ * (t : ℝ) ^ n * (r / t : ℝ) ^ n := by
field_simp [mul_right_comm, abs_mul]
_ ≤ C * (r / t : ℝ) ^ n := by gcongr; apply hC
| 14 |
import Mathlib.CategoryTheory.Limits.Shapes.Biproducts
import Mathlib.GroupTheory.EckmannHilton
import Mathlib.Tactic.CategoryTheory.Reassoc
#align_import category_theory.preadditive.of_biproducts from "leanprover-community/mathlib"@"061ea99a5610cfc72c286aa930d3c1f47f74f3d0"
noncomputable section
universe v u
open CategoryTheory
open CategoryTheory.Limits
namespace CategoryTheory.SemiadditiveOfBinaryBiproducts
variable {C : Type u} [Category.{v} C] [HasZeroMorphisms C] [HasBinaryBiproducts C]
section
variable (X Y : C)
@[simp]
def leftAdd (f g : X ⟶ Y) : X ⟶ Y :=
biprod.lift f g ≫ biprod.desc (𝟙 Y) (𝟙 Y)
#align category_theory.semiadditive_of_binary_biproducts.left_add CategoryTheory.SemiadditiveOfBinaryBiproducts.leftAdd
@[simp]
def rightAdd (f g : X ⟶ Y) : X ⟶ Y :=
biprod.lift (𝟙 X) (𝟙 X) ≫ biprod.desc f g
#align category_theory.semiadditive_of_binary_biproducts.right_add CategoryTheory.SemiadditiveOfBinaryBiproducts.rightAdd
local infixr:65 " +ₗ " => leftAdd X Y
local infixr:65 " +ᵣ " => rightAdd X Y
theorem isUnital_leftAdd : EckmannHilton.IsUnital (· +ₗ ·) 0 := by
have hr : ∀ f : X ⟶ Y, biprod.lift (0 : X ⟶ Y) f = f ≫ biprod.inr := by
intro f
ext
· aesop_cat
· simp [biprod.lift_fst, Category.assoc, biprod.inr_fst, comp_zero]
have hl : ∀ f : X ⟶ Y, biprod.lift f (0 : X ⟶ Y) = f ≫ biprod.inl := by
intro f
ext
· aesop_cat
· simp [biprod.lift_snd, Category.assoc, biprod.inl_snd, comp_zero]
exact {
left_id := fun f => by simp [hr f, leftAdd, Category.assoc, Category.comp_id, biprod.inr_desc],
right_id := fun f => by simp [hl f, leftAdd, Category.assoc, Category.comp_id, biprod.inl_desc]
}
#align category_theory.semiadditive_of_binary_biproducts.is_unital_left_add CategoryTheory.SemiadditiveOfBinaryBiproducts.isUnital_leftAdd
| Mathlib/CategoryTheory/Preadditive/OfBiproducts.lean | 71 | 85 | theorem isUnital_rightAdd : EckmannHilton.IsUnital (· +ᵣ ·) 0 := by |
have h₂ : ∀ f : X ⟶ Y, biprod.desc (0 : X ⟶ Y) f = biprod.snd ≫ f := by
intro f
ext
· aesop_cat
· simp only [biprod.inr_desc, BinaryBicone.inr_snd_assoc]
have h₁ : ∀ f : X ⟶ Y, biprod.desc f (0 : X ⟶ Y) = biprod.fst ≫ f := by
intro f
ext
· aesop_cat
· simp only [biprod.inr_desc, BinaryBicone.inr_fst_assoc, zero_comp]
exact {
left_id := fun f => by simp [h₂ f, rightAdd, biprod.lift_snd_assoc, Category.id_comp],
right_id := fun f => by simp [h₁ f, rightAdd, biprod.lift_fst_assoc, Category.id_comp]
}
| 14 |
import Mathlib.Data.Nat.Lattice
import Mathlib.Logic.Denumerable
import Mathlib.Logic.Function.Iterate
import Mathlib.Order.Hom.Basic
import Mathlib.Data.Set.Subsingleton
#align_import order.order_iso_nat from "leanprover-community/mathlib"@"210657c4ea4a4a7b234392f70a3a2a83346dfa90"
variable {α : Type*}
namespace RelEmbedding
variable {r : α → α → Prop} [IsStrictOrder α r]
def natLT (f : ℕ → α) (H : ∀ n : ℕ, r (f n) (f (n + 1))) : ((· < ·) : ℕ → ℕ → Prop) ↪r r :=
ofMonotone f <| Nat.rel_of_forall_rel_succ_of_lt r H
#align rel_embedding.nat_lt RelEmbedding.natLT
@[simp]
theorem coe_natLT {f : ℕ → α} {H : ∀ n : ℕ, r (f n) (f (n + 1))} : ⇑(natLT f H) = f :=
rfl
#align rel_embedding.coe_nat_lt RelEmbedding.coe_natLT
def natGT (f : ℕ → α) (H : ∀ n : ℕ, r (f (n + 1)) (f n)) : ((· > ·) : ℕ → ℕ → Prop) ↪r r :=
haveI := IsStrictOrder.swap r
RelEmbedding.swap (natLT f H)
#align rel_embedding.nat_gt RelEmbedding.natGT
@[simp]
theorem coe_natGT {f : ℕ → α} {H : ∀ n : ℕ, r (f (n + 1)) (f n)} : ⇑(natGT f H) = f :=
rfl
#align rel_embedding.coe_nat_gt RelEmbedding.coe_natGT
theorem exists_not_acc_lt_of_not_acc {a : α} {r} (h : ¬Acc r a) : ∃ b, ¬Acc r b ∧ r b a := by
contrapose! h
refine ⟨_, fun b hr => ?_⟩
by_contra hb
exact h b hb hr
#align rel_embedding.exists_not_acc_lt_of_not_acc RelEmbedding.exists_not_acc_lt_of_not_acc
| Mathlib/Order/OrderIsoNat.lean | 66 | 81 | theorem acc_iff_no_decreasing_seq {x} :
Acc r x ↔ IsEmpty { f : ((· > ·) : ℕ → ℕ → Prop) ↪r r // x ∈ Set.range f } := by |
constructor
· refine fun h => h.recOn fun x _ IH => ?_
constructor
rintro ⟨f, k, hf⟩
exact IsEmpty.elim' (IH (f (k + 1)) (hf ▸ f.map_rel_iff.2 (lt_add_one k))) ⟨f, _, rfl⟩
· have : ∀ x : { a // ¬Acc r a }, ∃ y : { a // ¬Acc r a }, r y.1 x.1 := by
rintro ⟨x, hx⟩
cases exists_not_acc_lt_of_not_acc hx with
| intro w h => exact ⟨⟨w, h.1⟩, h.2⟩
choose f h using this
refine fun E =>
by_contradiction fun hx => E.elim' ⟨natGT (fun n => (f^[n] ⟨x, hx⟩).1) fun n => ?_, 0, rfl⟩
simp only [Function.iterate_succ']
apply h
| 14 |
import Mathlib.CategoryTheory.Sites.InducedTopology
import Mathlib.CategoryTheory.Sites.LocallyBijective
import Mathlib.CategoryTheory.Sites.PreservesLocallyBijective
import Mathlib.CategoryTheory.Sites.Whiskering
universe u
namespace CategoryTheory
open Functor Limits GrothendieckTopology
variable {C : Type*} [Category C] (J : GrothendieckTopology C)
variable {D : Type*} [Category D] (K : GrothendieckTopology D) (e : C ≌ D) (G : D ⥤ C)
variable (A : Type*) [Category A]
namespace Equivalence
| Mathlib/CategoryTheory/Sites/Equivalence.lean | 51 | 65 | theorem locallyCoverDense : LocallyCoverDense J e.inverse := by |
intro X T
convert T.prop
ext Z f
constructor
· rintro ⟨_, _, g', hg, rfl⟩
exact T.val.downward_closed hg g'
· intro hf
refine ⟨e.functor.obj Z, (Adjunction.homEquiv e.toAdjunction _ _).symm f, e.unit.app Z, ?_, ?_⟩
· simp only [Adjunction.homEquiv_counit, Functor.id_obj, Equivalence.toAdjunction_counit,
Sieve.functorPullback_apply, Presieve.functorPullback_mem, Functor.map_comp,
Equivalence.inv_fun_map, Functor.comp_obj, Category.assoc, Equivalence.unit_inverse_comp,
Category.comp_id]
exact T.val.downward_closed hf _
· simp
| 14 |
import Mathlib.Analysis.Complex.UpperHalfPlane.Basic
import Mathlib.Analysis.Convex.Contractible
import Mathlib.Analysis.Convex.Normed
import Mathlib.Analysis.Convex.Complex
import Mathlib.Analysis.Complex.ReImTopology
import Mathlib.Topology.Homotopy.Contractible
import Mathlib.Topology.PartialHomeomorph
#align_import analysis.complex.upper_half_plane.topology from "leanprover-community/mathlib"@"57f9349f2fe19d2de7207e99b0341808d977cdcf"
noncomputable section
open Set Filter Function TopologicalSpace Complex
open scoped Filter Topology UpperHalfPlane
namespace UpperHalfPlane
instance : TopologicalSpace ℍ :=
instTopologicalSpaceSubtype
theorem openEmbedding_coe : OpenEmbedding ((↑) : ℍ → ℂ) :=
IsOpen.openEmbedding_subtype_val <| isOpen_lt continuous_const Complex.continuous_im
#align upper_half_plane.open_embedding_coe UpperHalfPlane.openEmbedding_coe
theorem embedding_coe : Embedding ((↑) : ℍ → ℂ) :=
embedding_subtype_val
#align upper_half_plane.embedding_coe UpperHalfPlane.embedding_coe
theorem continuous_coe : Continuous ((↑) : ℍ → ℂ) :=
embedding_coe.continuous
#align upper_half_plane.continuous_coe UpperHalfPlane.continuous_coe
theorem continuous_re : Continuous re :=
Complex.continuous_re.comp continuous_coe
#align upper_half_plane.continuous_re UpperHalfPlane.continuous_re
theorem continuous_im : Continuous im :=
Complex.continuous_im.comp continuous_coe
#align upper_half_plane.continuous_im UpperHalfPlane.continuous_im
instance : SecondCountableTopology ℍ :=
TopologicalSpace.Subtype.secondCountableTopology _
instance : T3Space ℍ := Subtype.t3Space
instance : T4Space ℍ := inferInstance
instance : ContractibleSpace ℍ :=
(convex_halfspace_im_gt 0).contractibleSpace ⟨I, one_pos.trans_eq I_im.symm⟩
instance : LocPathConnectedSpace ℍ :=
locPathConnected_of_isOpen <| isOpen_lt continuous_const Complex.continuous_im
instance : NoncompactSpace ℍ := by
refine ⟨fun h => ?_⟩
have : IsCompact (Complex.im ⁻¹' Ioi 0) := isCompact_iff_isCompact_univ.2 h
replace := this.isClosed.closure_eq
rw [closure_preimage_im, closure_Ioi, Set.ext_iff] at this
exact absurd ((this 0).1 (@left_mem_Ici ℝ _ 0)) (@lt_irrefl ℝ _ 0)
instance : LocallyCompactSpace ℍ :=
openEmbedding_coe.locallyCompactSpace
section strips
def verticalStrip (A B : ℝ) := {z : ℍ | |z.re| ≤ A ∧ B ≤ z.im}
theorem mem_verticalStrip_iff (A B : ℝ) (z : ℍ) : z ∈ verticalStrip A B ↔ |z.re| ≤ A ∧ B ≤ z.im :=
Iff.rfl
@[gcongr]
lemma verticalStrip_mono {A B A' B' : ℝ} (hA : A ≤ A') (hB : B' ≤ B) :
verticalStrip A B ⊆ verticalStrip A' B' := by
rintro z ⟨hzre, hzim⟩
exact ⟨hzre.trans hA, hB.trans hzim⟩
@[gcongr]
lemma verticalStrip_mono_left {A A'} (h : A ≤ A') (B) : verticalStrip A B ⊆ verticalStrip A' B :=
verticalStrip_mono h le_rfl
@[gcongr]
lemma verticalStrip_anti_right (A) {B B'} (h : B' ≤ B) : verticalStrip A B ⊆ verticalStrip A B' :=
verticalStrip_mono le_rfl h
lemma subset_verticalStrip_of_isCompact {K : Set ℍ} (hK : IsCompact K) :
∃ A B : ℝ, 0 < B ∧ K ⊆ verticalStrip A B := by
rcases K.eq_empty_or_nonempty with rfl | hne
· exact ⟨1, 1, Real.zero_lt_one, empty_subset _⟩
obtain ⟨u, _, hu⟩ := hK.exists_isMaxOn hne (_root_.continuous_abs.comp continuous_re).continuousOn
obtain ⟨v, _, hv⟩ := hK.exists_isMinOn hne continuous_im.continuousOn
exact ⟨|re u|, im v, v.im_pos, fun k hk ↦ ⟨isMaxOn_iff.mp hu _ hk, isMinOn_iff.mp hv _ hk⟩⟩
| Mathlib/Analysis/Complex/UpperHalfPlane/Topology.lean | 109 | 124 | theorem ModularGroup_T_zpow_mem_verticalStrip (z : ℍ) {N : ℕ} (hn : 0 < N) :
∃ n : ℤ, ModularGroup.T ^ (N * n) • z ∈ verticalStrip N z.im := by |
let n := Int.floor (z.re/N)
use -n
rw [modular_T_zpow_smul z (N * -n)]
refine ⟨?_, (by simp only [mul_neg, Int.cast_neg, Int.cast_mul, Int.cast_natCast, vadd_im,
le_refl])⟩
have h : (N * (-n : ℝ) +ᵥ z).re = -N * Int.floor (z.re / N) + z.re := by
simp only [Int.cast_natCast, mul_neg, vadd_re, neg_mul]
norm_cast at *
rw [h, add_comm]
simp only [neg_mul, Int.cast_neg, Int.cast_mul, Int.cast_natCast, ge_iff_le]
have hnn : (0 : ℝ) < (N : ℝ) := by norm_cast at *
have h2 : z.re + -(N * n) = z.re - n * N := by ring
rw [h2, abs_eq_self.2 (Int.sub_floor_div_mul_nonneg (z.re : ℝ) hnn)]
apply (Int.sub_floor_div_mul_lt (z.re : ℝ) hnn).le
| 14 |
import Mathlib.Data.Rat.Sqrt
import Mathlib.Data.Real.Sqrt
import Mathlib.RingTheory.Algebraic
import Mathlib.RingTheory.Int.Basic
import Mathlib.Tactic.IntervalCases
#align_import data.real.irrational from "leanprover-community/mathlib"@"7e7aaccf9b0182576cabdde36cf1b5ad3585b70d"
open Rat Real multiplicity
def Irrational (x : ℝ) :=
x ∉ Set.range ((↑) : ℚ → ℝ)
#align irrational Irrational
theorem irrational_iff_ne_rational (x : ℝ) : Irrational x ↔ ∀ a b : ℤ, x ≠ a / b := by
simp only [Irrational, Rat.forall, cast_mk, not_exists, Set.mem_range, cast_intCast, cast_div,
eq_comm]
#align irrational_iff_ne_rational irrational_iff_ne_rational
theorem Transcendental.irrational {r : ℝ} (tr : Transcendental ℚ r) : Irrational r := by
rintro ⟨a, rfl⟩
exact tr (isAlgebraic_algebraMap a)
#align transcendental.irrational Transcendental.irrational
| Mathlib/Data/Real/Irrational.lean | 50 | 65 | theorem irrational_nrt_of_notint_nrt {x : ℝ} (n : ℕ) (m : ℤ) (hxr : x ^ n = m)
(hv : ¬∃ y : ℤ, x = y) (hnpos : 0 < n) : Irrational x := by |
rintro ⟨⟨N, D, P, C⟩, rfl⟩
rw [← cast_pow] at hxr
have c1 : ((D : ℤ) : ℝ) ≠ 0 := by
rw [Int.cast_ne_zero, Int.natCast_ne_zero]
exact P
have c2 : ((D : ℤ) : ℝ) ^ n ≠ 0 := pow_ne_zero _ c1
rw [mk'_eq_divInt, cast_pow, cast_mk, div_pow, div_eq_iff_mul_eq c2, ← Int.cast_pow,
← Int.cast_pow, ← Int.cast_mul, Int.cast_inj] at hxr
have hdivn : (D : ℤ) ^ n ∣ N ^ n := Dvd.intro_left m hxr
rw [← Int.dvd_natAbs, ← Int.natCast_pow, Int.natCast_dvd_natCast, Int.natAbs_pow,
Nat.pow_dvd_pow_iff hnpos.ne'] at hdivn
obtain rfl : D = 1 := by rw [← Nat.gcd_eq_right hdivn, C.gcd_eq_one]
refine hv ⟨N, ?_⟩
rw [mk'_eq_divInt, Int.ofNat_one, divInt_one, cast_intCast]
| 14 |
import Mathlib.Analysis.Calculus.Deriv.AffineMap
import Mathlib.Analysis.Calculus.Deriv.Slope
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Comp
import Mathlib.Analysis.Calculus.LocalExtr.Rolle
import Mathlib.Analysis.Convex.Normed
import Mathlib.Analysis.RCLike.Basic
#align_import analysis.calculus.mean_value from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} [NormedAddCommGroup F]
[NormedSpace ℝ F]
open Metric Set Asymptotics ContinuousLinearMap Filter
open scoped Classical Topology NNReal
theorem image_le_of_liminf_slope_right_lt_deriv_boundary' {f f' : ℝ → ℝ} {a b : ℝ}
(hf : ContinuousOn f (Icc a b))
-- `hf'` actually says `liminf (f z - f x) / (z - x) ≤ f' x`
(hf' : ∀ x ∈ Ico a b, ∀ r, f' x < r → ∃ᶠ z in 𝓝[>] x, slope f x z < r)
{B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : ContinuousOn B (Icc a b))
(hB' : ∀ x ∈ Ico a b, HasDerivWithinAt B (B' x) (Ici x) x)
(bound : ∀ x ∈ Ico a b, f x = B x → f' x < B' x) : ∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x := by
change Icc a b ⊆ { x | f x ≤ B x }
set s := { x | f x ≤ B x } ∩ Icc a b
have A : ContinuousOn (fun x => (f x, B x)) (Icc a b) := hf.prod hB
have : IsClosed s := by
simp only [s, inter_comm]
exact A.preimage_isClosed_of_isClosed isClosed_Icc OrderClosedTopology.isClosed_le'
apply this.Icc_subset_of_forall_exists_gt ha
rintro x ⟨hxB : f x ≤ B x, xab⟩ y hy
cases' hxB.lt_or_eq with hxB hxB
· -- If `f x < B x`, then all we need is continuity of both sides
refine nonempty_of_mem (inter_mem ?_ (Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, hy⟩))
have : ∀ᶠ x in 𝓝[Icc a b] x, f x < B x :=
A x (Ico_subset_Icc_self xab) (IsOpen.mem_nhds (isOpen_lt continuous_fst continuous_snd) hxB)
have : ∀ᶠ x in 𝓝[>] x, f x < B x := nhdsWithin_le_of_mem (Icc_mem_nhdsWithin_Ioi xab) this
exact this.mono fun y => le_of_lt
· rcases exists_between (bound x xab hxB) with ⟨r, hfr, hrB⟩
specialize hf' x xab r hfr
have HB : ∀ᶠ z in 𝓝[>] x, r < slope B x z :=
(hasDerivWithinAt_iff_tendsto_slope' <| lt_irrefl x).1 (hB' x xab).Ioi_of_Ici
(Ioi_mem_nhds hrB)
obtain ⟨z, hfz, hzB, hz⟩ : ∃ z, slope f x z < r ∧ r < slope B x z ∧ z ∈ Ioc x y :=
(hf'.and_eventually (HB.and (Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, hy⟩))).exists
refine ⟨z, ?_, hz⟩
have := (hfz.trans hzB).le
rwa [slope_def_field, slope_def_field, div_le_div_right (sub_pos.2 hz.1), hxB,
sub_le_sub_iff_right] at this
#align image_le_of_liminf_slope_right_lt_deriv_boundary' image_le_of_liminf_slope_right_lt_deriv_boundary'
theorem image_le_of_liminf_slope_right_lt_deriv_boundary {f f' : ℝ → ℝ} {a b : ℝ}
(hf : ContinuousOn f (Icc a b))
-- `hf'` actually says `liminf (f z - f x) / (z - x) ≤ f' x`
(hf' : ∀ x ∈ Ico a b, ∀ r, f' x < r → ∃ᶠ z in 𝓝[>] x, slope f x z < r)
{B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : ∀ x, HasDerivAt B (B' x) x)
(bound : ∀ x ∈ Ico a b, f x = B x → f' x < B' x) : ∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x :=
image_le_of_liminf_slope_right_lt_deriv_boundary' hf hf' ha
(fun x _ => (hB x).continuousAt.continuousWithinAt) (fun x _ => (hB x).hasDerivWithinAt) bound
#align image_le_of_liminf_slope_right_lt_deriv_boundary image_le_of_liminf_slope_right_lt_deriv_boundary
| Mathlib/Analysis/Calculus/MeanValue.lean | 156 | 175 | theorem image_le_of_liminf_slope_right_le_deriv_boundary {f : ℝ → ℝ} {a b : ℝ}
(hf : ContinuousOn f (Icc a b)) {B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : ContinuousOn B (Icc a b))
(hB' : ∀ x ∈ Ico a b, HasDerivWithinAt B (B' x) (Ici x) x)
-- `bound` actually says `liminf (f z - f x) / (z - x) ≤ B' x`
(bound : ∀ x ∈ Ico a b, ∀ r, B' x < r → ∃ᶠ z in 𝓝[>] x, slope f x z < r) :
∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x := by |
have Hr : ∀ x ∈ Icc a b, ∀ r > 0, f x ≤ B x + r * (x - a) := fun x hx r hr => by
apply image_le_of_liminf_slope_right_lt_deriv_boundary' hf bound
· rwa [sub_self, mul_zero, add_zero]
· exact hB.add (continuousOn_const.mul (continuousOn_id.sub continuousOn_const))
· intro x hx
exact (hB' x hx).add (((hasDerivWithinAt_id x (Ici x)).sub_const a).const_mul r)
· intro x _ _
rw [mul_one]
exact (lt_add_iff_pos_right _).2 hr
exact hx
intro x hx
have : ContinuousWithinAt (fun r => B x + r * (x - a)) (Ioi 0) 0 :=
continuousWithinAt_const.add (continuousWithinAt_id.mul continuousWithinAt_const)
convert continuousWithinAt_const.closure_le _ this (Hr x hx) using 1 <;> simp
| 14 |
import Mathlib.Algebra.Algebra.Subalgebra.Pointwise
import Mathlib.AlgebraicGeometry.PrimeSpectrum.Maximal
import Mathlib.AlgebraicGeometry.PrimeSpectrum.Noetherian
import Mathlib.RingTheory.ChainOfDivisors
import Mathlib.RingTheory.DedekindDomain.Basic
import Mathlib.RingTheory.FractionalIdeal.Operations
#align_import ring_theory.dedekind_domain.ideal from "leanprover-community/mathlib"@"2bbc7e3884ba234309d2a43b19144105a753292e"
variable (R A K : Type*) [CommRing R] [CommRing A] [Field K]
open scoped nonZeroDivisors Polynomial
section Inverse
namespace FractionalIdeal
variable {R₁ : Type*} [CommRing R₁] [IsDomain R₁] [Algebra R₁ K] [IsFractionRing R₁ K]
variable {I J : FractionalIdeal R₁⁰ K}
noncomputable instance : Inv (FractionalIdeal R₁⁰ K) := ⟨fun I => 1 / I⟩
theorem inv_eq : I⁻¹ = 1 / I := rfl
#align fractional_ideal.inv_eq FractionalIdeal.inv_eq
theorem inv_zero' : (0 : FractionalIdeal R₁⁰ K)⁻¹ = 0 := div_zero
#align fractional_ideal.inv_zero' FractionalIdeal.inv_zero'
theorem inv_nonzero {J : FractionalIdeal R₁⁰ K} (h : J ≠ 0) :
J⁻¹ = ⟨(1 : FractionalIdeal R₁⁰ K) / J, fractional_div_of_nonzero h⟩ := div_nonzero h
#align fractional_ideal.inv_nonzero FractionalIdeal.inv_nonzero
theorem coe_inv_of_nonzero {J : FractionalIdeal R₁⁰ K} (h : J ≠ 0) :
(↑J⁻¹ : Submodule R₁ K) = IsLocalization.coeSubmodule K ⊤ / (J : Submodule R₁ K) := by
simp_rw [inv_nonzero _ h, coe_one, coe_mk, IsLocalization.coeSubmodule_top]
#align fractional_ideal.coe_inv_of_nonzero FractionalIdeal.coe_inv_of_nonzero
variable {K}
theorem mem_inv_iff (hI : I ≠ 0) {x : K} : x ∈ I⁻¹ ↔ ∀ y ∈ I, x * y ∈ (1 : FractionalIdeal R₁⁰ K) :=
mem_div_iff_of_nonzero hI
#align fractional_ideal.mem_inv_iff FractionalIdeal.mem_inv_iff
theorem inv_anti_mono (hI : I ≠ 0) (hJ : J ≠ 0) (hIJ : I ≤ J) : J⁻¹ ≤ I⁻¹ := by
-- Porting note: in Lean3, introducing `x` would just give `x ∈ J⁻¹ → x ∈ I⁻¹`, but
-- in Lean4, it goes all the way down to the subtypes
intro x
simp only [val_eq_coe, mem_coe, mem_inv_iff hJ, mem_inv_iff hI]
exact fun h y hy => h y (hIJ hy)
#align fractional_ideal.inv_anti_mono FractionalIdeal.inv_anti_mono
theorem le_self_mul_inv {I : FractionalIdeal R₁⁰ K} (hI : I ≤ (1 : FractionalIdeal R₁⁰ K)) :
I ≤ I * I⁻¹ :=
le_self_mul_one_div hI
#align fractional_ideal.le_self_mul_inv FractionalIdeal.le_self_mul_inv
variable (K)
theorem coe_ideal_le_self_mul_inv (I : Ideal R₁) :
(I : FractionalIdeal R₁⁰ K) ≤ I * (I : FractionalIdeal R₁⁰ K)⁻¹ :=
le_self_mul_inv coeIdeal_le_one
#align fractional_ideal.coe_ideal_le_self_mul_inv FractionalIdeal.coe_ideal_le_self_mul_inv
| Mathlib/RingTheory/DedekindDomain/Ideal.lean | 108 | 122 | theorem right_inverse_eq (I J : FractionalIdeal R₁⁰ K) (h : I * J = 1) : J = I⁻¹ := by |
have hI : I ≠ 0 := ne_zero_of_mul_eq_one I J h
suffices h' : I * (1 / I) = 1 from
congr_arg Units.inv <| @Units.ext _ _ (Units.mkOfMulEqOne _ _ h) (Units.mkOfMulEqOne _ _ h') rfl
apply le_antisymm
· apply mul_le.mpr _
intro x hx y hy
rw [mul_comm]
exact (mem_div_iff_of_nonzero hI).mp hy x hx
rw [← h]
apply mul_left_mono I
apply (le_div_iff_of_nonzero hI).mpr _
intro y hy x hx
rw [mul_comm]
exact mul_mem_mul hx hy
| 14 |
import Mathlib.Algebra.BigOperators.Ring
import Mathlib.Algebra.Field.Rat
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Algebra.Order.Field.Rat
import Mathlib.Combinatorics.Enumerative.DoubleCounting
import Mathlib.Combinatorics.SetFamily.Shadow
#align_import combinatorics.set_family.lym from "leanprover-community/mathlib"@"861a26926586cd46ff80264d121cdb6fa0e35cc1"
open Finset Nat
open FinsetFamily
variable {𝕜 α : Type*} [LinearOrderedField 𝕜]
namespace Finset
section LYM
section Falling
variable [DecidableEq α] (k : ℕ) (𝒜 : Finset (Finset α))
def falling : Finset (Finset α) :=
𝒜.sup <| powersetCard k
#align finset.falling Finset.falling
variable {𝒜 k} {s : Finset α}
theorem mem_falling : s ∈ falling k 𝒜 ↔ (∃ t ∈ 𝒜, s ⊆ t) ∧ s.card = k := by
simp_rw [falling, mem_sup, mem_powersetCard]
aesop
#align finset.mem_falling Finset.mem_falling
variable (𝒜 k)
theorem sized_falling : (falling k 𝒜 : Set (Finset α)).Sized k := fun _ hs => (mem_falling.1 hs).2
#align finset.sized_falling Finset.sized_falling
theorem slice_subset_falling : 𝒜 # k ⊆ falling k 𝒜 := fun s hs =>
mem_falling.2 <| (mem_slice.1 hs).imp_left fun h => ⟨s, h, Subset.refl _⟩
#align finset.slice_subset_falling Finset.slice_subset_falling
theorem falling_zero_subset : falling 0 𝒜 ⊆ {∅} :=
subset_singleton_iff'.2 fun _ ht => card_eq_zero.1 <| sized_falling _ _ ht
#align finset.falling_zero_subset Finset.falling_zero_subset
| Mathlib/Combinatorics/SetFamily/LYM.lean | 149 | 163 | theorem slice_union_shadow_falling_succ : 𝒜 # k ∪ ∂ (falling (k + 1) 𝒜) = falling k 𝒜 := by |
ext s
simp_rw [mem_union, mem_slice, mem_shadow_iff, mem_falling]
constructor
· rintro (h | ⟨s, ⟨⟨t, ht, hst⟩, hs⟩, a, ha, rfl⟩)
· exact ⟨⟨s, h.1, Subset.refl _⟩, h.2⟩
refine ⟨⟨t, ht, (erase_subset _ _).trans hst⟩, ?_⟩
rw [card_erase_of_mem ha, hs]
rfl
· rintro ⟨⟨t, ht, hst⟩, hs⟩
by_cases h : s ∈ 𝒜
· exact Or.inl ⟨h, hs⟩
obtain ⟨a, ha, hst⟩ := ssubset_iff.1 (ssubset_of_subset_of_ne hst (ht.ne_of_not_mem h).symm)
refine Or.inr ⟨insert a s, ⟨⟨t, ht, hst⟩, ?_⟩, a, mem_insert_self _ _, erase_insert ha⟩
rw [card_insert_of_not_mem ha, hs]
| 14 |
import Mathlib.CategoryTheory.Sites.Coherent.Comparison
import Mathlib.CategoryTheory.Sites.Coherent.ExtensiveSheaves
import Mathlib.CategoryTheory.Sites.Coherent.ReflectsPrecoherent
import Mathlib.CategoryTheory.Sites.Coherent.ReflectsPreregular
import Mathlib.CategoryTheory.Sites.InducedTopology
import Mathlib.CategoryTheory.Sites.Whiskering
universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄
namespace CategoryTheory
open Limits Functor regularTopology
variable {C D : Type*} [Category C] [Category D] (F : C ⥤ D)
namespace coherentTopology
variable [F.PreservesFiniteEffectiveEpiFamilies] [F.ReflectsFiniteEffectiveEpiFamilies]
[F.Full] [F.Faithful] [F.EffectivelyEnough] [Precoherent D]
instance : F.IsCoverDense (coherentTopology _) := by
refine F.isCoverDense_of_generate_singleton_functor_π_mem _ fun B ↦ ⟨_, F.effectiveEpiOver B, ?_⟩
apply Coverage.saturate.of
refine ⟨Unit, inferInstance, fun _ => F.effectiveEpiOverObj B,
fun _ => F.effectiveEpiOver B, ?_ , ?_⟩
· funext; ext -- Do we want `Presieve.ext`?
refine ⟨fun ⟨⟩ ↦ ⟨()⟩, ?_⟩
rintro ⟨⟩
simp
· rw [← effectiveEpi_iff_effectiveEpiFamily]
infer_instance
theorem exists_effectiveEpiFamily_iff_mem_induced (X : C) (S : Sieve X) :
(∃ (α : Type) (_ : Finite α) (Y : α → C) (π : (a : α) → (Y a ⟶ X)),
EffectiveEpiFamily Y π ∧ (∀ a : α, (S.arrows) (π a)) ) ↔
(S ∈ F.inducedTopologyOfIsCoverDense (coherentTopology _) X) := by
refine ⟨fun ⟨α, _, Y, π, ⟨H₁, H₂⟩⟩ ↦ ?_, fun hS ↦ ?_⟩
· apply (mem_sieves_iff_hasEffectiveEpiFamily (Sieve.functorPushforward _ S)).mpr
refine ⟨α, inferInstance, fun i => F.obj (Y i),
fun i => F.map (π i), ⟨?_,
fun a => Sieve.image_mem_functorPushforward F S (H₂ a)⟩⟩
exact F.map_finite_effectiveEpiFamily _ _
· obtain ⟨α, _, Y, π, ⟨H₁, H₂⟩⟩ := (mem_sieves_iff_hasEffectiveEpiFamily _).mp hS
refine ⟨α, inferInstance, ?_⟩
let Z : α → C := fun a ↦ (Functor.EffectivelyEnough.presentation (F := F) (Y a)).some.p
let g₀ : (a : α) → F.obj (Z a) ⟶ Y a := fun a ↦ F.effectiveEpiOver (Y a)
have : EffectiveEpiFamily _ (fun a ↦ g₀ a ≫ π a) := inferInstance
refine ⟨Z , fun a ↦ F.preimage (g₀ a ≫ π a), ?_, fun a ↦ (?_ : S.arrows (F.preimage _))⟩
· refine F.finite_effectiveEpiFamily_of_map _ _ ?_
simpa using this
· obtain ⟨W, g₁, g₂, h₁, h₂⟩ := H₂ a
rw [h₂]
convert S.downward_closed h₁ (F.preimage (g₀ a ≫ g₂))
exact F.map_injective (by simp)
lemma eq_induced : haveI := F.reflects_precoherent
coherentTopology C =
F.inducedTopologyOfIsCoverDense (coherentTopology _) := by
ext X S
have := F.reflects_precoherent
rw [← exists_effectiveEpiFamily_iff_mem_induced F X]
rw [← coherentTopology.mem_sieves_iff_hasEffectiveEpiFamily S]
lemma coverPreserving : haveI := F.reflects_precoherent
CoverPreserving (coherentTopology _) (coherentTopology _) F := by
rw [eq_induced F]
apply LocallyCoverDense.inducedTopology_coverPreserving
instance coverLifting : haveI := F.reflects_precoherent
F.IsCocontinuous (coherentTopology _) (coherentTopology _) := by
rw [eq_induced F]
apply LocallyCoverDense.inducedTopology_isCocontinuous
instance isContinuous : haveI := F.reflects_precoherent
F.IsContinuous (coherentTopology _) (coherentTopology _) :=
Functor.IsCoverDense.isContinuous _ _ _ (coverPreserving F)
namespace regularTopology
variable [F.PreservesEffectiveEpis] [F.ReflectsEffectiveEpis] [F.Full] [F.Faithful]
[F.EffectivelyEnough] [Preregular D]
instance : F.IsCoverDense (regularTopology _) := by
refine F.isCoverDense_of_generate_singleton_functor_π_mem _ fun B ↦ ⟨_, F.effectiveEpiOver B, ?_⟩
apply Coverage.saturate.of
refine ⟨F.effectiveEpiOverObj B, F.effectiveEpiOver B, ?_, inferInstance⟩
funext; ext -- Do we want `Presieve.ext`?
refine ⟨fun ⟨⟩ ↦ ⟨()⟩, ?_⟩
rintro ⟨⟩
simp
| Mathlib/CategoryTheory/Sites/Coherent/SheafComparison.lean | 161 | 178 | theorem exists_effectiveEpi_iff_mem_induced (X : C) (S : Sieve X) :
(∃ (Y : C) (π : Y ⟶ X),
EffectiveEpi π ∧ S.arrows π) ↔
(S ∈ F.inducedTopologyOfIsCoverDense (regularTopology _) X) := by |
refine ⟨fun ⟨Y, π, ⟨H₁, H₂⟩⟩ ↦ ?_, fun hS ↦ ?_⟩
· apply (mem_sieves_iff_hasEffectiveEpi (Sieve.functorPushforward _ S)).mpr
refine ⟨F.obj Y, F.map π, ⟨?_, Sieve.image_mem_functorPushforward F S H₂⟩⟩
exact F.map_effectiveEpi _
· obtain ⟨Y, π, ⟨H₁, H₂⟩⟩ := (mem_sieves_iff_hasEffectiveEpi _).mp hS
let g₀ := F.effectiveEpiOver Y
refine ⟨_, F.preimage (g₀ ≫ π), ?_, (?_ : S.arrows (F.preimage _))⟩
· refine F.effectiveEpi_of_map _ ?_
simp only [map_preimage]
infer_instance
· obtain ⟨W, g₁, g₂, h₁, h₂⟩ := H₂
rw [h₂]
convert S.downward_closed h₁ (F.preimage (g₀ ≫ g₂))
exact F.map_injective (by simp)
| 14 |
import Mathlib.Analysis.Calculus.ContDiff.Basic
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Shift
import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
variable
{𝕜 : Type*} [NontriviallyNormedField 𝕜]
{F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
{R : Type*} [Semiring R] [Module R F] [SMulCommClass 𝕜 R F] [ContinuousConstSMul R F]
{n : ℕ} {x : 𝕜} {s : Set 𝕜} (hx : x ∈ s) (h : UniqueDiffOn 𝕜 s) {f g : 𝕜 → F}
theorem iteratedDerivWithin_add (hf : ContDiffOn 𝕜 n f s) (hg : ContDiffOn 𝕜 n g s) :
iteratedDerivWithin n (f + g) s x =
iteratedDerivWithin n f s x + iteratedDerivWithin n g s x := by
simp_rw [iteratedDerivWithin, iteratedFDerivWithin_add_apply hf hg h hx,
ContinuousMultilinearMap.add_apply]
theorem iteratedDerivWithin_congr (hfg : Set.EqOn f g s) :
Set.EqOn (iteratedDerivWithin n f s) (iteratedDerivWithin n g s) s := by
induction n generalizing f g with
| zero => rwa [iteratedDerivWithin_zero]
| succ n IH =>
intro y hy
have : UniqueDiffWithinAt 𝕜 s y := h.uniqueDiffWithinAt hy
rw [iteratedDerivWithin_succ this, iteratedDerivWithin_succ this]
exact derivWithin_congr (IH hfg) (IH hfg hy)
theorem iteratedDerivWithin_const_add (hn : 0 < n) (c : F) :
iteratedDerivWithin n (fun z => c + f z) s x = iteratedDerivWithin n f s x := by
obtain ⟨n, rfl⟩ := n.exists_eq_succ_of_ne_zero hn.ne'
rw [iteratedDerivWithin_succ' h hx, iteratedDerivWithin_succ' h hx]
refine iteratedDerivWithin_congr h ?_ hx
intro y hy
exact derivWithin_const_add (h.uniqueDiffWithinAt hy) _
theorem iteratedDerivWithin_const_neg (hn : 0 < n) (c : F) :
iteratedDerivWithin n (fun z => c - f z) s x = iteratedDerivWithin n (fun z => -f z) s x := by
obtain ⟨n, rfl⟩ := n.exists_eq_succ_of_ne_zero hn.ne'
rw [iteratedDerivWithin_succ' h hx, iteratedDerivWithin_succ' h hx]
refine iteratedDerivWithin_congr h ?_ hx
intro y hy
have : UniqueDiffWithinAt 𝕜 s y := h.uniqueDiffWithinAt hy
rw [derivWithin.neg this]
exact derivWithin_const_sub this _
theorem iteratedDerivWithin_const_smul (c : R) (hf : ContDiffOn 𝕜 n f s) :
iteratedDerivWithin n (c • f) s x = c • iteratedDerivWithin n f s x := by
simp_rw [iteratedDerivWithin]
rw [iteratedFDerivWithin_const_smul_apply hf h hx]
simp only [ContinuousMultilinearMap.smul_apply]
theorem iteratedDerivWithin_const_mul (c : 𝕜) {f : 𝕜 → 𝕜} (hf : ContDiffOn 𝕜 n f s) :
iteratedDerivWithin n (fun z => c * f z) s x = c * iteratedDerivWithin n f s x := by
simpa using iteratedDerivWithin_const_smul (F := 𝕜) hx h c hf
variable (f) in
theorem iteratedDerivWithin_neg :
iteratedDerivWithin n (-f) s x = -iteratedDerivWithin n f s x := by
rw [iteratedDerivWithin, iteratedDerivWithin, iteratedFDerivWithin_neg_apply h hx,
ContinuousMultilinearMap.neg_apply]
variable (f) in
theorem iteratedDerivWithin_neg' :
iteratedDerivWithin n (fun z => -f z) s x = -iteratedDerivWithin n f s x :=
iteratedDerivWithin_neg hx h f
theorem iteratedDerivWithin_sub (hf : ContDiffOn 𝕜 n f s) (hg : ContDiffOn 𝕜 n g s) :
iteratedDerivWithin n (f - g) s x =
iteratedDerivWithin n f s x - iteratedDerivWithin n g s x := by
rw [sub_eq_add_neg, sub_eq_add_neg, Pi.neg_def, iteratedDerivWithin_add hx h hf hg.neg,
iteratedDerivWithin_neg' hx h]
| Mathlib/Analysis/Calculus/IteratedDeriv/Lemmas.lean | 85 | 100 | theorem iteratedDeriv_const_smul {n : ℕ} {f : 𝕜 → F} (h : ContDiff 𝕜 n f) (c : 𝕜) :
iteratedDeriv n (fun x => f (c * x)) = fun x => c ^ n • iteratedDeriv n f (c * x) := by |
induction n with
| zero => simp
| succ n ih =>
funext x
have h₀ : DifferentiableAt 𝕜 (iteratedDeriv n f) (c * x) :=
h.differentiable_iteratedDeriv n (Nat.cast_lt.mpr n.lt_succ_self) |>.differentiableAt
have h₁ : DifferentiableAt 𝕜 (fun x => iteratedDeriv n f (c * x)) x := by
rw [← Function.comp_def]
apply DifferentiableAt.comp
· exact h.differentiable_iteratedDeriv n (Nat.cast_lt.mpr n.lt_succ_self) |>.differentiableAt
· exact differentiableAt_id'.const_mul _
rw [iteratedDeriv_succ, ih h.of_succ, deriv_const_smul _ h₁, iteratedDeriv_succ,
← Function.comp_def, deriv.scomp x h₀ (differentiableAt_id'.const_mul _),
deriv_const_mul _ differentiableAt_id', deriv_id'', smul_smul, mul_one, pow_succ]
| 14 |
import Mathlib.Analysis.Calculus.ContDiff.Bounds
import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
import Mathlib.Analysis.Calculus.LineDeriv.Basic
import Mathlib.Analysis.LocallyConvex.WithSeminorms
import Mathlib.Analysis.Normed.Group.ZeroAtInfty
import Mathlib.Analysis.SpecialFunctions.Pow.Real
import Mathlib.Analysis.SpecialFunctions.JapaneseBracket
import Mathlib.Topology.Algebra.UniformFilterBasis
import Mathlib.Tactic.MoveAdd
#align_import analysis.schwartz_space from "leanprover-community/mathlib"@"e137999b2c6f2be388f4cd3bbf8523de1910cd2b"
noncomputable section
open scoped Nat NNReal
variable {𝕜 𝕜' D E F G V : Type*}
variable [NormedAddCommGroup E] [NormedSpace ℝ E]
variable [NormedAddCommGroup F] [NormedSpace ℝ F]
variable (E F)
structure SchwartzMap where
toFun : E → F
smooth' : ContDiff ℝ ⊤ toFun
decay' : ∀ k n : ℕ, ∃ C : ℝ, ∀ x, ‖x‖ ^ k * ‖iteratedFDeriv ℝ n toFun x‖ ≤ C
#align schwartz_map SchwartzMap
scoped[SchwartzMap] notation "𝓢(" E ", " F ")" => SchwartzMap E F
variable {E F}
namespace SchwartzMap
-- Porting note: removed
-- instance : Coe 𝓢(E, F) (E → F) := ⟨toFun⟩
instance instFunLike : FunLike 𝓢(E, F) E F where
coe f := f.toFun
coe_injective' f g h := by cases f; cases g; congr
#align schwartz_map.fun_like SchwartzMap.instFunLike
instance instCoeFun : CoeFun 𝓢(E, F) fun _ => E → F :=
DFunLike.hasCoeToFun
#align schwartz_map.has_coe_to_fun SchwartzMap.instCoeFun
theorem decay (f : 𝓢(E, F)) (k n : ℕ) :
∃ C : ℝ, 0 < C ∧ ∀ x, ‖x‖ ^ k * ‖iteratedFDeriv ℝ n f x‖ ≤ C := by
rcases f.decay' k n with ⟨C, hC⟩
exact ⟨max C 1, by positivity, fun x => (hC x).trans (le_max_left _ _)⟩
#align schwartz_map.decay SchwartzMap.decay
theorem smooth (f : 𝓢(E, F)) (n : ℕ∞) : ContDiff ℝ n f :=
f.smooth'.of_le le_top
#align schwartz_map.smooth SchwartzMap.smooth
@[continuity]
protected theorem continuous (f : 𝓢(E, F)) : Continuous f :=
(f.smooth 0).continuous
#align schwartz_map.continuous SchwartzMap.continuous
instance instContinuousMapClass : ContinuousMapClass 𝓢(E, F) E F where
map_continuous := SchwartzMap.continuous
protected theorem differentiable (f : 𝓢(E, F)) : Differentiable ℝ f :=
(f.smooth 1).differentiable rfl.le
#align schwartz_map.differentiable SchwartzMap.differentiable
protected theorem differentiableAt (f : 𝓢(E, F)) {x : E} : DifferentiableAt ℝ f x :=
f.differentiable.differentiableAt
#align schwartz_map.differentiable_at SchwartzMap.differentiableAt
@[ext]
theorem ext {f g : 𝓢(E, F)} (h : ∀ x, (f : E → F) x = g x) : f = g :=
DFunLike.ext f g h
#align schwartz_map.ext SchwartzMap.ext
section TemperateGrowth
def _root_.Function.HasTemperateGrowth (f : E → F) : Prop :=
ContDiff ℝ ⊤ f ∧ ∀ n : ℕ, ∃ (k : ℕ) (C : ℝ), ∀ x, ‖iteratedFDeriv ℝ n f x‖ ≤ C * (1 + ‖x‖) ^ k
#align function.has_temperate_growth Function.HasTemperateGrowth
| Mathlib/Analysis/Distribution/SchwartzSpace.lean | 613 | 629 | theorem _root_.Function.HasTemperateGrowth.norm_iteratedFDeriv_le_uniform_aux {f : E → F}
(hf_temperate : f.HasTemperateGrowth) (n : ℕ) :
∃ (k : ℕ) (C : ℝ), 0 ≤ C ∧ ∀ N ≤ n, ∀ x : E, ‖iteratedFDeriv ℝ N f x‖ ≤ C * (1 + ‖x‖) ^ k := by |
choose k C f using hf_temperate.2
use (Finset.range (n + 1)).sup k
let C' := max (0 : ℝ) ((Finset.range (n + 1)).sup' (by simp) C)
have hC' : 0 ≤ C' := by simp only [C', le_refl, Finset.le_sup'_iff, true_or_iff, le_max_iff]
use C', hC'
intro N hN x
rw [← Finset.mem_range_succ_iff] at hN
refine le_trans (f N x) (mul_le_mul ?_ ?_ (by positivity) hC')
· simp only [C', Finset.le_sup'_iff, le_max_iff]
right
exact ⟨N, hN, rfl.le⟩
gcongr
· simp
exact Finset.le_sup hN
| 14 |
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
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
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : ℂ) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : ℝ => (x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, ← intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel_right, neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, ← sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : ℂ} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
· rwa [sub_re, one_re, ← sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : ℂ) {a : ℝ} (ha : 0 < a) :
∫ x in (0)..a, (x : ℂ) ^ (s - 1) * ((a : ℂ) - x) ^ (t - 1) =
(a : ℂ) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : ℂ) ≠ 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : ℂ) ^ (s + t - 1) = a * ((a : ℂ) ^ (s - 1) * (a : ℂ) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, ← intervalIntegral.integral_const_mul, ← real_smul, ← zero_div a, ←
div_self ha.ne', ← intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine setIntegral_congr measurableSet_Ioc fun x hx => ?_
rw [mul_mul_mul_comm]
congr 1
· rw [← mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel₀ _ ha']
· rw [(by norm_cast : (1 : ℂ) - ↑(x / a) = ↑(1 - x / a)), ←
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel₀ _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
| Mathlib/Analysis/SpecialFunctions/Gamma/Beta.lean | 136 | 151 | theorem Gamma_mul_Gamma_eq_betaIntegral {s t : ℂ} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by |
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul ℝ ℂ)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, ← conv_int, ← integral_mul_right (betaIntegral _ _)]
refine setIntegral_congr measurableSet_Ioi fun x hx => ?_
rw [mul_assoc, ← betaIntegral_scaled s t hx, ← intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
rw [← Complex.exp_add]; congr 1; abel
| 14 |
import Mathlib.Analysis.Complex.AbsMax
import Mathlib.Analysis.Complex.RemovableSingularity
#align_import analysis.complex.schwarz from "leanprover-community/mathlib"@"3f655f5297b030a87d641ad4e825af8d9679eb0b"
open Metric Set Function Filter TopologicalSpace
open scoped Topology
namespace Complex
section Space
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {R R₁ R₂ : ℝ} {f : ℂ → E}
{c z z₀ : ℂ}
theorem schwarz_aux {f : ℂ → ℂ} (hd : DifferentiableOn ℂ f (ball c R₁))
(h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)) (hz : z ∈ ball c R₁) :
‖dslope f c z‖ ≤ R₂ / R₁ := by
have hR₁ : 0 < R₁ := nonempty_ball.1 ⟨z, hz⟩
suffices ∀ᶠ r in 𝓝[<] R₁, ‖dslope f c z‖ ≤ R₂ / r by
refine ge_of_tendsto ?_ this
exact (tendsto_const_nhds.div tendsto_id hR₁.ne').mono_left nhdsWithin_le_nhds
rw [mem_ball] at hz
filter_upwards [Ioo_mem_nhdsWithin_Iio ⟨hz, le_rfl⟩] with r hr
have hr₀ : 0 < r := dist_nonneg.trans_lt hr.1
replace hd : DiffContOnCl ℂ (dslope f c) (ball c r) := by
refine DifferentiableOn.diffContOnCl ?_
rw [closure_ball c hr₀.ne']
exact ((differentiableOn_dslope <| ball_mem_nhds _ hR₁).mpr hd).mono
(closedBall_subset_ball hr.2)
refine norm_le_of_forall_mem_frontier_norm_le isBounded_ball hd ?_ ?_
· rw [frontier_ball c hr₀.ne']
intro z hz
have hz' : z ≠ c := ne_of_mem_sphere hz hr₀.ne'
rw [dslope_of_ne _ hz', slope_def_module, norm_smul, norm_inv, mem_sphere_iff_norm.1 hz, ←
div_eq_inv_mul, div_le_div_right hr₀, ← dist_eq_norm]
exact le_of_lt (h_maps (mem_ball.2 (by rw [mem_sphere.1 hz]; exact hr.2)))
· rw [closure_ball c hr₀.ne', mem_closedBall]
exact hr.1.le
#align complex.schwarz_aux Complex.schwarz_aux
| Mathlib/Analysis/Complex/Schwarz.lean | 92 | 108 | theorem norm_dslope_le_div_of_mapsTo_ball (hd : DifferentiableOn ℂ f (ball c R₁))
(h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)) (hz : z ∈ ball c R₁) :
‖dslope f c z‖ ≤ R₂ / R₁ := by |
have hR₁ : 0 < R₁ := nonempty_ball.1 ⟨z, hz⟩
have hR₂ : 0 < R₂ := nonempty_ball.1 ⟨f z, h_maps hz⟩
rcases eq_or_ne (dslope f c z) 0 with hc | hc
· rw [hc, norm_zero]; exact div_nonneg hR₂.le hR₁.le
rcases exists_dual_vector ℂ _ hc with ⟨g, hg, hgf⟩
have hg' : ‖g‖₊ = 1 := NNReal.eq hg
have hg₀ : ‖g‖₊ ≠ 0 := by simpa only [hg'] using one_ne_zero
calc
‖dslope f c z‖ = ‖dslope (g ∘ f) c z‖ := by
rw [g.dslope_comp, hgf, RCLike.norm_ofReal, abs_norm]
exact fun _ => hd.differentiableAt (ball_mem_nhds _ hR₁)
_ ≤ R₂ / R₁ := by
refine schwarz_aux (g.differentiable.comp_differentiableOn hd) (MapsTo.comp ?_ h_maps) hz
simpa only [hg', NNReal.coe_one, one_mul] using g.lipschitz.mapsTo_ball hg₀ (f c) R₂
| 14 |
import Mathlib.CategoryTheory.Adjunction.Opposites
import Mathlib.CategoryTheory.Comma.Presheaf
import Mathlib.CategoryTheory.Elements
import Mathlib.CategoryTheory.Limits.ConeCategory
import Mathlib.CategoryTheory.Limits.Final
import Mathlib.CategoryTheory.Limits.KanExtension
import Mathlib.CategoryTheory.Limits.Over
#align_import category_theory.limits.presheaf from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
namespace CategoryTheory
open Category Limits
universe v₁ v₂ u₁ u₂
section SmallCategory
variable {C : Type u₁} [SmallCategory C]
variable {ℰ : Type u₂} [Category.{u₁} ℰ]
variable (A : C ⥤ ℰ)
section ArbitraryUniverses
variable {C : Type u₁} [Category.{v₁} C] (P : Cᵒᵖ ⥤ Type v₁)
@[simps]
def tautologicalCocone : Cocone (CostructuredArrow.proj yoneda P ⋙ yoneda) where
pt := P
ι := { app := fun X => X.hom }
def isColimitTautologicalCocone : IsColimit (tautologicalCocone P) where
desc := fun s => by
refine ⟨fun X t => yonedaEquiv (s.ι.app (CostructuredArrow.mk (yonedaEquiv.symm t))), ?_⟩
intros X Y f
ext t
dsimp
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [yonedaEquiv_naturality', yonedaEquiv_symm_map]
simpa using (s.ι.naturality
(CostructuredArrow.homMk' (CostructuredArrow.mk (yonedaEquiv.symm t)) f.unop)).symm
fac := by
intro s t
dsimp
apply yonedaEquiv.injective
rw [yonedaEquiv_comp]
dsimp only
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [Equiv.symm_apply_apply]
rfl
uniq := by
intro s j h
ext V x
obtain ⟨t, rfl⟩ := yonedaEquiv.surjective x
dsimp
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [Equiv.symm_apply_apply, ← yonedaEquiv_comp]
exact congr_arg _ (h (CostructuredArrow.mk t))
variable {I : Type v₁} [SmallCategory I] (F : I ⥤ C)
| Mathlib/CategoryTheory/Limits/Presheaf.lean | 486 | 503 | theorem final_toCostructuredArrow_comp_pre {c : Cocone (F ⋙ yoneda)} (hc : IsColimit c) :
Functor.Final (c.toCostructuredArrow ⋙ CostructuredArrow.pre F yoneda c.pt) := by |
apply Functor.cofinal_of_isTerminal_colimit_comp_yoneda
suffices IsTerminal (colimit ((c.toCostructuredArrow ⋙ CostructuredArrow.pre F yoneda c.pt) ⋙
CostructuredArrow.toOver yoneda c.pt)) by
apply IsTerminal.isTerminalOfObj (overEquivPresheafCostructuredArrow c.pt).inverse
apply IsTerminal.ofIso this
refine ?_ ≪≫ (preservesColimitIso (overEquivPresheafCostructuredArrow c.pt).inverse _).symm
apply HasColimit.isoOfNatIso
exact isoWhiskerLeft _
(CostructuredArrow.toOverCompOverEquivPresheafCostructuredArrow c.pt).isoCompInverse
apply IsTerminal.ofIso Over.mkIdTerminal
let isc : IsColimit ((Over.forget _).mapCocone _) := PreservesColimit.preserves
(colimit.isColimit ((c.toCostructuredArrow ⋙ CostructuredArrow.pre F yoneda c.pt) ⋙
CostructuredArrow.toOver yoneda c.pt))
exact Over.isoMk (hc.coconePointUniqueUpToIso isc) (hc.hom_ext fun i => by simp)
| 14 |
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]
| Mathlib/Data/Nat/Factorization/Basic.lean | 67 | 81 | 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
| 14 |
import Mathlib.Algebra.Polynomial.Eval
import Mathlib.LinearAlgebra.Dimension.Constructions
#align_import algebra.linear_recurrence from "leanprover-community/mathlib"@"039a089d2a4b93c761b234f3e5f5aeb752bac60f"
noncomputable section
open Finset
open Polynomial
structure LinearRecurrence (α : Type*) [CommSemiring α] where
order : ℕ
coeffs : Fin order → α
#align linear_recurrence LinearRecurrence
instance (α : Type*) [CommSemiring α] : Inhabited (LinearRecurrence α) :=
⟨⟨0, default⟩⟩
namespace LinearRecurrence
section CommSemiring
variable {α : Type*} [CommSemiring α] (E : LinearRecurrence α)
def IsSolution (u : ℕ → α) :=
∀ n, u (n + E.order) = ∑ i, E.coeffs i * u (n + i)
#align linear_recurrence.is_solution LinearRecurrence.IsSolution
def mkSol (init : Fin E.order → α) : ℕ → α
| n =>
if h : n < E.order then init ⟨n, h⟩
else
∑ k : Fin E.order,
have _ : n - E.order + k < n := by
rw [add_comm, ← add_tsub_assoc_of_le (not_lt.mp h), tsub_lt_iff_left]
· exact add_lt_add_right k.is_lt n
· convert add_le_add (zero_le (k : ℕ)) (not_lt.mp h)
simp only [zero_add]
E.coeffs k * mkSol init (n - E.order + k)
#align linear_recurrence.mk_sol LinearRecurrence.mkSol
theorem is_sol_mkSol (init : Fin E.order → α) : E.IsSolution (E.mkSol init) := by
intro n
rw [mkSol]
simp
#align linear_recurrence.is_sol_mk_sol LinearRecurrence.is_sol_mkSol
theorem mkSol_eq_init (init : Fin E.order → α) : ∀ n : Fin E.order, E.mkSol init n = init n := by
intro n
rw [mkSol]
simp only [n.is_lt, dif_pos, Fin.mk_val, Fin.eta]
#align linear_recurrence.mk_sol_eq_init LinearRecurrence.mkSol_eq_init
| Mathlib/Algebra/LinearRecurrence.lean | 100 | 115 | theorem eq_mk_of_is_sol_of_eq_init {u : ℕ → α} {init : Fin E.order → α} (h : E.IsSolution u)
(heq : ∀ n : Fin E.order, u n = init n) : ∀ n, u n = E.mkSol init n := by |
intro n
rw [mkSol]
split_ifs with h'
· exact mod_cast heq ⟨n, h'⟩
simp only
rw [← tsub_add_cancel_of_le (le_of_not_lt h'), h (n - E.order)]
congr with k
have : n - E.order + k < n := by
rw [add_comm, ← add_tsub_assoc_of_le (not_lt.mp h'), tsub_lt_iff_left]
· exact add_lt_add_right k.is_lt n
· convert add_le_add (zero_le (k : ℕ)) (not_lt.mp h')
simp only [zero_add]
rw [eq_mk_of_is_sol_of_eq_init h heq (n - E.order + k)]
simp
| 14 |
import Mathlib.Algebra.Polynomial.UnitTrinomial
import Mathlib.RingTheory.Polynomial.GaussLemma
import Mathlib.Tactic.LinearCombination
#align_import ring_theory.polynomial.selmer from "leanprover-community/mathlib"@"3e00d81bdcbf77c8188bbd18f5524ddc3ed8cac6"
namespace Polynomial
open scoped Polynomial
variable {n : ℕ}
| Mathlib/RingTheory/Polynomial/Selmer.lean | 31 | 45 | theorem X_pow_sub_X_sub_one_irreducible_aux (z : ℂ) : ¬(z ^ n = z + 1 ∧ z ^ n + z ^ 2 = 0) := by |
rintro ⟨h1, h2⟩
replace h3 : z ^ 3 = 1 := by
linear_combination (1 - z - z ^ 2 - z ^ n) * h1 + (z ^ n - 2) * h2
have key : z ^ n = 1 ∨ z ^ n = z ∨ z ^ n = z ^ 2 := by
rw [← Nat.mod_add_div n 3, pow_add, pow_mul, h3, one_pow, mul_one]
have : n % 3 < 3 := Nat.mod_lt n zero_lt_three
interval_cases n % 3 <;>
simp only [this, pow_zero, pow_one, eq_self_iff_true, or_true_iff, true_or_iff]
have z_ne_zero : z ≠ 0 := fun h =>
zero_ne_one ((zero_pow three_ne_zero).symm.trans (show (0 : ℂ) ^ 3 = 1 from h ▸ h3))
rcases key with (key | key | key)
· exact z_ne_zero (by rwa [key, self_eq_add_left] at h1)
· exact one_ne_zero (by rwa [key, self_eq_add_right] at h1)
· exact z_ne_zero (pow_eq_zero (by rwa [key, add_self_eq_zero] at h2))
| 14 |
import Mathlib.Data.Fintype.Card
import Mathlib.GroupTheory.Perm.Basic
import Mathlib.Tactic.Ring
#align_import data.fintype.perm from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
open Function
open Nat
universe u v
variable {α β γ : Type*}
open Finset Function List Equiv Equiv.Perm
variable [DecidableEq α] [DecidableEq β]
def permsOfList : List α → List (Perm α)
| [] => [1]
| a :: l => permsOfList l ++ l.bind fun b => (permsOfList l).map fun f => Equiv.swap a b * f
#align perms_of_list permsOfList
theorem length_permsOfList : ∀ l : List α, length (permsOfList l) = l.length !
| [] => rfl
| a :: l => by
rw [length_cons, Nat.factorial_succ]
simp only [permsOfList, length_append, length_permsOfList, length_bind, comp,
length_map, map_const', sum_replicate, smul_eq_mul, succ_mul]
ring
#align length_perms_of_list length_permsOfList
theorem mem_permsOfList_of_mem {l : List α} {f : Perm α} (h : ∀ x, f x ≠ x → x ∈ l) :
f ∈ permsOfList l := by
induction l generalizing f with
| nil =>
-- Porting note: applied `not_mem_nil` because it is no longer true definitionally.
simp only [not_mem_nil] at h
exact List.mem_singleton.2 (Equiv.ext fun x => Decidable.by_contradiction <| h x)
| cons a l IH =>
by_cases hfa : f a = a
· refine mem_append_left _ (IH fun x hx => mem_of_ne_of_mem ?_ (h x hx))
rintro rfl
exact hx hfa
have hfa' : f (f a) ≠ f a := mt (fun h => f.injective h) hfa
have : ∀ x : α, (Equiv.swap a (f a) * f) x ≠ x → x ∈ l := by
intro x hx
have hxa : x ≠ a := by
rintro rfl
apply hx
simp only [mul_apply, swap_apply_right]
refine List.mem_of_ne_of_mem hxa (h x fun h => ?_)
simp only [mul_apply, swap_apply_def, mul_apply, Ne, apply_eq_iff_eq] at hx
split_ifs at hx with h_1
exacts [hxa (h.symm.trans h_1), hx h]
suffices f ∈ permsOfList l ∨ ∃ b ∈ l, ∃ g ∈ permsOfList l, Equiv.swap a b * g = f by
simpa only [permsOfList, exists_prop, List.mem_map, mem_append, List.mem_bind]
refine or_iff_not_imp_left.2 fun _hfl => ⟨f a, ?_, Equiv.swap a (f a) * f, IH this, ?_⟩
· exact mem_of_ne_of_mem hfa (h _ hfa')
· rw [← mul_assoc, mul_def (swap a (f a)) (swap a (f a)), swap_swap, ← Perm.one_def, one_mul]
#align mem_perms_of_list_of_mem mem_permsOfList_of_mem
| Mathlib/Data/Fintype/Perm.lean | 77 | 94 | theorem mem_of_mem_permsOfList :
-- Porting note: was `∀ {x}` but need to capture the `x`
∀ {l : List α} {f : Perm α}, f ∈ permsOfList l → (x :α ) → f x ≠ x → x ∈ l
| [], f, h, heq_iff_eq => by
have : f = 1 := by | simpa [permsOfList] using h
rw [this]; simp
| a :: l, f, h, x =>
(mem_append.1 h).elim (fun h hx => mem_cons_of_mem _ (mem_of_mem_permsOfList h x hx))
fun h hx =>
let ⟨y, hy, hy'⟩ := List.mem_bind.1 h
let ⟨g, hg₁, hg₂⟩ := List.mem_map.1 hy'
-- Porting note: Seems like the implicit variable `x` of type `α` is needed.
if hxa : x = a then by simp [hxa]
else
if hxy : x = y then mem_cons_of_mem _ <| by rwa [hxy]
else mem_cons_of_mem a <| mem_of_mem_permsOfList hg₁ _ <| by
rw [eq_inv_mul_iff_mul_eq.2 hg₂, mul_apply, swap_inv, swap_apply_def]
split_ifs <;> [exact Ne.symm hxy; exact Ne.symm hxa; exact hx]
| 14 |
import Mathlib.FieldTheory.SplittingField.Construction
import Mathlib.RingTheory.Int.Basic
import Mathlib.RingTheory.Localization.Integral
import Mathlib.RingTheory.IntegrallyClosed
#align_import ring_theory.polynomial.gauss_lemma from "leanprover-community/mathlib"@"e3f4be1fcb5376c4948d7f095bec45350bfb9d1a"
open scoped nonZeroDivisors Polynomial
variable {R : Type*} [CommRing R]
section IsIntegrallyClosed
open Polynomial
open integralClosure
open IsIntegrallyClosed
variable (K : Type*) [Field K] [Algebra R K]
| Mathlib/RingTheory/Polynomial/GaussLemma.lean | 54 | 70 | theorem integralClosure.mem_lifts_of_monic_of_dvd_map {f : R[X]} (hf : f.Monic) {g : K[X]}
(hg : g.Monic) (hd : g ∣ f.map (algebraMap R K)) :
g ∈ lifts (algebraMap (integralClosure R K) K) := by |
have := mem_lift_of_splits_of_roots_mem_range (integralClosure R g.SplittingField)
((splits_id_iff_splits _).2 <| SplittingField.splits g) (hg.map _) fun a ha =>
(SetLike.ext_iff.mp (integralClosure R g.SplittingField).range_algebraMap _).mpr <|
roots_mem_integralClosure hf ?_
· rw [lifts_iff_coeff_lifts, ← RingHom.coe_range, Subalgebra.range_algebraMap] at this
refine (lifts_iff_coeff_lifts _).2 fun n => ?_
rw [← RingHom.coe_range, Subalgebra.range_algebraMap]
obtain ⟨p, hp, he⟩ := SetLike.mem_coe.mp (this n); use p, hp
rw [IsScalarTower.algebraMap_eq R K, coeff_map, ← eval₂_map, eval₂_at_apply] at he
rw [eval₂_eq_eval_map]; apply (injective_iff_map_eq_zero _).1 _ _ he
apply RingHom.injective
rw [aroots_def, IsScalarTower.algebraMap_eq R K _, ← map_map]
refine Multiset.mem_of_le (roots.le_of_dvd ((hf.map _).map _).ne_zero ?_) ha
exact map_dvd (algebraMap K g.SplittingField) hd
| 14 |
import Mathlib.MeasureTheory.Constructions.BorelSpace.Metric
import Mathlib.Topology.Metrizable.Basic
import Mathlib.Topology.IndicatorConstPointwise
#align_import measure_theory.constructions.borel_space.metrizable from "leanprover-community/mathlib"@"bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf"
open Filter MeasureTheory TopologicalSpace
open scoped Classical
open Topology NNReal ENNReal MeasureTheory
variable {α β : Type*} [MeasurableSpace α]
section Limits
variable [TopologicalSpace β] [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β]
open Metric
| Mathlib/MeasureTheory/Constructions/BorelSpace/Metrizable.lean | 31 | 47 | theorem measurable_of_tendsto_metrizable' {ι} {f : ι → α → β} {g : α → β} (u : Filter ι) [NeBot u]
[IsCountablyGenerated u] (hf : ∀ i, Measurable (f i)) (lim : Tendsto f u (𝓝 g)) :
Measurable g := by |
letI : PseudoMetricSpace β := pseudoMetrizableSpacePseudoMetric β
apply measurable_of_isClosed'
intro s h1s h2s h3s
have : Measurable fun x => infNndist (g x) s := by
suffices Tendsto (fun i x => infNndist (f i x) s) u (𝓝 fun x => infNndist (g x) s) from
NNReal.measurable_of_tendsto' u (fun i => (hf i).infNndist) this
rw [tendsto_pi_nhds] at lim ⊢
intro x
exact ((continuous_infNndist_pt s).tendsto (g x)).comp (lim x)
have h4s : g ⁻¹' s = (fun x => infNndist (g x) s) ⁻¹' {0} := by
ext x
simp [h1s, ← h1s.mem_iff_infDist_zero h2s, ← NNReal.coe_eq_zero]
rw [h4s]
exact this (measurableSet_singleton 0)
| 14 |
import Mathlib.LinearAlgebra.Quotient
import Mathlib.LinearAlgebra.Prod
#align_import linear_algebra.projection from "leanprover-community/mathlib"@"6d584f1709bedbed9175bd9350df46599bdd7213"
noncomputable section Ring
variable {R : Type*} [Ring R] {E : Type*} [AddCommGroup E] [Module R E]
variable {F : Type*} [AddCommGroup F] [Module R F] {G : Type*} [AddCommGroup G] [Module R G]
variable (p q : Submodule R E)
variable {S : Type*} [Semiring S] {M : Type*} [AddCommMonoid M] [Module S M] (m : Submodule S M)
namespace LinearMap
open Submodule
structure IsProj {F : Type*} [FunLike F M M] (f : F) : Prop where
map_mem : ∀ x, f x ∈ m
map_id : ∀ x ∈ m, f x = x
#align linear_map.is_proj LinearMap.IsProj
| Mathlib/LinearAlgebra/Projection.lean | 396 | 410 | theorem isProj_iff_idempotent (f : M →ₗ[S] M) : (∃ p : Submodule S M, IsProj p f) ↔ f ∘ₗ f = f := by |
constructor
· intro h
obtain ⟨p, hp⟩ := h
ext x
rw [comp_apply]
exact hp.map_id (f x) (hp.map_mem x)
· intro h
use range f
constructor
· intro x
exact mem_range_self f x
· intro x hx
obtain ⟨y, hy⟩ := mem_range.1 hx
rw [← hy, ← comp_apply, h]
| 14 |
import Mathlib.Analysis.NormedSpace.Star.ContinuousFunctionalCalculus.Restrict
import Mathlib.Analysis.NormedSpace.Star.ContinuousFunctionalCalculus
import Mathlib.Analysis.NormedSpace.Star.Spectrum
import Mathlib.Analysis.NormedSpace.Star.Unitization
import Mathlib.Topology.ContinuousFunction.UniqueCFC
noncomputable section
local notation "σₙ" => quasispectrum
local notation "σ" => spectrum
section RCLike
variable {𝕜 A : Type*} [RCLike 𝕜] [NonUnitalNormedRing A] [StarRing A] [CstarRing A]
variable [CompleteSpace A] [NormedSpace 𝕜 A] [IsScalarTower 𝕜 A A] [SMulCommClass 𝕜 A A]
variable [StarModule 𝕜 A] {p : A → Prop} {p₁ : Unitization 𝕜 A → Prop}
local postfix:max "⁺¹" => Unitization 𝕜
variable (hp₁ : ∀ {x : A}, p₁ x ↔ p x) (a : A) (ha : p a)
variable [ContinuousFunctionalCalculus 𝕜 p₁]
open scoped ContinuousMapZero
open Unitization in
noncomputable def cfcₙAux : C(σₙ 𝕜 a, 𝕜)₀ →⋆ₙₐ[𝕜] A⁺¹ :=
(cfcHom (R := 𝕜) (hp₁.mpr ha) : C(σ 𝕜 (a : A⁺¹), 𝕜) →⋆ₙₐ[𝕜] A⁺¹) |>.comp
(Homeomorph.compStarAlgEquiv' 𝕜 𝕜 <| .setCongr <| (quasispectrum_eq_spectrum_inr' 𝕜 𝕜 a).symm)
|>.comp ContinuousMapZero.toContinuousMapHom
lemma cfcₙAux_id : cfcₙAux hp₁ a ha (ContinuousMapZero.id rfl) = a := cfcHom_id (hp₁.mpr ha)
open Unitization in
lemma closedEmbedding_cfcₙAux : ClosedEmbedding (cfcₙAux hp₁ a ha) := by
simp only [cfcₙAux, NonUnitalStarAlgHom.coe_comp]
refine ((cfcHom_closedEmbedding (hp₁.mpr ha)).comp ?_).comp
ContinuousMapZero.closedEmbedding_toContinuousMap
let e : C(σₙ 𝕜 a, 𝕜) ≃ₜ C(σ 𝕜 (a : A⁺¹), 𝕜) :=
{ (Homeomorph.compStarAlgEquiv' 𝕜 𝕜 <| .setCongr <|
(quasispectrum_eq_spectrum_inr' 𝕜 𝕜 a).symm) with
continuous_toFun := ContinuousMap.continuous_comp_left _
continuous_invFun := ContinuousMap.continuous_comp_left _ }
exact e.closedEmbedding
lemma spec_cfcₙAux (f : C(σₙ 𝕜 a, 𝕜)₀) : σ 𝕜 (cfcₙAux hp₁ a ha f) = Set.range f := by
rw [cfcₙAux, NonUnitalStarAlgHom.comp_assoc, NonUnitalStarAlgHom.comp_apply]
simp only [NonUnitalStarAlgHom.comp_apply, NonUnitalStarAlgHom.coe_coe]
rw [cfcHom_map_spectrum (hp₁.mpr ha) (R := 𝕜) _]
ext x
constructor
all_goals rintro ⟨x, rfl⟩
· exact ⟨⟨x, (Unitization.quasispectrum_eq_spectrum_inr' 𝕜 𝕜 a).symm ▸ x.property⟩, rfl⟩
· exact ⟨⟨x, Unitization.quasispectrum_eq_spectrum_inr' 𝕜 𝕜 a ▸ x.property⟩, rfl⟩
lemma cfcₙAux_mem_range_inr (f : C(σₙ 𝕜 a, 𝕜)₀) :
cfcₙAux hp₁ a ha f ∈ NonUnitalStarAlgHom.range (Unitization.inrNonUnitalStarAlgHom 𝕜 A) := by
have h₁ := (closedEmbedding_cfcₙAux hp₁ a ha).continuous.range_subset_closure_image_dense
(ContinuousMapZero.adjoin_id_dense (s := σₙ 𝕜 a) rfl) ⟨f, rfl⟩
rw [← SetLike.mem_coe]
refine closure_minimal ?_ ?_ h₁
· rw [← NonUnitalStarSubalgebra.coe_map, SetLike.coe_subset_coe, NonUnitalStarSubalgebra.map_le]
apply NonUnitalStarAlgebra.adjoin_le
apply Set.singleton_subset_iff.mpr
rw [SetLike.mem_coe, NonUnitalStarSubalgebra.mem_comap, cfcₙAux_id hp₁ a ha]
exact ⟨a, rfl⟩
· have : Continuous (Unitization.fst (R := 𝕜) (A := A)) :=
Unitization.uniformEquivProd.continuous.fst
simp only [NonUnitalStarAlgHom.coe_range]
convert IsClosed.preimage this (isClosed_singleton (x := 0))
aesop
open Unitization NonUnitalStarAlgHom in
| Mathlib/Analysis/NormedSpace/Star/ContinuousFunctionalCalculus/Instances.lean | 120 | 136 | theorem RCLike.nonUnitalContinuousFunctionalCalculus :
NonUnitalContinuousFunctionalCalculus 𝕜 (p : A → Prop) where
exists_cfc_of_predicate a ha := by |
let ψ : C(σₙ 𝕜 a, 𝕜)₀ →⋆ₙₐ[𝕜] A := comp (inrRangeEquiv 𝕜 A).symm <|
codRestrict (cfcₙAux hp₁ a ha) _ (cfcₙAux_mem_range_inr hp₁ a ha)
have coe_ψ (f : C(σₙ 𝕜 a, 𝕜)₀) : ψ f = cfcₙAux hp₁ a ha f :=
congr_arg Subtype.val <| (inrRangeEquiv 𝕜 A).apply_symm_apply
⟨cfcₙAux hp₁ a ha f, cfcₙAux_mem_range_inr hp₁ a ha f⟩
refine ⟨ψ, ?closedEmbedding, ?map_id, fun f ↦ ?map_spec, fun f ↦ ?isStarNormal⟩
case closedEmbedding =>
apply isometry_inr (𝕜 := 𝕜) (A := A) |>.closedEmbedding |>.of_comp_iff.mp
have : inr ∘ ψ = cfcₙAux hp₁ a ha := by ext1; rw [Function.comp_apply, coe_ψ]
exact this ▸ closedEmbedding_cfcₙAux hp₁ a ha
case map_id => exact inr_injective (R := 𝕜) <| coe_ψ _ ▸ cfcₙAux_id hp₁ a ha
case map_spec =>
exact quasispectrum_eq_spectrum_inr' 𝕜 𝕜 (ψ f) ▸ coe_ψ _ ▸ spec_cfcₙAux hp₁ a ha f
case isStarNormal => exact hp₁.mp <| coe_ψ _ ▸ cfcHom_predicate (R := 𝕜) (hp₁.mpr ha) _
| 14 |
import Mathlib.NumberTheory.SmoothNumbers
import Mathlib.Analysis.PSeries
open Set Nat
open scoped Topology
-- This needs `Mathlib.Analysis.RCLike.Basic`, so we put it here
-- instead of in `Mathlib.NumberTheory.SmoothNumbers`.
lemma Nat.roughNumbersUpTo_card_le' (N k : ℕ) :
(roughNumbersUpTo N k).card ≤
N * (N.succ.primesBelow \ k.primesBelow).sum (fun p ↦ (1 : ℝ) / p) := by
simp_rw [Finset.mul_sum, mul_one_div]
exact (Nat.cast_le.mpr <| roughNumbersUpTo_card_le N k).trans <|
(cast_sum (β := ℝ) ..) ▸ Finset.sum_le_sum fun n _ ↦ cast_div_le
lemma one_half_le_sum_primes_ge_one_div (k : ℕ) :
1 / 2 ≤ ∑ p ∈ (4 ^ (k.primesBelow.card + 1)).succ.primesBelow \ k.primesBelow,
(1 / p : ℝ) := by
set m : ℕ := 2 ^ k.primesBelow.card
set N₀ : ℕ := 2 * m ^ 2 with hN₀
let S : ℝ := ((2 * N₀).succ.primesBelow \ k.primesBelow).sum (fun p ↦ (1 / p : ℝ))
suffices 1 / 2 ≤ S by
convert this using 5
rw [show 4 = 2 ^ 2 by norm_num, pow_right_comm]
ring
suffices 2 * N₀ ≤ m * (2 * N₀).sqrt + 2 * N₀ * S by
rwa [hN₀, ← mul_assoc, ← pow_two 2, ← mul_pow, sqrt_eq', ← sub_le_iff_le_add',
cast_mul, cast_mul, cast_pow, cast_two,
show (2 * (2 * m ^ 2) - m * (2 * m) : ℝ) = 2 * (2 * m ^ 2) * (1 / 2) by ring,
_root_.mul_le_mul_left <| by positivity] at this
calc (2 * N₀ : ℝ)
_ = ((2 * N₀).smoothNumbersUpTo k).card + ((2 * N₀).roughNumbersUpTo k).card := by
exact_mod_cast ((2 * N₀).smoothNumbersUpTo_card_add_roughNumbersUpTo_card k).symm
_ ≤ m * (2 * N₀).sqrt + ((2 * N₀).roughNumbersUpTo k).card := by
exact_mod_cast Nat.add_le_add_right ((2 * N₀).smoothNumbersUpTo_card_le k) _
_ ≤ m * (2 * N₀).sqrt + 2 * N₀ * S := add_le_add_left ?_ _
exact_mod_cast roughNumbersUpTo_card_le' (2 * N₀) k
| Mathlib/NumberTheory/SumPrimeReciprocals.lean | 64 | 79 | theorem not_summable_one_div_on_primes :
¬ Summable (indicator {p | p.Prime} (fun n : ℕ ↦ (1 : ℝ) / n)) := by |
intro h
obtain ⟨k, hk⟩ := h.nat_tsum_vanishing (Iio_mem_nhds one_half_pos : Iio (1 / 2 : ℝ) ∈ 𝓝 0)
specialize hk ({p | Nat.Prime p} ∩ {p | k ≤ p}) inter_subset_right
rw [tsum_subtype, indicator_indicator, inter_eq_left.mpr fun n hn ↦ hn.1, mem_Iio] at hk
have h' : Summable (indicator ({p | Nat.Prime p} ∩ {p | k ≤ p}) fun n ↦ (1 : ℝ) / n) := by
convert h.indicator {n : ℕ | k ≤ n} using 1
simp only [indicator_indicator, inter_comm]
refine ((one_half_le_sum_primes_ge_one_div k).trans_lt <| LE.le.trans_lt ?_ hk).false
convert sum_le_tsum (primesBelow ((4 ^ (k.primesBelow.card + 1)).succ) \ primesBelow k)
(fun n _ ↦ indicator_nonneg (fun p _ ↦ by positivity) _) h' using 2 with p hp
obtain ⟨hp₁, hp₂⟩ := mem_setOf_eq ▸ Finset.mem_sdiff.mp hp
have hpp := prime_of_mem_primesBelow hp₁
refine (indicator_of_mem (mem_def.mpr ⟨hpp, ?_⟩) fun n : ℕ ↦ (1 / n : ℝ)).symm
exact not_lt.mp <| (not_and_or.mp <| (not_congr mem_primesBelow).mp hp₂).neg_resolve_right hpp
| 14 |
import Mathlib.Algebra.CharP.Defs
import Mathlib.Data.Nat.Prime
import Mathlib.ModelTheory.Algebra.Ring.FreeCommRing
import Mathlib.ModelTheory.Algebra.Field.Basic
variable {p : ℕ} {K : Type*}
namespace FirstOrder
namespace Field
open Language Ring
noncomputable def eqZero (n : ℕ) : Language.ring.Sentence :=
Term.equal (termOfFreeCommRing n) 0
@[simp] theorem realize_eqZero [CommRing K] [CompatibleRing K] (n : ℕ)
(v : Empty → K) : (Formula.Realize (eqZero n) v) ↔ ((n : K) = 0) := by
simp [eqZero, Term.realize]
def _root_.FirstOrder.Language.Theory.fieldOfChar (p : ℕ) : Language.ring.Theory :=
Theory.field ∪
if p = 0
then (fun q => ∼(eqZero q)) '' {q : ℕ | q.Prime}
else if p.Prime then {eqZero p}
else {⊥}
instance model_hasChar_of_charP [Field K] [CompatibleRing K] [CharP K p] :
(Theory.fieldOfChar p).Model K := by
refine Language.Theory.model_union_iff.2 ⟨inferInstance, ?_⟩
cases CharP.char_is_prime_or_zero K p with
| inl hp =>
simp [hp.ne_zero, hp, Sentence.Realize]
| inr hp =>
subst hp
simp only [ite_false, ite_true, Theory.model_iff, Set.mem_image, Set.mem_setOf_eq,
Sentence.Realize, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂,
Formula.realize_not, realize_eqZero, ← CharZero.charZero_iff_forall_prime_ne_zero]
exact CharP.charP_to_charZero K
| Mathlib/ModelTheory/Algebra/Field/CharP.lean | 63 | 78 | theorem charP_iff_model_fieldOfChar [Field K] [CompatibleRing K] :
(Theory.fieldOfChar p).Model K ↔ CharP K p := by |
simp only [Theory.fieldOfChar, Theory.model_union_iff,
(show (Theory.field.Model K) by infer_instance), true_and]
split_ifs with hp0 hp
· subst hp0
simp only [Theory.model_iff, Set.mem_image, Set.mem_setOf_eq, Sentence.Realize,
forall_exists_index, and_imp, forall_apply_eq_imp_iff₂, Formula.realize_not,
realize_eqZero, ← CharZero.charZero_iff_forall_prime_ne_zero]
exact ⟨fun _ => CharP.ofCharZero _, fun _ => CharP.charP_to_charZero K⟩
· simp only [Theory.model_iff, Set.mem_singleton_iff, Sentence.Realize, forall_eq,
realize_eqZero, ← CharP.charP_iff_prime_eq_zero hp]
· simp only [Theory.model_iff, Set.mem_singleton_iff, Sentence.Realize,
forall_eq, Formula.realize_bot, false_iff]
intro H
cases (CharP.char_is_prime_or_zero K p) <;> simp_all
| 14 |
import Mathlib.Order.Interval.Set.Disjoint
import Mathlib.Order.SuccPred.Basic
#align_import data.set.intervals.monotone from "leanprover-community/mathlib"@"4d06b17aea8cf2e220f0b0aa46cd0231593c5c97"
open Set
section SuccOrder
open Order
variable {α β : Type*} [PartialOrder α]
| Mathlib/Order/Interval/Set/Monotone.lean | 203 | 218 | theorem StrictMonoOn.Iic_id_le [SuccOrder α] [IsSuccArchimedean α] [OrderBot α] {n : α} {φ : α → α}
(hφ : StrictMonoOn φ (Set.Iic n)) : ∀ m ≤ n, m ≤ φ m := by |
revert hφ
refine
Succ.rec_bot (fun n => StrictMonoOn φ (Set.Iic n) → ∀ m ≤ n, m ≤ φ m)
(fun _ _ hm => hm.trans bot_le) ?_ _
rintro k ih hφ m hm
by_cases hk : IsMax k
· rw [succ_eq_iff_isMax.2 hk] at hm
exact ih (hφ.mono <| Iic_subset_Iic.2 (le_succ _)) _ hm
obtain rfl | h := le_succ_iff_eq_or_le.1 hm
· specialize ih (StrictMonoOn.mono hφ fun x hx => le_trans hx (le_succ _)) k le_rfl
refine le_trans (succ_mono ih) (succ_le_of_lt (hφ (le_succ _) le_rfl ?_))
rw [lt_succ_iff_eq_or_lt_of_not_isMax hk]
exact Or.inl rfl
· exact ih (StrictMonoOn.mono hφ fun x hx => le_trans hx (le_succ _)) _ h
| 14 |
import Mathlib.Algebra.Order.Monoid.Canonical.Defs
import Mathlib.Data.List.Infix
import Mathlib.Data.List.MinMax
import Mathlib.Data.List.EditDistance.Defs
set_option autoImplicit true
variable {C : Levenshtein.Cost α β δ} [CanonicallyLinearOrderedAddCommMonoid δ]
theorem suffixLevenshtein_minimum_le_levenshtein_cons (xs : List α) (y ys) :
(suffixLevenshtein C xs ys).1.minimum ≤ levenshtein C xs (y :: ys) := by
induction xs with
| nil =>
simp only [suffixLevenshtein_nil', levenshtein_nil_cons,
List.minimum_singleton, WithTop.coe_le_coe]
exact le_add_of_nonneg_left (by simp)
| cons x xs ih =>
suffices
(suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.delete x + levenshtein C xs (y :: ys)) ∧
(suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.insert y + levenshtein C (x :: xs) ys) ∧
(suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.substitute x y + levenshtein C xs ys) by
simpa [suffixLevenshtein_eq_tails_map]
refine ⟨?_, ?_, ?_⟩
· calc
_ ≤ (suffixLevenshtein C xs ys).1.minimum := by
simp [suffixLevenshtein_cons₁_fst, List.minimum_cons]
_ ≤ ↑(levenshtein C xs (y :: ys)) := ih
_ ≤ _ := by simp
· calc
(suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C (x :: xs) ys) := by
simp [suffixLevenshtein_cons₁_fst, List.minimum_cons]
_ ≤ _ := by simp
· calc
(suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C xs ys) := by
simp only [suffixLevenshtein_cons₁_fst, List.minimum_cons]
apply min_le_of_right_le
cases xs
· simp [suffixLevenshtein_nil']
· simp [suffixLevenshtein_cons₁, List.minimum_cons]
_ ≤ _ := by simp
| Mathlib/Data/List/EditDistance/Bounds.lean | 58 | 73 | theorem le_suffixLevenshtein_cons_minimum (xs : List α) (y ys) :
(suffixLevenshtein C xs ys).1.minimum ≤ (suffixLevenshtein C xs (y :: ys)).1.minimum := by |
apply List.le_minimum_of_forall_le
simp only [suffixLevenshtein_eq_tails_map]
simp only [List.mem_map, List.mem_tails, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂]
intro a suff
refine (?_ : _ ≤ _).trans (suffixLevenshtein_minimum_le_levenshtein_cons _ _ _)
simp only [suffixLevenshtein_eq_tails_map]
apply List.le_minimum_of_forall_le
intro b m
replace m : ∃ a_1, a_1 <:+ a ∧ levenshtein C a_1 ys = b := by simpa using m
obtain ⟨a', suff', rfl⟩ := m
apply List.minimum_le_of_mem'
simp only [List.mem_map, List.mem_tails]
suffices ∃ a, a <:+ xs ∧ levenshtein C a ys = levenshtein C a' ys by simpa
exact ⟨a', suff'.trans suff, rfl⟩
| 14 |
import Mathlib.Data.Nat.Cast.WithTop
import Mathlib.FieldTheory.IsAlgClosed.Basic
import Mathlib.RingTheory.WittVector.DiscreteValuationRing
#align_import ring_theory.witt_vector.frobenius_fraction_field from "leanprover-community/mathlib"@"cead93130da7100f8a9fe22ee210f7636a91168f"
noncomputable section
namespace WittVector
variable (p : ℕ) [hp : Fact p.Prime]
local notation "𝕎" => WittVector p
namespace RecursionMain
section CommRing
variable {k : Type*} [CommRing k] [CharP k p]
open Polynomial
def succNthDefiningPoly (n : ℕ) (a₁ a₂ : 𝕎 k) (bs : Fin (n + 1) → k) : Polynomial k :=
X ^ p * C (a₁.coeff 0 ^ p ^ (n + 1)) - X * C (a₂.coeff 0 ^ p ^ (n + 1)) +
C
(a₁.coeff (n + 1) * (bs 0 ^ p) ^ p ^ (n + 1) +
nthRemainder p n (fun v => bs v ^ p) (truncateFun (n + 1) a₁) -
a₂.coeff (n + 1) * bs 0 ^ p ^ (n + 1) -
nthRemainder p n bs (truncateFun (n + 1) a₂))
#align witt_vector.recursion_main.succ_nth_defining_poly WittVector.RecursionMain.succNthDefiningPoly
| Mathlib/RingTheory/WittVector/FrobeniusFractionField.lean | 79 | 95 | theorem succNthDefiningPoly_degree [IsDomain k] (n : ℕ) (a₁ a₂ : 𝕎 k) (bs : Fin (n + 1) → k)
(ha₁ : a₁.coeff 0 ≠ 0) (ha₂ : a₂.coeff 0 ≠ 0) :
(succNthDefiningPoly p n a₁ a₂ bs).degree = p := by |
have : (X ^ p * C (a₁.coeff 0 ^ p ^ (n + 1))).degree = (p : WithBot ℕ) := by
rw [degree_mul, degree_C]
· simp only [Nat.cast_withBot, add_zero, degree_X, degree_pow, Nat.smul_one_eq_cast]
· exact pow_ne_zero _ ha₁
have : (X ^ p * C (a₁.coeff 0 ^ p ^ (n + 1)) - X * C (a₂.coeff 0 ^ p ^ (n + 1))).degree =
(p : WithBot ℕ) := by
rw [degree_sub_eq_left_of_degree_lt, this]
rw [this, degree_mul, degree_C, degree_X, add_zero]
· exact mod_cast hp.out.one_lt
· exact pow_ne_zero _ ha₂
rw [succNthDefiningPoly, degree_add_eq_left_of_degree_lt, this]
apply lt_of_le_of_lt degree_C_le
rw [this]
exact mod_cast hp.out.pos
| 14 |
import Mathlib.Algebra.Polynomial.Derivative
import Mathlib.Algebra.Polynomial.Roots
import Mathlib.RingTheory.EuclideanDomain
#align_import data.polynomial.field_division from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821"
noncomputable section
open Polynomial
namespace Polynomial
universe u v w y z
variable {R : Type u} {S : Type v} {k : Type y} {A : Type z} {a b : R} {n : ℕ}
section CommRing
variable [CommRing R]
theorem rootMultiplicity_sub_one_le_derivative_rootMultiplicity_of_ne_zero
(p : R[X]) (t : R) (hnezero : derivative p ≠ 0) :
p.rootMultiplicity t - 1 ≤ p.derivative.rootMultiplicity t :=
(le_rootMultiplicity_iff hnezero).2 <|
pow_sub_one_dvd_derivative_of_pow_dvd (p.pow_rootMultiplicity_dvd t)
| Mathlib/Algebra/Polynomial/FieldDivision.lean | 40 | 57 | theorem derivative_rootMultiplicity_of_root_of_mem_nonZeroDivisors
{p : R[X]} {t : R} (hpt : Polynomial.IsRoot p t)
(hnzd : (p.rootMultiplicity t : R) ∈ nonZeroDivisors R) :
(derivative p).rootMultiplicity t = p.rootMultiplicity t - 1 := by |
by_cases h : p = 0
· simp only [h, map_zero, rootMultiplicity_zero]
obtain ⟨g, hp, hndvd⟩ := p.exists_eq_pow_rootMultiplicity_mul_and_not_dvd h t
set m := p.rootMultiplicity t
have hm : m - 1 + 1 = m := Nat.sub_add_cancel <| (rootMultiplicity_pos h).2 hpt
have hndvd : ¬(X - C t) ^ m ∣ derivative p := by
rw [hp, derivative_mul, dvd_add_left (dvd_mul_right _ _),
derivative_X_sub_C_pow, ← hm, pow_succ, hm, mul_comm (C _), mul_assoc,
dvd_cancel_left_mem_nonZeroDivisors (monic_X_sub_C t |>.pow _ |>.mem_nonZeroDivisors)]
rw [dvd_iff_isRoot, IsRoot] at hndvd ⊢
rwa [eval_mul, eval_C, mul_left_mem_nonZeroDivisors_eq_zero_iff hnzd]
have hnezero : derivative p ≠ 0 := fun h ↦ hndvd (by rw [h]; exact dvd_zero _)
exact le_antisymm (by rwa [rootMultiplicity_le_iff hnezero, hm])
(rootMultiplicity_sub_one_le_derivative_rootMultiplicity_of_ne_zero _ t hnezero)
| 14 |
import Mathlib.Geometry.Manifold.MFDeriv.FDeriv
noncomputable section
open scoped Manifold
open Bundle Set Topology
section SpecificFunctions
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {H : Type*} [TopologicalSpace H] (I : ModelWithCorners 𝕜 E H) {M : Type*}
[TopologicalSpace M] [ChartedSpace H M] [SmoothManifoldWithCorners I M] {E' : Type*}
[NormedAddCommGroup E'] [NormedSpace 𝕜 E'] {H' : Type*} [TopologicalSpace H']
(I' : ModelWithCorners 𝕜 E' H') {M' : Type*} [TopologicalSpace M'] [ChartedSpace H' M']
[SmoothManifoldWithCorners I' M'] {E'' : Type*} [NormedAddCommGroup E''] [NormedSpace 𝕜 E'']
{H'' : Type*} [TopologicalSpace H''] (I'' : ModelWithCorners 𝕜 E'' H'') {M'' : Type*}
[TopologicalSpace M''] [ChartedSpace H'' M''] [SmoothManifoldWithCorners I'' M'']
variable {s : Set M} {x : M}
section Prod
| Mathlib/Geometry/Manifold/MFDeriv/SpecificFunctions.lean | 228 | 244 | theorem hasMFDerivAt_fst (x : M × M') :
HasMFDerivAt (I.prod I') I Prod.fst x
(ContinuousLinearMap.fst 𝕜 (TangentSpace I x.1) (TangentSpace I' x.2)) := by |
refine ⟨continuous_fst.continuousAt, ?_⟩
have :
∀ᶠ y in 𝓝[range (I.prod I')] extChartAt (I.prod I') x x,
(extChartAt I x.1 ∘ Prod.fst ∘ (extChartAt (I.prod I') x).symm) y = y.1 := by
/- porting note: was
apply Filter.mem_of_superset (extChartAt_target_mem_nhdsWithin (I.prod I') x)
mfld_set_tac
-/
filter_upwards [extChartAt_target_mem_nhdsWithin (I.prod I') x] with y hy
rw [extChartAt_prod] at hy
exact (extChartAt I x.1).right_inv hy.1
apply HasFDerivWithinAt.congr_of_eventuallyEq hasFDerivWithinAt_fst this
-- Porting note: next line was `simp only [mfld_simps]`
exact (extChartAt I x.1).right_inv <| (extChartAt I x.1).map_source (mem_extChartAt_source _ _)
| 14 |
import Mathlib.MeasureTheory.Group.GeometryOfNumbers
import Mathlib.MeasureTheory.Measure.Lebesgue.VolumeOfBalls
import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic
#align_import number_theory.number_field.canonical_embedding from "leanprover-community/mathlib"@"60da01b41bbe4206f05d34fd70c8dd7498717a30"
variable (K : Type*) [Field K]
namespace NumberField.mixedEmbedding
open NumberField NumberField.InfinitePlace FiniteDimensional
local notation "E" K =>
({w : InfinitePlace K // IsReal w} → ℝ) × ({w : InfinitePlace K // IsComplex w} → ℂ)
section convexBodyLT'
open Metric ENNReal NNReal
open scoped Classical
variable (f : InfinitePlace K → ℝ≥0) (w₀ : {w : InfinitePlace K // IsComplex w})
abbrev convexBodyLT' : Set (E K) :=
(Set.univ.pi (fun w : { w : InfinitePlace K // IsReal w } ↦ ball 0 (f w))) ×ˢ
(Set.univ.pi (fun w : { w : InfinitePlace K // IsComplex w } ↦
if w = w₀ then {x | |x.re| < 1 ∧ |x.im| < (f w : ℝ) ^ 2} else ball 0 (f w)))
| Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean | 169 | 186 | theorem convexBodyLT'_mem {x : K} :
mixedEmbedding K x ∈ convexBodyLT' K f w₀ ↔
(∀ w : InfinitePlace K, w ≠ w₀ → w x < f w) ∧
|(w₀.val.embedding x).re| < 1 ∧ |(w₀.val.embedding x).im| < (f w₀: ℝ) ^ 2 := by |
simp_rw [mixedEmbedding, RingHom.prod_apply, Set.mem_prod, Set.mem_pi, Set.mem_univ,
forall_true_left, Pi.ringHom_apply, apply_ite, mem_ball_zero_iff, ← Complex.norm_real,
embedding_of_isReal_apply, norm_embedding_eq, Subtype.forall, Set.mem_setOf_eq]
refine ⟨fun ⟨h₁, h₂⟩ ↦ ⟨fun w h_ne ↦ ?_, ?_⟩, fun ⟨h₁, h₂⟩ ↦ ⟨fun w hw ↦ ?_, fun w hw ↦ ?_⟩⟩
· by_cases hw : IsReal w
· exact norm_embedding_eq w _ ▸ h₁ w hw
· specialize h₂ w (not_isReal_iff_isComplex.mp hw)
rwa [if_neg (by exact Subtype.coe_ne_coe.1 h_ne)] at h₂
· simpa [if_true] using h₂ w₀.val w₀.prop
· exact h₁ w (ne_of_isReal_isComplex hw w₀.prop)
· by_cases h_ne : w = w₀
· simpa [h_ne]
· rw [if_neg (by exact Subtype.coe_ne_coe.1 h_ne)]
exact h₁ w h_ne
| 14 |
import Mathlib.CategoryTheory.Limits.Preserves.Opposites
import Mathlib.Topology.Category.TopCat.Yoneda
import Mathlib.Condensed.Explicit
universe w w' v u
open CategoryTheory Opposite Limits regularTopology ContinuousMap
variable {C : Type u} [Category.{v} C] (G : C ⥤ TopCat.{w})
(X : Type w') [TopologicalSpace X]
| Mathlib/Condensed/TopComparison.lean | 40 | 58 | theorem factorsThrough_of_pullbackCondition {Z B : C} {π : Z ⟶ B} [HasPullback π π]
[PreservesLimit (cospan π π) G]
{a : C(G.obj Z, X)}
(ha : a ∘ (G.map pullback.fst) = a ∘ (G.map (pullback.snd (f := π) (g := π)))) :
Function.FactorsThrough a (G.map π) := by |
intro x y hxy
let xy : G.obj (pullback π π) := (PreservesPullback.iso G π π).inv <|
(TopCat.pullbackIsoProdSubtype (G.map π) (G.map π)).inv ⟨(x, y), hxy⟩
have ha' := congr_fun ha xy
dsimp at ha'
have h₁ : ∀ y, G.map pullback.fst ((PreservesPullback.iso G π π).inv y) =
pullback.fst (f := G.map π) (g := G.map π) y := by
simp only [← PreservesPullback.iso_inv_fst]; intro y; rfl
have h₂ : ∀ y, G.map pullback.snd ((PreservesPullback.iso G π π).inv y) =
pullback.snd (f := G.map π) (g := G.map π) y := by
simp only [← PreservesPullback.iso_inv_snd]; intro y; rfl
erw [h₁, h₂, TopCat.pullbackIsoProdSubtype_inv_fst_apply,
TopCat.pullbackIsoProdSubtype_inv_snd_apply] at ha'
simpa using ha'
| 14 |
import Mathlib.Tactic.CategoryTheory.Coherence
import Mathlib.CategoryTheory.Bicategory.Coherence
namespace CategoryTheory
namespace Bicategory
open Category
open scoped Bicategory
open Mathlib.Tactic.BicategoryCoherence (bicategoricalComp bicategoricalIsoComp)
universe w v u
variable {B : Type u} [Bicategory.{w, v} B] {a b c : B} {f : a ⟶ b} {g : b ⟶ a}
def leftZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) :=
η ▷ f ⊗≫ f ◁ ε
def rightZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) :=
g ◁ η ⊗≫ ε ▷ g
theorem rightZigzag_idempotent_of_left_triangle
(η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) (h : leftZigzag η ε = (λ_ _).hom ≫ (ρ_ _).inv) :
rightZigzag η ε ⊗≫ rightZigzag η ε = rightZigzag η ε := by
dsimp only [rightZigzag]
calc
_ = g ◁ η ⊗≫ ((ε ▷ g ▷ 𝟙 a) ≫ (𝟙 b ≫ g) ◁ η) ⊗≫ ε ▷ g := by
simp [bicategoricalComp]; coherence
_ = 𝟙 _ ⊗≫ g ◁ (η ▷ 𝟙 a ≫ (f ≫ g) ◁ η) ⊗≫ (ε ▷ (g ≫ f) ≫ 𝟙 b ◁ ε) ▷ g ⊗≫ 𝟙 _ := by
rw [← whisker_exchange]; simp [bicategoricalComp]; coherence
_ = g ◁ η ⊗≫ g ◁ leftZigzag η ε ▷ g ⊗≫ ε ▷ g := by
rw [← whisker_exchange, ← whisker_exchange]; simp [leftZigzag, bicategoricalComp]; coherence
_ = g ◁ η ⊗≫ ε ▷ g := by
rw [h]; simp [bicategoricalComp]; coherence
structure Adjunction (f : a ⟶ b) (g : b ⟶ a) where
unit : 𝟙 a ⟶ f ≫ g
counit : g ≫ f ⟶ 𝟙 b
left_triangle : leftZigzag unit counit = (λ_ _).hom ≫ (ρ_ _).inv := by aesop_cat
right_triangle : rightZigzag unit counit = (ρ_ _).hom ≫ (λ_ _).inv := by aesop_cat
@[inherit_doc] scoped infixr:15 " ⊣ " => Bicategory.Adjunction
namespace Adjunction
attribute [simp] left_triangle right_triangle
attribute [local simp] leftZigzag rightZigzag
def id (a : B) : 𝟙 a ⊣ 𝟙 a where
unit := (ρ_ _).inv
counit := (ρ_ _).hom
left_triangle := by dsimp; coherence
right_triangle := by dsimp; coherence
instance : Inhabited (Adjunction (𝟙 a) (𝟙 a)) :=
⟨id a⟩
noncomputable section
variable (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b)
def leftZigzagIso (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) :=
whiskerRightIso η f ≪⊗≫ whiskerLeftIso f ε
def rightZigzagIso (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) :=
whiskerLeftIso g η ≪⊗≫ whiskerRightIso ε g
attribute [local simp] leftZigzagIso rightZigzagIso leftZigzag rightZigzag
@[simp]
theorem leftZigzagIso_hom : (leftZigzagIso η ε).hom = leftZigzag η.hom ε.hom :=
rfl
@[simp]
theorem rightZigzagIso_hom : (rightZigzagIso η ε).hom = rightZigzag η.hom ε.hom :=
rfl
@[simp]
theorem leftZigzagIso_inv : (leftZigzagIso η ε).inv = rightZigzag ε.inv η.inv := by
simp [bicategoricalComp, bicategoricalIsoComp]
@[simp]
theorem rightZigzagIso_inv : (rightZigzagIso η ε).inv = leftZigzag ε.inv η.inv := by
simp [bicategoricalComp, bicategoricalIsoComp]
@[simp]
theorem leftZigzagIso_symm : (leftZigzagIso η ε).symm = rightZigzagIso ε.symm η.symm :=
Iso.ext (leftZigzagIso_inv η ε)
@[simp]
theorem rightZigzagIso_symm : (rightZigzagIso η ε).symm = leftZigzagIso ε.symm η.symm :=
Iso.ext (rightZigzagIso_inv η ε)
instance : IsIso (leftZigzag η.hom ε.hom) := inferInstanceAs <| IsIso (leftZigzagIso η ε).hom
instance : IsIso (rightZigzag η.hom ε.hom) := inferInstanceAs <| IsIso (rightZigzagIso η ε).hom
theorem right_triangle_of_left_triangle (h : leftZigzag η.hom ε.hom = (λ_ f).hom ≫ (ρ_ f).inv) :
rightZigzag η.hom ε.hom = (ρ_ g).hom ≫ (λ_ g).inv := by
rw [← cancel_epi (rightZigzag η.hom ε.hom ≫ (λ_ g).hom ≫ (ρ_ g).inv)]
calc
_ = rightZigzag η.hom ε.hom ⊗≫ rightZigzag η.hom ε.hom := by coherence
_ = rightZigzag η.hom ε.hom := rightZigzag_idempotent_of_left_triangle _ _ h
_ = _ := by simp
def adjointifyCounit (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) : g ≫ f ≅ 𝟙 b :=
whiskerLeftIso g ((ρ_ f).symm ≪≫ rightZigzagIso ε.symm η.symm ≪≫ λ_ f) ≪≫ ε
| Mathlib/CategoryTheory/Bicategory/Adjunction.lean | 232 | 247 | theorem adjointifyCounit_left_triangle (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) :
leftZigzagIso η (adjointifyCounit η ε) = λ_ f ≪≫ (ρ_ f).symm := by |
apply Iso.ext
dsimp [adjointifyCounit, bicategoricalIsoComp]
calc
_ = 𝟙 _ ⊗≫ (η.hom ▷ (f ≫ 𝟙 b) ≫ (f ≫ g) ◁ f ◁ ε.inv) ⊗≫
f ◁ g ◁ η.inv ▷ f ⊗≫ f ◁ ε.hom := by
simp [bicategoricalComp]; coherence
_ = 𝟙 _ ⊗≫ f ◁ ε.inv ⊗≫ (η.hom ▷ (f ≫ g) ≫ (f ≫ g) ◁ η.inv) ▷ f ⊗≫ f ◁ ε.hom := by
rw [← whisker_exchange η.hom (f ◁ ε.inv)]; simp [bicategoricalComp]; coherence
_ = 𝟙 _ ⊗≫ f ◁ ε.inv ⊗≫ (η.inv ≫ η.hom) ▷ f ⊗≫ f ◁ ε.hom := by
rw [← whisker_exchange η.hom η.inv]; coherence
_ = 𝟙 _ ⊗≫ f ◁ (ε.inv ≫ ε.hom) := by
rw [Iso.inv_hom_id]; simp [bicategoricalComp]
_ = _ := by
rw [Iso.inv_hom_id]; simp [bicategoricalComp]
| 14 |
import Mathlib.LinearAlgebra.Basis
import Mathlib.Algebra.Module.LocalizedModule
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Localization.Integer
#align_import ring_theory.localization.module from "leanprover-community/mathlib"@"2e59a6de168f95d16b16d217b808a36290398c0a"
open nonZeroDivisors
section Localization
variable {R : Type*} (Rₛ : Type*) [CommSemiring R] (S : Submonoid R)
section IsLocalizedModule
section AddCommMonoid
open Submodule
variable [CommSemiring Rₛ] [Algebra R Rₛ] [hT : IsLocalization S Rₛ]
variable {M M' : Type*} [AddCommMonoid M] [Module R M] [Module Rₛ M] [IsScalarTower R Rₛ M]
[AddCommMonoid M'] [Module R M'] [Module Rₛ M'] [IsScalarTower R Rₛ M'] (f : M →ₗ[R] M')
[IsLocalizedModule S f]
theorem span_eq_top_of_isLocalizedModule {v : Set M} (hv : span R v = ⊤) :
span Rₛ (f '' v) = ⊤ := top_unique fun x _ ↦ by
obtain ⟨⟨m, s⟩, h⟩ := IsLocalizedModule.surj S f x
rw [Submonoid.smul_def, ← algebraMap_smul Rₛ, ← Units.smul_isUnit (IsLocalization.map_units Rₛ s),
eq_comm, ← inv_smul_eq_iff] at h
refine h ▸ smul_mem _ _ (span_subset_span R Rₛ _ ?_)
rw [← LinearMap.coe_restrictScalars R, ← LinearMap.map_span, hv]
exact mem_map_of_mem mem_top
| Mathlib/RingTheory/Localization/Module.lean | 56 | 71 | theorem LinearIndependent.of_isLocalizedModule {ι : Type*} {v : ι → M}
(hv : LinearIndependent R v) : LinearIndependent Rₛ (f ∘ v) := by |
rw [linearIndependent_iff'] at hv ⊢
intro t g hg i hi
choose! a g' hg' using IsLocalization.exist_integer_multiples S t g
have h0 : f (∑ i ∈ t, g' i • v i) = 0 := by
apply_fun ((a : R) • ·) at hg
rw [smul_zero, Finset.smul_sum] at hg
rw [map_sum, ← hg]
refine Finset.sum_congr rfl fun i hi => ?_
rw [← smul_assoc, ← hg' i hi, map_smul, Function.comp_apply, algebraMap_smul]
obtain ⟨s, hs⟩ := (IsLocalizedModule.eq_zero_iff S f).mp h0
simp_rw [Finset.smul_sum, Submonoid.smul_def, smul_smul] at hs
specialize hv t _ hs i hi
rw [← (IsLocalization.map_units Rₛ a).mul_right_eq_zero, ← Algebra.smul_def, ← hg' i hi]
exact (IsLocalization.map_eq_zero_iff S _ _).2 ⟨s, hv⟩
| 14 |
import Mathlib.Data.Finset.Basic
import Mathlib.ModelTheory.Syntax
import Mathlib.Data.List.ProdSigma
#align_import model_theory.semantics from "leanprover-community/mathlib"@"d565b3df44619c1498326936be16f1a935df0728"
universe u v w u' v'
namespace FirstOrder
namespace Language
variable {L : Language.{u, v}} {L' : Language}
variable {M : Type w} {N P : Type*} [L.Structure M] [L.Structure N] [L.Structure P]
variable {α : Type u'} {β : Type v'} {γ : Type*}
open FirstOrder Cardinal
open Structure Cardinal Fin
namespace Term
-- Porting note: universes in different order
def realize (v : α → M) : ∀ _t : L.Term α, M
| var k => v k
| func f ts => funMap f fun i => (ts i).realize v
#align first_order.language.term.realize FirstOrder.Language.Term.realize
@[simp]
theorem realize_var (v : α → M) (k) : realize v (var k : L.Term α) = v k := rfl
@[simp]
theorem realize_func (v : α → M) {n} (f : L.Functions n) (ts) :
realize v (func f ts : L.Term α) = funMap f fun i => (ts i).realize v := rfl
@[simp]
theorem realize_relabel {t : L.Term α} {g : α → β} {v : β → M} :
(t.relabel g).realize v = t.realize (v ∘ g) := by
induction' t with _ n f ts ih
· rfl
· simp [ih]
#align first_order.language.term.realize_relabel FirstOrder.Language.Term.realize_relabel
@[simp]
theorem realize_liftAt {n n' m : ℕ} {t : L.Term (Sum α (Fin n))} {v : Sum α (Fin (n + n')) → M} :
(t.liftAt n' m).realize v =
t.realize (v ∘ Sum.map id fun i : Fin _ =>
if ↑i < m then Fin.castAdd n' i else Fin.addNat i n') :=
realize_relabel
#align first_order.language.term.realize_lift_at FirstOrder.Language.Term.realize_liftAt
@[simp]
theorem realize_constants {c : L.Constants} {v : α → M} : c.term.realize v = c :=
funMap_eq_coe_constants
#align first_order.language.term.realize_constants FirstOrder.Language.Term.realize_constants
@[simp]
theorem realize_functions_apply₁ {f : L.Functions 1} {t : L.Term α} {v : α → M} :
(f.apply₁ t).realize v = funMap f ![t.realize v] := by
rw [Functions.apply₁, Term.realize]
refine congr rfl (funext fun i => ?_)
simp only [Matrix.cons_val_fin_one]
#align first_order.language.term.realize_functions_apply₁ FirstOrder.Language.Term.realize_functions_apply₁
@[simp]
theorem realize_functions_apply₂ {f : L.Functions 2} {t₁ t₂ : L.Term α} {v : α → M} :
(f.apply₂ t₁ t₂).realize v = funMap f ![t₁.realize v, t₂.realize v] := by
rw [Functions.apply₂, Term.realize]
refine congr rfl (funext (Fin.cases ?_ ?_))
· simp only [Matrix.cons_val_zero]
· simp only [Matrix.cons_val_succ, Matrix.cons_val_fin_one, forall_const]
#align first_order.language.term.realize_functions_apply₂ FirstOrder.Language.Term.realize_functions_apply₂
theorem realize_con {A : Set M} {a : A} {v : α → M} : (L.con a).term.realize v = a :=
rfl
#align first_order.language.term.realize_con FirstOrder.Language.Term.realize_con
@[simp]
theorem realize_subst {t : L.Term α} {tf : α → L.Term β} {v : β → M} :
(t.subst tf).realize v = t.realize fun a => (tf a).realize v := by
induction' t with _ _ _ _ ih
· rfl
· simp [ih]
#align first_order.language.term.realize_subst FirstOrder.Language.Term.realize_subst
@[simp]
theorem realize_restrictVar [DecidableEq α] {t : L.Term α} {s : Set α} (h : ↑t.varFinset ⊆ s)
{v : α → M} : (t.restrictVar (Set.inclusion h)).realize (v ∘ (↑)) = t.realize v := by
induction' t with _ _ _ _ ih
· rfl
· simp_rw [varFinset, Finset.coe_biUnion, Set.iUnion_subset_iff] at h
exact congr rfl (funext fun i => ih i (h i (Finset.mem_univ i)))
#align first_order.language.term.realize_restrict_var FirstOrder.Language.Term.realize_restrictVar
@[simp]
theorem realize_restrictVarLeft [DecidableEq α] {γ : Type*} {t : L.Term (Sum α γ)} {s : Set α}
(h : ↑t.varFinsetLeft ⊆ s) {v : α → M} {xs : γ → M} :
(t.restrictVarLeft (Set.inclusion h)).realize (Sum.elim (v ∘ (↑)) xs) =
t.realize (Sum.elim v xs) := by
induction' t with a _ _ _ ih
· cases a <;> rfl
· simp_rw [varFinsetLeft, Finset.coe_biUnion, Set.iUnion_subset_iff] at h
exact congr rfl (funext fun i => ih i (h i (Finset.mem_univ i)))
#align first_order.language.term.realize_restrict_var_left FirstOrder.Language.Term.realize_restrictVarLeft
@[simp]
| Mathlib/ModelTheory/Semantics.lean | 158 | 174 | theorem realize_constantsToVars [L[[α]].Structure M] [(lhomWithConstants L α).IsExpansionOn M]
{t : L[[α]].Term β} {v : β → M} :
t.constantsToVars.realize (Sum.elim (fun a => ↑(L.con a)) v) = t.realize v := by |
induction' t with _ n f ts ih
· simp
· cases n
· cases f
· simp only [realize, ih, Nat.zero_eq, constantsOn, mk₂_Functions]
-- Porting note: below lemma does not work with simp for some reason
rw [withConstants_funMap_sum_inl]
· simp only [realize, constantsToVars, Sum.elim_inl, funMap_eq_coe_constants]
rfl
· cases' f with _ f
· simp only [realize, ih, constantsOn, mk₂_Functions]
-- Porting note: below lemma does not work with simp for some reason
rw [withConstants_funMap_sum_inl]
· exact isEmptyElim f
| 14 |
import Mathlib.Algebra.MvPolynomial.PDeriv
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Derivative
import Mathlib.Data.Nat.Choose.Sum
import Mathlib.LinearAlgebra.LinearIndependent
import Mathlib.RingTheory.Polynomial.Pochhammer
#align_import ring_theory.polynomial.bernstein from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821"
noncomputable section
open Nat (choose)
open Polynomial (X)
open scoped Polynomial
variable (R : Type*) [CommRing R]
def bernsteinPolynomial (n ν : ℕ) : R[X] :=
(choose n ν : R[X]) * X ^ ν * (1 - X) ^ (n - ν)
#align bernstein_polynomial bernsteinPolynomial
example : bernsteinPolynomial ℤ 3 2 = 3 * X ^ 2 - 3 * X ^ 3 := by
norm_num [bernsteinPolynomial, choose]
ring
namespace bernsteinPolynomial
theorem eq_zero_of_lt {n ν : ℕ} (h : n < ν) : bernsteinPolynomial R n ν = 0 := by
simp [bernsteinPolynomial, Nat.choose_eq_zero_of_lt h]
#align bernstein_polynomial.eq_zero_of_lt bernsteinPolynomial.eq_zero_of_lt
section
variable {R} {S : Type*} [CommRing S]
@[simp]
theorem map (f : R →+* S) (n ν : ℕ) :
(bernsteinPolynomial R n ν).map f = bernsteinPolynomial S n ν := by simp [bernsteinPolynomial]
#align bernstein_polynomial.map bernsteinPolynomial.map
end
theorem flip (n ν : ℕ) (h : ν ≤ n) :
(bernsteinPolynomial R n ν).comp (1 - X) = bernsteinPolynomial R n (n - ν) := by
simp [bernsteinPolynomial, h, tsub_tsub_assoc, mul_right_comm]
#align bernstein_polynomial.flip bernsteinPolynomial.flip
theorem flip' (n ν : ℕ) (h : ν ≤ n) :
bernsteinPolynomial R n ν = (bernsteinPolynomial R n (n - ν)).comp (1 - X) := by
simp [← flip _ _ _ h, Polynomial.comp_assoc]
#align bernstein_polynomial.flip' bernsteinPolynomial.flip'
theorem eval_at_0 (n ν : ℕ) : (bernsteinPolynomial R n ν).eval 0 = if ν = 0 then 1 else 0 := by
rw [bernsteinPolynomial]
split_ifs with h
· subst h; simp
· simp [zero_pow h]
#align bernstein_polynomial.eval_at_0 bernsteinPolynomial.eval_at_0
theorem eval_at_1 (n ν : ℕ) : (bernsteinPolynomial R n ν).eval 1 = if ν = n then 1 else 0 := by
rw [bernsteinPolynomial]
split_ifs with h
· subst h; simp
· obtain hνn | hnν := Ne.lt_or_lt h
· simp [zero_pow $ Nat.sub_ne_zero_of_lt hνn]
· simp [Nat.choose_eq_zero_of_lt hnν]
#align bernstein_polynomial.eval_at_1 bernsteinPolynomial.eval_at_1
theorem derivative_succ_aux (n ν : ℕ) :
Polynomial.derivative (bernsteinPolynomial R (n + 1) (ν + 1)) =
(n + 1) * (bernsteinPolynomial R n ν - bernsteinPolynomial R n (ν + 1)) := by
rw [bernsteinPolynomial]
suffices ((n + 1).choose (ν + 1) : R[X]) * ((↑(ν + 1 : ℕ) : R[X]) * X ^ ν) * (1 - X) ^ (n - ν) -
((n + 1).choose (ν + 1) : R[X]) * X ^ (ν + 1) * ((↑(n - ν) : R[X]) * (1 - X) ^ (n - ν - 1)) =
(↑(n + 1) : R[X]) * ((n.choose ν : R[X]) * X ^ ν * (1 - X) ^ (n - ν) -
(n.choose (ν + 1) : R[X]) * X ^ (ν + 1) * (1 - X) ^ (n - (ν + 1))) by
simpa [Polynomial.derivative_pow, ← sub_eq_add_neg, Nat.succ_sub_succ_eq_sub,
Polynomial.derivative_mul, Polynomial.derivative_natCast, zero_mul,
Nat.cast_add, algebraMap.coe_one, Polynomial.derivative_X, mul_one, zero_add,
Polynomial.derivative_sub, Polynomial.derivative_one, zero_sub, mul_neg, Nat.sub_zero,
bernsteinPolynomial, map_add, map_natCast, Nat.cast_one]
conv_rhs => rw [mul_sub]
-- We'll prove the two terms match up separately.
refine congr (congr_arg Sub.sub ?_) ?_
· simp only [← mul_assoc]
apply congr (congr_arg (· * ·) (congr (congr_arg (· * ·) _) rfl)) rfl
-- Now it's just about binomial coefficients
exact mod_cast congr_arg (fun m : ℕ => (m : R[X])) (Nat.succ_mul_choose_eq n ν).symm
· rw [← tsub_add_eq_tsub_tsub, ← mul_assoc, ← mul_assoc]; congr 1
rw [mul_comm, ← mul_assoc, ← mul_assoc]; congr 1
norm_cast
congr 1
convert (Nat.choose_mul_succ_eq n (ν + 1)).symm using 1
· -- Porting note: was
-- convert mul_comm _ _ using 2
-- simp
rw [mul_comm, Nat.succ_sub_succ_eq_sub]
· apply mul_comm
#align bernstein_polynomial.derivative_succ_aux bernsteinPolynomial.derivative_succ_aux
theorem derivative_succ (n ν : ℕ) : Polynomial.derivative (bernsteinPolynomial R n (ν + 1)) =
n * (bernsteinPolynomial R (n - 1) ν - bernsteinPolynomial R (n - 1) (ν + 1)) := by
cases n
· simp [bernsteinPolynomial]
· rw [Nat.cast_succ]; apply derivative_succ_aux
#align bernstein_polynomial.derivative_succ bernsteinPolynomial.derivative_succ
theorem derivative_zero (n : ℕ) :
Polynomial.derivative (bernsteinPolynomial R n 0) = -n * bernsteinPolynomial R (n - 1) 0 := by
simp [bernsteinPolynomial, Polynomial.derivative_pow]
#align bernstein_polynomial.derivative_zero bernsteinPolynomial.derivative_zero
| Mathlib/RingTheory/Polynomial/Bernstein.lean | 146 | 161 | theorem iterate_derivative_at_0_eq_zero_of_lt (n : ℕ) {ν k : ℕ} :
k < ν → (Polynomial.derivative^[k] (bernsteinPolynomial R n ν)).eval 0 = 0 := by |
cases' ν with ν
· rintro ⟨⟩
· rw [Nat.lt_succ_iff]
induction' k with k ih generalizing n ν
· simp [eval_at_0]
· simp only [derivative_succ, Int.natCast_eq_zero, mul_eq_zero, Function.comp_apply,
Function.iterate_succ, Polynomial.iterate_derivative_sub,
Polynomial.iterate_derivative_natCast_mul, Polynomial.eval_mul, Polynomial.eval_natCast,
Polynomial.eval_sub]
intro h
apply mul_eq_zero_of_right
rw [ih _ _ (Nat.le_of_succ_le h), sub_zero]
convert ih _ _ (Nat.pred_le_pred h)
exact (Nat.succ_pred_eq_of_pos (k.succ_pos.trans_le h)).symm
| 14 |
import Mathlib.Data.Nat.Prime
import Mathlib.Tactic.NormNum.Basic
#align_import data.nat.prime_norm_num from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1"
open Nat Qq Lean Meta
namespace Mathlib.Meta.NormNum
theorem not_prime_mul_of_ble (a b n : ℕ) (h : a * b = n) (h₁ : a.ble 1 = false)
(h₂ : b.ble 1 = false) : ¬ n.Prime :=
not_prime_mul' h (ble_eq_false.mp h₁).ne' (ble_eq_false.mp h₂).ne'
def deriveNotPrime (n d : ℕ) (en : Q(ℕ)) : Q(¬ Nat.Prime $en) := Id.run <| do
let d' : ℕ := n / d
let prf : Q($d * $d' = $en) := (q(Eq.refl $en) : Expr)
let r : Q(Nat.ble $d 1 = false) := (q(Eq.refl false) : Expr)
let r' : Q(Nat.ble $d' 1 = false) := (q(Eq.refl false) : Expr)
return q(not_prime_mul_of_ble _ _ _ $prf $r $r')
def MinFacHelper (n k : ℕ) : Prop :=
2 < k ∧ k % 2 = 1 ∧ k ≤ minFac n
theorem MinFacHelper.one_lt {n k : ℕ} (h : MinFacHelper n k) : 1 < n := by
have : 2 < minFac n := h.1.trans_le h.2.2
obtain rfl | h := n.eq_zero_or_pos
· contradiction
rcases (succ_le_of_lt h).eq_or_lt with rfl|h
· simp_all
exact h
theorem minFacHelper_0 (n : ℕ)
(h1 : Nat.ble (nat_lit 2) n = true) (h2 : nat_lit 1 = n % (nat_lit 2)) :
MinFacHelper n (nat_lit 3) := by
refine ⟨by norm_num, by norm_num, ?_⟩
refine (le_minFac'.mpr λ p hp hpn ↦ ?_).resolve_left (Nat.ne_of_gt (Nat.le_of_ble_eq_true h1))
rcases hp.eq_or_lt with rfl|h
· simp [(Nat.dvd_iff_mod_eq_zero ..).1 hpn] at h2
· exact h
| Mathlib/Tactic/NormNum/Prime.lean | 67 | 82 | theorem minFacHelper_1 {n k k' : ℕ} (e : k + 2 = k') (h : MinFacHelper n k)
(np : minFac n ≠ k) : MinFacHelper n k' := by |
rw [← e]
refine ⟨Nat.lt_add_right _ h.1, ?_, ?_⟩
· rw [add_mod, mod_self, add_zero, mod_mod]
exact h.2.1
rcases h.2.2.eq_or_lt with rfl|h2
· exact (np rfl).elim
rcases (succ_le_of_lt h2).eq_or_lt with h2|h2
· refine ((h.1.trans_le h.2.2).ne ?_).elim
have h3 : 2 ∣ minFac n := by
rw [Nat.dvd_iff_mod_eq_zero, ← h2, succ_eq_add_one, add_mod, h.2.1]
rw [dvd_prime <| minFac_prime h.one_lt.ne'] at h3
norm_num at h3
exact h3
exact h2
| 14 |
import Mathlib.AlgebraicGeometry.GammaSpecAdjunction
import Mathlib.AlgebraicGeometry.Restrict
import Mathlib.CategoryTheory.Limits.Opposites
import Mathlib.RingTheory.Localization.InvSubmonoid
#align_import algebraic_geometry.AffineScheme from "leanprover-community/mathlib"@"88474d1b5af6d37c2ab728b757771bced7f5194c"
-- Explicit universe annotations were used in this file to improve perfomance #12737
set_option linter.uppercaseLean3 false
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe u
namespace AlgebraicGeometry
open Spec (structureSheaf)
-- Porting note(#5171): linter not ported yet
-- @[nolint has_nonempty_instance]
def AffineScheme :=
Scheme.Spec.EssImageSubcategory
deriving Category
#align algebraic_geometry.AffineScheme AlgebraicGeometry.AffineScheme
class IsAffine (X : Scheme) : Prop where
affine : IsIso (ΓSpec.adjunction.unit.app X)
#align algebraic_geometry.is_affine AlgebraicGeometry.IsAffine
attribute [instance] IsAffine.affine
def Scheme.isoSpec (X : Scheme) [IsAffine X] : X ≅ Scheme.Spec.obj (op <| Scheme.Γ.obj <| op X) :=
asIso (ΓSpec.adjunction.unit.app X)
#align algebraic_geometry.Scheme.iso_Spec AlgebraicGeometry.Scheme.isoSpec
@[simps]
def AffineScheme.mk (X : Scheme) (_ : IsAffine X) : AffineScheme :=
⟨X, mem_essImage_of_unit_isIso (adj := ΓSpec.adjunction) _⟩
#align algebraic_geometry.AffineScheme.mk AlgebraicGeometry.AffineScheme.mk
def AffineScheme.of (X : Scheme) [h : IsAffine X] : AffineScheme :=
AffineScheme.mk X h
#align algebraic_geometry.AffineScheme.of AlgebraicGeometry.AffineScheme.of
def AffineScheme.ofHom {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) :
AffineScheme.of X ⟶ AffineScheme.of Y :=
f
#align algebraic_geometry.AffineScheme.of_hom AlgebraicGeometry.AffineScheme.ofHom
theorem mem_Spec_essImage (X : Scheme) : X ∈ Scheme.Spec.essImage ↔ IsAffine X :=
⟨fun h => ⟨Functor.essImage.unit_isIso h⟩,
fun _ => mem_essImage_of_unit_isIso (adj := ΓSpec.adjunction) _⟩
#align algebraic_geometry.mem_Spec_ess_image AlgebraicGeometry.mem_Spec_essImage
instance isAffineAffineScheme (X : AffineScheme.{u}) : IsAffine X.obj :=
⟨Functor.essImage.unit_isIso X.property⟩
#align algebraic_geometry.is_affine_AffineScheme AlgebraicGeometry.isAffineAffineScheme
instance SpecIsAffine (R : CommRingCatᵒᵖ) : IsAffine (Scheme.Spec.obj R) :=
AlgebraicGeometry.isAffineAffineScheme ⟨_, Scheme.Spec.obj_mem_essImage R⟩
#align algebraic_geometry.Spec_is_affine AlgebraicGeometry.SpecIsAffine
theorem isAffineOfIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] [h : IsAffine Y] : IsAffine X := by
rw [← mem_Spec_essImage] at h ⊢; exact Functor.essImage.ofIso (asIso f).symm h
#align algebraic_geometry.is_affine_of_iso AlgebraicGeometry.isAffineOfIso
def IsAffineOpen {X : Scheme} (U : Opens X) : Prop :=
IsAffine (X ∣_ᵤ U)
#align algebraic_geometry.is_affine_open AlgebraicGeometry.IsAffineOpen
def Scheme.affineOpens (X : Scheme) : Set (Opens X) :=
{U : Opens X | IsAffineOpen U}
#align algebraic_geometry.Scheme.affine_opens AlgebraicGeometry.Scheme.affineOpens
instance {Y : Scheme.{u}} (U : Y.affineOpens) :
IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) :=
U.property
theorem rangeIsAffineOpenOfOpenImmersion {X Y : Scheme} [IsAffine X] (f : X ⟶ Y)
[H : IsOpenImmersion f] : IsAffineOpen (Scheme.Hom.opensRange f) := by
refine isAffineOfIso (IsOpenImmersion.isoOfRangeEq f (Y.ofRestrict _) ?_).inv
exact Subtype.range_val.symm
#align algebraic_geometry.range_is_affine_open_of_open_immersion AlgebraicGeometry.rangeIsAffineOpenOfOpenImmersion
theorem topIsAffineOpen (X : Scheme) [IsAffine X] : IsAffineOpen (⊤ : Opens X) := by
convert rangeIsAffineOpenOfOpenImmersion (𝟙 X)
ext1
exact Set.range_id.symm
#align algebraic_geometry.top_is_affine_open AlgebraicGeometry.topIsAffineOpen
instance Scheme.affineCoverIsAffine (X : Scheme) (i : X.affineCover.J) :
IsAffine (X.affineCover.obj i) :=
AlgebraicGeometry.SpecIsAffine _
#align algebraic_geometry.Scheme.affine_cover_is_affine AlgebraicGeometry.Scheme.affineCoverIsAffine
instance Scheme.affineBasisCoverIsAffine (X : Scheme) (i : X.affineBasisCover.J) :
IsAffine (X.affineBasisCover.obj i) :=
AlgebraicGeometry.SpecIsAffine _
#align algebraic_geometry.Scheme.affine_basis_cover_is_affine AlgebraicGeometry.Scheme.affineBasisCoverIsAffine
theorem isBasis_affine_open (X : Scheme) : Opens.IsBasis X.affineOpens := by
rw [Opens.isBasis_iff_nbhd]
rintro U x (hU : x ∈ (U : Set X))
obtain ⟨S, hS, hxS, hSU⟩ := X.affineBasisCover_is_basis.exists_subset_of_mem_open hU U.isOpen
refine ⟨⟨S, X.affineBasisCover_is_basis.isOpen hS⟩, ?_, hxS, hSU⟩
rcases hS with ⟨i, rfl⟩
exact rangeIsAffineOpenOfOpenImmersion _
#align algebraic_geometry.is_basis_affine_open AlgebraicGeometry.isBasis_affine_open
| Mathlib/AlgebraicGeometry/AffineScheme.lean | 218 | 234 | theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine
(X : Scheme) [IsAffine X] (f : Scheme.Γ.obj (op X)) :
X.isoSpec.hom ⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f := by |
rw [← basicOpen_eq_of_affine]
trans
X.isoSpec.hom ⁻¹ᵁ (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))).basicOpen
((inv (X.isoSpec.hom.1.c.app (op ((Opens.map (inv X.isoSpec.hom).val.base).obj ⊤)))) f)
· congr
rw [← IsIso.inv_eq_inv, IsIso.inv_inv, IsIso.Iso.inv_inv, NatIso.app_hom]
-- Porting note: added this `change` to prevent timeout
change SpecΓIdentity.hom.app (X.presheaf.obj <| op ⊤) = _
rw [← ΓSpec.adjunction_unit_app_app_top X]
rfl
· dsimp
refine (Scheme.preimage_basicOpen _ _).trans ?_
congr 1
exact IsIso.inv_hom_id_apply _ _
| 14 |
import Mathlib.CategoryTheory.Limits.Shapes.Biproducts
import Mathlib.GroupTheory.EckmannHilton
import Mathlib.Tactic.CategoryTheory.Reassoc
#align_import category_theory.preadditive.of_biproducts from "leanprover-community/mathlib"@"061ea99a5610cfc72c286aa930d3c1f47f74f3d0"
noncomputable section
universe v u
open CategoryTheory
open CategoryTheory.Limits
namespace CategoryTheory.SemiadditiveOfBinaryBiproducts
variable {C : Type u} [Category.{v} C] [HasZeroMorphisms C] [HasBinaryBiproducts C]
section
variable (X Y : C)
@[simp]
def leftAdd (f g : X ⟶ Y) : X ⟶ Y :=
biprod.lift f g ≫ biprod.desc (𝟙 Y) (𝟙 Y)
#align category_theory.semiadditive_of_binary_biproducts.left_add CategoryTheory.SemiadditiveOfBinaryBiproducts.leftAdd
@[simp]
def rightAdd (f g : X ⟶ Y) : X ⟶ Y :=
biprod.lift (𝟙 X) (𝟙 X) ≫ biprod.desc f g
#align category_theory.semiadditive_of_binary_biproducts.right_add CategoryTheory.SemiadditiveOfBinaryBiproducts.rightAdd
local infixr:65 " +ₗ " => leftAdd X Y
local infixr:65 " +ᵣ " => rightAdd X Y
| Mathlib/CategoryTheory/Preadditive/OfBiproducts.lean | 54 | 68 | theorem isUnital_leftAdd : EckmannHilton.IsUnital (· +ₗ ·) 0 := by |
have hr : ∀ f : X ⟶ Y, biprod.lift (0 : X ⟶ Y) f = f ≫ biprod.inr := by
intro f
ext
· aesop_cat
· simp [biprod.lift_fst, Category.assoc, biprod.inr_fst, comp_zero]
have hl : ∀ f : X ⟶ Y, biprod.lift f (0 : X ⟶ Y) = f ≫ biprod.inl := by
intro f
ext
· aesop_cat
· simp [biprod.lift_snd, Category.assoc, biprod.inl_snd, comp_zero]
exact {
left_id := fun f => by simp [hr f, leftAdd, Category.assoc, Category.comp_id, biprod.inr_desc],
right_id := fun f => by simp [hl f, leftAdd, Category.assoc, Category.comp_id, biprod.inl_desc]
}
| 14 |
import Mathlib.Data.Set.Image
import Mathlib.Order.SuccPred.Relation
import Mathlib.Topology.Clopen
import Mathlib.Topology.Irreducible
#align_import topology.connected from "leanprover-community/mathlib"@"d101e93197bb5f6ea89bd7ba386b7f7dff1f3903"
open Set Function Topology TopologicalSpace Relation
open scoped Classical
universe u v
variable {α : Type u} {β : Type v} {ι : Type*} {π : ι → Type*} [TopologicalSpace α]
{s t u v : Set α}
section Preconnected
def IsPreconnected (s : Set α) : Prop :=
∀ u v : Set α, IsOpen u → IsOpen v → s ⊆ u ∪ v → (s ∩ u).Nonempty → (s ∩ v).Nonempty →
(s ∩ (u ∩ v)).Nonempty
#align is_preconnected IsPreconnected
def IsConnected (s : Set α) : Prop :=
s.Nonempty ∧ IsPreconnected s
#align is_connected IsConnected
theorem IsConnected.nonempty {s : Set α} (h : IsConnected s) : s.Nonempty :=
h.1
#align is_connected.nonempty IsConnected.nonempty
theorem IsConnected.isPreconnected {s : Set α} (h : IsConnected s) : IsPreconnected s :=
h.2
#align is_connected.is_preconnected IsConnected.isPreconnected
theorem IsPreirreducible.isPreconnected {s : Set α} (H : IsPreirreducible s) : IsPreconnected s :=
fun _ _ hu hv _ => H _ _ hu hv
#align is_preirreducible.is_preconnected IsPreirreducible.isPreconnected
theorem IsIrreducible.isConnected {s : Set α} (H : IsIrreducible s) : IsConnected s :=
⟨H.nonempty, H.isPreirreducible.isPreconnected⟩
#align is_irreducible.is_connected IsIrreducible.isConnected
theorem isPreconnected_empty : IsPreconnected (∅ : Set α) :=
isPreirreducible_empty.isPreconnected
#align is_preconnected_empty isPreconnected_empty
theorem isConnected_singleton {x} : IsConnected ({x} : Set α) :=
isIrreducible_singleton.isConnected
#align is_connected_singleton isConnected_singleton
theorem isPreconnected_singleton {x} : IsPreconnected ({x} : Set α) :=
isConnected_singleton.isPreconnected
#align is_preconnected_singleton isPreconnected_singleton
theorem Set.Subsingleton.isPreconnected {s : Set α} (hs : s.Subsingleton) : IsPreconnected s :=
hs.induction_on isPreconnected_empty fun _ => isPreconnected_singleton
#align set.subsingleton.is_preconnected Set.Subsingleton.isPreconnected
| Mathlib/Topology/Connected/Basic.lean | 96 | 111 | theorem isPreconnected_of_forall {s : Set α} (x : α)
(H : ∀ y ∈ s, ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t) : IsPreconnected s := by |
rintro u v hu hv hs ⟨z, zs, zu⟩ ⟨y, ys, yv⟩
have xs : x ∈ s := by
rcases H y ys with ⟨t, ts, xt, -, -⟩
exact ts xt
-- Porting note (#11215): TODO: use `wlog xu : x ∈ u := hs xs using u v y z, v u z y`
cases hs xs with
| inl xu =>
rcases H y ys with ⟨t, ts, xt, yt, ht⟩
have := ht u v hu hv (ts.trans hs) ⟨x, xt, xu⟩ ⟨y, yt, yv⟩
exact this.imp fun z hz => ⟨ts hz.1, hz.2⟩
| inr xv =>
rcases H z zs with ⟨t, ts, xt, zt, ht⟩
have := ht v u hv hu (ts.trans <| by rwa [union_comm]) ⟨x, xt, xv⟩ ⟨z, zt, zu⟩
exact this.imp fun _ h => ⟨ts h.1, h.2.2, h.2.1⟩
| 14 |
import Mathlib.NumberTheory.Liouville.Basic
#align_import number_theory.liouville.liouville_number from "leanprover-community/mathlib"@"04e80bb7e8510958cd9aacd32fe2dc147af0b9f1"
noncomputable section
open scoped Nat
open Real Finset
def liouvilleNumber (m : ℝ) : ℝ :=
∑' i : ℕ, 1 / m ^ i !
#align liouville_number liouvilleNumber
namespace LiouvilleNumber
def partialSum (m : ℝ) (k : ℕ) : ℝ :=
∑ i ∈ range (k + 1), 1 / m ^ i !
#align liouville_number.partial_sum LiouvilleNumber.partialSum
def remainder (m : ℝ) (k : ℕ) : ℝ :=
∑' i, 1 / m ^ (i + (k + 1))!
#align liouville_number.remainder LiouvilleNumber.remainder
protected theorem summable {m : ℝ} (hm : 1 < m) : Summable fun i : ℕ => 1 / m ^ i ! :=
summable_one_div_pow_of_le hm Nat.self_le_factorial
#align liouville_number.summable LiouvilleNumber.summable
theorem remainder_summable {m : ℝ} (hm : 1 < m) (k : ℕ) :
Summable fun i : ℕ => 1 / m ^ (i + (k + 1))! := by
convert (summable_nat_add_iff (k + 1)).2 (LiouvilleNumber.summable hm)
#align liouville_number.remainder_summable LiouvilleNumber.remainder_summable
theorem remainder_pos {m : ℝ} (hm : 1 < m) (k : ℕ) : 0 < remainder m k :=
tsum_pos (remainder_summable hm k) (fun _ => by positivity) 0 (by positivity)
#align liouville_number.remainder_pos LiouvilleNumber.remainder_pos
theorem partialSum_succ (m : ℝ) (n : ℕ) :
partialSum m (n + 1) = partialSum m n + 1 / m ^ (n + 1)! :=
sum_range_succ _ _
#align liouville_number.partial_sum_succ LiouvilleNumber.partialSum_succ
theorem partialSum_add_remainder {m : ℝ} (hm : 1 < m) (k : ℕ) :
partialSum m k + remainder m k = liouvilleNumber m :=
sum_add_tsum_nat_add _ (LiouvilleNumber.summable hm)
#align liouville_number.partial_sum_add_remainder LiouvilleNumber.partialSum_add_remainder
theorem remainder_lt' (n : ℕ) {m : ℝ} (m1 : 1 < m) :
remainder m n < (1 - 1 / m)⁻¹ * (1 / m ^ (n + 1)!) :=
-- two useful inequalities
have m0 : 0 < m := zero_lt_one.trans m1
have mi : 1 / m < 1 := (div_lt_one m0).mpr m1
-- to show the strict inequality between these series, we prove that:
calc
(∑' i, 1 / m ^ (i + (n + 1))!) < ∑' i, 1 / m ^ (i + (n + 1)!) :=
-- 1. the second series dominates the first
tsum_lt_tsum (fun b => one_div_pow_le_one_div_pow_of_le m1.le
(b.add_factorial_succ_le_factorial_add_succ n))
-- 2. the term with index `i = 2` of the first series is strictly smaller than
-- the corresponding term of the second series
(one_div_pow_strictAnti m1 (n.add_factorial_succ_lt_factorial_add_succ (i := 2) le_rfl))
-- 3. the first series is summable
(remainder_summable m1 n)
-- 4. the second series is summable, since its terms grow quickly
(summable_one_div_pow_of_le m1 fun j => le_self_add)
-- split the sum in the exponent and massage
_ = ∑' i : ℕ, (1 / m) ^ i * (1 / m ^ (n + 1)!) := by
simp only [pow_add, one_div, mul_inv, inv_pow]
-- factor the constant `(1 / m ^ (n + 1)!)` out of the series
_ = (∑' i, (1 / m) ^ i) * (1 / m ^ (n + 1)!) := tsum_mul_right
-- the series is the geometric series
_ = (1 - 1 / m)⁻¹ * (1 / m ^ (n + 1)!) := by rw [tsum_geometric_of_lt_one (by positivity) mi]
#align liouville_number.remainder_lt' LiouvilleNumber.remainder_lt'
| Mathlib/NumberTheory/Liouville/LiouvilleNumber.lean | 137 | 160 | theorem aux_calc (n : ℕ) {m : ℝ} (hm : 2 ≤ m) :
(1 - 1 / m)⁻¹ * (1 / m ^ (n + 1)!) ≤ 1 / (m ^ n !) ^ n :=
calc
(1 - 1 / m)⁻¹ * (1 / m ^ (n + 1)!) ≤ 2 * (1 / m ^ (n + 1)!) :=
-- the second factors coincide (and are non-negative),
-- the first factors satisfy the inequality `sub_one_div_inv_le_two`
mul_le_mul_of_nonneg_right (sub_one_div_inv_le_two hm) (by positivity)
_ = 2 / m ^ (n + 1)! := mul_one_div 2 _
_ = 2 / m ^ (n ! * (n + 1)) := (congr_arg (2 / ·) (congr_arg (Pow.pow m) (mul_comm _ _)))
_ ≤ 1 / m ^ (n ! * n) := by |
-- [NB: in this block, I do not follow the brace convention for subgoals -- I wait until
-- I solve all extraneous goals at once with `exact pow_pos (zero_lt_two.trans_le hm) _`.]
-- Clear denominators and massage*
apply (div_le_div_iff _ _).mpr
focus
conv_rhs => rw [one_mul, mul_add, pow_add, mul_one, pow_mul, mul_comm, ← pow_mul]
-- the second factors coincide, so we prove the inequality of the first factors*
refine (mul_le_mul_right ?_).mpr ?_
-- solve all the inequalities `0 < m ^ ??`
any_goals exact pow_pos (zero_lt_two.trans_le hm) _
-- `2 ≤ m ^ n!` is a consequence of monotonicity of exponentiation at `2 ≤ m`.
exact _root_.trans (_root_.trans hm (pow_one _).symm.le)
(pow_right_mono (one_le_two.trans hm) n.factorial_pos)
_ = 1 / (m ^ n !) ^ n := congr_arg (1 / ·) (pow_mul m n ! n)
| 14 |
import Mathlib.FieldTheory.Extension
import Mathlib.FieldTheory.SplittingField.Construction
import Mathlib.GroupTheory.Solvable
#align_import field_theory.normal from "leanprover-community/mathlib"@"9fb8964792b4237dac6200193a0d533f1b3f7423"
noncomputable section
open scoped Classical Polynomial
open Polynomial IsScalarTower
variable (F K : Type*) [Field F] [Field K] [Algebra F K]
class Normal extends Algebra.IsAlgebraic F K : Prop where
splits' (x : K) : Splits (algebraMap F K) (minpoly F x)
#align normal Normal
variable {F K}
theorem Normal.isIntegral (_ : Normal F K) (x : K) : IsIntegral F x :=
Algebra.IsIntegral.isIntegral x
#align normal.is_integral Normal.isIntegral
theorem Normal.splits (_ : Normal F K) (x : K) : Splits (algebraMap F K) (minpoly F x) :=
Normal.splits' x
#align normal.splits Normal.splits
theorem normal_iff : Normal F K ↔ ∀ x : K, IsIntegral F x ∧ Splits (algebraMap F K) (minpoly F x) :=
⟨fun h x => ⟨h.isIntegral x, h.splits x⟩, fun h =>
{ isAlgebraic := fun x => (h x).1.isAlgebraic
splits' := fun x => (h x).2 }⟩
#align normal_iff normal_iff
theorem Normal.out : Normal F K → ∀ x : K, IsIntegral F x ∧ Splits (algebraMap F K) (minpoly F x) :=
normal_iff.1
#align normal.out Normal.out
variable (F K)
instance normal_self : Normal F F where
isAlgebraic := fun _ => isIntegral_algebraMap.isAlgebraic
splits' := fun x => (minpoly.eq_X_sub_C' x).symm ▸ splits_X_sub_C _
#align normal_self normal_self
| Mathlib/FieldTheory/Normal.lean | 66 | 81 | theorem Normal.exists_isSplittingField [h : Normal F K] [FiniteDimensional F K] :
∃ p : F[X], IsSplittingField F K p := by |
let s := Basis.ofVectorSpace F K
refine
⟨∏ x, minpoly F (s x), splits_prod _ fun x _ => h.splits (s x),
Subalgebra.toSubmodule.injective ?_⟩
rw [Algebra.top_toSubmodule, eq_top_iff, ← s.span_eq, Submodule.span_le, Set.range_subset_iff]
refine fun x =>
Algebra.subset_adjoin
(Multiset.mem_toFinset.mpr <|
(mem_roots <|
mt (Polynomial.map_eq_zero <| algebraMap F K).1 <|
Finset.prod_ne_zero_iff.2 fun x _ => ?_).2 ?_)
· exact minpoly.ne_zero (h.isIntegral (s x))
rw [IsRoot.def, eval_map, ← aeval_def, AlgHom.map_prod]
exact Finset.prod_eq_zero (Finset.mem_univ _) (minpoly.aeval _ _)
| 14 |
import Mathlib.LinearAlgebra.Dimension.Finite
import Mathlib.LinearAlgebra.Dimension.Constructions
open Cardinal Submodule Set FiniteDimensional
universe u v
section Module
variable {K : Type u} {V : Type v} [Ring K] [StrongRankCondition K] [AddCommGroup V] [Module K V]
noncomputable def Basis.ofRankEqZero [Module.Free K V] {ι : Type*} [IsEmpty ι]
(hV : Module.rank K V = 0) : Basis ι K V :=
haveI : Subsingleton V := by
obtain ⟨_, b⟩ := Module.Free.exists_basis (R := K) (M := V)
haveI := mk_eq_zero_iff.1 (hV ▸ b.mk_eq_rank'')
exact b.repr.toEquiv.subsingleton
Basis.empty _
#align basis.of_rank_eq_zero Basis.ofRankEqZero
@[simp]
theorem Basis.ofRankEqZero_apply [Module.Free K V] {ι : Type*} [IsEmpty ι]
(hV : Module.rank K V = 0) (i : ι) : Basis.ofRankEqZero hV i = 0 := rfl
#align basis.of_rank_eq_zero_apply Basis.ofRankEqZero_apply
theorem le_rank_iff_exists_linearIndependent [Module.Free K V] {c : Cardinal} :
c ≤ Module.rank K V ↔ ∃ s : Set V, #s = c ∧ LinearIndependent K ((↑) : s → V) := by
haveI := nontrivial_of_invariantBasisNumber K
constructor
· intro h
obtain ⟨κ, t'⟩ := Module.Free.exists_basis (R := K) (M := V)
let t := t'.reindexRange
have : LinearIndependent K ((↑) : Set.range t' → V) := by
convert t.linearIndependent
ext; exact (Basis.reindexRange_apply _ _).symm
rw [← t.mk_eq_rank'', le_mk_iff_exists_subset] at h
rcases h with ⟨s, hst, hsc⟩
exact ⟨s, hsc, this.mono hst⟩
· rintro ⟨s, rfl, si⟩
exact si.cardinal_le_rank
#align le_rank_iff_exists_linear_independent le_rank_iff_exists_linearIndependent
theorem le_rank_iff_exists_linearIndependent_finset
[Module.Free K V] {n : ℕ} : ↑n ≤ Module.rank K V ↔
∃ s : Finset V, s.card = n ∧ LinearIndependent K ((↑) : ↥(s : Set V) → V) := by
simp only [le_rank_iff_exists_linearIndependent, mk_set_eq_nat_iff_finset]
constructor
· rintro ⟨s, ⟨t, rfl, rfl⟩, si⟩
exact ⟨t, rfl, si⟩
· rintro ⟨s, rfl, si⟩
exact ⟨s, ⟨s, rfl, rfl⟩, si⟩
#align le_rank_iff_exists_linear_independent_finset le_rank_iff_exists_linearIndependent_finset
theorem rank_le_one_iff [Module.Free K V] :
Module.rank K V ≤ 1 ↔ ∃ v₀ : V, ∀ v, ∃ r : K, r • v₀ = v := by
obtain ⟨κ, b⟩ := Module.Free.exists_basis (R := K) (M := V)
constructor
· intro hd
rw [← b.mk_eq_rank'', le_one_iff_subsingleton] at hd
rcases isEmpty_or_nonempty κ with hb | ⟨⟨i⟩⟩
· use 0
have h' : ∀ v : V, v = 0 := by
simpa [range_eq_empty, Submodule.eq_bot_iff] using b.span_eq.symm
intro v
simp [h' v]
· use b i
have h' : (K ∙ b i) = ⊤ :=
(subsingleton_range b).eq_singleton_of_mem (mem_range_self i) ▸ b.span_eq
intro v
have hv : v ∈ (⊤ : Submodule K V) := mem_top
rwa [← h', mem_span_singleton] at hv
· rintro ⟨v₀, hv₀⟩
have h : (K ∙ v₀) = ⊤ := by
ext
simp [mem_span_singleton, hv₀]
rw [← rank_top, ← h]
refine (rank_span_le _).trans_eq ?_
simp
#align rank_le_one_iff rank_le_one_iff
theorem rank_eq_one_iff [Module.Free K V] :
Module.rank K V = 1 ↔ ∃ v₀ : V, v₀ ≠ 0 ∧ ∀ v, ∃ r : K, r • v₀ = v := by
haveI := nontrivial_of_invariantBasisNumber K
refine ⟨fun h ↦ ?_, fun ⟨v₀, h, hv⟩ ↦ (rank_le_one_iff.2 ⟨v₀, hv⟩).antisymm ?_⟩
· obtain ⟨v₀, hv⟩ := rank_le_one_iff.1 h.le
refine ⟨v₀, fun hzero ↦ ?_, hv⟩
simp_rw [hzero, smul_zero, exists_const] at hv
haveI : Subsingleton V := .intro fun _ _ ↦ by simp_rw [← hv]
exact one_ne_zero (h ▸ rank_subsingleton' K V)
· by_contra H
rw [not_le, lt_one_iff_zero] at H
obtain ⟨κ, b⟩ := Module.Free.exists_basis (R := K) (M := V)
haveI := mk_eq_zero_iff.1 (H ▸ b.mk_eq_rank'')
haveI := b.repr.toEquiv.subsingleton
exact h (Subsingleton.elim _ _)
| Mathlib/LinearAlgebra/Dimension/FreeAndStrongRankCondition.lean | 124 | 139 | theorem rank_submodule_le_one_iff (s : Submodule K V) [Module.Free K s] :
Module.rank K s ≤ 1 ↔ ∃ v₀ ∈ s, s ≤ K ∙ v₀ := by |
simp_rw [rank_le_one_iff, le_span_singleton_iff]
constructor
· rintro ⟨⟨v₀, hv₀⟩, h⟩
use v₀, hv₀
intro v hv
obtain ⟨r, hr⟩ := h ⟨v, hv⟩
use r
rwa [Subtype.ext_iff, coe_smul] at hr
· rintro ⟨v₀, hv₀, h⟩
use ⟨v₀, hv₀⟩
rintro ⟨v, hv⟩
obtain ⟨r, hr⟩ := h v hv
use r
rwa [Subtype.ext_iff, coe_smul]
| 14 |
import Mathlib.RingTheory.Localization.AtPrime
import Mathlib.RingTheory.Localization.Basic
import Mathlib.RingTheory.Localization.FractionRing
#align_import ring_theory.localization.localization_localization from "leanprover-community/mathlib"@"831c494092374cfe9f50591ed0ac81a25efc5b86"
open Function
namespace IsLocalization
section LocalizationLocalization
variable {R : Type*} [CommSemiring R] (M : Submonoid R) {S : Type*} [CommSemiring S]
variable [Algebra R S] {P : Type*} [CommSemiring P]
variable (N : Submonoid S) (T : Type*) [CommSemiring T] [Algebra R T]
section
variable [Algebra S T] [IsScalarTower R S T]
-- This should only be defined when `S` is the localization `M⁻¹R`, hence the nolint.
@[nolint unusedArguments]
def localizationLocalizationSubmodule : Submonoid R :=
(N ⊔ M.map (algebraMap R S)).comap (algebraMap R S)
#align is_localization.localization_localization_submodule IsLocalization.localizationLocalizationSubmodule
variable {M N}
@[simp]
theorem mem_localizationLocalizationSubmodule {x : R} :
x ∈ localizationLocalizationSubmodule M N ↔
∃ (y : N) (z : M), algebraMap R S x = y * algebraMap R S z := by
rw [localizationLocalizationSubmodule, Submonoid.mem_comap, Submonoid.mem_sup]
constructor
· rintro ⟨y, hy, _, ⟨z, hz, rfl⟩, e⟩
exact ⟨⟨y, hy⟩, ⟨z, hz⟩, e.symm⟩
· rintro ⟨y, z, e⟩
exact ⟨y, y.prop, _, ⟨z, z.prop, rfl⟩, e.symm⟩
#align is_localization.mem_localization_localization_submodule IsLocalization.mem_localizationLocalizationSubmodule
variable (M N) [IsLocalization M S]
theorem localization_localization_map_units [IsLocalization N T]
(y : localizationLocalizationSubmodule M N) : IsUnit (algebraMap R T y) := by
obtain ⟨y', z, eq⟩ := mem_localizationLocalizationSubmodule.mp y.prop
rw [IsScalarTower.algebraMap_apply R S T, eq, RingHom.map_mul, IsUnit.mul_iff]
exact ⟨IsLocalization.map_units T y', (IsLocalization.map_units _ z).map (algebraMap S T)⟩
#align is_localization.localization_localization_map_units IsLocalization.localization_localization_map_units
theorem localization_localization_surj [IsLocalization N T] (x : T) :
∃ y : R × localizationLocalizationSubmodule M N,
x * algebraMap R T y.2 = algebraMap R T y.1 := by
rcases IsLocalization.surj N x with ⟨⟨y, s⟩, eq₁⟩
-- x = y / s
rcases IsLocalization.surj M y with ⟨⟨z, t⟩, eq₂⟩
-- y = z / t
rcases IsLocalization.surj M (s : S) with ⟨⟨z', t'⟩, eq₃⟩
-- s = z' / t'
dsimp only at eq₁ eq₂ eq₃
refine ⟨⟨z * t', z' * t, ?_⟩, ?_⟩ -- x = y / s = (z * t') / (z' * t)
· rw [mem_localizationLocalizationSubmodule]
refine ⟨s, t * t', ?_⟩
rw [RingHom.map_mul, ← eq₃, mul_assoc, ← RingHom.map_mul, mul_comm t, Submonoid.coe_mul]
· simp only [Subtype.coe_mk, RingHom.map_mul, IsScalarTower.algebraMap_apply R S T, ← eq₃, ← eq₂,
← eq₁]
ring
#align is_localization.localization_localization_surj IsLocalization.localization_localization_surj
| Mathlib/RingTheory/Localization/LocalizationLocalization.lean | 92 | 108 | theorem localization_localization_exists_of_eq [IsLocalization N T] (x y : R) :
algebraMap R T x = algebraMap R T y →
∃ c : localizationLocalizationSubmodule M N, ↑c * x = ↑c * y := by |
rw [IsScalarTower.algebraMap_apply R S T, IsScalarTower.algebraMap_apply R S T,
IsLocalization.eq_iff_exists N T]
rintro ⟨z, eq₁⟩
rcases IsLocalization.surj M (z : S) with ⟨⟨z', s⟩, eq₂⟩
dsimp only at eq₂
suffices (algebraMap R S) (x * z' : R) = (algebraMap R S) (y * z') by
obtain ⟨c, eq₃ : ↑c * (x * z') = ↑c * (y * z')⟩ := (IsLocalization.eq_iff_exists M S).mp this
refine ⟨⟨c * z', ?_⟩, ?_⟩
· rw [mem_localizationLocalizationSubmodule]
refine ⟨z, c * s, ?_⟩
rw [map_mul, ← eq₂, Submonoid.coe_mul, map_mul, mul_left_comm]
· rwa [mul_comm _ z', mul_comm _ z', ← mul_assoc, ← mul_assoc] at eq₃
rw [map_mul, map_mul, ← eq₂, ← mul_assoc, ← mul_assoc, mul_comm _ (z : S), eq₁,
mul_comm _ (z : S)]
| 14 |
import Mathlib.Geometry.Manifold.MFDeriv.FDeriv
noncomputable section
open scoped Manifold
open Bundle Set Topology
section SpecificFunctions
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {H : Type*} [TopologicalSpace H] (I : ModelWithCorners 𝕜 E H) {M : Type*}
[TopologicalSpace M] [ChartedSpace H M] [SmoothManifoldWithCorners I M] {E' : Type*}
[NormedAddCommGroup E'] [NormedSpace 𝕜 E'] {H' : Type*} [TopologicalSpace H']
(I' : ModelWithCorners 𝕜 E' H') {M' : Type*} [TopologicalSpace M'] [ChartedSpace H' M']
[SmoothManifoldWithCorners I' M'] {E'' : Type*} [NormedAddCommGroup E''] [NormedSpace 𝕜 E'']
{H'' : Type*} [TopologicalSpace H''] (I'' : ModelWithCorners 𝕜 E'' H'') {M'' : Type*}
[TopologicalSpace M''] [ChartedSpace H'' M''] [SmoothManifoldWithCorners I'' M'']
variable {s : Set M} {x : M}
section Prod
theorem hasMFDerivAt_fst (x : M × M') :
HasMFDerivAt (I.prod I') I Prod.fst x
(ContinuousLinearMap.fst 𝕜 (TangentSpace I x.1) (TangentSpace I' x.2)) := by
refine ⟨continuous_fst.continuousAt, ?_⟩
have :
∀ᶠ y in 𝓝[range (I.prod I')] extChartAt (I.prod I') x x,
(extChartAt I x.1 ∘ Prod.fst ∘ (extChartAt (I.prod I') x).symm) y = y.1 := by
filter_upwards [extChartAt_target_mem_nhdsWithin (I.prod I') x] with y hy
rw [extChartAt_prod] at hy
exact (extChartAt I x.1).right_inv hy.1
apply HasFDerivWithinAt.congr_of_eventuallyEq hasFDerivWithinAt_fst this
-- Porting note: next line was `simp only [mfld_simps]`
exact (extChartAt I x.1).right_inv <| (extChartAt I x.1).map_source (mem_extChartAt_source _ _)
#align has_mfderiv_at_fst hasMFDerivAt_fst
theorem hasMFDerivWithinAt_fst (s : Set (M × M')) (x : M × M') :
HasMFDerivWithinAt (I.prod I') I Prod.fst s x
(ContinuousLinearMap.fst 𝕜 (TangentSpace I x.1) (TangentSpace I' x.2)) :=
(hasMFDerivAt_fst I I' x).hasMFDerivWithinAt
#align has_mfderiv_within_at_fst hasMFDerivWithinAt_fst
theorem mdifferentiableAt_fst {x : M × M'} : MDifferentiableAt (I.prod I') I Prod.fst x :=
(hasMFDerivAt_fst I I' x).mdifferentiableAt
#align mdifferentiable_at_fst mdifferentiableAt_fst
theorem mdifferentiableWithinAt_fst {s : Set (M × M')} {x : M × M'} :
MDifferentiableWithinAt (I.prod I') I Prod.fst s x :=
(mdifferentiableAt_fst I I').mdifferentiableWithinAt
#align mdifferentiable_within_at_fst mdifferentiableWithinAt_fst
theorem mdifferentiable_fst : MDifferentiable (I.prod I') I (Prod.fst : M × M' → M) := fun _ =>
mdifferentiableAt_fst I I'
#align mdifferentiable_fst mdifferentiable_fst
theorem mdifferentiableOn_fst {s : Set (M × M')} : MDifferentiableOn (I.prod I') I Prod.fst s :=
(mdifferentiable_fst I I').mdifferentiableOn
#align mdifferentiable_on_fst mdifferentiableOn_fst
@[simp, mfld_simps]
theorem mfderiv_fst {x : M × M'} :
mfderiv (I.prod I') I Prod.fst x =
ContinuousLinearMap.fst 𝕜 (TangentSpace I x.1) (TangentSpace I' x.2) :=
(hasMFDerivAt_fst I I' x).mfderiv
#align mfderiv_fst mfderiv_fst
theorem mfderivWithin_fst {s : Set (M × M')} {x : M × M'}
(hxs : UniqueMDiffWithinAt (I.prod I') s x) :
mfderivWithin (I.prod I') I Prod.fst s x =
ContinuousLinearMap.fst 𝕜 (TangentSpace I x.1) (TangentSpace I' x.2) := by
rw [MDifferentiable.mfderivWithin (mdifferentiableAt_fst I I') hxs]; exact mfderiv_fst I I'
#align mfderiv_within_fst mfderivWithin_fst
@[simp, mfld_simps]
theorem tangentMap_prod_fst {p : TangentBundle (I.prod I') (M × M')} :
tangentMap (I.prod I') I Prod.fst p = ⟨p.proj.1, p.2.1⟩ := by
-- Porting note: `rfl` wasn't needed
simp [tangentMap]; rfl
#align tangent_map_prod_fst tangentMap_prod_fst
theorem tangentMapWithin_prod_fst {s : Set (M × M')} {p : TangentBundle (I.prod I') (M × M')}
(hs : UniqueMDiffWithinAt (I.prod I') s p.proj) :
tangentMapWithin (I.prod I') I Prod.fst s p = ⟨p.proj.1, p.2.1⟩ := by
simp only [tangentMapWithin]
rw [mfderivWithin_fst]
· rcases p with ⟨⟩; rfl
· exact hs
#align tangent_map_within_prod_fst tangentMapWithin_prod_fst
| Mathlib/Geometry/Manifold/MFDeriv/SpecificFunctions.lean | 300 | 316 | theorem hasMFDerivAt_snd (x : M × M') :
HasMFDerivAt (I.prod I') I' Prod.snd x
(ContinuousLinearMap.snd 𝕜 (TangentSpace I x.1) (TangentSpace I' x.2)) := by |
refine ⟨continuous_snd.continuousAt, ?_⟩
have :
∀ᶠ y in 𝓝[range (I.prod I')] extChartAt (I.prod I') x x,
(extChartAt I' x.2 ∘ Prod.snd ∘ (extChartAt (I.prod I') x).symm) y = y.2 := by
/- porting note: was
apply Filter.mem_of_superset (extChartAt_target_mem_nhdsWithin (I.prod I') x)
mfld_set_tac
-/
filter_upwards [extChartAt_target_mem_nhdsWithin (I.prod I') x] with y hy
rw [extChartAt_prod] at hy
exact (extChartAt I' x.2).right_inv hy.2
apply HasFDerivWithinAt.congr_of_eventuallyEq hasFDerivWithinAt_snd this
-- Porting note: the next line was `simp only [mfld_simps]`
exact (extChartAt I' x.2).right_inv <| (extChartAt I' x.2).map_source (mem_extChartAt_source _ _)
| 14 |
import Mathlib.Data.List.Count
import Mathlib.Data.List.Dedup
import Mathlib.Data.List.InsertNth
import Mathlib.Data.List.Lattice
import Mathlib.Data.List.Permutation
import Mathlib.Data.Nat.Factorial.Basic
#align_import data.list.perm from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83"
-- Make sure we don't import algebra
assert_not_exists Monoid
open Nat
namespace List
variable {α β : Type*} {l l₁ l₂ : List α} {a : α}
#align list.perm List.Perm
instance : Trans (@List.Perm α) (@List.Perm α) List.Perm where
trans := @List.Perm.trans α
open Perm (swap)
attribute [refl] Perm.refl
#align list.perm.refl List.Perm.refl
lemma perm_rfl : l ~ l := Perm.refl _
-- Porting note: used rec_on in mathlib3; lean4 eqn compiler still doesn't like it
attribute [symm] Perm.symm
#align list.perm.symm List.Perm.symm
#align list.perm_comm List.perm_comm
#align list.perm.swap' List.Perm.swap'
attribute [trans] Perm.trans
#align list.perm.eqv List.Perm.eqv
#align list.is_setoid List.isSetoid
#align list.perm.mem_iff List.Perm.mem_iff
#align list.perm.subset List.Perm.subset
theorem Perm.subset_congr_left {l₁ l₂ l₃ : List α} (h : l₁ ~ l₂) : l₁ ⊆ l₃ ↔ l₂ ⊆ l₃ :=
⟨h.symm.subset.trans, h.subset.trans⟩
#align list.perm.subset_congr_left List.Perm.subset_congr_left
theorem Perm.subset_congr_right {l₁ l₂ l₃ : List α} (h : l₁ ~ l₂) : l₃ ⊆ l₁ ↔ l₃ ⊆ l₂ :=
⟨fun h' => h'.trans h.subset, fun h' => h'.trans h.symm.subset⟩
#align list.perm.subset_congr_right List.Perm.subset_congr_right
#align list.perm.append_right List.Perm.append_right
#align list.perm.append_left List.Perm.append_left
#align list.perm.append List.Perm.append
#align list.perm.append_cons List.Perm.append_cons
#align list.perm_middle List.perm_middle
#align list.perm_append_singleton List.perm_append_singleton
#align list.perm_append_comm List.perm_append_comm
#align list.concat_perm List.concat_perm
#align list.perm.length_eq List.Perm.length_eq
#align list.perm.eq_nil List.Perm.eq_nil
#align list.perm.nil_eq List.Perm.nil_eq
#align list.perm_nil List.perm_nil
#align list.nil_perm List.nil_perm
#align list.not_perm_nil_cons List.not_perm_nil_cons
#align list.reverse_perm List.reverse_perm
#align list.perm_cons_append_cons List.perm_cons_append_cons
#align list.perm_replicate List.perm_replicate
#align list.replicate_perm List.replicate_perm
#align list.perm_singleton List.perm_singleton
#align list.singleton_perm List.singleton_perm
#align list.singleton_perm_singleton List.singleton_perm_singleton
#align list.perm_cons_erase List.perm_cons_erase
#align list.perm_induction_on List.Perm.recOnSwap'
-- Porting note: used to be @[congr]
#align list.perm.filter_map List.Perm.filterMap
-- Porting note: used to be @[congr]
#align list.perm.map List.Perm.map
#align list.perm.pmap List.Perm.pmap
#align list.perm.filter List.Perm.filter
#align list.filter_append_perm List.filter_append_perm
#align list.exists_perm_sublist List.exists_perm_sublist
#align list.perm.sizeof_eq_sizeof List.Perm.sizeOf_eq_sizeOf
section Rel
open Relator
variable {γ : Type*} {δ : Type*} {r : α → β → Prop} {p : γ → δ → Prop}
local infixr:80 " ∘r " => Relation.Comp
theorem perm_comp_perm : (Perm ∘r Perm : List α → List α → Prop) = Perm := by
funext a c; apply propext
constructor
· exact fun ⟨b, hab, hba⟩ => Perm.trans hab hba
· exact fun h => ⟨a, Perm.refl a, h⟩
#align list.perm_comp_perm List.perm_comp_perm
| Mathlib/Data/List/Perm.lean | 149 | 164 | theorem perm_comp_forall₂ {l u v} (hlu : Perm l u) (huv : Forall₂ r u v) :
(Forall₂ r ∘r Perm) l v := by |
induction hlu generalizing v with
| nil => cases huv; exact ⟨[], Forall₂.nil, Perm.nil⟩
| cons u _hlu ih =>
cases' huv with _ b _ v hab huv'
rcases ih huv' with ⟨l₂, h₁₂, h₂₃⟩
exact ⟨b :: l₂, Forall₂.cons hab h₁₂, h₂₃.cons _⟩
| swap a₁ a₂ h₂₃ =>
cases' huv with _ b₁ _ l₂ h₁ hr₂₃
cases' hr₂₃ with _ b₂ _ l₂ h₂ h₁₂
exact ⟨b₂ :: b₁ :: l₂, Forall₂.cons h₂ (Forall₂.cons h₁ h₁₂), Perm.swap _ _ _⟩
| trans _ _ ih₁ ih₂ =>
rcases ih₂ huv with ⟨lb₂, hab₂, h₂₃⟩
rcases ih₁ hab₂ with ⟨lb₁, hab₁, h₁₂⟩
exact ⟨lb₁, hab₁, Perm.trans h₁₂ h₂₃⟩
| 14 |
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.Bounded
import Mathlib.SetTheory.Cardinal.PartENat
import Mathlib.SetTheory.Ordinal.Principal
import Mathlib.Tactic.Linarith
#align_import set_theory.cardinal.ordinal from "leanprover-community/mathlib"@"7c2ce0c2da15516b4e65d0c9e254bb6dc93abd1f"
noncomputable section
open Function Set Cardinal Equiv Order Ordinal
open scoped Classical
universe u v w
namespace Cardinal
section UsingOrdinals
theorem ord_isLimit {c} (co : ℵ₀ ≤ c) : (ord c).IsLimit := by
refine ⟨fun h => aleph0_ne_zero ?_, fun a => lt_imp_lt_of_le_imp_le fun h => ?_⟩
· rw [← Ordinal.le_zero, ord_le] at h
simpa only [card_zero, nonpos_iff_eq_zero] using co.trans h
· rw [ord_le] at h ⊢
rwa [← @add_one_of_aleph0_le (card a), ← card_succ]
rw [← ord_le, ← le_succ_of_isLimit, ord_le]
· exact co.trans h
· rw [ord_aleph0]
exact omega_isLimit
#align cardinal.ord_is_limit Cardinal.ord_isLimit
theorem noMaxOrder {c} (h : ℵ₀ ≤ c) : NoMaxOrder c.ord.out.α :=
Ordinal.out_no_max_of_succ_lt (ord_isLimit h).2
section beth
def beth (o : Ordinal.{u}) : Cardinal.{u} :=
limitRecOn o aleph0 (fun _ x => (2 : Cardinal) ^ x) fun a _ IH => ⨆ b : Iio a, IH b.1 b.2
#align cardinal.beth Cardinal.beth
@[simp]
theorem beth_zero : beth 0 = aleph0 :=
limitRecOn_zero _ _ _
#align cardinal.beth_zero Cardinal.beth_zero
@[simp]
theorem beth_succ (o : Ordinal) : beth (succ o) = 2 ^ beth o :=
limitRecOn_succ _ _ _ _
#align cardinal.beth_succ Cardinal.beth_succ
theorem beth_limit {o : Ordinal} : o.IsLimit → beth o = ⨆ a : Iio o, beth a :=
limitRecOn_limit _ _ _ _
#align cardinal.beth_limit Cardinal.beth_limit
| Mathlib/SetTheory/Cardinal/Ordinal.lean | 433 | 447 | theorem beth_strictMono : StrictMono beth := by |
intro a b
induction' b using Ordinal.induction with b IH generalizing a
intro h
rcases zero_or_succ_or_limit b with (rfl | ⟨c, rfl⟩ | hb)
· exact (Ordinal.not_lt_zero a h).elim
· rw [lt_succ_iff] at h
rw [beth_succ]
apply lt_of_le_of_lt _ (cantor _)
rcases eq_or_lt_of_le h with (rfl | h)
· rfl
exact (IH c (lt_succ c) h).le
· apply (cantor _).trans_le
rw [beth_limit hb, ← beth_succ]
exact le_ciSup (bddAbove_of_small _) (⟨_, hb.succ_lt h⟩ : Iio b)
| 14 |
import Mathlib.CategoryTheory.Sites.InducedTopology
import Mathlib.CategoryTheory.Sites.LocallyBijective
import Mathlib.CategoryTheory.Sites.PreservesLocallyBijective
import Mathlib.CategoryTheory.Sites.Whiskering
universe u
namespace CategoryTheory
open Functor Limits GrothendieckTopology
variable {C : Type*} [Category C] (J : GrothendieckTopology C)
variable {D : Type*} [Category D] (K : GrothendieckTopology D) (e : C ≌ D) (G : D ⥤ C)
variable (A : Type*) [Category A]
namespace Equivalence
theorem locallyCoverDense : LocallyCoverDense J e.inverse := by
intro X T
convert T.prop
ext Z f
constructor
· rintro ⟨_, _, g', hg, rfl⟩
exact T.val.downward_closed hg g'
· intro hf
refine ⟨e.functor.obj Z, (Adjunction.homEquiv e.toAdjunction _ _).symm f, e.unit.app Z, ?_, ?_⟩
· simp only [Adjunction.homEquiv_counit, Functor.id_obj, Equivalence.toAdjunction_counit,
Sieve.functorPullback_apply, Presieve.functorPullback_mem, Functor.map_comp,
Equivalence.inv_fun_map, Functor.comp_obj, Category.assoc, Equivalence.unit_inverse_comp,
Category.comp_id]
exact T.val.downward_closed hf _
· simp
| Mathlib/CategoryTheory/Sites/Equivalence.lean | 67 | 82 | theorem coverPreserving : CoverPreserving J (e.locallyCoverDense J).inducedTopology e.functor where
cover_preserve {U S} h := by |
change _ ∈ J.sieves (e.inverse.obj (e.functor.obj U))
convert J.pullback_stable (e.unitInv.app U) h
ext Z f
rw [← Sieve.functorPushforward_comp]
simp only [Sieve.functorPushforward_apply, Presieve.functorPushforward, exists_and_left, id_obj,
comp_obj, Sieve.pullback_apply]
constructor
· rintro ⟨W, g, hg, x, rfl⟩
rw [Category.assoc]
apply S.downward_closed
simpa using S.downward_closed hg _
· intro hf
exact ⟨_, e.unitInv.app Z ≫ f ≫ e.unitInv.app U, S.downward_closed hf _,
e.unit.app Z ≫ e.unit.app _, by simp⟩
| 14 |
import Mathlib.Algebra.BigOperators.Ring.List
import Mathlib.Data.Nat.ModEq
import Mathlib.Data.Nat.GCD.BigOperators
namespace Nat
variable {ι : Type*}
lemma modEq_list_prod_iff {a b} {l : List ℕ} (co : l.Pairwise Coprime) :
a ≡ b [MOD l.prod] ↔ ∀ i, a ≡ b [MOD l.get i] := by
induction' l with m l ih
· simp [modEq_one]
· have : Coprime m l.prod := coprime_list_prod_right_iff.mpr (List.pairwise_cons.mp co).1
simp only [List.prod_cons, ← modEq_and_modEq_iff_modEq_mul this, ih (List.Pairwise.of_cons co),
List.length_cons]
constructor
· rintro ⟨h0, hs⟩ i
cases i using Fin.cases <;> simp [h0, hs]
· intro h; exact ⟨h 0, fun i => h i.succ⟩
lemma modEq_list_prod_iff' {a b} {s : ι → ℕ} {l : List ι} (co : l.Pairwise (Coprime on s)) :
a ≡ b [MOD (l.map s).prod] ↔ ∀ i ∈ l, a ≡ b [MOD s i] := by
induction' l with i l ih
· simp [modEq_one]
· have : Coprime (s i) (l.map s).prod := by
simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂]
intro j hj
exact (List.pairwise_cons.mp co).1 j hj
simp [← modEq_and_modEq_iff_modEq_mul this, ih (List.Pairwise.of_cons co)]
variable (a s : ι → ℕ)
def chineseRemainderOfList : (l : List ι) → l.Pairwise (Coprime on s) →
{ k // ∀ i ∈ l, k ≡ a i [MOD s i] }
| [], _ => ⟨0, by simp⟩
| i :: l, co => by
have : Coprime (s i) (l.map s).prod := by
simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂]
intro j hj
exact (List.pairwise_cons.mp co).1 j hj
have ih := chineseRemainderOfList l co.of_cons
have k := chineseRemainder this (a i) ih
use k
simp only [List.mem_cons, forall_eq_or_imp, k.prop.1, true_and]
intro j hj
exact ((modEq_list_prod_iff' co.of_cons).mp k.prop.2 j hj).trans (ih.prop j hj)
@[simp] theorem chineseRemainderOfList_nil :
(chineseRemainderOfList a s [] List.Pairwise.nil : ℕ) = 0 := rfl
| Mathlib/Data/Nat/ChineseRemainder.lean | 75 | 91 | theorem chineseRemainderOfList_lt_prod (l : List ι)
(co : l.Pairwise (Coprime on s)) (hs : ∀ i ∈ l, s i ≠ 0) :
chineseRemainderOfList a s l co < (l.map s).prod := by |
cases l with
| nil => simp
| cons i l =>
simp only [chineseRemainderOfList, List.map_cons, List.prod_cons]
have : Coprime (s i) (l.map s).prod := by
simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂]
intro j hj
exact (List.pairwise_cons.mp co).1 j hj
refine chineseRemainder_lt_mul this (a i) (chineseRemainderOfList a s l co.of_cons)
(hs i (List.mem_cons_self _ l)) ?_
simp only [ne_eq, List.prod_eq_zero_iff, List.mem_map, not_exists, not_and]
intro j hj
exact hs j (List.mem_cons_of_mem _ hj)
| 14 |
import Mathlib.CategoryTheory.Galois.Basic
import Mathlib.RepresentationTheory.Action.Basic
import Mathlib.RepresentationTheory.Action.Concrete
import Mathlib.RepresentationTheory.Action.Limits
import Mathlib.CategoryTheory.Limits.FintypeCat
import Mathlib.CategoryTheory.Limits.Shapes.Types
import Mathlib.Logic.Equiv.TransferInstance
universe u v w
namespace CategoryTheory
namespace FintypeCat
open Limits Functor PreGaloisCategory
noncomputable def imageComplement {X Y : FintypeCat.{u}} (f : X ⟶ Y) :
FintypeCat.{u} := by
haveI : Fintype (↑(Set.range f)ᶜ) := Fintype.ofFinite _
exact FintypeCat.of (↑(Set.range f)ᶜ)
def imageComplementIncl {X Y : FintypeCat.{u}}
(f : X ⟶ Y) : imageComplement f ⟶ Y :=
Subtype.val
variable (G : Type u) [Group G]
noncomputable def Action.imageComplement {X Y : Action FintypeCat (MonCat.of G)}
(f : X ⟶ Y) : Action FintypeCat (MonCat.of G) where
V := FintypeCat.imageComplement f.hom
ρ := MonCat.ofHom <| {
toFun := fun g y ↦ Subtype.mk (Y.ρ g y.val) <| by
intro ⟨x, h⟩
apply y.property
use X.ρ g⁻¹ x
calc (X.ρ g⁻¹ ≫ f.hom) x
= (Y.ρ g⁻¹ * Y.ρ g) y.val := by rw [f.comm, FintypeCat.comp_apply, h]; rfl
_ = y.val := by rw [← map_mul, mul_left_inv, Action.ρ_one, FintypeCat.id_apply]
map_one' := by simp only [Action.ρ_one]; rfl
map_mul' := fun g h ↦ FintypeCat.hom_ext _ _ <| fun y ↦ Subtype.ext <| by
exact congrFun (MonoidHom.map_mul Y.ρ g h) y.val
}
def Action.imageComplementIncl {X Y : Action FintypeCat (MonCat.of G)} (f : X ⟶ Y) :
Action.imageComplement G f ⟶ Y where
hom := FintypeCat.imageComplementIncl f.hom
comm _ := rfl
instance {X Y : Action FintypeCat (MonCat.of G)} (f : X ⟶ Y) :
Mono (Action.imageComplementIncl G f) := by
apply Functor.mono_of_mono_map (forget _)
apply ConcreteCategory.mono_of_injective
exact Subtype.val_injective
instance [Finite G] : HasColimitsOfShape (SingleObj G) FintypeCat.{w} := by
obtain ⟨G', hg, hf, ⟨e⟩⟩ := Finite.exists_type_zero_nonempty_mulEquiv G
exact Limits.hasColimitsOfShape_of_equivalence e.toSingleObjEquiv.symm
noncomputable instance : PreservesFiniteLimits (forget (Action FintypeCat (MonCat.of G))) := by
show PreservesFiniteLimits (Action.forget FintypeCat _ ⋙ FintypeCat.incl)
apply compPreservesFiniteLimits
instance : PreGaloisCategory (Action FintypeCat (MonCat.of G)) where
hasQuotientsByFiniteGroups G _ _ := inferInstance
monoInducesIsoOnDirectSummand {X Y} i h :=
⟨Action.imageComplement G i, Action.imageComplementIncl G i,
⟨isColimitOfReflects (Action.forget _ _ ⋙ FintypeCat.incl) <|
(isColimitMapCoconeBinaryCofanEquiv (forget _) i _).symm
(Types.isCoprodOfMono ((forget _).map i))⟩⟩
noncomputable instance : FiberFunctor (Action.forget FintypeCat (MonCat.of G)) where
preservesFiniteCoproducts := ⟨fun _ _ ↦ inferInstance⟩
preservesQuotientsByFiniteGroups _ _ _ := inferInstance
reflectsIsos := ⟨fun f (h : IsIso f.hom) => inferInstance⟩
instance : GaloisCategory (Action FintypeCat (MonCat.of G)) where
hasFiberFunctor := ⟨Action.forget FintypeCat (MonCat.of G), ⟨inferInstance⟩⟩
theorem Action.pretransitive_of_isConnected (X : Action FintypeCat (MonCat.of G))
[IsConnected X] : MulAction.IsPretransitive G X.V where
exists_smul_eq x y := by
let T : Set X.V := MulAction.orbit G x
have : Fintype T := Fintype.ofFinite T
letI : MulAction G (FintypeCat.of T) := inferInstanceAs <| MulAction G ↑(MulAction.orbit G x)
let T' : Action FintypeCat (MonCat.of G) := Action.FintypeCat.ofMulAction G (FintypeCat.of T)
let i : T' ⟶ X := ⟨Subtype.val, fun _ ↦ rfl⟩
have : Mono i := ConcreteCategory.mono_of_injective _ (Subtype.val_injective)
have : IsIso i := by
apply IsConnected.noTrivialComponent T' i
apply (not_initial_iff_fiber_nonempty (Action.forget _ _) T').mpr
exact Set.Nonempty.coe_sort (MulAction.orbit_nonempty x)
have hb : Function.Bijective i.hom := by
apply (ConcreteCategory.isIso_iff_bijective i.hom).mp
exact map_isIso (forget₂ _ FintypeCat) i
obtain ⟨⟨y', ⟨g, (hg : g • x = y')⟩⟩, (hy' : y' = y)⟩ := hb.surjective y
use g
exact hg.trans hy'
| Mathlib/CategoryTheory/Galois/Examples.lean | 127 | 145 | theorem Action.isConnected_of_transitive (X : FintypeCat) [MulAction G X]
[MulAction.IsPretransitive G X] [h : Nonempty X] :
IsConnected (Action.FintypeCat.ofMulAction G X) where
notInitial := not_initial_of_inhabited (Action.forget _ _) h.some
noTrivialComponent Y i hm hni := by |
/- We show that the induced inclusion `i.hom` of finite sets is surjective, using the
transitivity of the `G`-action. -/
obtain ⟨(y : Y.V)⟩ := (not_initial_iff_fiber_nonempty (Action.forget _ _) Y).mp hni
have : IsIso i.hom := by
refine (ConcreteCategory.isIso_iff_bijective i.hom).mpr ⟨?_, fun x' ↦ ?_⟩
· haveI : Mono i.hom := map_mono (forget₂ _ _) i
exact ConcreteCategory.injective_of_mono_of_preservesPullback i.hom
· letI x : X := i.hom y
obtain ⟨σ, hσ⟩ := MulAction.exists_smul_eq G x x'
use σ • y
show (Y.ρ σ ≫ i.hom) y = x'
rw [i.comm, FintypeCat.comp_apply]
exact hσ
apply isIso_of_reflects_iso i (Action.forget _ _)
| 14 |
import Mathlib.LinearAlgebra.AffineSpace.Basis
import Mathlib.LinearAlgebra.Matrix.NonsingularInverse
#align_import linear_algebra.affine_space.matrix from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0"
open Affine Matrix
open Set
universe u₁ u₂ u₃ u₄
variable {ι : Type u₁} {k : Type u₂} {V : Type u₃} {P : Type u₄}
variable [AddCommGroup V] [AffineSpace V P]
namespace AffineBasis
section Ring
variable [Ring k] [Module k V] (b : AffineBasis ι k P)
noncomputable def toMatrix {ι' : Type*} (q : ι' → P) : Matrix ι' ι k :=
fun i j => b.coord j (q i)
#align affine_basis.to_matrix AffineBasis.toMatrix
@[simp]
theorem toMatrix_apply {ι' : Type*} (q : ι' → P) (i : ι') (j : ι) :
b.toMatrix q i j = b.coord j (q i) := rfl
#align affine_basis.to_matrix_apply AffineBasis.toMatrix_apply
@[simp]
theorem toMatrix_self [DecidableEq ι] : b.toMatrix b = (1 : Matrix ι ι k) := by
ext i j
rw [toMatrix_apply, coord_apply, Matrix.one_eq_pi_single, Pi.single_apply]
#align affine_basis.to_matrix_self AffineBasis.toMatrix_self
variable {ι' : Type*}
theorem toMatrix_row_sum_one [Fintype ι] (q : ι' → P) (i : ι') : ∑ j, b.toMatrix q i j = 1 := by
simp
#align affine_basis.to_matrix_row_sum_one AffineBasis.toMatrix_row_sum_one
| Mathlib/LinearAlgebra/AffineSpace/Matrix.lean | 61 | 76 | theorem affineIndependent_of_toMatrix_right_inv [Fintype ι] [Finite ι'] [DecidableEq ι']
(p : ι' → P) {A : Matrix ι ι' k} (hA : b.toMatrix p * A = 1) : AffineIndependent k p := by |
cases nonempty_fintype ι'
rw [affineIndependent_iff_eq_of_fintype_affineCombination_eq]
intro w₁ w₂ hw₁ hw₂ hweq
have hweq' : w₁ ᵥ* b.toMatrix p = w₂ ᵥ* b.toMatrix p := by
ext j
change (∑ i, w₁ i • b.coord j (p i)) = ∑ i, w₂ i • b.coord j (p i)
-- Porting note: Added `u` because `∘` was causing trouble
have u : (fun i => b.coord j (p i)) = b.coord j ∘ p := by simp only [(· ∘ ·)]
rw [← Finset.univ.affineCombination_eq_linear_combination _ _ hw₁,
← Finset.univ.affineCombination_eq_linear_combination _ _ hw₂, u,
← Finset.univ.map_affineCombination p w₁ hw₁, ← Finset.univ.map_affineCombination p w₂ hw₂,
hweq]
replace hweq' := congr_arg (fun w => w ᵥ* A) hweq'
simpa only [Matrix.vecMul_vecMul, hA, Matrix.vecMul_one] using hweq'
| 14 |
import Mathlib.Algebra.Polynomial.Inductions
import Mathlib.Algebra.Polynomial.Monic
import Mathlib.RingTheory.Multiplicity
import Mathlib.RingTheory.Ideal.Maps
#align_import data.polynomial.div from "leanprover-community/mathlib"@"e1e7190efdcefc925cb36f257a8362ef22944204"
noncomputable section
open Polynomial
open Finset
namespace Polynomial
universe u v w z
variable {R : Type u} {S : Type v} {T : Type w} {A : Type z} {a b : R} {n : ℕ}
section Semiring
variable [Semiring R]
theorem X_dvd_iff {f : R[X]} : X ∣ f ↔ f.coeff 0 = 0 :=
⟨fun ⟨g, hfg⟩ => by rw [hfg, coeff_X_mul_zero], fun hf =>
⟨f.divX, by rw [← add_zero (X * f.divX), ← C_0, ← hf, X_mul_divX_add]⟩⟩
set_option linter.uppercaseLean3 false in
#align polynomial.X_dvd_iff Polynomial.X_dvd_iff
theorem X_pow_dvd_iff {f : R[X]} {n : ℕ} : X ^ n ∣ f ↔ ∀ d < n, f.coeff d = 0 :=
⟨fun ⟨g, hgf⟩ d hd => by
simp only [hgf, coeff_X_pow_mul', ite_eq_right_iff, not_le_of_lt hd, IsEmpty.forall_iff],
fun hd => by
induction' n with n hn
· simp [pow_zero, one_dvd]
· obtain ⟨g, hgf⟩ := hn fun d : ℕ => fun H : d < n => hd _ (Nat.lt_succ_of_lt H)
have := coeff_X_pow_mul g n 0
rw [zero_add, ← hgf, hd n (Nat.lt_succ_self n)] at this
obtain ⟨k, hgk⟩ := Polynomial.X_dvd_iff.mpr this.symm
use k
rwa [pow_succ, mul_assoc, ← hgk]⟩
set_option linter.uppercaseLean3 false in
#align polynomial.X_pow_dvd_iff Polynomial.X_pow_dvd_iff
variable {p q : R[X]}
| Mathlib/Algebra/Polynomial/Div.lean | 61 | 82 | theorem multiplicity_finite_of_degree_pos_of_monic (hp : (0 : WithBot ℕ) < degree p) (hmp : Monic p)
(hq : q ≠ 0) : multiplicity.Finite p q :=
have zn0 : (0 : R) ≠ 1 :=
haveI := Nontrivial.of_polynomial_ne hq
zero_ne_one
⟨natDegree q, fun ⟨r, hr⟩ => by
have hp0 : p ≠ 0 := fun hp0 => by simp [hp0] at hp
have hr0 : r ≠ 0 := fun hr0 => by subst hr0; simp [hq] at hr
have hpn1 : leadingCoeff p ^ (natDegree q + 1) = 1 := by | simp [show _ = _ from hmp]
have hpn0' : leadingCoeff p ^ (natDegree q + 1) ≠ 0 := hpn1.symm ▸ zn0.symm
have hpnr0 : leadingCoeff (p ^ (natDegree q + 1)) * leadingCoeff r ≠ 0 := by
simp only [leadingCoeff_pow' hpn0', leadingCoeff_eq_zero, hpn1, one_pow, one_mul, Ne,
hr0, not_false_eq_true]
have hnp : 0 < natDegree p := Nat.cast_lt.1 <| by
rw [← degree_eq_natDegree hp0]; exact hp
have := congr_arg natDegree hr
rw [natDegree_mul' hpnr0, natDegree_pow' hpn0', add_mul, add_assoc] at this
exact
ne_of_lt
(lt_add_of_le_of_pos (le_mul_of_one_le_right (Nat.zero_le _) hnp)
(add_pos_of_pos_of_nonneg (by rwa [one_mul]) (Nat.zero_le _)))
this⟩
| 14 |
import Mathlib.Analysis.Quaternion
import Mathlib.Analysis.NormedSpace.Exponential
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Series
#align_import analysis.normed_space.quaternion_exponential from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
open scoped Quaternion Nat
open NormedSpace
namespace Quaternion
@[simp, norm_cast]
theorem exp_coe (r : ℝ) : exp ℝ (r : ℍ[ℝ]) = ↑(exp ℝ r) :=
(map_exp ℝ (algebraMap ℝ ℍ[ℝ]) (continuous_algebraMap _ _) _).symm
#align quaternion.exp_coe Quaternion.exp_coe
| Mathlib/Analysis/NormedSpace/QuaternionExponential.lean | 39 | 55 | theorem expSeries_even_of_imaginary {q : Quaternion ℝ} (hq : q.re = 0) (n : ℕ) :
expSeries ℝ (Quaternion ℝ) (2 * n) (fun _ => q) =
↑((-1 : ℝ) ^ n * ‖q‖ ^ (2 * n) / (2 * n)!) := by |
rw [expSeries_apply_eq]
have hq2 : q ^ 2 = -normSq q := sq_eq_neg_normSq.mpr hq
letI k : ℝ := ↑(2 * n)!
calc
k⁻¹ • q ^ (2 * n) = k⁻¹ • (-normSq q) ^ n := by rw [pow_mul, hq2]
_ = k⁻¹ • ↑((-1 : ℝ) ^ n * ‖q‖ ^ (2 * n)) := ?_
_ = ↑((-1 : ℝ) ^ n * ‖q‖ ^ (2 * n) / k) := ?_
· congr 1
rw [neg_pow, normSq_eq_norm_mul_self, pow_mul, sq]
push_cast
rfl
· rw [← coe_mul_eq_smul, div_eq_mul_inv]
norm_cast
ring_nf
| 14 |
import Mathlib.Algebra.Ring.Idempotents
import Mathlib.RingTheory.Finiteness
import Mathlib.Order.Basic
#align_import ring_theory.ideal.idempotent_fg from "leanprover-community/mathlib"@"25cf7631da8ddc2d5f957c388bf5e4b25a77d8dc"
namespace Ideal
| Mathlib/RingTheory/Ideal/IdempotentFG.lean | 20 | 35 | theorem isIdempotentElem_iff_of_fg {R : Type*} [CommRing R] (I : Ideal R) (h : I.FG) :
IsIdempotentElem I ↔ ∃ e : R, IsIdempotentElem e ∧ I = R ∙ e := by |
constructor
· intro e
obtain ⟨r, hr, hr'⟩ :=
Submodule.exists_mem_and_smul_eq_self_of_fg_of_le_smul I I h
(by
rw [smul_eq_mul]
exact e.ge)
simp_rw [smul_eq_mul] at hr'
refine ⟨r, hr' r hr, antisymm ?_ ((Submodule.span_singleton_le_iff_mem _ _).mpr hr)⟩
intro x hx
rw [← hr' x hx]
exact Ideal.mem_span_singleton'.mpr ⟨_, mul_comm _ _⟩
· rintro ⟨e, he, rfl⟩
simp [IsIdempotentElem, Ideal.span_singleton_mul_span_singleton, he.eq]
| 14 |
import Mathlib.Geometry.Euclidean.Sphere.Basic
#align_import geometry.euclidean.sphere.second_inter from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
noncomputable section
open RealInnerProductSpace
namespace EuclideanGeometry
variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
[NormedAddTorsor V P]
def Sphere.secondInter (s : Sphere P) (p : P) (v : V) : P :=
(-2 * ⟪v, p -ᵥ s.center⟫ / ⟪v, v⟫) • v +ᵥ p
#align euclidean_geometry.sphere.second_inter EuclideanGeometry.Sphere.secondInter
@[simp]
theorem Sphere.secondInter_dist (s : Sphere P) (p : P) (v : V) :
dist (s.secondInter p v) s.center = dist p s.center := by
rw [Sphere.secondInter]
by_cases hv : v = 0; · simp [hv]
rw [dist_smul_vadd_eq_dist _ _ hv]
exact Or.inr rfl
#align euclidean_geometry.sphere.second_inter_dist EuclideanGeometry.Sphere.secondInter_dist
@[simp]
theorem Sphere.secondInter_mem {s : Sphere P} {p : P} (v : V) : s.secondInter p v ∈ s ↔ p ∈ s := by
simp_rw [mem_sphere, Sphere.secondInter_dist]
#align euclidean_geometry.sphere.second_inter_mem EuclideanGeometry.Sphere.secondInter_mem
variable (V)
@[simp]
theorem Sphere.secondInter_zero (s : Sphere P) (p : P) : s.secondInter p (0 : V) = p := by
simp [Sphere.secondInter]
#align euclidean_geometry.sphere.second_inter_zero EuclideanGeometry.Sphere.secondInter_zero
variable {V}
theorem Sphere.secondInter_eq_self_iff {s : Sphere P} {p : P} {v : V} :
s.secondInter p v = p ↔ ⟪v, p -ᵥ s.center⟫ = 0 := by
refine ⟨fun hp => ?_, fun hp => ?_⟩
· by_cases hv : v = 0
· simp [hv]
rwa [Sphere.secondInter, eq_comm, eq_vadd_iff_vsub_eq, vsub_self, eq_comm, smul_eq_zero,
or_iff_left hv, div_eq_zero_iff, inner_self_eq_zero, or_iff_left hv, mul_eq_zero,
or_iff_right (by norm_num : (-2 : ℝ) ≠ 0)] at hp
· rw [Sphere.secondInter, hp, mul_zero, zero_div, zero_smul, zero_vadd]
#align euclidean_geometry.sphere.second_inter_eq_self_iff EuclideanGeometry.Sphere.secondInter_eq_self_iff
| Mathlib/Geometry/Euclidean/Sphere/SecondInter.lean | 82 | 98 | theorem Sphere.eq_or_eq_secondInter_of_mem_mk'_span_singleton_iff_mem {s : Sphere P} {p : P}
(hp : p ∈ s) {v : V} {p' : P} (hp' : p' ∈ AffineSubspace.mk' p (ℝ ∙ v)) :
p' = p ∨ p' = s.secondInter p v ↔ p' ∈ s := by |
refine ⟨fun h => ?_, fun h => ?_⟩
· rcases h with (h | h)
· rwa [h]
· rwa [h, Sphere.secondInter_mem]
· rw [AffineSubspace.mem_mk'_iff_vsub_mem, Submodule.mem_span_singleton] at hp'
rcases hp' with ⟨r, hr⟩
rw [eq_comm, ← eq_vadd_iff_vsub_eq] at hr
subst hr
by_cases hv : v = 0
· simp [hv]
rw [Sphere.secondInter]
rw [mem_sphere] at h hp
rw [← hp, dist_smul_vadd_eq_dist _ _ hv] at h
rcases h with (h | h) <;> simp [h]
| 14 |
import Mathlib.MeasureTheory.Function.ConditionalExpectation.CondexpL2
#align_import measure_theory.function.conditional_expectation.condexp_L1 from "leanprover-community/mathlib"@"d8bbb04e2d2a44596798a9207ceefc0fb236e41e"
noncomputable section
open TopologicalSpace MeasureTheory.Lp Filter ContinuousLinearMap
open scoped NNReal ENNReal Topology MeasureTheory
namespace MeasureTheory
variable {α β F F' G G' 𝕜 : 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']
-- G for a Lp add_subgroup
[NormedAddCommGroup G]
-- G' for integrals on a Lp add_subgroup
[NormedAddCommGroup G']
[NormedSpace ℝ G'] [CompleteSpace G']
section CondexpInd
variable {m m0 : MeasurableSpace α} {μ : Measure α} {s t : Set α} [NormedSpace ℝ G]
section CondexpIndL1Fin
set_option linter.uppercaseLean3 false
def condexpIndL1Fin (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (hs : MeasurableSet s) (hμs : μ s ≠ ∞)
(x : G) : α →₁[μ] G :=
(integrable_condexpIndSMul hm hs hμs x).toL1 _
#align measure_theory.condexp_ind_L1_fin MeasureTheory.condexpIndL1Fin
theorem condexpIndL1Fin_ae_eq_condexpIndSMul (hm : m ≤ m0) [SigmaFinite (μ.trim hm)]
(hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) :
condexpIndL1Fin hm hs hμs x =ᵐ[μ] condexpIndSMul hm hs hμs x :=
(integrable_condexpIndSMul hm hs hμs x).coeFn_toL1
#align measure_theory.condexp_ind_L1_fin_ae_eq_condexp_ind_smul MeasureTheory.condexpIndL1Fin_ae_eq_condexpIndSMul
variable {hm : m ≤ m0} [SigmaFinite (μ.trim hm)]
-- Porting note: this lemma fills the hole in `refine' (Memℒp.coeFn_toLp _) ...`
-- which is not automatically filled in Lean 4
private theorem q {hs : MeasurableSet s} {hμs : μ s ≠ ∞} {x : G} :
Memℒp (condexpIndSMul hm hs hμs x) 1 μ := by
rw [memℒp_one_iff_integrable]; apply integrable_condexpIndSMul
theorem condexpIndL1Fin_add (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x y : G) :
condexpIndL1Fin hm hs hμs (x + y) =
condexpIndL1Fin hm hs hμs x + condexpIndL1Fin hm hs hμs y := by
ext1
refine (Memℒp.coeFn_toLp q).trans ?_
refine EventuallyEq.trans ?_ (Lp.coeFn_add _ _).symm
refine EventuallyEq.trans ?_
(EventuallyEq.add (Memℒp.coeFn_toLp q).symm (Memℒp.coeFn_toLp q).symm)
rw [condexpIndSMul_add]
refine (Lp.coeFn_add _ _).trans (eventually_of_forall fun a => ?_)
rfl
#align measure_theory.condexp_ind_L1_fin_add MeasureTheory.condexpIndL1Fin_add
theorem condexpIndL1Fin_smul (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (c : ℝ) (x : G) :
condexpIndL1Fin hm hs hμs (c • x) = c • condexpIndL1Fin hm hs hμs x := by
ext1
refine (Memℒp.coeFn_toLp q).trans ?_
refine EventuallyEq.trans ?_ (Lp.coeFn_smul _ _).symm
rw [condexpIndSMul_smul hs hμs c x]
refine (Lp.coeFn_smul _ _).trans ?_
refine (condexpIndL1Fin_ae_eq_condexpIndSMul hm hs hμs x).mono fun y hy => ?_
simp only [Pi.smul_apply, hy]
#align measure_theory.condexp_ind_L1_fin_smul MeasureTheory.condexpIndL1Fin_smul
theorem condexpIndL1Fin_smul' [NormedSpace ℝ F] [SMulCommClass ℝ 𝕜 F] (hs : MeasurableSet s)
(hμs : μ s ≠ ∞) (c : 𝕜) (x : F) :
condexpIndL1Fin hm hs hμs (c • x) = c • condexpIndL1Fin hm hs hμs x := by
ext1
refine (Memℒp.coeFn_toLp q).trans ?_
refine EventuallyEq.trans ?_ (Lp.coeFn_smul _ _).symm
rw [condexpIndSMul_smul' hs hμs c x]
refine (Lp.coeFn_smul _ _).trans ?_
refine (condexpIndL1Fin_ae_eq_condexpIndSMul hm hs hμs x).mono fun y hy => ?_
simp only [Pi.smul_apply, hy]
#align measure_theory.condexp_ind_L1_fin_smul' MeasureTheory.condexpIndL1Fin_smul'
| Mathlib/MeasureTheory/Function/ConditionalExpectation/CondexpL1.lean | 128 | 143 | theorem norm_condexpIndL1Fin_le (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) :
‖condexpIndL1Fin hm hs hμs x‖ ≤ (μ s).toReal * ‖x‖ := by |
have : 0 ≤ ∫ a : α, ‖condexpIndL1Fin hm hs hμs x a‖ ∂μ := by positivity
rw [L1.norm_eq_integral_norm, ← ENNReal.toReal_ofReal (norm_nonneg x), ← ENNReal.toReal_mul, ←
ENNReal.toReal_ofReal this,
ENNReal.toReal_le_toReal ENNReal.ofReal_ne_top (ENNReal.mul_ne_top hμs ENNReal.ofReal_ne_top),
ofReal_integral_norm_eq_lintegral_nnnorm]
swap; · rw [← memℒp_one_iff_integrable]; exact Lp.memℒp _
have h_eq :
∫⁻ a, ‖condexpIndL1Fin hm hs hμs x a‖₊ ∂μ = ∫⁻ a, ‖condexpIndSMul hm hs hμs x a‖₊ ∂μ := by
refine lintegral_congr_ae ?_
refine (condexpIndL1Fin_ae_eq_condexpIndSMul hm hs hμs x).mono fun z hz => ?_
dsimp only
rw [hz]
rw [h_eq, ofReal_norm_eq_coe_nnnorm]
exact lintegral_nnnorm_condexpIndSMul_le hm hs hμs x
| 14 |
import Mathlib.Analysis.Complex.AbsMax
import Mathlib.Analysis.Complex.RemovableSingularity
#align_import analysis.complex.schwarz from "leanprover-community/mathlib"@"3f655f5297b030a87d641ad4e825af8d9679eb0b"
open Metric Set Function Filter TopologicalSpace
open scoped Topology
namespace Complex
section Space
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {R R₁ R₂ : ℝ} {f : ℂ → E}
{c z z₀ : ℂ}
theorem schwarz_aux {f : ℂ → ℂ} (hd : DifferentiableOn ℂ f (ball c R₁))
(h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)) (hz : z ∈ ball c R₁) :
‖dslope f c z‖ ≤ R₂ / R₁ := by
have hR₁ : 0 < R₁ := nonempty_ball.1 ⟨z, hz⟩
suffices ∀ᶠ r in 𝓝[<] R₁, ‖dslope f c z‖ ≤ R₂ / r by
refine ge_of_tendsto ?_ this
exact (tendsto_const_nhds.div tendsto_id hR₁.ne').mono_left nhdsWithin_le_nhds
rw [mem_ball] at hz
filter_upwards [Ioo_mem_nhdsWithin_Iio ⟨hz, le_rfl⟩] with r hr
have hr₀ : 0 < r := dist_nonneg.trans_lt hr.1
replace hd : DiffContOnCl ℂ (dslope f c) (ball c r) := by
refine DifferentiableOn.diffContOnCl ?_
rw [closure_ball c hr₀.ne']
exact ((differentiableOn_dslope <| ball_mem_nhds _ hR₁).mpr hd).mono
(closedBall_subset_ball hr.2)
refine norm_le_of_forall_mem_frontier_norm_le isBounded_ball hd ?_ ?_
· rw [frontier_ball c hr₀.ne']
intro z hz
have hz' : z ≠ c := ne_of_mem_sphere hz hr₀.ne'
rw [dslope_of_ne _ hz', slope_def_module, norm_smul, norm_inv, mem_sphere_iff_norm.1 hz, ←
div_eq_inv_mul, div_le_div_right hr₀, ← dist_eq_norm]
exact le_of_lt (h_maps (mem_ball.2 (by rw [mem_sphere.1 hz]; exact hr.2)))
· rw [closure_ball c hr₀.ne', mem_closedBall]
exact hr.1.le
#align complex.schwarz_aux Complex.schwarz_aux
theorem norm_dslope_le_div_of_mapsTo_ball (hd : DifferentiableOn ℂ f (ball c R₁))
(h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)) (hz : z ∈ ball c R₁) :
‖dslope f c z‖ ≤ R₂ / R₁ := by
have hR₁ : 0 < R₁ := nonempty_ball.1 ⟨z, hz⟩
have hR₂ : 0 < R₂ := nonempty_ball.1 ⟨f z, h_maps hz⟩
rcases eq_or_ne (dslope f c z) 0 with hc | hc
· rw [hc, norm_zero]; exact div_nonneg hR₂.le hR₁.le
rcases exists_dual_vector ℂ _ hc with ⟨g, hg, hgf⟩
have hg' : ‖g‖₊ = 1 := NNReal.eq hg
have hg₀ : ‖g‖₊ ≠ 0 := by simpa only [hg'] using one_ne_zero
calc
‖dslope f c z‖ = ‖dslope (g ∘ f) c z‖ := by
rw [g.dslope_comp, hgf, RCLike.norm_ofReal, abs_norm]
exact fun _ => hd.differentiableAt (ball_mem_nhds _ hR₁)
_ ≤ R₂ / R₁ := by
refine schwarz_aux (g.differentiable.comp_differentiableOn hd) (MapsTo.comp ?_ h_maps) hz
simpa only [hg', NNReal.coe_one, one_mul] using g.lipschitz.mapsTo_ball hg₀ (f c) R₂
#align complex.norm_dslope_le_div_of_maps_to_ball Complex.norm_dslope_le_div_of_mapsTo_ball
| Mathlib/Analysis/Complex/Schwarz.lean | 113 | 130 | theorem affine_of_mapsTo_ball_of_exists_norm_dslope_eq_div [CompleteSpace E] [StrictConvexSpace ℝ E]
(hd : DifferentiableOn ℂ f (ball c R₁)) (h_maps : Set.MapsTo f (ball c R₁) (ball (f c) R₂))
(h_z₀ : z₀ ∈ ball c R₁) (h_eq : ‖dslope f c z₀‖ = R₂ / R₁) :
Set.EqOn f (fun z => f c + (z - c) • dslope f c z₀) (ball c R₁) := by |
set g := dslope f c
rintro z hz
by_cases h : z = c; · simp [h]
have h_R₁ : 0 < R₁ := nonempty_ball.mp ⟨_, h_z₀⟩
have g_le_div : ∀ z ∈ ball c R₁, ‖g z‖ ≤ R₂ / R₁ := fun z hz =>
norm_dslope_le_div_of_mapsTo_ball hd h_maps hz
have g_max : IsMaxOn (norm ∘ g) (ball c R₁) z₀ :=
isMaxOn_iff.mpr fun z hz => by simpa [h_eq] using g_le_div z hz
have g_diff : DifferentiableOn ℂ g (ball c R₁) :=
(differentiableOn_dslope (isOpen_ball.mem_nhds (mem_ball_self h_R₁))).mpr hd
have : g z = g z₀ := eqOn_of_isPreconnected_of_isMaxOn_norm (convex_ball c R₁).isPreconnected
isOpen_ball g_diff h_z₀ g_max hz
simp [g] at this
simp [g, ← this]
| 14 |
import Mathlib.Analysis.Calculus.Deriv.Inv
import Mathlib.Analysis.NormedSpace.BallAction
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
import Mathlib.Analysis.InnerProductSpace.Calculus
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Geometry.Manifold.Algebra.LieGroup
import Mathlib.Geometry.Manifold.Instances.Real
import Mathlib.Geometry.Manifold.MFDeriv.Basic
#align_import geometry.manifold.instances.sphere from "leanprover-community/mathlib"@"0dc4079202c28226b2841a51eb6d3cc2135bb80f"
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
noncomputable section
open Metric FiniteDimensional Function
open scoped Manifold
section StereographicProjection
variable (v : E)
def stereoToFun (x : E) : (ℝ ∙ v)ᗮ :=
(2 / ((1 : ℝ) - innerSL ℝ v x)) • orthogonalProjection (ℝ ∙ v)ᗮ x
#align stereo_to_fun stereoToFun
variable {v}
@[simp]
theorem stereoToFun_apply (x : E) :
stereoToFun v x = (2 / ((1 : ℝ) - innerSL ℝ v x)) • orthogonalProjection (ℝ ∙ v)ᗮ x :=
rfl
#align stereo_to_fun_apply stereoToFun_apply
theorem contDiffOn_stereoToFun :
ContDiffOn ℝ ⊤ (stereoToFun v) {x : E | innerSL _ v x ≠ (1 : ℝ)} := by
refine ContDiffOn.smul ?_ (orthogonalProjection (ℝ ∙ v)ᗮ).contDiff.contDiffOn
refine contDiff_const.contDiffOn.div ?_ ?_
· exact (contDiff_const.sub (innerSL ℝ v).contDiff).contDiffOn
· intro x h h'
exact h (sub_eq_zero.mp h').symm
#align cont_diff_on_stereo_to_fun contDiffOn_stereoToFun
theorem continuousOn_stereoToFun :
ContinuousOn (stereoToFun v) {x : E | innerSL _ v x ≠ (1 : ℝ)} :=
contDiffOn_stereoToFun.continuousOn
#align continuous_on_stereo_to_fun continuousOn_stereoToFun
variable (v)
def stereoInvFunAux (w : E) : E :=
(‖w‖ ^ 2 + 4)⁻¹ • ((4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v)
#align stereo_inv_fun_aux stereoInvFunAux
variable {v}
@[simp]
theorem stereoInvFunAux_apply (w : E) :
stereoInvFunAux v w = (‖w‖ ^ 2 + 4)⁻¹ • ((4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v) :=
rfl
#align stereo_inv_fun_aux_apply stereoInvFunAux_apply
theorem stereoInvFunAux_mem (hv : ‖v‖ = 1) {w : E} (hw : w ∈ (ℝ ∙ v)ᗮ) :
stereoInvFunAux v w ∈ sphere (0 : E) 1 := by
have h₁ : (0 : ℝ) < ‖w‖ ^ 2 + 4 := by positivity
suffices ‖(4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v‖ = ‖w‖ ^ 2 + 4 by
simp only [mem_sphere_zero_iff_norm, norm_smul, Real.norm_eq_abs, abs_inv, this,
abs_of_pos h₁, stereoInvFunAux_apply, inv_mul_cancel h₁.ne']
suffices ‖(4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v‖ ^ 2 = (‖w‖ ^ 2 + 4) ^ 2 by
simpa [sq_eq_sq_iff_abs_eq_abs, abs_of_pos h₁] using this
rw [Submodule.mem_orthogonal_singleton_iff_inner_left] at hw
simp [norm_add_sq_real, norm_smul, inner_smul_left, inner_smul_right, hw, mul_pow,
Real.norm_eq_abs, hv]
ring
#align stereo_inv_fun_aux_mem stereoInvFunAux_mem
| Mathlib/Geometry/Manifold/Instances/Sphere.lean | 145 | 160 | theorem hasFDerivAt_stereoInvFunAux (v : E) :
HasFDerivAt (stereoInvFunAux v) (ContinuousLinearMap.id ℝ E) 0 := by |
have h₀ : HasFDerivAt (fun w : E => ‖w‖ ^ 2) (0 : E →L[ℝ] ℝ) 0 := by
convert (hasStrictFDerivAt_norm_sq (0 : E)).hasFDerivAt
simp
have h₁ : HasFDerivAt (fun w : E => (‖w‖ ^ 2 + 4)⁻¹) (0 : E →L[ℝ] ℝ) 0 := by
convert (hasFDerivAt_inv _).comp _ (h₀.add (hasFDerivAt_const 4 0)) <;> simp
have h₂ : HasFDerivAt (fun w => (4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v)
((4 : ℝ) • ContinuousLinearMap.id ℝ E) 0 := by
convert ((hasFDerivAt_const (4 : ℝ) 0).smul (hasFDerivAt_id 0)).add
((h₀.sub (hasFDerivAt_const (4 : ℝ) 0)).smul (hasFDerivAt_const v 0)) using 1
ext w
simp
convert h₁.smul h₂ using 1
ext w
simp
| 14 |
import Mathlib.Data.Fintype.Basic
import Mathlib.ModelTheory.Substructures
#align_import model_theory.elementary_maps from "leanprover-community/mathlib"@"d11893b411025250c8e61ff2f12ccbd7ee35ab15"
open FirstOrder
namespace FirstOrder
namespace Language
open Structure
variable (L : Language) (M : Type*) (N : Type*) {P : Type*} {Q : Type*}
variable [L.Structure M] [L.Structure N] [L.Structure P] [L.Structure Q]
structure ElementaryEmbedding where
toFun : M → N
-- Porting note:
-- The autoparam here used to be `obviously`. We would like to replace it with `aesop`
-- but that isn't currently sufficient.
-- See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Aesop.20and.20cases
-- If that can be improved, we should change this to `by aesop` and remove the proofs below.
map_formula' :
∀ ⦃n⦄ (φ : L.Formula (Fin n)) (x : Fin n → M), φ.Realize (toFun ∘ x) ↔ φ.Realize x := by
intros; trivial
#align first_order.language.elementary_embedding FirstOrder.Language.ElementaryEmbedding
#align first_order.language.elementary_embedding.to_fun FirstOrder.Language.ElementaryEmbedding.toFun
#align first_order.language.elementary_embedding.map_formula' FirstOrder.Language.ElementaryEmbedding.map_formula'
@[inherit_doc FirstOrder.Language.ElementaryEmbedding]
scoped[FirstOrder] notation:25 A " ↪ₑ[" L "] " B => FirstOrder.Language.ElementaryEmbedding L A B
variable {L} {M} {N}
namespace ElementaryEmbedding
attribute [coe] toFun
instance instFunLike : FunLike (M ↪ₑ[L] N) M N where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
simp only [ElementaryEmbedding.mk.injEq]
ext x
exact Function.funext_iff.1 h x
#align first_order.language.elementary_embedding.fun_like FirstOrder.Language.ElementaryEmbedding.instFunLike
instance : CoeFun (M ↪ₑ[L] N) fun _ => M → N :=
DFunLike.hasCoeToFun
@[simp]
| Mathlib/ModelTheory/ElementaryMaps.lean | 78 | 94 | theorem map_boundedFormula (f : M ↪ₑ[L] N) {α : Type*} {n : ℕ} (φ : L.BoundedFormula α n)
(v : α → M) (xs : Fin n → M) : φ.Realize (f ∘ v) (f ∘ xs) ↔ φ.Realize v xs := by |
classical
rw [← BoundedFormula.realize_restrictFreeVar Set.Subset.rfl, Set.inclusion_eq_id, iff_eq_eq]
have h :=
f.map_formula' ((φ.restrictFreeVar id).toFormula.relabel (Fintype.equivFin _))
(Sum.elim (v ∘ (↑)) xs ∘ (Fintype.equivFin _).symm)
simp only [Formula.realize_relabel, BoundedFormula.realize_toFormula, iff_eq_eq] at h
rw [← Function.comp.assoc _ _ (Fintype.equivFin _).symm,
Function.comp.assoc _ (Fintype.equivFin _).symm (Fintype.equivFin _),
_root_.Equiv.symm_comp_self, Function.comp_id, Function.comp.assoc, Sum.elim_comp_inl,
Function.comp.assoc _ _ Sum.inr, Sum.elim_comp_inr, ← Function.comp.assoc] at h
refine h.trans ?_
erw [Function.comp.assoc _ _ (Fintype.equivFin _), _root_.Equiv.symm_comp_self,
Function.comp_id, Sum.elim_comp_inl, Sum.elim_comp_inr (v ∘ Subtype.val) xs,
← Set.inclusion_eq_id (s := (BoundedFormula.freeVarFinset φ : Set α)) Set.Subset.rfl,
BoundedFormula.realize_restrictFreeVar Set.Subset.rfl]
| 15 |
import Mathlib.Data.Matrix.Basic
import Mathlib.Data.PEquiv
#align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1"
namespace PEquiv
open Matrix
universe u v
variable {k l m n : Type*}
variable {α : Type v}
open Matrix
def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α :=
of fun i j => if j ∈ f i then (1 : α) else 0
#align pequiv.to_matrix PEquiv.toMatrix
-- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024
@[simp]
theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) :
toMatrix f i j = if j ∈ f i then (1 : α) else 0 :=
rfl
#align pequiv.to_matrix_apply PEquiv.toMatrix_apply
theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α)
(i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by
dsimp [toMatrix, Matrix.mul_apply]
cases' h : f i with fi
· simp [h]
· rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm]
#align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply
theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) :
(f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by
ext
simp only [transpose, mem_iff_mem f, toMatrix_apply]
congr
#align pequiv.to_matrix_symm PEquiv.toMatrix_symm
@[simp]
theorem toMatrix_refl [DecidableEq n] [Zero α] [One α] :
((PEquiv.refl n).toMatrix : Matrix n n α) = 1 := by
ext
simp [toMatrix_apply, one_apply]
#align pequiv.to_matrix_refl PEquiv.toMatrix_refl
theorem matrix_mul_apply [Fintype m] [Semiring α] [DecidableEq n] (M : Matrix l m α) (f : m ≃. n)
(i j) : (M * f.toMatrix :) i j = Option.casesOn (f.symm j) 0 fun fj => M i fj := by
dsimp [toMatrix, Matrix.mul_apply]
cases' h : f.symm j with fj
· simp [h, ← f.eq_some_iff]
· rw [Finset.sum_eq_single fj]
· simp [h, ← f.eq_some_iff]
· rintro b - n
simp [h, ← f.eq_some_iff, n.symm]
· simp
#align pequiv.matrix_mul_apply PEquiv.matrix_mul_apply
theorem toPEquiv_mul_matrix [Fintype m] [DecidableEq m] [Semiring α] (f : m ≃ m)
(M : Matrix m n α) : f.toPEquiv.toMatrix * M = M.submatrix f id := by
ext i j
rw [mul_matrix_apply, Equiv.toPEquiv_apply, submatrix_apply, id]
#align pequiv.to_pequiv_mul_matrix PEquiv.toPEquiv_mul_matrix
theorem mul_toPEquiv_toMatrix {m n α : Type*} [Fintype n] [DecidableEq n] [Semiring α] (f : n ≃ n)
(M : Matrix m n α) : M * f.toPEquiv.toMatrix = M.submatrix id f.symm :=
Matrix.ext fun i j => by
rw [PEquiv.matrix_mul_apply, ← Equiv.toPEquiv_symm, Equiv.toPEquiv_apply,
Matrix.submatrix_apply, id]
#align pequiv.mul_to_pequiv_to_matrix PEquiv.mul_toPEquiv_toMatrix
theorem toMatrix_trans [Fintype m] [DecidableEq m] [DecidableEq n] [Semiring α] (f : l ≃. m)
(g : m ≃. n) : ((f.trans g).toMatrix : Matrix l n α) = f.toMatrix * g.toMatrix := by
ext i j
rw [mul_matrix_apply]
dsimp [toMatrix, PEquiv.trans]
cases f i <;> simp
#align pequiv.to_matrix_trans PEquiv.toMatrix_trans
@[simp]
theorem toMatrix_bot [DecidableEq n] [Zero α] [One α] :
((⊥ : PEquiv m n).toMatrix : Matrix m n α) = 0 :=
rfl
#align pequiv.to_matrix_bot PEquiv.toMatrix_bot
| Mathlib/Data/Matrix/PEquiv.lean | 123 | 139 | theorem toMatrix_injective [DecidableEq n] [MonoidWithZero α] [Nontrivial α] :
Function.Injective (@toMatrix m n α _ _ _) := by |
classical
intro f g
refine not_imp_not.1 ?_
simp only [Matrix.ext_iff.symm, toMatrix_apply, PEquiv.ext_iff, not_forall, exists_imp]
intro i hi
use i
cases' hf : f i with fi
· cases' hg : g i with gi
-- Porting note: was `cc`
· rw [hf, hg] at hi
exact (hi rfl).elim
· use gi
simp
· use fi
simp [hf.symm, Ne.symm hi]
| 15 |
import Mathlib.Algebra.MonoidAlgebra.Degree
import Mathlib.Algebra.MvPolynomial.Rename
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
#align_import data.mv_polynomial.variables from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4"
noncomputable section
open Set Function Finsupp AddMonoidAlgebra
universe u v w
variable {R : Type u} {S : Type v}
namespace MvPolynomial
variable {σ τ : Type*} {r : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ}
section CommSemiring
variable [CommSemiring R] {p q : MvPolynomial σ R}
section Degrees
def degrees (p : MvPolynomial σ R) : Multiset σ :=
letI := Classical.decEq σ
p.support.sup fun s : σ →₀ ℕ => toMultiset s
#align mv_polynomial.degrees MvPolynomial.degrees
theorem degrees_def [DecidableEq σ] (p : MvPolynomial σ R) :
p.degrees = p.support.sup fun s : σ →₀ ℕ => Finsupp.toMultiset s := by rw [degrees]; convert rfl
#align mv_polynomial.degrees_def MvPolynomial.degrees_def
theorem degrees_monomial (s : σ →₀ ℕ) (a : R) : degrees (monomial s a) ≤ toMultiset s := by
classical
refine (supDegree_single s a).trans_le ?_
split_ifs
exacts [bot_le, le_rfl]
#align mv_polynomial.degrees_monomial MvPolynomial.degrees_monomial
theorem degrees_monomial_eq (s : σ →₀ ℕ) (a : R) (ha : a ≠ 0) :
degrees (monomial s a) = toMultiset s := by
classical
exact (supDegree_single s a).trans (if_neg ha)
#align mv_polynomial.degrees_monomial_eq MvPolynomial.degrees_monomial_eq
theorem degrees_C (a : R) : degrees (C a : MvPolynomial σ R) = 0 :=
Multiset.le_zero.1 <| degrees_monomial _ _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.degrees_C MvPolynomial.degrees_C
theorem degrees_X' (n : σ) : degrees (X n : MvPolynomial σ R) ≤ {n} :=
le_trans (degrees_monomial _ _) <| le_of_eq <| toMultiset_single _ _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.degrees_X' MvPolynomial.degrees_X'
@[simp]
theorem degrees_X [Nontrivial R] (n : σ) : degrees (X n : MvPolynomial σ R) = {n} :=
(degrees_monomial_eq _ (1 : R) one_ne_zero).trans (toMultiset_single _ _)
set_option linter.uppercaseLean3 false in
#align mv_polynomial.degrees_X MvPolynomial.degrees_X
@[simp]
theorem degrees_zero : degrees (0 : MvPolynomial σ R) = 0 := by
rw [← C_0]
exact degrees_C 0
#align mv_polynomial.degrees_zero MvPolynomial.degrees_zero
@[simp]
theorem degrees_one : degrees (1 : MvPolynomial σ R) = 0 :=
degrees_C 1
#align mv_polynomial.degrees_one MvPolynomial.degrees_one
theorem degrees_add [DecidableEq σ] (p q : MvPolynomial σ R) :
(p + q).degrees ≤ p.degrees ⊔ q.degrees := by
simp_rw [degrees_def]; exact supDegree_add_le
#align mv_polynomial.degrees_add MvPolynomial.degrees_add
theorem degrees_sum {ι : Type*} [DecidableEq σ] (s : Finset ι) (f : ι → MvPolynomial σ R) :
(∑ i ∈ s, f i).degrees ≤ s.sup fun i => (f i).degrees := by
simp_rw [degrees_def]; exact supDegree_sum_le
#align mv_polynomial.degrees_sum MvPolynomial.degrees_sum
theorem degrees_mul (p q : MvPolynomial σ R) : (p * q).degrees ≤ p.degrees + q.degrees := by
classical
simp_rw [degrees_def]
exact supDegree_mul_le (map_add _)
#align mv_polynomial.degrees_mul MvPolynomial.degrees_mul
theorem degrees_prod {ι : Type*} (s : Finset ι) (f : ι → MvPolynomial σ R) :
(∏ i ∈ s, f i).degrees ≤ ∑ i ∈ s, (f i).degrees := by
classical exact supDegree_prod_le (map_zero _) (map_add _)
#align mv_polynomial.degrees_prod MvPolynomial.degrees_prod
theorem degrees_pow (p : MvPolynomial σ R) (n : ℕ) : (p ^ n).degrees ≤ n • p.degrees := by
simpa using degrees_prod (Finset.range n) fun _ ↦ p
#align mv_polynomial.degrees_pow MvPolynomial.degrees_pow
theorem mem_degrees {p : MvPolynomial σ R} {i : σ} :
i ∈ p.degrees ↔ ∃ d, p.coeff d ≠ 0 ∧ i ∈ d.support := by
classical
simp only [degrees_def, Multiset.mem_sup, ← mem_support_iff, Finsupp.mem_toMultiset, exists_prop]
#align mv_polynomial.mem_degrees MvPolynomial.mem_degrees
| Mathlib/Algebra/MvPolynomial/Degrees.lean | 159 | 175 | theorem le_degrees_add {p q : MvPolynomial σ R} (h : p.degrees.Disjoint q.degrees) :
p.degrees ≤ (p + q).degrees := by |
classical
apply Finset.sup_le
intro d hd
rw [Multiset.disjoint_iff_ne] at h
obtain rfl | h0 := eq_or_ne d 0
· rw [toMultiset_zero]; apply Multiset.zero_le
· refine Finset.le_sup_of_le (b := d) ?_ le_rfl
rw [mem_support_iff, coeff_add]
suffices q.coeff d = 0 by rwa [this, add_zero, coeff, ← Finsupp.mem_support_iff]
rw [Ne, ← Finsupp.support_eq_empty, ← Ne, ← Finset.nonempty_iff_ne_empty] at h0
obtain ⟨j, hj⟩ := h0
contrapose! h
rw [mem_support_iff] at hd
refine ⟨j, ?_, j, ?_, rfl⟩
all_goals rw [mem_degrees]; refine ⟨d, ?_, hj⟩; assumption
| 15 |
import Mathlib.Algebra.ContinuedFractions.Computation.Approximations
import Mathlib.Algebra.ContinuedFractions.Computation.CorrectnessTerminating
import Mathlib.Data.Rat.Floor
#align_import algebra.continued_fractions.computation.terminates_iff_rat from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
namespace GeneralizedContinuedFraction
open GeneralizedContinuedFraction (of)
variable {K : Type*} [LinearOrderedField K] [FloorRing K]
attribute [local simp] Pair.map IntFractPair.mapFr
section RatTranslation
-- The lifting works for arbitrary linear ordered fields with a floor function.
variable {v : K} {q : ℚ} (v_eq_q : v = (↑q : K)) (n : ℕ)
section TerminatesOfRat
namespace IntFractPair
variable {q : ℚ} {n : ℕ}
theorem of_inv_fr_num_lt_num_of_pos (q_pos : 0 < q) : (IntFractPair.of q⁻¹).fr.num < q.num :=
Rat.fract_inv_num_lt_num_of_pos q_pos
#align generalized_continued_fraction.int_fract_pair.of_inv_fr_num_lt_num_of_pos GeneralizedContinuedFraction.IntFractPair.of_inv_fr_num_lt_num_of_pos
theorem stream_succ_nth_fr_num_lt_nth_fr_num_rat {ifp_n ifp_succ_n : IntFractPair ℚ}
(stream_nth_eq : IntFractPair.stream q n = some ifp_n)
(stream_succ_nth_eq : IntFractPair.stream q (n + 1) = some ifp_succ_n) :
ifp_succ_n.fr.num < ifp_n.fr.num := by
obtain ⟨ifp_n', stream_nth_eq', ifp_n_fract_ne_zero, IntFractPair.of_eq_ifp_succ_n⟩ :
∃ ifp_n',
IntFractPair.stream q n = some ifp_n' ∧
ifp_n'.fr ≠ 0 ∧ IntFractPair.of ifp_n'.fr⁻¹ = ifp_succ_n :=
succ_nth_stream_eq_some_iff.mp stream_succ_nth_eq
have : ifp_n = ifp_n' := by injection Eq.trans stream_nth_eq.symm stream_nth_eq'
cases this
rw [← IntFractPair.of_eq_ifp_succ_n]
cases' nth_stream_fr_nonneg_lt_one stream_nth_eq with zero_le_ifp_n_fract ifp_n_fract_lt_one
have : 0 < ifp_n.fr := lt_of_le_of_ne zero_le_ifp_n_fract <| ifp_n_fract_ne_zero.symm
exact of_inv_fr_num_lt_num_of_pos this
#align generalized_continued_fraction.int_fract_pair.stream_succ_nth_fr_num_lt_nth_fr_num_rat GeneralizedContinuedFraction.IntFractPair.stream_succ_nth_fr_num_lt_nth_fr_num_rat
| Mathlib/Algebra/ContinuedFractions/Computation/TerminatesIffRat.lean | 295 | 312 | theorem stream_nth_fr_num_le_fr_num_sub_n_rat :
∀ {ifp_n : IntFractPair ℚ},
IntFractPair.stream q n = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - n := by |
induction n with
| zero =>
intro ifp_zero stream_zero_eq
have : IntFractPair.of q = ifp_zero := by injection stream_zero_eq
simp [le_refl, this.symm]
| succ n IH =>
intro ifp_succ_n stream_succ_nth_eq
suffices ifp_succ_n.fr.num + 1 ≤ (IntFractPair.of q).fr.num - n by
rw [Int.ofNat_succ, sub_add_eq_sub_sub]
solve_by_elim [le_sub_right_of_add_le]
rcases succ_nth_stream_eq_some_iff.mp stream_succ_nth_eq with ⟨ifp_n, stream_nth_eq, -⟩
have : ifp_succ_n.fr.num < ifp_n.fr.num :=
stream_succ_nth_fr_num_lt_nth_fr_num_rat stream_nth_eq stream_succ_nth_eq
have : ifp_succ_n.fr.num + 1 ≤ ifp_n.fr.num := Int.add_one_le_of_lt this
exact le_trans this (IH stream_nth_eq)
| 15 |
import Mathlib.Analysis.Convex.Body
import Mathlib.Analysis.Convex.Measure
import Mathlib.MeasureTheory.Group.FundamentalDomain
#align_import measure_theory.group.geometry_of_numbers from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
namespace MeasureTheory
open ENNReal FiniteDimensional MeasureTheory MeasureTheory.Measure Set Filter
open scoped Pointwise NNReal
variable {E L : Type*} [MeasurableSpace E] {μ : Measure E} {F s : Set E}
theorem exists_pair_mem_lattice_not_disjoint_vadd [AddCommGroup L] [Countable L] [AddAction L E]
[MeasurableSpace L] [MeasurableVAdd L E] [VAddInvariantMeasure L E μ]
(fund : IsAddFundamentalDomain L F μ) (hS : NullMeasurableSet s μ) (h : μ F < μ s) :
∃ x y : L, x ≠ y ∧ ¬Disjoint (x +ᵥ s) (y +ᵥ s) := by
contrapose! h
exact ((fund.measure_eq_tsum _).trans (measure_iUnion₀
(Pairwise.mono h fun i j hij => (hij.mono inf_le_left inf_le_left).aedisjoint)
fun _ => (hS.vadd _).inter fund.nullMeasurableSet).symm).trans_le
(measure_mono <| Set.iUnion_subset fun _ => Set.inter_subset_right)
#align measure_theory.exists_pair_mem_lattice_not_disjoint_vadd MeasureTheory.exists_pair_mem_lattice_not_disjoint_vadd
| Mathlib/MeasureTheory/Group/GeometryOfNumbers.lean | 64 | 83 | theorem exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure [NormedAddCommGroup E]
[NormedSpace ℝ E] [BorelSpace E] [FiniteDimensional ℝ E] [IsAddHaarMeasure μ]
{L : AddSubgroup E} [Countable L] (fund : IsAddFundamentalDomain L F μ)
(h_symm : ∀ x ∈ s, -x ∈ s) (h_conv : Convex ℝ s) (h : μ F * 2 ^ finrank ℝ E < μ s) :
∃ x ≠ 0, ((x : L) : E) ∈ s := by |
have h_vol : μ F < μ ((2⁻¹ : ℝ) • s) := by
rw [addHaar_smul_of_nonneg μ (by norm_num : 0 ≤ (2 : ℝ)⁻¹) s, ←
mul_lt_mul_right (pow_ne_zero (finrank ℝ E) (two_ne_zero' _)) (pow_ne_top two_ne_top),
mul_right_comm, ofReal_pow (by norm_num : 0 ≤ (2 : ℝ)⁻¹), ofReal_inv_of_pos zero_lt_two]
norm_num
rwa [← mul_pow, ENNReal.inv_mul_cancel two_ne_zero two_ne_top, one_pow, one_mul]
obtain ⟨x, y, hxy, h⟩ :=
exists_pair_mem_lattice_not_disjoint_vadd fund ((h_conv.smul _).nullMeasurableSet _) h_vol
obtain ⟨_, ⟨v, hv, rfl⟩, w, hw, hvw⟩ := Set.not_disjoint_iff.mp h
refine ⟨x - y, sub_ne_zero.2 hxy, ?_⟩
rw [Set.mem_inv_smul_set_iff₀ (two_ne_zero' ℝ)] at hv hw
simp_rw [AddSubgroup.vadd_def, vadd_eq_add, add_comm _ w, ← sub_eq_sub_iff_add_eq_add, ←
AddSubgroup.coe_sub] at hvw
rw [← hvw, ← inv_smul_smul₀ (two_ne_zero' ℝ) (_ - _), smul_sub, sub_eq_add_neg, smul_add]
refine h_conv hw (h_symm _ hv) ?_ ?_ ?_ <;> norm_num
| 15 |
import Mathlib.Geometry.Euclidean.Sphere.Power
import Mathlib.Geometry.Euclidean.Triangle
#align_import geometry.euclidean.sphere.ptolemy from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
open Real
open scoped EuclideanGeometry RealInnerProductSpace Real
namespace EuclideanGeometry
variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]
variable {P : Type*} [MetricSpace P] [NormedAddTorsor V P]
| Mathlib/Geometry/Euclidean/Sphere/Ptolemy.lean | 53 | 70 | theorem mul_dist_add_mul_dist_eq_mul_dist_of_cospherical {a b c d p : P}
(h : Cospherical ({a, b, c, d} : Set P)) (hapc : ∠ a p c = π) (hbpd : ∠ b p d = π) :
dist a b * dist c d + dist b c * dist d a = dist a c * dist b d := by |
have h' : Cospherical ({a, c, b, d} : Set P) := by rwa [Set.insert_comm c b {d}]
have hmul := mul_dist_eq_mul_dist_of_cospherical_of_angle_eq_pi h' hapc hbpd
have hbp := left_dist_ne_zero_of_angle_eq_pi hbpd
have h₁ : dist c d = dist c p / dist b p * dist a b := by
rw [dist_mul_of_eq_angle_of_dist_mul b p a c p d, dist_comm a b]
· rw [angle_eq_angle_of_angle_eq_pi_of_angle_eq_pi hbpd hapc, angle_comm]
all_goals field_simp [mul_comm, hmul]
have h₂ : dist d a = dist a p / dist b p * dist b c := by
rw [dist_mul_of_eq_angle_of_dist_mul c p b d p a, dist_comm c b]
· rwa [angle_comm, angle_eq_angle_of_angle_eq_pi_of_angle_eq_pi]; rwa [angle_comm]
all_goals field_simp [mul_comm, hmul]
have h₃ : dist d p = dist a p * dist c p / dist b p := by field_simp [mul_comm, hmul]
have h₄ : ∀ x y : ℝ, x * (y * x) = x * x * y := fun x y => by rw [mul_left_comm, mul_comm]
field_simp [h₁, h₂, dist_eq_add_dist_of_angle_eq_pi hbpd, h₃, hbp, dist_comm a b, h₄, ← sq,
dist_sq_mul_dist_add_dist_sq_mul_dist b, hapc]
| 15 |
import Mathlib.Algebra.Order.Group.TypeTags
import Mathlib.FieldTheory.RatFunc.Degree
import Mathlib.RingTheory.DedekindDomain.IntegralClosure
import Mathlib.RingTheory.IntegrallyClosed
import Mathlib.Topology.Algebra.ValuedField
#align_import number_theory.function_field from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
noncomputable section
open scoped nonZeroDivisors Polynomial DiscreteValuation
variable (Fq F : Type) [Field Fq] [Field F]
abbrev FunctionField [Algebra (RatFunc Fq) F] : Prop :=
FiniteDimensional (RatFunc Fq) F
#align function_field FunctionField
-- Porting note: Removed `protected`
| Mathlib/NumberTheory/FunctionField.lean | 62 | 80 | theorem functionField_iff (Fqt : Type*) [Field Fqt] [Algebra Fq[X] Fqt]
[IsFractionRing Fq[X] Fqt] [Algebra (RatFunc Fq) F] [Algebra Fqt F] [Algebra Fq[X] F]
[IsScalarTower Fq[X] Fqt F] [IsScalarTower Fq[X] (RatFunc Fq) F] :
FunctionField Fq F ↔ FiniteDimensional Fqt F := by |
let e := IsLocalization.algEquiv Fq[X]⁰ (RatFunc Fq) Fqt
have : ∀ (c) (x : F), e c • x = c • x := by
intro c x
rw [Algebra.smul_def, Algebra.smul_def]
congr
refine congr_fun (f := fun c => algebraMap Fqt F (e c)) ?_ c -- Porting note: Added `(f := _)`
refine IsLocalization.ext (nonZeroDivisors Fq[X]) _ _ ?_ ?_ ?_ ?_ ?_ <;> intros <;>
simp only [AlgEquiv.map_one, RingHom.map_one, AlgEquiv.map_mul, RingHom.map_mul,
AlgEquiv.commutes, ← IsScalarTower.algebraMap_apply]
constructor <;> intro h
· let b := FiniteDimensional.finBasis (RatFunc Fq) F
exact FiniteDimensional.of_fintype_basis (b.mapCoeffs e this)
· let b := FiniteDimensional.finBasis Fqt F
refine FiniteDimensional.of_fintype_basis (b.mapCoeffs e.symm ?_)
intro c x; convert (this (e.symm c) x).symm; simp only [e.apply_symm_apply]
| 15 |
import Mathlib.RingTheory.FiniteType
import Mathlib.RingTheory.Localization.AtPrime
import Mathlib.RingTheory.Localization.Away.Basic
import Mathlib.RingTheory.Localization.Integer
import Mathlib.RingTheory.Localization.Submodule
import Mathlib.RingTheory.Nilpotent.Lemmas
import Mathlib.RingTheory.RingHomProperties
import Mathlib.Data.Set.Subsingleton
#align_import ring_theory.local_properties from "leanprover-community/mathlib"@"a7c017d750512a352b623b1824d75da5998457d0"
open scoped Pointwise Classical
universe u
variable {R S : Type u} [CommRing R] [CommRing S] (M : Submonoid R)
variable (N : Submonoid S) (R' S' : Type u) [CommRing R'] [CommRing S'] (f : R →+* S)
variable [Algebra R R'] [Algebra S S']
section Properties
section Ideal
open scoped nonZeroDivisors
| Mathlib/RingTheory/LocalProperties.lean | 236 | 255 | theorem Ideal.le_of_localization_maximal {I J : Ideal R}
(h : ∀ (P : Ideal R) (hP : P.IsMaximal),
Ideal.map (algebraMap R (Localization.AtPrime P)) I ≤
Ideal.map (algebraMap R (Localization.AtPrime P)) J) :
I ≤ J := by |
intro x hx
suffices J.colon (Ideal.span {x}) = ⊤ by
simpa using Submodule.mem_colon.mp
(show (1 : R) ∈ J.colon (Ideal.span {x}) from this.symm ▸ Submodule.mem_top) x
(Ideal.mem_span_singleton_self x)
refine Not.imp_symm (J.colon (Ideal.span {x})).exists_le_maximal ?_
push_neg
intro P hP le
obtain ⟨⟨⟨a, ha⟩, ⟨s, hs⟩⟩, eq⟩ :=
(IsLocalization.mem_map_algebraMap_iff P.primeCompl _).mp (h P hP (Ideal.mem_map_of_mem _ hx))
rw [← _root_.map_mul, ← sub_eq_zero, ← map_sub] at eq
obtain ⟨⟨m, hm⟩, eq⟩ := (IsLocalization.map_eq_zero_iff P.primeCompl _ _).mp eq
refine hs ((hP.isPrime.mem_or_mem (le (Ideal.mem_colon_singleton.mpr ?_))).resolve_right hm)
simp only [Subtype.coe_mk, mul_sub, sub_eq_zero, mul_comm x s, mul_left_comm] at eq
simpa only [mul_assoc, eq] using J.mul_mem_left m ha
| 15 |
import Mathlib.Algebra.Order.Field.Pi
import Mathlib.Algebra.Order.UpperLower
import Mathlib.Analysis.Normed.Group.Pointwise
import Mathlib.Analysis.Normed.Order.Basic
import Mathlib.Data.Real.Sqrt
import Mathlib.Topology.Algebra.Order.UpperLower
import Mathlib.Topology.MetricSpace.Sequences
#align_import analysis.normed.order.upper_lower from "leanprover-community/mathlib"@"b1abe23ae96fef89ad30d9f4362c307f72a55010"
open Bornology Function Metric Set
open scoped Pointwise
variable {α ι : Type*}
section Finite
variable [Finite ι] {s : Set (ι → ℝ)} {x y : ι → ℝ}
theorem IsUpperSet.mem_interior_of_forall_lt (hs : IsUpperSet s) (hx : x ∈ closure s)
(h : ∀ i, x i < y i) : y ∈ interior s := by
cases nonempty_fintype ι
obtain ⟨ε, hε, hxy⟩ := Pi.exists_forall_pos_add_lt h
obtain ⟨z, hz, hxz⟩ := Metric.mem_closure_iff.1 hx _ hε
rw [dist_pi_lt_iff hε] at hxz
have hyz : ∀ i, z i < y i := by
refine fun i => (hxy _).trans_le' (sub_le_iff_le_add'.1 <| (le_abs_self _).trans ?_)
rw [← Real.norm_eq_abs, ← dist_eq_norm']
exact (hxz _).le
obtain ⟨δ, hδ, hyz⟩ := Pi.exists_forall_pos_add_lt hyz
refine mem_interior.2 ⟨ball y δ, ?_, isOpen_ball, mem_ball_self hδ⟩
rintro w hw
refine hs (fun i => ?_) hz
simp_rw [ball_pi _ hδ, Real.ball_eq_Ioo] at hw
exact ((lt_sub_iff_add_lt.2 <| hyz _).trans (hw _ <| mem_univ _).1).le
#align is_upper_set.mem_interior_of_forall_lt IsUpperSet.mem_interior_of_forall_lt
| Mathlib/Analysis/Normed/Order/UpperLower.lean | 112 | 128 | theorem IsLowerSet.mem_interior_of_forall_lt (hs : IsLowerSet s) (hx : x ∈ closure s)
(h : ∀ i, y i < x i) : y ∈ interior s := by |
cases nonempty_fintype ι
obtain ⟨ε, hε, hxy⟩ := Pi.exists_forall_pos_add_lt h
obtain ⟨z, hz, hxz⟩ := Metric.mem_closure_iff.1 hx _ hε
rw [dist_pi_lt_iff hε] at hxz
have hyz : ∀ i, y i < z i := by
refine fun i =>
(lt_sub_iff_add_lt.2 <| hxy _).trans_le (sub_le_comm.1 <| (le_abs_self _).trans ?_)
rw [← Real.norm_eq_abs, ← dist_eq_norm]
exact (hxz _).le
obtain ⟨δ, hδ, hyz⟩ := Pi.exists_forall_pos_add_lt hyz
refine mem_interior.2 ⟨ball y δ, ?_, isOpen_ball, mem_ball_self hδ⟩
rintro w hw
refine hs (fun i => ?_) hz
simp_rw [ball_pi _ hδ, Real.ball_eq_Ioo] at hw
exact ((hw _ <| mem_univ _).2.trans <| hyz _).le
| 15 |
import Mathlib.Analysis.Calculus.Deriv.Slope
import Mathlib.MeasureTheory.Covering.OneDim
import Mathlib.Order.Monotone.Extension
#align_import analysis.calculus.monotone from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
open Set Filter Function Metric MeasureTheory MeasureTheory.Measure IsUnifLocDoublingMeasure
open scoped Topology
| Mathlib/Analysis/Calculus/Monotone.lean | 44 | 62 | theorem tendsto_apply_add_mul_sq_div_sub {f : ℝ → ℝ} {x a c d : ℝ} {l : Filter ℝ} (hl : l ≤ 𝓝[≠] x)
(hf : Tendsto (fun y => (f y - d) / (y - x)) l (𝓝 a))
(h' : Tendsto (fun y => y + c * (y - x) ^ 2) l l) :
Tendsto (fun y => (f (y + c * (y - x) ^ 2) - d) / (y - x)) l (𝓝 a) := by |
have L : Tendsto (fun y => (y + c * (y - x) ^ 2 - x) / (y - x)) l (𝓝 1) := by
have : Tendsto (fun y => 1 + c * (y - x)) l (𝓝 (1 + c * (x - x))) := by
apply Tendsto.mono_left _ (hl.trans nhdsWithin_le_nhds)
exact ((tendsto_id.sub_const x).const_mul c).const_add 1
simp only [_root_.sub_self, add_zero, mul_zero] at this
apply Tendsto.congr' (Eventually.filter_mono hl _) this
filter_upwards [self_mem_nhdsWithin] with y hy
field_simp [sub_ne_zero.2 hy]
ring
have Z := (hf.comp h').mul L
rw [mul_one] at Z
apply Tendsto.congr' _ Z
have : ∀ᶠ y in l, y + c * (y - x) ^ 2 ≠ x := by apply Tendsto.mono_right h' hl self_mem_nhdsWithin
filter_upwards [this] with y hy
field_simp [sub_ne_zero.2 hy]
| 15 |
import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic
import Mathlib.RingTheory.GradedAlgebra.Basic
#align_import linear_algebra.exterior_algebra.grading from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0"
namespace ExteriorAlgebra
variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M]
variable (R M)
open scoped DirectSum
-- Porting note: protected
protected def GradedAlgebra.ι :
M →ₗ[R] ⨁ i : ℕ, ⋀[R]^i M :=
DirectSum.lof R ℕ (fun i => ⋀[R]^i M) 1 ∘ₗ
(ι R).codRestrict _ fun m => by simpa only [pow_one] using LinearMap.mem_range_self _ m
#align exterior_algebra.graded_algebra.ι ExteriorAlgebra.GradedAlgebra.ι
theorem GradedAlgebra.ι_apply (m : M) :
GradedAlgebra.ι R M m =
DirectSum.of (fun i : ℕ => ⋀[R]^i M) 1
⟨ι R m, by simpa only [pow_one] using LinearMap.mem_range_self _ m⟩ :=
rfl
#align exterior_algebra.graded_algebra.ι_apply ExteriorAlgebra.GradedAlgebra.ι_apply
-- Defining this instance manually, because Lean doesn't seem to be able to synthesize it.
-- Strangely, this problem only appears when we use the abbreviation or notation for the
-- exterior powers.
instance : SetLike.GradedMonoid fun i : ℕ ↦ ⋀[R]^i M :=
Submodule.nat_power_gradedMonoid (LinearMap.range (ι R : M →ₗ[R] ExteriorAlgebra R M))
-- Porting note: Lean needs to be reminded of this instance otherwise it cannot
-- synthesize 0 in the next theorem
attribute [local instance 1100] MulZeroClass.toZero in
theorem GradedAlgebra.ι_sq_zero (m : M) : GradedAlgebra.ι R M m * GradedAlgebra.ι R M m = 0 := by
rw [GradedAlgebra.ι_apply, DirectSum.of_mul_of]
exact DFinsupp.single_eq_zero.mpr (Subtype.ext <| ExteriorAlgebra.ι_sq_zero _)
#align exterior_algebra.graded_algebra.ι_sq_zero ExteriorAlgebra.GradedAlgebra.ι_sq_zero
def GradedAlgebra.liftι :
ExteriorAlgebra R M →ₐ[R] ⨁ i : ℕ, ⋀[R]^i M :=
lift R ⟨by apply GradedAlgebra.ι R M, GradedAlgebra.ι_sq_zero R M⟩
#align exterior_algebra.graded_algebra.lift_ι ExteriorAlgebra.GradedAlgebra.liftι
| Mathlib/LinearAlgebra/ExteriorAlgebra/Grading.lean | 64 | 80 | theorem GradedAlgebra.liftι_eq (i : ℕ) (x : ⋀[R]^i M) :
GradedAlgebra.liftι R M x = DirectSum.of (fun i => ⋀[R]^i M) i x := by |
cases' x with x hx
dsimp only [Subtype.coe_mk, DirectSum.lof_eq_of]
-- Porting note: original statement was
-- refine Submodule.pow_induction_on_left' _ (fun r => ?_) (fun x y i hx hy ihx ihy => ?_)
-- (fun m hm i x hx ih => ?_) hx
-- but it created invalid goals
induction hx using Submodule.pow_induction_on_left' with
| algebraMap => simp_rw [AlgHom.commutes, DirectSum.algebraMap_apply]; rfl
-- FIXME: specialized `map_add` to avoid a (whole-declaration) timeout
| add _ _ _ _ _ ihx ihy => simp_rw [AlgHom.map_add, ihx, ihy, ← AddMonoidHom.map_add]; rfl
| mem_mul _ hm _ _ _ ih =>
obtain ⟨_, rfl⟩ := hm
simp_rw [AlgHom.map_mul, ih, GradedAlgebra.liftι, lift_ι_apply, GradedAlgebra.ι_apply R M,
DirectSum.of_mul_of]
exact DirectSum.of_eq_of_gradedMonoid_eq (Sigma.subtype_ext (add_comm _ _) rfl)
| 15 |
import Mathlib.MeasureTheory.Covering.VitaliFamily
import Mathlib.MeasureTheory.Measure.Regular
import Mathlib.MeasureTheory.Function.AEMeasurableOrder
import Mathlib.MeasureTheory.Integral.Lebesgue
import Mathlib.MeasureTheory.Integral.Average
import Mathlib.MeasureTheory.Decomposition.Lebesgue
#align_import measure_theory.covering.differentiation from "leanprover-community/mathlib"@"57ac39bd365c2f80589a700f9fbb664d3a1a30c2"
open MeasureTheory Metric Set Filter TopologicalSpace MeasureTheory.Measure
open scoped Filter ENNReal MeasureTheory NNReal Topology
variable {α : Type*} [MetricSpace α] {m0 : MeasurableSpace α} {μ : Measure α} (v : VitaliFamily μ)
{E : Type*} [NormedAddCommGroup E]
namespace VitaliFamily
noncomputable def limRatio (ρ : Measure α) (x : α) : ℝ≥0∞ :=
limUnder (v.filterAt x) fun a => ρ a / μ a
#align vitali_family.lim_ratio VitaliFamily.limRatio
| Mathlib/MeasureTheory/Covering/Differentiation.lean | 97 | 113 | theorem ae_eventually_measure_pos [SecondCountableTopology α] :
∀ᵐ x ∂μ, ∀ᶠ a in v.filterAt x, 0 < μ a := by |
set s := {x | ¬∀ᶠ a in v.filterAt x, 0 < μ a} with hs
simp (config := { zeta := false }) only [not_lt, not_eventually, nonpos_iff_eq_zero] at hs
change μ s = 0
let f : α → Set (Set α) := fun _ => {a | μ a = 0}
have h : v.FineSubfamilyOn f s := by
intro x hx ε εpos
rw [hs] at hx
simp only [frequently_filterAt_iff, exists_prop, gt_iff_lt, mem_setOf_eq] at hx
rcases hx ε εpos with ⟨a, a_sets, ax, μa⟩
exact ⟨a, ⟨a_sets, μa⟩, ax⟩
refine le_antisymm ?_ bot_le
calc
μ s ≤ ∑' x : h.index, μ (h.covering x) := h.measure_le_tsum
_ = ∑' x : h.index, 0 := by congr; ext1 x; exact h.covering_mem x.2
_ = 0 := by simp only [tsum_zero, add_zero]
| 15 |
import Mathlib.Analysis.Calculus.FDeriv.Prod
import Mathlib.Analysis.Calculus.InverseFunctionTheorem.FDeriv
import Mathlib.LinearAlgebra.Dual
#align_import analysis.calculus.lagrange_multipliers from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
open Filter Set
open scoped Topology Filter
variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
[NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {f : E → F} {φ : E → ℝ} {x₀ : E}
{f' : E →L[ℝ] F} {φ' : E →L[ℝ] ℝ}
theorem IsLocalExtrOn.range_ne_top_of_hasStrictFDerivAt
(hextr : IsLocalExtrOn φ {x | f x = f x₀} x₀) (hf' : HasStrictFDerivAt f f' x₀)
(hφ' : HasStrictFDerivAt φ φ' x₀) : LinearMap.range (f'.prod φ') ≠ ⊤ := by
intro htop
set fφ := fun x => (f x, φ x)
have A : map φ (𝓝[f ⁻¹' {f x₀}] x₀) = 𝓝 (φ x₀) := by
change map (Prod.snd ∘ fφ) (𝓝[fφ ⁻¹' {p | p.1 = f x₀}] x₀) = 𝓝 (φ x₀)
rw [← map_map, nhdsWithin, map_inf_principal_preimage, (hf'.prod hφ').map_nhds_eq_of_surj htop]
exact map_snd_nhdsWithin _
exact hextr.not_nhds_le_map A.ge
#align is_local_extr_on.range_ne_top_of_has_strict_fderiv_at IsLocalExtrOn.range_ne_top_of_hasStrictFDerivAt
| Mathlib/Analysis/Calculus/LagrangeMultipliers.lean | 60 | 78 | theorem IsLocalExtrOn.exists_linear_map_of_hasStrictFDerivAt
(hextr : IsLocalExtrOn φ {x | f x = f x₀} x₀) (hf' : HasStrictFDerivAt f f' x₀)
(hφ' : HasStrictFDerivAt φ φ' x₀) :
∃ (Λ : Module.Dual ℝ F) (Λ₀ : ℝ), (Λ, Λ₀) ≠ 0 ∧ ∀ x, Λ (f' x) + Λ₀ • φ' x = 0 := by |
rcases Submodule.exists_le_ker_of_lt_top _
(lt_top_iff_ne_top.2 <| hextr.range_ne_top_of_hasStrictFDerivAt hf' hφ') with
⟨Λ', h0, hΛ'⟩
set e : ((F →ₗ[ℝ] ℝ) × ℝ) ≃ₗ[ℝ] F × ℝ →ₗ[ℝ] ℝ :=
((LinearEquiv.refl ℝ (F →ₗ[ℝ] ℝ)).prod (LinearMap.ringLmapEquivSelf ℝ ℝ ℝ).symm).trans
(LinearMap.coprodEquiv ℝ)
rcases e.surjective Λ' with ⟨⟨Λ, Λ₀⟩, rfl⟩
refine ⟨Λ, Λ₀, e.map_ne_zero_iff.1 h0, fun x => ?_⟩
convert LinearMap.congr_fun (LinearMap.range_le_ker_iff.1 hΛ') x using 1
-- squeezed `simp [mul_comm]` to speed up elaboration
simp only [e, smul_eq_mul, LinearEquiv.trans_apply, LinearEquiv.prod_apply,
LinearEquiv.refl_apply, LinearMap.ringLmapEquivSelf_symm_apply, LinearMap.coprodEquiv_apply,
ContinuousLinearMap.coe_prod, LinearMap.coprod_comp_prod, LinearMap.add_apply,
LinearMap.coe_comp, ContinuousLinearMap.coe_coe, Function.comp_apply, LinearMap.coe_smulRight,
LinearMap.one_apply, mul_comm]
| 15 |
import Mathlib.CategoryTheory.EffectiveEpi.Preserves
import Mathlib.CategoryTheory.Limits.Final.ParallelPair
import Mathlib.CategoryTheory.Preadditive.Projective
import Mathlib.CategoryTheory.Sites.Canonical
import Mathlib.CategoryTheory.Sites.Coherent.Basic
import Mathlib.CategoryTheory.Sites.EffectiveEpimorphic
namespace CategoryTheory
open Limits
variable {C D E : Type*} [Category C] [Category D] [Category E]
open Opposite Presieve Functor
class Presieve.regular {X : C} (R : Presieve X) : Prop where
single_epi : ∃ (Y : C) (f : Y ⟶ X), R = Presieve.ofArrows (fun (_ : Unit) ↦ Y)
(fun (_ : Unit) ↦ f) ∧ EffectiveEpi f
namespace regularTopology
lemma equalizerCondition_w (P : Cᵒᵖ ⥤ D) {X B : C} {π : X ⟶ B} (c : PullbackCone π π) :
P.map π.op ≫ P.map c.fst.op = P.map π.op ≫ P.map c.snd.op := by
simp only [← Functor.map_comp, ← op_comp, c.condition]
def SingleEqualizerCondition (P : Cᵒᵖ ⥤ D) ⦃X B : C⦄ (π : X ⟶ B) : Prop :=
∀ (c : PullbackCone π π) (_ : IsLimit c),
Nonempty (IsLimit (Fork.ofι (P.map π.op) (equalizerCondition_w P c)))
def EqualizerCondition (P : Cᵒᵖ ⥤ D) : Prop :=
∀ ⦃X B : C⦄ (π : X ⟶ B) [EffectiveEpi π], SingleEqualizerCondition P π
theorem equalizerCondition_of_natIso {P P' : Cᵒᵖ ⥤ D} (i : P ≅ P')
(hP : EqualizerCondition P) : EqualizerCondition P' := fun X B π _ c hc ↦
⟨Fork.isLimitOfIsos _ (hP π c hc).some _ (i.app _) (i.app _) (i.app _)⟩
theorem equalizerCondition_precomp_of_preservesPullback (P : Cᵒᵖ ⥤ D) (F : E ⥤ C)
[∀ {X B} (π : X ⟶ B) [EffectiveEpi π], PreservesLimit (cospan π π) F]
[F.PreservesEffectiveEpis] (hP : EqualizerCondition P) : EqualizerCondition (F.op ⋙ P) := by
intro X B π _ c hc
have h : P.map (F.map π).op = (F.op ⋙ P).map π.op := by simp
refine ⟨(IsLimit.equivIsoLimit (ForkOfι.ext ?_ _ h)) ?_⟩
· simp only [Functor.comp_map, op_map, Quiver.Hom.unop_op, ← map_comp, ← op_comp, c.condition]
· refine (hP (F.map π) (PullbackCone.mk (F.map c.fst) (F.map c.snd) ?_) ?_).some
· simp only [← map_comp, c.condition]
· exact (isLimitMapConePullbackConeEquiv F c.condition)
(isLimitOfPreserves F (hc.ofIsoLimit (PullbackCone.ext (Iso.refl _) (by simp) (by simp))))
def MapToEqualizer (P : Cᵒᵖ ⥤ Type*) {W X B : C} (f : X ⟶ B)
(g₁ g₂ : W ⟶ X) (w : g₁ ≫ f = g₂ ≫ f) :
P.obj (op B) → { x : P.obj (op X) | P.map g₁.op x = P.map g₂.op x } := fun t ↦
⟨P.map f.op t, by simp only [Set.mem_setOf_eq, ← FunctorToTypes.map_comp_apply, ← op_comp, w]⟩
theorem EqualizerCondition.bijective_mapToEqualizer_pullback (P : Cᵒᵖ ⥤ Type*)
(hP : EqualizerCondition P) : ∀ (X B : C) (π : X ⟶ B) [EffectiveEpi π] [HasPullback π π],
Function.Bijective
(MapToEqualizer P π (pullback.fst (f := π) (g := π)) (pullback.snd (f := π) (g := π))
pullback.condition) := by
intro X B π _ _
specialize hP π _ (pullbackIsPullback π π)
rw [Types.type_equalizer_iff_unique] at hP
rw [Function.bijective_iff_existsUnique]
intro ⟨b, hb⟩
obtain ⟨a, ha₁, ha₂⟩ := hP b hb
refine ⟨a, ?_, ?_⟩
· simpa [MapToEqualizer] using ha₁
· simpa [MapToEqualizer] using ha₂
| Mathlib/CategoryTheory/Sites/Coherent/RegularSheaves.lean | 102 | 120 | theorem EqualizerCondition.mk (P : Cᵒᵖ ⥤ Type*)
(hP : ∀ (X B : C) (π : X ⟶ B) [EffectiveEpi π] [HasPullback π π], Function.Bijective
(MapToEqualizer P π (pullback.fst (f := π) (g := π)) (pullback.snd (f := π) (g := π))
pullback.condition)) : EqualizerCondition P := by |
intro X B π _ c hc
have : HasPullback π π := ⟨c, hc⟩
specialize hP X B π
rw [Types.type_equalizer_iff_unique]
rw [Function.bijective_iff_existsUnique] at hP
intro b hb
have h₁ : ((pullbackIsPullback π π).conePointUniqueUpToIso hc).hom ≫ c.fst =
pullback.fst (f := π) (g := π) := by simp
have hb' : P.map (pullback.fst (f := π) (g := π)).op b = P.map pullback.snd.op b := by
rw [← h₁, op_comp, FunctorToTypes.map_comp_apply, hb]
simp [← FunctorToTypes.map_comp_apply, ← op_comp]
obtain ⟨a, ha₁, ha₂⟩ := hP ⟨b, hb'⟩
refine ⟨a, ?_, ?_⟩
· simpa [MapToEqualizer] using ha₁
· simpa [MapToEqualizer] using ha₂
| 15 |
import Mathlib.Geometry.Manifold.MFDeriv.SpecificFunctions
noncomputable section
open scoped Manifold
open Bundle Set Topology
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
{E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {H : Type*} [TopologicalSpace H]
(I : ModelWithCorners 𝕜 E H) {M : Type*} [TopologicalSpace M] [ChartedSpace H M]
{E' : Type*} [NormedAddCommGroup E'] [NormedSpace 𝕜 E'] {H' : Type*} [TopologicalSpace H']
(I' : ModelWithCorners 𝕜 E' H') {M' : Type*} [TopologicalSpace M'] [ChartedSpace H' M']
{E'' : Type*} [NormedAddCommGroup E''] [NormedSpace 𝕜 E''] {H'' : Type*} [TopologicalSpace H'']
(I'' : ModelWithCorners 𝕜 E'' H'') {M'' : Type*} [TopologicalSpace M''] [ChartedSpace H'' M'']
section Charts
variable [SmoothManifoldWithCorners I M] [SmoothManifoldWithCorners I' M']
[SmoothManifoldWithCorners I'' M''] {e : PartialHomeomorph M H}
theorem mdifferentiableAt_atlas (h : e ∈ atlas H M) {x : M} (hx : x ∈ e.source) :
MDifferentiableAt I I e x := by
rw [mdifferentiableAt_iff]
refine ⟨(e.continuousOn x hx).continuousAt (e.open_source.mem_nhds hx), ?_⟩
have mem :
I ((chartAt H x : M → H) x) ∈ I.symm ⁻¹' ((chartAt H x).symm ≫ₕ e).source ∩ range I := by
simp only [hx, mfld_simps]
have : (chartAt H x).symm.trans e ∈ contDiffGroupoid ∞ I :=
HasGroupoid.compatible (chart_mem_atlas H x) h
have A :
ContDiffOn 𝕜 ∞ (I ∘ (chartAt H x).symm.trans e ∘ I.symm)
(I.symm ⁻¹' ((chartAt H x).symm.trans e).source ∩ range I) :=
this.1
have B := A.differentiableOn le_top (I ((chartAt H x : M → H) x)) mem
simp only [mfld_simps] at B
rw [inter_comm, differentiableWithinAt_inter] at B
· simpa only [mfld_simps]
· apply IsOpen.mem_nhds ((PartialHomeomorph.open_source _).preimage I.continuous_symm) mem.1
#align mdifferentiable_at_atlas mdifferentiableAt_atlas
theorem mdifferentiableOn_atlas (h : e ∈ atlas H M) : MDifferentiableOn I I e e.source :=
fun _x hx => (mdifferentiableAt_atlas I h hx).mdifferentiableWithinAt
#align mdifferentiable_on_atlas mdifferentiableOn_atlas
| Mathlib/Geometry/Manifold/MFDeriv/Atlas.lean | 113 | 129 | theorem mdifferentiableAt_atlas_symm (h : e ∈ atlas H M) {x : H} (hx : x ∈ e.target) :
MDifferentiableAt I I e.symm x := by |
rw [mdifferentiableAt_iff]
refine ⟨(e.continuousOn_symm x hx).continuousAt (e.open_target.mem_nhds hx), ?_⟩
have mem : I x ∈ I.symm ⁻¹' (e.symm ≫ₕ chartAt H (e.symm x)).source ∩ range I := by
simp only [hx, mfld_simps]
have : e.symm.trans (chartAt H (e.symm x)) ∈ contDiffGroupoid ∞ I :=
HasGroupoid.compatible h (chart_mem_atlas H _)
have A :
ContDiffOn 𝕜 ∞ (I ∘ e.symm.trans (chartAt H (e.symm x)) ∘ I.symm)
(I.symm ⁻¹' (e.symm.trans (chartAt H (e.symm x))).source ∩ range I) :=
this.1
have B := A.differentiableOn le_top (I x) mem
simp only [mfld_simps] at B
rw [inter_comm, differentiableWithinAt_inter] at B
· simpa only [mfld_simps]
· apply IsOpen.mem_nhds ((PartialHomeomorph.open_source _).preimage I.continuous_symm) mem.1
| 15 |
import Batteries.Classes.SatisfiesM
namespace Array
theorem SatisfiesM_foldlM [Monad m] [LawfulMonad m]
{as : Array α} (motive : Nat → β → Prop) {init : β} (h0 : motive 0 init) {f : β → α → m β}
(hf : ∀ i : Fin as.size, ∀ b, motive i.1 b → SatisfiesM (motive (i.1 + 1)) (f b as[i])) :
SatisfiesM (motive as.size) (as.foldlM f init) := by
let rec go {i j b} (h₁ : j ≤ as.size) (h₂ : as.size ≤ i + j) (H : motive j b) :
SatisfiesM (motive as.size) (foldlM.loop f as as.size (Nat.le_refl _) i j b) := by
unfold foldlM.loop; split
· next hj =>
split
· cases Nat.not_le_of_gt (by simp [hj]) h₂
· exact (hf ⟨j, hj⟩ b H).bind fun _ => go hj (by rwa [Nat.succ_add] at h₂)
· next hj => exact Nat.le_antisymm h₁ (Nat.ge_of_not_lt hj) ▸ .pure H
simp [foldlM]; exact go (Nat.zero_le _) (Nat.le_refl _) h0
theorem SatisfiesM_mapM [Monad m] [LawfulMonad m] (as : Array α) (f : α → m β)
(motive : Nat → Prop) (h0 : motive 0)
(p : Fin as.size → β → Prop)
(hs : ∀ i, motive i.1 → SatisfiesM (p i · ∧ motive (i + 1)) (f as[i])) :
SatisfiesM
(fun arr => motive as.size ∧ ∃ eq : arr.size = as.size, ∀ i h, p ⟨i, h⟩ arr[i])
(Array.mapM f as) := by
rw [mapM_eq_foldlM]
refine SatisfiesM_foldlM (m := m) (β := Array β)
(motive := fun i arr => motive i ∧ arr.size = i ∧ ∀ i h2, p i (arr[i.1]'h2)) ?z ?s
|>.imp fun ⟨h₁, eq, h₂⟩ => ⟨h₁, eq, fun _ _ => h₂ ..⟩
· case z => exact ⟨h0, rfl, nofun⟩
· case s =>
intro ⟨i, hi⟩ arr ⟨ih₁, eq, ih₂⟩
refine (hs _ ih₁).map fun ⟨h₁, h₂⟩ => ⟨h₂, by simp [eq], fun j hj => ?_⟩
simp [get_push] at hj ⊢; split; {apply ih₂}
cases j; cases (Nat.le_or_eq_of_le_succ hj).resolve_left ‹_›; cases eq; exact h₁
theorem SatisfiesM_mapM' [Monad m] [LawfulMonad m] (as : Array α) (f : α → m β)
(p : Fin as.size → β → Prop)
(hs : ∀ i, SatisfiesM (p i) (f as[i])) :
SatisfiesM
(fun arr => ∃ eq : arr.size = as.size, ∀ i h, p ⟨i, h⟩ arr[i])
(Array.mapM f as) :=
(SatisfiesM_mapM _ _ (fun _ => True) trivial _ (fun _ h => (hs _).imp (⟨·, h⟩))).imp (·.2)
theorem size_mapM [Monad m] [LawfulMonad m] (f : α → m β) (as : Array α) :
SatisfiesM (fun arr => arr.size = as.size) (Array.mapM f as) :=
(SatisfiesM_mapM' _ _ (fun _ _ => True) (fun _ => .trivial)).imp (·.1)
| .lake/packages/batteries/Batteries/Data/Array/Monadic.lean | 62 | 83 | theorem SatisfiesM_anyM [Monad m] [LawfulMonad m] (p : α → m Bool) (as : Array α) (start stop)
(hstart : start ≤ min stop as.size) (tru : Prop) (fal : Nat → Prop) (h0 : fal start)
(hp : ∀ i : Fin as.size, i.1 < stop → fal i.1 →
SatisfiesM (bif · then tru else fal (i + 1)) (p as[i])) :
SatisfiesM
(fun res => bif res then tru else fal (min stop as.size))
(anyM p as start stop) := by |
let rec go {stop j} (hj' : j ≤ stop) (hstop : stop ≤ as.size) (h0 : fal j)
(hp : ∀ i : Fin as.size, i.1 < stop → fal i.1 →
SatisfiesM (bif · then tru else fal (i + 1)) (p as[i])) :
SatisfiesM
(fun res => bif res then tru else fal stop)
(anyM.loop p as stop hstop j) := by
unfold anyM.loop; split
· next hj =>
exact (hp ⟨j, Nat.lt_of_lt_of_le hj hstop⟩ hj h0).bind fun
| true, h => .pure h
| false, h => go hj hstop h hp
· next hj => exact .pure <| Nat.le_antisymm hj' (Nat.ge_of_not_lt hj) ▸ h0
termination_by stop - j
simp only [Array.anyM_eq_anyM_loop]
exact go hstart _ h0 fun i hi => hp i <| Nat.lt_of_lt_of_le hi <| Nat.min_le_left ..
| 15 |
import Mathlib.Algebra.CharP.Basic
import Mathlib.GroupTheory.Perm.Cycle.Type
import Mathlib.RingTheory.Coprime.Lemmas
#align_import algebra.char_p.char_and_card from "leanprover-community/mathlib"@"2fae5fd7f90711febdadf19c44dc60fae8834d1b"
theorem isUnit_iff_not_dvd_char_of_ringChar_ne_zero (R : Type*) [CommRing R] (p : ℕ) [Fact p.Prime]
(hR : ringChar R ≠ 0) : IsUnit (p : R) ↔ ¬p ∣ ringChar R := by
have hch := CharP.cast_eq_zero R (ringChar R)
have hp : p.Prime := Fact.out
constructor
· rintro h₁ ⟨q, hq⟩
rcases IsUnit.exists_left_inv h₁ with ⟨a, ha⟩
have h₃ : ¬ringChar R ∣ q := by
rintro ⟨r, hr⟩
rw [hr, ← mul_assoc, mul_comm p, mul_assoc] at hq
nth_rw 1 [← mul_one (ringChar R)] at hq
exact Nat.Prime.not_dvd_one hp ⟨r, mul_left_cancel₀ hR hq⟩
have h₄ := mt (CharP.intCast_eq_zero_iff R (ringChar R) q).mp
apply_fun ((↑) : ℕ → R) at hq
apply_fun (· * ·) a at hq
rw [Nat.cast_mul, hch, mul_zero, ← mul_assoc, ha, one_mul] at hq
norm_cast at h₄
exact h₄ h₃ hq.symm
· intro h
rcases (hp.coprime_iff_not_dvd.mpr h).isCoprime with ⟨a, b, hab⟩
apply_fun ((↑) : ℤ → R) at hab
push_cast at hab
rw [hch, mul_zero, add_zero, mul_comm] at hab
exact isUnit_of_mul_eq_one (p : R) a hab
#align is_unit_iff_not_dvd_char_of_ring_char_ne_zero isUnit_iff_not_dvd_char_of_ringChar_ne_zero
theorem isUnit_iff_not_dvd_char (R : Type*) [CommRing R] (p : ℕ) [Fact p.Prime] [Finite R] :
IsUnit (p : R) ↔ ¬p ∣ ringChar R :=
isUnit_iff_not_dvd_char_of_ringChar_ne_zero R p <| CharP.char_ne_zero_of_finite R (ringChar R)
#align is_unit_iff_not_dvd_char isUnit_iff_not_dvd_char
| Mathlib/Algebra/CharP/CharAndCard.lean | 59 | 75 | theorem prime_dvd_char_iff_dvd_card {R : Type*} [CommRing R] [Fintype R] (p : ℕ) [Fact p.Prime] :
p ∣ ringChar R ↔ p ∣ Fintype.card R := by |
refine
⟨fun h =>
h.trans <|
Int.natCast_dvd_natCast.mp <|
(CharP.intCast_eq_zero_iff R (ringChar R) (Fintype.card R)).mp <|
mod_cast Nat.cast_card_eq_zero R,
fun h => ?_⟩
by_contra h₀
rcases exists_prime_addOrderOf_dvd_card p h with ⟨r, hr⟩
have hr₁ := addOrderOf_nsmul_eq_zero r
rw [hr, nsmul_eq_mul] at hr₁
rcases IsUnit.exists_left_inv ((isUnit_iff_not_dvd_char R p).mpr h₀) with ⟨u, hu⟩
apply_fun (· * ·) u at hr₁
rw [mul_zero, ← mul_assoc, hu, one_mul] at hr₁
exact mt AddMonoid.addOrderOf_eq_one_iff.mpr (ne_of_eq_of_ne hr (Nat.Prime.ne_one Fact.out)) hr₁
| 15 |
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
theorem ker_eq_bot (coercive : IsCoercive B) : ker B♯ = ⊥ := by
rw [LinearMapClass.ker_eq_bot]
rcases coercive.antilipschitz with ⟨_, _, antilipschitz⟩
exact antilipschitz.injective
#align is_coercive.ker_eq_bot IsCoercive.ker_eq_bot
theorem isClosed_range (coercive : IsCoercive B) : IsClosed (range B♯ : Set V) := by
rcases coercive.antilipschitz with ⟨_, _, antilipschitz⟩
exact antilipschitz.isClosed_range B♯.uniformContinuous
#align is_coercive.closed_range IsCoercive.isClosed_range
@[deprecated (since := "2024-03-19")] alias closed_range := isClosed_range
| Mathlib/Analysis/InnerProductSpace/LaxMilgram.lean | 87 | 102 | theorem range_eq_top (coercive : IsCoercive B) : range B♯ = ⊤ := by |
haveI := coercive.isClosed_range.completeSpace_coe
rw [← (range B♯).orthogonal_orthogonal]
rw [Submodule.eq_top_iff']
intro v w mem_w_orthogonal
rcases coercive with ⟨C, C_pos, coercivity⟩
obtain rfl : w = 0 := by
rw [← norm_eq_zero, ← mul_self_eq_zero, ← mul_right_inj' C_pos.ne', mul_zero, ←
mul_assoc]
apply le_antisymm
· calc
C * ‖w‖ * ‖w‖ ≤ B w w := coercivity w
_ = ⟪B♯ w, w⟫_ℝ := (continuousLinearMapOfBilin_apply B w w).symm
_ = 0 := mem_w_orthogonal _ ⟨w, rfl⟩
· positivity
exact inner_zero_left _
| 15 |
import Mathlib.Analysis.SpecialFunctions.Integrals
import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar
import Mathlib.MeasureTheory.Integral.Layercake
#align_import analysis.special_functions.japanese_bracket from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
noncomputable section
open scoped NNReal Filter Topology ENNReal
open Asymptotics Filter Set Real MeasureTheory FiniteDimensional
variable {E : Type*} [NormedAddCommGroup E]
theorem sqrt_one_add_norm_sq_le (x : E) : √((1 : ℝ) + ‖x‖ ^ 2) ≤ 1 + ‖x‖ := by
rw [sqrt_le_left (by positivity)]
simp [add_sq]
#align sqrt_one_add_norm_sq_le sqrt_one_add_norm_sq_le
theorem one_add_norm_le_sqrt_two_mul_sqrt (x : E) :
(1 : ℝ) + ‖x‖ ≤ √2 * √(1 + ‖x‖ ^ 2) := by
rw [← sqrt_mul zero_le_two]
have := sq_nonneg (‖x‖ - 1)
apply le_sqrt_of_sq_le
linarith
#align one_add_norm_le_sqrt_two_mul_sqrt one_add_norm_le_sqrt_two_mul_sqrt
theorem rpow_neg_one_add_norm_sq_le {r : ℝ} (x : E) (hr : 0 < r) :
((1 : ℝ) + ‖x‖ ^ 2) ^ (-r / 2) ≤ (2 : ℝ) ^ (r / 2) * (1 + ‖x‖) ^ (-r) :=
calc
((1 : ℝ) + ‖x‖ ^ 2) ^ (-r / 2)
= (2 : ℝ) ^ (r / 2) * ((√2 * √((1 : ℝ) + ‖x‖ ^ 2)) ^ r)⁻¹ := by
rw [rpow_div_two_eq_sqrt, rpow_div_two_eq_sqrt, mul_rpow, mul_inv, rpow_neg,
mul_inv_cancel_left₀] <;> positivity
_ ≤ (2 : ℝ) ^ (r / 2) * ((1 + ‖x‖) ^ r)⁻¹ := by
gcongr
apply one_add_norm_le_sqrt_two_mul_sqrt
_ = (2 : ℝ) ^ (r / 2) * (1 + ‖x‖) ^ (-r) := by rw [rpow_neg]; positivity
#align rpow_neg_one_add_norm_sq_le rpow_neg_one_add_norm_sq_le
theorem le_rpow_one_add_norm_iff_norm_le {r t : ℝ} (hr : 0 < r) (ht : 0 < t) (x : E) :
t ≤ (1 + ‖x‖) ^ (-r) ↔ ‖x‖ ≤ t ^ (-r⁻¹) - 1 := by
rw [le_sub_iff_add_le', neg_inv]
exact (Real.le_rpow_inv_iff_of_neg (by positivity) ht (neg_lt_zero.mpr hr)).symm
#align le_rpow_one_add_norm_iff_norm_le le_rpow_one_add_norm_iff_norm_le
variable (E)
theorem closedBall_rpow_sub_one_eq_empty_aux {r t : ℝ} (hr : 0 < r) (ht : 1 < t) :
Metric.closedBall (0 : E) (t ^ (-r⁻¹) - 1) = ∅ := by
rw [Metric.closedBall_eq_empty, sub_neg]
exact Real.rpow_lt_one_of_one_lt_of_neg ht (by simp only [hr, Right.neg_neg_iff, inv_pos])
#align closed_ball_rpow_sub_one_eq_empty_aux closedBall_rpow_sub_one_eq_empty_aux
variable [NormedSpace ℝ E] [FiniteDimensional ℝ E]
variable {E}
| Mathlib/Analysis/SpecialFunctions/JapaneseBracket.lean | 79 | 95 | theorem finite_integral_rpow_sub_one_pow_aux {r : ℝ} (n : ℕ) (hnr : (n : ℝ) < r) :
(∫⁻ x : ℝ in Ioc 0 1, ENNReal.ofReal ((x ^ (-r⁻¹) - 1) ^ n)) < ∞ := by |
have hr : 0 < r := lt_of_le_of_lt n.cast_nonneg hnr
have h_int : ∀ x : ℝ, x ∈ Ioc (0 : ℝ) 1 →
ENNReal.ofReal ((x ^ (-r⁻¹) - 1) ^ n) ≤ ENNReal.ofReal (x ^ (-(r⁻¹ * n))) := fun x hx ↦ by
apply ENNReal.ofReal_le_ofReal
rw [← neg_mul, rpow_mul hx.1.le, rpow_natCast]
refine pow_le_pow_left ?_ (by simp only [sub_le_self_iff, zero_le_one]) n
rw [le_sub_iff_add_le', add_zero]
refine Real.one_le_rpow_of_pos_of_le_one_of_nonpos hx.1 hx.2 ?_
rw [Right.neg_nonpos_iff, inv_nonneg]
exact hr.le
refine lt_of_le_of_lt (set_lintegral_mono' measurableSet_Ioc h_int) ?_
refine IntegrableOn.set_lintegral_lt_top ?_
rw [← intervalIntegrable_iff_integrableOn_Ioc_of_le zero_le_one]
apply intervalIntegral.intervalIntegrable_rpow'
rwa [neg_lt_neg_iff, inv_mul_lt_iff' hr, one_mul]
| 15 |
import Mathlib.Data.Finset.Image
import Mathlib.Data.Multiset.Pi
#align_import data.finset.pi from "leanprover-community/mathlib"@"b2c89893177f66a48daf993b7ba5ef7cddeff8c9"
namespace Finset
open Multiset
section Pi
variable {α : Type*}
def Pi.empty (β : α → Sort*) (a : α) (h : a ∈ (∅ : Finset α)) : β a :=
Multiset.Pi.empty β a h
#align finset.pi.empty Finset.Pi.empty
universe u v
variable {β : α → Type u} {δ : α → Sort v} [DecidableEq α] {s : Finset α} {t : ∀ a, Finset (β a)}
def pi (s : Finset α) (t : ∀ a, Finset (β a)) : Finset (∀ a ∈ s, β a) :=
⟨s.1.pi fun a => (t a).1, s.nodup.pi fun a _ => (t a).nodup⟩
#align finset.pi Finset.pi
@[simp]
theorem pi_val (s : Finset α) (t : ∀ a, Finset (β a)) : (s.pi t).1 = s.1.pi fun a => (t a).1 :=
rfl
#align finset.pi_val Finset.pi_val
@[simp]
theorem mem_pi {s : Finset α} {t : ∀ a, Finset (β a)} {f : ∀ a ∈ s, β a} :
f ∈ s.pi t ↔ ∀ (a) (h : a ∈ s), f a h ∈ t a :=
Multiset.mem_pi _ _ _
#align finset.mem_pi Finset.mem_pi
def Pi.cons (s : Finset α) (a : α) (b : δ a) (f : ∀ a, a ∈ s → δ a) (a' : α) (h : a' ∈ insert a s) :
δ a' :=
Multiset.Pi.cons s.1 a b f _ (Multiset.mem_cons.2 <| mem_insert.symm.2 h)
#align finset.pi.cons Finset.Pi.cons
@[simp]
theorem Pi.cons_same (s : Finset α) (a : α) (b : δ a) (f : ∀ a, a ∈ s → δ a) (h : a ∈ insert a s) :
Pi.cons s a b f a h = b :=
Multiset.Pi.cons_same _
#align finset.pi.cons_same Finset.Pi.cons_same
theorem Pi.cons_ne {s : Finset α} {a a' : α} {b : δ a} {f : ∀ a, a ∈ s → δ a} {h : a' ∈ insert a s}
(ha : a ≠ a') : Pi.cons s a b f a' h = f a' ((mem_insert.1 h).resolve_left ha.symm) :=
Multiset.Pi.cons_ne _ (Ne.symm ha)
#align finset.pi.cons_ne Finset.Pi.cons_ne
theorem Pi.cons_injective {a : α} {b : δ a} {s : Finset α} (hs : a ∉ s) :
Function.Injective (Pi.cons s a b) := fun e₁ e₂ eq =>
@Multiset.Pi.cons_injective α _ δ a b s.1 hs _ _ <|
funext fun e =>
funext fun h =>
have :
Pi.cons s a b e₁ e (by simpa only [Multiset.mem_cons, mem_insert] using h) =
Pi.cons s a b e₂ e (by simpa only [Multiset.mem_cons, mem_insert] using h) := by
rw [eq]
this
#align finset.pi.cons_injective Finset.Pi.cons_injective
@[simp]
theorem pi_empty {t : ∀ a : α, Finset (β a)} : pi (∅ : Finset α) t = singleton (Pi.empty β) :=
rfl
#align finset.pi_empty Finset.pi_empty
@[simp, aesop safe apply (rule_sets := [finsetNonempty])]
lemma pi_nonempty : (s.pi t).Nonempty ↔ ∀ a ∈ s, (t a).Nonempty := by
simp [Finset.Nonempty, Classical.skolem]
@[simp]
| Mathlib/Data/Finset/Pi.lean | 96 | 112 | theorem pi_insert [∀ a, DecidableEq (β a)] {s : Finset α} {t : ∀ a : α, Finset (β a)} {a : α}
(ha : a ∉ s) : pi (insert a s) t = (t a).biUnion fun b => (pi s t).image (Pi.cons s a b) := by |
apply eq_of_veq
rw [← (pi (insert a s) t).2.dedup]
refine
(fun s' (h : s' = a ::ₘ s.1) =>
(?_ :
dedup (Multiset.pi s' fun a => (t a).1) =
dedup
((t a).1.bind fun b =>
dedup <|
(Multiset.pi s.1 fun a : α => (t a).val).map fun f a' h' =>
Multiset.Pi.cons s.1 a b f a' (h ▸ h'))))
_ (insert_val_of_not_mem ha)
subst s'; rw [pi_cons]
congr; funext b
exact ((pi s t).nodup.map <| Multiset.Pi.cons_injective ha).dedup.symm
| 15 |
import Mathlib.Algebra.CharP.Invertible
import Mathlib.Algebra.MvPolynomial.Variables
import Mathlib.Algebra.MvPolynomial.CommRing
import Mathlib.Algebra.MvPolynomial.Expand
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.ZMod.Basic
#align_import ring_theory.witt_vector.witt_polynomial from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395"
open MvPolynomial
open Finset hiding map
open Finsupp (single)
--attribute [-simp] coe_eval₂_hom
variable (p : ℕ)
variable (R : Type*) [CommRing R] [DecidableEq R]
noncomputable def wittPolynomial (n : ℕ) : MvPolynomial ℕ R :=
∑ i ∈ range (n + 1), monomial (single i (p ^ (n - i))) ((p : R) ^ i)
#align witt_polynomial wittPolynomial
theorem wittPolynomial_eq_sum_C_mul_X_pow (n : ℕ) :
wittPolynomial p R n = ∑ i ∈ range (n + 1), C ((p : R) ^ i) * X i ^ p ^ (n - i) := by
apply sum_congr rfl
rintro i -
rw [monomial_eq, Finsupp.prod_single_index]
rw [pow_zero]
set_option linter.uppercaseLean3 false in
#align witt_polynomial_eq_sum_C_mul_X_pow wittPolynomial_eq_sum_C_mul_X_pow
-- Notation with ring of coefficients explicit
set_option quotPrecheck false in
@[inherit_doc]
scoped[Witt] notation "W_" => wittPolynomial p
-- Notation with ring of coefficients implicit
set_option quotPrecheck false in
@[inherit_doc]
scoped[Witt] notation "W" => wittPolynomial p _
open Witt
open MvPolynomial
section
variable {R} {S : Type*} [CommRing S]
@[simp]
theorem map_wittPolynomial (f : R →+* S) (n : ℕ) : map f (W n) = W n := by
rw [wittPolynomial, map_sum, wittPolynomial]
refine sum_congr rfl fun i _ => ?_
rw [map_monomial, RingHom.map_pow, map_natCast]
#align map_witt_polynomial map_wittPolynomial
variable (R)
@[simp]
theorem constantCoeff_wittPolynomial [hp : Fact p.Prime] (n : ℕ) :
constantCoeff (wittPolynomial p R n) = 0 := by
simp only [wittPolynomial, map_sum, constantCoeff_monomial]
rw [sum_eq_zero]
rintro i _
rw [if_neg]
rw [Finsupp.single_eq_zero]
exact ne_of_gt (pow_pos hp.1.pos _)
#align constant_coeff_witt_polynomial constantCoeff_wittPolynomial
@[simp]
theorem wittPolynomial_zero : wittPolynomial p R 0 = X 0 := by
simp only [wittPolynomial, X, sum_singleton, range_one, pow_zero, zero_add, tsub_self]
#align witt_polynomial_zero wittPolynomial_zero
@[simp]
theorem wittPolynomial_one : wittPolynomial p R 1 = C (p : R) * X 1 + X 0 ^ p := by
simp only [wittPolynomial_eq_sum_C_mul_X_pow, sum_range_succ_comm, range_one, sum_singleton,
one_mul, pow_one, C_1, pow_zero, tsub_self, tsub_zero]
#align witt_polynomial_one wittPolynomial_one
theorem aeval_wittPolynomial {A : Type*} [CommRing A] [Algebra R A] (f : ℕ → A) (n : ℕ) :
aeval f (W_ R n) = ∑ i ∈ range (n + 1), (p : A) ^ i * f i ^ p ^ (n - i) := by
simp [wittPolynomial, AlgHom.map_sum, aeval_monomial, Finsupp.prod_single_index]
#align aeval_witt_polynomial aeval_wittPolynomial
@[simp]
theorem wittPolynomial_zmod_self (n : ℕ) :
W_ (ZMod (p ^ (n + 1))) (n + 1) = expand p (W_ (ZMod (p ^ (n + 1))) n) := by
simp only [wittPolynomial_eq_sum_C_mul_X_pow]
rw [sum_range_succ, ← Nat.cast_pow, CharP.cast_eq_zero (ZMod (p ^ (n + 1))) (p ^ (n + 1)), C_0,
zero_mul, add_zero, AlgHom.map_sum, sum_congr rfl]
intro k hk
rw [AlgHom.map_mul, AlgHom.map_pow, expand_X, algHom_C, ← pow_mul, ← pow_succ']
congr
rw [mem_range] at hk
rw [add_comm, add_tsub_assoc_of_le (Nat.lt_succ_iff.mp hk), ← add_comm]
#align witt_polynomial_zmod_self wittPolynomial_zmod_self
end
noncomputable def xInTermsOfW [Invertible (p : R)] : ℕ → MvPolynomial ℕ R
| n => (X n - ∑ i : Fin n,
C ((p : R) ^ (i : ℕ)) * xInTermsOfW i ^ p ^ (n - (i : ℕ))) * C ((⅟ p : R) ^ n)
set_option linter.uppercaseLean3 false in
#align X_in_terms_of_W xInTermsOfW
theorem xInTermsOfW_eq [Invertible (p : R)] {n : ℕ} : xInTermsOfW p R n =
(X n - ∑ i ∈ range n, C ((p: R) ^ i) * xInTermsOfW p R i ^ p ^ (n - i)) * C ((⅟p : R) ^ n) := by
rw [xInTermsOfW, ← Fin.sum_univ_eq_sum_range]
set_option linter.uppercaseLean3 false in
#align X_in_terms_of_W_eq xInTermsOfW_eq
@[simp]
| Mathlib/RingTheory/WittVector/WittPolynomial.lean | 218 | 234 | theorem constantCoeff_xInTermsOfW [hp : Fact p.Prime] [Invertible (p : R)] (n : ℕ) :
constantCoeff (xInTermsOfW p R n) = 0 := by |
apply Nat.strongInductionOn n; clear n
intro n IH
rw [xInTermsOfW_eq, mul_comm, RingHom.map_mul, RingHom.map_sub, map_sum, constantCoeff_C,
constantCoeff_X, zero_sub, mul_neg, neg_eq_zero]
-- Porting note: here, we should be able to do `rw [sum_eq_zero]`, but the goal that
-- is created is not what we expect, and the sum is not replaced by zero...
-- is it a bug in `rw` tactic?
refine Eq.trans (?_ : _ = ((⅟↑p : R) ^ n)* 0) (mul_zero _)
congr 1
rw [sum_eq_zero]
intro m H
rw [mem_range] at H
simp only [RingHom.map_mul, RingHom.map_pow, map_natCast, IH m H]
rw [zero_pow, mul_zero]
exact pow_ne_zero _ hp.1.ne_zero
| 15 |
import Mathlib.MeasureTheory.PiSystem
import Mathlib.Order.OmegaCompletePartialOrder
import Mathlib.Topology.Constructions
import Mathlib.MeasureTheory.MeasurableSpace.Basic
open Set
namespace MeasureTheory
variable {ι : Type _} {α : ι → Type _}
section squareCylinders
def squareCylinders (C : ∀ i, Set (Set (α i))) : Set (Set (∀ i, α i)) :=
{S | ∃ s : Finset ι, ∃ t ∈ univ.pi C, S = (s : Set ι).pi t}
theorem squareCylinders_eq_iUnion_image (C : ∀ i, Set (Set (α i))) :
squareCylinders C = ⋃ s : Finset ι, (fun t ↦ (s : Set ι).pi t) '' univ.pi C := by
ext1 f
simp only [squareCylinders, mem_iUnion, mem_image, mem_univ_pi, exists_prop, mem_setOf_eq,
eq_comm (a := f)]
theorem isPiSystem_squareCylinders {C : ∀ i, Set (Set (α i))} (hC : ∀ i, IsPiSystem (C i))
(hC_univ : ∀ i, univ ∈ C i) :
IsPiSystem (squareCylinders C) := by
rintro S₁ ⟨s₁, t₁, h₁, rfl⟩ S₂ ⟨s₂, t₂, h₂, rfl⟩ hst_nonempty
classical
let t₁' := s₁.piecewise t₁ (fun i ↦ univ)
let t₂' := s₂.piecewise t₂ (fun i ↦ univ)
have h1 : ∀ i ∈ (s₁ : Set ι), t₁ i = t₁' i :=
fun i hi ↦ (Finset.piecewise_eq_of_mem _ _ _ hi).symm
have h1' : ∀ i ∉ (s₁ : Set ι), t₁' i = univ :=
fun i hi ↦ Finset.piecewise_eq_of_not_mem _ _ _ hi
have h2 : ∀ i ∈ (s₂ : Set ι), t₂ i = t₂' i :=
fun i hi ↦ (Finset.piecewise_eq_of_mem _ _ _ hi).symm
have h2' : ∀ i ∉ (s₂ : Set ι), t₂' i = univ :=
fun i hi ↦ Finset.piecewise_eq_of_not_mem _ _ _ hi
rw [Set.pi_congr rfl h1, Set.pi_congr rfl h2, ← union_pi_inter h1' h2']
refine ⟨s₁ ∪ s₂, fun i ↦ t₁' i ∩ t₂' i, ?_, ?_⟩
· rw [mem_univ_pi]
intro i
have : (t₁' i ∩ t₂' i).Nonempty := by
obtain ⟨f, hf⟩ := hst_nonempty
rw [Set.pi_congr rfl h1, Set.pi_congr rfl h2, mem_inter_iff, mem_pi, mem_pi] at hf
refine ⟨f i, ⟨?_, ?_⟩⟩
· by_cases hi₁ : i ∈ s₁
· exact hf.1 i hi₁
· rw [h1' i hi₁]
exact mem_univ _
· by_cases hi₂ : i ∈ s₂
· exact hf.2 i hi₂
· rw [h2' i hi₂]
exact mem_univ _
refine hC i _ ?_ _ ?_ this
· by_cases hi₁ : i ∈ s₁
· rw [← h1 i hi₁]
exact h₁ i (mem_univ _)
· rw [h1' i hi₁]
exact hC_univ i
· by_cases hi₂ : i ∈ s₂
· rw [← h2 i hi₂]
exact h₂ i (mem_univ _)
· rw [h2' i hi₂]
exact hC_univ i
· rw [Finset.coe_union]
| Mathlib/MeasureTheory/Constructions/Cylinders.lean | 107 | 126 | theorem comap_eval_le_generateFrom_squareCylinders_singleton
(α : ι → Type*) [m : ∀ i, MeasurableSpace (α i)] (i : ι) :
MeasurableSpace.comap (Function.eval i) (m i) ≤
MeasurableSpace.generateFrom
((fun t ↦ ({i} : Set ι).pi t) '' univ.pi fun i ↦ {s : Set (α i) | MeasurableSet s}) := by |
simp only [Function.eval, singleton_pi, ge_iff_le]
rw [MeasurableSpace.comap_eq_generateFrom]
refine MeasurableSpace.generateFrom_mono fun S ↦ ?_
simp only [mem_setOf_eq, mem_image, mem_univ_pi, forall_exists_index, and_imp]
intro t ht h
classical
refine ⟨fun j ↦ if hji : j = i then by convert t else univ, fun j ↦ ?_, ?_⟩
· by_cases hji : j = i
· simp only [hji, eq_self_iff_true, eq_mpr_eq_cast, dif_pos]
convert ht
simp only [id_eq, cast_heq]
· simp only [hji, not_false_iff, dif_neg, MeasurableSet.univ]
· simp only [id_eq, eq_mpr_eq_cast, ← h]
ext1 x
simp only [singleton_pi, Function.eval, cast_eq, dite_eq_ite, ite_true, mem_preimage]
| 15 |
import Batteries.Data.RBMap.Alter
import Batteries.Data.List.Lemmas
namespace Batteries
namespace RBNode
open RBColor
attribute [simp] fold foldl foldr Any forM foldlM Ordered
@[simp] theorem min?_reverse (t : RBNode α) : t.reverse.min? = t.max? := by
unfold RBNode.max?; split <;> simp [RBNode.min?]
unfold RBNode.min?; rw [min?.match_1.eq_3]
· apply min?_reverse
· simpa [reverse_eq_iff]
@[simp] theorem max?_reverse (t : RBNode α) : t.reverse.max? = t.min? := by
rw [← min?_reverse, reverse_reverse]
@[simp] theorem mem_nil {x} : ¬x ∈ (.nil : RBNode α) := by simp [(·∈·), EMem]
@[simp] theorem mem_node {y c a x b} :
y ∈ (.node c a x b : RBNode α) ↔ y = x ∨ y ∈ a ∨ y ∈ b := by simp [(·∈·), EMem]
theorem All_def {t : RBNode α} : t.All p ↔ ∀ x ∈ t, p x := by
induction t <;> simp [or_imp, forall_and, *]
theorem Any_def {t : RBNode α} : t.Any p ↔ ∃ x ∈ t, p x := by
induction t <;> simp [or_and_right, exists_or, *]
theorem memP_def : MemP cut t ↔ ∃ x ∈ t, cut x = .eq := Any_def
theorem mem_def : Mem cmp x t ↔ ∃ y ∈ t, cmp x y = .eq := Any_def
theorem mem_congr [@TransCmp α cmp] {t : RBNode α} (h : cmp x y = .eq) :
Mem cmp x t ↔ Mem cmp y t := by simp [Mem, TransCmp.cmp_congr_left' h]
| .lake/packages/batteries/Batteries/Data/RBMap/Lemmas.lean | 45 | 65 | theorem isOrdered_iff' [@TransCmp α cmp] {t : RBNode α} :
isOrdered cmp t L R ↔
(∀ a ∈ L, t.All (cmpLT cmp a ·)) ∧
(∀ a ∈ R, t.All (cmpLT cmp · a)) ∧
(∀ a ∈ L, ∀ b ∈ R, cmpLT cmp a b) ∧
Ordered cmp t := by |
induction t generalizing L R with
| nil =>
simp [isOrdered]; split <;> simp [cmpLT_iff]
next h => intro _ ha _ hb; cases h _ _ ha hb
| node _ l v r =>
simp [isOrdered, *]
exact ⟨
fun ⟨⟨Ll, lv, Lv, ol⟩, ⟨vr, rR, vR, or⟩⟩ => ⟨
fun _ h => ⟨Lv _ h, Ll _ h, (Lv _ h).trans_l vr⟩,
fun _ h => ⟨vR _ h, (vR _ h).trans_r lv, rR _ h⟩,
fun _ hL _ hR => (Lv _ hL).trans (vR _ hR),
lv, vr, ol, or⟩,
fun ⟨hL, hR, _, lv, vr, ol, or⟩ => ⟨
⟨fun _ h => (hL _ h).2.1, lv, fun _ h => (hL _ h).1, ol⟩,
⟨vr, fun _ h => (hR _ h).2.2, fun _ h => (hR _ h).1, or⟩⟩⟩
| 15 |
import Mathlib.Algebra.ContinuedFractions.ContinuantsRecurrence
import Mathlib.Algebra.ContinuedFractions.TerminatedStable
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring
#align_import algebra.continued_fractions.convergents_equiv from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
variable {K : Type*} {n : ℕ}
namespace GeneralizedContinuedFraction
variable {g : GeneralizedContinuedFraction K} {s : Stream'.Seq <| Pair K}
section Squash
section WithDivisionRing
variable [DivisionRing K]
def squashSeq (s : Stream'.Seq <| Pair K) (n : ℕ) : Stream'.Seq (Pair K) :=
match Prod.mk (s.get? n) (s.get? (n + 1)) with
| ⟨some gp_n, some gp_succ_n⟩ =>
Stream'.Seq.nats.zipWith
-- return the squashed value at position `n`; otherwise, do nothing.
(fun n' gp => if n' = n then ⟨gp_n.a, gp_n.b + gp_succ_n.a / gp_succ_n.b⟩ else gp) s
| _ => s
#align generalized_continued_fraction.squash_seq GeneralizedContinuedFraction.squashSeq
theorem squashSeq_eq_self_of_terminated (terminated_at_succ_n : s.TerminatedAt (n + 1)) :
squashSeq s n = s := by
change s.get? (n + 1) = none at terminated_at_succ_n
cases s_nth_eq : s.get? n <;> simp only [*, squashSeq]
#align generalized_continued_fraction.squash_seq_eq_self_of_terminated GeneralizedContinuedFraction.squashSeq_eq_self_of_terminated
theorem squashSeq_nth_of_not_terminated {gp_n gp_succ_n : Pair K} (s_nth_eq : s.get? n = some gp_n)
(s_succ_nth_eq : s.get? (n + 1) = some gp_succ_n) :
(squashSeq s n).get? n = some ⟨gp_n.a, gp_n.b + gp_succ_n.a / gp_succ_n.b⟩ := by
simp [*, squashSeq]
#align generalized_continued_fraction.squash_seq_nth_of_not_terminated GeneralizedContinuedFraction.squashSeq_nth_of_not_terminated
theorem squashSeq_nth_of_lt {m : ℕ} (m_lt_n : m < n) : (squashSeq s n).get? m = s.get? m := by
cases s_succ_nth_eq : s.get? (n + 1) with
| none => rw [squashSeq_eq_self_of_terminated s_succ_nth_eq]
| some =>
obtain ⟨gp_n, s_nth_eq⟩ : ∃ gp_n, s.get? n = some gp_n :=
s.ge_stable n.le_succ s_succ_nth_eq
obtain ⟨gp_m, s_mth_eq⟩ : ∃ gp_m, s.get? m = some gp_m :=
s.ge_stable (le_of_lt m_lt_n) s_nth_eq
simp [*, squashSeq, m_lt_n.ne]
#align generalized_continued_fraction.squash_seq_nth_of_lt GeneralizedContinuedFraction.squashSeq_nth_of_lt
| Mathlib/Algebra/ContinuedFractions/ConvergentsEquiv.lean | 134 | 150 | theorem squashSeq_succ_n_tail_eq_squashSeq_tail_n :
(squashSeq s (n + 1)).tail = squashSeq s.tail n := by |
cases s_succ_succ_nth_eq : s.get? (n + 2) with
| none =>
cases s_succ_nth_eq : s.get? (n + 1) <;>
simp only [squashSeq, Stream'.Seq.get?_tail, s_succ_nth_eq, s_succ_succ_nth_eq]
| some gp_succ_succ_n =>
obtain ⟨gp_succ_n, s_succ_nth_eq⟩ : ∃ gp_succ_n, s.get? (n + 1) = some gp_succ_n :=
s.ge_stable (n + 1).le_succ s_succ_succ_nth_eq
-- apply extensionality with `m` and continue by cases `m = n`.
ext1 m
cases' Decidable.em (m = n) with m_eq_n m_ne_n
· simp [*, squashSeq]
· cases s_succ_mth_eq : s.get? (m + 1)
· simp only [*, squashSeq, Stream'.Seq.get?_tail, Stream'.Seq.get?_zipWith,
Option.map₂_none_right]
· simp [*, squashSeq]
| 15 |
import Mathlib.Algebra.Algebra.Unitization
import Mathlib.Analysis.NormedSpace.OperatorNorm.Mul
suppress_compilation
variable (𝕜 A : Type*) [NontriviallyNormedField 𝕜] [NonUnitalNormedRing A]
variable [NormedSpace 𝕜 A] [IsScalarTower 𝕜 A A] [SMulCommClass 𝕜 A A]
open ContinuousLinearMap
namespace Unitization
def splitMul : Unitization 𝕜 A →ₐ[𝕜] 𝕜 × (A →L[𝕜] A) :=
(lift 0).prod (lift <| NonUnitalAlgHom.Lmul 𝕜 A)
variable {𝕜 A}
@[simp]
theorem splitMul_apply (x : Unitization 𝕜 A) :
splitMul 𝕜 A x = (x.fst, algebraMap 𝕜 (A →L[𝕜] A) x.fst + mul 𝕜 A x.snd) :=
show (x.fst + 0, _) = (x.fst, _) by rw [add_zero]; rfl
theorem splitMul_injective_of_clm_mul_injective
(h : Function.Injective (mul 𝕜 A)) :
Function.Injective (splitMul 𝕜 A) := by
rw [injective_iff_map_eq_zero]
intro x hx
induction x
rw [map_add] at hx
simp only [splitMul_apply, fst_inl, snd_inl, map_zero, add_zero, fst_inr, snd_inr,
zero_add, Prod.mk_add_mk, Prod.mk_eq_zero] at hx
obtain ⟨rfl, hx⟩ := hx
simp only [map_zero, zero_add, inl_zero] at hx ⊢
rw [← map_zero (mul 𝕜 A)] at hx
rw [h hx, inr_zero]
variable [RegularNormedAlgebra 𝕜 A]
variable (𝕜 A)
theorem splitMul_injective : Function.Injective (splitMul 𝕜 A) :=
splitMul_injective_of_clm_mul_injective (isometry_mul 𝕜 A).injective
variable {𝕜 A}
section Aux
noncomputable abbrev normedRingAux : NormedRing (Unitization 𝕜 A) :=
NormedRing.induced (Unitization 𝕜 A) (𝕜 × (A →L[𝕜] A)) (splitMul 𝕜 A) (splitMul_injective 𝕜 A)
attribute [local instance] Unitization.normedRingAux
noncomputable abbrev normedAlgebraAux : NormedAlgebra 𝕜 (Unitization 𝕜 A) :=
NormedAlgebra.induced 𝕜 (Unitization 𝕜 A) (𝕜 × (A →L[𝕜] A)) (splitMul 𝕜 A)
attribute [local instance] Unitization.normedAlgebraAux
theorem norm_def (x : Unitization 𝕜 A) : ‖x‖ = ‖splitMul 𝕜 A x‖ :=
rfl
theorem nnnorm_def (x : Unitization 𝕜 A) : ‖x‖₊ = ‖splitMul 𝕜 A x‖₊ :=
rfl
theorem norm_eq_sup (x : Unitization 𝕜 A) :
‖x‖ = ‖x.fst‖ ⊔ ‖algebraMap 𝕜 (A →L[𝕜] A) x.fst + mul 𝕜 A x.snd‖ := by
rw [norm_def, splitMul_apply, Prod.norm_def, sup_eq_max]
theorem nnnorm_eq_sup (x : Unitization 𝕜 A) :
‖x‖₊ = ‖x.fst‖₊ ⊔ ‖algebraMap 𝕜 (A →L[𝕜] A) x.fst + mul 𝕜 A x.snd‖₊ :=
NNReal.eq <| norm_eq_sup x
| Mathlib/Analysis/NormedSpace/Unitization.lean | 149 | 165 | theorem lipschitzWith_addEquiv :
LipschitzWith 2 (Unitization.addEquiv 𝕜 A) := by |
rw [← Real.toNNReal_ofNat]
refine AddMonoidHomClass.lipschitz_of_bound (Unitization.addEquiv 𝕜 A) 2 fun x => ?_
rw [norm_eq_sup, Prod.norm_def]
refine max_le ?_ ?_
· rw [sup_eq_max, mul_max_of_nonneg _ _ (zero_le_two : (0 : ℝ) ≤ 2)]
exact le_max_of_le_left ((le_add_of_nonneg_left (norm_nonneg _)).trans_eq (two_mul _).symm)
· nontriviality A
rw [two_mul]
calc
‖x.snd‖ = ‖mul 𝕜 A x.snd‖ :=
.symm <| (isometry_mul 𝕜 A).norm_map_of_map_zero (map_zero _) _
_ ≤ ‖algebraMap 𝕜 _ x.fst + mul 𝕜 A x.snd‖ + ‖x.fst‖ := by
simpa only [add_comm _ (mul 𝕜 A x.snd), norm_algebraMap'] using
norm_le_add_norm_add (mul 𝕜 A x.snd) (algebraMap 𝕜 _ x.fst)
_ ≤ _ := add_le_add le_sup_right le_sup_left
| 15 |
import Mathlib.Algebra.IsPrimePow
import Mathlib.SetTheory.Cardinal.Ordinal
import Mathlib.Tactic.WLOG
#align_import set_theory.cardinal.divisibility from "leanprover-community/mathlib"@"ea050b44c0f9aba9d16a948c7cc7d2e7c8493567"
namespace Cardinal
open Cardinal
universe u
variable {a b : Cardinal.{u}} {n m : ℕ}
@[simp]
| Mathlib/SetTheory/Cardinal/Divisibility.lean | 43 | 58 | theorem isUnit_iff : IsUnit a ↔ a = 1 := by |
refine
⟨fun h => ?_, by
rintro rfl
exact isUnit_one⟩
rcases eq_or_ne a 0 with (rfl | ha)
· exact (not_isUnit_zero h).elim
rw [isUnit_iff_forall_dvd] at h
cases' h 1 with t ht
rw [eq_comm, mul_eq_one_iff'] at ht
· exact ht.1
· exact one_le_iff_ne_zero.mpr ha
· apply one_le_iff_ne_zero.mpr
intro h
rw [h, mul_zero] at ht
exact zero_ne_one ht
| 15 |
import Mathlib.Data.Set.Lattice
import Mathlib.Order.Directed
#align_import data.set.Union_lift from "leanprover-community/mathlib"@"5a4ea8453f128345f73cc656e80a49de2a54f481"
variable {α : Type*} {ι β : Sort _}
namespace Set
section UnionLift
@[nolint unusedArguments]
noncomputable def iUnionLift (S : ι → Set α) (f : ∀ i, S i → β)
(_ : ∀ (i j) (x : α) (hxi : x ∈ S i) (hxj : x ∈ S j), f i ⟨x, hxi⟩ = f j ⟨x, hxj⟩) (T : Set α)
(hT : T ⊆ iUnion S) (x : T) : β :=
let i := Classical.indefiniteDescription _ (mem_iUnion.1 (hT x.prop))
f i ⟨x, i.prop⟩
#align set.Union_lift Set.iUnionLift
variable {S : ι → Set α} {f : ∀ i, S i → β}
{hf : ∀ (i j) (x : α) (hxi : x ∈ S i) (hxj : x ∈ S j), f i ⟨x, hxi⟩ = f j ⟨x, hxj⟩} {T : Set α}
{hT : T ⊆ iUnion S} (hT' : T = iUnion S)
@[simp]
theorem iUnionLift_mk {i : ι} (x : S i) (hx : (x : α) ∈ T) :
iUnionLift S f hf T hT ⟨x, hx⟩ = f i x := hf _ i x _ _
#align set.Union_lift_mk Set.iUnionLift_mk
@[simp]
theorem iUnionLift_inclusion {i : ι} (x : S i) (h : S i ⊆ T) :
iUnionLift S f hf T hT (Set.inclusion h x) = f i x :=
iUnionLift_mk x _
#align set.Union_lift_inclusion Set.iUnionLift_inclusion
theorem iUnionLift_of_mem (x : T) {i : ι} (hx : (x : α) ∈ S i) :
iUnionLift S f hf T hT x = f i ⟨x, hx⟩ := by cases' x with x hx; exact hf _ _ _ _ _
#align set.Union_lift_of_mem Set.iUnionLift_of_mem
theorem preimage_iUnionLift (t : Set β) :
iUnionLift S f hf T hT ⁻¹' t =
inclusion hT ⁻¹' (⋃ i, inclusion (subset_iUnion S i) '' (f i ⁻¹' t)) := by
ext x
simp only [mem_preimage, mem_iUnion, mem_image]
constructor
· rcases mem_iUnion.1 (hT x.prop) with ⟨i, hi⟩
refine fun h => ⟨i, ⟨x, hi⟩, ?_, rfl⟩
rwa [iUnionLift_of_mem x hi] at h
· rintro ⟨i, ⟨y, hi⟩, h, hxy⟩
obtain rfl : y = x := congr_arg Subtype.val hxy
rwa [iUnionLift_of_mem x hi]
theorem iUnionLift_const (c : T) (ci : ∀ i, S i) (hci : ∀ i, (ci i : α) = c) (cβ : β)
(h : ∀ i, f i (ci i) = cβ) : iUnionLift S f hf T hT c = cβ := by
let ⟨i, hi⟩ := Set.mem_iUnion.1 (hT c.prop)
have : ci i = ⟨c, hi⟩ := Subtype.ext (hci i)
rw [iUnionLift_of_mem _ hi, ← this, h]
#align set.Union_lift_const Set.iUnionLift_const
theorem iUnionLift_unary (u : T → T) (ui : ∀ i, S i → S i)
(hui :
∀ (i) (x : S i),
u (Set.inclusion (show S i ⊆ T from hT'.symm ▸ Set.subset_iUnion S i) x) =
Set.inclusion (show S i ⊆ T from hT'.symm ▸ Set.subset_iUnion S i) (ui i x))
(uβ : β → β) (h : ∀ (i) (x : S i), f i (ui i x) = uβ (f i x)) (x : T) :
iUnionLift S f hf T (le_of_eq hT') (u x) = uβ (iUnionLift S f hf T (le_of_eq hT') x) := by
subst hT'
cases' Set.mem_iUnion.1 x.prop with i hi
rw [iUnionLift_of_mem x hi, ← h i]
have : x = Set.inclusion (Set.subset_iUnion S i) ⟨x, hi⟩ := by
cases x
rfl
conv_lhs => rw [this, hui, iUnionLift_inclusion]
#align set.Union_lift_unary Set.iUnionLift_unary
| Mathlib/Data/Set/UnionLift.lean | 127 | 150 | theorem iUnionLift_binary (dir : Directed (· ≤ ·) S) (op : T → T → T) (opi : ∀ i, S i → S i → S i)
(hopi :
∀ i x y,
Set.inclusion (show S i ⊆ T from hT'.symm ▸ Set.subset_iUnion S i) (opi i x y) =
op (Set.inclusion (show S i ⊆ T from hT'.symm ▸ Set.subset_iUnion S i) x)
(Set.inclusion (show S i ⊆ T from hT'.symm ▸ Set.subset_iUnion S i) y))
(opβ : β → β → β) (h : ∀ (i) (x y : S i), f i (opi i x y) = opβ (f i x) (f i y)) (x y : T) :
iUnionLift S f hf T (le_of_eq hT') (op x y) =
opβ (iUnionLift S f hf T (le_of_eq hT') x) (iUnionLift S f hf T (le_of_eq hT') y) := by |
subst hT'
cases' Set.mem_iUnion.1 x.prop with i hi
cases' Set.mem_iUnion.1 y.prop with j hj
rcases dir i j with ⟨k, hik, hjk⟩
rw [iUnionLift_of_mem x (hik hi), iUnionLift_of_mem y (hjk hj), ← h k]
have hx : x = Set.inclusion (Set.subset_iUnion S k) ⟨x, hik hi⟩ := by
cases x
rfl
have hy : y = Set.inclusion (Set.subset_iUnion S k) ⟨y, hjk hj⟩ := by
cases y
rfl
have hxy : (Set.inclusion (Set.subset_iUnion S k) (opi k ⟨x, hik hi⟩ ⟨y, hjk hj⟩) : α) ∈ S k :=
(opi k ⟨x, hik hi⟩ ⟨y, hjk hj⟩).prop
conv_lhs => rw [hx, hy, ← hopi, iUnionLift_of_mem _ hxy]
rfl
| 15 |
import Mathlib.Algebra.BigOperators.NatAntidiagonal
import Mathlib.Algebra.GeomSum
import Mathlib.Data.Fintype.BigOperators
import Mathlib.RingTheory.PowerSeries.Inverse
import Mathlib.RingTheory.PowerSeries.WellKnown
import Mathlib.Tactic.FieldSimp
#align_import number_theory.bernoulli from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
open Nat Finset Finset.Nat PowerSeries
variable (A : Type*) [CommRing A] [Algebra ℚ A]
def bernoulli' : ℕ → ℚ :=
WellFounded.fix Nat.lt_wfRel.wf fun n bernoulli' =>
1 - ∑ k : Fin n, n.choose k / (n - k + 1) * bernoulli' k k.2
#align bernoulli' bernoulli'
theorem bernoulli'_def' (n : ℕ) :
bernoulli' n = 1 - ∑ k : Fin n, n.choose k / (n - k + 1) * bernoulli' k :=
WellFounded.fix_eq _ _ _
#align bernoulli'_def' bernoulli'_def'
theorem bernoulli'_def (n : ℕ) :
bernoulli' n = 1 - ∑ k ∈ range n, n.choose k / (n - k + 1) * bernoulli' k := by
rw [bernoulli'_def', ← Fin.sum_univ_eq_sum_range]
#align bernoulli'_def bernoulli'_def
theorem bernoulli'_spec (n : ℕ) :
(∑ k ∈ range n.succ, (n.choose (n - k) : ℚ) / (n - k + 1) * bernoulli' k) = 1 := by
rw [sum_range_succ_comm, bernoulli'_def n, tsub_self, choose_zero_right, sub_self, zero_add,
div_one, cast_one, one_mul, sub_add, ← sum_sub_distrib, ← sub_eq_zero, sub_sub_cancel_left,
neg_eq_zero]
exact Finset.sum_eq_zero (fun x hx => by rw [choose_symm (le_of_lt (mem_range.1 hx)), sub_self])
#align bernoulli'_spec bernoulli'_spec
theorem bernoulli'_spec' (n : ℕ) :
(∑ k ∈ antidiagonal n, ((k.1 + k.2).choose k.2 : ℚ) / (k.2 + 1) * bernoulli' k.1) = 1 := by
refine ((sum_antidiagonal_eq_sum_range_succ_mk _ n).trans ?_).trans (bernoulli'_spec n)
refine sum_congr rfl fun x hx => ?_
simp only [add_tsub_cancel_of_le, mem_range_succ_iff.mp hx, cast_sub]
#align bernoulli'_spec' bernoulli'_spec'
@[simp]
theorem sum_bernoulli' (n : ℕ) : (∑ k ∈ range n, (n.choose k : ℚ) * bernoulli' k) = n := by
cases' n with n
· simp
suffices
((n + 1 : ℚ) * ∑ k ∈ range n, ↑(n.choose k) / (n - k + 1) * bernoulli' k) =
∑ x ∈ range n, ↑(n.succ.choose x) * bernoulli' x by
rw_mod_cast [sum_range_succ, bernoulli'_def, ← this, choose_succ_self_right]
ring
simp_rw [mul_sum, ← mul_assoc]
refine sum_congr rfl fun k hk => ?_
congr
have : ((n - k : ℕ) : ℚ) + 1 ≠ 0 := by norm_cast
field_simp [← cast_sub (mem_range.1 hk).le, mul_comm]
rw_mod_cast [tsub_add_eq_add_tsub (mem_range.1 hk).le, choose_mul_succ_eq]
#align sum_bernoulli' sum_bernoulli'
def bernoulli'PowerSeries :=
mk fun n => algebraMap ℚ A (bernoulli' n / n !)
#align bernoulli'_power_series bernoulli'PowerSeries
theorem bernoulli'PowerSeries_mul_exp_sub_one :
bernoulli'PowerSeries A * (exp A - 1) = X * exp A := by
ext n
-- constant coefficient is a special case
cases' n with n
· simp
rw [bernoulli'PowerSeries, coeff_mul, mul_comm X, sum_antidiagonal_succ']
suffices (∑ p ∈ antidiagonal n,
bernoulli' p.1 / p.1! * ((p.2 + 1) * p.2! : ℚ)⁻¹) = (n ! : ℚ)⁻¹ by
simpa [map_sum, Nat.factorial] using congr_arg (algebraMap ℚ A) this
apply eq_inv_of_mul_eq_one_left
rw [sum_mul]
convert bernoulli'_spec' n using 1
apply sum_congr rfl
simp_rw [mem_antidiagonal]
rintro ⟨i, j⟩ rfl
have := factorial_mul_factorial_dvd_factorial_add i j
field_simp [mul_comm _ (bernoulli' i), mul_assoc, add_choose]
norm_cast
simp [mul_comm (j + 1)]
#align bernoulli'_power_series_mul_exp_sub_one bernoulli'PowerSeries_mul_exp_sub_one
| Mathlib/NumberTheory/Bernoulli.lean | 181 | 196 | theorem bernoulli'_odd_eq_zero {n : ℕ} (h_odd : Odd n) (hlt : 1 < n) : bernoulli' n = 0 := by |
let B := mk fun n => bernoulli' n / (n ! : ℚ)
suffices (B - evalNegHom B) * (exp ℚ - 1) = X * (exp ℚ - 1) by
cases' mul_eq_mul_right_iff.mp this with h h <;>
simp only [PowerSeries.ext_iff, evalNegHom, coeff_X] at h
· apply eq_zero_of_neg_eq
specialize h n
split_ifs at h <;> simp_all [B, h_odd.neg_one_pow, factorial_ne_zero]
· simpa (config := {decide := true}) [Nat.factorial] using h 1
have h : B * (exp ℚ - 1) = X * exp ℚ := by
simpa [bernoulli'PowerSeries] using bernoulli'PowerSeries_mul_exp_sub_one ℚ
rw [sub_mul, h, mul_sub X, sub_right_inj, ← neg_sub, mul_neg, neg_eq_iff_eq_neg]
suffices evalNegHom (B * (exp ℚ - 1)) * exp ℚ = evalNegHom (X * exp ℚ) * exp ℚ by
rw [map_mul, map_mul] at this -- Porting note: Why doesn't simp do this?
simpa [mul_assoc, sub_mul, mul_comm (evalNegHom (exp ℚ)), exp_mul_exp_neg_eq_one]
congr
| 15 |
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
| Mathlib/Computability/TMToPartrec.lean | 264 | 282 | 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⟩
| 15 |
import Mathlib.Data.Sigma.Basic
import Mathlib.Algebra.Order.Ring.Nat
#align_import set_theory.lists from "leanprover-community/mathlib"@"497d1e06409995dd8ec95301fa8d8f3480187f4c"
variable {α : Type*}
inductive Lists'.{u} (α : Type u) : Bool → Type u
| atom : α → Lists' α false
| nil : Lists' α true
| cons' {b} : Lists' α b → Lists' α true → Lists' α true
deriving DecidableEq
#align lists' Lists'
compile_inductive% Lists'
def Lists (α : Type*) :=
Σb, Lists' α b
#align lists Lists
namespace Lists'
instance [Inhabited α] : ∀ b, Inhabited (Lists' α b)
| true => ⟨nil⟩
| false => ⟨atom default⟩
def cons : Lists α → Lists' α true → Lists' α true
| ⟨_, a⟩, l => cons' a l
#align lists'.cons Lists'.cons
@[simp]
def toList : ∀ {b}, Lists' α b → List (Lists α)
| _, atom _ => []
| _, nil => []
| _, cons' a l => ⟨_, a⟩ :: l.toList
#align lists'.to_list Lists'.toList
-- Porting note (#10618): removed @[simp]
-- simp can prove this: by simp only [@Lists'.toList, @Sigma.eta]
theorem toList_cons (a : Lists α) (l) : toList (cons a l) = a :: l.toList := by simp
#align lists'.to_list_cons Lists'.toList_cons
@[simp]
def ofList : List (Lists α) → Lists' α true
| [] => nil
| a :: l => cons a (ofList l)
#align lists'.of_list Lists'.ofList
@[simp]
theorem to_ofList (l : List (Lists α)) : toList (ofList l) = l := by induction l <;> simp [*]
#align lists'.to_of_list Lists'.to_ofList
@[simp]
| Mathlib/SetTheory/Lists.lean | 103 | 120 | theorem of_toList : ∀ l : Lists' α true, ofList (toList l) = l :=
suffices
∀ (b) (h : true = b) (l : Lists' α b),
let l' : Lists' α true := by | rw [h]; exact l
ofList (toList l') = l'
from this _ rfl
fun b h l => by
induction l with
| atom => cases h
-- Porting note: case nil was not covered.
| nil => simp
| cons' b a _ IH =>
intro l'
-- Porting note: Previous code was:
-- change l' with cons' a l
--
-- This can be removed.
simpa [cons, l'] using IH rfl
| 15 |
import Mathlib.Algebra.CharP.ExpChar
import Mathlib.Algebra.GeomSum
import Mathlib.Algebra.MvPolynomial.CommRing
import Mathlib.Algebra.MvPolynomial.Equiv
import Mathlib.RingTheory.Polynomial.Content
import Mathlib.RingTheory.UniqueFactorizationDomain
#align_import ring_theory.polynomial.basic from "leanprover-community/mathlib"@"da420a8c6dd5bdfb85c4ced85c34388f633bc6ff"
noncomputable section
open Polynomial
open Finset
universe u v w
variable {R : Type u} {S : Type*}
namespace Polynomial
section Semiring
variable [Semiring R]
instance instCharP (p : ℕ) [h : CharP R p] : CharP R[X] p :=
let ⟨h⟩ := h
⟨fun n => by rw [← map_natCast C, ← C_0, C_inj, h]⟩
instance instExpChar (p : ℕ) [h : ExpChar R p] : ExpChar R[X] p := by
cases h; exacts [ExpChar.zero, ExpChar.prime ‹_›]
variable (R)
def degreeLE (n : WithBot ℕ) : Submodule R R[X] :=
⨅ k : ℕ, ⨅ _ : ↑k > n, LinearMap.ker (lcoeff R k)
#align polynomial.degree_le Polynomial.degreeLE
def degreeLT (n : ℕ) : Submodule R R[X] :=
⨅ k : ℕ, ⨅ (_ : k ≥ n), LinearMap.ker (lcoeff R k)
#align polynomial.degree_lt Polynomial.degreeLT
variable {R}
theorem mem_degreeLE {n : WithBot ℕ} {f : R[X]} : f ∈ degreeLE R n ↔ degree f ≤ n := by
simp only [degreeLE, Submodule.mem_iInf, degree_le_iff_coeff_zero, LinearMap.mem_ker]; rfl
#align polynomial.mem_degree_le Polynomial.mem_degreeLE
@[mono]
theorem degreeLE_mono {m n : WithBot ℕ} (H : m ≤ n) : degreeLE R m ≤ degreeLE R n := fun _ hf =>
mem_degreeLE.2 (le_trans (mem_degreeLE.1 hf) H)
#align polynomial.degree_le_mono Polynomial.degreeLE_mono
theorem degreeLE_eq_span_X_pow [DecidableEq R] {n : ℕ} :
degreeLE R n = Submodule.span R ↑((Finset.range (n + 1)).image fun n => (X : R[X]) ^ n) := by
apply le_antisymm
· intro p hp
replace hp := mem_degreeLE.1 hp
rw [← Polynomial.sum_monomial_eq p, Polynomial.sum]
refine Submodule.sum_mem _ fun k hk => ?_
have := WithBot.coe_le_coe.1 (Finset.sup_le_iff.1 hp k hk)
rw [← C_mul_X_pow_eq_monomial, C_mul']
refine
Submodule.smul_mem _ _
(Submodule.subset_span <|
Finset.mem_coe.2 <|
Finset.mem_image.2 ⟨_, Finset.mem_range.2 (Nat.lt_succ_of_le this), rfl⟩)
rw [Submodule.span_le, Finset.coe_image, Set.image_subset_iff]
intro k hk
apply mem_degreeLE.2
exact
(degree_X_pow_le _).trans (WithBot.coe_le_coe.2 <| Nat.le_of_lt_succ <| Finset.mem_range.1 hk)
set_option linter.uppercaseLean3 false in
#align polynomial.degree_le_eq_span_X_pow Polynomial.degreeLE_eq_span_X_pow
theorem mem_degreeLT {n : ℕ} {f : R[X]} : f ∈ degreeLT R n ↔ degree f < n := by
rw [degreeLT, Submodule.mem_iInf]
conv_lhs => intro i; rw [Submodule.mem_iInf]
rw [degree, Finset.max_eq_sup_coe]
rw [Finset.sup_lt_iff ?_]
rotate_left
· apply WithBot.bot_lt_coe
conv_rhs =>
simp only [mem_support_iff]
intro b
rw [Nat.cast_withBot, WithBot.coe_lt_coe, lt_iff_not_le, Ne, not_imp_not]
rfl
#align polynomial.mem_degree_lt Polynomial.mem_degreeLT
@[mono]
theorem degreeLT_mono {m n : ℕ} (H : m ≤ n) : degreeLT R m ≤ degreeLT R n := fun _ hf =>
mem_degreeLT.2 (lt_of_lt_of_le (mem_degreeLT.1 hf) <| WithBot.coe_le_coe.2 H)
#align polynomial.degree_lt_mono Polynomial.degreeLT_mono
| Mathlib/RingTheory/Polynomial/Basic.lean | 117 | 133 | theorem degreeLT_eq_span_X_pow [DecidableEq R] {n : ℕ} :
degreeLT R n = Submodule.span R ↑((Finset.range n).image fun n => X ^ n : Finset R[X]) := by |
apply le_antisymm
· intro p hp
replace hp := mem_degreeLT.1 hp
rw [← Polynomial.sum_monomial_eq p, Polynomial.sum]
refine Submodule.sum_mem _ fun k hk => ?_
have := WithBot.coe_lt_coe.1 ((Finset.sup_lt_iff <| WithBot.bot_lt_coe n).1 hp k hk)
rw [← C_mul_X_pow_eq_monomial, C_mul']
refine
Submodule.smul_mem _ _
(Submodule.subset_span <|
Finset.mem_coe.2 <| Finset.mem_image.2 ⟨_, Finset.mem_range.2 this, rfl⟩)
rw [Submodule.span_le, Finset.coe_image, Set.image_subset_iff]
intro k hk
apply mem_degreeLT.2
exact lt_of_le_of_lt (degree_X_pow_le _) (WithBot.coe_lt_coe.2 <| Finset.mem_range.1 hk)
| 15 |
import Mathlib.Geometry.Euclidean.Angle.Oriented.RightAngle
import Mathlib.Geometry.Euclidean.Circumcenter
#align_import geometry.euclidean.angle.sphere from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
noncomputable section
open FiniteDimensional Complex
open scoped EuclideanGeometry Real RealInnerProductSpace ComplexConjugate
namespace Orientation
variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]
variable [Fact (finrank ℝ V = 2)] (o : Orientation ℝ V (Fin 2))
| Mathlib/Geometry/Euclidean/Angle/Sphere.lean | 32 | 48 | theorem oangle_eq_two_zsmul_oangle_sub_of_norm_eq {x y z : V} (hxyne : x ≠ y) (hxzne : x ≠ z)
(hxy : ‖x‖ = ‖y‖) (hxz : ‖x‖ = ‖z‖) : o.oangle y z = (2 : ℤ) • o.oangle (y - x) (z - x) := by |
have hy : y ≠ 0 := by
rintro rfl
rw [norm_zero, norm_eq_zero] at hxy
exact hxyne hxy
have hx : x ≠ 0 := norm_ne_zero_iff.1 (hxy.symm ▸ norm_ne_zero_iff.2 hy)
have hz : z ≠ 0 := norm_ne_zero_iff.1 (hxz ▸ norm_ne_zero_iff.2 hx)
calc
o.oangle y z = o.oangle x z - o.oangle x y := (o.oangle_sub_left hx hy hz).symm
_ = π - (2 : ℤ) • o.oangle (x - z) x - (π - (2 : ℤ) • o.oangle (x - y) x) := by
rw [o.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq hxzne.symm hxz.symm,
o.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq hxyne.symm hxy.symm]
_ = (2 : ℤ) • (o.oangle (x - y) x - o.oangle (x - z) x) := by abel
_ = (2 : ℤ) • o.oangle (x - y) (x - z) := by
rw [o.oangle_sub_right (sub_ne_zero_of_ne hxyne) (sub_ne_zero_of_ne hxzne) hx]
_ = (2 : ℤ) • o.oangle (y - x) (z - x) := by rw [← oangle_neg_neg, neg_sub, neg_sub]
| 15 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.