Context stringlengths 57 85k | file_name stringlengths 21 79 | start int64 14 2.42k | end int64 18 2.43k | theorem stringlengths 25 2.71k | proof stringlengths 5 10.6k |
|---|---|---|---|---|---|
import Mathlib.MeasureTheory.Measure.NullMeasurable
import Mathlib.MeasureTheory.MeasurableSpace.Basic
import Mathlib.Topology.Algebra.Order.LiminfLimsup
#align_import measure_theory.measure.measure_space from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55"
noncomputable section
open Set
open Filter hiding map
open Function MeasurableSpace
open scoped Classical symmDiff
open Topology Filter ENNReal NNReal Interval MeasureTheory
variable {α β γ δ ι R R' : Type*}
namespace MeasureTheory
section
variable {m : MeasurableSpace α} {μ μ₁ μ₂ : Measure α} {s s₁ s₂ t : Set α}
instance ae_isMeasurablyGenerated : IsMeasurablyGenerated (ae μ) :=
⟨fun _s hs =>
let ⟨t, hst, htm, htμ⟩ := exists_measurable_superset_of_null hs
⟨tᶜ, compl_mem_ae_iff.2 htμ, htm.compl, compl_subset_comm.1 hst⟩⟩
#align measure_theory.ae_is_measurably_generated MeasureTheory.ae_isMeasurablyGenerated
theorem ae_uIoc_iff [LinearOrder α] {a b : α} {P : α → Prop} :
(∀ᵐ x ∂μ, x ∈ Ι a b → P x) ↔ (∀ᵐ x ∂μ, x ∈ Ioc a b → P x) ∧ ∀ᵐ x ∂μ, x ∈ Ioc b a → P x := by
simp only [uIoc_eq_union, mem_union, or_imp, eventually_and]
#align measure_theory.ae_uIoc_iff MeasureTheory.ae_uIoc_iff
theorem measure_union (hd : Disjoint s₁ s₂) (h : MeasurableSet s₂) : μ (s₁ ∪ s₂) = μ s₁ + μ s₂ :=
measure_union₀ h.nullMeasurableSet hd.aedisjoint
#align measure_theory.measure_union MeasureTheory.measure_union
theorem measure_union' (hd : Disjoint s₁ s₂) (h : MeasurableSet s₁) : μ (s₁ ∪ s₂) = μ s₁ + μ s₂ :=
measure_union₀' h.nullMeasurableSet hd.aedisjoint
#align measure_theory.measure_union' MeasureTheory.measure_union'
theorem measure_inter_add_diff (s : Set α) (ht : MeasurableSet t) : μ (s ∩ t) + μ (s \ t) = μ s :=
measure_inter_add_diff₀ _ ht.nullMeasurableSet
#align measure_theory.measure_inter_add_diff MeasureTheory.measure_inter_add_diff
theorem measure_diff_add_inter (s : Set α) (ht : MeasurableSet t) : μ (s \ t) + μ (s ∩ t) = μ s :=
(add_comm _ _).trans (measure_inter_add_diff s ht)
#align measure_theory.measure_diff_add_inter MeasureTheory.measure_diff_add_inter
theorem measure_union_add_inter (s : Set α) (ht : MeasurableSet t) :
μ (s ∪ t) + μ (s ∩ t) = μ s + μ t := by
rw [← measure_inter_add_diff (s ∪ t) ht, Set.union_inter_cancel_right, union_diff_right, ←
measure_inter_add_diff s ht]
ac_rfl
#align measure_theory.measure_union_add_inter MeasureTheory.measure_union_add_inter
theorem measure_union_add_inter' (hs : MeasurableSet s) (t : Set α) :
μ (s ∪ t) + μ (s ∩ t) = μ s + μ t := by
rw [union_comm, inter_comm, measure_union_add_inter t hs, add_comm]
#align measure_theory.measure_union_add_inter' MeasureTheory.measure_union_add_inter'
lemma measure_symmDiff_eq (hs : MeasurableSet s) (ht : MeasurableSet t) :
μ (s ∆ t) = μ (s \ t) + μ (t \ s) := by
simpa only [symmDiff_def, sup_eq_union] using measure_union disjoint_sdiff_sdiff (ht.diff hs)
lemma measure_symmDiff_le (s t u : Set α) :
μ (s ∆ u) ≤ μ (s ∆ t) + μ (t ∆ u) :=
le_trans (μ.mono <| symmDiff_triangle s t u) (measure_union_le (s ∆ t) (t ∆ u))
theorem measure_add_measure_compl (h : MeasurableSet s) : μ s + μ sᶜ = μ univ :=
measure_add_measure_compl₀ h.nullMeasurableSet
#align measure_theory.measure_add_measure_compl MeasureTheory.measure_add_measure_compl
theorem measure_biUnion₀ {s : Set β} {f : β → Set α} (hs : s.Countable)
(hd : s.Pairwise (AEDisjoint μ on f)) (h : ∀ b ∈ s, NullMeasurableSet (f b) μ) :
μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) := by
haveI := hs.toEncodable
rw [biUnion_eq_iUnion]
exact measure_iUnion₀ (hd.on_injective Subtype.coe_injective fun x => x.2) fun x => h x x.2
#align measure_theory.measure_bUnion₀ MeasureTheory.measure_biUnion₀
theorem measure_biUnion {s : Set β} {f : β → Set α} (hs : s.Countable) (hd : s.PairwiseDisjoint f)
(h : ∀ b ∈ s, MeasurableSet (f b)) : μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) :=
measure_biUnion₀ hs hd.aedisjoint fun b hb => (h b hb).nullMeasurableSet
#align measure_theory.measure_bUnion MeasureTheory.measure_biUnion
theorem measure_sUnion₀ {S : Set (Set α)} (hs : S.Countable) (hd : S.Pairwise (AEDisjoint μ))
(h : ∀ s ∈ S, NullMeasurableSet s μ) : μ (⋃₀ S) = ∑' s : S, μ s := by
rw [sUnion_eq_biUnion, measure_biUnion₀ hs hd h]
#align measure_theory.measure_sUnion₀ MeasureTheory.measure_sUnion₀
theorem measure_sUnion {S : Set (Set α)} (hs : S.Countable) (hd : S.Pairwise Disjoint)
(h : ∀ s ∈ S, MeasurableSet s) : μ (⋃₀ S) = ∑' s : S, μ s := by
rw [sUnion_eq_biUnion, measure_biUnion hs hd h]
#align measure_theory.measure_sUnion MeasureTheory.measure_sUnion
theorem measure_biUnion_finset₀ {s : Finset ι} {f : ι → Set α}
(hd : Set.Pairwise (↑s) (AEDisjoint μ on f)) (hm : ∀ b ∈ s, NullMeasurableSet (f b) μ) :
μ (⋃ b ∈ s, f b) = ∑ p ∈ s, μ (f p) := by
rw [← Finset.sum_attach, Finset.attach_eq_univ, ← tsum_fintype]
exact measure_biUnion₀ s.countable_toSet hd hm
#align measure_theory.measure_bUnion_finset₀ MeasureTheory.measure_biUnion_finset₀
theorem measure_biUnion_finset {s : Finset ι} {f : ι → Set α} (hd : PairwiseDisjoint (↑s) f)
(hm : ∀ b ∈ s, MeasurableSet (f b)) : μ (⋃ b ∈ s, f b) = ∑ p ∈ s, μ (f p) :=
measure_biUnion_finset₀ hd.aedisjoint fun b hb => (hm b hb).nullMeasurableSet
#align measure_theory.measure_bUnion_finset MeasureTheory.measure_biUnion_finset
theorem tsum_meas_le_meas_iUnion_of_disjoint₀ {ι : Type*} [MeasurableSpace α] (μ : Measure α)
{As : ι → Set α} (As_mble : ∀ i : ι, NullMeasurableSet (As i) μ)
(As_disj : Pairwise (AEDisjoint μ on As)) : (∑' i, μ (As i)) ≤ μ (⋃ i, As i) := by
rw [ENNReal.tsum_eq_iSup_sum, iSup_le_iff]
intro s
simp only [← measure_biUnion_finset₀ (fun _i _hi _j _hj hij => As_disj hij) fun i _ => As_mble i]
gcongr
exact iUnion_subset fun _ ↦ Subset.rfl
theorem tsum_meas_le_meas_iUnion_of_disjoint {ι : Type*} [MeasurableSpace α] (μ : Measure α)
{As : ι → Set α} (As_mble : ∀ i : ι, MeasurableSet (As i))
(As_disj : Pairwise (Disjoint on As)) : (∑' i, μ (As i)) ≤ μ (⋃ i, As i) :=
tsum_meas_le_meas_iUnion_of_disjoint₀ μ (fun i ↦ (As_mble i).nullMeasurableSet)
(fun _ _ h ↦ Disjoint.aedisjoint (As_disj h))
#align measure_theory.tsum_meas_le_meas_Union_of_disjoint MeasureTheory.tsum_meas_le_meas_iUnion_of_disjoint
theorem tsum_measure_preimage_singleton {s : Set β} (hs : s.Countable) {f : α → β}
(hf : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y})) : (∑' b : s, μ (f ⁻¹' {↑b})) = μ (f ⁻¹' s) := by
rw [← Set.biUnion_preimage_singleton, measure_biUnion hs (pairwiseDisjoint_fiber f s) hf]
#align measure_theory.tsum_measure_preimage_singleton MeasureTheory.tsum_measure_preimage_singleton
lemma measure_preimage_eq_zero_iff_of_countable {s : Set β} {f : α → β} (hs : s.Countable) :
μ (f ⁻¹' s) = 0 ↔ ∀ x ∈ s, μ (f ⁻¹' {x}) = 0 := by
rw [← biUnion_preimage_singleton, measure_biUnion_null_iff hs]
theorem sum_measure_preimage_singleton (s : Finset β) {f : α → β}
(hf : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y})) : (∑ b ∈ s, μ (f ⁻¹' {b})) = μ (f ⁻¹' ↑s) := by
simp only [← measure_biUnion_finset (pairwiseDisjoint_fiber f s) hf,
Finset.set_biUnion_preimage_singleton]
#align measure_theory.sum_measure_preimage_singleton MeasureTheory.sum_measure_preimage_singleton
theorem measure_diff_null' (h : μ (s₁ ∩ s₂) = 0) : μ (s₁ \ s₂) = μ s₁ :=
measure_congr <| diff_ae_eq_self.2 h
#align measure_theory.measure_diff_null' MeasureTheory.measure_diff_null'
theorem measure_add_diff (hs : MeasurableSet s) (t : Set α) : μ s + μ (t \ s) = μ (s ∪ t) := by
rw [← measure_union' disjoint_sdiff_right hs, union_diff_self]
#align measure_theory.measure_add_diff MeasureTheory.measure_add_diff
theorem measure_diff' (s : Set α) (hm : MeasurableSet t) (h_fin : μ t ≠ ∞) :
μ (s \ t) = μ (s ∪ t) - μ t :=
Eq.symm <| ENNReal.sub_eq_of_add_eq h_fin <| by rw [add_comm, measure_add_diff hm, union_comm]
#align measure_theory.measure_diff' MeasureTheory.measure_diff'
theorem measure_diff (h : s₂ ⊆ s₁) (h₂ : MeasurableSet s₂) (h_fin : μ s₂ ≠ ∞) :
μ (s₁ \ s₂) = μ s₁ - μ s₂ := by rw [measure_diff' _ h₂ h_fin, union_eq_self_of_subset_right h]
#align measure_theory.measure_diff MeasureTheory.measure_diff
theorem le_measure_diff : μ s₁ - μ s₂ ≤ μ (s₁ \ s₂) :=
tsub_le_iff_left.2 <| (measure_le_inter_add_diff μ s₁ s₂).trans <| by
gcongr; apply inter_subset_right
#align measure_theory.le_measure_diff MeasureTheory.le_measure_diff
theorem measure_eq_top_iff_of_symmDiff (hμst : μ (s ∆ t) ≠ ∞) : μ s = ∞ ↔ μ t = ∞ := by
suffices h : ∀ u v, μ (u ∆ v) ≠ ∞ → μ u = ∞ → μ v = ∞
from ⟨h s t hμst, h t s (symmDiff_comm s t ▸ hμst)⟩
intro u v hμuv hμu
by_contra! hμv
apply hμuv
rw [Set.symmDiff_def, eq_top_iff]
calc
∞ = μ u - μ v := (WithTop.sub_eq_top_iff.2 ⟨hμu, hμv⟩).symm
_ ≤ μ (u \ v) := le_measure_diff
_ ≤ μ (u \ v ∪ v \ u) := measure_mono subset_union_left
theorem measure_ne_top_iff_of_symmDiff (hμst : μ (s ∆ t) ≠ ∞) : μ s ≠ ∞ ↔ μ t ≠ ∞ :=
(measure_eq_top_iff_of_symmDiff hμst).ne
theorem measure_diff_lt_of_lt_add (hs : MeasurableSet s) (hst : s ⊆ t) (hs' : μ s ≠ ∞) {ε : ℝ≥0∞}
(h : μ t < μ s + ε) : μ (t \ s) < ε := by
rw [measure_diff hst hs hs']; rw [add_comm] at h
exact ENNReal.sub_lt_of_lt_add (measure_mono hst) h
#align measure_theory.measure_diff_lt_of_lt_add MeasureTheory.measure_diff_lt_of_lt_add
theorem measure_diff_le_iff_le_add (hs : MeasurableSet s) (hst : s ⊆ t) (hs' : μ s ≠ ∞) {ε : ℝ≥0∞} :
μ (t \ s) ≤ ε ↔ μ t ≤ μ s + ε := by rw [measure_diff hst hs hs', tsub_le_iff_left]
#align measure_theory.measure_diff_le_iff_le_add MeasureTheory.measure_diff_le_iff_le_add
theorem measure_eq_measure_of_null_diff {s t : Set α} (hst : s ⊆ t) (h_nulldiff : μ (t \ s) = 0) :
μ s = μ t := measure_congr <|
EventuallyLE.antisymm (HasSubset.Subset.eventuallyLE hst) (ae_le_set.mpr h_nulldiff)
#align measure_theory.measure_eq_measure_of_null_diff MeasureTheory.measure_eq_measure_of_null_diff
theorem measure_eq_measure_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂) (h23 : s₂ ⊆ s₃)
(h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₁ = μ s₂ ∧ μ s₂ = μ s₃ := by
have le12 : μ s₁ ≤ μ s₂ := measure_mono h12
have le23 : μ s₂ ≤ μ s₃ := measure_mono h23
have key : μ s₃ ≤ μ s₁ :=
calc
μ s₃ = μ (s₃ \ s₁ ∪ s₁) := by rw [diff_union_of_subset (h12.trans h23)]
_ ≤ μ (s₃ \ s₁) + μ s₁ := measure_union_le _ _
_ = μ s₁ := by simp only [h_nulldiff, zero_add]
exact ⟨le12.antisymm (le23.trans key), le23.antisymm (key.trans le12)⟩
#align measure_theory.measure_eq_measure_of_between_null_diff MeasureTheory.measure_eq_measure_of_between_null_diff
theorem measure_eq_measure_smaller_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂)
(h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₁ = μ s₂ :=
(measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).1
#align measure_theory.measure_eq_measure_smaller_of_between_null_diff MeasureTheory.measure_eq_measure_smaller_of_between_null_diff
theorem measure_eq_measure_larger_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂)
(h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₂ = μ s₃ :=
(measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).2
#align measure_theory.measure_eq_measure_larger_of_between_null_diff MeasureTheory.measure_eq_measure_larger_of_between_null_diff
lemma measure_compl₀ (h : NullMeasurableSet s μ) (hs : μ s ≠ ∞) :
μ sᶜ = μ Set.univ - μ s := by
rw [← measure_add_measure_compl₀ h, ENNReal.add_sub_cancel_left hs]
theorem measure_compl (h₁ : MeasurableSet s) (h_fin : μ s ≠ ∞) : μ sᶜ = μ univ - μ s :=
measure_compl₀ h₁.nullMeasurableSet h_fin
#align measure_theory.measure_compl MeasureTheory.measure_compl
lemma measure_inter_conull' (ht : μ (s \ t) = 0) : μ (s ∩ t) = μ s := by
rw [← diff_compl, measure_diff_null']; rwa [← diff_eq]
lemma measure_inter_conull (ht : μ tᶜ = 0) : μ (s ∩ t) = μ s := by
rw [← diff_compl, measure_diff_null ht]
@[simp]
theorem union_ae_eq_left_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] s ↔ t ≤ᵐ[μ] s := by
rw [ae_le_set]
refine
⟨fun h => by simpa only [union_diff_left] using (ae_eq_set.mp h).1, fun h =>
eventuallyLE_antisymm_iff.mpr
⟨by rwa [ae_le_set, union_diff_left],
HasSubset.Subset.eventuallyLE subset_union_left⟩⟩
#align measure_theory.union_ae_eq_left_iff_ae_subset MeasureTheory.union_ae_eq_left_iff_ae_subset
@[simp]
theorem union_ae_eq_right_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] t ↔ s ≤ᵐ[μ] t := by
rw [union_comm, union_ae_eq_left_iff_ae_subset]
#align measure_theory.union_ae_eq_right_iff_ae_subset MeasureTheory.union_ae_eq_right_iff_ae_subset
theorem ae_eq_of_ae_subset_of_measure_ge (h₁ : s ≤ᵐ[μ] t) (h₂ : μ t ≤ μ s) (hsm : MeasurableSet s)
(ht : μ t ≠ ∞) : s =ᵐ[μ] t := by
refine eventuallyLE_antisymm_iff.mpr ⟨h₁, ae_le_set.mpr ?_⟩
replace h₂ : μ t = μ s := h₂.antisymm (measure_mono_ae h₁)
replace ht : μ s ≠ ∞ := h₂ ▸ ht
rw [measure_diff' t hsm ht, measure_congr (union_ae_eq_left_iff_ae_subset.mpr h₁), h₂, tsub_self]
#align measure_theory.ae_eq_of_ae_subset_of_measure_ge MeasureTheory.ae_eq_of_ae_subset_of_measure_ge
theorem ae_eq_of_subset_of_measure_ge (h₁ : s ⊆ t) (h₂ : μ t ≤ μ s) (hsm : MeasurableSet s)
(ht : μ t ≠ ∞) : s =ᵐ[μ] t :=
ae_eq_of_ae_subset_of_measure_ge (HasSubset.Subset.eventuallyLE h₁) h₂ hsm ht
#align measure_theory.ae_eq_of_subset_of_measure_ge MeasureTheory.ae_eq_of_subset_of_measure_ge
theorem measure_iUnion_congr_of_subset [Countable β] {s : β → Set α} {t : β → Set α}
(hsub : ∀ b, s b ⊆ t b) (h_le : ∀ b, μ (t b) ≤ μ (s b)) : μ (⋃ b, s b) = μ (⋃ b, t b) := by
rcases Classical.em (∃ b, μ (t b) = ∞) with (⟨b, hb⟩ | htop)
· calc
μ (⋃ b, s b) = ∞ := top_unique (hb ▸ (h_le b).trans <| measure_mono <| subset_iUnion _ _)
_ = μ (⋃ b, t b) := Eq.symm <| top_unique <| hb ▸ measure_mono (subset_iUnion _ _)
push_neg at htop
refine le_antisymm (measure_mono (iUnion_mono hsub)) ?_
set M := toMeasurable μ
have H : ∀ b, (M (t b) ∩ M (⋃ b, s b) : Set α) =ᵐ[μ] M (t b) := by
refine fun b => ae_eq_of_subset_of_measure_ge inter_subset_left ?_ ?_ ?_
· calc
μ (M (t b)) = μ (t b) := measure_toMeasurable _
_ ≤ μ (s b) := h_le b
_ ≤ μ (M (t b) ∩ M (⋃ b, s b)) :=
measure_mono <|
subset_inter ((hsub b).trans <| subset_toMeasurable _ _)
((subset_iUnion _ _).trans <| subset_toMeasurable _ _)
· exact (measurableSet_toMeasurable _ _).inter (measurableSet_toMeasurable _ _)
· rw [measure_toMeasurable]
exact htop b
calc
μ (⋃ b, t b) ≤ μ (⋃ b, M (t b)) := measure_mono (iUnion_mono fun b => subset_toMeasurable _ _)
_ = μ (⋃ b, M (t b) ∩ M (⋃ b, s b)) := measure_congr (EventuallyEq.countable_iUnion H).symm
_ ≤ μ (M (⋃ b, s b)) := measure_mono (iUnion_subset fun b => inter_subset_right)
_ = μ (⋃ b, s b) := measure_toMeasurable _
#align measure_theory.measure_Union_congr_of_subset MeasureTheory.measure_iUnion_congr_of_subset
theorem measure_union_congr_of_subset {t₁ t₂ : Set α} (hs : s₁ ⊆ s₂) (hsμ : μ s₂ ≤ μ s₁)
(ht : t₁ ⊆ t₂) (htμ : μ t₂ ≤ μ t₁) : μ (s₁ ∪ t₁) = μ (s₂ ∪ t₂) := by
rw [union_eq_iUnion, union_eq_iUnion]
exact measure_iUnion_congr_of_subset (Bool.forall_bool.2 ⟨ht, hs⟩) (Bool.forall_bool.2 ⟨htμ, hsμ⟩)
#align measure_theory.measure_union_congr_of_subset MeasureTheory.measure_union_congr_of_subset
@[simp]
theorem measure_iUnion_toMeasurable [Countable β] (s : β → Set α) :
μ (⋃ b, toMeasurable μ (s b)) = μ (⋃ b, s b) :=
Eq.symm <|
measure_iUnion_congr_of_subset (fun _b => subset_toMeasurable _ _) fun _b =>
(measure_toMeasurable _).le
#align measure_theory.measure_Union_to_measurable MeasureTheory.measure_iUnion_toMeasurable
theorem measure_biUnion_toMeasurable {I : Set β} (hc : I.Countable) (s : β → Set α) :
μ (⋃ b ∈ I, toMeasurable μ (s b)) = μ (⋃ b ∈ I, s b) := by
haveI := hc.toEncodable
simp only [biUnion_eq_iUnion, measure_iUnion_toMeasurable]
#align measure_theory.measure_bUnion_to_measurable MeasureTheory.measure_biUnion_toMeasurable
@[simp]
theorem measure_toMeasurable_union : μ (toMeasurable μ s ∪ t) = μ (s ∪ t) :=
Eq.symm <|
measure_union_congr_of_subset (subset_toMeasurable _ _) (measure_toMeasurable _).le Subset.rfl
le_rfl
#align measure_theory.measure_to_measurable_union MeasureTheory.measure_toMeasurable_union
@[simp]
theorem measure_union_toMeasurable : μ (s ∪ toMeasurable μ t) = μ (s ∪ t) :=
Eq.symm <|
measure_union_congr_of_subset Subset.rfl le_rfl (subset_toMeasurable _ _)
(measure_toMeasurable _).le
#align measure_theory.measure_union_to_measurable MeasureTheory.measure_union_toMeasurable
theorem sum_measure_le_measure_univ {s : Finset ι} {t : ι → Set α}
(h : ∀ i ∈ s, MeasurableSet (t i)) (H : Set.PairwiseDisjoint (↑s) t) :
(∑ i ∈ s, μ (t i)) ≤ μ (univ : Set α) := by
rw [← measure_biUnion_finset H h]
exact measure_mono (subset_univ _)
#align measure_theory.sum_measure_le_measure_univ MeasureTheory.sum_measure_le_measure_univ
theorem tsum_measure_le_measure_univ {s : ι → Set α} (hs : ∀ i, MeasurableSet (s i))
(H : Pairwise (Disjoint on s)) : (∑' i, μ (s i)) ≤ μ (univ : Set α) := by
rw [ENNReal.tsum_eq_iSup_sum]
exact iSup_le fun s =>
sum_measure_le_measure_univ (fun i _hi => hs i) fun i _hi j _hj hij => H hij
#align measure_theory.tsum_measure_le_measure_univ MeasureTheory.tsum_measure_le_measure_univ
theorem exists_nonempty_inter_of_measure_univ_lt_tsum_measure {m : MeasurableSpace α}
(μ : Measure α) {s : ι → Set α} (hs : ∀ i, MeasurableSet (s i))
(H : μ (univ : Set α) < ∑' i, μ (s i)) : ∃ i j, i ≠ j ∧ (s i ∩ s j).Nonempty := by
contrapose! H
apply tsum_measure_le_measure_univ hs
intro i j hij
exact disjoint_iff_inter_eq_empty.mpr (H i j hij)
#align measure_theory.exists_nonempty_inter_of_measure_univ_lt_tsum_measure MeasureTheory.exists_nonempty_inter_of_measure_univ_lt_tsum_measure
theorem exists_nonempty_inter_of_measure_univ_lt_sum_measure {m : MeasurableSpace α} (μ : Measure α)
{s : Finset ι} {t : ι → Set α} (h : ∀ i ∈ s, MeasurableSet (t i))
(H : μ (univ : Set α) < ∑ i ∈ s, μ (t i)) :
∃ i ∈ s, ∃ j ∈ s, ∃ _h : i ≠ j, (t i ∩ t j).Nonempty := by
contrapose! H
apply sum_measure_le_measure_univ h
intro i hi j hj hij
exact disjoint_iff_inter_eq_empty.mpr (H i hi j hj hij)
#align measure_theory.exists_nonempty_inter_of_measure_univ_lt_sum_measure MeasureTheory.exists_nonempty_inter_of_measure_univ_lt_sum_measure
theorem nonempty_inter_of_measure_lt_add {m : MeasurableSpace α} (μ : Measure α) {s t u : Set α}
(ht : MeasurableSet t) (h's : s ⊆ u) (h't : t ⊆ u) (h : μ u < μ s + μ t) :
(s ∩ t).Nonempty := by
rw [← Set.not_disjoint_iff_nonempty_inter]
contrapose! h
calc
μ s + μ t = μ (s ∪ t) := (measure_union h ht).symm
_ ≤ μ u := measure_mono (union_subset h's h't)
#align measure_theory.nonempty_inter_of_measure_lt_add MeasureTheory.nonempty_inter_of_measure_lt_add
theorem nonempty_inter_of_measure_lt_add' {m : MeasurableSpace α} (μ : Measure α) {s t u : Set α}
(hs : MeasurableSet s) (h's : s ⊆ u) (h't : t ⊆ u) (h : μ u < μ s + μ t) :
(s ∩ t).Nonempty := by
rw [add_comm] at h
rw [inter_comm]
exact nonempty_inter_of_measure_lt_add μ hs h't h's h
#align measure_theory.nonempty_inter_of_measure_lt_add' MeasureTheory.nonempty_inter_of_measure_lt_add'
theorem measure_iUnion_eq_iSup [Countable ι] {s : ι → Set α} (hd : Directed (· ⊆ ·) s) :
μ (⋃ i, s i) = ⨆ i, μ (s i) := by
cases nonempty_encodable ι
-- WLOG, `ι = ℕ`
generalize ht : Function.extend Encodable.encode s ⊥ = t
replace hd : Directed (· ⊆ ·) t := ht ▸ hd.extend_bot Encodable.encode_injective
suffices μ (⋃ n, t n) = ⨆ n, μ (t n) by
simp only [← ht, Function.apply_extend μ, ← iSup_eq_iUnion,
iSup_extend_bot Encodable.encode_injective, (· ∘ ·), Pi.bot_apply, bot_eq_empty,
measure_empty] at this
exact this.trans (iSup_extend_bot Encodable.encode_injective _)
clear! ι
-- The `≥` inequality is trivial
refine le_antisymm ?_ (iSup_le fun i => measure_mono <| subset_iUnion _ _)
-- Choose `T n ⊇ t n` of the same measure, put `Td n = disjointed T`
set T : ℕ → Set α := fun n => toMeasurable μ (t n)
set Td : ℕ → Set α := disjointed T
have hm : ∀ n, MeasurableSet (Td n) :=
MeasurableSet.disjointed fun n => measurableSet_toMeasurable _ _
calc
μ (⋃ n, t n) ≤ μ (⋃ n, T n) := measure_mono (iUnion_mono fun i => subset_toMeasurable _ _)
_ = μ (⋃ n, Td n) := by rw [iUnion_disjointed]
_ ≤ ∑' n, μ (Td n) := measure_iUnion_le _
_ = ⨆ I : Finset ℕ, ∑ n ∈ I, μ (Td n) := ENNReal.tsum_eq_iSup_sum
_ ≤ ⨆ n, μ (t n) := iSup_le fun I => by
rcases hd.finset_le I with ⟨N, hN⟩
calc
(∑ n ∈ I, μ (Td n)) = μ (⋃ n ∈ I, Td n) :=
(measure_biUnion_finset ((disjoint_disjointed T).set_pairwise I) fun n _ => hm n).symm
_ ≤ μ (⋃ n ∈ I, T n) := measure_mono (iUnion₂_mono fun n _hn => disjointed_subset _ _)
_ = μ (⋃ n ∈ I, t n) := measure_biUnion_toMeasurable I.countable_toSet _
_ ≤ μ (t N) := measure_mono (iUnion₂_subset hN)
_ ≤ ⨆ n, μ (t n) := le_iSup (μ ∘ t) N
#align measure_theory.measure_Union_eq_supr MeasureTheory.measure_iUnion_eq_iSup
| Mathlib/MeasureTheory/Measure/MeasureSpace.lean | 507 | 516 | theorem measure_iUnion_eq_iSup' {α ι : Type*} [MeasurableSpace α] {μ : Measure α}
[Countable ι] [Preorder ι] [IsDirected ι (· ≤ ·)]
{f : ι → Set α} : μ (⋃ i, f i) = ⨆ i, μ (Accumulate f i) := by |
have hd : Directed (· ⊆ ·) (Accumulate f) := by
intro i j
rcases directed_of (· ≤ ·) i j with ⟨k, rik, rjk⟩
exact ⟨k, biUnion_subset_biUnion_left fun l rli ↦ le_trans rli rik,
biUnion_subset_biUnion_left fun l rlj ↦ le_trans rlj rjk⟩
rw [← iUnion_accumulate]
exact measure_iUnion_eq_iSup hd
|
import Batteries.Data.Rat.Basic
import Batteries.Tactic.SeqFocus
namespace Rat
theorem ext : {p q : Rat} → p.num = q.num → p.den = q.den → p = q
| ⟨_,_,_,_⟩, ⟨_,_,_,_⟩, rfl, rfl => rfl
@[simp] theorem mk_den_one {r : Int} :
⟨r, 1, Nat.one_ne_zero, (Nat.coprime_one_right _)⟩ = (r : Rat) := rfl
@[simp] theorem zero_num : (0 : Rat).num = 0 := rfl
@[simp] theorem zero_den : (0 : Rat).den = 1 := rfl
@[simp] theorem one_num : (1 : Rat).num = 1 := rfl
@[simp] theorem one_den : (1 : Rat).den = 1 := rfl
@[simp] theorem maybeNormalize_eq {num den g} (den_nz reduced) :
maybeNormalize num den g den_nz reduced =
{ num := num.div g, den := den / g, den_nz, reduced } := by
unfold maybeNormalize; split
· subst g; simp
· rfl
theorem normalize.reduced' {num : Int} {den g : Nat} (den_nz : den ≠ 0)
(e : g = num.natAbs.gcd den) : (num / g).natAbs.Coprime (den / g) := by
rw [← Int.div_eq_ediv_of_dvd (e ▸ Int.ofNat_dvd_left.2 (Nat.gcd_dvd_left ..))]
exact normalize.reduced den_nz e
theorem normalize_eq {num den} (den_nz) : normalize num den den_nz =
{ num := num / num.natAbs.gcd den
den := den / num.natAbs.gcd den
den_nz := normalize.den_nz den_nz rfl
reduced := normalize.reduced' den_nz rfl } := by
simp only [normalize, maybeNormalize_eq,
Int.div_eq_ediv_of_dvd (Int.ofNat_dvd_left.2 (Nat.gcd_dvd_left ..))]
@[simp] theorem normalize_zero (nz) : normalize 0 d nz = 0 := by
simp [normalize, Int.zero_div, Int.natAbs_zero, Nat.div_self (Nat.pos_of_ne_zero nz)]; rfl
theorem mk_eq_normalize (num den nz c) : ⟨num, den, nz, c⟩ = normalize num den nz := by
simp [normalize_eq, c.gcd_eq_one]
theorem normalize_self (r : Rat) : normalize r.num r.den r.den_nz = r := (mk_eq_normalize ..).symm
theorem normalize_mul_left {a : Nat} (d0 : d ≠ 0) (a0 : a ≠ 0) :
normalize (↑a * n) (a * d) (Nat.mul_ne_zero a0 d0) = normalize n d d0 := by
simp [normalize_eq, mk'.injEq, Int.natAbs_mul, Nat.gcd_mul_left,
Nat.mul_div_mul_left _ _ (Nat.pos_of_ne_zero a0), Int.ofNat_mul,
Int.mul_ediv_mul_of_pos _ _ (Int.ofNat_pos.2 <| Nat.pos_of_ne_zero a0)]
theorem normalize_mul_right {a : Nat} (d0 : d ≠ 0) (a0 : a ≠ 0) :
normalize (n * a) (d * a) (Nat.mul_ne_zero d0 a0) = normalize n d d0 := by
rw [← normalize_mul_left (d0 := d0) a0]; congr 1 <;> [apply Int.mul_comm; apply Nat.mul_comm]
theorem normalize_eq_iff (z₁ : d₁ ≠ 0) (z₂ : d₂ ≠ 0) :
normalize n₁ d₁ z₁ = normalize n₂ d₂ z₂ ↔ n₁ * d₂ = n₂ * d₁ := by
constructor <;> intro h
· simp only [normalize_eq, mk'.injEq] at h
have' hn₁ := Int.ofNat_dvd_left.2 <| Nat.gcd_dvd_left n₁.natAbs d₁
have' hn₂ := Int.ofNat_dvd_left.2 <| Nat.gcd_dvd_left n₂.natAbs d₂
have' hd₁ := Int.ofNat_dvd.2 <| Nat.gcd_dvd_right n₁.natAbs d₁
have' hd₂ := Int.ofNat_dvd.2 <| Nat.gcd_dvd_right n₂.natAbs d₂
rw [← Int.ediv_mul_cancel (Int.dvd_trans hd₂ (Int.dvd_mul_left ..)),
Int.mul_ediv_assoc _ hd₂, ← Int.ofNat_ediv, ← h.2, Int.ofNat_ediv,
← Int.mul_ediv_assoc _ hd₁, Int.mul_ediv_assoc' _ hn₁,
Int.mul_right_comm, h.1, Int.ediv_mul_cancel hn₂]
· rw [← normalize_mul_right _ z₂, ← normalize_mul_left z₂ z₁, Int.mul_comm d₁, h]
theorem maybeNormalize_eq_normalize {num : Int} {den g : Nat} (den_nz reduced)
(hn : ↑g ∣ num) (hd : g ∣ den) :
maybeNormalize num den g den_nz reduced = normalize num den (mt (by simp [·]) den_nz) := by
simp only [maybeNormalize_eq, mk_eq_normalize, Int.div_eq_ediv_of_dvd hn]
have : g ≠ 0 := mt (by simp [·]) den_nz
rw [← normalize_mul_right _ this, Int.ediv_mul_cancel hn]
congr 1; exact Nat.div_mul_cancel hd
@[simp] theorem normalize_eq_zero (d0 : d ≠ 0) : normalize n d d0 = 0 ↔ n = 0 := by
have' := normalize_eq_iff d0 Nat.one_ne_zero
rw [normalize_zero (d := 1)] at this; rw [this]; simp
theorem normalize_num_den' (num den nz) : ∃ d : Nat, d ≠ 0 ∧
num = (normalize num den nz).num * d ∧ den = (normalize num den nz).den * d := by
refine ⟨num.natAbs.gcd den, Nat.gcd_ne_zero_right nz, ?_⟩
simp [normalize_eq, Int.ediv_mul_cancel (Int.ofNat_dvd_left.2 <| Nat.gcd_dvd_left ..),
Nat.div_mul_cancel (Nat.gcd_dvd_right ..)]
theorem normalize_num_den (h : normalize n d z = ⟨n', d', z', c⟩) :
∃ m : Nat, m ≠ 0 ∧ n = n' * m ∧ d = d' * m := by
have := normalize_num_den' n d z; rwa [h] at this
theorem normalize_eq_mkRat {num den} (den_nz) : normalize num den den_nz = mkRat num den := by
simp [mkRat, den_nz]
theorem mkRat_num_den (z : d ≠ 0) (h : mkRat n d = ⟨n', d', z', c⟩) :
∃ m : Nat, m ≠ 0 ∧ n = n' * m ∧ d = d' * m :=
normalize_num_den ((normalize_eq_mkRat z).symm ▸ h)
theorem mkRat_def (n d) : mkRat n d = if d0 : d = 0 then 0 else normalize n d d0 := rfl
theorem mkRat_self (a : Rat) : mkRat a.num a.den = a := by
rw [← normalize_eq_mkRat a.den_nz, normalize_self]
theorem mk_eq_mkRat (num den nz c) : ⟨num, den, nz, c⟩ = mkRat num den := by
simp [mk_eq_normalize, normalize_eq_mkRat]
@[simp] theorem zero_mkRat (n) : mkRat 0 n = 0 := by simp [mkRat_def]
@[simp] theorem mkRat_zero (n) : mkRat n 0 = 0 := by simp [mkRat_def]
theorem mkRat_eq_zero (d0 : d ≠ 0) : mkRat n d = 0 ↔ n = 0 := by simp [mkRat_def, d0]
theorem mkRat_ne_zero (d0 : d ≠ 0) : mkRat n d ≠ 0 ↔ n ≠ 0 := not_congr (mkRat_eq_zero d0)
theorem mkRat_mul_left {a : Nat} (a0 : a ≠ 0) : mkRat (↑a * n) (a * d) = mkRat n d := by
if d0 : d = 0 then simp [d0] else
rw [← normalize_eq_mkRat d0, ← normalize_mul_left d0 a0, normalize_eq_mkRat]
theorem mkRat_mul_right {a : Nat} (a0 : a ≠ 0) : mkRat (n * a) (d * a) = mkRat n d := by
rw [← mkRat_mul_left (d := d) a0]; congr 1 <;> [apply Int.mul_comm; apply Nat.mul_comm]
theorem mkRat_eq_iff (z₁ : d₁ ≠ 0) (z₂ : d₂ ≠ 0) :
mkRat n₁ d₁ = mkRat n₂ d₂ ↔ n₁ * d₂ = n₂ * d₁ := by
rw [← normalize_eq_mkRat z₁, ← normalize_eq_mkRat z₂, normalize_eq_iff]
@[simp] theorem divInt_ofNat (num den) : num /. (den : Nat) = mkRat num den := by
simp [divInt, normalize_eq_mkRat]
theorem mk_eq_divInt (num den nz c) : ⟨num, den, nz, c⟩ = num /. (den : Nat) := by
simp [mk_eq_mkRat]
theorem divInt_self (a : Rat) : a.num /. a.den = a := by rw [divInt_ofNat, mkRat_self]
@[simp] theorem zero_divInt (n) : 0 /. n = 0 := by cases n <;> simp [divInt]
@[simp] theorem divInt_zero (n) : n /. 0 = 0 := mkRat_zero n
theorem neg_divInt_neg (num den) : -num /. -den = num /. den := by
match den with
| Nat.succ n =>
simp only [divInt, Int.neg_ofNat_succ]
simp [normalize_eq_mkRat, Int.neg_neg]
| 0 => rfl
| Int.negSucc n =>
simp only [divInt, Int.neg_negSucc]
simp [normalize_eq_mkRat, Int.neg_neg]
theorem divInt_neg' (num den) : num /. -den = -num /. den := by rw [← neg_divInt_neg, Int.neg_neg]
theorem divInt_eq_iff (z₁ : d₁ ≠ 0) (z₂ : d₂ ≠ 0) :
n₁ /. d₁ = n₂ /. d₂ ↔ n₁ * d₂ = n₂ * d₁ := by
rcases Int.eq_nat_or_neg d₁ with ⟨_, rfl | rfl⟩ <;>
rcases Int.eq_nat_or_neg d₂ with ⟨_, rfl | rfl⟩ <;>
simp_all [divInt_neg', Int.ofNat_eq_zero, Int.neg_eq_zero,
mkRat_eq_iff, Int.neg_mul, Int.mul_neg, Int.eq_neg_comm, eq_comm]
theorem divInt_mul_left {a : Int} (a0 : a ≠ 0) : (a * n) /. (a * d) = n /. d := by
if d0 : d = 0 then simp [d0] else
simp [divInt_eq_iff (Int.mul_ne_zero a0 d0) d0, Int.mul_assoc, Int.mul_left_comm]
theorem divInt_mul_right {a : Int} (a0 : a ≠ 0) : (n * a) /. (d * a) = n /. d := by
simp [← divInt_mul_left (d := d) a0, Int.mul_comm]
theorem divInt_num_den (z : d ≠ 0) (h : n /. d = ⟨n', d', z', c⟩) :
∃ m, m ≠ 0 ∧ n = n' * m ∧ d = d' * m := by
rcases Int.eq_nat_or_neg d with ⟨_, rfl | rfl⟩ <;>
simp_all [divInt_neg', Int.ofNat_eq_zero, Int.neg_eq_zero]
· have ⟨m, h₁, h₂⟩ := mkRat_num_den z h; exists m
simp [Int.ofNat_eq_zero, Int.ofNat_mul, h₁, h₂]
· have ⟨m, h₁, h₂⟩ := mkRat_num_den z h; exists -m
rw [← Int.neg_inj, Int.neg_neg] at h₂
simp [Int.ofNat_eq_zero, Int.ofNat_mul, h₁, h₂, Int.mul_neg, Int.neg_eq_zero]
@[simp] theorem ofInt_ofNat : ofInt (OfNat.ofNat n) = OfNat.ofNat n := rfl
@[simp] theorem ofInt_num : (ofInt n : Rat).num = n := rfl
@[simp] theorem ofInt_den : (ofInt n : Rat).den = 1 := rfl
@[simp] theorem ofNat_num : (OfNat.ofNat n : Rat).num = OfNat.ofNat n := rfl
@[simp] theorem ofNat_den : (OfNat.ofNat n : Rat).den = 1 := rfl
theorem add_def (a b : Rat) :
a + b = normalize (a.num * b.den + b.num * a.den) (a.den * b.den)
(Nat.mul_ne_zero a.den_nz b.den_nz) := by
show Rat.add .. = _; delta Rat.add; dsimp only; split
· exact (normalize_self _).symm
· have : a.den.gcd b.den ≠ 0 := Nat.gcd_ne_zero_left a.den_nz
rw [maybeNormalize_eq_normalize _ _
(Int.ofNat_dvd_left.2 <| Nat.gcd_dvd_left ..)
(Nat.dvd_trans (Nat.gcd_dvd_right ..) <|
Nat.dvd_trans (Nat.gcd_dvd_right ..) (Nat.dvd_mul_left ..)),
← normalize_mul_right _ this]; congr 1
· simp only [Int.add_mul, Int.mul_assoc, Int.ofNat_mul_ofNat,
Nat.div_mul_cancel (Nat.gcd_dvd_left ..), Nat.div_mul_cancel (Nat.gcd_dvd_right ..)]
· rw [Nat.mul_right_comm, Nat.div_mul_cancel (Nat.gcd_dvd_left ..)]
theorem add_def' (a b : Rat) : a + b = mkRat (a.num * b.den + b.num * a.den) (a.den * b.den) := by
rw [add_def, normalize_eq_mkRat]
theorem normalize_add_normalize (n₁ n₂) {d₁ d₂} (z₁ z₂) :
normalize n₁ d₁ z₁ + normalize n₂ d₂ z₂ =
normalize (n₁ * d₂ + n₂ * d₁) (d₁ * d₂) (Nat.mul_ne_zero z₁ z₂) := by
cases e₁ : normalize n₁ d₁ z₁; rcases normalize_num_den e₁ with ⟨g₁, zg₁, rfl, rfl⟩
cases e₂ : normalize n₂ d₂ z₂; rcases normalize_num_den e₂ with ⟨g₂, zg₂, rfl, rfl⟩
simp only [add_def]; rw [← normalize_mul_right _ (Nat.mul_ne_zero zg₁ zg₂)]; congr 1
· rw [Int.add_mul]; simp [Int.ofNat_mul, Int.mul_assoc, Int.mul_left_comm, Int.mul_comm]
· simp [Nat.mul_left_comm, Nat.mul_comm]
| .lake/packages/batteries/Batteries/Data/Rat/Lemmas.lean | 215 | 217 | theorem mkRat_add_mkRat (n₁ n₂ : Int) {d₁ d₂} (z₁ : d₁ ≠ 0) (z₂ : d₂ ≠ 0) :
mkRat n₁ d₁ + mkRat n₂ d₂ = mkRat (n₁ * d₂ + n₂ * d₁) (d₁ * d₂) := by |
rw [← normalize_eq_mkRat z₁, ← normalize_eq_mkRat z₂, normalize_add_normalize, normalize_eq_mkRat]
|
import Mathlib.Data.DFinsupp.Basic
#align_import data.dfinsupp.ne_locus from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c"
variable {α : Type*} {N : α → Type*}
namespace DFinsupp
variable [DecidableEq α]
section NHasZero
variable [∀ a, DecidableEq (N a)] [∀ a, Zero (N a)] (f g : Π₀ a, N a)
def neLocus (f g : Π₀ a, N a) : Finset α :=
(f.support ∪ g.support).filter fun x ↦ f x ≠ g x
#align dfinsupp.ne_locus DFinsupp.neLocus
@[simp]
theorem mem_neLocus {f g : Π₀ a, N a} {a : α} : a ∈ f.neLocus g ↔ f a ≠ g a := by
simpa only [neLocus, Finset.mem_filter, Finset.mem_union, mem_support_iff,
and_iff_right_iff_imp] using Ne.ne_or_ne _
#align dfinsupp.mem_ne_locus DFinsupp.mem_neLocus
theorem not_mem_neLocus {f g : Π₀ a, N a} {a : α} : a ∉ f.neLocus g ↔ f a = g a :=
mem_neLocus.not.trans not_ne_iff
#align dfinsupp.not_mem_ne_locus DFinsupp.not_mem_neLocus
@[simp]
theorem coe_neLocus : ↑(f.neLocus g) = { x | f x ≠ g x } :=
Set.ext fun _x ↦ mem_neLocus
#align dfinsupp.coe_ne_locus DFinsupp.coe_neLocus
@[simp]
theorem neLocus_eq_empty {f g : Π₀ a, N a} : f.neLocus g = ∅ ↔ f = g :=
⟨fun h ↦
ext fun a ↦ not_not.mp (mem_neLocus.not.mp (Finset.eq_empty_iff_forall_not_mem.mp h a)),
fun h ↦ h ▸ by simp only [neLocus, Ne, eq_self_iff_true, not_true, Finset.filter_False]⟩
#align dfinsupp.ne_locus_eq_empty DFinsupp.neLocus_eq_empty
@[simp]
theorem nonempty_neLocus_iff {f g : Π₀ a, N a} : (f.neLocus g).Nonempty ↔ f ≠ g :=
Finset.nonempty_iff_ne_empty.trans neLocus_eq_empty.not
#align dfinsupp.nonempty_ne_locus_iff DFinsupp.nonempty_neLocus_iff
theorem neLocus_comm : f.neLocus g = g.neLocus f := by
simp_rw [neLocus, Finset.union_comm, ne_comm]
#align dfinsupp.ne_locus_comm DFinsupp.neLocus_comm
@[simp]
| Mathlib/Data/DFinsupp/NeLocus.lean | 72 | 74 | theorem neLocus_zero_right : f.neLocus 0 = f.support := by |
ext
rw [mem_neLocus, mem_support_iff, coe_zero, Pi.zero_apply]
|
import Mathlib.Data.List.Infix
#align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2"
-- Make sure we don't import algebra
assert_not_exists Monoid
variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ)
namespace List
def rdrop : List α :=
l.take (l.length - n)
#align list.rdrop List.rdrop
@[simp]
theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop]
#align list.rdrop_nil List.rdrop_nil
@[simp]
theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop]
#align list.rdrop_zero List.rdrop_zero
theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by
rw [rdrop]
induction' l using List.reverseRecOn with xs x IH generalizing n
· simp
· cases n
· simp [take_append]
· simp [take_append_eq_append_take, IH]
#align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse
@[simp]
theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by
simp [rdrop_eq_reverse_drop_reverse]
#align list.rdrop_concat_succ List.rdrop_concat_succ
def rtake : List α :=
l.drop (l.length - n)
#align list.rtake List.rtake
@[simp]
| Mathlib/Data/List/DropRight.lean | 74 | 74 | theorem rtake_nil : rtake ([] : List α) n = [] := by | simp [rtake]
|
import Mathlib.Algebra.Polynomial.Reverse
import Mathlib.Algebra.Regular.SMul
#align_import data.polynomial.monic from "leanprover-community/mathlib"@"cbdf7b565832144d024caa5a550117c6df0204a5"
noncomputable section
open Finset
open Polynomial
namespace Polynomial
universe u v y
variable {R : Type u} {S : Type v} {a b : R} {m n : ℕ} {ι : Type y}
section Semiring
variable [Semiring R] {p q r : R[X]}
theorem monic_zero_iff_subsingleton : Monic (0 : R[X]) ↔ Subsingleton R :=
subsingleton_iff_zero_eq_one
#align polynomial.monic_zero_iff_subsingleton Polynomial.monic_zero_iff_subsingleton
theorem not_monic_zero_iff : ¬Monic (0 : R[X]) ↔ (0 : R) ≠ 1 :=
(monic_zero_iff_subsingleton.trans subsingleton_iff_zero_eq_one.symm).not
#align polynomial.not_monic_zero_iff Polynomial.not_monic_zero_iff
theorem monic_zero_iff_subsingleton' :
Monic (0 : R[X]) ↔ (∀ f g : R[X], f = g) ∧ ∀ a b : R, a = b :=
Polynomial.monic_zero_iff_subsingleton.trans
⟨by
intro
simp [eq_iff_true_of_subsingleton], fun h => subsingleton_iff.mpr h.2⟩
#align polynomial.monic_zero_iff_subsingleton' Polynomial.monic_zero_iff_subsingleton'
theorem Monic.as_sum (hp : p.Monic) :
p = X ^ p.natDegree + ∑ i ∈ range p.natDegree, C (p.coeff i) * X ^ i := by
conv_lhs => rw [p.as_sum_range_C_mul_X_pow, sum_range_succ_comm]
suffices C (p.coeff p.natDegree) = 1 by rw [this, one_mul]
exact congr_arg C hp
#align polynomial.monic.as_sum Polynomial.Monic.as_sum
theorem ne_zero_of_ne_zero_of_monic (hp : p ≠ 0) (hq : Monic q) : q ≠ 0 := by
rintro rfl
rw [Monic.def, leadingCoeff_zero] at hq
rw [← mul_one p, ← C_1, ← hq, C_0, mul_zero] at hp
exact hp rfl
#align polynomial.ne_zero_of_ne_zero_of_monic Polynomial.ne_zero_of_ne_zero_of_monic
theorem Monic.map [Semiring S] (f : R →+* S) (hp : Monic p) : Monic (p.map f) := by
unfold Monic
nontriviality
have : f p.leadingCoeff ≠ 0 := by
rw [show _ = _ from hp, f.map_one]
exact one_ne_zero
rw [Polynomial.leadingCoeff, coeff_map]
suffices p.coeff (p.map f).natDegree = 1 by simp [this]
rwa [natDegree_eq_of_degree_eq (degree_map_eq_of_leadingCoeff_ne_zero f this)]
#align polynomial.monic.map Polynomial.Monic.map
theorem monic_C_mul_of_mul_leadingCoeff_eq_one {b : R} (hp : b * p.leadingCoeff = 1) :
Monic (C b * p) := by
unfold Monic
nontriviality
rw [leadingCoeff_mul' _] <;> simp [leadingCoeff_C b, hp]
set_option linter.uppercaseLean3 false in
#align polynomial.monic_C_mul_of_mul_leading_coeff_eq_one Polynomial.monic_C_mul_of_mul_leadingCoeff_eq_one
theorem monic_mul_C_of_leadingCoeff_mul_eq_one {b : R} (hp : p.leadingCoeff * b = 1) :
Monic (p * C b) := by
unfold Monic
nontriviality
rw [leadingCoeff_mul' _] <;> simp [leadingCoeff_C b, hp]
set_option linter.uppercaseLean3 false in
#align polynomial.monic_mul_C_of_leading_coeff_mul_eq_one Polynomial.monic_mul_C_of_leadingCoeff_mul_eq_one
theorem monic_of_degree_le (n : ℕ) (H1 : degree p ≤ n) (H2 : coeff p n = 1) : Monic p :=
Decidable.byCases
(fun H : degree p < n => eq_of_zero_eq_one (H2 ▸ (coeff_eq_zero_of_degree_lt H).symm) _ _)
fun H : ¬degree p < n => by
rwa [Monic, Polynomial.leadingCoeff, natDegree, (lt_or_eq_of_le H1).resolve_left H]
#align polynomial.monic_of_degree_le Polynomial.monic_of_degree_le
theorem monic_X_pow_add {n : ℕ} (H : degree p ≤ n) : Monic (X ^ (n + 1) + p) :=
have H1 : degree p < (n + 1 : ℕ) := lt_of_le_of_lt H (WithBot.coe_lt_coe.2 (Nat.lt_succ_self n))
monic_of_degree_le (n + 1)
(le_trans (degree_add_le _ _) (max_le (degree_X_pow_le _) (le_of_lt H1)))
(by rw [coeff_add, coeff_X_pow, if_pos rfl, coeff_eq_zero_of_degree_lt H1, add_zero])
set_option linter.uppercaseLean3 false in
#align polynomial.monic_X_pow_add Polynomial.monic_X_pow_add
variable (a) in
theorem monic_X_pow_add_C {n : ℕ} (h : n ≠ 0) : (X ^ n + C a).Monic := by
obtain ⟨k, rfl⟩ := Nat.exists_eq_succ_of_ne_zero h
exact monic_X_pow_add <| degree_C_le.trans Nat.WithBot.coe_nonneg
theorem monic_X_add_C (x : R) : Monic (X + C x) :=
pow_one (X : R[X]) ▸ monic_X_pow_add_C x one_ne_zero
set_option linter.uppercaseLean3 false in
#align polynomial.monic_X_add_C Polynomial.monic_X_add_C
theorem Monic.mul (hp : Monic p) (hq : Monic q) : Monic (p * q) :=
letI := Classical.decEq R
if h0 : (0 : R) = 1 then
haveI := subsingleton_of_zero_eq_one h0
Subsingleton.elim _ _
else by
have : p.leadingCoeff * q.leadingCoeff ≠ 0 := by
simp [Monic.def.1 hp, Monic.def.1 hq, Ne.symm h0]
rw [Monic.def, leadingCoeff_mul' this, Monic.def.1 hp, Monic.def.1 hq, one_mul]
#align polynomial.monic.mul Polynomial.Monic.mul
theorem Monic.pow (hp : Monic p) : ∀ n : ℕ, Monic (p ^ n)
| 0 => monic_one
| n + 1 => by
rw [pow_succ]
exact (Monic.pow hp n).mul hp
#align polynomial.monic.pow Polynomial.Monic.pow
theorem Monic.add_of_left (hp : Monic p) (hpq : degree q < degree p) : Monic (p + q) := by
rwa [Monic, add_comm, leadingCoeff_add_of_degree_lt hpq]
#align polynomial.monic.add_of_left Polynomial.Monic.add_of_left
theorem Monic.add_of_right (hq : Monic q) (hpq : degree p < degree q) : Monic (p + q) := by
rwa [Monic, leadingCoeff_add_of_degree_lt hpq]
#align polynomial.monic.add_of_right Polynomial.Monic.add_of_right
theorem Monic.of_mul_monic_left (hp : p.Monic) (hpq : (p * q).Monic) : q.Monic := by
contrapose! hpq
rw [Monic.def] at hpq ⊢
rwa [leadingCoeff_monic_mul hp]
#align polynomial.monic.of_mul_monic_left Polynomial.Monic.of_mul_monic_left
theorem Monic.of_mul_monic_right (hq : q.Monic) (hpq : (p * q).Monic) : p.Monic := by
contrapose! hpq
rw [Monic.def] at hpq ⊢
rwa [leadingCoeff_mul_monic hq]
#align polynomial.monic.of_mul_monic_right Polynomial.Monic.of_mul_monic_right
section Semiring
variable [Semiring R]
@[simp]
theorem Monic.natDegree_map [Semiring S] [Nontrivial S] {P : R[X]} (hmo : P.Monic) (f : R →+* S) :
(P.map f).natDegree = P.natDegree := by
refine le_antisymm (natDegree_map_le _ _) (le_natDegree_of_ne_zero ?_)
rw [coeff_map, Monic.coeff_natDegree hmo, RingHom.map_one]
exact one_ne_zero
#align polynomial.monic.nat_degree_map Polynomial.Monic.natDegree_map
@[simp]
theorem Monic.degree_map [Semiring S] [Nontrivial S] {P : R[X]} (hmo : P.Monic) (f : R →+* S) :
(P.map f).degree = P.degree := by
by_cases hP : P = 0
· simp [hP]
· refine le_antisymm (degree_map_le _ _) ?_
rw [degree_eq_natDegree hP]
refine le_degree_of_ne_zero ?_
rw [coeff_map, Monic.coeff_natDegree hmo, RingHom.map_one]
exact one_ne_zero
#align polynomial.monic.degree_map Polynomial.Monic.degree_map
section Injective
open Function
variable [Semiring S] {f : R →+* S} (hf : Injective f)
theorem degree_map_eq_of_injective (p : R[X]) : degree (p.map f) = degree p :=
letI := Classical.decEq R
if h : p = 0 then by simp [h]
else
degree_map_eq_of_leadingCoeff_ne_zero _
(by rw [← f.map_zero]; exact mt hf.eq_iff.1 (mt leadingCoeff_eq_zero.1 h))
#align polynomial.degree_map_eq_of_injective Polynomial.degree_map_eq_of_injective
theorem natDegree_map_eq_of_injective (p : R[X]) : natDegree (p.map f) = natDegree p :=
natDegree_eq_of_degree_eq (degree_map_eq_of_injective hf p)
#align polynomial.nat_degree_map_eq_of_injective Polynomial.natDegree_map_eq_of_injective
| Mathlib/Algebra/Polynomial/Monic.lean | 355 | 357 | theorem leadingCoeff_map' (p : R[X]) : leadingCoeff (p.map f) = f (leadingCoeff p) := by |
unfold leadingCoeff
rw [coeff_map, natDegree_map_eq_of_injective hf p]
|
import Mathlib.Order.Filter.Basic
import Mathlib.Topology.Bases
import Mathlib.Data.Set.Accumulate
import Mathlib.Topology.Bornology.Basic
import Mathlib.Topology.LocallyFinite
open Set Filter Topology TopologicalSpace Classical Function
universe u v
variable {X : Type u} {Y : Type v} {ι : Type*}
variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X}
-- compact sets
section Compact
lemma IsCompact.exists_clusterPt (hs : IsCompact s) {f : Filter X} [NeBot f] (hf : f ≤ 𝓟 s) :
∃ x ∈ s, ClusterPt x f := hs hf
lemma IsCompact.exists_mapClusterPt {ι : Type*} (hs : IsCompact s) {f : Filter ι} [NeBot f]
{u : ι → X} (hf : Filter.map u f ≤ 𝓟 s) :
∃ x ∈ s, MapClusterPt x f u := hs hf
theorem IsCompact.compl_mem_sets (hs : IsCompact s) {f : Filter X} (hf : ∀ x ∈ s, sᶜ ∈ 𝓝 x ⊓ f) :
sᶜ ∈ f := by
contrapose! hf
simp only [not_mem_iff_inf_principal_compl, compl_compl, inf_assoc] at hf ⊢
exact @hs _ hf inf_le_right
#align is_compact.compl_mem_sets IsCompact.compl_mem_sets
theorem IsCompact.compl_mem_sets_of_nhdsWithin (hs : IsCompact s) {f : Filter X}
(hf : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, tᶜ ∈ f) : sᶜ ∈ f := by
refine hs.compl_mem_sets fun x hx => ?_
rcases hf x hx with ⟨t, ht, hst⟩
replace ht := mem_inf_principal.1 ht
apply mem_inf_of_inter ht hst
rintro x ⟨h₁, h₂⟩ hs
exact h₂ (h₁ hs)
#align is_compact.compl_mem_sets_of_nhds_within IsCompact.compl_mem_sets_of_nhdsWithin
@[elab_as_elim]
theorem IsCompact.induction_on (hs : IsCompact s) {p : Set X → Prop} (he : p ∅)
(hmono : ∀ ⦃s t⦄, s ⊆ t → p t → p s) (hunion : ∀ ⦃s t⦄, p s → p t → p (s ∪ t))
(hnhds : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, p t) : p s := by
let f : Filter X := comk p he (fun _t ht _s hsub ↦ hmono hsub ht) (fun _s hs _t ht ↦ hunion hs ht)
have : sᶜ ∈ f := hs.compl_mem_sets_of_nhdsWithin (by simpa [f] using hnhds)
rwa [← compl_compl s]
#align is_compact.induction_on IsCompact.induction_on
theorem IsCompact.inter_right (hs : IsCompact s) (ht : IsClosed t) : IsCompact (s ∩ t) := by
intro f hnf hstf
obtain ⟨x, hsx, hx⟩ : ∃ x ∈ s, ClusterPt x f :=
hs (le_trans hstf (le_principal_iff.2 inter_subset_left))
have : x ∈ t := ht.mem_of_nhdsWithin_neBot <|
hx.mono <| le_trans hstf (le_principal_iff.2 inter_subset_right)
exact ⟨x, ⟨hsx, this⟩, hx⟩
#align is_compact.inter_right IsCompact.inter_right
theorem IsCompact.inter_left (ht : IsCompact t) (hs : IsClosed s) : IsCompact (s ∩ t) :=
inter_comm t s ▸ ht.inter_right hs
#align is_compact.inter_left IsCompact.inter_left
theorem IsCompact.diff (hs : IsCompact s) (ht : IsOpen t) : IsCompact (s \ t) :=
hs.inter_right (isClosed_compl_iff.mpr ht)
#align is_compact.diff IsCompact.diff
theorem IsCompact.of_isClosed_subset (hs : IsCompact s) (ht : IsClosed t) (h : t ⊆ s) :
IsCompact t :=
inter_eq_self_of_subset_right h ▸ hs.inter_right ht
#align is_compact_of_is_closed_subset IsCompact.of_isClosed_subset
theorem IsCompact.image_of_continuousOn {f : X → Y} (hs : IsCompact s) (hf : ContinuousOn f s) :
IsCompact (f '' s) := by
intro l lne ls
have : NeBot (l.comap f ⊓ 𝓟 s) :=
comap_inf_principal_neBot_of_image_mem lne (le_principal_iff.1 ls)
obtain ⟨x, hxs, hx⟩ : ∃ x ∈ s, ClusterPt x (l.comap f ⊓ 𝓟 s) := @hs _ this inf_le_right
haveI := hx.neBot
use f x, mem_image_of_mem f hxs
have : Tendsto f (𝓝 x ⊓ (comap f l ⊓ 𝓟 s)) (𝓝 (f x) ⊓ l) := by
convert (hf x hxs).inf (@tendsto_comap _ _ f l) using 1
rw [nhdsWithin]
ac_rfl
exact this.neBot
#align is_compact.image_of_continuous_on IsCompact.image_of_continuousOn
theorem IsCompact.image {f : X → Y} (hs : IsCompact s) (hf : Continuous f) : IsCompact (f '' s) :=
hs.image_of_continuousOn hf.continuousOn
#align is_compact.image IsCompact.image
theorem IsCompact.adherence_nhdset {f : Filter X} (hs : IsCompact s) (hf₂ : f ≤ 𝓟 s)
(ht₁ : IsOpen t) (ht₂ : ∀ x ∈ s, ClusterPt x f → x ∈ t) : t ∈ f :=
Classical.by_cases mem_of_eq_bot fun (this : f ⊓ 𝓟 tᶜ ≠ ⊥) =>
let ⟨x, hx, (hfx : ClusterPt x <| f ⊓ 𝓟 tᶜ)⟩ := @hs _ ⟨this⟩ <| inf_le_of_left_le hf₂
have : x ∈ t := ht₂ x hx hfx.of_inf_left
have : tᶜ ∩ t ∈ 𝓝[tᶜ] x := inter_mem_nhdsWithin _ (IsOpen.mem_nhds ht₁ this)
have A : 𝓝[tᶜ] x = ⊥ := empty_mem_iff_bot.1 <| compl_inter_self t ▸ this
have : 𝓝[tᶜ] x ≠ ⊥ := hfx.of_inf_right.ne
absurd A this
#align is_compact.adherence_nhdset IsCompact.adherence_nhdset
| Mathlib/Topology/Compactness/Compact.lean | 134 | 139 | theorem isCompact_iff_ultrafilter_le_nhds :
IsCompact s ↔ ∀ f : Ultrafilter X, ↑f ≤ 𝓟 s → ∃ x ∈ s, ↑f ≤ 𝓝 x := by |
refine (forall_neBot_le_iff ?_).trans ?_
· rintro f g hle ⟨x, hxs, hxf⟩
exact ⟨x, hxs, hxf.mono hle⟩
· simp only [Ultrafilter.clusterPt_iff]
|
import Mathlib.Algebra.Order.Group.PiLex
import Mathlib.Data.DFinsupp.Order
import Mathlib.Data.DFinsupp.NeLocus
import Mathlib.Order.WellFoundedSet
#align_import data.dfinsupp.lex from "leanprover-community/mathlib"@"dde670c9a3f503647fd5bfdf1037bad526d3397a"
variable {ι : Type*} {α : ι → Type*}
namespace DFinsupp
section Zero
variable [∀ i, Zero (α i)]
protected def Lex (r : ι → ι → Prop) (s : ∀ i, α i → α i → Prop) (x y : Π₀ i, α i) : Prop :=
Pi.Lex r (s _) x y
#align dfinsupp.lex DFinsupp.Lex
-- Porting note: Added `_root_` to match more closely with Lean 3. Also updated `s`'s type.
theorem _root_.Pi.lex_eq_dfinsupp_lex {r : ι → ι → Prop} {s : ∀ i, α i → α i → Prop}
(a b : Π₀ i, α i) : Pi.Lex r (s _) (a : ∀ i, α i) b = DFinsupp.Lex r s a b :=
rfl
#align pi.lex_eq_dfinsupp_lex Pi.lex_eq_dfinsupp_lex
-- Porting note: Updated `s`'s type.
theorem lex_def {r : ι → ι → Prop} {s : ∀ i, α i → α i → Prop} {a b : Π₀ i, α i} :
DFinsupp.Lex r s a b ↔ ∃ j, (∀ d, r d j → a d = b d) ∧ s j (a j) (b j) :=
Iff.rfl
#align dfinsupp.lex_def DFinsupp.lex_def
instance [LT ι] [∀ i, LT (α i)] : LT (Lex (Π₀ i, α i)) :=
⟨fun f g ↦ DFinsupp.Lex (· < ·) (fun _ ↦ (· < ·)) (ofLex f) (ofLex g)⟩
theorem lex_lt_of_lt_of_preorder [∀ i, Preorder (α i)] (r) [IsStrictOrder ι r] {x y : Π₀ i, α i}
(hlt : x < y) : ∃ i, (∀ j, r j i → x j ≤ y j ∧ y j ≤ x j) ∧ x i < y i := by
obtain ⟨hle, j, hlt⟩ := Pi.lt_def.1 hlt
classical
have : (x.neLocus y : Set ι).WellFoundedOn r := (x.neLocus y).finite_toSet.wellFoundedOn
obtain ⟨i, hi, hl⟩ := this.has_min { i | x i < y i } ⟨⟨j, mem_neLocus.2 hlt.ne⟩, hlt⟩
refine ⟨i, fun k hk ↦ ⟨hle k, ?_⟩, hi⟩
exact of_not_not fun h ↦ hl ⟨k, mem_neLocus.2 (ne_of_not_le h).symm⟩ ((hle k).lt_of_not_le h) hk
#align dfinsupp.lex_lt_of_lt_of_preorder DFinsupp.lex_lt_of_lt_of_preorder
| Mathlib/Data/DFinsupp/Lex.lean | 61 | 64 | theorem lex_lt_of_lt [∀ i, PartialOrder (α i)] (r) [IsStrictOrder ι r] {x y : Π₀ i, α i}
(hlt : x < y) : Pi.Lex r (· < ·) x y := by |
simp_rw [Pi.Lex, le_antisymm_iff]
exact lex_lt_of_lt_of_preorder r hlt
|
import Mathlib.Order.Interval.Set.UnorderedInterval
import Mathlib.Algebra.Order.Interval.Set.Monoid
import Mathlib.Data.Set.Pointwise.Basic
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Algebra.Order.Group.MinMax
#align_import data.set.pointwise.interval from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
open Interval Pointwise
variable {α : Type*}
namespace Set
section LinearOrderedField
variable [LinearOrderedField α] {a : α}
@[simp]
theorem preimage_mul_const_Iio (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Iio a = Iio (a / c) :=
ext fun _x => (lt_div_iff h).symm
#align set.preimage_mul_const_Iio Set.preimage_mul_const_Iio
@[simp]
theorem preimage_mul_const_Ioi (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ioi a = Ioi (a / c) :=
ext fun _x => (div_lt_iff h).symm
#align set.preimage_mul_const_Ioi Set.preimage_mul_const_Ioi
@[simp]
theorem preimage_mul_const_Iic (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Iic a = Iic (a / c) :=
ext fun _x => (le_div_iff h).symm
#align set.preimage_mul_const_Iic Set.preimage_mul_const_Iic
@[simp]
theorem preimage_mul_const_Ici (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ici a = Ici (a / c) :=
ext fun _x => (div_le_iff h).symm
#align set.preimage_mul_const_Ici Set.preimage_mul_const_Ici
@[simp]
theorem preimage_mul_const_Ioo (a b : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ioo a b = Ioo (a / c) (b / c) := by simp [← Ioi_inter_Iio, h]
#align set.preimage_mul_const_Ioo Set.preimage_mul_const_Ioo
@[simp]
theorem preimage_mul_const_Ioc (a b : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ioc a b = Ioc (a / c) (b / c) := by simp [← Ioi_inter_Iic, h]
#align set.preimage_mul_const_Ioc Set.preimage_mul_const_Ioc
@[simp]
theorem preimage_mul_const_Ico (a b : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ico a b = Ico (a / c) (b / c) := by simp [← Ici_inter_Iio, h]
#align set.preimage_mul_const_Ico Set.preimage_mul_const_Ico
@[simp]
theorem preimage_mul_const_Icc (a b : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Icc a b = Icc (a / c) (b / c) := by simp [← Ici_inter_Iic, h]
#align set.preimage_mul_const_Icc Set.preimage_mul_const_Icc
@[simp]
theorem preimage_mul_const_Iio_of_neg (a : α) {c : α} (h : c < 0) :
(fun x => x * c) ⁻¹' Iio a = Ioi (a / c) :=
ext fun _x => (div_lt_iff_of_neg h).symm
#align set.preimage_mul_const_Iio_of_neg Set.preimage_mul_const_Iio_of_neg
@[simp]
theorem preimage_mul_const_Ioi_of_neg (a : α) {c : α} (h : c < 0) :
(fun x => x * c) ⁻¹' Ioi a = Iio (a / c) :=
ext fun _x => (lt_div_iff_of_neg h).symm
#align set.preimage_mul_const_Ioi_of_neg Set.preimage_mul_const_Ioi_of_neg
@[simp]
theorem preimage_mul_const_Iic_of_neg (a : α) {c : α} (h : c < 0) :
(fun x => x * c) ⁻¹' Iic a = Ici (a / c) :=
ext fun _x => (div_le_iff_of_neg h).symm
#align set.preimage_mul_const_Iic_of_neg Set.preimage_mul_const_Iic_of_neg
@[simp]
theorem preimage_mul_const_Ici_of_neg (a : α) {c : α} (h : c < 0) :
(fun x => x * c) ⁻¹' Ici a = Iic (a / c) :=
ext fun _x => (le_div_iff_of_neg h).symm
#align set.preimage_mul_const_Ici_of_neg Set.preimage_mul_const_Ici_of_neg
@[simp]
theorem preimage_mul_const_Ioo_of_neg (a b : α) {c : α} (h : c < 0) :
(fun x => x * c) ⁻¹' Ioo a b = Ioo (b / c) (a / c) := by simp [← Ioi_inter_Iio, h, inter_comm]
#align set.preimage_mul_const_Ioo_of_neg Set.preimage_mul_const_Ioo_of_neg
@[simp]
| Mathlib/Data/Set/Pointwise/Interval.lean | 668 | 670 | theorem preimage_mul_const_Ioc_of_neg (a b : α) {c : α} (h : c < 0) :
(fun x => x * c) ⁻¹' Ioc a b = Ico (b / c) (a / c) := by |
simp [← Ioi_inter_Iic, ← Ici_inter_Iio, h, inter_comm]
|
import Mathlib.Analysis.Calculus.Deriv.ZPow
import Mathlib.Analysis.SpecialFunctions.Sqrt
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv
import Mathlib.Analysis.Convex.Deriv
#align_import analysis.convex.specific_functions.deriv from "leanprover-community/mathlib"@"a16665637b378379689c566204817ae792ac8b39"
open Real Set
open scoped NNReal
theorem strictConvexOn_pow {n : ℕ} (hn : 2 ≤ n) : StrictConvexOn ℝ (Ici 0) fun x : ℝ => x ^ n := by
apply StrictMonoOn.strictConvexOn_of_deriv (convex_Ici _) (continuousOn_pow _)
rw [deriv_pow', interior_Ici]
exact fun x (hx : 0 < x) y _ hxy => mul_lt_mul_of_pos_left
(pow_lt_pow_left hxy hx.le <| Nat.sub_ne_zero_of_lt hn) (by positivity)
#align strict_convex_on_pow strictConvexOn_pow
theorem Even.strictConvexOn_pow {n : ℕ} (hn : Even n) (h : n ≠ 0) :
StrictConvexOn ℝ Set.univ fun x : ℝ => x ^ n := by
apply StrictMono.strictConvexOn_univ_of_deriv (continuous_pow n)
rw [deriv_pow']
replace h := Nat.pos_of_ne_zero h
exact StrictMono.const_mul (Odd.strictMono_pow <| Nat.Even.sub_odd h hn <| Nat.odd_iff.2 rfl)
(Nat.cast_pos.2 h)
#align even.strict_convex_on_pow Even.strictConvexOn_pow
theorem Finset.prod_nonneg_of_card_nonpos_even {α β : Type*} [LinearOrderedCommRing β] {f : α → β}
[DecidablePred fun x => f x ≤ 0] {s : Finset α} (h0 : Even (s.filter fun x => f x ≤ 0).card) :
0 ≤ ∏ x ∈ s, f x :=
calc
0 ≤ ∏ x ∈ s, (if f x ≤ 0 then (-1 : β) else 1) * f x :=
Finset.prod_nonneg fun x _ => by
split_ifs with hx
· simp [hx]
simp? at hx ⊢ says simp only [not_le, one_mul] at hx ⊢
exact le_of_lt hx
_ = _ := by
rw [Finset.prod_mul_distrib, Finset.prod_ite, Finset.prod_const_one, mul_one,
Finset.prod_const, neg_one_pow_eq_pow_mod_two, Nat.even_iff.1 h0, pow_zero, one_mul]
#align finset.prod_nonneg_of_card_nonpos_even Finset.prod_nonneg_of_card_nonpos_even
theorem int_prod_range_nonneg (m : ℤ) (n : ℕ) (hn : Even n) :
0 ≤ ∏ k ∈ Finset.range n, (m - k) := by
rcases hn with ⟨n, rfl⟩
induction' n with n ihn
· simp
rw [← two_mul] at ihn
rw [← two_mul, mul_add, mul_one, ← one_add_one_eq_two, ← add_assoc,
Finset.prod_range_succ, Finset.prod_range_succ, mul_assoc]
refine mul_nonneg ihn ?_; generalize (1 + 1) * n = k
rcases le_or_lt m k with hmk | hmk
· have : m ≤ k + 1 := hmk.trans (lt_add_one (k : ℤ)).le
convert mul_nonneg_of_nonpos_of_nonpos (sub_nonpos_of_le hmk) _
convert sub_nonpos_of_le this
· exact mul_nonneg (sub_nonneg_of_le hmk.le) (sub_nonneg_of_le hmk)
#align int_prod_range_nonneg int_prod_range_nonneg
theorem int_prod_range_pos {m : ℤ} {n : ℕ} (hn : Even n) (hm : m ∉ Ico (0 : ℤ) n) :
0 < ∏ k ∈ Finset.range n, (m - k) := by
refine (int_prod_range_nonneg m n hn).lt_of_ne fun h => hm ?_
rw [eq_comm, Finset.prod_eq_zero_iff] at h
obtain ⟨a, ha, h⟩ := h
rw [sub_eq_zero.1 h]
exact ⟨Int.ofNat_zero_le _, Int.ofNat_lt.2 <| Finset.mem_range.1 ha⟩
#align int_prod_range_pos int_prod_range_pos
theorem strictConvexOn_zpow {m : ℤ} (hm₀ : m ≠ 0) (hm₁ : m ≠ 1) :
StrictConvexOn ℝ (Ioi 0) fun x : ℝ => x ^ m := by
apply strictConvexOn_of_deriv2_pos' (convex_Ioi 0)
· exact (continuousOn_zpow₀ m).mono fun x hx => ne_of_gt hx
intro x hx
rw [mem_Ioi] at hx
rw [iter_deriv_zpow]
refine mul_pos ?_ (zpow_pos_of_pos hx _)
norm_cast
refine int_prod_range_pos (by decide) fun hm => ?_
rw [← Finset.coe_Ico] at hm
norm_cast at hm
fin_cases hm <;> simp_all -- Porting note: `simp_all` was `cc`
#align strict_convex_on_zpow strictConvexOn_zpow
open scoped Real
| Mathlib/Analysis/Convex/SpecificFunctions/Deriv.lean | 168 | 171 | theorem strictConcaveOn_sin_Icc : StrictConcaveOn ℝ (Icc 0 π) sin := by |
apply strictConcaveOn_of_deriv2_neg (convex_Icc _ _) continuousOn_sin fun x hx => ?_
rw [interior_Icc] at hx
simp [sin_pos_of_mem_Ioo hx]
|
import Mathlib.GroupTheory.QuotientGroup
import Mathlib.LinearAlgebra.Span
#align_import linear_algebra.quotient from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
-- For most of this file we work over a noncommutative ring
section Ring
namespace Submodule
variable {R M : Type*} {r : R} {x y : M} [Ring R] [AddCommGroup M] [Module R M]
variable (p p' : Submodule R M)
open LinearMap QuotientAddGroup
def quotientRel : Setoid M :=
QuotientAddGroup.leftRel p.toAddSubgroup
#align submodule.quotient_rel Submodule.quotientRel
theorem quotientRel_r_def {x y : M} : @Setoid.r _ p.quotientRel x y ↔ x - y ∈ p :=
Iff.trans
(by
rw [leftRel_apply, sub_eq_add_neg, neg_add, neg_neg]
rfl)
neg_mem_iff
#align submodule.quotient_rel_r_def Submodule.quotientRel_r_def
instance hasQuotient : HasQuotient M (Submodule R M) :=
⟨fun p => Quotient (quotientRel p)⟩
#align submodule.has_quotient Submodule.hasQuotient
namespace Quotient
def mk {p : Submodule R M} : M → M ⧸ p :=
Quotient.mk''
#align submodule.quotient.mk Submodule.Quotient.mk
@[simp]
theorem mk'_eq_mk' {p : Submodule R M} (x : M) :
@Quotient.mk' _ (quotientRel p) x = (mk : M → M ⧸ p) x :=
rfl
#align submodule.quotient.mk_eq_mk Submodule.Quotient.mk'_eq_mk'
@[simp]
theorem mk''_eq_mk {p : Submodule R M} (x : M) : (Quotient.mk'' x : M ⧸ p) = (mk : M → M ⧸ p) x :=
rfl
#align submodule.quotient.mk'_eq_mk Submodule.Quotient.mk''_eq_mk
@[simp]
theorem quot_mk_eq_mk {p : Submodule R M} (x : M) : (Quot.mk _ x : M ⧸ p) = (mk : M → M ⧸ p) x :=
rfl
#align submodule.quotient.quot_mk_eq_mk Submodule.Quotient.quot_mk_eq_mk
protected theorem eq' {x y : M} : (mk x : M ⧸ p) = (mk : M → M ⧸ p) y ↔ -x + y ∈ p :=
QuotientAddGroup.eq
#align submodule.quotient.eq' Submodule.Quotient.eq'
protected theorem eq {x y : M} : (mk x : M ⧸ p) = (mk y : M ⧸ p) ↔ x - y ∈ p :=
(Submodule.Quotient.eq' p).trans (leftRel_apply.symm.trans p.quotientRel_r_def)
#align submodule.quotient.eq Submodule.Quotient.eq
instance : Zero (M ⧸ p) where
-- Use Quotient.mk'' instead of mk here because mk is not reducible.
-- This would lead to non-defeq diamonds.
-- See also the same comment at the One instance for Con.
zero := Quotient.mk'' 0
instance : Inhabited (M ⧸ p) :=
⟨0⟩
@[simp]
theorem mk_zero : mk 0 = (0 : M ⧸ p) :=
rfl
#align submodule.quotient.mk_zero Submodule.Quotient.mk_zero
@[simp]
theorem mk_eq_zero : (mk x : M ⧸ p) = 0 ↔ x ∈ p := by simpa using (Quotient.eq' p : mk x = 0 ↔ _)
#align submodule.quotient.mk_eq_zero Submodule.Quotient.mk_eq_zero
instance addCommGroup : AddCommGroup (M ⧸ p) :=
QuotientAddGroup.Quotient.addCommGroup p.toAddSubgroup
#align submodule.quotient.add_comm_group Submodule.Quotient.addCommGroup
@[simp]
theorem mk_add : (mk (x + y) : M ⧸ p) = (mk x : M ⧸ p) + (mk y : M ⧸ p) :=
rfl
#align submodule.quotient.mk_add Submodule.Quotient.mk_add
@[simp]
theorem mk_neg : (mk (-x) : M ⧸ p) = -(mk x : M ⧸ p) :=
rfl
#align submodule.quotient.mk_neg Submodule.Quotient.mk_neg
@[simp]
theorem mk_sub : (mk (x - y) : M ⧸ p) = (mk x : M ⧸ p) - (mk y : M ⧸ p) :=
rfl
#align submodule.quotient.mk_sub Submodule.Quotient.mk_sub
| Mathlib/LinearAlgebra/Quotient.lean | 257 | 259 | theorem mk_surjective : Function.Surjective (@mk _ _ _ _ _ p) := by |
rintro ⟨x⟩
exact ⟨x, rfl⟩
|
import Mathlib.Data.Set.Function
import Mathlib.Logic.Equiv.Defs
import Mathlib.Tactic.Says
#align_import logic.equiv.set from "leanprover-community/mathlib"@"aba57d4d3dae35460225919dcd82fe91355162f9"
open Function Set
universe u v w z
variable {α : Sort u} {β : Sort v} {γ : Sort w}
namespace Equiv
@[simp]
theorem range_eq_univ {α : Type*} {β : Type*} (e : α ≃ β) : range e = univ :=
eq_univ_of_forall e.surjective
#align equiv.range_eq_univ Equiv.range_eq_univ
protected theorem image_eq_preimage {α β} (e : α ≃ β) (s : Set α) : e '' s = e.symm ⁻¹' s :=
Set.ext fun _ => mem_image_iff_of_inverse e.left_inv e.right_inv
#align equiv.image_eq_preimage Equiv.image_eq_preimage
@[simp 1001]
theorem _root_.Set.mem_image_equiv {α β} {S : Set α} {f : α ≃ β} {x : β} :
x ∈ f '' S ↔ f.symm x ∈ S :=
Set.ext_iff.mp (f.image_eq_preimage S) x
#align set.mem_image_equiv Set.mem_image_equiv
theorem _root_.Set.image_equiv_eq_preimage_symm {α β} (S : Set α) (f : α ≃ β) :
f '' S = f.symm ⁻¹' S :=
f.image_eq_preimage S
#align set.image_equiv_eq_preimage_symm Set.image_equiv_eq_preimage_symm
theorem _root_.Set.preimage_equiv_eq_image_symm {α β} (S : Set α) (f : β ≃ α) :
f ⁻¹' S = f.symm '' S :=
(f.symm.image_eq_preimage S).symm
#align set.preimage_equiv_eq_image_symm Set.preimage_equiv_eq_image_symm
-- Porting note: increased priority so this fires before `image_subset_iff`
@[simp high]
protected theorem symm_image_subset {α β} (e : α ≃ β) (s : Set α) (t : Set β) :
e.symm '' t ⊆ s ↔ t ⊆ e '' s := by rw [image_subset_iff, e.image_eq_preimage]
#align equiv.subset_image Equiv.symm_image_subset
@[deprecated (since := "2024-01-19")] alias subset_image := Equiv.symm_image_subset
-- Porting note: increased priority so this fires before `image_subset_iff`
@[simp high]
protected theorem subset_symm_image {α β} (e : α ≃ β) (s : Set α) (t : Set β) :
s ⊆ e.symm '' t ↔ e '' s ⊆ t :=
calc
s ⊆ e.symm '' t ↔ e.symm.symm '' s ⊆ t := by rw [e.symm.symm_image_subset]
_ ↔ e '' s ⊆ t := by rw [e.symm_symm]
#align equiv.subset_image' Equiv.subset_symm_image
@[deprecated (since := "2024-01-19")] alias subset_image' := Equiv.subset_symm_image
@[simp]
theorem symm_image_image {α β} (e : α ≃ β) (s : Set α) : e.symm '' (e '' s) = s :=
e.leftInverse_symm.image_image s
#align equiv.symm_image_image Equiv.symm_image_image
theorem eq_image_iff_symm_image_eq {α β} (e : α ≃ β) (s : Set α) (t : Set β) :
t = e '' s ↔ e.symm '' t = s :=
(e.symm.injective.image_injective.eq_iff' (e.symm_image_image s)).symm
#align equiv.eq_image_iff_symm_image_eq Equiv.eq_image_iff_symm_image_eq
@[simp]
theorem image_symm_image {α β} (e : α ≃ β) (s : Set β) : e '' (e.symm '' s) = s :=
e.symm.symm_image_image s
#align equiv.image_symm_image Equiv.image_symm_image
@[simp]
theorem image_preimage {α β} (e : α ≃ β) (s : Set β) : e '' (e ⁻¹' s) = s :=
e.surjective.image_preimage s
#align equiv.image_preimage Equiv.image_preimage
@[simp]
theorem preimage_image {α β} (e : α ≃ β) (s : Set α) : e ⁻¹' (e '' s) = s :=
e.injective.preimage_image s
#align equiv.preimage_image Equiv.preimage_image
protected theorem image_compl {α β} (f : Equiv α β) (s : Set α) : f '' sᶜ = (f '' s)ᶜ :=
image_compl_eq f.bijective
#align equiv.image_compl Equiv.image_compl
@[simp]
theorem symm_preimage_preimage {α β} (e : α ≃ β) (s : Set β) : e.symm ⁻¹' (e ⁻¹' s) = s :=
e.rightInverse_symm.preimage_preimage s
#align equiv.symm_preimage_preimage Equiv.symm_preimage_preimage
@[simp]
theorem preimage_symm_preimage {α β} (e : α ≃ β) (s : Set α) : e ⁻¹' (e.symm ⁻¹' s) = s :=
e.leftInverse_symm.preimage_preimage s
#align equiv.preimage_symm_preimage Equiv.preimage_symm_preimage
theorem preimage_subset {α β} (e : α ≃ β) (s t : Set β) : e ⁻¹' s ⊆ e ⁻¹' t ↔ s ⊆ t :=
e.surjective.preimage_subset_preimage_iff
#align equiv.preimage_subset Equiv.preimage_subset
-- Porting note (#10618): removed `simp` attribute. `simp` can prove it.
theorem image_subset {α β} (e : α ≃ β) (s t : Set α) : e '' s ⊆ e '' t ↔ s ⊆ t :=
image_subset_image_iff e.injective
#align equiv.image_subset Equiv.image_subset
@[simp]
theorem image_eq_iff_eq {α β} (e : α ≃ β) (s t : Set α) : e '' s = e '' t ↔ s = t :=
image_eq_image e.injective
#align equiv.image_eq_iff_eq Equiv.image_eq_iff_eq
theorem preimage_eq_iff_eq_image {α β} (e : α ≃ β) (s t) : e ⁻¹' s = t ↔ s = e '' t :=
Set.preimage_eq_iff_eq_image e.bijective
#align equiv.preimage_eq_iff_eq_image Equiv.preimage_eq_iff_eq_image
theorem eq_preimage_iff_image_eq {α β} (e : α ≃ β) (s t) : s = e ⁻¹' t ↔ e '' s = t :=
Set.eq_preimage_iff_image_eq e.bijective
#align equiv.eq_preimage_iff_image_eq Equiv.eq_preimage_iff_image_eq
lemma setOf_apply_symm_eq_image_setOf {α β} (e : α ≃ β) (p : α → Prop) :
{b | p (e.symm b)} = e '' {a | p a} := by
rw [Equiv.image_eq_preimage, preimage_setOf_eq]
@[simp]
theorem prod_assoc_preimage {α β γ} {s : Set α} {t : Set β} {u : Set γ} :
Equiv.prodAssoc α β γ ⁻¹' s ×ˢ t ×ˢ u = (s ×ˢ t) ×ˢ u := by
ext
simp [and_assoc]
#align equiv.prod_assoc_preimage Equiv.prod_assoc_preimage
@[simp]
theorem prod_assoc_symm_preimage {α β γ} {s : Set α} {t : Set β} {u : Set γ} :
(Equiv.prodAssoc α β γ).symm ⁻¹' (s ×ˢ t) ×ˢ u = s ×ˢ t ×ˢ u := by
ext
simp [and_assoc]
#align equiv.prod_assoc_symm_preimage Equiv.prod_assoc_symm_preimage
-- `@[simp]` doesn't like these lemmas, as it uses `Set.image_congr'` to turn `Equiv.prodAssoc`
-- into a lambda expression and then unfold it.
theorem prod_assoc_image {α β γ} {s : Set α} {t : Set β} {u : Set γ} :
Equiv.prodAssoc α β γ '' (s ×ˢ t) ×ˢ u = s ×ˢ t ×ˢ u := by
simpa only [Equiv.image_eq_preimage] using prod_assoc_symm_preimage
#align equiv.prod_assoc_image Equiv.prod_assoc_image
theorem prod_assoc_symm_image {α β γ} {s : Set α} {t : Set β} {u : Set γ} :
(Equiv.prodAssoc α β γ).symm '' s ×ˢ t ×ˢ u = (s ×ˢ t) ×ˢ u := by
simpa only [Equiv.image_eq_preimage] using prod_assoc_preimage
#align equiv.prod_assoc_symm_image Equiv.prod_assoc_symm_image
def setProdEquivSigma {α β : Type*} (s : Set (α × β)) :
s ≃ Σx : α, { y : β | (x, y) ∈ s } where
toFun x := ⟨x.1.1, x.1.2, by simp⟩
invFun x := ⟨(x.1, x.2.1), x.2.2⟩
left_inv := fun ⟨⟨x, y⟩, h⟩ => rfl
right_inv := fun ⟨x, y, h⟩ => rfl
#align equiv.set_prod_equiv_sigma Equiv.setProdEquivSigma
@[simps! apply]
def setCongr {α : Type*} {s t : Set α} (h : s = t) : s ≃ t :=
subtypeEquivProp h
#align equiv.set_congr Equiv.setCongr
#align equiv.set_congr_apply Equiv.setCongr_apply
-- We could construct this using `Equiv.Set.image e s e.injective`,
-- but this definition provides an explicit inverse.
@[simps]
def image {α β : Type*} (e : α ≃ β) (s : Set α) :
s ≃ e '' s where
toFun x := ⟨e x.1, by simp⟩
invFun y :=
⟨e.symm y.1, by
rcases y with ⟨-, ⟨a, ⟨m, rfl⟩⟩⟩
simpa using m⟩
left_inv x := by simp
right_inv y := by simp
#align equiv.image Equiv.image
#align equiv.image_symm_apply_coe Equiv.image_symm_apply_coe
#align equiv.image_apply_coe Equiv.image_apply_coe
namespace Set
-- Porting note: Removed attribute @[simps apply symm_apply]
protected def univ (α) : @univ α ≃ α :=
⟨Subtype.val, fun a => ⟨a, trivial⟩, fun ⟨_, _⟩ => rfl, fun _ => rfl⟩
#align equiv.set.univ Equiv.Set.univ
protected def empty (α) : (∅ : Set α) ≃ Empty :=
equivEmpty _
#align equiv.set.empty Equiv.Set.empty
protected def pempty (α) : (∅ : Set α) ≃ PEmpty :=
equivPEmpty _
#align equiv.set.pempty Equiv.Set.pempty
protected def union' {α} {s t : Set α} (p : α → Prop) [DecidablePred p] (hs : ∀ x ∈ s, p x)
(ht : ∀ x ∈ t, ¬p x) : (s ∪ t : Set α) ≃ s ⊕ t where
toFun x :=
if hp : p x then Sum.inl ⟨_, x.2.resolve_right fun xt => ht _ xt hp⟩
else Sum.inr ⟨_, x.2.resolve_left fun xs => hp (hs _ xs)⟩
invFun o :=
match o with
| Sum.inl x => ⟨x, Or.inl x.2⟩
| Sum.inr x => ⟨x, Or.inr x.2⟩
left_inv := fun ⟨x, h'⟩ => by by_cases h : p x <;> simp [h]
right_inv o := by
rcases o with (⟨x, h⟩ | ⟨x, h⟩) <;> [simp [hs _ h]; simp [ht _ h]]
#align equiv.set.union' Equiv.Set.union'
protected def union {α} {s t : Set α} [DecidablePred fun x => x ∈ s] (H : s ∩ t ⊆ ∅) :
(s ∪ t : Set α) ≃ s ⊕ t :=
Set.union' (fun x => x ∈ s) (fun _ => id) fun _ xt xs => H ⟨xs, xt⟩
#align equiv.set.union Equiv.Set.union
theorem union_apply_left {α} {s t : Set α} [DecidablePred fun x => x ∈ s] (H : s ∩ t ⊆ ∅)
{a : (s ∪ t : Set α)} (ha : ↑a ∈ s) : Equiv.Set.union H a = Sum.inl ⟨a, ha⟩ :=
dif_pos ha
#align equiv.set.union_apply_left Equiv.Set.union_apply_left
theorem union_apply_right {α} {s t : Set α} [DecidablePred fun x => x ∈ s] (H : s ∩ t ⊆ ∅)
{a : (s ∪ t : Set α)} (ha : ↑a ∈ t) : Equiv.Set.union H a = Sum.inr ⟨a, ha⟩ :=
dif_neg fun h => H ⟨h, ha⟩
#align equiv.set.union_apply_right Equiv.Set.union_apply_right
@[simp]
theorem union_symm_apply_left {α} {s t : Set α} [DecidablePred fun x => x ∈ s] (H : s ∩ t ⊆ ∅)
(a : s) : (Equiv.Set.union H).symm (Sum.inl a) = ⟨a, by simp⟩ :=
rfl
#align equiv.set.union_symm_apply_left Equiv.Set.union_symm_apply_left
@[simp]
theorem union_symm_apply_right {α} {s t : Set α} [DecidablePred fun x => x ∈ s] (H : s ∩ t ⊆ ∅)
(a : t) : (Equiv.Set.union H).symm (Sum.inr a) = ⟨a, by simp⟩ :=
rfl
#align equiv.set.union_symm_apply_right Equiv.Set.union_symm_apply_right
protected def singleton {α} (a : α) : ({a} : Set α) ≃ PUnit.{u} :=
⟨fun _ => PUnit.unit, fun _ => ⟨a, mem_singleton _⟩, fun ⟨x, h⟩ => by
simp? at h says simp only [mem_singleton_iff] at h
subst x
rfl, fun ⟨⟩ => rfl⟩
#align equiv.set.singleton Equiv.Set.singleton
@[simps! apply symm_apply]
protected def ofEq {α : Type u} {s t : Set α} (h : s = t) : s ≃ t :=
Equiv.setCongr h
#align equiv.set.of_eq Equiv.Set.ofEq
protected def insert {α} {s : Set.{u} α} [DecidablePred (· ∈ s)] {a : α} (H : a ∉ s) :
(insert a s : Set α) ≃ Sum s PUnit.{u + 1} :=
calc
(insert a s : Set α) ≃ ↥(s ∪ {a}) := Equiv.Set.ofEq (by simp)
_ ≃ Sum s ({a} : Set α) := Equiv.Set.union fun x ⟨hx, _⟩ => by simp_all
_ ≃ Sum s PUnit.{u + 1} := sumCongr (Equiv.refl _) (Equiv.Set.singleton _)
#align equiv.set.insert Equiv.Set.insert
@[simp]
theorem insert_symm_apply_inl {α} {s : Set.{u} α} [DecidablePred (· ∈ s)] {a : α} (H : a ∉ s)
(b : s) : (Equiv.Set.insert H).symm (Sum.inl b) = ⟨b, Or.inr b.2⟩ :=
rfl
#align equiv.set.insert_symm_apply_inl Equiv.Set.insert_symm_apply_inl
@[simp]
theorem insert_symm_apply_inr {α} {s : Set.{u} α} [DecidablePred (· ∈ s)] {a : α} (H : a ∉ s)
(b : PUnit.{u + 1}) : (Equiv.Set.insert H).symm (Sum.inr b) = ⟨a, Or.inl rfl⟩ :=
rfl
#align equiv.set.insert_symm_apply_inr Equiv.Set.insert_symm_apply_inr
@[simp]
theorem insert_apply_left {α} {s : Set.{u} α} [DecidablePred (· ∈ s)] {a : α} (H : a ∉ s) :
Equiv.Set.insert H ⟨a, Or.inl rfl⟩ = Sum.inr PUnit.unit :=
(Equiv.Set.insert H).apply_eq_iff_eq_symm_apply.2 rfl
#align equiv.set.insert_apply_left Equiv.Set.insert_apply_left
@[simp]
theorem insert_apply_right {α} {s : Set.{u} α} [DecidablePred (· ∈ s)] {a : α} (H : a ∉ s) (b : s) :
Equiv.Set.insert H ⟨b, Or.inr b.2⟩ = Sum.inl b :=
(Equiv.Set.insert H).apply_eq_iff_eq_symm_apply.2 rfl
#align equiv.set.insert_apply_right Equiv.Set.insert_apply_right
protected def sumCompl {α} (s : Set α) [DecidablePred (· ∈ s)] : Sum s (sᶜ : Set α) ≃ α :=
calc
Sum s (sᶜ : Set α) ≃ ↥(s ∪ sᶜ) := (Equiv.Set.union (by simp [Set.ext_iff])).symm
_ ≃ @univ α := Equiv.Set.ofEq (by simp)
_ ≃ α := Equiv.Set.univ _
#align equiv.set.sum_compl Equiv.Set.sumCompl
@[simp]
theorem sumCompl_apply_inl {α : Type u} (s : Set α) [DecidablePred (· ∈ s)] (x : s) :
Equiv.Set.sumCompl s (Sum.inl x) = x :=
rfl
#align equiv.set.sum_compl_apply_inl Equiv.Set.sumCompl_apply_inl
@[simp]
theorem sumCompl_apply_inr {α : Type u} (s : Set α) [DecidablePred (· ∈ s)] (x : (sᶜ : Set α)) :
Equiv.Set.sumCompl s (Sum.inr x) = x :=
rfl
#align equiv.set.sum_compl_apply_inr Equiv.Set.sumCompl_apply_inr
theorem sumCompl_symm_apply_of_mem {α : Type u} {s : Set α} [DecidablePred (· ∈ s)] {x : α}
(hx : x ∈ s) : (Equiv.Set.sumCompl s).symm x = Sum.inl ⟨x, hx⟩ := by
have : ((⟨x, Or.inl hx⟩ : (s ∪ sᶜ : Set α)) : α) ∈ s := hx
rw [Equiv.Set.sumCompl]
simpa using Set.union_apply_left (by simp) this
#align equiv.set.sum_compl_symm_apply_of_mem Equiv.Set.sumCompl_symm_apply_of_mem
theorem sumCompl_symm_apply_of_not_mem {α : Type u} {s : Set α} [DecidablePred (· ∈ s)] {x : α}
(hx : x ∉ s) : (Equiv.Set.sumCompl s).symm x = Sum.inr ⟨x, hx⟩ := by
have : ((⟨x, Or.inr hx⟩ : (s ∪ sᶜ : Set α)) : α) ∈ sᶜ := hx
rw [Equiv.Set.sumCompl]
simpa using Set.union_apply_right (by simp) this
#align equiv.set.sum_compl_symm_apply_of_not_mem Equiv.Set.sumCompl_symm_apply_of_not_mem
@[simp]
theorem sumCompl_symm_apply {α : Type*} {s : Set α} [DecidablePred (· ∈ s)] {x : s} :
(Equiv.Set.sumCompl s).symm x = Sum.inl x := by
cases' x with x hx; exact Set.sumCompl_symm_apply_of_mem hx
#align equiv.set.sum_compl_symm_apply Equiv.Set.sumCompl_symm_apply
@[simp]
theorem sumCompl_symm_apply_compl {α : Type*} {s : Set α} [DecidablePred (· ∈ s)]
{x : (sᶜ : Set α)} : (Equiv.Set.sumCompl s).symm x = Sum.inr x := by
cases' x with x hx; exact Set.sumCompl_symm_apply_of_not_mem hx
#align equiv.set.sum_compl_symm_apply_compl Equiv.Set.sumCompl_symm_apply_compl
protected def sumDiffSubset {α} {s t : Set α} (h : s ⊆ t) [DecidablePred (· ∈ s)] :
Sum s (t \ s : Set α) ≃ t :=
calc
Sum s (t \ s : Set α) ≃ (s ∪ t \ s : Set α) :=
(Equiv.Set.union (by simp [inter_diff_self])).symm
_ ≃ t := Equiv.Set.ofEq (by simp [union_diff_self, union_eq_self_of_subset_left h])
#align equiv.set.sum_diff_subset Equiv.Set.sumDiffSubset
@[simp]
theorem sumDiffSubset_apply_inl {α} {s t : Set α} (h : s ⊆ t) [DecidablePred (· ∈ s)] (x : s) :
Equiv.Set.sumDiffSubset h (Sum.inl x) = inclusion h x :=
rfl
#align equiv.set.sum_diff_subset_apply_inl Equiv.Set.sumDiffSubset_apply_inl
@[simp]
theorem sumDiffSubset_apply_inr {α} {s t : Set α} (h : s ⊆ t) [DecidablePred (· ∈ s)]
(x : (t \ s : Set α)) : Equiv.Set.sumDiffSubset h (Sum.inr x) = inclusion diff_subset x :=
rfl
#align equiv.set.sum_diff_subset_apply_inr Equiv.Set.sumDiffSubset_apply_inr
theorem sumDiffSubset_symm_apply_of_mem {α} {s t : Set α} (h : s ⊆ t) [DecidablePred (· ∈ s)]
{x : t} (hx : x.1 ∈ s) : (Equiv.Set.sumDiffSubset h).symm x = Sum.inl ⟨x, hx⟩ := by
apply (Equiv.Set.sumDiffSubset h).injective
simp only [apply_symm_apply, sumDiffSubset_apply_inl]
exact Subtype.eq rfl
#align equiv.set.sum_diff_subset_symm_apply_of_mem Equiv.Set.sumDiffSubset_symm_apply_of_mem
theorem sumDiffSubset_symm_apply_of_not_mem {α} {s t : Set α} (h : s ⊆ t) [DecidablePred (· ∈ s)]
{x : t} (hx : x.1 ∉ s) : (Equiv.Set.sumDiffSubset h).symm x = Sum.inr ⟨x, ⟨x.2, hx⟩⟩ := by
apply (Equiv.Set.sumDiffSubset h).injective
simp only [apply_symm_apply, sumDiffSubset_apply_inr]
exact Subtype.eq rfl
#align equiv.set.sum_diff_subset_symm_apply_of_not_mem Equiv.Set.sumDiffSubset_symm_apply_of_not_mem
protected def unionSumInter {α : Type u} (s t : Set α) [DecidablePred (· ∈ s)] :
Sum (s ∪ t : Set α) (s ∩ t : Set α) ≃ Sum s t :=
calc
Sum (s ∪ t : Set α) (s ∩ t : Set α)
≃ Sum (s ∪ t \ s : Set α) (s ∩ t : Set α) := by rw [union_diff_self]
_ ≃ Sum (Sum s (t \ s : Set α)) (s ∩ t : Set α) :=
sumCongr (Set.union <| subset_empty_iff.2 (inter_diff_self _ _)) (Equiv.refl _)
_ ≃ Sum s (Sum (t \ s : Set α) (s ∩ t : Set α)) := sumAssoc _ _ _
_ ≃ Sum s (t \ s ∪ s ∩ t : Set α) :=
sumCongr (Equiv.refl _)
(by
refine (Set.union' (· ∉ s) ?_ ?_).symm
exacts [fun x hx => hx.2, fun x hx => not_not_intro hx.1])
_ ≃ Sum s t := by
{ rw [(_ : t \ s ∪ s ∩ t = t)]
rw [union_comm, inter_comm, inter_union_diff] }
#align equiv.set.union_sum_inter Equiv.Set.unionSumInter
protected def compl {α : Type u} {β : Type v} {s : Set α} {t : Set β} [DecidablePred (· ∈ s)]
[DecidablePred (· ∈ t)] (e₀ : s ≃ t) :
{ e : α ≃ β // ∀ x : s, e x = e₀ x } ≃ ((sᶜ : Set α) ≃ (tᶜ : Set β)) where
toFun e :=
subtypeEquiv e fun a =>
not_congr <|
Iff.symm <|
MapsTo.mem_iff (mapsTo_iff_exists_map_subtype.2 ⟨e₀, e.2⟩)
(SurjOn.mapsTo_compl
(surjOn_iff_exists_map_subtype.2 ⟨t, e₀, Subset.refl t, e₀.surjective, e.2⟩)
e.1.injective)
invFun e₁ :=
Subtype.mk
(calc
α ≃ Sum s (sᶜ : Set α) := (Set.sumCompl s).symm
_ ≃ Sum t (tᶜ : Set β) := e₀.sumCongr e₁
_ ≃ β := Set.sumCompl t
)
fun x => by
simp only [Sum.map_inl, trans_apply, sumCongr_apply, Set.sumCompl_apply_inl,
Set.sumCompl_symm_apply, Trans.trans]
left_inv e := by
ext x
by_cases hx : x ∈ s
· simp only [Set.sumCompl_symm_apply_of_mem hx, ← e.prop ⟨x, hx⟩, Sum.map_inl, sumCongr_apply,
trans_apply, Subtype.coe_mk, Set.sumCompl_apply_inl, Trans.trans]
· simp only [Set.sumCompl_symm_apply_of_not_mem hx, Sum.map_inr, subtypeEquiv_apply,
Set.sumCompl_apply_inr, trans_apply, sumCongr_apply, Subtype.coe_mk, Trans.trans]
right_inv e :=
Equiv.ext fun x => by
simp only [Sum.map_inr, subtypeEquiv_apply, Set.sumCompl_apply_inr, Function.comp_apply,
sumCongr_apply, Equiv.coe_trans, Subtype.coe_eta, Subtype.coe_mk, Trans.trans,
Set.sumCompl_symm_apply_compl]
#align equiv.set.compl Equiv.Set.compl
protected def prod {α β} (s : Set α) (t : Set β) : ↥(s ×ˢ t) ≃ s × t :=
@subtypeProdEquivProd α β s t
#align equiv.set.prod Equiv.Set.prod
@[simps]
protected def univPi {α : Type*} {β : α → Type*} (s : ∀ a, Set (β a)) :
pi univ s ≃ ∀ a, s a where
toFun f a := ⟨(f : ∀ a, β a) a, f.2 a (mem_univ a)⟩
invFun f := ⟨fun a => f a, fun a _ => (f a).2⟩
left_inv := fun ⟨f, hf⟩ => by
ext a
rfl
right_inv f := by
ext a
rfl
#align equiv.set.univ_pi Equiv.Set.univPi
#align equiv.set.univ_pi_symm_apply_coe Equiv.Set.univPi_symm_apply_coe
#align equiv.set.univ_pi_apply_coe Equiv.Set.univPi_apply_coe
protected noncomputable def imageOfInjOn {α β} (f : α → β) (s : Set α) (H : InjOn f s) :
s ≃ f '' s :=
⟨fun p => ⟨f p, mem_image_of_mem f p.2⟩, fun p =>
⟨Classical.choose p.2, (Classical.choose_spec p.2).1⟩, fun ⟨_, h⟩ =>
Subtype.eq
(H (Classical.choose_spec (mem_image_of_mem f h)).1 h
(Classical.choose_spec (mem_image_of_mem f h)).2),
fun ⟨_, h⟩ => Subtype.eq (Classical.choose_spec h).2⟩
#align equiv.set.image_of_inj_on Equiv.Set.imageOfInjOn
@[simps! apply]
protected noncomputable def image {α β} (f : α → β) (s : Set α) (H : Injective f) : s ≃ f '' s :=
Equiv.Set.imageOfInjOn f s H.injOn
#align equiv.set.image Equiv.Set.image
#align equiv.set.image_apply Equiv.Set.image_apply
@[simp]
protected theorem image_symm_apply {α β} (f : α → β) (s : Set α) (H : Injective f) (x : α)
(h : f x ∈ f '' s) : (Set.image f s H).symm ⟨f x, h⟩ = ⟨x, H.mem_set_image.1 h⟩ :=
(Equiv.symm_apply_eq _).2 rfl
#align equiv.set.image_symm_apply Equiv.Set.image_symm_apply
| Mathlib/Logic/Equiv/Set.lean | 503 | 506 | theorem image_symm_preimage {α β} {f : α → β} (hf : Injective f) (u s : Set α) :
(fun x => (Set.image f s hf).symm x : f '' s → α) ⁻¹' u = Subtype.val ⁻¹' (f '' u) := by |
ext ⟨b, a, has, rfl⟩
simp [hf.eq_iff]
|
import Mathlib.Combinatorics.SimpleGraph.Subgraph
import Mathlib.Data.List.Rotate
#align_import combinatorics.simple_graph.connectivity from "leanprover-community/mathlib"@"b99e2d58a5e6861833fa8de11e51a81144258db4"
open Function
universe u v w
namespace SimpleGraph
variable {V : Type u} {V' : Type v} {V'' : Type w}
variable (G : SimpleGraph V) (G' : SimpleGraph V') (G'' : SimpleGraph V'')
inductive Walk : V → V → Type u
| nil {u : V} : Walk u u
| cons {u v w : V} (h : G.Adj u v) (p : Walk v w) : Walk u w
deriving DecidableEq
#align simple_graph.walk SimpleGraph.Walk
attribute [refl] Walk.nil
@[simps]
instance Walk.instInhabited (v : V) : Inhabited (G.Walk v v) := ⟨Walk.nil⟩
#align simple_graph.walk.inhabited SimpleGraph.Walk.instInhabited
@[match_pattern, reducible]
def Adj.toWalk {G : SimpleGraph V} {u v : V} (h : G.Adj u v) : G.Walk u v :=
Walk.cons h Walk.nil
#align simple_graph.adj.to_walk SimpleGraph.Adj.toWalk
namespace Walk
variable {G}
@[match_pattern]
abbrev nil' (u : V) : G.Walk u u := Walk.nil
#align simple_graph.walk.nil' SimpleGraph.Walk.nil'
@[match_pattern]
abbrev cons' (u v w : V) (h : G.Adj u v) (p : G.Walk v w) : G.Walk u w := Walk.cons h p
#align simple_graph.walk.cons' SimpleGraph.Walk.cons'
protected def copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') : G.Walk u' v' :=
hu ▸ hv ▸ p
#align simple_graph.walk.copy SimpleGraph.Walk.copy
@[simp]
theorem copy_rfl_rfl {u v} (p : G.Walk u v) : p.copy rfl rfl = p := rfl
#align simple_graph.walk.copy_rfl_rfl SimpleGraph.Walk.copy_rfl_rfl
@[simp]
theorem copy_copy {u v u' v' u'' v''} (p : G.Walk u v)
(hu : u = u') (hv : v = v') (hu' : u' = u'') (hv' : v' = v'') :
(p.copy hu hv).copy hu' hv' = p.copy (hu.trans hu') (hv.trans hv') := by
subst_vars
rfl
#align simple_graph.walk.copy_copy SimpleGraph.Walk.copy_copy
@[simp]
theorem copy_nil {u u'} (hu : u = u') : (Walk.nil : G.Walk u u).copy hu hu = Walk.nil := by
subst_vars
rfl
#align simple_graph.walk.copy_nil SimpleGraph.Walk.copy_nil
theorem copy_cons {u v w u' w'} (h : G.Adj u v) (p : G.Walk v w) (hu : u = u') (hw : w = w') :
(Walk.cons h p).copy hu hw = Walk.cons (hu ▸ h) (p.copy rfl hw) := by
subst_vars
rfl
#align simple_graph.walk.copy_cons SimpleGraph.Walk.copy_cons
@[simp]
theorem cons_copy {u v w v' w'} (h : G.Adj u v) (p : G.Walk v' w') (hv : v' = v) (hw : w' = w) :
Walk.cons h (p.copy hv hw) = (Walk.cons (hv ▸ h) p).copy rfl hw := by
subst_vars
rfl
#align simple_graph.walk.cons_copy SimpleGraph.Walk.cons_copy
theorem exists_eq_cons_of_ne {u v : V} (hne : u ≠ v) :
∀ (p : G.Walk u v), ∃ (w : V) (h : G.Adj u w) (p' : G.Walk w v), p = cons h p'
| nil => (hne rfl).elim
| cons h p' => ⟨_, h, p', rfl⟩
#align simple_graph.walk.exists_eq_cons_of_ne SimpleGraph.Walk.exists_eq_cons_of_ne
def length {u v : V} : G.Walk u v → ℕ
| nil => 0
| cons _ q => q.length.succ
#align simple_graph.walk.length SimpleGraph.Walk.length
@[trans]
def append {u v w : V} : G.Walk u v → G.Walk v w → G.Walk u w
| nil, q => q
| cons h p, q => cons h (p.append q)
#align simple_graph.walk.append SimpleGraph.Walk.append
def concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) : G.Walk u w := p.append (cons h nil)
#align simple_graph.walk.concat SimpleGraph.Walk.concat
theorem concat_eq_append {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
p.concat h = p.append (cons h nil) := rfl
#align simple_graph.walk.concat_eq_append SimpleGraph.Walk.concat_eq_append
protected def reverseAux {u v w : V} : G.Walk u v → G.Walk u w → G.Walk v w
| nil, q => q
| cons h p, q => Walk.reverseAux p (cons (G.symm h) q)
#align simple_graph.walk.reverse_aux SimpleGraph.Walk.reverseAux
@[symm]
def reverse {u v : V} (w : G.Walk u v) : G.Walk v u := w.reverseAux nil
#align simple_graph.walk.reverse SimpleGraph.Walk.reverse
def getVert {u v : V} : G.Walk u v → ℕ → V
| nil, _ => u
| cons _ _, 0 => u
| cons _ q, n + 1 => q.getVert n
#align simple_graph.walk.get_vert SimpleGraph.Walk.getVert
@[simp]
theorem getVert_zero {u v} (w : G.Walk u v) : w.getVert 0 = u := by cases w <;> rfl
#align simple_graph.walk.get_vert_zero SimpleGraph.Walk.getVert_zero
theorem getVert_of_length_le {u v} (w : G.Walk u v) {i : ℕ} (hi : w.length ≤ i) :
w.getVert i = v := by
induction w generalizing i with
| nil => rfl
| cons _ _ ih =>
cases i
· cases hi
· exact ih (Nat.succ_le_succ_iff.1 hi)
#align simple_graph.walk.get_vert_of_length_le SimpleGraph.Walk.getVert_of_length_le
@[simp]
theorem getVert_length {u v} (w : G.Walk u v) : w.getVert w.length = v :=
w.getVert_of_length_le rfl.le
#align simple_graph.walk.get_vert_length SimpleGraph.Walk.getVert_length
theorem adj_getVert_succ {u v} (w : G.Walk u v) {i : ℕ} (hi : i < w.length) :
G.Adj (w.getVert i) (w.getVert (i + 1)) := by
induction w generalizing i with
| nil => cases hi
| cons hxy _ ih =>
cases i
· simp [getVert, hxy]
· exact ih (Nat.succ_lt_succ_iff.1 hi)
#align simple_graph.walk.adj_get_vert_succ SimpleGraph.Walk.adj_getVert_succ
@[simp]
theorem cons_append {u v w x : V} (h : G.Adj u v) (p : G.Walk v w) (q : G.Walk w x) :
(cons h p).append q = cons h (p.append q) := rfl
#align simple_graph.walk.cons_append SimpleGraph.Walk.cons_append
@[simp]
theorem cons_nil_append {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h nil).append p = cons h p := rfl
#align simple_graph.walk.cons_nil_append SimpleGraph.Walk.cons_nil_append
@[simp]
theorem append_nil {u v : V} (p : G.Walk u v) : p.append nil = p := by
induction p with
| nil => rfl
| cons _ _ ih => rw [cons_append, ih]
#align simple_graph.walk.append_nil SimpleGraph.Walk.append_nil
@[simp]
theorem nil_append {u v : V} (p : G.Walk u v) : nil.append p = p :=
rfl
#align simple_graph.walk.nil_append SimpleGraph.Walk.nil_append
theorem append_assoc {u v w x : V} (p : G.Walk u v) (q : G.Walk v w) (r : G.Walk w x) :
p.append (q.append r) = (p.append q).append r := by
induction p with
| nil => rfl
| cons h p' ih =>
dsimp only [append]
rw [ih]
#align simple_graph.walk.append_assoc SimpleGraph.Walk.append_assoc
@[simp]
theorem append_copy_copy {u v w u' v' w'} (p : G.Walk u v) (q : G.Walk v w)
(hu : u = u') (hv : v = v') (hw : w = w') :
(p.copy hu hv).append (q.copy hv hw) = (p.append q).copy hu hw := by
subst_vars
rfl
#align simple_graph.walk.append_copy_copy SimpleGraph.Walk.append_copy_copy
theorem concat_nil {u v : V} (h : G.Adj u v) : nil.concat h = cons h nil := rfl
#align simple_graph.walk.concat_nil SimpleGraph.Walk.concat_nil
@[simp]
theorem concat_cons {u v w x : V} (h : G.Adj u v) (p : G.Walk v w) (h' : G.Adj w x) :
(cons h p).concat h' = cons h (p.concat h') := rfl
#align simple_graph.walk.concat_cons SimpleGraph.Walk.concat_cons
theorem append_concat {u v w x : V} (p : G.Walk u v) (q : G.Walk v w) (h : G.Adj w x) :
p.append (q.concat h) = (p.append q).concat h := append_assoc _ _ _
#align simple_graph.walk.append_concat SimpleGraph.Walk.append_concat
theorem concat_append {u v w x : V} (p : G.Walk u v) (h : G.Adj v w) (q : G.Walk w x) :
(p.concat h).append q = p.append (cons h q) := by
rw [concat_eq_append, ← append_assoc, cons_nil_append]
#align simple_graph.walk.concat_append SimpleGraph.Walk.concat_append
theorem exists_cons_eq_concat {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
∃ (x : V) (q : G.Walk u x) (h' : G.Adj x w), cons h p = q.concat h' := by
induction p generalizing u with
| nil => exact ⟨_, nil, h, rfl⟩
| cons h' p ih =>
obtain ⟨y, q, h'', hc⟩ := ih h'
refine ⟨y, cons h q, h'', ?_⟩
rw [concat_cons, hc]
#align simple_graph.walk.exists_cons_eq_concat SimpleGraph.Walk.exists_cons_eq_concat
theorem exists_concat_eq_cons {u v w : V} :
∀ (p : G.Walk u v) (h : G.Adj v w),
∃ (x : V) (h' : G.Adj u x) (q : G.Walk x w), p.concat h = cons h' q
| nil, h => ⟨_, h, nil, rfl⟩
| cons h' p, h => ⟨_, h', Walk.concat p h, concat_cons _ _ _⟩
#align simple_graph.walk.exists_concat_eq_cons SimpleGraph.Walk.exists_concat_eq_cons
@[simp]
theorem reverse_nil {u : V} : (nil : G.Walk u u).reverse = nil := rfl
#align simple_graph.walk.reverse_nil SimpleGraph.Walk.reverse_nil
theorem reverse_singleton {u v : V} (h : G.Adj u v) : (cons h nil).reverse = cons (G.symm h) nil :=
rfl
#align simple_graph.walk.reverse_singleton SimpleGraph.Walk.reverse_singleton
@[simp]
theorem cons_reverseAux {u v w x : V} (p : G.Walk u v) (q : G.Walk w x) (h : G.Adj w u) :
(cons h p).reverseAux q = p.reverseAux (cons (G.symm h) q) := rfl
#align simple_graph.walk.cons_reverse_aux SimpleGraph.Walk.cons_reverseAux
@[simp]
protected theorem append_reverseAux {u v w x : V}
(p : G.Walk u v) (q : G.Walk v w) (r : G.Walk u x) :
(p.append q).reverseAux r = q.reverseAux (p.reverseAux r) := by
induction p with
| nil => rfl
| cons h _ ih => exact ih q (cons (G.symm h) r)
#align simple_graph.walk.append_reverse_aux SimpleGraph.Walk.append_reverseAux
@[simp]
protected theorem reverseAux_append {u v w x : V}
(p : G.Walk u v) (q : G.Walk u w) (r : G.Walk w x) :
(p.reverseAux q).append r = p.reverseAux (q.append r) := by
induction p with
| nil => rfl
| cons h _ ih => simp [ih (cons (G.symm h) q)]
#align simple_graph.walk.reverse_aux_append SimpleGraph.Walk.reverseAux_append
protected theorem reverseAux_eq_reverse_append {u v w : V} (p : G.Walk u v) (q : G.Walk u w) :
p.reverseAux q = p.reverse.append q := by simp [reverse]
#align simple_graph.walk.reverse_aux_eq_reverse_append SimpleGraph.Walk.reverseAux_eq_reverse_append
@[simp]
theorem reverse_cons {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h p).reverse = p.reverse.append (cons (G.symm h) nil) := by simp [reverse]
#align simple_graph.walk.reverse_cons SimpleGraph.Walk.reverse_cons
@[simp]
theorem reverse_copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') :
(p.copy hu hv).reverse = p.reverse.copy hv hu := by
subst_vars
rfl
#align simple_graph.walk.reverse_copy SimpleGraph.Walk.reverse_copy
@[simp]
theorem reverse_append {u v w : V} (p : G.Walk u v) (q : G.Walk v w) :
(p.append q).reverse = q.reverse.append p.reverse := by simp [reverse]
#align simple_graph.walk.reverse_append SimpleGraph.Walk.reverse_append
@[simp]
theorem reverse_concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
(p.concat h).reverse = cons (G.symm h) p.reverse := by simp [concat_eq_append]
#align simple_graph.walk.reverse_concat SimpleGraph.Walk.reverse_concat
@[simp]
theorem reverse_reverse {u v : V} (p : G.Walk u v) : p.reverse.reverse = p := by
induction p with
| nil => rfl
| cons _ _ ih => simp [ih]
#align simple_graph.walk.reverse_reverse SimpleGraph.Walk.reverse_reverse
@[simp]
theorem length_nil {u : V} : (nil : G.Walk u u).length = 0 := rfl
#align simple_graph.walk.length_nil SimpleGraph.Walk.length_nil
@[simp]
theorem length_cons {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h p).length = p.length + 1 := rfl
#align simple_graph.walk.length_cons SimpleGraph.Walk.length_cons
@[simp]
theorem length_copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') :
(p.copy hu hv).length = p.length := by
subst_vars
rfl
#align simple_graph.walk.length_copy SimpleGraph.Walk.length_copy
@[simp]
theorem length_append {u v w : V} (p : G.Walk u v) (q : G.Walk v w) :
(p.append q).length = p.length + q.length := by
induction p with
| nil => simp
| cons _ _ ih => simp [ih, add_comm, add_left_comm, add_assoc]
#align simple_graph.walk.length_append SimpleGraph.Walk.length_append
@[simp]
theorem length_concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
(p.concat h).length = p.length + 1 := length_append _ _
#align simple_graph.walk.length_concat SimpleGraph.Walk.length_concat
@[simp]
protected theorem length_reverseAux {u v w : V} (p : G.Walk u v) (q : G.Walk u w) :
(p.reverseAux q).length = p.length + q.length := by
induction p with
| nil => simp!
| cons _ _ ih => simp [ih, Nat.succ_add, Nat.add_assoc]
#align simple_graph.walk.length_reverse_aux SimpleGraph.Walk.length_reverseAux
@[simp]
theorem length_reverse {u v : V} (p : G.Walk u v) : p.reverse.length = p.length := by simp [reverse]
#align simple_graph.walk.length_reverse SimpleGraph.Walk.length_reverse
theorem eq_of_length_eq_zero {u v : V} : ∀ {p : G.Walk u v}, p.length = 0 → u = v
| nil, _ => rfl
#align simple_graph.walk.eq_of_length_eq_zero SimpleGraph.Walk.eq_of_length_eq_zero
theorem adj_of_length_eq_one {u v : V} : ∀ {p : G.Walk u v}, p.length = 1 → G.Adj u v
| cons h nil, _ => h
@[simp]
theorem exists_length_eq_zero_iff {u v : V} : (∃ p : G.Walk u v, p.length = 0) ↔ u = v := by
constructor
· rintro ⟨p, hp⟩
exact eq_of_length_eq_zero hp
· rintro rfl
exact ⟨nil, rfl⟩
#align simple_graph.walk.exists_length_eq_zero_iff SimpleGraph.Walk.exists_length_eq_zero_iff
@[simp]
theorem length_eq_zero_iff {u : V} {p : G.Walk u u} : p.length = 0 ↔ p = nil := by cases p <;> simp
#align simple_graph.walk.length_eq_zero_iff SimpleGraph.Walk.length_eq_zero_iff
theorem getVert_append {u v w : V} (p : G.Walk u v) (q : G.Walk v w) (i : ℕ) :
(p.append q).getVert i = if i < p.length then p.getVert i else q.getVert (i - p.length) := by
induction p generalizing i with
| nil => simp
| cons h p ih => cases i <;> simp [getVert, ih, Nat.succ_lt_succ_iff]
theorem getVert_reverse {u v : V} (p : G.Walk u v) (i : ℕ) :
p.reverse.getVert i = p.getVert (p.length - i) := by
induction p with
| nil => rfl
| cons h p ih =>
simp only [reverse_cons, getVert_append, length_reverse, ih, length_cons]
split_ifs
next hi =>
rw [Nat.succ_sub hi.le]
simp [getVert]
next hi =>
obtain rfl | hi' := Nat.eq_or_lt_of_not_lt hi
· simp [getVert]
· rw [Nat.eq_add_of_sub_eq (Nat.sub_pos_of_lt hi') rfl, Nat.sub_eq_zero_of_le hi']
simp [getVert]
theorem concat_ne_nil {u v : V} (p : G.Walk u v) (h : G.Adj v u) : p.concat h ≠ nil := by
cases p <;> simp [concat]
#align simple_graph.walk.concat_ne_nil SimpleGraph.Walk.concat_ne_nil
theorem concat_inj {u v v' w : V} {p : G.Walk u v} {h : G.Adj v w} {p' : G.Walk u v'}
{h' : G.Adj v' w} (he : p.concat h = p'.concat h') : ∃ hv : v = v', p.copy rfl hv = p' := by
induction p with
| nil =>
cases p'
· exact ⟨rfl, rfl⟩
· exfalso
simp only [concat_nil, concat_cons, cons.injEq] at he
obtain ⟨rfl, he⟩ := he
simp only [heq_iff_eq] at he
exact concat_ne_nil _ _ he.symm
| cons _ _ ih =>
rw [concat_cons] at he
cases p'
· exfalso
simp only [concat_nil, cons.injEq] at he
obtain ⟨rfl, he⟩ := he
rw [heq_iff_eq] at he
exact concat_ne_nil _ _ he
· rw [concat_cons, cons.injEq] at he
obtain ⟨rfl, he⟩ := he
rw [heq_iff_eq] at he
obtain ⟨rfl, rfl⟩ := ih he
exact ⟨rfl, rfl⟩
#align simple_graph.walk.concat_inj SimpleGraph.Walk.concat_inj
def support {u v : V} : G.Walk u v → List V
| nil => [u]
| cons _ p => u :: p.support
#align simple_graph.walk.support SimpleGraph.Walk.support
def darts {u v : V} : G.Walk u v → List G.Dart
| nil => []
| cons h p => ⟨(u, _), h⟩ :: p.darts
#align simple_graph.walk.darts SimpleGraph.Walk.darts
def edges {u v : V} (p : G.Walk u v) : List (Sym2 V) := p.darts.map Dart.edge
#align simple_graph.walk.edges SimpleGraph.Walk.edges
@[simp]
theorem support_nil {u : V} : (nil : G.Walk u u).support = [u] := rfl
#align simple_graph.walk.support_nil SimpleGraph.Walk.support_nil
@[simp]
theorem support_cons {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h p).support = u :: p.support := rfl
#align simple_graph.walk.support_cons SimpleGraph.Walk.support_cons
@[simp]
theorem support_concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
(p.concat h).support = p.support.concat w := by
induction p <;> simp [*, concat_nil]
#align simple_graph.walk.support_concat SimpleGraph.Walk.support_concat
@[simp]
theorem support_copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') :
(p.copy hu hv).support = p.support := by
subst_vars
rfl
#align simple_graph.walk.support_copy SimpleGraph.Walk.support_copy
theorem support_append {u v w : V} (p : G.Walk u v) (p' : G.Walk v w) :
(p.append p').support = p.support ++ p'.support.tail := by
induction p <;> cases p' <;> simp [*]
#align simple_graph.walk.support_append SimpleGraph.Walk.support_append
@[simp]
| Mathlib/Combinatorics/SimpleGraph/Connectivity.lean | 574 | 575 | theorem support_reverse {u v : V} (p : G.Walk u v) : p.reverse.support = p.support.reverse := by |
induction p <;> simp [support_append, *]
|
import Mathlib.CategoryTheory.Extensive
import Mathlib.CategoryTheory.Limits.Shapes.KernelPair
#align_import category_theory.adhesive from "leanprover-community/mathlib"@"afff1f24a6b68d0077c9d63782a1d093e337758c"
namespace CategoryTheory
open Limits
universe v' u' v u
variable {J : Type v'} [Category.{u'} J] {C : Type u} [Category.{v} C]
variable {W X Y Z : C} {f : W ⟶ X} {g : W ⟶ Y} {h : X ⟶ Z} {i : Y ⟶ Z}
-- This only makes sense when the original diagram is a pushout.
@[nolint unusedArguments]
def IsPushout.IsVanKampen (_ : IsPushout f g h i) : Prop :=
∀ ⦃W' X' Y' Z' : C⦄ (f' : W' ⟶ X') (g' : W' ⟶ Y') (h' : X' ⟶ Z') (i' : Y' ⟶ Z') (αW : W' ⟶ W)
(αX : X' ⟶ X) (αY : Y' ⟶ Y) (αZ : Z' ⟶ Z) (_ : IsPullback f' αW αX f)
(_ : IsPullback g' αW αY g) (_ : CommSq h' αX αZ h) (_ : CommSq i' αY αZ i)
(_ : CommSq f' g' h' i'), IsPushout f' g' h' i' ↔ IsPullback h' αX αZ h ∧ IsPullback i' αY αZ i
#align category_theory.is_pushout.is_van_kampen CategoryTheory.IsPushout.IsVanKampen
theorem IsPushout.IsVanKampen.flip {H : IsPushout f g h i} (H' : H.IsVanKampen) :
H.flip.IsVanKampen := by
introv W' hf hg hh hi w
simpa only [IsPushout.flip_iff, IsPullback.flip_iff, and_comm] using
H' g' f' i' h' αW αY αX αZ hg hf hi hh w.flip
#align category_theory.is_pushout.is_van_kampen.flip CategoryTheory.IsPushout.IsVanKampen.flip
theorem IsPushout.isVanKampen_iff (H : IsPushout f g h i) :
H.IsVanKampen ↔ IsVanKampenColimit (PushoutCocone.mk h i H.w) := by
constructor
· intro H F' c' α fα eα hα
refine Iff.trans ?_
((H (F'.map WalkingSpan.Hom.fst) (F'.map WalkingSpan.Hom.snd) (c'.ι.app _) (c'.ι.app _)
(α.app _) (α.app _) (α.app _) fα (by convert hα WalkingSpan.Hom.fst)
(by convert hα WalkingSpan.Hom.snd) ?_ ?_ ?_).trans ?_)
· have : F'.map WalkingSpan.Hom.fst ≫ c'.ι.app WalkingSpan.left =
F'.map WalkingSpan.Hom.snd ≫ c'.ι.app WalkingSpan.right := by
simp only [Cocone.w]
rw [(IsColimit.equivOfNatIsoOfIso (diagramIsoSpan F') c' (PushoutCocone.mk _ _ this)
_).nonempty_congr]
· exact ⟨fun h => ⟨⟨this⟩, h⟩, fun h => h.2⟩
· refine Cocones.ext (Iso.refl c'.pt) ?_
rintro (_ | _ | _) <;> dsimp <;>
simp only [c'.w, Category.assoc, Category.id_comp, Category.comp_id]
· exact ⟨NatTrans.congr_app eα.symm _⟩
· exact ⟨NatTrans.congr_app eα.symm _⟩
· exact ⟨by simp⟩
constructor
· rintro ⟨h₁, h₂⟩ (_ | _ | _)
· rw [← c'.w WalkingSpan.Hom.fst]; exact (hα WalkingSpan.Hom.fst).paste_horiz h₁
exacts [h₁, h₂]
· intro h; exact ⟨h _, h _⟩
· introv H W' hf hg hh hi w
refine
Iff.trans ?_ ((H w.cocone ⟨by rintro (_ | _ | _); exacts [αW, αX, αY], ?_⟩ αZ ?_ ?_).trans ?_)
rotate_left
· rintro i _ (_ | _ | _)
· dsimp; simp only [Functor.map_id, Category.comp_id, Category.id_comp]
exacts [hf.w, hg.w]
· ext (_ | _ | _)
· dsimp; rw [PushoutCocone.condition_zero]; erw [Category.assoc, hh.w, hf.w_assoc]
exacts [hh.w.symm, hi.w.symm]
· rintro i _ (_ | _ | _)
· dsimp; simp_rw [Functor.map_id]
exact IsPullback.of_horiz_isIso ⟨by rw [Category.comp_id, Category.id_comp]⟩
exacts [hf, hg]
· constructor
· intro h; exact ⟨h WalkingCospan.left, h WalkingCospan.right⟩
· rintro ⟨h₁, h₂⟩ (_ | _ | _)
· dsimp; rw [PushoutCocone.condition_zero]; exact hf.paste_horiz h₁
exacts [h₁, h₂]
· exact ⟨fun h => h.2, fun h => ⟨w, h⟩⟩
#align category_theory.is_pushout.is_van_kampen_iff CategoryTheory.IsPushout.isVanKampen_iff
theorem is_coprod_iff_isPushout {X E Y YE : C} (c : BinaryCofan X E) (hc : IsColimit c) {f : X ⟶ Y}
{iY : Y ⟶ YE} {fE : c.pt ⟶ YE} (H : CommSq f c.inl iY fE) :
Nonempty (IsColimit (BinaryCofan.mk (c.inr ≫ fE) iY)) ↔ IsPushout f c.inl iY fE := by
constructor
· rintro ⟨h⟩
refine ⟨H, ⟨Limits.PushoutCocone.isColimitAux' _ ?_⟩⟩
intro s
dsimp only [PushoutCocone.inr, PushoutCocone.mk] -- Porting note: Originally `dsimp`
refine ⟨h.desc (BinaryCofan.mk (c.inr ≫ s.inr) s.inl), h.fac _ ⟨WalkingPair.right⟩, ?_, ?_⟩
· apply BinaryCofan.IsColimit.hom_ext hc
· rw [← H.w_assoc]; erw [h.fac _ ⟨WalkingPair.right⟩]; exact s.condition
· rw [← Category.assoc]; exact h.fac _ ⟨WalkingPair.left⟩
· intro m e₁ e₂
apply BinaryCofan.IsColimit.hom_ext h
· dsimp only [BinaryCofan.mk, id] -- Porting note: Originally `dsimp`
rw [Category.assoc, e₂, eq_comm]; exact h.fac _ ⟨WalkingPair.left⟩
· refine e₁.trans (Eq.symm ?_); exact h.fac _ _
· refine fun H => ⟨?_⟩
fapply Limits.BinaryCofan.isColimitMk
· exact fun s => H.isColimit.desc (PushoutCocone.mk s.inr _ <|
(hc.fac (BinaryCofan.mk (f ≫ s.inr) s.inl) ⟨WalkingPair.left⟩).symm)
· intro s
erw [Category.assoc, H.isColimit.fac _ WalkingSpan.right, hc.fac]; rfl
· intro s; exact H.isColimit.fac _ WalkingSpan.left
· intro s m e₁ e₂
apply PushoutCocone.IsColimit.hom_ext H.isColimit
· symm; exact (H.isColimit.fac _ WalkingSpan.left).trans e₂.symm
· erw [H.isColimit.fac _ WalkingSpan.right]
apply BinaryCofan.IsColimit.hom_ext hc
· erw [hc.fac, ← H.w_assoc, e₂]; rfl
· refine ((Category.assoc _ _ _).symm.trans e₁).trans ?_; symm; exact hc.fac _ _
#align category_theory.is_coprod_iff_is_pushout CategoryTheory.is_coprod_iff_isPushout
| Mathlib/CategoryTheory/Adhesive.lean | 146 | 183 | theorem IsPushout.isVanKampen_inl {W E X Z : C} (c : BinaryCofan W E) [FinitaryExtensive C]
[HasPullbacks C] (hc : IsColimit c) (f : W ⟶ X) (h : X ⟶ Z) (i : c.pt ⟶ Z)
(H : IsPushout f c.inl h i) : H.IsVanKampen := by |
obtain ⟨hc₁⟩ := (is_coprod_iff_isPushout c hc H.1).mpr H
introv W' hf hg hh hi w
obtain ⟨hc₂⟩ := ((BinaryCofan.isVanKampen_iff _).mp (FinitaryExtensive.vanKampen c hc)
(BinaryCofan.mk _ pullback.fst) _ _ _ hg.w.symm pullback.condition.symm).mpr
⟨hg, IsPullback.of_hasPullback αY c.inr⟩
refine (is_coprod_iff_isPushout _ hc₂ w).symm.trans ?_
refine ((BinaryCofan.isVanKampen_iff _).mp (FinitaryExtensive.vanKampen _ hc₁)
(BinaryCofan.mk _ _) pullback.snd _ _ ?_ hh.w.symm).trans ?_
· dsimp; rw [← pullback.condition_assoc, Category.assoc, hi.w]
constructor
· rintro ⟨hc₃, hc₄⟩
refine ⟨hc₄, ?_⟩
let Y'' := pullback αZ i
let cmp : Y' ⟶ Y'' := pullback.lift i' αY hi.w
have e₁ : (g' ≫ cmp) ≫ pullback.snd = αW ≫ c.inl := by
rw [Category.assoc, pullback.lift_snd, hg.w]
have e₂ : (pullback.fst ≫ cmp : pullback αY c.inr ⟶ _) ≫ pullback.snd = pullback.snd ≫ c.inr :=
by rw [Category.assoc, pullback.lift_snd, pullback.condition]
obtain ⟨hc₄⟩ := ((BinaryCofan.isVanKampen_iff _).mp (FinitaryExtensive.vanKampen c hc)
(BinaryCofan.mk _ _) αW _ _ e₁.symm e₂.symm).mpr <| by
constructor
· apply IsPullback.of_right _ e₁ (IsPullback.of_hasPullback _ _)
rw [Category.assoc, pullback.lift_fst, ← H.w, ← w.w]; exact hf.paste_horiz hc₄
· apply IsPullback.of_right _ e₂ (IsPullback.of_hasPullback _ _)
rw [Category.assoc, pullback.lift_fst]; exact hc₃
rw [← Category.id_comp αZ, ← show cmp ≫ pullback.snd = αY from pullback.lift_snd _ _ _]
apply IsPullback.paste_vert _ (IsPullback.of_hasPullback αZ i)
have : cmp = (hc₂.coconePointUniqueUpToIso hc₄).hom := by
apply BinaryCofan.IsColimit.hom_ext hc₂
exacts [(hc₂.comp_coconePointUniqueUpToIso_hom hc₄ ⟨WalkingPair.left⟩).symm,
(hc₂.comp_coconePointUniqueUpToIso_hom hc₄ ⟨WalkingPair.right⟩).symm]
rw [this]
exact IsPullback.of_vert_isIso ⟨by rw [← this, Category.comp_id, pullback.lift_fst]⟩
· rintro ⟨hc₃, hc₄⟩
exact ⟨(IsPullback.of_hasPullback αY c.inr).paste_horiz hc₄, hc₃⟩
|
import Mathlib.Combinatorics.SimpleGraph.Clique
import Mathlib.Data.ENat.Lattice
import Mathlib.Data.Nat.Lattice
import Mathlib.Data.Setoid.Partition
import Mathlib.Order.Antichain
#align_import combinatorics.simple_graph.coloring from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
open Fintype Function
universe u v
namespace SimpleGraph
variable {V : Type u} (G : SimpleGraph V) {n : ℕ}
abbrev Coloring (α : Type v) := G →g (⊤ : SimpleGraph α)
#align simple_graph.coloring SimpleGraph.Coloring
variable {G} {α β : Type*} (C : G.Coloring α)
theorem Coloring.valid {v w : V} (h : G.Adj v w) : C v ≠ C w :=
C.map_rel h
#align simple_graph.coloring.valid SimpleGraph.Coloring.valid
@[match_pattern]
def Coloring.mk (color : V → α) (valid : ∀ {v w : V}, G.Adj v w → color v ≠ color w) :
G.Coloring α :=
⟨color, @valid⟩
#align simple_graph.coloring.mk SimpleGraph.Coloring.mk
def Coloring.colorClass (c : α) : Set V := { v : V | C v = c }
#align simple_graph.coloring.color_class SimpleGraph.Coloring.colorClass
def Coloring.colorClasses : Set (Set V) := (Setoid.ker C).classes
#align simple_graph.coloring.color_classes SimpleGraph.Coloring.colorClasses
theorem Coloring.mem_colorClass (v : V) : v ∈ C.colorClass (C v) := rfl
#align simple_graph.coloring.mem_color_class SimpleGraph.Coloring.mem_colorClass
theorem Coloring.colorClasses_isPartition : Setoid.IsPartition C.colorClasses :=
Setoid.isPartition_classes (Setoid.ker C)
#align simple_graph.coloring.color_classes_is_partition SimpleGraph.Coloring.colorClasses_isPartition
theorem Coloring.mem_colorClasses {v : V} : C.colorClass (C v) ∈ C.colorClasses :=
⟨v, rfl⟩
#align simple_graph.coloring.mem_color_classes SimpleGraph.Coloring.mem_colorClasses
theorem Coloring.colorClasses_finite [Finite α] : C.colorClasses.Finite :=
Setoid.finite_classes_ker _
#align simple_graph.coloring.color_classes_finite SimpleGraph.Coloring.colorClasses_finite
theorem Coloring.card_colorClasses_le [Fintype α] [Fintype C.colorClasses] :
Fintype.card C.colorClasses ≤ Fintype.card α := by
simp [colorClasses]
-- Porting note: brute force instance declaration `[Fintype (Setoid.classes (Setoid.ker C))]`
haveI : Fintype (Setoid.classes (Setoid.ker C)) := by assumption
convert Setoid.card_classes_ker_le C
#align simple_graph.coloring.card_color_classes_le SimpleGraph.Coloring.card_colorClasses_le
theorem Coloring.not_adj_of_mem_colorClass {c : α} {v w : V} (hv : v ∈ C.colorClass c)
(hw : w ∈ C.colorClass c) : ¬G.Adj v w := fun h => C.valid h (Eq.trans hv (Eq.symm hw))
#align simple_graph.coloring.not_adj_of_mem_color_class SimpleGraph.Coloring.not_adj_of_mem_colorClass
theorem Coloring.color_classes_independent (c : α) : IsAntichain G.Adj (C.colorClass c) :=
fun _ hv _ hw _ => C.not_adj_of_mem_colorClass hv hw
#align simple_graph.coloring.color_classes_independent SimpleGraph.Coloring.color_classes_independent
-- TODO make this computable
noncomputable instance [Fintype V] [Fintype α] : Fintype (Coloring G α) := by
classical
change Fintype (RelHom G.Adj (⊤ : SimpleGraph α).Adj)
apply Fintype.ofInjective _ RelHom.coe_fn_injective
variable (G)
def Colorable (n : ℕ) : Prop := Nonempty (G.Coloring (Fin n))
#align simple_graph.colorable SimpleGraph.Colorable
def coloringOfIsEmpty [IsEmpty V] : G.Coloring α :=
Coloring.mk isEmptyElim fun {v} => isEmptyElim v
#align simple_graph.coloring_of_is_empty SimpleGraph.coloringOfIsEmpty
theorem colorable_of_isEmpty [IsEmpty V] (n : ℕ) : G.Colorable n :=
⟨G.coloringOfIsEmpty⟩
#align simple_graph.colorable_of_is_empty SimpleGraph.colorable_of_isEmpty
theorem isEmpty_of_colorable_zero (h : G.Colorable 0) : IsEmpty V := by
constructor
intro v
obtain ⟨i, hi⟩ := h.some v
exact Nat.not_lt_zero _ hi
#align simple_graph.is_empty_of_colorable_zero SimpleGraph.isEmpty_of_colorable_zero
def selfColoring : G.Coloring V := Coloring.mk id fun {_ _} => G.ne_of_adj
#align simple_graph.self_coloring SimpleGraph.selfColoring
noncomputable def chromaticNumber : ℕ∞ := ⨅ n ∈ setOf G.Colorable, (n : ℕ∞)
#align simple_graph.chromatic_number SimpleGraph.chromaticNumber
lemma chromaticNumber_eq_biInf {G : SimpleGraph V} :
G.chromaticNumber = ⨅ n ∈ setOf G.Colorable, (n : ℕ∞) := rfl
lemma chromaticNumber_eq_iInf {G : SimpleGraph V} :
G.chromaticNumber = ⨅ n : {m | G.Colorable m}, (n : ℕ∞) := by
rw [chromaticNumber, iInf_subtype]
lemma Colorable.chromaticNumber_eq_sInf {G : SimpleGraph V} {n} (h : G.Colorable n) :
G.chromaticNumber = sInf {n' : ℕ | G.Colorable n'} := by
rw [ENat.coe_sInf, chromaticNumber]
exact ⟨_, h⟩
def recolorOfEmbedding {α β : Type*} (f : α ↪ β) : G.Coloring α ↪ G.Coloring β where
toFun C := (Embedding.completeGraph f).toHom.comp C
inj' := by -- this was strangely painful; seems like missing lemmas about embeddings
intro C C' h
dsimp only at h
ext v
apply (Embedding.completeGraph f).inj'
change ((Embedding.completeGraph f).toHom.comp C) v = _
rw [h]
rfl
#align simple_graph.recolor_of_embedding SimpleGraph.recolorOfEmbedding
@[simp] lemma coe_recolorOfEmbedding (f : α ↪ β) :
⇑(G.recolorOfEmbedding f) = (Embedding.completeGraph f).toHom.comp := rfl
def recolorOfEquiv {α β : Type*} (f : α ≃ β) : G.Coloring α ≃ G.Coloring β where
toFun := G.recolorOfEmbedding f.toEmbedding
invFun := G.recolorOfEmbedding f.symm.toEmbedding
left_inv C := by
ext v
apply Equiv.symm_apply_apply
right_inv C := by
ext v
apply Equiv.apply_symm_apply
#align simple_graph.recolor_of_equiv SimpleGraph.recolorOfEquiv
@[simp] lemma coe_recolorOfEquiv (f : α ≃ β) :
⇑(G.recolorOfEquiv f) = (Embedding.completeGraph f).toHom.comp := rfl
noncomputable def recolorOfCardLE {α β : Type*} [Fintype α] [Fintype β]
(hn : Fintype.card α ≤ Fintype.card β) : G.Coloring α ↪ G.Coloring β :=
G.recolorOfEmbedding <| (Function.Embedding.nonempty_of_card_le hn).some
#align simple_graph.recolor_of_card_le SimpleGraph.recolorOfCardLE
@[simp] lemma coe_recolorOfCardLE [Fintype α] [Fintype β] (hαβ : card α ≤ card β) :
⇑(G.recolorOfCardLE hαβ) =
(Embedding.completeGraph (Embedding.nonempty_of_card_le hαβ).some).toHom.comp := rfl
variable {G}
theorem Colorable.mono {n m : ℕ} (h : n ≤ m) (hc : G.Colorable n) : G.Colorable m :=
⟨G.recolorOfCardLE (by simp [h]) hc.some⟩
#align simple_graph.colorable.mono SimpleGraph.Colorable.mono
theorem Coloring.colorable [Fintype α] (C : G.Coloring α) : G.Colorable (Fintype.card α) :=
⟨G.recolorOfCardLE (by simp) C⟩
#align simple_graph.coloring.to_colorable SimpleGraph.Coloring.colorable
theorem colorable_of_fintype (G : SimpleGraph V) [Fintype V] : G.Colorable (Fintype.card V) :=
G.selfColoring.colorable
#align simple_graph.colorable_of_fintype SimpleGraph.colorable_of_fintype
noncomputable def Colorable.toColoring [Fintype α] {n : ℕ} (hc : G.Colorable n)
(hn : n ≤ Fintype.card α) : G.Coloring α := by
rw [← Fintype.card_fin n] at hn
exact G.recolorOfCardLE hn hc.some
#align simple_graph.colorable.to_coloring SimpleGraph.Colorable.toColoring
theorem Colorable.of_embedding {V' : Type*} {G' : SimpleGraph V'} (f : G ↪g G') {n : ℕ}
(h : G'.Colorable n) : G.Colorable n :=
⟨(h.toColoring (by simp)).comp f⟩
#align simple_graph.colorable.of_embedding SimpleGraph.Colorable.of_embedding
theorem colorable_iff_exists_bdd_nat_coloring (n : ℕ) :
G.Colorable n ↔ ∃ C : G.Coloring ℕ, ∀ v, C v < n := by
constructor
· rintro hc
have C : G.Coloring (Fin n) := hc.toColoring (by simp)
let f := Embedding.completeGraph (@Fin.valEmbedding n)
use f.toHom.comp C
intro v
cases' C with color valid
exact Fin.is_lt (color v)
· rintro ⟨C, Cf⟩
refine ⟨Coloring.mk ?_ ?_⟩
· exact fun v => ⟨C v, Cf v⟩
· rintro v w hvw
simp only [Fin.mk_eq_mk, Ne]
exact C.valid hvw
#align simple_graph.colorable_iff_exists_bdd_nat_coloring SimpleGraph.colorable_iff_exists_bdd_nat_coloring
theorem colorable_set_nonempty_of_colorable {n : ℕ} (hc : G.Colorable n) :
{ n : ℕ | G.Colorable n }.Nonempty :=
⟨n, hc⟩
#align simple_graph.colorable_set_nonempty_of_colorable SimpleGraph.colorable_set_nonempty_of_colorable
theorem chromaticNumber_bddBelow : BddBelow { n : ℕ | G.Colorable n } :=
⟨0, fun _ _ => zero_le _⟩
#align simple_graph.chromatic_number_bdd_below SimpleGraph.chromaticNumber_bddBelow
theorem Colorable.chromaticNumber_le {n : ℕ} (hc : G.Colorable n) : G.chromaticNumber ≤ n := by
rw [hc.chromaticNumber_eq_sInf]
norm_cast
apply csInf_le chromaticNumber_bddBelow
exact hc
#align simple_graph.chromatic_number_le_of_colorable SimpleGraph.Colorable.chromaticNumber_le
theorem chromaticNumber_ne_top_iff_exists : G.chromaticNumber ≠ ⊤ ↔ ∃ n, G.Colorable n := by
rw [chromaticNumber]
convert_to ⨅ n : {m | G.Colorable m}, (n : ℕ∞) ≠ ⊤ ↔ _
· rw [iInf_subtype]
rw [← lt_top_iff_ne_top, ENat.iInf_coe_lt_top]
simp
theorem chromaticNumber_le_iff_colorable {n : ℕ} : G.chromaticNumber ≤ n ↔ G.Colorable n := by
refine ⟨fun h ↦ ?_, Colorable.chromaticNumber_le⟩
have : G.chromaticNumber ≠ ⊤ := (trans h (WithTop.coe_lt_top n)).ne
rw [chromaticNumber_ne_top_iff_exists] at this
obtain ⟨m, hm⟩ := this
rw [hm.chromaticNumber_eq_sInf, Nat.cast_le] at h
have := Nat.sInf_mem (⟨m, hm⟩ : {n' | G.Colorable n'}.Nonempty)
rw [Set.mem_setOf_eq] at this
exact this.mono h
@[deprecated Colorable.chromaticNumber_le (since := "2024-03-21")]
theorem chromaticNumber_le_card [Fintype α] (C : G.Coloring α) :
G.chromaticNumber ≤ Fintype.card α := C.colorable.chromaticNumber_le
#align simple_graph.chromatic_number_le_card SimpleGraph.chromaticNumber_le_card
theorem colorable_chromaticNumber {m : ℕ} (hc : G.Colorable m) :
G.Colorable (ENat.toNat G.chromaticNumber) := by
classical
rw [hc.chromaticNumber_eq_sInf, Nat.sInf_def]
· apply Nat.find_spec
· exact colorable_set_nonempty_of_colorable hc
#align simple_graph.colorable_chromatic_number SimpleGraph.colorable_chromaticNumber
theorem colorable_chromaticNumber_of_fintype (G : SimpleGraph V) [Finite V] :
G.Colorable (ENat.toNat G.chromaticNumber) := by
cases nonempty_fintype V
exact colorable_chromaticNumber G.colorable_of_fintype
#align simple_graph.colorable_chromatic_number_of_fintype SimpleGraph.colorable_chromaticNumber_of_fintype
| Mathlib/Combinatorics/SimpleGraph/Coloring.lean | 319 | 325 | theorem chromaticNumber_le_one_of_subsingleton (G : SimpleGraph V) [Subsingleton V] :
G.chromaticNumber ≤ 1 := by |
rw [← Nat.cast_one, chromaticNumber_le_iff_colorable]
refine ⟨Coloring.mk (fun _ => 0) ?_⟩
intros v w
cases Subsingleton.elim v w
simp
|
import Mathlib.Analysis.Normed.Group.Hom
import Mathlib.Analysis.NormedSpace.Basic
import Mathlib.Analysis.NormedSpace.LinearIsometry
import Mathlib.Algebra.Star.SelfAdjoint
import Mathlib.Algebra.Star.Subalgebra
import Mathlib.Algebra.Star.Unitary
import Mathlib.Topology.Algebra.Module.Star
#align_import analysis.normed_space.star.basic from "leanprover-community/mathlib"@"aa6669832974f87406a3d9d70fc5707a60546207"
open Topology
local postfix:max "⋆" => star
class NormedStarGroup (E : Type*) [SeminormedAddCommGroup E] [StarAddMonoid E] : Prop where
norm_star : ∀ x : E, ‖x⋆‖ = ‖x‖
#align normed_star_group NormedStarGroup
export NormedStarGroup (norm_star)
attribute [simp] norm_star
variable {𝕜 E α : Type*}
instance RingHomIsometric.starRingEnd [NormedCommRing E] [StarRing E] [NormedStarGroup E] :
RingHomIsometric (starRingEnd E) :=
⟨@norm_star _ _ _ _⟩
#align ring_hom_isometric.star_ring_end RingHomIsometric.starRingEnd
class CstarRing (E : Type*) [NonUnitalNormedRing E] [StarRing E] : Prop where
norm_star_mul_self : ∀ {x : E}, ‖x⋆ * x‖ = ‖x‖ * ‖x‖
#align cstar_ring CstarRing
instance : CstarRing ℝ where norm_star_mul_self {x} := by simp only [star, id, norm_mul]
namespace CstarRing
section NonUnital
variable [NonUnitalNormedRing E] [StarRing E] [CstarRing E]
-- see Note [lower instance priority]
instance (priority := 100) to_normedStarGroup : NormedStarGroup E :=
⟨by
intro x
by_cases htriv : x = 0
· simp only [htriv, star_zero]
· have hnt : 0 < ‖x‖ := norm_pos_iff.mpr htriv
have hnt_star : 0 < ‖x⋆‖ :=
norm_pos_iff.mpr ((AddEquiv.map_ne_zero_iff starAddEquiv (M := E)).mpr htriv)
have h₁ :=
calc
‖x‖ * ‖x‖ = ‖x⋆ * x‖ := norm_star_mul_self.symm
_ ≤ ‖x⋆‖ * ‖x‖ := norm_mul_le _ _
have h₂ :=
calc
‖x⋆‖ * ‖x⋆‖ = ‖x * x⋆‖ := by rw [← norm_star_mul_self, star_star]
_ ≤ ‖x‖ * ‖x⋆‖ := norm_mul_le _ _
exact le_antisymm (le_of_mul_le_mul_right h₂ hnt_star) (le_of_mul_le_mul_right h₁ hnt)⟩
#align cstar_ring.to_normed_star_group CstarRing.to_normedStarGroup
theorem norm_self_mul_star {x : E} : ‖x * x⋆‖ = ‖x‖ * ‖x‖ := by
nth_rw 1 [← star_star x]
simp only [norm_star_mul_self, norm_star]
#align cstar_ring.norm_self_mul_star CstarRing.norm_self_mul_star
theorem norm_star_mul_self' {x : E} : ‖x⋆ * x‖ = ‖x⋆‖ * ‖x‖ := by rw [norm_star_mul_self, norm_star]
#align cstar_ring.norm_star_mul_self' CstarRing.norm_star_mul_self'
theorem nnnorm_self_mul_star {x : E} : ‖x * x⋆‖₊ = ‖x‖₊ * ‖x‖₊ :=
Subtype.ext norm_self_mul_star
#align cstar_ring.nnnorm_self_mul_star CstarRing.nnnorm_self_mul_star
theorem nnnorm_star_mul_self {x : E} : ‖x⋆ * x‖₊ = ‖x‖₊ * ‖x‖₊ :=
Subtype.ext norm_star_mul_self
#align cstar_ring.nnnorm_star_mul_self CstarRing.nnnorm_star_mul_self
@[simp]
| Mathlib/Analysis/NormedSpace/Star/Basic.lean | 135 | 137 | theorem star_mul_self_eq_zero_iff (x : E) : x⋆ * x = 0 ↔ x = 0 := by |
rw [← norm_eq_zero, norm_star_mul_self]
exact mul_self_eq_zero.trans norm_eq_zero
|
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 Ring
variable [Ring R] {p q : R[X]}
theorem div_wf_lemma (h : degree q ≤ degree p ∧ p ≠ 0) (hq : Monic q) :
degree (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) < degree p :=
have hp : leadingCoeff p ≠ 0 := mt leadingCoeff_eq_zero.1 h.2
have hq0 : q ≠ 0 := hq.ne_zero_of_polynomial_ne h.2
have hlt : natDegree q ≤ natDegree p :=
Nat.cast_le.1
(by rw [← degree_eq_natDegree h.2, ← degree_eq_natDegree hq0]; exact h.1)
degree_sub_lt
(by
rw [hq.degree_mul_comm, hq.degree_mul, degree_C_mul_X_pow _ hp, degree_eq_natDegree h.2,
degree_eq_natDegree hq0, ← Nat.cast_add, tsub_add_cancel_of_le hlt])
h.2 (by rw [leadingCoeff_monic_mul hq, leadingCoeff_mul_X_pow, leadingCoeff_C])
#align polynomial.div_wf_lemma Polynomial.div_wf_lemma
noncomputable def divModByMonicAux : ∀ (_p : R[X]) {q : R[X]}, Monic q → R[X] × R[X]
| p, q, hq =>
letI := Classical.decEq R
if h : degree q ≤ degree p ∧ p ≠ 0 then
let z := C (leadingCoeff p) * X ^ (natDegree p - natDegree q)
have _wf := div_wf_lemma h hq
let dm := divModByMonicAux (p - q * z) hq
⟨z + dm.1, dm.2⟩
else ⟨0, p⟩
termination_by p => p
#align polynomial.div_mod_by_monic_aux Polynomial.divModByMonicAux
def divByMonic (p q : R[X]) : R[X] :=
letI := Classical.decEq R
if hq : Monic q then (divModByMonicAux p hq).1 else 0
#align polynomial.div_by_monic Polynomial.divByMonic
def modByMonic (p q : R[X]) : R[X] :=
letI := Classical.decEq R
if hq : Monic q then (divModByMonicAux p hq).2 else p
#align polynomial.mod_by_monic Polynomial.modByMonic
@[inherit_doc]
infixl:70 " /ₘ " => divByMonic
@[inherit_doc]
infixl:70 " %ₘ " => modByMonic
theorem degree_modByMonic_lt [Nontrivial R] :
∀ (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %ₘ q) < degree q
| p, q, hq =>
letI := Classical.decEq R
if h : degree q ≤ degree p ∧ p ≠ 0 then by
have _wf := div_wf_lemma ⟨h.1, h.2⟩ hq
have :=
degree_modByMonic_lt (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq
unfold modByMonic at this ⊢
unfold divModByMonicAux
dsimp
rw [dif_pos hq] at this ⊢
rw [if_pos h]
exact this
else
Or.casesOn (not_and_or.1 h)
(by
unfold modByMonic divModByMonicAux
dsimp
rw [dif_pos hq, if_neg h]
exact lt_of_not_ge)
(by
intro hp
unfold modByMonic divModByMonicAux
dsimp
rw [dif_pos hq, if_neg h, Classical.not_not.1 hp]
exact lt_of_le_of_ne bot_le (Ne.symm (mt degree_eq_bot.1 hq.ne_zero)))
termination_by p => p
#align polynomial.degree_mod_by_monic_lt Polynomial.degree_modByMonic_lt
theorem natDegree_modByMonic_lt (p : R[X]) {q : R[X]} (hmq : Monic q) (hq : q ≠ 1) :
natDegree (p %ₘ q) < q.natDegree := by
by_cases hpq : p %ₘ q = 0
· rw [hpq, natDegree_zero, Nat.pos_iff_ne_zero]
contrapose! hq
exact eq_one_of_monic_natDegree_zero hmq hq
· haveI := Nontrivial.of_polynomial_ne hpq
exact natDegree_lt_natDegree hpq (degree_modByMonic_lt p hmq)
@[simp]
| Mathlib/Algebra/Polynomial/Div.lean | 176 | 182 | theorem zero_modByMonic (p : R[X]) : 0 %ₘ p = 0 := by |
classical
unfold modByMonic divModByMonicAux
dsimp
by_cases hp : Monic p
· rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl))]
· rw [dif_neg hp]
|
import Mathlib.SetTheory.Cardinal.Basic
import Mathlib.Tactic.Ring
#align_import data.nat.count from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988"
open Finset
namespace Nat
variable (p : ℕ → Prop)
section Count
variable [DecidablePred p]
def count (n : ℕ) : ℕ :=
(List.range n).countP p
#align nat.count Nat.count
@[simp]
theorem count_zero : count p 0 = 0 := by
rw [count, List.range_zero, List.countP, List.countP.go]
#align nat.count_zero Nat.count_zero
def CountSet.fintype (n : ℕ) : Fintype { i // i < n ∧ p i } := by
apply Fintype.ofFinset ((Finset.range n).filter p)
intro x
rw [mem_filter, mem_range]
rfl
#align nat.count_set.fintype Nat.CountSet.fintype
scoped[Count] attribute [instance] Nat.CountSet.fintype
open Count
theorem count_eq_card_filter_range (n : ℕ) : count p n = ((range n).filter p).card := by
rw [count, List.countP_eq_length_filter]
rfl
#align nat.count_eq_card_filter_range Nat.count_eq_card_filter_range
theorem count_eq_card_fintype (n : ℕ) : count p n = Fintype.card { k : ℕ // k < n ∧ p k } := by
rw [count_eq_card_filter_range, ← Fintype.card_ofFinset, ← CountSet.fintype]
rfl
#align nat.count_eq_card_fintype Nat.count_eq_card_fintype
theorem count_succ (n : ℕ) : count p (n + 1) = count p n + if p n then 1 else 0 := by
split_ifs with h <;> simp [count, List.range_succ, h]
#align nat.count_succ Nat.count_succ
@[mono]
theorem count_monotone : Monotone (count p) :=
monotone_nat_of_le_succ fun n ↦ by by_cases h : p n <;> simp [count_succ, h]
#align nat.count_monotone Nat.count_monotone
theorem count_add (a b : ℕ) : count p (a + b) = count p a + count (fun k ↦ p (a + k)) b := by
have : Disjoint ((range a).filter p) (((range b).map <| addLeftEmbedding a).filter p) := by
apply disjoint_filter_filter
rw [Finset.disjoint_left]
simp_rw [mem_map, mem_range, addLeftEmbedding_apply]
rintro x hx ⟨c, _, rfl⟩
exact (self_le_add_right _ _).not_lt hx
simp_rw [count_eq_card_filter_range, range_add, filter_union, card_union_of_disjoint this,
filter_map, addLeftEmbedding, card_map]
rfl
#align nat.count_add Nat.count_add
theorem count_add' (a b : ℕ) : count p (a + b) = count (fun k ↦ p (k + b)) a + count p b := by
rw [add_comm, count_add, add_comm]
simp_rw [add_comm b]
#align nat.count_add' Nat.count_add'
theorem count_one : count p 1 = if p 0 then 1 else 0 := by simp [count_succ]
#align nat.count_one Nat.count_one
| Mathlib/Data/Nat/Count.lean | 94 | 96 | theorem count_succ' (n : ℕ) :
count p (n + 1) = count (fun k ↦ p (k + 1)) n + if p 0 then 1 else 0 := by |
rw [count_add', count_one]
|
import Mathlib.Algebra.Algebra.Spectrum
import Mathlib.LinearAlgebra.GeneralLinearGroup
import Mathlib.LinearAlgebra.FiniteDimensional
import Mathlib.RingTheory.Nilpotent.Basic
#align_import linear_algebra.eigenspace.basic from "leanprover-community/mathlib"@"6b0169218d01f2837d79ea2784882009a0da1aa1"
universe u v w
namespace Module
namespace End
open FiniteDimensional Set
variable {K R : Type v} {V M : Type w} [CommRing R] [AddCommGroup M] [Module R M] [Field K]
[AddCommGroup V] [Module K V]
def eigenspace (f : End R M) (μ : R) : Submodule R M :=
LinearMap.ker (f - algebraMap R (End R M) μ)
#align module.End.eigenspace Module.End.eigenspace
@[simp]
theorem eigenspace_zero (f : End R M) : f.eigenspace 0 = LinearMap.ker f := by simp [eigenspace]
#align module.End.eigenspace_zero Module.End.eigenspace_zero
def HasEigenvector (f : End R M) (μ : R) (x : M) : Prop :=
x ∈ eigenspace f μ ∧ x ≠ 0
#align module.End.has_eigenvector Module.End.HasEigenvector
def HasEigenvalue (f : End R M) (a : R) : Prop :=
eigenspace f a ≠ ⊥
#align module.End.has_eigenvalue Module.End.HasEigenvalue
def Eigenvalues (f : End R M) : Type _ :=
{ μ : R // f.HasEigenvalue μ }
#align module.End.eigenvalues Module.End.Eigenvalues
@[coe]
def Eigenvalues.val (f : Module.End R M) : Eigenvalues f → R := Subtype.val
instance Eigenvalues.instCoeOut {f : Module.End R M} : CoeOut (Eigenvalues f) R where
coe := Eigenvalues.val f
instance Eigenvalues.instDecidableEq [DecidableEq R] (f : Module.End R M) :
DecidableEq (Eigenvalues f) :=
inferInstanceAs (DecidableEq (Subtype (fun x : R => HasEigenvalue f x)))
theorem hasEigenvalue_of_hasEigenvector {f : End R M} {μ : R} {x : M} (h : HasEigenvector f μ x) :
HasEigenvalue f μ := by
rw [HasEigenvalue, Submodule.ne_bot_iff]
use x; exact h
#align module.End.has_eigenvalue_of_has_eigenvector Module.End.hasEigenvalue_of_hasEigenvector
theorem mem_eigenspace_iff {f : End R M} {μ : R} {x : M} : x ∈ eigenspace f μ ↔ f x = μ • x := by
rw [eigenspace, LinearMap.mem_ker, LinearMap.sub_apply, algebraMap_end_apply, sub_eq_zero]
#align module.End.mem_eigenspace_iff Module.End.mem_eigenspace_iff
theorem HasEigenvector.apply_eq_smul {f : End R M} {μ : R} {x : M} (hx : f.HasEigenvector μ x) :
f x = μ • x :=
mem_eigenspace_iff.mp hx.1
#align module.End.has_eigenvector.apply_eq_smul Module.End.HasEigenvector.apply_eq_smul
theorem HasEigenvector.pow_apply {f : End R M} {μ : R} {v : M} (hv : f.HasEigenvector μ v) (n : ℕ) :
(f ^ n) v = μ ^ n • v := by
induction n <;> simp [*, pow_succ f, hv.apply_eq_smul, smul_smul, pow_succ' μ]
theorem HasEigenvalue.exists_hasEigenvector {f : End R M} {μ : R} (hμ : f.HasEigenvalue μ) :
∃ v, f.HasEigenvector μ v :=
Submodule.exists_mem_ne_zero_of_ne_bot hμ
#align module.End.has_eigenvalue.exists_has_eigenvector Module.End.HasEigenvalue.exists_hasEigenvector
lemma HasEigenvalue.pow {f : End R M} {μ : R} (h : f.HasEigenvalue μ) (n : ℕ) :
(f ^ n).HasEigenvalue (μ ^ n) := by
rw [HasEigenvalue, Submodule.ne_bot_iff]
obtain ⟨m : M, hm⟩ := h.exists_hasEigenvector
exact ⟨m, by simpa [mem_eigenspace_iff] using hm.pow_apply n, hm.2⟩
lemma HasEigenvalue.isNilpotent_of_isNilpotent [NoZeroSMulDivisors R M] {f : End R M}
(hfn : IsNilpotent f) {μ : R} (hf : f.HasEigenvalue μ) :
IsNilpotent μ := by
obtain ⟨m : M, hm⟩ := hf.exists_hasEigenvector
obtain ⟨n : ℕ, hn : f ^ n = 0⟩ := hfn
exact ⟨n, by simpa [hn, hm.2, eq_comm (a := (0 : M))] using hm.pow_apply n⟩
theorem HasEigenvalue.mem_spectrum {f : End R M} {μ : R} (hμ : HasEigenvalue f μ) :
μ ∈ spectrum R f := by
refine spectrum.mem_iff.mpr fun h_unit => ?_
set f' := LinearMap.GeneralLinearGroup.toLinearEquiv h_unit.unit
rcases hμ.exists_hasEigenvector with ⟨v, hv⟩
refine hv.2 ((LinearMap.ker_eq_bot'.mp f'.ker) v (?_ : μ • v - f v = 0))
rw [hv.apply_eq_smul, sub_self]
#align module.End.mem_spectrum_of_has_eigenvalue Module.End.HasEigenvalue.mem_spectrum
theorem hasEigenvalue_iff_mem_spectrum [FiniteDimensional K V] {f : End K V} {μ : K} :
f.HasEigenvalue μ ↔ μ ∈ spectrum K f := by
rw [spectrum.mem_iff, IsUnit.sub_iff, LinearMap.isUnit_iff_ker_eq_bot, HasEigenvalue, eigenspace]
#align module.End.has_eigenvalue_iff_mem_spectrum Module.End.hasEigenvalue_iff_mem_spectrum
alias ⟨_, HasEigenvalue.of_mem_spectrum⟩ := hasEigenvalue_iff_mem_spectrum
theorem eigenspace_div (f : End K V) (a b : K) (hb : b ≠ 0) :
eigenspace f (a / b) = LinearMap.ker (b • f - algebraMap K (End K V) a) :=
calc
eigenspace f (a / b) = eigenspace f (b⁻¹ * a) := by rw [div_eq_mul_inv, mul_comm]
_ = LinearMap.ker (f - (b⁻¹ * a) • LinearMap.id) := by rw [eigenspace]; rfl
_ = LinearMap.ker (f - b⁻¹ • a • LinearMap.id) := by rw [smul_smul]
_ = LinearMap.ker (f - b⁻¹ • algebraMap K (End K V) a) := rfl
_ = LinearMap.ker (b • (f - b⁻¹ • algebraMap K (End K V) a)) := by
rw [LinearMap.ker_smul _ b hb]
_ = LinearMap.ker (b • f - algebraMap K (End K V) a) := by rw [smul_sub, smul_inv_smul₀ hb]
#align module.End.eigenspace_div Module.End.eigenspace_div
def genEigenspace (f : End R M) (μ : R) : ℕ →o Submodule R M where
toFun k := LinearMap.ker ((f - algebraMap R (End R M) μ) ^ k)
monotone' k m hm := by
simp only [← pow_sub_mul_pow _ hm]
exact
LinearMap.ker_le_ker_comp ((f - algebraMap R (End R M) μ) ^ k)
((f - algebraMap R (End R M) μ) ^ (m - k))
#align module.End.generalized_eigenspace Module.End.genEigenspace
@[simp]
theorem mem_genEigenspace (f : End R M) (μ : R) (k : ℕ) (m : M) :
m ∈ f.genEigenspace μ k ↔ ((f - μ • (1 : End R M)) ^ k) m = 0 := Iff.rfl
#align module.End.mem_generalized_eigenspace Module.End.mem_genEigenspace
@[simp]
theorem genEigenspace_zero (f : End R M) (k : ℕ) :
f.genEigenspace 0 k = LinearMap.ker (f ^ k) := by
simp [Module.End.genEigenspace]
#align module.End.generalized_eigenspace_zero Module.End.genEigenspace_zero
def HasGenEigenvector (f : End R M) (μ : R) (k : ℕ) (x : M) : Prop :=
x ≠ 0 ∧ x ∈ genEigenspace f μ k
#align module.End.has_generalized_eigenvector Module.End.HasGenEigenvector
def HasGenEigenvalue (f : End R M) (μ : R) (k : ℕ) : Prop :=
genEigenspace f μ k ≠ ⊥
#align module.End.has_generalized_eigenvalue Module.End.HasGenEigenvalue
def genEigenrange (f : End R M) (μ : R) (k : ℕ) : Submodule R M :=
LinearMap.range ((f - algebraMap R (End R M) μ) ^ k)
#align module.End.generalized_eigenrange Module.End.genEigenrange
theorem exp_ne_zero_of_hasGenEigenvalue {f : End R M} {μ : R} {k : ℕ}
(h : f.HasGenEigenvalue μ k) : k ≠ 0 := by
rintro rfl
exact h LinearMap.ker_id
#align module.End.exp_ne_zero_of_has_generalized_eigenvalue Module.End.exp_ne_zero_of_hasGenEigenvalue
def maxGenEigenspace (f : End R M) (μ : R) : Submodule R M :=
⨆ k, f.genEigenspace μ k
#align module.End.maximal_generalized_eigenspace Module.End.maxGenEigenspace
theorem genEigenspace_le_maximal (f : End R M) (μ : R) (k : ℕ) :
f.genEigenspace μ k ≤ f.maxGenEigenspace μ :=
le_iSup _ _
#align module.End.generalized_eigenspace_le_maximal Module.End.genEigenspace_le_maximal
@[simp]
theorem mem_maxGenEigenspace (f : End R M) (μ : R) (m : M) :
m ∈ f.maxGenEigenspace μ ↔ ∃ k : ℕ, ((f - μ • (1 : End R M)) ^ k) m = 0 := by
simp only [maxGenEigenspace, ← mem_genEigenspace, Submodule.mem_iSup_of_chain]
#align module.End.mem_maximal_generalized_eigenspace Module.End.mem_maxGenEigenspace
noncomputable def maxGenEigenspaceIndex (f : End R M) (μ : R) :=
monotonicSequenceLimitIndex (f.genEigenspace μ)
#align module.End.maximal_generalized_eigenspace_index Module.End.maxGenEigenspaceIndex
theorem maxGenEigenspace_eq [h : IsNoetherian R M] (f : End R M) (μ : R) :
maxGenEigenspace f μ =
f.genEigenspace μ (maxGenEigenspaceIndex f μ) := by
rw [isNoetherian_iff_wellFounded] at h
exact (WellFounded.iSup_eq_monotonicSequenceLimit h (f.genEigenspace μ) : _)
#align module.End.maximal_generalized_eigenspace_eq Module.End.maxGenEigenspace_eq
theorem hasGenEigenvalue_of_hasGenEigenvalue_of_le {f : End R M} {μ : R} {k : ℕ}
{m : ℕ} (hm : k ≤ m) (hk : f.HasGenEigenvalue μ k) :
f.HasGenEigenvalue μ m := by
unfold HasGenEigenvalue at *
contrapose! hk
rw [← le_bot_iff, ← hk]
exact (f.genEigenspace μ).monotone hm
#align module.End.has_generalized_eigenvalue_of_has_generalized_eigenvalue_of_le Module.End.hasGenEigenvalue_of_hasGenEigenvalue_of_le
theorem eigenspace_le_genEigenspace {f : End R M} {μ : R} {k : ℕ} (hk : 0 < k) :
f.eigenspace μ ≤ f.genEigenspace μ k :=
(f.genEigenspace μ).monotone (Nat.succ_le_of_lt hk)
#align module.End.eigenspace_le_generalized_eigenspace Module.End.eigenspace_le_genEigenspace
theorem hasGenEigenvalue_of_hasEigenvalue {f : End R M} {μ : R} {k : ℕ} (hk : 0 < k)
(hμ : f.HasEigenvalue μ) : f.HasGenEigenvalue μ k := by
apply hasGenEigenvalue_of_hasGenEigenvalue_of_le hk
rw [HasGenEigenvalue, genEigenspace, OrderHom.coe_mk, pow_one]
exact hμ
#align module.End.has_generalized_eigenvalue_of_has_eigenvalue Module.End.hasGenEigenvalue_of_hasEigenvalue
theorem hasEigenvalue_of_hasGenEigenvalue {f : End R M} {μ : R} {k : ℕ}
(hμ : f.HasGenEigenvalue μ k) : f.HasEigenvalue μ := by
intro contra; apply hμ
erw [LinearMap.ker_eq_bot] at contra ⊢; rw [LinearMap.coe_pow]
exact Function.Injective.iterate contra k
#align module.End.has_eigenvalue_of_has_generalized_eigenvalue Module.End.hasEigenvalue_of_hasGenEigenvalue
@[simp]
theorem hasGenEigenvalue_iff_hasEigenvalue {f : End R M} {μ : R} {k : ℕ} (hk : 0 < k) :
f.HasGenEigenvalue μ k ↔ f.HasEigenvalue μ :=
⟨hasEigenvalue_of_hasGenEigenvalue, hasGenEigenvalue_of_hasEigenvalue hk⟩
#align module.End.has_generalized_eigenvalue_iff_has_eigenvalue Module.End.hasGenEigenvalue_iff_hasEigenvalue
theorem genEigenspace_le_genEigenspace_finrank [FiniteDimensional K V] (f : End K V)
(μ : K) (k : ℕ) : f.genEigenspace μ k ≤ f.genEigenspace μ (finrank K V) :=
ker_pow_le_ker_pow_finrank _ _
#align module.End.generalized_eigenspace_le_generalized_eigenspace_finrank Module.End.genEigenspace_le_genEigenspace_finrank
@[simp] theorem iSup_genEigenspace_eq_genEigenspace_finrank
[FiniteDimensional K V] (f : End K V) (μ : K) :
⨆ k, f.genEigenspace μ k = f.genEigenspace μ (finrank K V) :=
le_antisymm (iSup_le (genEigenspace_le_genEigenspace_finrank f μ)) (le_iSup _ _)
theorem genEigenspace_eq_genEigenspace_finrank_of_le [FiniteDimensional K V]
(f : End K V) (μ : K) {k : ℕ} (hk : finrank K V ≤ k) :
f.genEigenspace μ k = f.genEigenspace μ (finrank K V) :=
ker_pow_eq_ker_pow_finrank_of_le hk
#align module.End.generalized_eigenspace_eq_generalized_eigenspace_finrank_of_le Module.End.genEigenspace_eq_genEigenspace_finrank_of_le
lemma mapsTo_genEigenspace_of_comm {f g : End R M} (h : Commute f g) (μ : R) (k : ℕ) :
MapsTo g (f.genEigenspace μ k) (f.genEigenspace μ k) := by
replace h : Commute ((f - μ • (1 : End R M)) ^ k) g :=
(h.sub_left <| Algebra.commute_algebraMap_left μ g).pow_left k
intro x hx
simp only [SetLike.mem_coe, mem_genEigenspace] at hx ⊢
rw [← LinearMap.comp_apply, ← LinearMap.mul_eq_comp, h.eq, LinearMap.mul_eq_comp,
LinearMap.comp_apply, hx, map_zero]
lemma mapsTo_iSup_genEigenspace_of_comm {f g : End R M} (h : Commute f g) (μ : R) :
MapsTo g ↑(⨆ k, f.genEigenspace μ k) ↑(⨆ k, f.genEigenspace μ k) := by
simp only [MapsTo, Submodule.coe_iSup_of_chain, mem_iUnion, SetLike.mem_coe]
rintro x ⟨k, hk⟩
exact ⟨k, f.mapsTo_genEigenspace_of_comm h μ k hk⟩
lemma isNilpotent_restrict_sub_algebraMap (f : End R M) (μ : R) (k : ℕ)
(h : MapsTo (f - algebraMap R (End R M) μ)
(f.genEigenspace μ k) (f.genEigenspace μ k) :=
mapsTo_genEigenspace_of_comm (Algebra.mul_sub_algebraMap_commutes f μ) μ k) :
IsNilpotent ((f - algebraMap R (End R M) μ).restrict h) := by
use k
ext
simp [LinearMap.restrict_apply, LinearMap.pow_restrict _]
lemma isNilpotent_restrict_iSup_sub_algebraMap [IsNoetherian R M] (f : End R M) (μ : R)
(h : MapsTo (f - algebraMap R (End R M) μ)
↑(⨆ k, f.genEigenspace μ k) ↑(⨆ k, f.genEigenspace μ k) :=
mapsTo_iSup_genEigenspace_of_comm (Algebra.mul_sub_algebraMap_commutes f μ) μ) :
IsNilpotent ((f - algebraMap R (End R M) μ).restrict h) := by
obtain ⟨l, hl⟩ : ∃ l, ⨆ k, f.genEigenspace μ k = f.genEigenspace μ l :=
⟨_, maxGenEigenspace_eq f μ⟩
use l
ext ⟨x, hx⟩
simpa [hl, LinearMap.restrict_apply, LinearMap.pow_restrict _] using hx
lemma disjoint_genEigenspace [NoZeroSMulDivisors R M]
(f : End R M) {μ₁ μ₂ : R} (hμ : μ₁ ≠ μ₂) (k l : ℕ) :
Disjoint (f.genEigenspace μ₁ k) (f.genEigenspace μ₂ l) := by
nontriviality M
have := NoZeroSMulDivisors.isReduced R M
rw [disjoint_iff]
set p := f.genEigenspace μ₁ k ⊓ f.genEigenspace μ₂ l
by_contra hp
replace hp : Nontrivial p := Submodule.nontrivial_iff_ne_bot.mpr hp
let f₁ : End R p := (f - algebraMap R (End R M) μ₁).restrict <| MapsTo.inter_inter
(mapsTo_genEigenspace_of_comm (Algebra.mul_sub_algebraMap_commutes f μ₁) μ₁ k)
(mapsTo_genEigenspace_of_comm (Algebra.mul_sub_algebraMap_commutes f μ₁) μ₂ l)
let f₂ : End R p := (f - algebraMap R (End R M) μ₂).restrict <| MapsTo.inter_inter
(mapsTo_genEigenspace_of_comm (Algebra.mul_sub_algebraMap_commutes f μ₂) μ₁ k)
(mapsTo_genEigenspace_of_comm (Algebra.mul_sub_algebraMap_commutes f μ₂) μ₂ l)
have : IsNilpotent (f₂ - f₁) := by
apply Commute.isNilpotent_sub (x := f₂) (y := f₁) _ ⟨l, ?_⟩ ⟨k, ?_⟩
· ext; simp [f₁, f₂, smul_sub, sub_sub, smul_comm μ₁, add_sub_left_comm]
all_goals ext ⟨x, _, _⟩; simpa [LinearMap.restrict_apply, LinearMap.pow_restrict _] using ‹_›
have hf₁₂ : f₂ - f₁ = algebraMap R (End R p) (μ₁ - μ₂) := by ext; simp [f₁, f₂, sub_smul]
rw [hf₁₂, IsNilpotent.map_iff (NoZeroSMulDivisors.algebraMap_injective R (End R p)),
isNilpotent_iff_eq_zero, sub_eq_zero] at this
contradiction
lemma disjoint_iSup_genEigenspace [NoZeroSMulDivisors R M]
(f : End R M) {μ₁ μ₂ : R} (hμ : μ₁ ≠ μ₂) :
Disjoint (⨆ k, f.genEigenspace μ₁ k) (⨆ k, f.genEigenspace μ₂ k) := by
simp_rw [(f.genEigenspace μ₁).mono.directed_le.disjoint_iSup_left,
(f.genEigenspace μ₂).mono.directed_le.disjoint_iSup_right]
exact disjoint_genEigenspace f hμ
lemma injOn_genEigenspace [NoZeroSMulDivisors R M] (f : End R M) :
InjOn (⨆ k, f.genEigenspace · k) {μ | ⨆ k, f.genEigenspace μ k ≠ ⊥} := by
rintro μ₁ _ μ₂ hμ₂ (hμ₁₂ : ⨆ k, f.genEigenspace μ₁ k = ⨆ k, f.genEigenspace μ₂ k)
by_contra contra
apply hμ₂
simpa only [hμ₁₂, disjoint_self] using f.disjoint_iSup_genEigenspace contra
theorem independent_genEigenspace [NoZeroSMulDivisors R M] (f : End R M) :
CompleteLattice.Independent (fun μ ↦ ⨆ k, f.genEigenspace μ k) := by
classical
suffices ∀ μ (s : Finset R), μ ∉ s → Disjoint (⨆ k, f.genEigenspace μ k)
(s.sup fun μ ↦ ⨆ k, f.genEigenspace μ k) by
simp_rw [CompleteLattice.independent_iff_supIndep_of_injOn f.injOn_genEigenspace,
Finset.supIndep_iff_disjoint_erase]
exact fun s μ _ ↦ this _ _ (s.not_mem_erase μ)
intro μ₁ s
induction' s using Finset.induction_on with μ₂ s _ ih
· simp
intro hμ₁₂
obtain ⟨hμ₁₂ : μ₁ ≠ μ₂, hμ₁ : μ₁ ∉ s⟩ := by rwa [Finset.mem_insert, not_or] at hμ₁₂
specialize ih hμ₁
rw [Finset.sup_insert, disjoint_iff, Submodule.eq_bot_iff]
rintro x ⟨hx, hx'⟩
simp only [SetLike.mem_coe] at hx hx'
suffices x ∈ ⨆ k, genEigenspace f μ₂ k by
rw [← Submodule.mem_bot (R := R), ← (f.disjoint_iSup_genEigenspace hμ₁₂).eq_bot]
exact ⟨hx, this⟩
obtain ⟨y, hy, z, hz, rfl⟩ := Submodule.mem_sup.mp hx'; clear hx'
let g := f - algebraMap R (End R M) μ₂
obtain ⟨k : ℕ, hk : (g ^ k) y = 0⟩ := by simpa using hy
have hyz : (g ^ k) (y + z) ∈
(⨆ k, genEigenspace f μ₁ k) ⊓ s.sup fun μ ↦ ⨆ k, f.genEigenspace μ k := by
refine ⟨f.mapsTo_iSup_genEigenspace_of_comm ?_ μ₁ hx, ?_⟩
· exact Algebra.mul_sub_algebraMap_pow_commutes f μ₂ k
· rw [SetLike.mem_coe, map_add, hk, zero_add]
suffices (s.sup fun μ ↦ ⨆ k, f.genEigenspace μ k).map (g ^ k) ≤
s.sup fun μ ↦ ⨆ k, f.genEigenspace μ k by exact this (Submodule.mem_map_of_mem hz)
simp_rw [Finset.sup_eq_iSup, Submodule.map_iSup (ι := R), Submodule.map_iSup (ι := _ ∈ s)]
refine iSup₂_mono fun μ _ ↦ ?_
rintro - ⟨u, hu, rfl⟩
refine f.mapsTo_iSup_genEigenspace_of_comm ?_ μ hu
exact Algebra.mul_sub_algebraMap_pow_commutes f μ₂ k
rw [ih.eq_bot, Submodule.mem_bot] at hyz
simp_rw [Submodule.mem_iSup_of_chain, mem_genEigenspace]
exact ⟨k, hyz⟩
theorem eigenspaces_independent [NoZeroSMulDivisors R M] (f : End R M) :
CompleteLattice.Independent f.eigenspace :=
f.independent_genEigenspace.mono fun μ ↦ le_iSup (genEigenspace f μ) 1
theorem eigenvectors_linearIndependent [NoZeroSMulDivisors R M]
(f : End R M) (μs : Set R) (xs : μs → M)
(h_eigenvec : ∀ μ : μs, f.HasEigenvector μ (xs μ)) : LinearIndependent R xs :=
CompleteLattice.Independent.linearIndependent _
(f.eigenspaces_independent.comp Subtype.coe_injective) (fun μ => (h_eigenvec μ).1) fun μ =>
(h_eigenvec μ).2
#align module.End.eigenvectors_linear_independent Module.End.eigenvectors_linearIndependent
theorem genEigenspace_restrict (f : End R M) (p : Submodule R M) (k : ℕ) (μ : R)
(hfp : ∀ x : M, x ∈ p → f x ∈ p) :
genEigenspace (LinearMap.restrict f hfp) μ k =
Submodule.comap p.subtype (f.genEigenspace μ k) := by
simp only [genEigenspace, OrderHom.coe_mk, ← LinearMap.ker_comp]
induction' k with k ih
· rw [pow_zero, pow_zero, LinearMap.one_eq_id]
apply (Submodule.ker_subtype _).symm
· erw [pow_succ, pow_succ, LinearMap.ker_comp, LinearMap.ker_comp, ih, ← LinearMap.ker_comp,
LinearMap.comp_assoc]
#align module.End.generalized_eigenspace_restrict Module.End.genEigenspace_restrict
lemma _root_.Submodule.inf_genEigenspace (f : End R M) (p : Submodule R M) {k : ℕ} {μ : R}
(hfp : ∀ x : M, x ∈ p → f x ∈ p) :
p ⊓ f.genEigenspace μ k =
(genEigenspace (LinearMap.restrict f hfp) μ k).map p.subtype := by
rw [f.genEigenspace_restrict _ _ _ hfp, Submodule.map_comap_eq, Submodule.range_subtype]
theorem eigenspace_restrict_le_eigenspace (f : End R M) {p : Submodule R M} (hfp : ∀ x ∈ p, f x ∈ p)
(μ : R) : (eigenspace (f.restrict hfp) μ).map p.subtype ≤ f.eigenspace μ := by
rintro a ⟨x, hx, rfl⟩
simp only [SetLike.mem_coe, mem_eigenspace_iff, LinearMap.restrict_apply] at hx ⊢
exact congr_arg Subtype.val hx
#align module.End.eigenspace_restrict_le_eigenspace Module.End.eigenspace_restrict_le_eigenspace
theorem generalized_eigenvec_disjoint_range_ker [FiniteDimensional K V] (f : End K V) (μ : K) :
Disjoint (f.genEigenrange μ (finrank K V))
(f.genEigenspace μ (finrank K V)) := by
have h :=
calc
Submodule.comap ((f - algebraMap _ _ μ) ^ finrank K V)
(f.genEigenspace μ (finrank K V)) =
LinearMap.ker ((f - algebraMap _ _ μ) ^ finrank K V *
(f - algebraMap K (End K V) μ) ^ finrank K V) := by
rw [genEigenspace, OrderHom.coe_mk, ← LinearMap.ker_comp]; rfl
_ = f.genEigenspace μ (finrank K V + finrank K V) := by rw [← pow_add]; rfl
_ = f.genEigenspace μ (finrank K V) := by
rw [genEigenspace_eq_genEigenspace_finrank_of_le]; omega
rw [disjoint_iff_inf_le, genEigenrange, LinearMap.range_eq_map,
Submodule.map_inf_eq_map_inf_comap, top_inf_eq, h]
apply Submodule.map_comap_le
#align module.End.generalized_eigenvec_disjoint_range_ker Module.End.generalized_eigenvec_disjoint_range_ker
theorem eigenspace_restrict_eq_bot {f : End R M} {p : Submodule R M} (hfp : ∀ x ∈ p, f x ∈ p)
{μ : R} (hμp : Disjoint (f.eigenspace μ) p) : eigenspace (f.restrict hfp) μ = ⊥ := by
rw [eq_bot_iff]
intro x hx
simpa using hμp.le_bot ⟨eigenspace_restrict_le_eigenspace f hfp μ ⟨x, hx, rfl⟩, x.prop⟩
#align module.End.eigenspace_restrict_eq_bot Module.End.eigenspace_restrict_eq_bot
| Mathlib/LinearAlgebra/Eigenspace/Basic.lean | 496 | 503 | theorem pos_finrank_genEigenspace_of_hasEigenvalue [FiniteDimensional K V] {f : End K V}
{k : ℕ} {μ : K} (hx : f.HasEigenvalue μ) (hk : 0 < k) :
0 < finrank K (f.genEigenspace μ k) :=
calc
0 = finrank K (⊥ : Submodule K V) := by | rw [finrank_bot]
_ < finrank K (f.eigenspace μ) := Submodule.finrank_lt_finrank_of_lt (bot_lt_iff_ne_bot.2 hx)
_ ≤ finrank K (f.genEigenspace μ k) :=
Submodule.finrank_mono ((f.genEigenspace μ).monotone (Nat.succ_le_of_lt hk))
|
import Mathlib.Algebra.Order.ZeroLEOne
import Mathlib.Data.List.InsertNth
import Mathlib.Logic.Relation
import Mathlib.Logic.Small.Defs
import Mathlib.Order.GameAdd
#align_import set_theory.game.pgame from "leanprover-community/mathlib"@"8900d545017cd21961daa2a1734bb658ef52c618"
set_option autoImplicit true
namespace SetTheory
open Function Relation
-- We'd like to be able to use multi-character auto-implicits in this file.
set_option relaxedAutoImplicit true
inductive PGame : Type (u + 1)
| mk : ∀ α β : Type u, (α → PGame) → (β → PGame) → PGame
#align pgame SetTheory.PGame
compile_inductive% PGame
namespace PGame
def LeftMoves : PGame → Type u
| mk l _ _ _ => l
#align pgame.left_moves SetTheory.PGame.LeftMoves
def RightMoves : PGame → Type u
| mk _ r _ _ => r
#align pgame.right_moves SetTheory.PGame.RightMoves
def moveLeft : ∀ g : PGame, LeftMoves g → PGame
| mk _l _ L _ => L
#align pgame.move_left SetTheory.PGame.moveLeft
def moveRight : ∀ g : PGame, RightMoves g → PGame
| mk _ _r _ R => R
#align pgame.move_right SetTheory.PGame.moveRight
@[simp]
theorem leftMoves_mk {xl xr xL xR} : (⟨xl, xr, xL, xR⟩ : PGame).LeftMoves = xl :=
rfl
#align pgame.left_moves_mk SetTheory.PGame.leftMoves_mk
@[simp]
theorem moveLeft_mk {xl xr xL xR} : (⟨xl, xr, xL, xR⟩ : PGame).moveLeft = xL :=
rfl
#align pgame.move_left_mk SetTheory.PGame.moveLeft_mk
@[simp]
theorem rightMoves_mk {xl xr xL xR} : (⟨xl, xr, xL, xR⟩ : PGame).RightMoves = xr :=
rfl
#align pgame.right_moves_mk SetTheory.PGame.rightMoves_mk
@[simp]
theorem moveRight_mk {xl xr xL xR} : (⟨xl, xr, xL, xR⟩ : PGame).moveRight = xR :=
rfl
#align pgame.move_right_mk SetTheory.PGame.moveRight_mk
-- TODO define this at the level of games, as well, and perhaps also for finsets of games.
def ofLists (L R : List PGame.{u}) : PGame.{u} :=
mk (ULift (Fin L.length)) (ULift (Fin R.length)) (fun i => L.get i.down) fun j ↦ R.get j.down
#align pgame.of_lists SetTheory.PGame.ofLists
theorem leftMoves_ofLists (L R : List PGame) : (ofLists L R).LeftMoves = ULift (Fin L.length) :=
rfl
#align pgame.left_moves_of_lists SetTheory.PGame.leftMoves_ofLists
theorem rightMoves_ofLists (L R : List PGame) : (ofLists L R).RightMoves = ULift (Fin R.length) :=
rfl
#align pgame.right_moves_of_lists SetTheory.PGame.rightMoves_ofLists
def toOfListsLeftMoves {L R : List PGame} : Fin L.length ≃ (ofLists L R).LeftMoves :=
((Equiv.cast (leftMoves_ofLists L R).symm).trans Equiv.ulift).symm
#align pgame.to_of_lists_left_moves SetTheory.PGame.toOfListsLeftMoves
def toOfListsRightMoves {L R : List PGame} : Fin R.length ≃ (ofLists L R).RightMoves :=
((Equiv.cast (rightMoves_ofLists L R).symm).trans Equiv.ulift).symm
#align pgame.to_of_lists_right_moves SetTheory.PGame.toOfListsRightMoves
theorem ofLists_moveLeft {L R : List PGame} (i : Fin L.length) :
(ofLists L R).moveLeft (toOfListsLeftMoves i) = L.get i :=
rfl
#align pgame.of_lists_move_left SetTheory.PGame.ofLists_moveLeft
@[simp]
theorem ofLists_moveLeft' {L R : List PGame} (i : (ofLists L R).LeftMoves) :
(ofLists L R).moveLeft i = L.get (toOfListsLeftMoves.symm i) :=
rfl
#align pgame.of_lists_move_left' SetTheory.PGame.ofLists_moveLeft'
theorem ofLists_moveRight {L R : List PGame} (i : Fin R.length) :
(ofLists L R).moveRight (toOfListsRightMoves i) = R.get i :=
rfl
#align pgame.of_lists_move_right SetTheory.PGame.ofLists_moveRight
@[simp]
theorem ofLists_moveRight' {L R : List PGame} (i : (ofLists L R).RightMoves) :
(ofLists L R).moveRight i = R.get (toOfListsRightMoves.symm i) :=
rfl
#align pgame.of_lists_move_right' SetTheory.PGame.ofLists_moveRight'
@[elab_as_elim]
def moveRecOn {C : PGame → Sort*} (x : PGame)
(IH : ∀ y : PGame, (∀ i, C (y.moveLeft i)) → (∀ j, C (y.moveRight j)) → C y) : C x :=
x.recOn fun yl yr yL yR => IH (mk yl yr yL yR)
#align pgame.move_rec_on SetTheory.PGame.moveRecOn
@[mk_iff]
inductive IsOption : PGame → PGame → Prop
| moveLeft {x : PGame} (i : x.LeftMoves) : IsOption (x.moveLeft i) x
| moveRight {x : PGame} (i : x.RightMoves) : IsOption (x.moveRight i) x
#align pgame.is_option SetTheory.PGame.IsOption
theorem IsOption.mk_left {xl xr : Type u} (xL : xl → PGame) (xR : xr → PGame) (i : xl) :
(xL i).IsOption (mk xl xr xL xR) :=
@IsOption.moveLeft (mk _ _ _ _) i
#align pgame.is_option.mk_left SetTheory.PGame.IsOption.mk_left
theorem IsOption.mk_right {xl xr : Type u} (xL : xl → PGame) (xR : xr → PGame) (i : xr) :
(xR i).IsOption (mk xl xr xL xR) :=
@IsOption.moveRight (mk _ _ _ _) i
#align pgame.is_option.mk_right SetTheory.PGame.IsOption.mk_right
theorem wf_isOption : WellFounded IsOption :=
⟨fun x =>
moveRecOn x fun x IHl IHr =>
Acc.intro x fun y h => by
induction' h with _ i _ j
· exact IHl i
· exact IHr j⟩
#align pgame.wf_is_option SetTheory.PGame.wf_isOption
def Subsequent : PGame → PGame → Prop :=
TransGen IsOption
#align pgame.subsequent SetTheory.PGame.Subsequent
instance : IsTrans _ Subsequent :=
inferInstanceAs <| IsTrans _ (TransGen _)
@[trans]
theorem Subsequent.trans {x y z} : Subsequent x y → Subsequent y z → Subsequent x z :=
TransGen.trans
#align pgame.subsequent.trans SetTheory.PGame.Subsequent.trans
theorem wf_subsequent : WellFounded Subsequent :=
wf_isOption.transGen
#align pgame.wf_subsequent SetTheory.PGame.wf_subsequent
instance : WellFoundedRelation PGame :=
⟨_, wf_subsequent⟩
@[simp]
theorem Subsequent.moveLeft {x : PGame} (i : x.LeftMoves) : Subsequent (x.moveLeft i) x :=
TransGen.single (IsOption.moveLeft i)
#align pgame.subsequent.move_left SetTheory.PGame.Subsequent.moveLeft
@[simp]
theorem Subsequent.moveRight {x : PGame} (j : x.RightMoves) : Subsequent (x.moveRight j) x :=
TransGen.single (IsOption.moveRight j)
#align pgame.subsequent.move_right SetTheory.PGame.Subsequent.moveRight
@[simp]
theorem Subsequent.mk_left {xl xr} (xL : xl → PGame) (xR : xr → PGame) (i : xl) :
Subsequent (xL i) (mk xl xr xL xR) :=
@Subsequent.moveLeft (mk _ _ _ _) i
#align pgame.subsequent.mk_left SetTheory.PGame.Subsequent.mk_left
@[simp]
theorem Subsequent.mk_right {xl xr} (xL : xl → PGame) (xR : xr → PGame) (j : xr) :
Subsequent (xR j) (mk xl xr xL xR) :=
@Subsequent.moveRight (mk _ _ _ _) j
#align pgame.subsequent.mk_right SetTheory.PGame.Subsequent.mk_right
macro "pgame_wf_tac" : tactic =>
`(tactic| solve_by_elim (config := { maxDepth := 8 })
[Prod.Lex.left, Prod.Lex.right, PSigma.Lex.left, PSigma.Lex.right,
Subsequent.moveLeft, Subsequent.moveRight, Subsequent.mk_left, Subsequent.mk_right,
Subsequent.trans] )
-- Register some consequences of pgame_wf_tac as simp-lemmas for convenience
-- (which are applied by default for WF goals)
-- This is different from mk_right from the POV of the simplifier,
-- because the unifier can't solve `xr =?= RightMoves (mk xl xr xL xR)` at reducible transparency.
@[simp]
theorem Subsequent.mk_right' (xL : xl → PGame) (xR : xr → PGame) (j : RightMoves (mk xl xr xL xR)) :
Subsequent (xR j) (mk xl xr xL xR) := by
pgame_wf_tac
@[simp] theorem Subsequent.moveRight_mk_left (xL : xl → PGame) (j) :
Subsequent ((xL i).moveRight j) (mk xl xr xL xR) := by
pgame_wf_tac
@[simp] theorem Subsequent.moveRight_mk_right (xR : xr → PGame) (j) :
Subsequent ((xR i).moveRight j) (mk xl xr xL xR) := by
pgame_wf_tac
@[simp] theorem Subsequent.moveLeft_mk_left (xL : xl → PGame) (j) :
Subsequent ((xL i).moveLeft j) (mk xl xr xL xR) := by
pgame_wf_tac
@[simp] theorem Subsequent.moveLeft_mk_right (xR : xr → PGame) (j) :
Subsequent ((xR i).moveLeft j) (mk xl xr xL xR) := by
pgame_wf_tac
-- Porting note: linter claims these lemmas don't simplify?
open Subsequent in attribute [nolint simpNF] mk_left mk_right mk_right'
moveRight_mk_left moveRight_mk_right moveLeft_mk_left moveLeft_mk_right
instance : Zero PGame :=
⟨⟨PEmpty, PEmpty, PEmpty.elim, PEmpty.elim⟩⟩
@[simp]
theorem zero_leftMoves : LeftMoves 0 = PEmpty :=
rfl
#align pgame.zero_left_moves SetTheory.PGame.zero_leftMoves
@[simp]
theorem zero_rightMoves : RightMoves 0 = PEmpty :=
rfl
#align pgame.zero_right_moves SetTheory.PGame.zero_rightMoves
instance isEmpty_zero_leftMoves : IsEmpty (LeftMoves 0) :=
instIsEmptyPEmpty
#align pgame.is_empty_zero_left_moves SetTheory.PGame.isEmpty_zero_leftMoves
instance isEmpty_zero_rightMoves : IsEmpty (RightMoves 0) :=
instIsEmptyPEmpty
#align pgame.is_empty_zero_right_moves SetTheory.PGame.isEmpty_zero_rightMoves
instance : Inhabited PGame :=
⟨0⟩
instance instOnePGame : One PGame :=
⟨⟨PUnit, PEmpty, fun _ => 0, PEmpty.elim⟩⟩
@[simp]
theorem one_leftMoves : LeftMoves 1 = PUnit :=
rfl
#align pgame.one_left_moves SetTheory.PGame.one_leftMoves
@[simp]
theorem one_moveLeft (x) : moveLeft 1 x = 0 :=
rfl
#align pgame.one_move_left SetTheory.PGame.one_moveLeft
@[simp]
theorem one_rightMoves : RightMoves 1 = PEmpty :=
rfl
#align pgame.one_right_moves SetTheory.PGame.one_rightMoves
instance uniqueOneLeftMoves : Unique (LeftMoves 1) :=
PUnit.unique
#align pgame.unique_one_left_moves SetTheory.PGame.uniqueOneLeftMoves
instance isEmpty_one_rightMoves : IsEmpty (RightMoves 1) :=
instIsEmptyPEmpty
#align pgame.is_empty_one_right_moves SetTheory.PGame.isEmpty_one_rightMoves
instance le : LE PGame :=
⟨Sym2.GameAdd.fix wf_isOption fun x y le =>
(∀ i, ¬le y (x.moveLeft i) (Sym2.GameAdd.snd_fst <| IsOption.moveLeft i)) ∧
∀ j, ¬le (y.moveRight j) x (Sym2.GameAdd.fst_snd <| IsOption.moveRight j)⟩
def LF (x y : PGame) : Prop :=
¬y ≤ x
#align pgame.lf SetTheory.PGame.LF
@[inherit_doc]
scoped infixl:50 " ⧏ " => PGame.LF
@[simp]
protected theorem not_le {x y : PGame} : ¬x ≤ y ↔ y ⧏ x :=
Iff.rfl
#align pgame.not_le SetTheory.PGame.not_le
@[simp]
theorem not_lf {x y : PGame} : ¬x ⧏ y ↔ y ≤ x :=
Classical.not_not
#align pgame.not_lf SetTheory.PGame.not_lf
theorem _root_.LE.le.not_gf {x y : PGame} : x ≤ y → ¬y ⧏ x :=
not_lf.2
#align has_le.le.not_gf LE.le.not_gf
theorem LF.not_ge {x y : PGame} : x ⧏ y → ¬y ≤ x :=
id
#align pgame.lf.not_ge SetTheory.PGame.LF.not_ge
theorem le_iff_forall_lf {x y : PGame} :
x ≤ y ↔ (∀ i, x.moveLeft i ⧏ y) ∧ ∀ j, x ⧏ y.moveRight j := by
unfold LE.le le
simp only
rw [Sym2.GameAdd.fix_eq]
rfl
#align pgame.le_iff_forall_lf SetTheory.PGame.le_iff_forall_lf
@[simp]
theorem mk_le_mk {xl xr xL xR yl yr yL yR} :
mk xl xr xL xR ≤ mk yl yr yL yR ↔ (∀ i, xL i ⧏ mk yl yr yL yR) ∧ ∀ j, mk xl xr xL xR ⧏ yR j :=
le_iff_forall_lf
#align pgame.mk_le_mk SetTheory.PGame.mk_le_mk
theorem le_of_forall_lf {x y : PGame} (h₁ : ∀ i, x.moveLeft i ⧏ y) (h₂ : ∀ j, x ⧏ y.moveRight j) :
x ≤ y :=
le_iff_forall_lf.2 ⟨h₁, h₂⟩
#align pgame.le_of_forall_lf SetTheory.PGame.le_of_forall_lf
theorem lf_iff_exists_le {x y : PGame} :
x ⧏ y ↔ (∃ i, x ≤ y.moveLeft i) ∨ ∃ j, x.moveRight j ≤ y := by
rw [LF, le_iff_forall_lf, not_and_or]
simp
#align pgame.lf_iff_exists_le SetTheory.PGame.lf_iff_exists_le
@[simp]
theorem mk_lf_mk {xl xr xL xR yl yr yL yR} :
mk xl xr xL xR ⧏ mk yl yr yL yR ↔ (∃ i, mk xl xr xL xR ≤ yL i) ∨ ∃ j, xR j ≤ mk yl yr yL yR :=
lf_iff_exists_le
#align pgame.mk_lf_mk SetTheory.PGame.mk_lf_mk
theorem le_or_gf (x y : PGame) : x ≤ y ∨ y ⧏ x := by
rw [← PGame.not_le]
apply em
#align pgame.le_or_gf SetTheory.PGame.le_or_gf
theorem moveLeft_lf_of_le {x y : PGame} (h : x ≤ y) (i) : x.moveLeft i ⧏ y :=
(le_iff_forall_lf.1 h).1 i
#align pgame.move_left_lf_of_le SetTheory.PGame.moveLeft_lf_of_le
alias _root_.LE.le.moveLeft_lf := moveLeft_lf_of_le
#align has_le.le.move_left_lf LE.le.moveLeft_lf
theorem lf_moveRight_of_le {x y : PGame} (h : x ≤ y) (j) : x ⧏ y.moveRight j :=
(le_iff_forall_lf.1 h).2 j
#align pgame.lf_move_right_of_le SetTheory.PGame.lf_moveRight_of_le
alias _root_.LE.le.lf_moveRight := lf_moveRight_of_le
#align has_le.le.lf_move_right LE.le.lf_moveRight
theorem lf_of_moveRight_le {x y : PGame} {j} (h : x.moveRight j ≤ y) : x ⧏ y :=
lf_iff_exists_le.2 <| Or.inr ⟨j, h⟩
#align pgame.lf_of_move_right_le SetTheory.PGame.lf_of_moveRight_le
theorem lf_of_le_moveLeft {x y : PGame} {i} (h : x ≤ y.moveLeft i) : x ⧏ y :=
lf_iff_exists_le.2 <| Or.inl ⟨i, h⟩
#align pgame.lf_of_le_move_left SetTheory.PGame.lf_of_le_moveLeft
theorem lf_of_le_mk {xl xr xL xR y} : mk xl xr xL xR ≤ y → ∀ i, xL i ⧏ y :=
moveLeft_lf_of_le
#align pgame.lf_of_le_mk SetTheory.PGame.lf_of_le_mk
theorem lf_of_mk_le {x yl yr yL yR} : x ≤ mk yl yr yL yR → ∀ j, x ⧏ yR j :=
lf_moveRight_of_le
#align pgame.lf_of_mk_le SetTheory.PGame.lf_of_mk_le
theorem mk_lf_of_le {xl xr y j} (xL) {xR : xr → PGame} : xR j ≤ y → mk xl xr xL xR ⧏ y :=
@lf_of_moveRight_le (mk _ _ _ _) y j
#align pgame.mk_lf_of_le SetTheory.PGame.mk_lf_of_le
theorem lf_mk_of_le {x yl yr} {yL : yl → PGame} (yR) {i} : x ≤ yL i → x ⧏ mk yl yr yL yR :=
@lf_of_le_moveLeft x (mk _ _ _ _) i
#align pgame.lf_mk_of_le SetTheory.PGame.lf_mk_of_le
private theorem le_trans_aux {x y z : PGame}
(h₁ : ∀ {i}, y ≤ z → z ≤ x.moveLeft i → y ≤ x.moveLeft i)
(h₂ : ∀ {j}, z.moveRight j ≤ x → x ≤ y → z.moveRight j ≤ y) (hxy : x ≤ y) (hyz : y ≤ z) :
x ≤ z :=
le_of_forall_lf (fun i => PGame.not_le.1 fun h => (h₁ hyz h).not_gf <| hxy.moveLeft_lf i)
fun j => PGame.not_le.1 fun h => (h₂ h hxy).not_gf <| hyz.lf_moveRight j
instance : Preorder PGame :=
{ PGame.le with
le_refl := fun x => by
induction' x with _ _ _ _ IHl IHr
exact
le_of_forall_lf (fun i => lf_of_le_moveLeft (IHl i)) fun i => lf_of_moveRight_le (IHr i)
le_trans := by
suffices
∀ {x y z : PGame},
(x ≤ y → y ≤ z → x ≤ z) ∧ (y ≤ z → z ≤ x → y ≤ x) ∧ (z ≤ x → x ≤ y → z ≤ y) from
fun x y z => this.1
intro x y z
induction' x with xl xr xL xR IHxl IHxr generalizing y z
induction' y with yl yr yL yR IHyl IHyr generalizing z
induction' z with zl zr zL zR IHzl IHzr
exact
⟨le_trans_aux (fun {i} => (IHxl i).2.1) fun {j} => (IHzr j).2.2,
le_trans_aux (fun {i} => (IHyl i).2.2) fun {j} => (IHxr j).1,
le_trans_aux (fun {i} => (IHzl i).1) fun {j} => (IHyr j).2.1⟩
lt := fun x y => x ≤ y ∧ x ⧏ y }
theorem lt_iff_le_and_lf {x y : PGame} : x < y ↔ x ≤ y ∧ x ⧏ y :=
Iff.rfl
#align pgame.lt_iff_le_and_lf SetTheory.PGame.lt_iff_le_and_lf
theorem lt_of_le_of_lf {x y : PGame} (h₁ : x ≤ y) (h₂ : x ⧏ y) : x < y :=
⟨h₁, h₂⟩
#align pgame.lt_of_le_of_lf SetTheory.PGame.lt_of_le_of_lf
theorem lf_of_lt {x y : PGame} (h : x < y) : x ⧏ y :=
h.2
#align pgame.lf_of_lt SetTheory.PGame.lf_of_lt
alias _root_.LT.lt.lf := lf_of_lt
#align has_lt.lt.lf LT.lt.lf
theorem lf_irrefl (x : PGame) : ¬x ⧏ x :=
le_rfl.not_gf
#align pgame.lf_irrefl SetTheory.PGame.lf_irrefl
instance : IsIrrefl _ (· ⧏ ·) :=
⟨lf_irrefl⟩
@[trans]
theorem lf_of_le_of_lf {x y z : PGame} (h₁ : x ≤ y) (h₂ : y ⧏ z) : x ⧏ z := by
rw [← PGame.not_le] at h₂ ⊢
exact fun h₃ => h₂ (h₃.trans h₁)
#align pgame.lf_of_le_of_lf SetTheory.PGame.lf_of_le_of_lf
-- Porting note (#10754): added instance
instance : Trans (· ≤ ·) (· ⧏ ·) (· ⧏ ·) := ⟨lf_of_le_of_lf⟩
@[trans]
theorem lf_of_lf_of_le {x y z : PGame} (h₁ : x ⧏ y) (h₂ : y ≤ z) : x ⧏ z := by
rw [← PGame.not_le] at h₁ ⊢
exact fun h₃ => h₁ (h₂.trans h₃)
#align pgame.lf_of_lf_of_le SetTheory.PGame.lf_of_lf_of_le
-- Porting note (#10754): added instance
instance : Trans (· ⧏ ·) (· ≤ ·) (· ⧏ ·) := ⟨lf_of_lf_of_le⟩
alias _root_.LE.le.trans_lf := lf_of_le_of_lf
#align has_le.le.trans_lf LE.le.trans_lf
alias LF.trans_le := lf_of_lf_of_le
#align pgame.lf.trans_le SetTheory.PGame.LF.trans_le
@[trans]
theorem lf_of_lt_of_lf {x y z : PGame} (h₁ : x < y) (h₂ : y ⧏ z) : x ⧏ z :=
h₁.le.trans_lf h₂
#align pgame.lf_of_lt_of_lf SetTheory.PGame.lf_of_lt_of_lf
@[trans]
theorem lf_of_lf_of_lt {x y z : PGame} (h₁ : x ⧏ y) (h₂ : y < z) : x ⧏ z :=
h₁.trans_le h₂.le
#align pgame.lf_of_lf_of_lt SetTheory.PGame.lf_of_lf_of_lt
alias _root_.LT.lt.trans_lf := lf_of_lt_of_lf
#align has_lt.lt.trans_lf LT.lt.trans_lf
alias LF.trans_lt := lf_of_lf_of_lt
#align pgame.lf.trans_lt SetTheory.PGame.LF.trans_lt
theorem moveLeft_lf {x : PGame} : ∀ i, x.moveLeft i ⧏ x :=
le_rfl.moveLeft_lf
#align pgame.move_left_lf SetTheory.PGame.moveLeft_lf
theorem lf_moveRight {x : PGame} : ∀ j, x ⧏ x.moveRight j :=
le_rfl.lf_moveRight
#align pgame.lf_move_right SetTheory.PGame.lf_moveRight
theorem lf_mk {xl xr} (xL : xl → PGame) (xR : xr → PGame) (i) : xL i ⧏ mk xl xr xL xR :=
@moveLeft_lf (mk _ _ _ _) i
#align pgame.lf_mk SetTheory.PGame.lf_mk
theorem mk_lf {xl xr} (xL : xl → PGame) (xR : xr → PGame) (j) : mk xl xr xL xR ⧏ xR j :=
@lf_moveRight (mk _ _ _ _) j
#align pgame.mk_lf SetTheory.PGame.mk_lf
theorem le_of_forall_lt {x y : PGame} (h₁ : ∀ i, x.moveLeft i < y) (h₂ : ∀ j, x < y.moveRight j) :
x ≤ y :=
le_of_forall_lf (fun i => (h₁ i).lf) fun i => (h₂ i).lf
#align pgame.le_of_forall_lt SetTheory.PGame.le_of_forall_lt
theorem le_def {x y : PGame} :
x ≤ y ↔
(∀ i, (∃ i', x.moveLeft i ≤ y.moveLeft i') ∨ ∃ j, (x.moveLeft i).moveRight j ≤ y) ∧
∀ j, (∃ i, x ≤ (y.moveRight j).moveLeft i) ∨ ∃ j', x.moveRight j' ≤ y.moveRight j := by
rw [le_iff_forall_lf]
conv =>
lhs
simp only [lf_iff_exists_le]
#align pgame.le_def SetTheory.PGame.le_def
theorem lf_def {x y : PGame} :
x ⧏ y ↔
(∃ i, (∀ i', x.moveLeft i' ⧏ y.moveLeft i) ∧ ∀ j, x ⧏ (y.moveLeft i).moveRight j) ∨
∃ j, (∀ i, (x.moveRight j).moveLeft i ⧏ y) ∧ ∀ j', x.moveRight j ⧏ y.moveRight j' := by
rw [lf_iff_exists_le]
conv =>
lhs
simp only [le_iff_forall_lf]
#align pgame.lf_def SetTheory.PGame.lf_def
theorem zero_le_lf {x : PGame} : 0 ≤ x ↔ ∀ j, 0 ⧏ x.moveRight j := by
rw [le_iff_forall_lf]
simp
#align pgame.zero_le_lf SetTheory.PGame.zero_le_lf
theorem le_zero_lf {x : PGame} : x ≤ 0 ↔ ∀ i, x.moveLeft i ⧏ 0 := by
rw [le_iff_forall_lf]
simp
#align pgame.le_zero_lf SetTheory.PGame.le_zero_lf
theorem zero_lf_le {x : PGame} : 0 ⧏ x ↔ ∃ i, 0 ≤ x.moveLeft i := by
rw [lf_iff_exists_le]
simp
#align pgame.zero_lf_le SetTheory.PGame.zero_lf_le
theorem lf_zero_le {x : PGame} : x ⧏ 0 ↔ ∃ j, x.moveRight j ≤ 0 := by
rw [lf_iff_exists_le]
simp
#align pgame.lf_zero_le SetTheory.PGame.lf_zero_le
theorem zero_le {x : PGame} : 0 ≤ x ↔ ∀ j, ∃ i, 0 ≤ (x.moveRight j).moveLeft i := by
rw [le_def]
simp
#align pgame.zero_le SetTheory.PGame.zero_le
theorem le_zero {x : PGame} : x ≤ 0 ↔ ∀ i, ∃ j, (x.moveLeft i).moveRight j ≤ 0 := by
rw [le_def]
simp
#align pgame.le_zero SetTheory.PGame.le_zero
theorem zero_lf {x : PGame} : 0 ⧏ x ↔ ∃ i, ∀ j, 0 ⧏ (x.moveLeft i).moveRight j := by
rw [lf_def]
simp
#align pgame.zero_lf SetTheory.PGame.zero_lf
theorem lf_zero {x : PGame} : x ⧏ 0 ↔ ∃ j, ∀ i, (x.moveRight j).moveLeft i ⧏ 0 := by
rw [lf_def]
simp
#align pgame.lf_zero SetTheory.PGame.lf_zero
@[simp]
theorem zero_le_of_isEmpty_rightMoves (x : PGame) [IsEmpty x.RightMoves] : 0 ≤ x :=
zero_le.2 isEmptyElim
#align pgame.zero_le_of_is_empty_right_moves SetTheory.PGame.zero_le_of_isEmpty_rightMoves
@[simp]
theorem le_zero_of_isEmpty_leftMoves (x : PGame) [IsEmpty x.LeftMoves] : x ≤ 0 :=
le_zero.2 isEmptyElim
#align pgame.le_zero_of_is_empty_left_moves SetTheory.PGame.le_zero_of_isEmpty_leftMoves
noncomputable def rightResponse {x : PGame} (h : x ≤ 0) (i : x.LeftMoves) :
(x.moveLeft i).RightMoves :=
Classical.choose <| (le_zero.1 h) i
#align pgame.right_response SetTheory.PGame.rightResponse
theorem rightResponse_spec {x : PGame} (h : x ≤ 0) (i : x.LeftMoves) :
(x.moveLeft i).moveRight (rightResponse h i) ≤ 0 :=
Classical.choose_spec <| (le_zero.1 h) i
#align pgame.right_response_spec SetTheory.PGame.rightResponse_spec
noncomputable def leftResponse {x : PGame} (h : 0 ≤ x) (j : x.RightMoves) :
(x.moveRight j).LeftMoves :=
Classical.choose <| (zero_le.1 h) j
#align pgame.left_response SetTheory.PGame.leftResponse
theorem leftResponse_spec {x : PGame} (h : 0 ≤ x) (j : x.RightMoves) :
0 ≤ (x.moveRight j).moveLeft (leftResponse h j) :=
Classical.choose_spec <| (zero_le.1 h) j
#align pgame.left_response_spec SetTheory.PGame.leftResponse_spec
#noalign pgame.upper_bound
#noalign pgame.upper_bound_right_moves_empty
#noalign pgame.le_upper_bound
#noalign pgame.upper_bound_mem_upper_bounds
lemma bddAbove_range_of_small [Small.{u} ι] (f : ι → PGame.{u}) : BddAbove (Set.range f) := by
let x : PGame.{u} := ⟨Σ i, (f $ (equivShrink.{u} ι).symm i).LeftMoves, PEmpty,
fun x ↦ moveLeft _ x.2, PEmpty.elim⟩
refine ⟨x, Set.forall_mem_range.2 fun i ↦ ?_⟩
rw [← (equivShrink ι).symm_apply_apply i, le_iff_forall_lf]
simpa [x] using fun j ↦ @moveLeft_lf x ⟨equivShrink ι i, j⟩
lemma bddAbove_of_small (s : Set PGame.{u}) [Small.{u} s] : BddAbove s := by
simpa using bddAbove_range_of_small (Subtype.val : s → PGame.{u})
#align pgame.bdd_above_of_small SetTheory.PGame.bddAbove_of_small
#noalign pgame.lower_bound
#noalign pgame.lower_bound_left_moves_empty
#noalign pgame.lower_bound_le
#noalign pgame.lower_bound_mem_lower_bounds
lemma bddBelow_range_of_small [Small.{u} ι] (f : ι → PGame.{u}) : BddBelow (Set.range f) := by
let x : PGame.{u} := ⟨PEmpty, Σ i, (f $ (equivShrink.{u} ι).symm i).RightMoves, PEmpty.elim,
fun x ↦ moveRight _ x.2⟩
refine ⟨x, Set.forall_mem_range.2 fun i ↦ ?_⟩
rw [← (equivShrink ι).symm_apply_apply i, le_iff_forall_lf]
simpa [x] using fun j ↦ @lf_moveRight x ⟨equivShrink ι i, j⟩
lemma bddBelow_of_small (s : Set PGame.{u}) [Small.{u} s] : BddBelow s := by
simpa using bddBelow_range_of_small (Subtype.val : s → PGame.{u})
#align pgame.bdd_below_of_small SetTheory.PGame.bddBelow_of_small
def Equiv (x y : PGame) : Prop :=
x ≤ y ∧ y ≤ x
#align pgame.equiv SetTheory.PGame.Equiv
-- Porting note: deleted the scoped notation due to notation overloading with the setoid
-- instance and this causes the PGame.equiv docstring to not show up on hover.
instance : IsEquiv _ PGame.Equiv where
refl _ := ⟨le_rfl, le_rfl⟩
trans := fun _ _ _ ⟨xy, yx⟩ ⟨yz, zy⟩ => ⟨xy.trans yz, zy.trans yx⟩
symm _ _ := And.symm
-- Porting note: moved the setoid instance from Basic.lean to here
instance setoid : Setoid PGame :=
⟨Equiv, refl, symm, Trans.trans⟩
#align pgame.setoid SetTheory.PGame.setoid
theorem Equiv.le {x y : PGame} (h : x ≈ y) : x ≤ y :=
h.1
#align pgame.equiv.le SetTheory.PGame.Equiv.le
theorem Equiv.ge {x y : PGame} (h : x ≈ y) : y ≤ x :=
h.2
#align pgame.equiv.ge SetTheory.PGame.Equiv.ge
@[refl, simp]
theorem equiv_rfl {x : PGame} : x ≈ x :=
refl x
#align pgame.equiv_rfl SetTheory.PGame.equiv_rfl
theorem equiv_refl (x : PGame) : x ≈ x :=
refl x
#align pgame.equiv_refl SetTheory.PGame.equiv_refl
@[symm]
protected theorem Equiv.symm {x y : PGame} : (x ≈ y) → (y ≈ x) :=
symm
#align pgame.equiv.symm SetTheory.PGame.Equiv.symm
@[trans]
protected theorem Equiv.trans {x y z : PGame} : (x ≈ y) → (y ≈ z) → (x ≈ z) :=
_root_.trans
#align pgame.equiv.trans SetTheory.PGame.Equiv.trans
protected theorem equiv_comm {x y : PGame} : (x ≈ y) ↔ (y ≈ x) :=
comm
#align pgame.equiv_comm SetTheory.PGame.equiv_comm
theorem equiv_of_eq {x y : PGame} (h : x = y) : x ≈ y := by subst h; rfl
#align pgame.equiv_of_eq SetTheory.PGame.equiv_of_eq
@[trans]
theorem le_of_le_of_equiv {x y z : PGame} (h₁ : x ≤ y) (h₂ : y ≈ z) : x ≤ z :=
h₁.trans h₂.1
#align pgame.le_of_le_of_equiv SetTheory.PGame.le_of_le_of_equiv
instance : Trans
((· ≤ ·) : PGame → PGame → Prop)
((· ≈ ·) : PGame → PGame → Prop)
((· ≤ ·) : PGame → PGame → Prop) where
trans := le_of_le_of_equiv
@[trans]
theorem le_of_equiv_of_le {x y z : PGame} (h₁ : x ≈ y) : y ≤ z → x ≤ z :=
h₁.1.trans
#align pgame.le_of_equiv_of_le SetTheory.PGame.le_of_equiv_of_le
instance : Trans
((· ≈ ·) : PGame → PGame → Prop)
((· ≤ ·) : PGame → PGame → Prop)
((· ≤ ·) : PGame → PGame → Prop) where
trans := le_of_equiv_of_le
theorem LF.not_equiv {x y : PGame} (h : x ⧏ y) : ¬(x ≈ y) := fun h' => h.not_ge h'.2
#align pgame.lf.not_equiv SetTheory.PGame.LF.not_equiv
theorem LF.not_equiv' {x y : PGame} (h : x ⧏ y) : ¬(y ≈ x) := fun h' => h.not_ge h'.1
#align pgame.lf.not_equiv' SetTheory.PGame.LF.not_equiv'
theorem LF.not_gt {x y : PGame} (h : x ⧏ y) : ¬y < x := fun h' => h.not_ge h'.le
#align pgame.lf.not_gt SetTheory.PGame.LF.not_gt
theorem le_congr_imp {x₁ y₁ x₂ y₂ : PGame} (hx : x₁ ≈ x₂) (hy : y₁ ≈ y₂) (h : x₁ ≤ y₁) : x₂ ≤ y₂ :=
hx.2.trans (h.trans hy.1)
#align pgame.le_congr_imp SetTheory.PGame.le_congr_imp
theorem le_congr {x₁ y₁ x₂ y₂ : PGame} (hx : x₁ ≈ x₂) (hy : y₁ ≈ y₂) : x₁ ≤ y₁ ↔ x₂ ≤ y₂ :=
⟨le_congr_imp hx hy, le_congr_imp (Equiv.symm hx) (Equiv.symm hy)⟩
#align pgame.le_congr SetTheory.PGame.le_congr
theorem le_congr_left {x₁ x₂ y : PGame} (hx : x₁ ≈ x₂) : x₁ ≤ y ↔ x₂ ≤ y :=
le_congr hx equiv_rfl
#align pgame.le_congr_left SetTheory.PGame.le_congr_left
theorem le_congr_right {x y₁ y₂ : PGame} (hy : y₁ ≈ y₂) : x ≤ y₁ ↔ x ≤ y₂ :=
le_congr equiv_rfl hy
#align pgame.le_congr_right SetTheory.PGame.le_congr_right
theorem lf_congr {x₁ y₁ x₂ y₂ : PGame} (hx : x₁ ≈ x₂) (hy : y₁ ≈ y₂) : x₁ ⧏ y₁ ↔ x₂ ⧏ y₂ :=
PGame.not_le.symm.trans <| (not_congr (le_congr hy hx)).trans PGame.not_le
#align pgame.lf_congr SetTheory.PGame.lf_congr
theorem lf_congr_imp {x₁ y₁ x₂ y₂ : PGame} (hx : x₁ ≈ x₂) (hy : y₁ ≈ y₂) : x₁ ⧏ y₁ → x₂ ⧏ y₂ :=
(lf_congr hx hy).1
#align pgame.lf_congr_imp SetTheory.PGame.lf_congr_imp
theorem lf_congr_left {x₁ x₂ y : PGame} (hx : x₁ ≈ x₂) : x₁ ⧏ y ↔ x₂ ⧏ y :=
lf_congr hx equiv_rfl
#align pgame.lf_congr_left SetTheory.PGame.lf_congr_left
theorem lf_congr_right {x y₁ y₂ : PGame} (hy : y₁ ≈ y₂) : x ⧏ y₁ ↔ x ⧏ y₂ :=
lf_congr equiv_rfl hy
#align pgame.lf_congr_right SetTheory.PGame.lf_congr_right
@[trans]
theorem lf_of_lf_of_equiv {x y z : PGame} (h₁ : x ⧏ y) (h₂ : y ≈ z) : x ⧏ z :=
lf_congr_imp equiv_rfl h₂ h₁
#align pgame.lf_of_lf_of_equiv SetTheory.PGame.lf_of_lf_of_equiv
@[trans]
theorem lf_of_equiv_of_lf {x y z : PGame} (h₁ : x ≈ y) : y ⧏ z → x ⧏ z :=
lf_congr_imp (Equiv.symm h₁) equiv_rfl
#align pgame.lf_of_equiv_of_lf SetTheory.PGame.lf_of_equiv_of_lf
@[trans]
theorem lt_of_lt_of_equiv {x y z : PGame} (h₁ : x < y) (h₂ : y ≈ z) : x < z :=
h₁.trans_le h₂.1
#align pgame.lt_of_lt_of_equiv SetTheory.PGame.lt_of_lt_of_equiv
@[trans]
theorem lt_of_equiv_of_lt {x y z : PGame} (h₁ : x ≈ y) : y < z → x < z :=
h₁.1.trans_lt
#align pgame.lt_of_equiv_of_lt SetTheory.PGame.lt_of_equiv_of_lt
instance : Trans
((· ≈ ·) : PGame → PGame → Prop)
((· < ·) : PGame → PGame → Prop)
((· < ·) : PGame → PGame → Prop) where
trans := lt_of_equiv_of_lt
theorem lt_congr_imp {x₁ y₁ x₂ y₂ : PGame} (hx : x₁ ≈ x₂) (hy : y₁ ≈ y₂) (h : x₁ < y₁) : x₂ < y₂ :=
hx.2.trans_lt (h.trans_le hy.1)
#align pgame.lt_congr_imp SetTheory.PGame.lt_congr_imp
theorem lt_congr {x₁ y₁ x₂ y₂ : PGame} (hx : x₁ ≈ x₂) (hy : y₁ ≈ y₂) : x₁ < y₁ ↔ x₂ < y₂ :=
⟨lt_congr_imp hx hy, lt_congr_imp (Equiv.symm hx) (Equiv.symm hy)⟩
#align pgame.lt_congr SetTheory.PGame.lt_congr
theorem lt_congr_left {x₁ x₂ y : PGame} (hx : x₁ ≈ x₂) : x₁ < y ↔ x₂ < y :=
lt_congr hx equiv_rfl
#align pgame.lt_congr_left SetTheory.PGame.lt_congr_left
theorem lt_congr_right {x y₁ y₂ : PGame} (hy : y₁ ≈ y₂) : x < y₁ ↔ x < y₂ :=
lt_congr equiv_rfl hy
#align pgame.lt_congr_right SetTheory.PGame.lt_congr_right
theorem lt_or_equiv_of_le {x y : PGame} (h : x ≤ y) : x < y ∨ (x ≈ y) :=
and_or_left.mp ⟨h, (em <| y ≤ x).symm.imp_left PGame.not_le.1⟩
#align pgame.lt_or_equiv_of_le SetTheory.PGame.lt_or_equiv_of_le
theorem lf_or_equiv_or_gf (x y : PGame) : x ⧏ y ∨ (x ≈ y) ∨ y ⧏ x := by
by_cases h : x ⧏ y
· exact Or.inl h
· right
cases' lt_or_equiv_of_le (PGame.not_lf.1 h) with h' h'
· exact Or.inr h'.lf
· exact Or.inl (Equiv.symm h')
#align pgame.lf_or_equiv_or_gf SetTheory.PGame.lf_or_equiv_or_gf
theorem equiv_congr_left {y₁ y₂ : PGame} : (y₁ ≈ y₂) ↔ ∀ x₁, (x₁ ≈ y₁) ↔ (x₁ ≈ y₂) :=
⟨fun h _ => ⟨fun h' => Equiv.trans h' h, fun h' => Equiv.trans h' (Equiv.symm h)⟩,
fun h => (h y₁).1 <| equiv_rfl⟩
#align pgame.equiv_congr_left SetTheory.PGame.equiv_congr_left
theorem equiv_congr_right {x₁ x₂ : PGame} : (x₁ ≈ x₂) ↔ ∀ y₁, (x₁ ≈ y₁) ↔ (x₂ ≈ y₁) :=
⟨fun h _ => ⟨fun h' => Equiv.trans (Equiv.symm h) h', fun h' => Equiv.trans h h'⟩,
fun h => (h x₂).2 <| equiv_rfl⟩
#align pgame.equiv_congr_right SetTheory.PGame.equiv_congr_right
theorem equiv_of_mk_equiv {x y : PGame} (L : x.LeftMoves ≃ y.LeftMoves)
(R : x.RightMoves ≃ y.RightMoves) (hl : ∀ i, x.moveLeft i ≈ y.moveLeft (L i))
(hr : ∀ j, x.moveRight j ≈ y.moveRight (R j)) : x ≈ y := by
constructor <;> rw [le_def]
· exact ⟨fun i => Or.inl ⟨_, (hl i).1⟩, fun j => Or.inr ⟨_, by simpa using (hr (R.symm j)).1⟩⟩
· exact ⟨fun i => Or.inl ⟨_, by simpa using (hl (L.symm i)).2⟩, fun j => Or.inr ⟨_, (hr j).2⟩⟩
#align pgame.equiv_of_mk_equiv SetTheory.PGame.equiv_of_mk_equiv
def Fuzzy (x y : PGame) : Prop :=
x ⧏ y ∧ y ⧏ x
#align pgame.fuzzy SetTheory.PGame.Fuzzy
@[inherit_doc]
scoped infixl:50 " ‖ " => PGame.Fuzzy
@[symm]
theorem Fuzzy.swap {x y : PGame} : x ‖ y → y ‖ x :=
And.symm
#align pgame.fuzzy.swap SetTheory.PGame.Fuzzy.swap
instance : IsSymm _ (· ‖ ·) :=
⟨fun _ _ => Fuzzy.swap⟩
theorem Fuzzy.swap_iff {x y : PGame} : x ‖ y ↔ y ‖ x :=
⟨Fuzzy.swap, Fuzzy.swap⟩
#align pgame.fuzzy.swap_iff SetTheory.PGame.Fuzzy.swap_iff
theorem fuzzy_irrefl (x : PGame) : ¬x ‖ x := fun h => lf_irrefl x h.1
#align pgame.fuzzy_irrefl SetTheory.PGame.fuzzy_irrefl
instance : IsIrrefl _ (· ‖ ·) :=
⟨fuzzy_irrefl⟩
theorem lf_iff_lt_or_fuzzy {x y : PGame} : x ⧏ y ↔ x < y ∨ x ‖ y := by
simp only [lt_iff_le_and_lf, Fuzzy, ← PGame.not_le]
tauto
#align pgame.lf_iff_lt_or_fuzzy SetTheory.PGame.lf_iff_lt_or_fuzzy
theorem lf_of_fuzzy {x y : PGame} (h : x ‖ y) : x ⧏ y :=
lf_iff_lt_or_fuzzy.2 (Or.inr h)
#align pgame.lf_of_fuzzy SetTheory.PGame.lf_of_fuzzy
alias Fuzzy.lf := lf_of_fuzzy
#align pgame.fuzzy.lf SetTheory.PGame.Fuzzy.lf
theorem lt_or_fuzzy_of_lf {x y : PGame} : x ⧏ y → x < y ∨ x ‖ y :=
lf_iff_lt_or_fuzzy.1
#align pgame.lt_or_fuzzy_of_lf SetTheory.PGame.lt_or_fuzzy_of_lf
theorem Fuzzy.not_equiv {x y : PGame} (h : x ‖ y) : ¬(x ≈ y) := fun h' => h'.1.not_gf h.2
#align pgame.fuzzy.not_equiv SetTheory.PGame.Fuzzy.not_equiv
theorem Fuzzy.not_equiv' {x y : PGame} (h : x ‖ y) : ¬(y ≈ x) := fun h' => h'.2.not_gf h.2
#align pgame.fuzzy.not_equiv' SetTheory.PGame.Fuzzy.not_equiv'
theorem not_fuzzy_of_le {x y : PGame} (h : x ≤ y) : ¬x ‖ y := fun h' => h'.2.not_ge h
#align pgame.not_fuzzy_of_le SetTheory.PGame.not_fuzzy_of_le
theorem not_fuzzy_of_ge {x y : PGame} (h : y ≤ x) : ¬x ‖ y := fun h' => h'.1.not_ge h
#align pgame.not_fuzzy_of_ge SetTheory.PGame.not_fuzzy_of_ge
theorem Equiv.not_fuzzy {x y : PGame} (h : x ≈ y) : ¬x ‖ y :=
not_fuzzy_of_le h.1
#align pgame.equiv.not_fuzzy SetTheory.PGame.Equiv.not_fuzzy
theorem Equiv.not_fuzzy' {x y : PGame} (h : x ≈ y) : ¬y ‖ x :=
not_fuzzy_of_le h.2
#align pgame.equiv.not_fuzzy' SetTheory.PGame.Equiv.not_fuzzy'
theorem fuzzy_congr {x₁ y₁ x₂ y₂ : PGame} (hx : x₁ ≈ x₂) (hy : y₁ ≈ y₂) : x₁ ‖ y₁ ↔ x₂ ‖ y₂ :=
show _ ∧ _ ↔ _ ∧ _ by rw [lf_congr hx hy, lf_congr hy hx]
#align pgame.fuzzy_congr SetTheory.PGame.fuzzy_congr
theorem fuzzy_congr_imp {x₁ y₁ x₂ y₂ : PGame} (hx : x₁ ≈ x₂) (hy : y₁ ≈ y₂) : x₁ ‖ y₁ → x₂ ‖ y₂ :=
(fuzzy_congr hx hy).1
#align pgame.fuzzy_congr_imp SetTheory.PGame.fuzzy_congr_imp
theorem fuzzy_congr_left {x₁ x₂ y : PGame} (hx : x₁ ≈ x₂) : x₁ ‖ y ↔ x₂ ‖ y :=
fuzzy_congr hx equiv_rfl
#align pgame.fuzzy_congr_left SetTheory.PGame.fuzzy_congr_left
theorem fuzzy_congr_right {x y₁ y₂ : PGame} (hy : y₁ ≈ y₂) : x ‖ y₁ ↔ x ‖ y₂ :=
fuzzy_congr equiv_rfl hy
#align pgame.fuzzy_congr_right SetTheory.PGame.fuzzy_congr_right
@[trans]
theorem fuzzy_of_fuzzy_of_equiv {x y z : PGame} (h₁ : x ‖ y) (h₂ : y ≈ z) : x ‖ z :=
(fuzzy_congr_right h₂).1 h₁
#align pgame.fuzzy_of_fuzzy_of_equiv SetTheory.PGame.fuzzy_of_fuzzy_of_equiv
@[trans]
theorem fuzzy_of_equiv_of_fuzzy {x y z : PGame} (h₁ : x ≈ y) (h₂ : y ‖ z) : x ‖ z :=
(fuzzy_congr_left h₁).2 h₂
#align pgame.fuzzy_of_equiv_of_fuzzy SetTheory.PGame.fuzzy_of_equiv_of_fuzzy
| Mathlib/SetTheory/Game/PGame.lean | 1,051 | 1,065 | theorem lt_or_equiv_or_gt_or_fuzzy (x y : PGame) : x < y ∨ (x ≈ y) ∨ y < x ∨ x ‖ y := by |
cases' le_or_gf x y with h₁ h₁ <;> cases' le_or_gf y x with h₂ h₂
· right
left
exact ⟨h₁, h₂⟩
· left
exact ⟨h₁, h₂⟩
· right
right
left
exact ⟨h₂, h₁⟩
· right
right
right
exact ⟨h₂, h₁⟩
|
import Mathlib.Analysis.Convex.Slope
import Mathlib.Analysis.SpecialFunctions.Pow.Real
import Mathlib.Tactic.LinearCombination
#align_import analysis.convex.specific_functions.basic from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
open Real Set NNReal
theorem strictConvexOn_exp : StrictConvexOn ℝ univ exp := by
apply strictConvexOn_of_slope_strict_mono_adjacent convex_univ
rintro x y z - - hxy hyz
trans exp y
· have h1 : 0 < y - x := by linarith
have h2 : x - y < 0 := by linarith
rw [div_lt_iff h1]
calc
exp y - exp x = exp y - exp y * exp (x - y) := by rw [← exp_add]; ring_nf
_ = exp y * (1 - exp (x - y)) := by ring
_ < exp y * -(x - y) := by gcongr; linarith [add_one_lt_exp h2.ne]
_ = exp y * (y - x) := by ring
· have h1 : 0 < z - y := by linarith
rw [lt_div_iff h1]
calc
exp y * (z - y) < exp y * (exp (z - y) - 1) := by
gcongr _ * ?_
linarith [add_one_lt_exp h1.ne']
_ = exp (z - y) * exp y - exp y := by ring
_ ≤ exp z - exp y := by rw [← exp_add]; ring_nf; rfl
#align strict_convex_on_exp strictConvexOn_exp
theorem convexOn_exp : ConvexOn ℝ univ exp :=
strictConvexOn_exp.convexOn
#align convex_on_exp convexOn_exp
theorem strictConcaveOn_log_Ioi : StrictConcaveOn ℝ (Ioi 0) log := by
apply strictConcaveOn_of_slope_strict_anti_adjacent (convex_Ioi (0 : ℝ))
intro x y z (hx : 0 < x) (hz : 0 < z) hxy hyz
have hy : 0 < y := hx.trans hxy
trans y⁻¹
· have h : 0 < z - y := by linarith
rw [div_lt_iff h]
have hyz' : 0 < z / y := by positivity
have hyz'' : z / y ≠ 1 := by
contrapose! h
rw [div_eq_one_iff_eq hy.ne'] at h
simp [h]
calc
log z - log y = log (z / y) := by rw [← log_div hz.ne' hy.ne']
_ < z / y - 1 := log_lt_sub_one_of_pos hyz' hyz''
_ = y⁻¹ * (z - y) := by field_simp
· have h : 0 < y - x := by linarith
rw [lt_div_iff h]
have hxy' : 0 < x / y := by positivity
have hxy'' : x / y ≠ 1 := by
contrapose! h
rw [div_eq_one_iff_eq hy.ne'] at h
simp [h]
calc
y⁻¹ * (y - x) = 1 - x / y := by field_simp
_ < -log (x / y) := by linarith [log_lt_sub_one_of_pos hxy' hxy'']
_ = -(log x - log y) := by rw [log_div hx.ne' hy.ne']
_ = log y - log x := by ring
#align strict_concave_on_log_Ioi strictConcaveOn_log_Ioi
theorem one_add_mul_self_lt_rpow_one_add {s : ℝ} (hs : -1 ≤ s) (hs' : s ≠ 0) {p : ℝ} (hp : 1 < p) :
1 + p * s < (1 + s) ^ p := by
have hp' : 0 < p := zero_lt_one.trans hp
rcases eq_or_lt_of_le hs with rfl | hs
· rwa [add_right_neg, zero_rpow hp'.ne', mul_neg_one, add_neg_lt_iff_lt_add, zero_add]
have hs1 : 0 < 1 + s := neg_lt_iff_pos_add'.mp hs
rcases le_or_lt (1 + p * s) 0 with hs2 | hs2
· exact hs2.trans_lt (rpow_pos_of_pos hs1 _)
have hs3 : 1 + s ≠ 1 := hs' ∘ add_right_eq_self.mp
have hs4 : 1 + p * s ≠ 1 := by
contrapose! hs'; rwa [add_right_eq_self, mul_eq_zero, eq_false_intro hp'.ne', false_or] at hs'
rw [rpow_def_of_pos hs1, ← exp_log hs2]
apply exp_strictMono
cases' lt_or_gt_of_ne hs' with hs' hs'
· rw [← div_lt_iff hp', ← div_lt_div_right_of_neg hs']
convert strictConcaveOn_log_Ioi.secant_strict_mono (zero_lt_one' ℝ) hs2 hs1 hs4 hs3 _ using 1
· rw [add_sub_cancel_left, log_one, sub_zero]
· rw [add_sub_cancel_left, div_div, log_one, sub_zero]
· apply add_lt_add_left (mul_lt_of_one_lt_left hs' hp)
· rw [← div_lt_iff hp', ← div_lt_div_right hs']
convert strictConcaveOn_log_Ioi.secant_strict_mono (zero_lt_one' ℝ) hs1 hs2 hs3 hs4 _ using 1
· rw [add_sub_cancel_left, div_div, log_one, sub_zero]
· rw [add_sub_cancel_left, log_one, sub_zero]
· apply add_lt_add_left (lt_mul_of_one_lt_left hs' hp)
#align one_add_mul_self_lt_rpow_one_add one_add_mul_self_lt_rpow_one_add
theorem one_add_mul_self_le_rpow_one_add {s : ℝ} (hs : -1 ≤ s) {p : ℝ} (hp : 1 ≤ p) :
1 + p * s ≤ (1 + s) ^ p := by
rcases eq_or_lt_of_le hp with (rfl | hp)
· simp
by_cases hs' : s = 0
· simp [hs']
exact (one_add_mul_self_lt_rpow_one_add hs hs' hp).le
#align one_add_mul_self_le_rpow_one_add one_add_mul_self_le_rpow_one_add
theorem rpow_one_add_lt_one_add_mul_self {s : ℝ} (hs : -1 ≤ s) (hs' : s ≠ 0) {p : ℝ} (hp1 : 0 < p)
(hp2 : p < 1) : (1 + s) ^ p < 1 + p * s := by
rcases eq_or_lt_of_le hs with rfl | hs
· rwa [add_right_neg, zero_rpow hp1.ne', mul_neg_one, lt_add_neg_iff_add_lt, zero_add]
have hs1 : 0 < 1 + s := neg_lt_iff_pos_add'.mp hs
have hs2 : 0 < 1 + p * s := by
rw [← neg_lt_iff_pos_add']
rcases lt_or_gt_of_ne hs' with h | h
· exact hs.trans (lt_mul_of_lt_one_left h hp2)
· exact neg_one_lt_zero.trans (mul_pos hp1 h)
have hs3 : 1 + s ≠ 1 := hs' ∘ add_right_eq_self.mp
have hs4 : 1 + p * s ≠ 1 := by
contrapose! hs'; rwa [add_right_eq_self, mul_eq_zero, eq_false_intro hp1.ne', false_or] at hs'
rw [rpow_def_of_pos hs1, ← exp_log hs2]
apply exp_strictMono
cases' lt_or_gt_of_ne hs' with hs' hs'
· rw [← lt_div_iff hp1, ← div_lt_div_right_of_neg hs']
convert strictConcaveOn_log_Ioi.secant_strict_mono (zero_lt_one' ℝ) hs1 hs2 hs3 hs4 _ using 1
· rw [add_sub_cancel_left, div_div, log_one, sub_zero]
· rw [add_sub_cancel_left, log_one, sub_zero]
· apply add_lt_add_left (lt_mul_of_lt_one_left hs' hp2)
· rw [← lt_div_iff hp1, ← div_lt_div_right hs']
convert strictConcaveOn_log_Ioi.secant_strict_mono (zero_lt_one' ℝ) hs2 hs1 hs4 hs3 _ using 1
· rw [add_sub_cancel_left, log_one, sub_zero]
· rw [add_sub_cancel_left, div_div, log_one, sub_zero]
· apply add_lt_add_left (mul_lt_of_lt_one_left hs' hp2)
theorem rpow_one_add_le_one_add_mul_self {s : ℝ} (hs : -1 ≤ s) {p : ℝ} (hp1 : 0 ≤ p) (hp2 : p ≤ 1) :
(1 + s) ^ p ≤ 1 + p * s := by
rcases eq_or_lt_of_le hp1 with (rfl | hp1)
· simp
rcases eq_or_lt_of_le hp2 with (rfl | hp2)
· simp
by_cases hs' : s = 0
· simp [hs']
exact (rpow_one_add_lt_one_add_mul_self hs hs' hp1 hp2).le
theorem strictConvexOn_rpow {p : ℝ} (hp : 1 < p) : StrictConvexOn ℝ (Ici 0) fun x : ℝ ↦ x ^ p := by
apply strictConvexOn_of_slope_strict_mono_adjacent (convex_Ici (0 : ℝ))
intro x y z (hx : 0 ≤ x) (hz : 0 ≤ z) hxy hyz
have hy : 0 < y := hx.trans_lt hxy
have hy' : 0 < y ^ p := rpow_pos_of_pos hy _
trans p * y ^ (p - 1)
· have q : 0 < y - x := by rwa [sub_pos]
rw [div_lt_iff q, ← div_lt_div_right hy', _root_.sub_div, div_self hy'.ne', ← div_rpow hx hy.le,
sub_lt_comm, ← add_sub_cancel_right (x / y) 1, add_comm, add_sub_assoc, ← div_mul_eq_mul_div,
mul_div_assoc, ← rpow_sub hy, sub_sub_cancel_left, rpow_neg_one, mul_assoc, ← div_eq_inv_mul,
sub_eq_add_neg, ← mul_neg, ← neg_div, neg_sub, _root_.sub_div, div_self hy.ne']
apply one_add_mul_self_lt_rpow_one_add _ _ hp
· rw [le_sub_iff_add_le, add_left_neg, div_nonneg_iff]
exact Or.inl ⟨hx, hy.le⟩
· rw [sub_ne_zero]
exact ((div_lt_one hy).mpr hxy).ne
· have q : 0 < z - y := by rwa [sub_pos]
rw [lt_div_iff q, ← div_lt_div_right hy', _root_.sub_div, div_self hy'.ne', ← div_rpow hz hy.le,
lt_sub_iff_add_lt', ← add_sub_cancel_right (z / y) 1, add_comm _ 1, add_sub_assoc,
← div_mul_eq_mul_div, mul_div_assoc, ← rpow_sub hy, sub_sub_cancel_left, rpow_neg_one,
mul_assoc, ← div_eq_inv_mul, _root_.sub_div, div_self hy.ne']
apply one_add_mul_self_lt_rpow_one_add _ _ hp
· rw [le_sub_iff_add_le, add_left_neg, div_nonneg_iff]
exact Or.inl ⟨hz, hy.le⟩
· rw [sub_ne_zero]
exact ((one_lt_div hy).mpr hyz).ne'
#align strict_convex_on_rpow strictConvexOn_rpow
theorem convexOn_rpow {p : ℝ} (hp : 1 ≤ p) : ConvexOn ℝ (Ici 0) fun x : ℝ ↦ x ^ p := by
rcases eq_or_lt_of_le hp with (rfl | hp)
· simpa using convexOn_id (convex_Ici _)
exact (strictConvexOn_rpow hp).convexOn
#align convex_on_rpow convexOn_rpow
| Mathlib/Analysis/Convex/SpecificFunctions/Basic.lean | 212 | 222 | theorem strictConcaveOn_log_Iio : StrictConcaveOn ℝ (Iio 0) log := by |
refine ⟨convex_Iio _, ?_⟩
intro x (hx : x < 0) y (hy : y < 0) hxy a b ha hb hab
have hx' : 0 < -x := by linarith
have hy' : 0 < -y := by linarith
have hxy' : -x ≠ -y := by contrapose! hxy; linarith
calc
a • log x + b • log y = a • log (-x) + b • log (-y) := by simp_rw [log_neg_eq_log]
_ < log (a • -x + b • -y) := strictConcaveOn_log_Ioi.2 hx' hy' hxy' ha hb hab
_ = log (-(a • x + b • y)) := by congr 1; simp only [Algebra.id.smul_eq_mul]; ring
_ = _ := by rw [log_neg_eq_log]
|
import Mathlib.Algebra.Group.Hom.End
import Mathlib.Algebra.Ring.Invertible
import Mathlib.Algebra.SMulWithZero
import Mathlib.Data.Int.Cast.Lemmas
import Mathlib.GroupTheory.GroupAction.Units
#align_import algebra.module.basic from "leanprover-community/mathlib"@"30413fc89f202a090a54d78e540963ed3de0056e"
assert_not_exists Multiset
assert_not_exists Set.indicator
assert_not_exists Pi.single_smul₀
open Function Set
universe u v
variable {α R k S M M₂ M₃ ι : Type*}
@[ext]
class Module (R : Type u) (M : Type v) [Semiring R] [AddCommMonoid M] extends
DistribMulAction R M where
protected add_smul : ∀ (r s : R) (x : M), (r + s) • x = r • x + s • x
protected zero_smul : ∀ x : M, (0 : R) • x = 0
#align module Module
#align module.ext Module.ext
#align module.ext_iff Module.ext_iff
section AddCommMonoid
variable [Semiring R] [AddCommMonoid M] [Module R M] (r s : R) (x y : M)
-- see Note [lower instance priority]
instance (priority := 100) Module.toMulActionWithZero : MulActionWithZero R M :=
{ (inferInstance : MulAction R M) with
smul_zero := smul_zero
zero_smul := Module.zero_smul }
#align module.to_mul_action_with_zero Module.toMulActionWithZero
instance AddCommMonoid.natModule : Module ℕ M where
one_smul := one_nsmul
mul_smul m n a := mul_nsmul' a m n
smul_add n a b := nsmul_add a b n
smul_zero := nsmul_zero
zero_smul := zero_nsmul
add_smul r s x := add_nsmul x r s
#align add_comm_monoid.nat_module AddCommMonoid.natModule
theorem AddMonoid.End.natCast_def (n : ℕ) :
(↑n : AddMonoid.End M) = DistribMulAction.toAddMonoidEnd ℕ M n :=
rfl
#align add_monoid.End.nat_cast_def AddMonoid.End.natCast_def
theorem add_smul : (r + s) • x = r • x + s • x :=
Module.add_smul r s x
#align add_smul add_smul
theorem Convex.combo_self {a b : R} (h : a + b = 1) (x : M) : a • x + b • x = x := by
rw [← add_smul, h, one_smul]
#align convex.combo_self Convex.combo_self
variable (R)
-- Porting note: this is the letter of the mathlib3 version, but not really the spirit
theorem two_smul : (2 : R) • x = x + x := by rw [← one_add_one_eq_two, add_smul, one_smul]
#align two_smul two_smul
set_option linter.deprecated false in
@[deprecated]
theorem two_smul' : (2 : R) • x = bit0 x :=
two_smul R x
#align two_smul' two_smul'
@[simp]
theorem invOf_two_smul_add_invOf_two_smul [Invertible (2 : R)] (x : M) :
(⅟ 2 : R) • x + (⅟ 2 : R) • x = x :=
Convex.combo_self invOf_two_add_invOf_two _
#align inv_of_two_smul_add_inv_of_two_smul invOf_two_smul_add_invOf_two_smul
protected abbrev Function.Injective.module [AddCommMonoid M₂] [SMul R M₂] (f : M₂ →+ M)
(hf : Injective f) (smul : ∀ (c : R) (x), f (c • x) = c • f x) : Module R M₂ :=
{ hf.distribMulAction f smul with
add_smul := fun c₁ c₂ x => hf <| by simp only [smul, f.map_add, add_smul]
zero_smul := fun x => hf <| by simp only [smul, zero_smul, f.map_zero] }
#align function.injective.module Function.Injective.module
protected abbrev Function.Surjective.module [AddCommMonoid M₂] [SMul R M₂] (f : M →+ M₂)
(hf : Surjective f) (smul : ∀ (c : R) (x), f (c • x) = c • f x) : Module R M₂ :=
{ toDistribMulAction := hf.distribMulAction f smul
add_smul := fun c₁ c₂ x => by
rcases hf x with ⟨x, rfl⟩
simp only [add_smul, ← smul, ← f.map_add]
zero_smul := fun x => by
rcases hf x with ⟨x, rfl⟩
rw [← f.map_zero, ← smul, zero_smul] }
#align function.surjective.module Function.Surjective.module
abbrev Function.Surjective.moduleLeft {R S M : Type*} [Semiring R] [AddCommMonoid M] [Module R M]
[Semiring S] [SMul S M] (f : R →+* S) (hf : Function.Surjective f)
(hsmul : ∀ (c) (x : M), f c • x = c • x) : Module S M :=
{ hf.distribMulActionLeft f.toMonoidHom hsmul with
zero_smul := fun x => by rw [← f.map_zero, hsmul, zero_smul]
add_smul := hf.forall₂.mpr fun a b x => by simp only [← f.map_add, hsmul, add_smul] }
#align function.surjective.module_left Function.Surjective.moduleLeft
variable {R} (M)
abbrev Module.compHom [Semiring S] (f : S →+* R) : Module S M :=
{ MulActionWithZero.compHom M f.toMonoidWithZeroHom, DistribMulAction.compHom M (f : S →* R) with
-- Porting note: the `show f (r + s) • x = f r • x + f s • x` wasn't needed in mathlib3.
-- Somehow, now that `SMul` is heterogeneous, it can't unfold earlier fields of a definition for
-- use in later fields. See
-- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Heterogeneous.20scalar.20multiplication
add_smul := fun r s x => show f (r + s) • x = f r • x + f s • x by simp [add_smul] }
#align module.comp_hom Module.compHom
variable (R)
@[simps! apply_apply]
def Module.toAddMonoidEnd : R →+* AddMonoid.End M :=
{ DistribMulAction.toAddMonoidEnd R M with
-- Porting note: the two `show`s weren't needed in mathlib3.
-- Somehow, now that `SMul` is heterogeneous, it can't unfold earlier fields of a definition for
-- use in later fields. See
-- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Heterogeneous.20scalar.20multiplication
map_zero' := AddMonoidHom.ext fun r => show (0:R) • r = 0 by simp
map_add' := fun x y =>
AddMonoidHom.ext fun r => show (x + y) • r = x • r + y • r by simp [add_smul] }
#align module.to_add_monoid_End Module.toAddMonoidEnd
#align module.to_add_monoid_End_apply_apply Module.toAddMonoidEnd_apply_apply
def smulAddHom : R →+ M →+ M :=
(Module.toAddMonoidEnd R M).toAddMonoidHom
#align smul_add_hom smulAddHom
variable {R M}
@[simp]
theorem smulAddHom_apply (r : R) (x : M) : smulAddHom R M r x = r • x :=
rfl
#align smul_add_hom_apply smulAddHom_apply
theorem Module.eq_zero_of_zero_eq_one (zero_eq_one : (0 : R) = 1) : x = 0 := by
rw [← one_smul R x, ← zero_eq_one, zero_smul]
#align module.eq_zero_of_zero_eq_one Module.eq_zero_of_zero_eq_one
@[simp]
| Mathlib/Algebra/Module/Defs.lean | 203 | 204 | theorem smul_add_one_sub_smul {R : Type*} [Ring R] [Module R M] {r : R} {m : M} :
r • m + (1 - r) • m = m := by | rw [← add_smul, add_sub_cancel, one_smul]
|
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
| Mathlib/MeasureTheory/Function/ConditionalExpectation/CondexpL1.lean | 116 | 125 | 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]
|
import Mathlib.RingTheory.Polynomial.Basic
import Mathlib.RingTheory.Ideal.LocalRing
#align_import data.polynomial.expand from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821"
universe u v w
open Polynomial
open Finset
namespace Polynomial
section CommSemiring
variable (R : Type u) [CommSemiring R] {S : Type v} [CommSemiring S] (p q : ℕ)
noncomputable def expand : R[X] →ₐ[R] R[X] :=
{ (eval₂RingHom C (X ^ p) : R[X] →+* R[X]) with commutes' := fun _ => eval₂_C _ _ }
#align polynomial.expand Polynomial.expand
theorem coe_expand : (expand R p : R[X] → R[X]) = eval₂ C (X ^ p) :=
rfl
#align polynomial.coe_expand Polynomial.coe_expand
variable {R}
theorem expand_eq_comp_X_pow {f : R[X]} : expand R p f = f.comp (X ^ p) := rfl
theorem expand_eq_sum {f : R[X]} : expand R p f = f.sum fun e a => C a * (X ^ p) ^ e := by
simp [expand, eval₂]
#align polynomial.expand_eq_sum Polynomial.expand_eq_sum
@[simp]
theorem expand_C (r : R) : expand R p (C r) = C r :=
eval₂_C _ _
set_option linter.uppercaseLean3 false in
#align polynomial.expand_C Polynomial.expand_C
@[simp]
theorem expand_X : expand R p X = X ^ p :=
eval₂_X _ _
set_option linter.uppercaseLean3 false in
#align polynomial.expand_X Polynomial.expand_X
@[simp]
theorem expand_monomial (r : R) : expand R p (monomial q r) = monomial (q * p) r := by
simp_rw [← smul_X_eq_monomial, AlgHom.map_smul, AlgHom.map_pow, expand_X, mul_comm, pow_mul]
#align polynomial.expand_monomial Polynomial.expand_monomial
theorem expand_expand (f : R[X]) : expand R p (expand R q f) = expand R (p * q) f :=
Polynomial.induction_on f (fun r => by simp_rw [expand_C])
(fun f g ihf ihg => by simp_rw [AlgHom.map_add, ihf, ihg]) fun n r _ => by
simp_rw [AlgHom.map_mul, expand_C, AlgHom.map_pow, expand_X, AlgHom.map_pow, expand_X, pow_mul]
#align polynomial.expand_expand Polynomial.expand_expand
theorem expand_mul (f : R[X]) : expand R (p * q) f = expand R p (expand R q f) :=
(expand_expand p q f).symm
#align polynomial.expand_mul Polynomial.expand_mul
@[simp]
theorem expand_zero (f : R[X]) : expand R 0 f = C (eval 1 f) := by simp [expand]
#align polynomial.expand_zero Polynomial.expand_zero
@[simp]
theorem expand_one (f : R[X]) : expand R 1 f = f :=
Polynomial.induction_on f (fun r => by rw [expand_C])
(fun f g ihf ihg => by rw [AlgHom.map_add, ihf, ihg]) fun n r _ => by
rw [AlgHom.map_mul, expand_C, AlgHom.map_pow, expand_X, pow_one]
#align polynomial.expand_one Polynomial.expand_one
theorem expand_pow (f : R[X]) : expand R (p ^ q) f = (expand R p)^[q] f :=
Nat.recOn q (by rw [pow_zero, expand_one, Function.iterate_zero, id]) fun n ih => by
rw [Function.iterate_succ_apply', pow_succ', expand_mul, ih]
#align polynomial.expand_pow Polynomial.expand_pow
theorem derivative_expand (f : R[X]) : Polynomial.derivative (expand R p f) =
expand R p (Polynomial.derivative f) * (p * (X ^ (p - 1) : R[X])) := by
rw [coe_expand, derivative_eval₂_C, derivative_pow, C_eq_natCast, derivative_X, mul_one]
#align polynomial.derivative_expand Polynomial.derivative_expand
theorem coeff_expand {p : ℕ} (hp : 0 < p) (f : R[X]) (n : ℕ) :
(expand R p f).coeff n = if p ∣ n then f.coeff (n / p) else 0 := by
simp only [expand_eq_sum]
simp_rw [coeff_sum, ← pow_mul, C_mul_X_pow_eq_monomial, coeff_monomial, sum]
split_ifs with h
· rw [Finset.sum_eq_single (n / p), Nat.mul_div_cancel' h, if_pos rfl]
· intro b _ hb2
rw [if_neg]
intro hb3
apply hb2
rw [← hb3, Nat.mul_div_cancel_left b hp]
· intro hn
rw [not_mem_support_iff.1 hn]
split_ifs <;> rfl
· rw [Finset.sum_eq_zero]
intro k _
rw [if_neg]
exact fun hkn => h ⟨k, hkn.symm⟩
#align polynomial.coeff_expand Polynomial.coeff_expand
@[simp]
theorem coeff_expand_mul {p : ℕ} (hp : 0 < p) (f : R[X]) (n : ℕ) :
(expand R p f).coeff (n * p) = f.coeff n := by
rw [coeff_expand hp, if_pos (dvd_mul_left _ _), Nat.mul_div_cancel _ hp]
#align polynomial.coeff_expand_mul Polynomial.coeff_expand_mul
@[simp]
theorem coeff_expand_mul' {p : ℕ} (hp : 0 < p) (f : R[X]) (n : ℕ) :
(expand R p f).coeff (p * n) = f.coeff n := by rw [mul_comm, coeff_expand_mul hp]
#align polynomial.coeff_expand_mul' Polynomial.coeff_expand_mul'
theorem expand_injective {n : ℕ} (hn : 0 < n) : Function.Injective (expand R n) := fun g g' H =>
ext fun k => by rw [← coeff_expand_mul hn, H, coeff_expand_mul hn]
#align polynomial.expand_injective Polynomial.expand_injective
theorem expand_inj {p : ℕ} (hp : 0 < p) {f g : R[X]} : expand R p f = expand R p g ↔ f = g :=
(expand_injective hp).eq_iff
#align polynomial.expand_inj Polynomial.expand_inj
theorem expand_eq_zero {p : ℕ} (hp : 0 < p) {f : R[X]} : expand R p f = 0 ↔ f = 0 :=
(expand_injective hp).eq_iff' (map_zero _)
#align polynomial.expand_eq_zero Polynomial.expand_eq_zero
theorem expand_ne_zero {p : ℕ} (hp : 0 < p) {f : R[X]} : expand R p f ≠ 0 ↔ f ≠ 0 :=
(expand_eq_zero hp).not
#align polynomial.expand_ne_zero Polynomial.expand_ne_zero
theorem expand_eq_C {p : ℕ} (hp : 0 < p) {f : R[X]} {r : R} : expand R p f = C r ↔ f = C r := by
rw [← expand_C, expand_inj hp, expand_C]
set_option linter.uppercaseLean3 false in
#align polynomial.expand_eq_C Polynomial.expand_eq_C
theorem natDegree_expand (p : ℕ) (f : R[X]) : (expand R p f).natDegree = f.natDegree * p := by
rcases p.eq_zero_or_pos with hp | hp
· rw [hp, coe_expand, pow_zero, mul_zero, ← C_1, eval₂_hom, natDegree_C]
by_cases hf : f = 0
· rw [hf, AlgHom.map_zero, natDegree_zero, zero_mul]
have hf1 : expand R p f ≠ 0 := mt (expand_eq_zero hp).1 hf
rw [← WithBot.coe_eq_coe]
convert (degree_eq_natDegree hf1).symm -- Porting note: was `rw [degree_eq_natDegree hf1]`
symm
refine le_antisymm ((degree_le_iff_coeff_zero _ _).2 fun n hn => ?_) ?_
· rw [coeff_expand hp]
split_ifs with hpn
· rw [coeff_eq_zero_of_natDegree_lt]
contrapose! hn
erw [WithBot.coe_le_coe, ← Nat.div_mul_cancel hpn]
exact Nat.mul_le_mul_right p hn
· rfl
· refine le_degree_of_ne_zero ?_
erw [coeff_expand_mul hp, ← leadingCoeff]
exact mt leadingCoeff_eq_zero.1 hf
#align polynomial.nat_degree_expand Polynomial.natDegree_expand
theorem leadingCoeff_expand {p : ℕ} {f : R[X]} (hp : 0 < p) :
(expand R p f).leadingCoeff = f.leadingCoeff := by
simp_rw [leadingCoeff, natDegree_expand, coeff_expand_mul hp]
theorem monic_expand_iff {p : ℕ} {f : R[X]} (hp : 0 < p) : (expand R p f).Monic ↔ f.Monic := by
simp only [Monic, leadingCoeff_expand hp]
alias ⟨_, Monic.expand⟩ := monic_expand_iff
#align polynomial.monic.expand Polynomial.Monic.expand
| Mathlib/Algebra/Polynomial/Expand.lean | 185 | 191 | theorem map_expand {p : ℕ} {f : R →+* S} {q : R[X]} :
map f (expand R p q) = expand S p (map f q) := by |
by_cases hp : p = 0
· simp [hp]
ext
rw [coeff_map, coeff_expand (Nat.pos_of_ne_zero hp), coeff_expand (Nat.pos_of_ne_zero hp)]
split_ifs <;> simp_all
|
import Mathlib.Data.List.Basic
#align_import data.list.lattice from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734"
open Nat
namespace List
variable {α : Type*} {l l₁ l₂ : List α} {p : α → Prop} {a : α}
variable [DecidableEq α]
section Inter
@[simp]
theorem inter_nil (l : List α) : [] ∩ l = [] :=
rfl
#align list.inter_nil List.inter_nil
@[simp]
| Mathlib/Data/List/Lattice.lean | 134 | 135 | theorem inter_cons_of_mem (l₁ : List α) (h : a ∈ l₂) : (a :: l₁) ∩ l₂ = a :: l₁ ∩ l₂ := by |
simp [Inter.inter, List.inter, h]
|
import Mathlib.Geometry.Euclidean.Angle.Oriented.Affine
import Mathlib.Geometry.Euclidean.Angle.Unoriented.RightAngle
#align_import geometry.euclidean.angle.oriented.right_angle from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
noncomputable section
open scoped EuclideanGeometry
open scoped Real
open scoped RealInnerProductSpace
namespace Orientation
open FiniteDimensional
variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]
variable [hd2 : Fact (finrank ℝ V = 2)] (o : Orientation ℝ V (Fin 2))
theorem oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle x (x + y) = Real.arccos (‖x‖ / ‖x + y‖) := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_add_eq_arccos_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
#align orientation.oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two Orientation.oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two
theorem oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x + y) y = Real.arccos (‖y‖ / ‖x + y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two h
#align orientation.oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two Orientation.oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two
theorem oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle x (x + y) = Real.arcsin (‖y‖ / ‖x + y‖) := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_add_eq_arcsin_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
#align orientation.oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two Orientation.oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two
theorem oangle_add_left_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x + y) y = Real.arcsin (‖x‖ / ‖x + y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two h
#align orientation.oangle_add_left_eq_arcsin_of_oangle_eq_pi_div_two Orientation.oangle_add_left_eq_arcsin_of_oangle_eq_pi_div_two
theorem oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle x (x + y) = Real.arctan (‖y‖ / ‖x‖) := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_add_eq_arctan_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h) (o.left_ne_zero_of_oangle_eq_pi_div_two h)]
#align orientation.oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two Orientation.oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two
theorem oangle_add_left_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x + y) y = Real.arctan (‖x‖ / ‖y‖) := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two h
#align orientation.oangle_add_left_eq_arctan_of_oangle_eq_pi_div_two Orientation.oangle_add_left_eq_arctan_of_oangle_eq_pi_div_two
theorem cos_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.cos (o.oangle x (x + y)) = ‖x‖ / ‖x + y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.cos_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
#align orientation.cos_oangle_add_right_of_oangle_eq_pi_div_two Orientation.cos_oangle_add_right_of_oangle_eq_pi_div_two
theorem cos_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.cos (o.oangle (x + y) y) = ‖y‖ / ‖x + y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).cos_oangle_add_right_of_oangle_eq_pi_div_two h
#align orientation.cos_oangle_add_left_of_oangle_eq_pi_div_two Orientation.cos_oangle_add_left_of_oangle_eq_pi_div_two
theorem sin_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.sin (o.oangle x (x + y)) = ‖y‖ / ‖x + y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.sin_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
#align orientation.sin_oangle_add_right_of_oangle_eq_pi_div_two Orientation.sin_oangle_add_right_of_oangle_eq_pi_div_two
theorem sin_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.sin (o.oangle (x + y) y) = ‖x‖ / ‖x + y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).sin_oangle_add_right_of_oangle_eq_pi_div_two h
#align orientation.sin_oangle_add_left_of_oangle_eq_pi_div_two Orientation.sin_oangle_add_left_of_oangle_eq_pi_div_two
theorem tan_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.tan (o.oangle x (x + y)) = ‖y‖ / ‖x‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.tan_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
#align orientation.tan_oangle_add_right_of_oangle_eq_pi_div_two Orientation.tan_oangle_add_right_of_oangle_eq_pi_div_two
theorem tan_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
Real.Angle.tan (o.oangle (x + y) y) = ‖x‖ / ‖y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).tan_oangle_add_right_of_oangle_eq_pi_div_two h
#align orientation.tan_oangle_add_left_of_oangle_eq_pi_div_two Orientation.tan_oangle_add_left_of_oangle_eq_pi_div_two
theorem cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle x (x + y)) * ‖x + y‖ = ‖x‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.cos_angle_add_mul_norm_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
#align orientation.cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two Orientation.cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two
theorem cos_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle (x + y) y) * ‖x + y‖ = ‖y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two h
#align orientation.cos_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two Orientation.cos_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two
theorem sin_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle x (x + y)) * ‖x + y‖ = ‖y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.sin_angle_add_mul_norm_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
#align orientation.sin_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two Orientation.sin_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two
theorem sin_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle (x + y) y) * ‖x + y‖ = ‖x‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).sin_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two h
#align orientation.sin_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two Orientation.sin_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two
theorem tan_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle x (x + y)) * ‖x‖ = ‖y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.tan_angle_add_mul_norm_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
#align orientation.tan_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two Orientation.tan_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two
theorem tan_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle (x + y) y) * ‖y‖ = ‖x‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).tan_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two h
#align orientation.tan_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two Orientation.tan_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two
theorem norm_div_cos_oangle_add_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.cos (o.oangle x (x + y)) = ‖x + y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe,
InnerProductGeometry.norm_div_cos_angle_add_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))]
#align orientation.norm_div_cos_oangle_add_right_of_oangle_eq_pi_div_two Orientation.norm_div_cos_oangle_add_right_of_oangle_eq_pi_div_two
theorem norm_div_cos_oangle_add_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.cos (o.oangle (x + y) y) = ‖x + y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).norm_div_cos_oangle_add_right_of_oangle_eq_pi_div_two h
#align orientation.norm_div_cos_oangle_add_left_of_oangle_eq_pi_div_two Orientation.norm_div_cos_oangle_add_left_of_oangle_eq_pi_div_two
theorem norm_div_sin_oangle_add_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.sin (o.oangle x (x + y)) = ‖x + y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe,
InnerProductGeometry.norm_div_sin_angle_add_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inr (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
#align orientation.norm_div_sin_oangle_add_right_of_oangle_eq_pi_div_two Orientation.norm_div_sin_oangle_add_right_of_oangle_eq_pi_div_two
theorem norm_div_sin_oangle_add_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.sin (o.oangle (x + y) y) = ‖x + y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).norm_div_sin_oangle_add_right_of_oangle_eq_pi_div_two h
#align orientation.norm_div_sin_oangle_add_left_of_oangle_eq_pi_div_two Orientation.norm_div_sin_oangle_add_left_of_oangle_eq_pi_div_two
theorem norm_div_tan_oangle_add_right_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖y‖ / Real.Angle.tan (o.oangle x (x + y)) = ‖x‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by
rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe,
InnerProductGeometry.norm_div_tan_angle_add_of_inner_eq_zero
(o.inner_eq_zero_of_oangle_eq_pi_div_two h)
(Or.inr (o.right_ne_zero_of_oangle_eq_pi_div_two h))]
#align orientation.norm_div_tan_oangle_add_right_of_oangle_eq_pi_div_two Orientation.norm_div_tan_oangle_add_right_of_oangle_eq_pi_div_two
theorem norm_div_tan_oangle_add_left_of_oangle_eq_pi_div_two {x y : V}
(h : o.oangle x y = ↑(π / 2)) : ‖x‖ / Real.Angle.tan (o.oangle (x + y) y) = ‖y‖ := by
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
rw [add_comm]
exact (-o).norm_div_tan_oangle_add_right_of_oangle_eq_pi_div_two h
#align orientation.norm_div_tan_oangle_add_left_of_oangle_eq_pi_div_two Orientation.norm_div_tan_oangle_add_left_of_oangle_eq_pi_div_two
theorem oangle_sub_right_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle y (y - x) = Real.arccos (‖y‖ / ‖y - x‖) := by
have hs : (o.oangle y (y - x)).sign = 1 := by
rw [oangle_sign_sub_right_swap, h, Real.Angle.sign_coe_pi_div_two]
rw [o.oangle_eq_angle_of_sign_eq_one hs,
InnerProductGeometry.angle_sub_eq_arccos_of_inner_eq_zero
(o.inner_rev_eq_zero_of_oangle_eq_pi_div_two h)]
#align orientation.oangle_sub_right_eq_arccos_of_oangle_eq_pi_div_two Orientation.oangle_sub_right_eq_arccos_of_oangle_eq_pi_div_two
| Mathlib/Geometry/Euclidean/Angle/Oriented/RightAngle.lean | 277 | 280 | theorem oangle_sub_left_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) :
o.oangle (x - y) x = Real.arccos (‖x‖ / ‖x - y‖) := by |
rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢
exact (-o).oangle_sub_right_eq_arccos_of_oangle_eq_pi_div_two h
|
import Mathlib.FieldTheory.RatFunc.Defs
import Mathlib.RingTheory.EuclideanDomain
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Polynomial.Content
#align_import field_theory.ratfunc from "leanprover-community/mathlib"@"bf9bbbcf0c1c1ead18280b0d010e417b10abb1b6"
universe u v
noncomputable section
open scoped Classical
open scoped nonZeroDivisors Polynomial
variable {K : Type u}
namespace RatFunc
section Field
variable [CommRing K]
protected irreducible_def zero : RatFunc K :=
⟨0⟩
#align ratfunc.zero RatFunc.zero
instance : Zero (RatFunc K) :=
⟨RatFunc.zero⟩
-- Porting note: added `OfNat.ofNat`. using `simp?` produces `simp only [zero_def]`
-- that does not close the goal
theorem ofFractionRing_zero : (ofFractionRing 0 : RatFunc K) = 0 := by
simp only [Zero.zero, OfNat.ofNat, RatFunc.zero]
#align ratfunc.of_fraction_ring_zero RatFunc.ofFractionRing_zero
protected irreducible_def add : RatFunc K → RatFunc K → RatFunc K
| ⟨p⟩, ⟨q⟩ => ⟨p + q⟩
#align ratfunc.add RatFunc.add
instance : Add (RatFunc K) :=
⟨RatFunc.add⟩
-- Porting note: added `HAdd.hAdd`. using `simp?` produces `simp only [add_def]`
-- that does not close the goal
theorem ofFractionRing_add (p q : FractionRing K[X]) :
ofFractionRing (p + q) = ofFractionRing p + ofFractionRing q := by
simp only [HAdd.hAdd, Add.add, RatFunc.add]
#align ratfunc.of_fraction_ring_add RatFunc.ofFractionRing_add
protected irreducible_def sub : RatFunc K → RatFunc K → RatFunc K
| ⟨p⟩, ⟨q⟩ => ⟨p - q⟩
#align ratfunc.sub RatFunc.sub
instance : Sub (RatFunc K) :=
⟨RatFunc.sub⟩
-- Porting note: added `HSub.hSub`. using `simp?` produces `simp only [sub_def]`
-- that does not close the goal
| Mathlib/FieldTheory/RatFunc/Basic.lean | 104 | 106 | theorem ofFractionRing_sub (p q : FractionRing K[X]) :
ofFractionRing (p - q) = ofFractionRing p - ofFractionRing q := by |
simp only [Sub.sub, HSub.hSub, RatFunc.sub]
|
import Mathlib.Algebra.Polynomial.Roots
import Mathlib.Analysis.Asymptotics.AsymptoticEquivalent
import Mathlib.Analysis.Asymptotics.SpecificAsymptotics
#align_import analysis.special_functions.polynomials from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
open Filter Finset Asymptotics
open Asymptotics Polynomial Topology
namespace Polynomial
variable {𝕜 : Type*} [NormedLinearOrderedField 𝕜] (P Q : 𝕜[X])
theorem eventually_no_roots (hP : P ≠ 0) : ∀ᶠ x in atTop, ¬P.IsRoot x :=
atTop_le_cofinite <| (finite_setOf_isRoot hP).compl_mem_cofinite
#align polynomial.eventually_no_roots Polynomial.eventually_no_roots
variable [OrderTopology 𝕜]
section PolynomialAtTop
theorem isEquivalent_atTop_lead :
(fun x => eval x P) ~[atTop] fun x => P.leadingCoeff * x ^ P.natDegree := by
by_cases h : P = 0
· simp [h, IsEquivalent.refl]
· simp only [Polynomial.eval_eq_sum_range, sum_range_succ]
exact
IsLittleO.add_isEquivalent
(IsLittleO.sum fun i hi =>
IsLittleO.const_mul_left
((IsLittleO.const_mul_right fun hz => h <| leadingCoeff_eq_zero.mp hz) <|
isLittleO_pow_pow_atTop_of_lt (mem_range.mp hi))
_)
IsEquivalent.refl
#align polynomial.is_equivalent_at_top_lead Polynomial.isEquivalent_atTop_lead
theorem tendsto_atTop_of_leadingCoeff_nonneg (hdeg : 0 < P.degree) (hnng : 0 ≤ P.leadingCoeff) :
Tendsto (fun x => eval x P) atTop atTop :=
P.isEquivalent_atTop_lead.symm.tendsto_atTop <|
tendsto_const_mul_pow_atTop (natDegree_pos_iff_degree_pos.2 hdeg).ne' <|
hnng.lt_of_ne' <| leadingCoeff_ne_zero.mpr <| ne_zero_of_degree_gt hdeg
#align polynomial.tendsto_at_top_of_leading_coeff_nonneg Polynomial.tendsto_atTop_of_leadingCoeff_nonneg
theorem tendsto_atTop_iff_leadingCoeff_nonneg :
Tendsto (fun x => eval x P) atTop atTop ↔ 0 < P.degree ∧ 0 ≤ P.leadingCoeff := by
refine ⟨fun h => ?_, fun h => tendsto_atTop_of_leadingCoeff_nonneg P h.1 h.2⟩
have : Tendsto (fun x => P.leadingCoeff * x ^ P.natDegree) atTop atTop :=
(isEquivalent_atTop_lead P).tendsto_atTop h
rw [tendsto_const_mul_pow_atTop_iff, ← pos_iff_ne_zero, natDegree_pos_iff_degree_pos] at this
exact ⟨this.1, this.2.le⟩
#align polynomial.tendsto_at_top_iff_leading_coeff_nonneg Polynomial.tendsto_atTop_iff_leadingCoeff_nonneg
theorem tendsto_atBot_iff_leadingCoeff_nonpos :
Tendsto (fun x => eval x P) atTop atBot ↔ 0 < P.degree ∧ P.leadingCoeff ≤ 0 := by
simp only [← tendsto_neg_atTop_iff, ← eval_neg, tendsto_atTop_iff_leadingCoeff_nonneg,
degree_neg, leadingCoeff_neg, neg_nonneg]
#align polynomial.tendsto_at_bot_iff_leading_coeff_nonpos Polynomial.tendsto_atBot_iff_leadingCoeff_nonpos
theorem tendsto_atBot_of_leadingCoeff_nonpos (hdeg : 0 < P.degree) (hnps : P.leadingCoeff ≤ 0) :
Tendsto (fun x => eval x P) atTop atBot :=
P.tendsto_atBot_iff_leadingCoeff_nonpos.2 ⟨hdeg, hnps⟩
#align polynomial.tendsto_at_bot_of_leading_coeff_nonpos Polynomial.tendsto_atBot_of_leadingCoeff_nonpos
theorem abs_tendsto_atTop (hdeg : 0 < P.degree) :
Tendsto (fun x => abs <| eval x P) atTop atTop := by
rcases le_total 0 P.leadingCoeff with hP | hP
· exact tendsto_abs_atTop_atTop.comp (P.tendsto_atTop_of_leadingCoeff_nonneg hdeg hP)
· exact tendsto_abs_atBot_atTop.comp (P.tendsto_atBot_of_leadingCoeff_nonpos hdeg hP)
#align polynomial.abs_tendsto_at_top Polynomial.abs_tendsto_atTop
theorem abs_isBoundedUnder_iff :
(IsBoundedUnder (· ≤ ·) atTop fun x => |eval x P|) ↔ P.degree ≤ 0 := by
refine ⟨fun h => ?_, fun h => ⟨|P.coeff 0|, eventually_map.mpr (eventually_of_forall
(forall_imp (fun _ => le_of_eq) fun x => congr_arg abs <| _root_.trans (congr_arg (eval x)
(eq_C_of_degree_le_zero h)) eval_C))⟩⟩
contrapose! h
exact not_isBoundedUnder_of_tendsto_atTop (abs_tendsto_atTop P h)
#align polynomial.abs_is_bounded_under_iff Polynomial.abs_isBoundedUnder_iff
theorem abs_tendsto_atTop_iff : Tendsto (fun x => abs <| eval x P) atTop atTop ↔ 0 < P.degree :=
⟨fun h => not_le.mp (mt (abs_isBoundedUnder_iff P).mpr (not_isBoundedUnder_of_tendsto_atTop h)),
abs_tendsto_atTop P⟩
#align polynomial.abs_tendsto_at_top_iff Polynomial.abs_tendsto_atTop_iff
| Mathlib/Analysis/SpecialFunctions/Polynomials.lean | 105 | 117 | theorem tendsto_nhds_iff {c : 𝕜} :
Tendsto (fun x => eval x P) atTop (𝓝 c) ↔ P.leadingCoeff = c ∧ P.degree ≤ 0 := by |
refine ⟨fun h => ?_, fun h => ?_⟩
· have := P.isEquivalent_atTop_lead.tendsto_nhds h
by_cases hP : P.leadingCoeff = 0
· simp only [hP, zero_mul, tendsto_const_nhds_iff] at this
exact ⟨_root_.trans hP this, by simp [leadingCoeff_eq_zero.1 hP]⟩
· rw [tendsto_const_mul_pow_nhds_iff hP, natDegree_eq_zero_iff_degree_le_zero] at this
exact this.symm
· refine P.isEquivalent_atTop_lead.symm.tendsto_nhds ?_
have : P.natDegree = 0 := natDegree_eq_zero_iff_degree_le_zero.2 h.2
simp only [h.1, this, pow_zero, mul_one]
exact tendsto_const_nhds
|
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Localization.Integer
import Mathlib.RingTheory.UniqueFactorizationDomain
#align_import ring_theory.localization.num_denom from "leanprover-community/mathlib"@"831c494092374cfe9f50591ed0ac81a25efc5b86"
variable {R : Type*} [CommRing R] (M : Submonoid R) {S : Type*} [CommRing S]
variable [Algebra R S] {P : Type*} [CommRing P]
namespace IsFractionRing
open IsLocalization
section NumDen
variable (A : Type*) [CommRing A] [IsDomain A] [UniqueFactorizationMonoid A]
variable {K : Type*} [Field K] [Algebra A K] [IsFractionRing A K]
| Mathlib/RingTheory/Localization/NumDen.lean | 37 | 47 | theorem exists_reduced_fraction (x : K) :
∃ (a : A) (b : nonZeroDivisors A), IsRelPrime a b ∧ mk' K a b = x := by |
obtain ⟨⟨b, b_nonzero⟩, a, hab⟩ := exists_integer_multiple (nonZeroDivisors A) x
obtain ⟨a', b', c', no_factor, rfl, rfl⟩ :=
UniqueFactorizationMonoid.exists_reduced_factors' a b
(mem_nonZeroDivisors_iff_ne_zero.mp b_nonzero)
obtain ⟨_, b'_nonzero⟩ := mul_mem_nonZeroDivisors.mp b_nonzero
refine ⟨a', ⟨b', b'_nonzero⟩, no_factor, ?_⟩
refine mul_left_cancel₀ (IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors b_nonzero) ?_
simp only [Subtype.coe_mk, RingHom.map_mul, Algebra.smul_def] at *
erw [← hab, mul_assoc, mk'_spec' _ a' ⟨b', b'_nonzero⟩]
|
import Mathlib.Algebra.Algebra.Equiv
import Mathlib.Algebra.Field.Basic
import Mathlib.Logic.Equiv.Defs
import Mathlib.Logic.Small.Defs
#align_import logic.equiv.transfer_instance from "leanprover-community/mathlib"@"ec1c7d810034d4202b0dd239112d1792be9f6fdc"
universe u v
variable {α : Type u} {β : Type v}
namespace Equiv
section Instances
variable (e : α ≃ β)
@[to_additive (attr := reducible) "Transfer `Zero` across an `Equiv`"]
protected def one [One β] : One α :=
⟨e.symm 1⟩
#align equiv.has_one Equiv.one
#align equiv.has_zero Equiv.zero
@[to_additive]
theorem one_def [One β] :
letI := e.one
1 = e.symm 1 :=
rfl
#align equiv.one_def Equiv.one_def
#align equiv.zero_def Equiv.zero_def
@[to_additive]
noncomputable instance [Small.{v} α] [One α] : One (Shrink.{v} α) :=
(equivShrink α).symm.one
@[to_additive (attr := reducible) "Transfer `Add` across an `Equiv`"]
protected def mul [Mul β] : Mul α :=
⟨fun x y => e.symm (e x * e y)⟩
#align equiv.has_mul Equiv.mul
#align equiv.has_add Equiv.add
@[to_additive]
theorem mul_def [Mul β] (x y : α) :
letI := Equiv.mul e
x * y = e.symm (e x * e y) :=
rfl
#align equiv.mul_def Equiv.mul_def
#align equiv.add_def Equiv.add_def
@[to_additive]
noncomputable instance [Small.{v} α] [Mul α] : Mul (Shrink.{v} α) :=
(equivShrink α).symm.mul
@[to_additive (attr := reducible) "Transfer `Sub` across an `Equiv`"]
protected def div [Div β] : Div α :=
⟨fun x y => e.symm (e x / e y)⟩
#align equiv.has_div Equiv.div
#align equiv.has_sub Equiv.sub
@[to_additive]
theorem div_def [Div β] (x y : α) :
letI := Equiv.div e
x / y = e.symm (e x / e y) :=
rfl
#align equiv.div_def Equiv.div_def
#align equiv.sub_def Equiv.sub_def
@[to_additive]
noncomputable instance [Small.{v} α] [Div α] : Div (Shrink.{v} α) :=
(equivShrink α).symm.div
-- Porting note: this should be called `inv`,
-- but we already have an `Equiv.inv` (which perhaps should move to `Perm.inv`?)
@[to_additive (attr := reducible) "Transfer `Neg` across an `Equiv`"]
protected def Inv [Inv β] : Inv α :=
⟨fun x => e.symm (e x)⁻¹⟩
#align equiv.has_inv Equiv.Inv
#align equiv.has_neg Equiv.Neg
@[to_additive]
theorem inv_def [Inv β] (x : α) :
letI := Equiv.Inv e
x⁻¹ = e.symm (e x)⁻¹ :=
rfl
#align equiv.inv_def Equiv.inv_def
#align equiv.neg_def Equiv.neg_def
@[to_additive]
noncomputable instance [Small.{v} α] [Inv α] : Inv (Shrink.{v} α) :=
(equivShrink α).symm.Inv
protected abbrev smul (R : Type*) [SMul R β] : SMul R α :=
⟨fun r x => e.symm (r • e x)⟩
#align equiv.has_smul Equiv.smul
theorem smul_def {R : Type*} [SMul R β] (r : R) (x : α) :
letI := e.smul R
r • x = e.symm (r • e x) :=
rfl
#align equiv.smul_def Equiv.smul_def
noncomputable instance [Small.{v} α] (R : Type*) [SMul R α] : SMul R (Shrink.{v} α) :=
(equivShrink α).symm.smul R
@[reducible, to_additive existing smul]
protected def pow (N : Type*) [Pow β N] : Pow α N :=
⟨fun x n => e.symm (e x ^ n)⟩
#align equiv.has_pow Equiv.pow
theorem pow_def {N : Type*} [Pow β N] (n : N) (x : α) :
letI := e.pow N
x ^ n = e.symm (e x ^ n) :=
rfl
#align equiv.pow_def Equiv.pow_def
noncomputable instance [Small.{v} α] (N : Type*) [Pow α N] : Pow (Shrink.{v} α) N :=
(equivShrink α).symm.pow N
@[to_additive "An equivalence `e : α ≃ β` gives an additive equivalence `α ≃+ β` where
the additive structure on `α` is the one obtained by transporting an additive structure
on `β` back along `e`."]
def mulEquiv (e : α ≃ β) [Mul β] :
let mul := Equiv.mul e
α ≃* β := by
intros
exact
{ e with
map_mul' := fun x y => by
apply e.symm.injective
simp [mul_def] }
#align equiv.mul_equiv Equiv.mulEquiv
#align equiv.add_equiv Equiv.addEquiv
@[to_additive (attr := simp)]
theorem mulEquiv_apply (e : α ≃ β) [Mul β] (a : α) : (mulEquiv e) a = e a :=
rfl
#align equiv.mul_equiv_apply Equiv.mulEquiv_apply
#align equiv.add_equiv_apply Equiv.addEquiv_apply
@[to_additive]
theorem mulEquiv_symm_apply (e : α ≃ β) [Mul β] (b : β) :
letI := Equiv.mul e
(mulEquiv e).symm b = e.symm b :=
rfl
#align equiv.mul_equiv_symm_apply Equiv.mulEquiv_symm_apply
#align equiv.add_equiv_symm_apply Equiv.addEquiv_symm_apply
@[to_additive "Shrink `α` to a smaller universe preserves addition."]
noncomputable def _root_.Shrink.mulEquiv [Small.{v} α] [Mul α] : Shrink.{v} α ≃* α :=
(equivShrink α).symm.mulEquiv
def ringEquiv (e : α ≃ β) [Add β] [Mul β] : by
let add := Equiv.add e
let mul := Equiv.mul e
exact α ≃+* β := by
intros
exact
{ e with
map_add' := fun x y => by
apply e.symm.injective
simp [add_def]
map_mul' := fun x y => by
apply e.symm.injective
simp [mul_def] }
#align equiv.ring_equiv Equiv.ringEquiv
@[simp]
theorem ringEquiv_apply (e : α ≃ β) [Add β] [Mul β] (a : α) : (ringEquiv e) a = e a :=
rfl
#align equiv.ring_equiv_apply Equiv.ringEquiv_apply
theorem ringEquiv_symm_apply (e : α ≃ β) [Add β] [Mul β] (b : β) : by
letI := Equiv.add e
letI := Equiv.mul e
exact (ringEquiv e).symm b = e.symm b := rfl
#align equiv.ring_equiv_symm_apply Equiv.ringEquiv_symm_apply
variable (α) in
noncomputable def _root_.Shrink.ringEquiv [Small.{v} α] [Ring α] : Shrink.{v} α ≃+* α :=
(equivShrink α).symm.ringEquiv
@[to_additive (attr := reducible) "Transfer `add_semigroup` across an `Equiv`"]
protected def semigroup [Semigroup β] : Semigroup α := by
let mul := e.mul
apply e.injective.semigroup _; intros; exact e.apply_symm_apply _
#align equiv.semigroup Equiv.semigroup
#align equiv.add_semigroup Equiv.addSemigroup
@[to_additive]
noncomputable instance [Small.{v} α] [Semigroup α] : Semigroup (Shrink.{v} α) :=
(equivShrink α).symm.semigroup
protected abbrev semigroupWithZero [SemigroupWithZero β] : SemigroupWithZero α := by
let mul := e.mul
let zero := e.zero
apply e.injective.semigroupWithZero _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.semigroup_with_zero Equiv.semigroupWithZero
@[to_additive]
noncomputable instance [Small.{v} α] [SemigroupWithZero α] : SemigroupWithZero (Shrink.{v} α) :=
(equivShrink α).symm.semigroupWithZero
@[to_additive (attr := reducible) "Transfer `AddCommSemigroup` across an `Equiv`"]
protected def commSemigroup [CommSemigroup β] : CommSemigroup α := by
let mul := e.mul
apply e.injective.commSemigroup _; intros; exact e.apply_symm_apply _
#align equiv.comm_semigroup Equiv.commSemigroup
#align equiv.add_comm_semigroup Equiv.addCommSemigroup
@[to_additive]
noncomputable instance [Small.{v} α] [CommSemigroup α] : CommSemigroup (Shrink.{v} α) :=
(equivShrink α).symm.commSemigroup
protected abbrev mulZeroClass [MulZeroClass β] : MulZeroClass α := by
let zero := e.zero
let mul := e.mul
apply e.injective.mulZeroClass _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.mul_zero_class Equiv.mulZeroClass
noncomputable instance [Small.{v} α] [MulZeroClass α] : MulZeroClass (Shrink.{v} α) :=
(equivShrink α).symm.mulZeroClass
@[to_additive (attr := reducible) "Transfer `AddZeroClass` across an `Equiv`"]
protected def mulOneClass [MulOneClass β] : MulOneClass α := by
let one := e.one
let mul := e.mul
apply e.injective.mulOneClass _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.mul_one_class Equiv.mulOneClass
#align equiv.add_zero_class Equiv.addZeroClass
@[to_additive]
noncomputable instance [Small.{v} α] [MulOneClass α] : MulOneClass (Shrink.{v} α) :=
(equivShrink α).symm.mulOneClass
protected abbrev mulZeroOneClass [MulZeroOneClass β] : MulZeroOneClass α := by
let zero := e.zero
let one := e.one
let mul := e.mul
apply e.injective.mulZeroOneClass _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.mul_zero_one_class Equiv.mulZeroOneClass
noncomputable instance [Small.{v} α] [MulZeroOneClass α] : MulZeroOneClass (Shrink.{v} α) :=
(equivShrink α).symm.mulZeroOneClass
@[to_additive (attr := reducible) "Transfer `AddMonoid` across an `Equiv`"]
protected def monoid [Monoid β] : Monoid α := by
let one := e.one
let mul := e.mul
let pow := e.pow ℕ
apply e.injective.monoid _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.monoid Equiv.monoid
#align equiv.add_monoid Equiv.addMonoid
@[to_additive]
noncomputable instance [Small.{v} α] [Monoid α] : Monoid (Shrink.{v} α) :=
(equivShrink α).symm.monoid
@[to_additive (attr := reducible) "Transfer `AddCommMonoid` across an `Equiv`"]
protected def commMonoid [CommMonoid β] : CommMonoid α := by
let one := e.one
let mul := e.mul
let pow := e.pow ℕ
apply e.injective.commMonoid _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.comm_monoid Equiv.commMonoid
#align equiv.add_comm_monoid Equiv.addCommMonoid
@[to_additive]
noncomputable instance [Small.{v} α] [CommMonoid α] : CommMonoid (Shrink.{v} α) :=
(equivShrink α).symm.commMonoid
@[to_additive (attr := reducible) "Transfer `AddGroup` across an `Equiv`"]
protected def group [Group β] : Group α := by
let one := e.one
let mul := e.mul
let inv := e.Inv
let div := e.div
let npow := e.pow ℕ
let zpow := e.pow ℤ
apply e.injective.group _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.group Equiv.group
#align equiv.add_group Equiv.addGroup
@[to_additive]
noncomputable instance [Small.{v} α] [Group α] : Group (Shrink.{v} α) :=
(equivShrink α).symm.group
@[to_additive (attr := reducible) "Transfer `AddCommGroup` across an `Equiv`"]
protected def commGroup [CommGroup β] : CommGroup α := by
let one := e.one
let mul := e.mul
let inv := e.Inv
let div := e.div
let npow := e.pow ℕ
let zpow := e.pow ℤ
apply e.injective.commGroup _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.comm_group Equiv.commGroup
#align equiv.add_comm_group Equiv.addCommGroup
@[to_additive]
noncomputable instance [Small.{v} α] [CommGroup α] : CommGroup (Shrink.{v} α) :=
(equivShrink α).symm.commGroup
protected abbrev nonUnitalNonAssocSemiring [NonUnitalNonAssocSemiring β] :
NonUnitalNonAssocSemiring α := by
let zero := e.zero
let add := e.add
let mul := e.mul
let nsmul := e.smul ℕ
apply e.injective.nonUnitalNonAssocSemiring _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.non_unital_non_assoc_semiring Equiv.nonUnitalNonAssocSemiring
noncomputable instance [Small.{v} α] [NonUnitalNonAssocSemiring α] :
NonUnitalNonAssocSemiring (Shrink.{v} α) :=
(equivShrink α).symm.nonUnitalNonAssocSemiring
protected abbrev nonUnitalSemiring [NonUnitalSemiring β] : NonUnitalSemiring α := by
let zero := e.zero
let add := e.add
let mul := e.mul
let nsmul := e.smul ℕ
apply e.injective.nonUnitalSemiring _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.non_unital_semiring Equiv.nonUnitalSemiring
noncomputable instance [Small.{v} α] [NonUnitalSemiring α] : NonUnitalSemiring (Shrink.{v} α) :=
(equivShrink α).symm.nonUnitalSemiring
protected abbrev addMonoidWithOne [AddMonoidWithOne β] : AddMonoidWithOne α :=
{ e.addMonoid, e.one with
natCast := fun n => e.symm n
natCast_zero := e.injective (by simp [zero_def])
natCast_succ := fun n => e.injective (by simp [add_def, one_def]) }
#align equiv.add_monoid_with_one Equiv.addMonoidWithOne
noncomputable instance [Small.{v} α] [AddMonoidWithOne α] : AddMonoidWithOne (Shrink.{v} α) :=
(equivShrink α).symm.addMonoidWithOne
protected abbrev addGroupWithOne [AddGroupWithOne β] : AddGroupWithOne α :=
{ e.addMonoidWithOne,
e.addGroup with
intCast := fun n => e.symm n
intCast_ofNat := fun n => by simp only [Int.cast_natCast]; rfl
intCast_negSucc := fun n =>
congr_arg e.symm <| (Int.cast_negSucc _).trans <| congr_arg _ (e.apply_symm_apply _).symm }
#align equiv.add_group_with_one Equiv.addGroupWithOne
noncomputable instance [Small.{v} α] [AddGroupWithOne α] : AddGroupWithOne (Shrink.{v} α) :=
(equivShrink α).symm.addGroupWithOne
protected abbrev nonAssocSemiring [NonAssocSemiring β] : NonAssocSemiring α := by
let mul := e.mul
let add_monoid_with_one := e.addMonoidWithOne
apply e.injective.nonAssocSemiring _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.non_assoc_semiring Equiv.nonAssocSemiring
noncomputable instance [Small.{v} α] [NonAssocSemiring α] : NonAssocSemiring (Shrink.{v} α) :=
(equivShrink α).symm.nonAssocSemiring
protected abbrev semiring [Semiring β] : Semiring α := by
let mul := e.mul
let add_monoid_with_one := e.addMonoidWithOne
let npow := e.pow ℕ
apply e.injective.semiring _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.semiring Equiv.semiring
noncomputable instance [Small.{v} α] [Semiring α] : Semiring (Shrink.{v} α) :=
(equivShrink α).symm.semiring
protected abbrev nonUnitalCommSemiring [NonUnitalCommSemiring β] : NonUnitalCommSemiring α := by
let zero := e.zero
let add := e.add
let mul := e.mul
let nsmul := e.smul ℕ
apply e.injective.nonUnitalCommSemiring _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.non_unital_comm_semiring Equiv.nonUnitalCommSemiring
noncomputable instance [Small.{v} α] [NonUnitalCommSemiring α] :
NonUnitalCommSemiring (Shrink.{v} α) :=
(equivShrink α).symm.nonUnitalCommSemiring
protected abbrev commSemiring [CommSemiring β] : CommSemiring α := by
let mul := e.mul
let add_monoid_with_one := e.addMonoidWithOne
let npow := e.pow ℕ
apply e.injective.commSemiring _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.comm_semiring Equiv.commSemiring
noncomputable instance [Small.{v} α] [CommSemiring α] : CommSemiring (Shrink.{v} α) :=
(equivShrink α).symm.commSemiring
protected abbrev nonUnitalNonAssocRing [NonUnitalNonAssocRing β] : NonUnitalNonAssocRing α := by
let zero := e.zero
let add := e.add
let mul := e.mul
let neg := e.Neg
let sub := e.sub
let nsmul := e.smul ℕ
let zsmul := e.smul ℤ
apply e.injective.nonUnitalNonAssocRing _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.non_unital_non_assoc_ring Equiv.nonUnitalNonAssocRing
noncomputable instance [Small.{v} α] [NonUnitalNonAssocRing α] :
NonUnitalNonAssocRing (Shrink.{v} α) :=
(equivShrink α).symm.nonUnitalNonAssocRing
protected abbrev nonUnitalRing [NonUnitalRing β] : NonUnitalRing α := by
let zero := e.zero
let add := e.add
let mul := e.mul
let neg := e.Neg
let sub := e.sub
let nsmul := e.smul ℕ
let zsmul := e.smul ℤ
apply e.injective.nonUnitalRing _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.non_unital_ring Equiv.nonUnitalRing
noncomputable instance [Small.{v} α] [NonUnitalRing α] : NonUnitalRing (Shrink.{v} α) :=
(equivShrink α).symm.nonUnitalRing
protected abbrev nonAssocRing [NonAssocRing β] : NonAssocRing α := by
let add_group_with_one := e.addGroupWithOne
let mul := e.mul
apply e.injective.nonAssocRing _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.non_assoc_ring Equiv.nonAssocRing
noncomputable instance [Small.{v} α] [NonAssocRing α] : NonAssocRing (Shrink.{v} α) :=
(equivShrink α).symm.nonAssocRing
protected abbrev ring [Ring β] : Ring α := by
let mul := e.mul
let add_group_with_one := e.addGroupWithOne
let npow := e.pow ℕ
apply e.injective.ring _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.ring Equiv.ring
noncomputable instance [Small.{v} α] [Ring α] : Ring (Shrink.{v} α) :=
(equivShrink α).symm.ring
protected abbrev nonUnitalCommRing [NonUnitalCommRing β] : NonUnitalCommRing α := by
let zero := e.zero
let add := e.add
let mul := e.mul
let neg := e.Neg
let sub := e.sub
let nsmul := e.smul ℕ
let zsmul := e.smul ℤ
apply e.injective.nonUnitalCommRing _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.non_unital_comm_ring Equiv.nonUnitalCommRing
noncomputable instance [Small.{v} α] [NonUnitalCommRing α] : NonUnitalCommRing (Shrink.{v} α) :=
(equivShrink α).symm.nonUnitalCommRing
protected abbrev commRing [CommRing β] : CommRing α := by
let mul := e.mul
let add_group_with_one := e.addGroupWithOne
let npow := e.pow ℕ
apply e.injective.commRing _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.comm_ring Equiv.commRing
noncomputable instance [Small.{v} α] [CommRing α] : CommRing (Shrink.{v} α) :=
(equivShrink α).symm.commRing
protected theorem nontrivial [Nontrivial β] : Nontrivial α :=
e.surjective.nontrivial
#align equiv.nontrivial Equiv.nontrivial
noncomputable instance [Small.{v} α] [Nontrivial α] : Nontrivial (Shrink.{v} α) :=
(equivShrink α).symm.nontrivial
protected theorem isDomain [Ring α] [Ring β] [IsDomain β] (e : α ≃+* β) : IsDomain α :=
Function.Injective.isDomain e.toRingHom e.injective
#align equiv.is_domain Equiv.isDomain
noncomputable instance [Small.{v} α] [Ring α] [IsDomain α] : IsDomain (Shrink.{v} α) :=
Equiv.isDomain (Shrink.ringEquiv α)
protected abbrev nnratCast [NNRatCast β] : NNRatCast α where nnratCast q := e.symm q
protected abbrev ratCast [RatCast β] : RatCast α where ratCast n := e.symm n
#align equiv.has_rat_cast Equiv.ratCast
noncomputable instance _root_.Shrink.instNNRatCast [Small.{v} α] [NNRatCast α] :
NNRatCast (Shrink.{v} α) := (equivShrink α).symm.nnratCast
noncomputable instance _root_.Shrink.instRatCast [Small.{v} α] [RatCast α] :
RatCast (Shrink.{v} α) := (equivShrink α).symm.ratCast
protected abbrev divisionRing [DivisionRing β] : DivisionRing α := by
let add_group_with_one := e.addGroupWithOne
let inv := e.Inv
let div := e.div
let mul := e.mul
let npow := e.pow ℕ
let zpow := e.pow ℤ
let nnratCast := e.nnratCast
let ratCast := e.ratCast
let nnqsmul := e.smul ℚ≥0
let qsmul := e.smul ℚ
apply e.injective.divisionRing _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.division_ring Equiv.divisionRing
noncomputable instance [Small.{v} α] [DivisionRing α] : DivisionRing (Shrink.{v} α) :=
(equivShrink α).symm.divisionRing
protected abbrev field [Field β] : Field α := by
let add_group_with_one := e.addGroupWithOne
let neg := e.Neg
let inv := e.Inv
let div := e.div
let mul := e.mul
let npow := e.pow ℕ
let zpow := e.pow ℤ
let nnratCast := e.nnratCast
let ratCast := e.ratCast
let nnqsmul := e.smul ℚ≥0
let qsmul := e.smul ℚ
apply e.injective.field _ <;> intros <;> exact e.apply_symm_apply _
#align equiv.field Equiv.field
noncomputable instance [Small.{v} α] [Field α] : Field (Shrink.{v} α) :=
(equivShrink α).symm.field
section R
variable (R : Type*)
section
variable [Monoid R]
protected abbrev mulAction (e : α ≃ β) [MulAction R β] : MulAction R α :=
{ e.smul R with
one_smul := by simp [smul_def]
mul_smul := by simp [smul_def, mul_smul] }
#align equiv.mul_action Equiv.mulAction
noncomputable instance [Small.{v} α] [MulAction R α] : MulAction R (Shrink.{v} α) :=
(equivShrink α).symm.mulAction R
protected abbrev distribMulAction (e : α ≃ β) [AddCommMonoid β] :
letI := Equiv.addCommMonoid e
∀ [DistribMulAction R β], DistribMulAction R α := by
intros
letI := Equiv.addCommMonoid e
exact
({ Equiv.mulAction R e with
smul_zero := by simp [zero_def, smul_def]
smul_add := by simp [add_def, smul_def, smul_add] } :
DistribMulAction R α)
#align equiv.distrib_mul_action Equiv.distribMulAction
noncomputable instance [Small.{v} α] [AddCommMonoid α] [DistribMulAction R α] :
DistribMulAction R (Shrink.{v} α) :=
(equivShrink α).symm.distribMulAction R
end
section
variable [Semiring R]
protected abbrev module (e : α ≃ β) [AddCommMonoid β] :
let addCommMonoid := Equiv.addCommMonoid e
∀ [Module R β], Module R α := by
intros
exact
({ Equiv.distribMulAction R e with
zero_smul := by simp [smul_def, zero_smul, zero_def]
add_smul := by simp [add_def, smul_def, add_smul] } :
Module R α)
#align equiv.module Equiv.module
noncomputable instance [Small.{v} α] [AddCommMonoid α] [Module R α] : Module R (Shrink.{v} α) :=
(equivShrink α).symm.module R
def linearEquiv (e : α ≃ β) [AddCommMonoid β] [Module R β] : by
let addCommMonoid := Equiv.addCommMonoid e
let module := Equiv.module R e
exact α ≃ₗ[R] β := by
intros
exact
{ Equiv.addEquiv e with
map_smul' := fun r x => by
apply e.symm.injective
simp only [toFun_as_coe, RingHom.id_apply, EmbeddingLike.apply_eq_iff_eq]
exact Iff.mpr (apply_eq_iff_eq_symm_apply _) rfl }
#align equiv.linear_equiv Equiv.linearEquiv
variable (α) in
@[simps!]
noncomputable def _root_.Shrink.linearEquiv [Small.{v} α] [AddCommMonoid α] [Module R α] :
Shrink.{v} α ≃ₗ[R] α :=
Equiv.linearEquiv _ (equivShrink α).symm
end
section
variable [CommSemiring R]
protected abbrev algebra (e : α ≃ β) [Semiring β] :
let semiring := Equiv.semiring e
∀ [Algebra R β], Algebra R α := by
intros
letI : Module R α := e.module R
fapply Algebra.ofModule
· intro r x y
show e.symm (e (e.symm (r • e x)) * e y) = e.symm (r • e.ringEquiv (x * y))
simp only [apply_symm_apply, Algebra.smul_mul_assoc, map_mul, ringEquiv_apply]
· intro r x y
show e.symm (e x * e (e.symm (r • e y))) = e.symm (r • e (e.symm (e x * e y)))
simp only [apply_symm_apply, Algebra.mul_smul_comm]
#align equiv.algebra Equiv.algebra
lemma algebraMap_def (e : α ≃ β) [Semiring β] [Algebra R β] (r : R) :
let semiring := Equiv.semiring e
let algebra := Equiv.algebra R e
(algebraMap R α) r = e.symm ((algebraMap R β) r) := by
intros
simp only [Algebra.algebraMap_eq_smul_one]
show e.symm (r • e 1) = e.symm (r • 1)
simp only [Equiv.one_def, apply_symm_apply]
noncomputable instance [Small.{v} α] [Semiring α] [Algebra R α] :
Algebra R (Shrink.{v} α) :=
(equivShrink α).symm.algebra _
def algEquiv (e : α ≃ β) [Semiring β] [Algebra R β] : by
let semiring := Equiv.semiring e
let algebra := Equiv.algebra R e
exact α ≃ₐ[R] β := by
intros
exact
{ Equiv.ringEquiv e with
commutes' := fun r => by
apply e.symm.injective
simp only [RingEquiv.toEquiv_eq_coe, toFun_as_coe, EquivLike.coe_coe, ringEquiv_apply,
symm_apply_apply, algebraMap_def] }
#align equiv.alg_equiv Equiv.algEquiv
@[simp]
theorem algEquiv_apply (e : α ≃ β) [Semiring β] [Algebra R β] (a : α) : (algEquiv R e) a = e a :=
rfl
| Mathlib/Logic/Equiv/TransferInstance.lean | 728 | 731 | theorem algEquiv_symm_apply (e : α ≃ β) [Semiring β] [Algebra R β] (b : β) : by
letI := Equiv.semiring e
letI := Equiv.algebra R e
exact (algEquiv R e).symm b = e.symm b := by | intros; rfl
|
import Mathlib.RingTheory.Ideal.Operations
#align_import ring_theory.ideal.operations from "leanprover-community/mathlib"@"e7f0ddbf65bd7181a85edb74b64bdc35ba4bdc74"
assert_not_exists Basis -- See `RingTheory.Ideal.Basis`
assert_not_exists Submodule.hasQuotient -- See `RingTheory.Ideal.QuotientOperations`
universe u v w x
open Pointwise
namespace Ideal
section MapAndComap
variable {R : Type u} {S : Type v}
section Semiring
variable {F : Type*} [Semiring R] [Semiring S]
variable [FunLike F R S] [rc : RingHomClass F R S]
variable (f : F)
variable {I J : Ideal R} {K L : Ideal S}
def map (I : Ideal R) : Ideal S :=
span (f '' I)
#align ideal.map Ideal.map
def comap (I : Ideal S) : Ideal R where
carrier := f ⁻¹' I
add_mem' {x y} hx hy := by
simp only [Set.mem_preimage, SetLike.mem_coe, map_add f] at hx hy ⊢
exact add_mem hx hy
zero_mem' := by simp only [Set.mem_preimage, map_zero, SetLike.mem_coe, Submodule.zero_mem]
smul_mem' c x hx := by
simp only [smul_eq_mul, Set.mem_preimage, map_mul, SetLike.mem_coe] at *
exact mul_mem_left I _ hx
#align ideal.comap Ideal.comap
@[simp]
theorem coe_comap (I : Ideal S) : (comap f I : Set R) = f ⁻¹' I := rfl
variable {f}
theorem map_mono (h : I ≤ J) : map f I ≤ map f J :=
span_mono <| Set.image_subset _ h
#align ideal.map_mono Ideal.map_mono
theorem mem_map_of_mem (f : F) {I : Ideal R} {x : R} (h : x ∈ I) : f x ∈ map f I :=
subset_span ⟨x, h, rfl⟩
#align ideal.mem_map_of_mem Ideal.mem_map_of_mem
theorem apply_coe_mem_map (f : F) (I : Ideal R) (x : I) : f x ∈ I.map f :=
mem_map_of_mem f x.2
#align ideal.apply_coe_mem_map Ideal.apply_coe_mem_map
theorem map_le_iff_le_comap : map f I ≤ K ↔ I ≤ comap f K :=
span_le.trans Set.image_subset_iff
#align ideal.map_le_iff_le_comap Ideal.map_le_iff_le_comap
@[simp]
theorem mem_comap {x} : x ∈ comap f K ↔ f x ∈ K :=
Iff.rfl
#align ideal.mem_comap Ideal.mem_comap
theorem comap_mono (h : K ≤ L) : comap f K ≤ comap f L :=
Set.preimage_mono fun _ hx => h hx
#align ideal.comap_mono Ideal.comap_mono
variable (f)
theorem comap_ne_top (hK : K ≠ ⊤) : comap f K ≠ ⊤ :=
(ne_top_iff_one _).2 <| by rw [mem_comap, map_one]; exact (ne_top_iff_one _).1 hK
#align ideal.comap_ne_top Ideal.comap_ne_top
variable {G : Type*} [FunLike G S R] [rcg : RingHomClass G S R]
theorem map_le_comap_of_inv_on (g : G) (I : Ideal R) (hf : Set.LeftInvOn g f I) :
I.map f ≤ I.comap g := by
refine Ideal.span_le.2 ?_
rintro x ⟨x, hx, rfl⟩
rw [SetLike.mem_coe, mem_comap, hf hx]
exact hx
#align ideal.map_le_comap_of_inv_on Ideal.map_le_comap_of_inv_on
theorem comap_le_map_of_inv_on (g : G) (I : Ideal S) (hf : Set.LeftInvOn g f (f ⁻¹' I)) :
I.comap f ≤ I.map g := fun x (hx : f x ∈ I) => hf hx ▸ Ideal.mem_map_of_mem g hx
#align ideal.comap_le_map_of_inv_on Ideal.comap_le_map_of_inv_on
theorem map_le_comap_of_inverse (g : G) (I : Ideal R) (h : Function.LeftInverse g f) :
I.map f ≤ I.comap g :=
map_le_comap_of_inv_on _ _ _ <| h.leftInvOn _
#align ideal.map_le_comap_of_inverse Ideal.map_le_comap_of_inverse
theorem comap_le_map_of_inverse (g : G) (I : Ideal S) (h : Function.LeftInverse g f) :
I.comap f ≤ I.map g :=
comap_le_map_of_inv_on _ _ _ <| h.leftInvOn _
#align ideal.comap_le_map_of_inverse Ideal.comap_le_map_of_inverse
instance IsPrime.comap [hK : K.IsPrime] : (comap f K).IsPrime :=
⟨comap_ne_top _ hK.1, fun {x y} => by simp only [mem_comap, map_mul]; apply hK.2⟩
#align ideal.is_prime.comap Ideal.IsPrime.comap
variable (I J K L)
theorem map_top : map f ⊤ = ⊤ :=
(eq_top_iff_one _).2 <| subset_span ⟨1, trivial, map_one f⟩
#align ideal.map_top Ideal.map_top
theorem gc_map_comap : GaloisConnection (Ideal.map f) (Ideal.comap f) := fun _ _ =>
Ideal.map_le_iff_le_comap
#align ideal.gc_map_comap Ideal.gc_map_comap
@[simp]
theorem comap_id : I.comap (RingHom.id R) = I :=
Ideal.ext fun _ => Iff.rfl
#align ideal.comap_id Ideal.comap_id
@[simp]
theorem map_id : I.map (RingHom.id R) = I :=
(gc_map_comap (RingHom.id R)).l_unique GaloisConnection.id comap_id
#align ideal.map_id Ideal.map_id
theorem comap_comap {T : Type*} [Semiring T] {I : Ideal T} (f : R →+* S) (g : S →+* T) :
(I.comap g).comap f = I.comap (g.comp f) :=
rfl
#align ideal.comap_comap Ideal.comap_comap
theorem map_map {T : Type*} [Semiring T] {I : Ideal R} (f : R →+* S) (g : S →+* T) :
(I.map f).map g = I.map (g.comp f) :=
((gc_map_comap f).compose (gc_map_comap g)).l_unique (gc_map_comap (g.comp f)) fun _ =>
comap_comap _ _
#align ideal.map_map Ideal.map_map
theorem map_span (f : F) (s : Set R) : map f (span s) = span (f '' s) := by
refine (Submodule.span_eq_of_le _ ?_ ?_).symm
· rintro _ ⟨x, hx, rfl⟩; exact mem_map_of_mem f (subset_span hx)
· rw [map_le_iff_le_comap, span_le, coe_comap, ← Set.image_subset_iff]
exact subset_span
#align ideal.map_span Ideal.map_span
variable {f I J K L}
theorem map_le_of_le_comap : I ≤ K.comap f → I.map f ≤ K :=
(gc_map_comap f).l_le
#align ideal.map_le_of_le_comap Ideal.map_le_of_le_comap
theorem le_comap_of_map_le : I.map f ≤ K → I ≤ K.comap f :=
(gc_map_comap f).le_u
#align ideal.le_comap_of_map_le Ideal.le_comap_of_map_le
theorem le_comap_map : I ≤ (I.map f).comap f :=
(gc_map_comap f).le_u_l _
#align ideal.le_comap_map Ideal.le_comap_map
theorem map_comap_le : (K.comap f).map f ≤ K :=
(gc_map_comap f).l_u_le _
#align ideal.map_comap_le Ideal.map_comap_le
@[simp]
theorem comap_top : (⊤ : Ideal S).comap f = ⊤ :=
(gc_map_comap f).u_top
#align ideal.comap_top Ideal.comap_top
@[simp]
theorem comap_eq_top_iff {I : Ideal S} : I.comap f = ⊤ ↔ I = ⊤ :=
⟨fun h => I.eq_top_iff_one.mpr (map_one f ▸ mem_comap.mp ((I.comap f).eq_top_iff_one.mp h)),
fun h => by rw [h, comap_top]⟩
#align ideal.comap_eq_top_iff Ideal.comap_eq_top_iff
@[simp]
theorem map_bot : (⊥ : Ideal R).map f = ⊥ :=
(gc_map_comap f).l_bot
#align ideal.map_bot Ideal.map_bot
variable (f I J K L)
@[simp]
theorem map_comap_map : ((I.map f).comap f).map f = I.map f :=
(gc_map_comap f).l_u_l_eq_l I
#align ideal.map_comap_map Ideal.map_comap_map
@[simp]
theorem comap_map_comap : ((K.comap f).map f).comap f = K.comap f :=
(gc_map_comap f).u_l_u_eq_u K
#align ideal.comap_map_comap Ideal.comap_map_comap
theorem map_sup : (I ⊔ J).map f = I.map f ⊔ J.map f :=
(gc_map_comap f : GaloisConnection (map f) (comap f)).l_sup
#align ideal.map_sup Ideal.map_sup
theorem comap_inf : comap f (K ⊓ L) = comap f K ⊓ comap f L :=
rfl
#align ideal.comap_inf Ideal.comap_inf
variable {ι : Sort*}
theorem map_iSup (K : ι → Ideal R) : (iSup K).map f = ⨆ i, (K i).map f :=
(gc_map_comap f : GaloisConnection (map f) (comap f)).l_iSup
#align ideal.map_supr Ideal.map_iSup
theorem comap_iInf (K : ι → Ideal S) : (iInf K).comap f = ⨅ i, (K i).comap f :=
(gc_map_comap f : GaloisConnection (map f) (comap f)).u_iInf
#align ideal.comap_infi Ideal.comap_iInf
theorem map_sSup (s : Set (Ideal R)) : (sSup s).map f = ⨆ I ∈ s, (I : Ideal R).map f :=
(gc_map_comap f : GaloisConnection (map f) (comap f)).l_sSup
#align ideal.map_Sup Ideal.map_sSup
theorem comap_sInf (s : Set (Ideal S)) : (sInf s).comap f = ⨅ I ∈ s, (I : Ideal S).comap f :=
(gc_map_comap f : GaloisConnection (map f) (comap f)).u_sInf
#align ideal.comap_Inf Ideal.comap_sInf
theorem comap_sInf' (s : Set (Ideal S)) : (sInf s).comap f = ⨅ I ∈ comap f '' s, I :=
_root_.trans (comap_sInf f s) (by rw [iInf_image])
#align ideal.comap_Inf' Ideal.comap_sInf'
theorem comap_isPrime [H : IsPrime K] : IsPrime (comap f K) :=
⟨comap_ne_top f H.ne_top, fun {x y} h => H.mem_or_mem <| by rwa [mem_comap, map_mul] at h⟩
#align ideal.comap_is_prime Ideal.comap_isPrime
variable {I J K L}
theorem map_inf_le : map f (I ⊓ J) ≤ map f I ⊓ map f J :=
(gc_map_comap f : GaloisConnection (map f) (comap f)).monotone_l.map_inf_le _ _
#align ideal.map_inf_le Ideal.map_inf_le
theorem le_comap_sup : comap f K ⊔ comap f L ≤ comap f (K ⊔ L) :=
(gc_map_comap f : GaloisConnection (map f) (comap f)).monotone_u.le_map_sup _ _
#align ideal.le_comap_sup Ideal.le_comap_sup
-- TODO: Should these be simp lemmas?
theorem _root_.element_smul_restrictScalars {R S M}
[CommSemiring R] [CommSemiring S] [Algebra R S] [AddCommMonoid M]
[Module R M] [Module S M] [IsScalarTower R S M] (r : R) (N : Submodule S M) :
(algebraMap R S r • N).restrictScalars R = r • N.restrictScalars R :=
SetLike.coe_injective (congrArg (· '' _) (funext (algebraMap_smul S r)))
theorem smul_restrictScalars {R S M} [CommSemiring R] [CommSemiring S]
[Algebra R S] [AddCommMonoid M] [Module R M] [Module S M]
[IsScalarTower R S M] (I : Ideal R) (N : Submodule S M) :
(I.map (algebraMap R S) • N).restrictScalars R = I • N.restrictScalars R := by
simp_rw [map, Submodule.span_smul_eq, ← Submodule.coe_set_smul,
Submodule.set_smul_eq_iSup, ← element_smul_restrictScalars, iSup_image]
exact (_root_.map_iSup₂ (Submodule.restrictScalarsLatticeHom R S M) _)
@[simp]
theorem smul_top_eq_map {R S : Type*} [CommSemiring R] [CommSemiring S] [Algebra R S]
(I : Ideal R) : I • (⊤ : Submodule R S) = (I.map (algebraMap R S)).restrictScalars R :=
Eq.trans (smul_restrictScalars I (⊤ : Ideal S)).symm <|
congrArg _ <| Eq.trans (Ideal.smul_eq_mul _ _) (Ideal.mul_top _)
#align ideal.smul_top_eq_map Ideal.smul_top_eq_map
@[simp]
theorem coe_restrictScalars {R S : Type*} [CommSemiring R] [Semiring S] [Algebra R S]
(I : Ideal S) : (I.restrictScalars R : Set S) = ↑I :=
rfl
#align ideal.coe_restrict_scalars Ideal.coe_restrictScalars
@[simp]
theorem restrictScalars_mul {R S : Type*} [CommSemiring R] [CommSemiring S] [Algebra R S]
(I J : Ideal S) : (I * J).restrictScalars R = I.restrictScalars R * J.restrictScalars R :=
le_antisymm
(fun _ hx =>
Submodule.mul_induction_on hx (fun _ hx _ hy => Submodule.mul_mem_mul hx hy) fun _ _ =>
Submodule.add_mem _)
(Submodule.mul_le.mpr fun _ hx _ hy => Ideal.mul_mem_mul hx hy)
#align ideal.restrict_scalars_mul Ideal.restrictScalars_mul
@[simp]
| Mathlib/RingTheory/Ideal/Maps.lean | 372 | 375 | theorem map_of_equiv (I : Ideal R) (f : R ≃+* S) :
(I.map (f : R →+* S)).map (f.symm : S →+* R) = I := by |
rw [← RingEquiv.toRingHom_eq_coe, ← RingEquiv.toRingHom_eq_coe, map_map,
RingEquiv.toRingHom_eq_coe, RingEquiv.toRingHom_eq_coe, RingEquiv.symm_comp, map_id]
|
import Mathlib.Algebra.Group.Support
import Mathlib.Data.Int.Cast.Field
import Mathlib.Data.Int.Cast.Lemmas
#align_import data.int.char_zero from "leanprover-community/mathlib"@"29cb56a7b35f72758b05a30490e1f10bd62c35c1"
open Nat Set
variable {α β : Type*}
namespace Int
@[simp, norm_cast]
theorem cast_div_charZero {k : Type*} [DivisionRing k] [CharZero k] {m n : ℤ} (n_dvd : n ∣ m) :
((m / n : ℤ) : k) = m / n := by
rcases eq_or_ne n 0 with (rfl | hn)
· simp [Int.ediv_zero]
· exact cast_div n_dvd (cast_ne_zero.mpr hn)
#align int.cast_div_char_zero Int.cast_div_charZero
-- Necessary for confluence with `ofNat_ediv` and `cast_div_charZero`.
@[simp, norm_cast]
| Mathlib/Data/Int/CharZero.lean | 33 | 35 | theorem cast_div_ofNat_charZero {k : Type*} [DivisionRing k] [CharZero k] {m n : ℕ}
(n_dvd : n ∣ m) : (((m : ℤ) / (n : ℤ) : ℤ) : k) = m / n := by |
rw [cast_div_charZero (Int.ofNat_dvd.mpr n_dvd), cast_natCast, cast_natCast]
|
import Mathlib.Topology.Order.Basic
import Mathlib.Data.Set.Pointwise.Basic
open Set Filter TopologicalSpace Topology Function
open OrderDual (toDual ofDual)
variable {α β γ : Type*}
section LinearOrder
variable [TopologicalSpace α] [LinearOrder α]
section OrderTopology
variable [OrderTopology α]
open List in
theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) :
TFAE [s ∈ 𝓝[>] a,
s ∈ 𝓝[Ioc a b] a,
s ∈ 𝓝[Ioo a b] a,
∃ u ∈ Ioc a b, Ioo a u ⊆ s,
∃ u ∈ Ioi a, Ioo a u ⊆ s] := by
tfae_have 1 ↔ 2
· rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab]
tfae_have 1 ↔ 3
· rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab]
tfae_have 4 → 5
· exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩
tfae_have 5 → 1
· rintro ⟨u, hau, hu⟩
exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu
tfae_have 1 → 4
· intro h
rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩
rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩
exact ⟨u, au, fun x hx => hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, hx.1⟩⟩
tfae_finish
#align tfae_mem_nhds_within_Ioi TFAE_mem_nhdsWithin_Ioi
theorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : Set α} (hu' : a < u') :
s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioc a u', Ioo a u ⊆ s :=
(TFAE_mem_nhdsWithin_Ioi hu' s).out 0 3
#align mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset
theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : Set α} (hu' : a < u') :
s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s :=
(TFAE_mem_nhdsWithin_Ioi hu' s).out 0 4
#align mem_nhds_within_Ioi_iff_exists_Ioo_subset' mem_nhdsWithin_Ioi_iff_exists_Ioo_subset'
theorem nhdsWithin_Ioi_basis' {a : α} (h : ∃ b, a < b) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) :=
let ⟨_, h⟩ := h
⟨fun _ => mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' h⟩
lemma nhdsWithin_Ioi_basis [NoMaxOrder α] (a : α) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) :=
nhdsWithin_Ioi_basis' <| exists_gt a
theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by
by_cases ha : IsTop a
· simp [ha, ha.isMax.Ioi_eq]
· simp only [ha, false_or]
rw [isTop_iff_isMax, not_isMax_iff] at ha
simp only [(nhdsWithin_Ioi_basis' ha).eq_bot_iff, covBy_iff_Ioo_eq]
theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset [NoMaxOrder α] {a : α} {s : Set α} :
s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s :=
let ⟨_u', hu'⟩ := exists_gt a
mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' hu'
#align mem_nhds_within_Ioi_iff_exists_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_Ioo_subset
theorem countable_setOf_isolated_right [SecondCountableTopology α] :
{ x : α | 𝓝[>] x = ⊥ }.Countable := by
simp only [nhdsWithin_Ioi_eq_bot_iff, setOf_or]
exact (subsingleton_isTop α).countable.union countable_setOf_covBy_right
theorem countable_setOf_isolated_left [SecondCountableTopology α] :
{ x : α | 𝓝[<] x = ⊥ }.Countable :=
countable_setOf_isolated_right (α := αᵒᵈ)
| Mathlib/Topology/Order/LeftRightNhds.lean | 112 | 120 | theorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α}
{s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s := by |
rw [mem_nhdsWithin_Ioi_iff_exists_Ioo_subset]
constructor
· rintro ⟨u, au, as⟩
rcases exists_between au with ⟨v, hv⟩
exact ⟨v, hv.1, fun x hx => as ⟨hx.1, lt_of_le_of_lt hx.2 hv.2⟩⟩
· rintro ⟨u, au, as⟩
exact ⟨u, au, Subset.trans Ioo_subset_Ioc_self as⟩
|
import Mathlib.Algebra.Polynomial.RingDivision
import Mathlib.RingTheory.Localization.FractionRing
#align_import data.polynomial.ring_division from "leanprover-community/mathlib"@"8efcf8022aac8e01df8d302dcebdbc25d6a886c8"
noncomputable section
namespace Polynomial
universe u v w z
variable {R : Type u} {S : Type v} {T : Type w} {a b : R} {n : ℕ}
section CommRing
variable [CommRing R] [IsDomain R] {p q : R[X]}
section Roots
open Multiset Finset
noncomputable def roots (p : R[X]) : Multiset R :=
haveI := Classical.decEq R
haveI := Classical.dec (p = 0)
if h : p = 0 then ∅ else Classical.choose (exists_multiset_roots h)
#align polynomial.roots Polynomial.roots
theorem roots_def [DecidableEq R] (p : R[X]) [Decidable (p = 0)] :
p.roots = if h : p = 0 then ∅ else Classical.choose (exists_multiset_roots h) := by
-- porting noteL `‹_›` doesn't work for instance arguments
rename_i iR ip0
obtain rfl := Subsingleton.elim iR (Classical.decEq R)
obtain rfl := Subsingleton.elim ip0 (Classical.dec (p = 0))
rfl
#align polynomial.roots_def Polynomial.roots_def
@[simp]
theorem roots_zero : (0 : R[X]).roots = 0 :=
dif_pos rfl
#align polynomial.roots_zero Polynomial.roots_zero
theorem card_roots (hp0 : p ≠ 0) : (Multiset.card (roots p) : WithBot ℕ) ≤ degree p := by
classical
unfold roots
rw [dif_neg hp0]
exact (Classical.choose_spec (exists_multiset_roots hp0)).1
#align polynomial.card_roots Polynomial.card_roots
theorem card_roots' (p : R[X]) : Multiset.card p.roots ≤ natDegree p := by
by_cases hp0 : p = 0
· simp [hp0]
exact WithBot.coe_le_coe.1 (le_trans (card_roots hp0) (le_of_eq <| degree_eq_natDegree hp0))
#align polynomial.card_roots' Polynomial.card_roots'
theorem card_roots_sub_C {p : R[X]} {a : R} (hp0 : 0 < degree p) :
(Multiset.card (p - C a).roots : WithBot ℕ) ≤ degree p :=
calc
(Multiset.card (p - C a).roots : WithBot ℕ) ≤ degree (p - C a) :=
card_roots <| mt sub_eq_zero.1 fun h => not_le_of_gt hp0 <| h.symm ▸ degree_C_le
_ = degree p := by rw [sub_eq_add_neg, ← C_neg]; exact degree_add_C hp0
set_option linter.uppercaseLean3 false in
#align polynomial.card_roots_sub_C Polynomial.card_roots_sub_C
theorem card_roots_sub_C' {p : R[X]} {a : R} (hp0 : 0 < degree p) :
Multiset.card (p - C a).roots ≤ natDegree p :=
WithBot.coe_le_coe.1
(le_trans (card_roots_sub_C hp0)
(le_of_eq <| degree_eq_natDegree fun h => by simp_all [lt_irrefl]))
set_option linter.uppercaseLean3 false in
#align polynomial.card_roots_sub_C' Polynomial.card_roots_sub_C'
@[simp]
theorem count_roots [DecidableEq R] (p : R[X]) : p.roots.count a = rootMultiplicity a p := by
classical
by_cases hp : p = 0
· simp [hp]
rw [roots_def, dif_neg hp]
exact (Classical.choose_spec (exists_multiset_roots hp)).2 a
#align polynomial.count_roots Polynomial.count_roots
@[simp]
theorem mem_roots' : a ∈ p.roots ↔ p ≠ 0 ∧ IsRoot p a := by
classical
rw [← count_pos, count_roots p, rootMultiplicity_pos']
#align polynomial.mem_roots' Polynomial.mem_roots'
theorem mem_roots (hp : p ≠ 0) : a ∈ p.roots ↔ IsRoot p a :=
mem_roots'.trans <| and_iff_right hp
#align polynomial.mem_roots Polynomial.mem_roots
theorem ne_zero_of_mem_roots (h : a ∈ p.roots) : p ≠ 0 :=
(mem_roots'.1 h).1
#align polynomial.ne_zero_of_mem_roots Polynomial.ne_zero_of_mem_roots
theorem isRoot_of_mem_roots (h : a ∈ p.roots) : IsRoot p a :=
(mem_roots'.1 h).2
#align polynomial.is_root_of_mem_roots Polynomial.isRoot_of_mem_roots
-- Porting note: added during port.
lemma mem_roots_iff_aeval_eq_zero {x : R} (w : p ≠ 0) : x ∈ roots p ↔ aeval x p = 0 := by
rw [mem_roots w, IsRoot.def, aeval_def, eval₂_eq_eval_map]
simp
theorem card_le_degree_of_subset_roots {p : R[X]} {Z : Finset R} (h : Z.val ⊆ p.roots) :
Z.card ≤ p.natDegree :=
(Multiset.card_le_card (Finset.val_le_iff_val_subset.2 h)).trans (Polynomial.card_roots' p)
#align polynomial.card_le_degree_of_subset_roots Polynomial.card_le_degree_of_subset_roots
theorem finite_setOf_isRoot {p : R[X]} (hp : p ≠ 0) : Set.Finite { x | IsRoot p x } := by
classical
simpa only [← Finset.setOf_mem, Multiset.mem_toFinset, mem_roots hp]
using p.roots.toFinset.finite_toSet
#align polynomial.finite_set_of_is_root Polynomial.finite_setOf_isRoot
theorem eq_zero_of_infinite_isRoot (p : R[X]) (h : Set.Infinite { x | IsRoot p x }) : p = 0 :=
not_imp_comm.mp finite_setOf_isRoot h
#align polynomial.eq_zero_of_infinite_is_root Polynomial.eq_zero_of_infinite_isRoot
theorem exists_max_root [LinearOrder R] (p : R[X]) (hp : p ≠ 0) : ∃ x₀, ∀ x, p.IsRoot x → x ≤ x₀ :=
Set.exists_upper_bound_image _ _ <| finite_setOf_isRoot hp
#align polynomial.exists_max_root Polynomial.exists_max_root
theorem exists_min_root [LinearOrder R] (p : R[X]) (hp : p ≠ 0) : ∃ x₀, ∀ x, p.IsRoot x → x₀ ≤ x :=
Set.exists_lower_bound_image _ _ <| finite_setOf_isRoot hp
#align polynomial.exists_min_root Polynomial.exists_min_root
theorem eq_of_infinite_eval_eq (p q : R[X]) (h : Set.Infinite { x | eval x p = eval x q }) :
p = q := by
rw [← sub_eq_zero]
apply eq_zero_of_infinite_isRoot
simpa only [IsRoot, eval_sub, sub_eq_zero]
#align polynomial.eq_of_infinite_eval_eq Polynomial.eq_of_infinite_eval_eq
theorem roots_mul {p q : R[X]} (hpq : p * q ≠ 0) : (p * q).roots = p.roots + q.roots := by
classical
exact Multiset.ext.mpr fun r => by
rw [count_add, count_roots, count_roots, count_roots, rootMultiplicity_mul hpq]
#align polynomial.roots_mul Polynomial.roots_mul
theorem roots.le_of_dvd (h : q ≠ 0) : p ∣ q → roots p ≤ roots q := by
rintro ⟨k, rfl⟩
exact Multiset.le_iff_exists_add.mpr ⟨k.roots, roots_mul h⟩
#align polynomial.roots.le_of_dvd Polynomial.roots.le_of_dvd
theorem mem_roots_sub_C' {p : R[X]} {a x : R} : x ∈ (p - C a).roots ↔ p ≠ C a ∧ p.eval x = a := by
rw [mem_roots', IsRoot.def, sub_ne_zero, eval_sub, sub_eq_zero, eval_C]
set_option linter.uppercaseLean3 false in
#align polynomial.mem_roots_sub_C' Polynomial.mem_roots_sub_C'
theorem mem_roots_sub_C {p : R[X]} {a x : R} (hp0 : 0 < degree p) :
x ∈ (p - C a).roots ↔ p.eval x = a :=
mem_roots_sub_C'.trans <| and_iff_right fun hp => hp0.not_le <| hp.symm ▸ degree_C_le
set_option linter.uppercaseLean3 false in
#align polynomial.mem_roots_sub_C Polynomial.mem_roots_sub_C
@[simp]
theorem roots_X_sub_C (r : R) : roots (X - C r) = {r} := by
classical
ext s
rw [count_roots, rootMultiplicity_X_sub_C, count_singleton]
set_option linter.uppercaseLean3 false in
#align polynomial.roots_X_sub_C Polynomial.roots_X_sub_C
@[simp]
theorem roots_X : roots (X : R[X]) = {0} := by rw [← roots_X_sub_C, C_0, sub_zero]
set_option linter.uppercaseLean3 false in
#align polynomial.roots_X Polynomial.roots_X
@[simp]
theorem roots_C (x : R) : (C x).roots = 0 := by
classical exact
if H : x = 0 then by rw [H, C_0, roots_zero]
else
Multiset.ext.mpr fun r => (by
rw [count_roots, count_zero, rootMultiplicity_eq_zero (not_isRoot_C _ _ H)])
set_option linter.uppercaseLean3 false in
#align polynomial.roots_C Polynomial.roots_C
@[simp]
theorem roots_one : (1 : R[X]).roots = ∅ :=
roots_C 1
#align polynomial.roots_one Polynomial.roots_one
@[simp]
theorem roots_C_mul (p : R[X]) (ha : a ≠ 0) : (C a * p).roots = p.roots := by
by_cases hp : p = 0 <;>
simp only [roots_mul, *, Ne, mul_eq_zero, C_eq_zero, or_self_iff, not_false_iff, roots_C,
zero_add, mul_zero]
set_option linter.uppercaseLean3 false in
#align polynomial.roots_C_mul Polynomial.roots_C_mul
@[simp]
theorem roots_smul_nonzero (p : R[X]) (ha : a ≠ 0) : (a • p).roots = p.roots := by
rw [smul_eq_C_mul, roots_C_mul _ ha]
#align polynomial.roots_smul_nonzero Polynomial.roots_smul_nonzero
@[simp]
lemma roots_neg (p : R[X]) : (-p).roots = p.roots := by
rw [← neg_one_smul R p, roots_smul_nonzero p (neg_ne_zero.mpr one_ne_zero)]
theorem roots_list_prod (L : List R[X]) :
(0 : R[X]) ∉ L → L.prod.roots = (L : Multiset R[X]).bind roots :=
List.recOn L (fun _ => roots_one) fun hd tl ih H => by
rw [List.mem_cons, not_or] at H
rw [List.prod_cons, roots_mul (mul_ne_zero (Ne.symm H.1) <| List.prod_ne_zero H.2), ←
Multiset.cons_coe, Multiset.cons_bind, ih H.2]
#align polynomial.roots_list_prod Polynomial.roots_list_prod
theorem roots_multiset_prod (m : Multiset R[X]) : (0 : R[X]) ∉ m → m.prod.roots = m.bind roots := by
rcases m with ⟨L⟩
simpa only [Multiset.prod_coe, quot_mk_to_coe''] using roots_list_prod L
#align polynomial.roots_multiset_prod Polynomial.roots_multiset_prod
theorem roots_prod {ι : Type*} (f : ι → R[X]) (s : Finset ι) :
s.prod f ≠ 0 → (s.prod f).roots = s.val.bind fun i => roots (f i) := by
rcases s with ⟨m, hm⟩
simpa [Multiset.prod_eq_zero_iff, Multiset.bind_map] using roots_multiset_prod (m.map f)
#align polynomial.roots_prod Polynomial.roots_prod
@[simp]
theorem roots_pow (p : R[X]) (n : ℕ) : (p ^ n).roots = n • p.roots := by
induction' n with n ihn
· rw [pow_zero, roots_one, zero_smul, empty_eq_zero]
· rcases eq_or_ne p 0 with (rfl | hp)
· rw [zero_pow n.succ_ne_zero, roots_zero, smul_zero]
· rw [pow_succ, roots_mul (mul_ne_zero (pow_ne_zero _ hp) hp), ihn, add_smul, one_smul]
#align polynomial.roots_pow Polynomial.roots_pow
theorem roots_X_pow (n : ℕ) : (X ^ n : R[X]).roots = n • ({0} : Multiset R) := by
rw [roots_pow, roots_X]
set_option linter.uppercaseLean3 false in
#align polynomial.roots_X_pow Polynomial.roots_X_pow
theorem roots_C_mul_X_pow (ha : a ≠ 0) (n : ℕ) :
Polynomial.roots (C a * X ^ n) = n • ({0} : Multiset R) := by
rw [roots_C_mul _ ha, roots_X_pow]
set_option linter.uppercaseLean3 false in
#align polynomial.roots_C_mul_X_pow Polynomial.roots_C_mul_X_pow
@[simp]
theorem roots_monomial (ha : a ≠ 0) (n : ℕ) : (monomial n a).roots = n • ({0} : Multiset R) := by
rw [← C_mul_X_pow_eq_monomial, roots_C_mul_X_pow ha]
#align polynomial.roots_monomial Polynomial.roots_monomial
theorem roots_prod_X_sub_C (s : Finset R) : (s.prod fun a => X - C a).roots = s.val := by
apply (roots_prod (fun a => X - C a) s ?_).trans
· simp_rw [roots_X_sub_C]
rw [Multiset.bind_singleton, Multiset.map_id']
· refine prod_ne_zero_iff.mpr (fun a _ => X_sub_C_ne_zero a)
set_option linter.uppercaseLean3 false in
#align polynomial.roots_prod_X_sub_C Polynomial.roots_prod_X_sub_C
@[simp]
theorem roots_multiset_prod_X_sub_C (s : Multiset R) : (s.map fun a => X - C a).prod.roots = s := by
rw [roots_multiset_prod, Multiset.bind_map]
· simp_rw [roots_X_sub_C]
rw [Multiset.bind_singleton, Multiset.map_id']
· rw [Multiset.mem_map]
rintro ⟨a, -, h⟩
exact X_sub_C_ne_zero a h
set_option linter.uppercaseLean3 false in
#align polynomial.roots_multiset_prod_X_sub_C Polynomial.roots_multiset_prod_X_sub_C
theorem card_roots_X_pow_sub_C {n : ℕ} (hn : 0 < n) (a : R) :
Multiset.card (roots ((X : R[X]) ^ n - C a)) ≤ n :=
WithBot.coe_le_coe.1 <|
calc
(Multiset.card (roots ((X : R[X]) ^ n - C a)) : WithBot ℕ) ≤ degree ((X : R[X]) ^ n - C a) :=
card_roots (X_pow_sub_C_ne_zero hn a)
_ = n := degree_X_pow_sub_C hn a
set_option linter.uppercaseLean3 false in
#align polynomial.card_roots_X_pow_sub_C Polynomial.card_roots_X_pow_sub_C
| Mathlib/Algebra/Polynomial/Roots.lean | 395 | 399 | theorem zero_of_eval_zero [Infinite R] (p : R[X]) (h : ∀ x, p.eval x = 0) : p = 0 := by |
classical
by_contra hp
refine @Fintype.false R _ ?_
exact ⟨p.roots.toFinset, fun x => Multiset.mem_toFinset.mpr ((mem_roots hp).mpr (h _))⟩
|
import Mathlib.Combinatorics.SimpleGraph.AdjMatrix
import Mathlib.LinearAlgebra.Matrix.PosDef
open Finset Matrix
namespace SimpleGraph
variable {V : Type*} (R : Type*)
variable [Fintype V] [DecidableEq V] (G : SimpleGraph V) [DecidableRel G.Adj]
def degMatrix [AddMonoidWithOne R] : Matrix V V R := Matrix.diagonal (G.degree ·)
def lapMatrix [AddGroupWithOne R] : Matrix V V R := G.degMatrix R - G.adjMatrix R
variable {R}
theorem isSymm_degMatrix [AddMonoidWithOne R] : (G.degMatrix R).IsSymm :=
isSymm_diagonal _
theorem isSymm_lapMatrix [AddGroupWithOne R] : (G.lapMatrix R).IsSymm :=
(isSymm_degMatrix _).sub (isSymm_adjMatrix _)
theorem degMatrix_mulVec_apply [NonAssocSemiring R] (v : V) (vec : V → R) :
(G.degMatrix R *ᵥ vec) v = G.degree v * vec v := by
rw [degMatrix, mulVec_diagonal]
theorem lapMatrix_mulVec_apply [NonAssocRing R] (v : V) (vec : V → R) :
(G.lapMatrix R *ᵥ vec) v = G.degree v * vec v - ∑ u ∈ G.neighborFinset v, vec u := by
simp_rw [lapMatrix, sub_mulVec, Pi.sub_apply, degMatrix_mulVec_apply, adjMatrix_mulVec_apply]
theorem lapMatrix_mulVec_const_eq_zero [Ring R] : mulVec (G.lapMatrix R) (fun _ ↦ 1) = 0 := by
ext1 i
rw [lapMatrix_mulVec_apply]
simp
| Mathlib/Combinatorics/SimpleGraph/LapMatrix.lean | 61 | 63 | theorem dotProduct_mulVec_degMatrix [CommRing R] (x : V → R) :
x ⬝ᵥ (G.degMatrix R *ᵥ x) = ∑ i : V, G.degree i * x i * x i := by |
simp only [dotProduct, degMatrix, mulVec_diagonal, ← mul_assoc, mul_comm]
|
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
open Filter Metric Set
open scoped ComplexConjugate Real Topology
namespace Complex
variable {a x z : ℂ}
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine ⟨fun hz => ⟨arg z, ?_⟩, ?_⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [re_ofReal_mul, im_ofReal_mul, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left₀ _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine Real.cos_pos_of_mem_Ioo ⟨?_, ?_⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel_right] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
lemma arg_exp_mul_I (θ : ℝ) :
arg (exp (θ * I)) = toIocMod (mul_pos two_pos Real.pi_pos) (-π) θ := by
convert arg_cos_add_sin_mul_I (θ := toIocMod (mul_pos two_pos Real.pi_pos) (-π) θ) _ using 2
· rw [← exp_mul_I, eq_sub_of_add_eq $ toIocMod_add_toIocDiv_zsmul _ _ θ, ofReal_sub,
ofReal_zsmul, ofReal_mul, ofReal_ofNat, exp_mul_I_periodic.sub_zsmul_eq]
· convert toIocMod_mem_Ioc _ _ _
ring
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz)
· simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel₀ _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_neg_I Complex.arg_neg_I
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
#align complex.tan_arg Complex.tan_arg
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
#align complex.arg_of_real_of_nonneg Complex.arg_ofReal_of_nonneg
@[simp, norm_cast]
lemma natCast_arg {n : ℕ} : arg n = 0 :=
ofReal_natCast n ▸ arg_ofReal_of_nonneg n.cast_nonneg
@[simp]
lemma ofNat_arg {n : ℕ} [n.AtLeastTwo] : arg (no_index (OfNat.ofNat n)) = 0 :=
natCast_arg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine ⟨fun h => ?_, ?_⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
#align complex.arg_eq_zero_iff Complex.arg_eq_zero_iff
open ComplexOrder in
lemma arg_eq_zero_iff_zero_le {z : ℂ} : arg z = 0 ↔ 0 ≤ z := by
rw [arg_eq_zero_iff, eq_comm, nonneg_iff]
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0
· simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
#align complex.arg_eq_pi_iff Complex.arg_eq_pi_iff
open ComplexOrder in
lemma arg_eq_pi_iff_lt_zero {z : ℂ} : arg z = π ↔ z < 0 := arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
#align complex.arg_lt_pi_iff Complex.arg_lt_pi_iff
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
#align complex.arg_of_real_of_neg Complex.arg_ofReal_of_neg
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
#align complex.arg_eq_pi_div_two_iff Complex.arg_eq_pi_div_two_iff
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
#align complex.arg_eq_neg_pi_div_two_iff Complex.arg_eq_neg_pi_div_two_iff
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
#align complex.arg_of_re_nonneg Complex.arg_of_re_nonneg
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
#align complex.arg_of_re_neg_of_im_nonneg Complex.arg_of_re_neg_of_im_nonneg
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
#align complex.arg_of_re_neg_of_im_neg Complex.arg_of_re_neg_of_im_neg
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
#align complex.arg_of_im_nonneg_of_ne_zero Complex.arg_of_im_nonneg_of_ne_zero
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
#align complex.arg_of_im_pos Complex.arg_of_im_pos
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
#align complex.arg_of_im_neg Complex.arg_of_im_neg
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
#align complex.arg_conj Complex.arg_conj
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
#align complex.arg_inv Complex.arg_inv
@[simp] lemma abs_arg_inv (x : ℂ) : |x⁻¹.arg| = |x.arg| := by rw [arg_inv]; split_ifs <;> simp [*]
-- TODO: Replace the next two lemmas by general facts about periodic functions
lemma abs_eq_one_iff' : abs x = 1 ↔ ∃ θ ∈ Set.Ioc (-π) π, exp (θ * I) = x := by
rw [abs_eq_one_iff]
constructor
· rintro ⟨θ, rfl⟩
refine ⟨toIocMod (mul_pos two_pos Real.pi_pos) (-π) θ, ?_, ?_⟩
· convert toIocMod_mem_Ioc _ _ _
ring
· rw [eq_sub_of_add_eq $ toIocMod_add_toIocDiv_zsmul _ _ θ, ofReal_sub,
ofReal_zsmul, ofReal_mul, ofReal_ofNat, exp_mul_I_periodic.sub_zsmul_eq]
· rintro ⟨θ, _, rfl⟩
exact ⟨θ, rfl⟩
lemma image_exp_Ioc_eq_sphere : (fun θ : ℝ ↦ exp (θ * I)) '' Set.Ioc (-π) π = sphere 0 1 := by
ext; simpa using abs_eq_one_iff'.symm
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
#align complex.arg_le_pi_div_two_iff Complex.arg_le_pi_div_two_iff
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
#align complex.neg_pi_div_two_le_arg_iff Complex.neg_pi_div_two_le_arg_iff
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
lemma arg_lt_pi_div_two_iff {z : ℂ} : arg z < π / 2 ↔ 0 < re z ∨ im z < 0 ∨ z = 0 := by
rw [lt_iff_le_and_ne, arg_le_pi_div_two_iff, Ne, arg_eq_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· have : z ≠ 0 := by simp [ext_iff, hre.ne]
simp [hre.ne, hre.not_le, hre.not_lt, this]
· have : z = 0 ↔ z.im = 0 := by simp [ext_iff, hre]
simp [hre, this, or_comm, le_iff_eq_or_lt]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
#align complex.abs_arg_le_pi_div_two_iff Complex.abs_arg_le_pi_div_two_iff
@[simp]
theorem abs_arg_lt_pi_div_two_iff {z : ℂ} : |arg z| < π / 2 ↔ 0 < re z ∨ z = 0 := by
rw [abs_lt, arg_lt_pi_div_two_iff, neg_pi_div_two_lt_arg_iff, ← or_and_left]
rcases eq_or_ne z 0 with hz | hz
· simp [hz]
· simp_rw [hz, or_false, ← not_lt, not_and_self_iff, or_false]
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
#align complex.arg_conj_coe_angle Complex.arg_conj_coe_angle
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
#align complex.arg_inv_coe_angle Complex.arg_inv_coe_angle
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
#align complex.arg_neg_eq_arg_sub_pi_of_im_pos Complex.arg_neg_eq_arg_sub_pi_of_im_pos
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
#align complex.arg_neg_eq_arg_add_pi_of_im_neg Complex.arg_neg_eq_arg_add_pi_of_im_neg
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
#align complex.arg_neg_eq_arg_sub_pi_iff Complex.arg_neg_eq_arg_sub_pi_iff
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
#align complex.arg_neg_eq_arg_add_pi_iff Complex.arg_neg_eq_arg_add_pi_iff
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
#align complex.arg_neg_coe_angle Complex.arg_neg_coe_angle
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I_eq_to_Ioc_mod Complex.arg_mul_cos_add_sin_mul_I_eq_toIocMod
| Mathlib/Analysis/SpecialFunctions/Complex/Arg.lean | 506 | 508 | theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by |
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
|
import Mathlib.Data.Int.Bitwise
import Mathlib.Data.Int.Order.Lemmas
import Mathlib.Data.Set.Function
import Mathlib.Order.Interval.Set.Basic
#align_import data.int.lemmas from "leanprover-community/mathlib"@"09597669f02422ed388036273d8848119699c22f"
open Nat
namespace Int
| Mathlib/Data/Int/Lemmas.lean | 26 | 29 | theorem le_natCast_sub (m n : ℕ) : (m - n : ℤ) ≤ ↑(m - n : ℕ) := by |
by_cases h : m ≥ n
· exact le_of_eq (Int.ofNat_sub h).symm
· simp [le_of_not_ge h, ofNat_le]
|
import Mathlib.Order.Interval.Set.UnorderedInterval
import Mathlib.Algebra.Order.Interval.Set.Monoid
import Mathlib.Data.Set.Pointwise.Basic
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Algebra.Order.Group.MinMax
#align_import data.set.pointwise.interval from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
open Interval Pointwise
variable {α : Type*}
namespace Set
section LinearOrderedField
variable [LinearOrderedField α] {a : α}
@[simp]
theorem preimage_mul_const_Iio (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Iio a = Iio (a / c) :=
ext fun _x => (lt_div_iff h).symm
#align set.preimage_mul_const_Iio Set.preimage_mul_const_Iio
@[simp]
theorem preimage_mul_const_Ioi (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ioi a = Ioi (a / c) :=
ext fun _x => (div_lt_iff h).symm
#align set.preimage_mul_const_Ioi Set.preimage_mul_const_Ioi
@[simp]
theorem preimage_mul_const_Iic (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Iic a = Iic (a / c) :=
ext fun _x => (le_div_iff h).symm
#align set.preimage_mul_const_Iic Set.preimage_mul_const_Iic
@[simp]
theorem preimage_mul_const_Ici (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ici a = Ici (a / c) :=
ext fun _x => (div_le_iff h).symm
#align set.preimage_mul_const_Ici Set.preimage_mul_const_Ici
@[simp]
theorem preimage_mul_const_Ioo (a b : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ioo a b = Ioo (a / c) (b / c) := by simp [← Ioi_inter_Iio, h]
#align set.preimage_mul_const_Ioo Set.preimage_mul_const_Ioo
@[simp]
theorem preimage_mul_const_Ioc (a b : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ioc a b = Ioc (a / c) (b / c) := by simp [← Ioi_inter_Iic, h]
#align set.preimage_mul_const_Ioc Set.preimage_mul_const_Ioc
@[simp]
theorem preimage_mul_const_Ico (a b : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ico a b = Ico (a / c) (b / c) := by simp [← Ici_inter_Iio, h]
#align set.preimage_mul_const_Ico Set.preimage_mul_const_Ico
@[simp]
theorem preimage_mul_const_Icc (a b : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Icc a b = Icc (a / c) (b / c) := by simp [← Ici_inter_Iic, h]
#align set.preimage_mul_const_Icc Set.preimage_mul_const_Icc
@[simp]
theorem preimage_mul_const_Iio_of_neg (a : α) {c : α} (h : c < 0) :
(fun x => x * c) ⁻¹' Iio a = Ioi (a / c) :=
ext fun _x => (div_lt_iff_of_neg h).symm
#align set.preimage_mul_const_Iio_of_neg Set.preimage_mul_const_Iio_of_neg
@[simp]
theorem preimage_mul_const_Ioi_of_neg (a : α) {c : α} (h : c < 0) :
(fun x => x * c) ⁻¹' Ioi a = Iio (a / c) :=
ext fun _x => (lt_div_iff_of_neg h).symm
#align set.preimage_mul_const_Ioi_of_neg Set.preimage_mul_const_Ioi_of_neg
@[simp]
theorem preimage_mul_const_Iic_of_neg (a : α) {c : α} (h : c < 0) :
(fun x => x * c) ⁻¹' Iic a = Ici (a / c) :=
ext fun _x => (div_le_iff_of_neg h).symm
#align set.preimage_mul_const_Iic_of_neg Set.preimage_mul_const_Iic_of_neg
@[simp]
theorem preimage_mul_const_Ici_of_neg (a : α) {c : α} (h : c < 0) :
(fun x => x * c) ⁻¹' Ici a = Iic (a / c) :=
ext fun _x => (le_div_iff_of_neg h).symm
#align set.preimage_mul_const_Ici_of_neg Set.preimage_mul_const_Ici_of_neg
@[simp]
theorem preimage_mul_const_Ioo_of_neg (a b : α) {c : α} (h : c < 0) :
(fun x => x * c) ⁻¹' Ioo a b = Ioo (b / c) (a / c) := by simp [← Ioi_inter_Iio, h, inter_comm]
#align set.preimage_mul_const_Ioo_of_neg Set.preimage_mul_const_Ioo_of_neg
@[simp]
theorem preimage_mul_const_Ioc_of_neg (a b : α) {c : α} (h : c < 0) :
(fun x => x * c) ⁻¹' Ioc a b = Ico (b / c) (a / c) := by
simp [← Ioi_inter_Iic, ← Ici_inter_Iio, h, inter_comm]
#align set.preimage_mul_const_Ioc_of_neg Set.preimage_mul_const_Ioc_of_neg
@[simp]
theorem preimage_mul_const_Ico_of_neg (a b : α) {c : α} (h : c < 0) :
(fun x => x * c) ⁻¹' Ico a b = Ioc (b / c) (a / c) := by
simp [← Ici_inter_Iio, ← Ioi_inter_Iic, h, inter_comm]
#align set.preimage_mul_const_Ico_of_neg Set.preimage_mul_const_Ico_of_neg
@[simp]
theorem preimage_mul_const_Icc_of_neg (a b : α) {c : α} (h : c < 0) :
(fun x => x * c) ⁻¹' Icc a b = Icc (b / c) (a / c) := by simp [← Ici_inter_Iic, h, inter_comm]
#align set.preimage_mul_const_Icc_of_neg Set.preimage_mul_const_Icc_of_neg
@[simp]
theorem preimage_const_mul_Iio (a : α) {c : α} (h : 0 < c) : (c * ·) ⁻¹' Iio a = Iio (a / c) :=
ext fun _x => (lt_div_iff' h).symm
#align set.preimage_const_mul_Iio Set.preimage_const_mul_Iio
@[simp]
theorem preimage_const_mul_Ioi (a : α) {c : α} (h : 0 < c) : (c * ·) ⁻¹' Ioi a = Ioi (a / c) :=
ext fun _x => (div_lt_iff' h).symm
#align set.preimage_const_mul_Ioi Set.preimage_const_mul_Ioi
@[simp]
theorem preimage_const_mul_Iic (a : α) {c : α} (h : 0 < c) : (c * ·) ⁻¹' Iic a = Iic (a / c) :=
ext fun _x => (le_div_iff' h).symm
#align set.preimage_const_mul_Iic Set.preimage_const_mul_Iic
@[simp]
theorem preimage_const_mul_Ici (a : α) {c : α} (h : 0 < c) : (c * ·) ⁻¹' Ici a = Ici (a / c) :=
ext fun _x => (div_le_iff' h).symm
#align set.preimage_const_mul_Ici Set.preimage_const_mul_Ici
@[simp]
theorem preimage_const_mul_Ioo (a b : α) {c : α} (h : 0 < c) :
(c * ·) ⁻¹' Ioo a b = Ioo (a / c) (b / c) := by simp [← Ioi_inter_Iio, h]
#align set.preimage_const_mul_Ioo Set.preimage_const_mul_Ioo
@[simp]
theorem preimage_const_mul_Ioc (a b : α) {c : α} (h : 0 < c) :
(c * ·) ⁻¹' Ioc a b = Ioc (a / c) (b / c) := by simp [← Ioi_inter_Iic, h]
#align set.preimage_const_mul_Ioc Set.preimage_const_mul_Ioc
@[simp]
theorem preimage_const_mul_Ico (a b : α) {c : α} (h : 0 < c) :
(c * ·) ⁻¹' Ico a b = Ico (a / c) (b / c) := by simp [← Ici_inter_Iio, h]
#align set.preimage_const_mul_Ico Set.preimage_const_mul_Ico
@[simp]
theorem preimage_const_mul_Icc (a b : α) {c : α} (h : 0 < c) :
(c * ·) ⁻¹' Icc a b = Icc (a / c) (b / c) := by simp [← Ici_inter_Iic, h]
#align set.preimage_const_mul_Icc Set.preimage_const_mul_Icc
@[simp]
theorem preimage_const_mul_Iio_of_neg (a : α) {c : α} (h : c < 0) :
(c * ·) ⁻¹' Iio a = Ioi (a / c) := by
simpa only [mul_comm] using preimage_mul_const_Iio_of_neg a h
#align set.preimage_const_mul_Iio_of_neg Set.preimage_const_mul_Iio_of_neg
@[simp]
theorem preimage_const_mul_Ioi_of_neg (a : α) {c : α} (h : c < 0) :
(c * ·) ⁻¹' Ioi a = Iio (a / c) := by
simpa only [mul_comm] using preimage_mul_const_Ioi_of_neg a h
#align set.preimage_const_mul_Ioi_of_neg Set.preimage_const_mul_Ioi_of_neg
@[simp]
theorem preimage_const_mul_Iic_of_neg (a : α) {c : α} (h : c < 0) :
(c * ·) ⁻¹' Iic a = Ici (a / c) := by
simpa only [mul_comm] using preimage_mul_const_Iic_of_neg a h
#align set.preimage_const_mul_Iic_of_neg Set.preimage_const_mul_Iic_of_neg
@[simp]
theorem preimage_const_mul_Ici_of_neg (a : α) {c : α} (h : c < 0) :
(c * ·) ⁻¹' Ici a = Iic (a / c) := by
simpa only [mul_comm] using preimage_mul_const_Ici_of_neg a h
#align set.preimage_const_mul_Ici_of_neg Set.preimage_const_mul_Ici_of_neg
@[simp]
theorem preimage_const_mul_Ioo_of_neg (a b : α) {c : α} (h : c < 0) :
(c * ·) ⁻¹' Ioo a b = Ioo (b / c) (a / c) := by
simpa only [mul_comm] using preimage_mul_const_Ioo_of_neg a b h
#align set.preimage_const_mul_Ioo_of_neg Set.preimage_const_mul_Ioo_of_neg
@[simp]
theorem preimage_const_mul_Ioc_of_neg (a b : α) {c : α} (h : c < 0) :
(c * ·) ⁻¹' Ioc a b = Ico (b / c) (a / c) := by
simpa only [mul_comm] using preimage_mul_const_Ioc_of_neg a b h
#align set.preimage_const_mul_Ioc_of_neg Set.preimage_const_mul_Ioc_of_neg
@[simp]
theorem preimage_const_mul_Ico_of_neg (a b : α) {c : α} (h : c < 0) :
(c * ·) ⁻¹' Ico a b = Ioc (b / c) (a / c) := by
simpa only [mul_comm] using preimage_mul_const_Ico_of_neg a b h
#align set.preimage_const_mul_Ico_of_neg Set.preimage_const_mul_Ico_of_neg
@[simp]
theorem preimage_const_mul_Icc_of_neg (a b : α) {c : α} (h : c < 0) :
(c * ·) ⁻¹' Icc a b = Icc (b / c) (a / c) := by
simpa only [mul_comm] using preimage_mul_const_Icc_of_neg a b h
#align set.preimage_const_mul_Icc_of_neg Set.preimage_const_mul_Icc_of_neg
@[simp]
theorem preimage_mul_const_uIcc (ha : a ≠ 0) (b c : α) :
(· * a) ⁻¹' [[b, c]] = [[b / a, c / a]] :=
(lt_or_gt_of_ne ha).elim
(fun h => by
simp [← Icc_min_max, h, h.le, min_div_div_right_of_nonpos, max_div_div_right_of_nonpos])
fun ha : 0 < a => by simp [← Icc_min_max, ha, ha.le, min_div_div_right, max_div_div_right]
#align set.preimage_mul_const_uIcc Set.preimage_mul_const_uIcc
@[simp]
theorem preimage_const_mul_uIcc (ha : a ≠ 0) (b c : α) :
(a * ·) ⁻¹' [[b, c]] = [[b / a, c / a]] := by
simp only [← preimage_mul_const_uIcc ha, mul_comm]
#align set.preimage_const_mul_uIcc Set.preimage_const_mul_uIcc
@[simp]
theorem preimage_div_const_uIcc (ha : a ≠ 0) (b c : α) :
(fun x => x / a) ⁻¹' [[b, c]] = [[b * a, c * a]] := by
simp only [div_eq_mul_inv, preimage_mul_const_uIcc (inv_ne_zero ha), inv_inv]
#align set.preimage_div_const_uIcc Set.preimage_div_const_uIcc
@[simp]
theorem image_mul_const_uIcc (a b c : α) : (· * a) '' [[b, c]] = [[b * a, c * a]] :=
if ha : a = 0 then by simp [ha]
else calc
(fun x => x * a) '' [[b, c]] = (· * a⁻¹) ⁻¹' [[b, c]] :=
(Units.mk0 a ha).mulRight.image_eq_preimage _
_ = (fun x => x / a) ⁻¹' [[b, c]] := by simp only [div_eq_mul_inv]
_ = [[b * a, c * a]] := preimage_div_const_uIcc ha _ _
#align set.image_mul_const_uIcc Set.image_mul_const_uIcc
@[simp]
| Mathlib/Data/Set/Pointwise/Interval.lean | 804 | 805 | theorem image_const_mul_uIcc (a b c : α) : (a * ·) '' [[b, c]] = [[a * b, a * c]] := by |
simpa only [mul_comm] using image_mul_const_uIcc a b c
|
import Mathlib.Algebra.CharZero.Lemmas
import Mathlib.Algebra.GroupWithZero.Commute
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Algebra.Order.Ring.Pow
import Mathlib.Algebra.Ring.Int
#align_import algebra.order.field.power from "leanprover-community/mathlib"@"acb3d204d4ee883eb686f45d486a2a6811a01329"
variable {α : Type*}
open Function Int
section LinearOrderedSemifield
variable [LinearOrderedSemifield α] {a b c d e : α} {m n : ℤ}
@[gcongr]
| Mathlib/Algebra/Order/Field/Power.lean | 30 | 37 | theorem zpow_le_of_le (ha : 1 ≤ a) (h : m ≤ n) : a ^ m ≤ a ^ n := by |
have ha₀ : 0 < a := one_pos.trans_le ha
lift n - m to ℕ using sub_nonneg.2 h with k hk
calc
a ^ m = a ^ m * 1 := (mul_one _).symm
_ ≤ a ^ m * a ^ k :=
mul_le_mul_of_nonneg_left (one_le_pow_of_one_le ha _) (zpow_nonneg ha₀.le _)
_ = a ^ n := by rw [← zpow_natCast, ← zpow_add₀ ha₀.ne', hk, add_sub_cancel]
|
import Mathlib.Algebra.Group.Subgroup.Pointwise
import Mathlib.Data.Set.Basic
import Mathlib.Data.Setoid.Basic
import Mathlib.GroupTheory.Coset
#align_import group_theory.double_coset from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514"
-- Porting note: removed import
-- import Mathlib.Tactic.Group
variable {G : Type*} [Group G] {α : Type*} [Mul α] (J : Subgroup G) (g : G)
open MulOpposite
open scoped Pointwise
namespace Doset
def doset (a : α) (s t : Set α) : Set α :=
s * {a} * t
#align doset Doset.doset
lemma doset_eq_image2 (a : α) (s t : Set α) : doset a s t = Set.image2 (· * a * ·) s t := by
simp_rw [doset, Set.mul_singleton, ← Set.image2_mul, Set.image2_image_left]
theorem mem_doset {s t : Set α} {a b : α} : b ∈ doset a s t ↔ ∃ x ∈ s, ∃ y ∈ t, b = x * a * y := by
simp only [doset_eq_image2, Set.mem_image2, eq_comm]
#align doset.mem_doset Doset.mem_doset
theorem mem_doset_self (H K : Subgroup G) (a : G) : a ∈ doset a H K :=
mem_doset.mpr ⟨1, H.one_mem, 1, K.one_mem, (one_mul a).symm.trans (mul_one (1 * a)).symm⟩
#align doset.mem_doset_self Doset.mem_doset_self
theorem doset_eq_of_mem {H K : Subgroup G} {a b : G} (hb : b ∈ doset a H K) :
doset b H K = doset a H K := by
obtain ⟨h, hh, k, hk, rfl⟩ := mem_doset.1 hb
rw [doset, doset, ← Set.singleton_mul_singleton, ← Set.singleton_mul_singleton, mul_assoc,
mul_assoc, Subgroup.singleton_mul_subgroup hk, ← mul_assoc, ← mul_assoc,
Subgroup.subgroup_mul_singleton hh]
#align doset.doset_eq_of_mem Doset.doset_eq_of_mem
| Mathlib/GroupTheory/DoubleCoset.lean | 60 | 66 | theorem mem_doset_of_not_disjoint {H K : Subgroup G} {a b : G}
(h : ¬Disjoint (doset a H K) (doset b H K)) : b ∈ doset a H K := by |
rw [Set.not_disjoint_iff] at h
simp only [mem_doset] at *
obtain ⟨x, ⟨l, hl, r, hr, hrx⟩, y, hy, ⟨r', hr', rfl⟩⟩ := h
refine ⟨y⁻¹ * l, H.mul_mem (H.inv_mem hy) hl, r * r'⁻¹, K.mul_mem hr (K.inv_mem hr'), ?_⟩
rwa [mul_assoc, mul_assoc, eq_inv_mul_iff_mul_eq, ← mul_assoc, ← mul_assoc, eq_mul_inv_iff_mul_eq]
|
import Mathlib.Topology.UniformSpace.UniformConvergence
import Mathlib.Topology.UniformSpace.Equicontinuity
import Mathlib.Topology.Separation
import Mathlib.Topology.Support
#align_import topology.uniform_space.compact from "leanprover-community/mathlib"@"735b22f8f9ff9792cf4212d7cb051c4c994bc685"
open scoped Classical
open Uniformity Topology Filter UniformSpace Set
variable {α β γ : Type*} [UniformSpace α] [UniformSpace β]
theorem nhdsSet_diagonal_eq_uniformity [CompactSpace α] : 𝓝ˢ (diagonal α) = 𝓤 α := by
refine nhdsSet_diagonal_le_uniformity.antisymm ?_
have :
(𝓤 (α × α)).HasBasis (fun U => U ∈ 𝓤 α) fun U =>
(fun p : (α × α) × α × α => ((p.1.1, p.2.1), p.1.2, p.2.2)) ⁻¹' U ×ˢ U := by
rw [uniformity_prod_eq_comap_prod]
exact (𝓤 α).basis_sets.prod_self.comap _
refine (isCompact_diagonal.nhdsSet_basis_uniformity this).ge_iff.2 fun U hU => ?_
exact mem_of_superset hU fun ⟨x, y⟩ hxy => mem_iUnion₂.2
⟨(x, x), rfl, refl_mem_uniformity hU, hxy⟩
#align nhds_set_diagonal_eq_uniformity nhdsSet_diagonal_eq_uniformity
theorem compactSpace_uniformity [CompactSpace α] : 𝓤 α = ⨆ x, 𝓝 (x, x) :=
nhdsSet_diagonal_eq_uniformity.symm.trans (nhdsSet_diagonal _)
#align compact_space_uniformity compactSpace_uniformity
theorem unique_uniformity_of_compact [t : TopologicalSpace γ] [CompactSpace γ]
{u u' : UniformSpace γ} (h : u.toTopologicalSpace = t) (h' : u'.toTopologicalSpace = t) :
u = u' := by
refine UniformSpace.ext ?_
have : @CompactSpace γ u.toTopologicalSpace := by rwa [h]
have : @CompactSpace γ u'.toTopologicalSpace := by rwa [h']
rw [@compactSpace_uniformity _ u, compactSpace_uniformity, h, h']
#align unique_uniformity_of_compact unique_uniformity_of_compact
def uniformSpaceOfCompactT2 [TopologicalSpace γ] [CompactSpace γ] [T2Space γ] : UniformSpace γ where
uniformity := 𝓝ˢ (diagonal γ)
symm := continuous_swap.tendsto_nhdsSet fun x => Eq.symm
comp := by
set 𝓝Δ := 𝓝ˢ (diagonal γ)
-- The filter of neighborhoods of Δ
set F := 𝓝Δ.lift' fun s : Set (γ × γ) => s ○ s
-- Compositions of neighborhoods of Δ
-- If this weren't true, then there would be V ∈ 𝓝Δ such that F ⊓ 𝓟 Vᶜ ≠ ⊥
rw [le_iff_forall_inf_principal_compl]
intro V V_in
by_contra H
haveI : NeBot (F ⊓ 𝓟 Vᶜ) := ⟨H⟩
-- Hence compactness would give us a cluster point (x, y) for F ⊓ 𝓟 Vᶜ
obtain ⟨⟨x, y⟩, hxy⟩ : ∃ p : γ × γ, ClusterPt p (F ⊓ 𝓟 Vᶜ) := exists_clusterPt_of_compactSpace _
-- In particular (x, y) is a cluster point of 𝓟 Vᶜ, hence is not in the interior of V,
-- and a fortiori not in Δ, so x ≠ y
have clV : ClusterPt (x, y) (𝓟 <| Vᶜ) := hxy.of_inf_right
have : (x, y) ∉ interior V := by
have : (x, y) ∈ closure Vᶜ := by rwa [mem_closure_iff_clusterPt]
rwa [closure_compl] at this
have diag_subset : diagonal γ ⊆ interior V := subset_interior_iff_mem_nhdsSet.2 V_in
have x_ne_y : x ≠ y := mt (@diag_subset (x, y)) this
-- Since γ is compact and Hausdorff, it is T₄, hence T₃.
-- So there are closed neighborhoods V₁ and V₂ of x and y contained in
-- disjoint open neighborhoods U₁ and U₂.
obtain
⟨U₁, _, V₁, V₁_in, U₂, _, V₂, V₂_in, V₁_cl, V₂_cl, U₁_op, U₂_op, VU₁, VU₂, hU₁₂⟩ :=
disjoint_nested_nhds x_ne_y
-- We set U₃ := (V₁ ∪ V₂)ᶜ so that W := U₁ ×ˢ U₁ ∪ U₂ ×ˢ U₂ ∪ U₃ ×ˢ U₃ is an open
-- neighborhood of Δ.
let U₃ := (V₁ ∪ V₂)ᶜ
have U₃_op : IsOpen U₃ := (V₁_cl.union V₂_cl).isOpen_compl
let W := U₁ ×ˢ U₁ ∪ U₂ ×ˢ U₂ ∪ U₃ ×ˢ U₃
have W_in : W ∈ 𝓝Δ := by
rw [mem_nhdsSet_iff_forall]
rintro ⟨z, z'⟩ (rfl : z = z')
refine IsOpen.mem_nhds ?_ ?_
· apply_rules [IsOpen.union, IsOpen.prod]
· simp only [W, mem_union, mem_prod, and_self_iff]
exact (_root_.em _).imp_left fun h => union_subset_union VU₁ VU₂ h
-- So W ○ W ∈ F by definition of F
have : W ○ W ∈ F := @mem_lift' _ _ _ (fun s => s ○ s) _ W_in
-- Porting note: was `by simpa only using mem_lift' W_in`
-- And V₁ ×ˢ V₂ ∈ 𝓝 (x, y)
have hV₁₂ : V₁ ×ˢ V₂ ∈ 𝓝 (x, y) := prod_mem_nhds V₁_in V₂_in
-- But (x, y) is also a cluster point of F so (V₁ ×ˢ V₂) ∩ (W ○ W) ≠ ∅
-- However the construction of W implies (V₁ ×ˢ V₂) ∩ (W ○ W) = ∅.
-- Indeed assume for contradiction there is some (u, v) in the intersection.
obtain ⟨⟨u, v⟩, ⟨u_in, v_in⟩, w, huw, hwv⟩ := clusterPt_iff.mp hxy.of_inf_left hV₁₂ this
-- So u ∈ V₁, v ∈ V₂, and there exists some w such that (u, w) ∈ W and (w ,v) ∈ W.
-- Because u is in V₁ which is disjoint from U₂ and U₃, (u, w) ∈ W forces (u, w) ∈ U₁ ×ˢ U₁.
have uw_in : (u, w) ∈ U₁ ×ˢ U₁ :=
(huw.resolve_right fun h => h.1 <| Or.inl u_in).resolve_right fun h =>
hU₁₂.le_bot ⟨VU₁ u_in, h.1⟩
-- Similarly, because v ∈ V₂, (w ,v) ∈ W forces (w, v) ∈ U₂ ×ˢ U₂.
have wv_in : (w, v) ∈ U₂ ×ˢ U₂ :=
(hwv.resolve_right fun h => h.2 <| Or.inr v_in).resolve_left fun h =>
hU₁₂.le_bot ⟨h.2, VU₂ v_in⟩
-- Hence w ∈ U₁ ∩ U₂ which is empty.
-- So we have a contradiction
exact hU₁₂.le_bot ⟨uw_in.2, wv_in.1⟩
nhds_eq_comap_uniformity x := by
simp_rw [nhdsSet_diagonal, comap_iSup, nhds_prod_eq, comap_prod, (· ∘ ·), comap_id']
rw [iSup_split_single _ x, comap_const_of_mem fun V => mem_of_mem_nhds]
suffices ∀ y ≠ x, comap (fun _ : γ ↦ x) (𝓝 y) ⊓ 𝓝 y ≤ 𝓝 x by simpa
intro y hxy
simp [comap_const_of_not_mem (compl_singleton_mem_nhds hxy) (not_not_intro rfl)]
#align uniform_space_of_compact_t2 uniformSpaceOfCompactT2
theorem CompactSpace.uniformContinuous_of_continuous [CompactSpace α] {f : α → β}
(h : Continuous f) : UniformContinuous f :=
calc map (Prod.map f f) (𝓤 α)
= map (Prod.map f f) (𝓝ˢ (diagonal α)) := by rw [nhdsSet_diagonal_eq_uniformity]
_ ≤ 𝓝ˢ (diagonal β) := (h.prod_map h).tendsto_nhdsSet mapsTo_prod_map_diagonal
_ ≤ 𝓤 β := nhdsSet_diagonal_le_uniformity
#align compact_space.uniform_continuous_of_continuous CompactSpace.uniformContinuous_of_continuous
theorem IsCompact.uniformContinuousOn_of_continuous {s : Set α} {f : α → β} (hs : IsCompact s)
(hf : ContinuousOn f s) : UniformContinuousOn f s := by
rw [uniformContinuousOn_iff_restrict]
rw [isCompact_iff_compactSpace] at hs
rw [continuousOn_iff_continuous_restrict] at hf
exact CompactSpace.uniformContinuous_of_continuous hf
#align is_compact.uniform_continuous_on_of_continuous IsCompact.uniformContinuousOn_of_continuous
theorem IsCompact.uniformContinuousAt_of_continuousAt {r : Set (β × β)} {s : Set α}
(hs : IsCompact s) (f : α → β) (hf : ∀ a ∈ s, ContinuousAt f a) (hr : r ∈ 𝓤 β) :
{ x : α × α | x.1 ∈ s → (f x.1, f x.2) ∈ r } ∈ 𝓤 α := by
obtain ⟨t, ht, htsymm, htr⟩ := comp_symm_mem_uniformity_sets hr
choose U hU T hT hb using fun a ha =>
exists_mem_nhds_ball_subset_of_mem_nhds ((hf a ha).preimage_mem_nhds <| mem_nhds_left _ ht)
obtain ⟨fs, hsU⟩ := hs.elim_nhds_subcover' U hU
apply mem_of_superset ((biInter_finset_mem fs).2 fun a _ => hT a a.2)
rintro ⟨a₁, a₂⟩ h h₁
obtain ⟨a, ha, haU⟩ := Set.mem_iUnion₂.1 (hsU h₁)
apply htr
refine ⟨f a, htsymm.mk_mem_comm.1 (hb _ _ _ haU ?_), hb _ _ _ haU ?_⟩
exacts [mem_ball_self _ (hT a a.2), mem_iInter₂.1 h a ha]
#align is_compact.uniform_continuous_at_of_continuous_at IsCompact.uniformContinuousAt_of_continuousAt
theorem Continuous.uniformContinuous_of_tendsto_cocompact {f : α → β} {x : β}
(h_cont : Continuous f) (hx : Tendsto f (cocompact α) (𝓝 x)) : UniformContinuous f :=
uniformContinuous_def.2 fun r hr => by
obtain ⟨t, ht, htsymm, htr⟩ := comp_symm_mem_uniformity_sets hr
obtain ⟨s, hs, hst⟩ := mem_cocompact.1 (hx <| mem_nhds_left _ ht)
apply
mem_of_superset
(symmetrize_mem_uniformity <|
(hs.uniformContinuousAt_of_continuousAt f fun _ _ => h_cont.continuousAt) <|
symmetrize_mem_uniformity hr)
rintro ⟨b₁, b₂⟩ h
by_cases h₁ : b₁ ∈ s; · exact (h.1 h₁).1
by_cases h₂ : b₂ ∈ s; · exact (h.2 h₂).2
apply htr
exact ⟨x, htsymm.mk_mem_comm.1 (hst h₁), hst h₂⟩
#align continuous.uniform_continuous_of_tendsto_cocompact Continuous.uniformContinuous_of_tendsto_cocompact
@[to_additive "If `f` has compact support, then `f` tends to zero at infinity."]
theorem HasCompactMulSupport.is_one_at_infty {f : α → γ} [TopologicalSpace γ] [One γ]
(h : HasCompactMulSupport f) : Tendsto f (cocompact α) (𝓝 1) := by
-- Porting note: move to src/topology/support.lean once the port is over
intro N hN
rw [mem_map, mem_cocompact']
refine ⟨mulTSupport f, h.isCompact, ?_⟩
rw [compl_subset_comm]
intro v hv
rw [mem_preimage, image_eq_one_of_nmem_mulTSupport hv]
exact mem_of_mem_nhds hN
#align has_compact_mul_support.is_one_at_infty HasCompactMulSupport.is_one_at_infty
#align has_compact_support.is_zero_at_infty HasCompactSupport.is_zero_at_infty
@[to_additive]
theorem HasCompactMulSupport.uniformContinuous_of_continuous {f : α → β} [One β]
(h1 : HasCompactMulSupport f) (h2 : Continuous f) : UniformContinuous f :=
h2.uniformContinuous_of_tendsto_cocompact h1.is_one_at_infty
#align has_compact_mul_support.uniform_continuous_of_continuous HasCompactMulSupport.uniformContinuous_of_continuous
#align has_compact_support.uniform_continuous_of_continuous HasCompactSupport.uniformContinuous_of_continuous
theorem ContinuousOn.tendstoUniformly [LocallyCompactSpace α] [CompactSpace β] [UniformSpace γ]
{f : α → β → γ} {x : α} {U : Set α} (hxU : U ∈ 𝓝 x) (h : ContinuousOn (↿f) (U ×ˢ univ)) :
TendstoUniformly f (f x) (𝓝 x) := by
rcases LocallyCompactSpace.local_compact_nhds _ _ hxU with ⟨K, hxK, hKU, hK⟩
have : UniformContinuousOn (↿f) (K ×ˢ univ) :=
IsCompact.uniformContinuousOn_of_continuous (hK.prod isCompact_univ)
(h.mono <| prod_mono hKU Subset.rfl)
exact this.tendstoUniformly hxK
#align continuous_on.tendsto_uniformly ContinuousOn.tendstoUniformly
theorem Continuous.tendstoUniformly [WeaklyLocallyCompactSpace α] [CompactSpace β] [UniformSpace γ]
(f : α → β → γ) (h : Continuous ↿f) (x : α) : TendstoUniformly f (f x) (𝓝 x) :=
let ⟨K, hK, hxK⟩ := exists_compact_mem_nhds x
have : UniformContinuousOn (↿f) (K ×ˢ univ) :=
IsCompact.uniformContinuousOn_of_continuous (hK.prod isCompact_univ) h.continuousOn
this.tendstoUniformly hxK
#align continuous.tendsto_uniformly Continuous.tendstoUniformly
lemma IsCompact.mem_uniformity_of_prod
{α β E : Type*} [TopologicalSpace α] [TopologicalSpace β] [UniformSpace E]
{f : α → β → E} {s : Set α} {k : Set β} {q : α} {u : Set (E × E)}
(hk : IsCompact k) (hf : ContinuousOn f.uncurry (s ×ˢ k)) (hq : q ∈ s) (hu : u ∈ 𝓤 E) :
∃ v ∈ 𝓝[s] q, ∀ p ∈ v, ∀ x ∈ k, (f p x, f q x) ∈ u := by
apply hk.induction_on (p := fun t ↦ ∃ v ∈ 𝓝[s] q, ∀ p ∈ v, ∀ x ∈ t, (f p x, f q x) ∈ u)
· exact ⟨univ, univ_mem, by simp⟩
· intro t' t ht't ⟨v, v_mem, hv⟩
exact ⟨v, v_mem, fun p hp x hx ↦ hv p hp x (ht't hx)⟩
· intro t t' ⟨v, v_mem, hv⟩ ⟨v', v'_mem, hv'⟩
refine ⟨v ∩ v', inter_mem v_mem v'_mem, fun p hp x hx ↦ ?_⟩
rcases hx with h'x|h'x
· exact hv p hp.1 x h'x
· exact hv' p hp.2 x h'x
· rcases comp_symm_of_uniformity hu with ⟨u', u'_mem, u'_symm, hu'⟩
intro x hx
obtain ⟨v, hv, w, hw, hvw⟩ :
∃ v ∈ 𝓝[s] q, ∃ w ∈ 𝓝[k] x, v ×ˢ w ⊆ f.uncurry ⁻¹' {z | (f q x, z) ∈ u'} :=
mem_nhdsWithin_prod_iff.1 (hf (q, x) ⟨hq, hx⟩ (mem_nhds_left (f q x) u'_mem))
refine ⟨w, hw, v, hv, fun p hp y hy ↦ ?_⟩
have A : (f q x, f p y) ∈ u' := hvw (⟨hp, hy⟩ : (p, y) ∈ v ×ˢ w)
have B : (f q x, f q y) ∈ u' := hvw (⟨mem_of_mem_nhdsWithin hq hv, hy⟩ : (q, y) ∈ v ×ˢ w)
exact hu' (prod_mk_mem_compRel (u'_symm A) B)
section UniformConvergence
| Mathlib/Topology/UniformSpace/Compact.lean | 288 | 292 | theorem CompactSpace.uniformEquicontinuous_of_equicontinuous {ι : Type*} {F : ι → β → α}
[CompactSpace β] (h : Equicontinuous F) : UniformEquicontinuous F := by |
rw [equicontinuous_iff_continuous] at h
rw [uniformEquicontinuous_iff_uniformContinuous]
exact CompactSpace.uniformContinuous_of_continuous h
|
import Mathlib.Deprecated.Group
#align_import deprecated.ring from "leanprover-community/mathlib"@"5a3e819569b0f12cbec59d740a2613018e7b8eec"
universe u v w
variable {α : Type u}
structure IsSemiringHom {α : Type u} {β : Type v} [Semiring α] [Semiring β] (f : α → β) : Prop where
map_zero : f 0 = 0
map_one : f 1 = 1
map_add : ∀ x y, f (x + y) = f x + f y
map_mul : ∀ x y, f (x * y) = f x * f y
#align is_semiring_hom IsSemiringHom
namespace IsSemiringHom
variable {β : Type v} [Semiring α] [Semiring β]
variable {f : α → β} (hf : IsSemiringHom f) {x y : α}
theorem id : IsSemiringHom (@id α) := by constructor <;> intros <;> rfl
#align is_semiring_hom.id IsSemiringHom.id
theorem comp (hf : IsSemiringHom f) {γ} [Semiring γ] {g : β → γ} (hg : IsSemiringHom g) :
IsSemiringHom (g ∘ f) :=
{ map_zero := by simpa [map_zero hf] using map_zero hg
map_one := by simpa [map_one hf] using map_one hg
map_add := fun {x y} => by simp [map_add hf, map_add hg]
map_mul := fun {x y} => by simp [map_mul hf, map_mul hg] }
#align is_semiring_hom.comp IsSemiringHom.comp
| Mathlib/Deprecated/Ring.lean | 67 | 68 | theorem to_isAddMonoidHom (hf : IsSemiringHom f) : IsAddMonoidHom f :=
{ ‹IsSemiringHom f› with map_add := by | apply @‹IsSemiringHom f›.map_add }
|
import Mathlib.Data.Real.Pi.Bounds
import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.ConvexBody
-- TODO. Rewrite some of the FLT results on the disciminant using the definitions and results of
-- this file
namespace NumberField
open FiniteDimensional NumberField NumberField.InfinitePlace Matrix
open scoped Classical Real nonZeroDivisors
variable (K : Type*) [Field K] [NumberField K]
noncomputable abbrev discr : ℤ := Algebra.discr ℤ (RingOfIntegers.basis K)
theorem coe_discr : (discr K : ℚ) = Algebra.discr ℚ (integralBasis K) :=
(Algebra.discr_localizationLocalization ℤ _ K (RingOfIntegers.basis K)).symm
theorem discr_ne_zero : discr K ≠ 0 := by
rw [← (Int.cast_injective (α := ℚ)).ne_iff, coe_discr]
exact Algebra.discr_not_zero_of_basis ℚ (integralBasis K)
theorem discr_eq_discr {ι : Type*} [Fintype ι] [DecidableEq ι] (b : Basis ι ℤ (𝓞 K)) :
Algebra.discr ℤ b = discr K := by
let b₀ := Basis.reindex (RingOfIntegers.basis K) (Basis.indexEquiv (RingOfIntegers.basis K) b)
rw [Algebra.discr_eq_discr (𝓞 K) b b₀, Basis.coe_reindex, Algebra.discr_reindex]
| Mathlib/NumberTheory/NumberField/Discriminant.lean | 55 | 66 | theorem discr_eq_discr_of_algEquiv {L : Type*} [Field L] [NumberField L] (f : K ≃ₐ[ℚ] L) :
discr K = discr L := by |
let f₀ : 𝓞 K ≃ₗ[ℤ] 𝓞 L := (f.restrictScalars ℤ).mapIntegralClosure.toLinearEquiv
rw [← Rat.intCast_inj, coe_discr, Algebra.discr_eq_discr_of_algEquiv (integralBasis K) f,
← discr_eq_discr L ((RingOfIntegers.basis K).map f₀)]
change _ = algebraMap ℤ ℚ _
rw [← Algebra.discr_localizationLocalization ℤ (nonZeroDivisors ℤ) L]
congr
ext
simp only [Function.comp_apply, integralBasis_apply, Basis.localizationLocalization_apply,
Basis.map_apply]
rfl
|
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
| Mathlib/Analysis/Calculus/IteratedDeriv/Lemmas.lean | 69 | 72 | 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]
|
import Mathlib.MeasureTheory.Integral.SetIntegral
#align_import measure_theory.integral.average from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"
open ENNReal MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSpace Function
open scoped Topology ENNReal Convex
variable {α E F : Type*} {m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E]
[CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {μ ν : Measure α}
{s t : Set α}
namespace MeasureTheory
section ENNReal
variable (μ) {f g : α → ℝ≥0∞}
noncomputable def laverage (f : α → ℝ≥0∞) := ∫⁻ x, f x ∂(μ univ)⁻¹ • μ
#align measure_theory.laverage MeasureTheory.laverage
notation3 "⨍⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => laverage μ r
notation3 "⨍⁻ "(...)", "r:60:(scoped f => laverage volume f) => r
notation3 "⨍⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => laverage (Measure.restrict μ s) r
notation3 (prettyPrint := false)
"⨍⁻ "(...)" in "s", "r:60:(scoped f => laverage Measure.restrict volume s f) => r
@[simp]
theorem laverage_zero : ⨍⁻ _x, (0 : ℝ≥0∞) ∂μ = 0 := by rw [laverage, lintegral_zero]
#align measure_theory.laverage_zero MeasureTheory.laverage_zero
@[simp]
theorem laverage_zero_measure (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂(0 : Measure α) = 0 := by simp [laverage]
#align measure_theory.laverage_zero_measure MeasureTheory.laverage_zero_measure
theorem laverage_eq' (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂(μ univ)⁻¹ • μ := rfl
#align measure_theory.laverage_eq' MeasureTheory.laverage_eq'
theorem laverage_eq (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = (∫⁻ x, f x ∂μ) / μ univ := by
rw [laverage_eq', lintegral_smul_measure, ENNReal.div_eq_inv_mul]
#align measure_theory.laverage_eq MeasureTheory.laverage_eq
theorem laverage_eq_lintegral [IsProbabilityMeasure μ] (f : α → ℝ≥0∞) :
⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ := by rw [laverage, measure_univ, inv_one, one_smul]
#align measure_theory.laverage_eq_lintegral MeasureTheory.laverage_eq_lintegral
@[simp]
theorem measure_mul_laverage [IsFiniteMeasure μ] (f : α → ℝ≥0∞) :
μ univ * ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ := by
rcases eq_or_ne μ 0 with hμ | hμ
· rw [hμ, lintegral_zero_measure, laverage_zero_measure, mul_zero]
· rw [laverage_eq, ENNReal.mul_div_cancel' (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)]
#align measure_theory.measure_mul_laverage MeasureTheory.measure_mul_laverage
theorem setLaverage_eq (f : α → ℝ≥0∞) (s : Set α) :
⨍⁻ x in s, f x ∂μ = (∫⁻ x in s, f x ∂μ) / μ s := by rw [laverage_eq, restrict_apply_univ]
#align measure_theory.set_laverage_eq MeasureTheory.setLaverage_eq
theorem setLaverage_eq' (f : α → ℝ≥0∞) (s : Set α) :
⨍⁻ x in s, f x ∂μ = ∫⁻ x, f x ∂(μ s)⁻¹ • μ.restrict s := by
simp only [laverage_eq', restrict_apply_univ]
#align measure_theory.set_laverage_eq' MeasureTheory.setLaverage_eq'
variable {μ}
theorem laverage_congr {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) : ⨍⁻ x, f x ∂μ = ⨍⁻ x, g x ∂μ := by
simp only [laverage_eq, lintegral_congr_ae h]
#align measure_theory.laverage_congr MeasureTheory.laverage_congr
theorem setLaverage_congr (h : s =ᵐ[μ] t) : ⨍⁻ x in s, f x ∂μ = ⨍⁻ x in t, f x ∂μ := by
simp only [setLaverage_eq, set_lintegral_congr h, measure_congr h]
#align measure_theory.set_laverage_congr MeasureTheory.setLaverage_congr
theorem setLaverage_congr_fun (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) :
⨍⁻ x in s, f x ∂μ = ⨍⁻ x in s, g x ∂μ := by
simp only [laverage_eq, set_lintegral_congr_fun hs h]
#align measure_theory.set_laverage_congr_fun MeasureTheory.setLaverage_congr_fun
theorem laverage_lt_top (hf : ∫⁻ x, f x ∂μ ≠ ∞) : ⨍⁻ x, f x ∂μ < ∞ := by
obtain rfl | hμ := eq_or_ne μ 0
· simp
· rw [laverage_eq]
exact div_lt_top hf (measure_univ_ne_zero.2 hμ)
#align measure_theory.laverage_lt_top MeasureTheory.laverage_lt_top
theorem setLaverage_lt_top : ∫⁻ x in s, f x ∂μ ≠ ∞ → ⨍⁻ x in s, f x ∂μ < ∞ :=
laverage_lt_top
#align measure_theory.set_laverage_lt_top MeasureTheory.setLaverage_lt_top
theorem laverage_add_measure :
⨍⁻ x, f x ∂(μ + ν) =
μ univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂μ + ν univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂ν := by
by_cases hμ : IsFiniteMeasure μ; swap
· rw [not_isFiniteMeasure_iff] at hμ
simp [laverage_eq, hμ]
by_cases hν : IsFiniteMeasure ν; swap
· rw [not_isFiniteMeasure_iff] at hν
simp [laverage_eq, hν]
haveI := hμ; haveI := hν
simp only [← ENNReal.mul_div_right_comm, measure_mul_laverage, ← ENNReal.add_div,
← lintegral_add_measure, ← Measure.add_apply, ← laverage_eq]
#align measure_theory.laverage_add_measure MeasureTheory.laverage_add_measure
theorem measure_mul_setLaverage (f : α → ℝ≥0∞) (h : μ s ≠ ∞) :
μ s * ⨍⁻ x in s, f x ∂μ = ∫⁻ x in s, f x ∂μ := by
have := Fact.mk h.lt_top
rw [← measure_mul_laverage, restrict_apply_univ]
#align measure_theory.measure_mul_set_laverage MeasureTheory.measure_mul_setLaverage
theorem laverage_union (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ) :
⨍⁻ x in s ∪ t, f x ∂μ =
μ s / (μ s + μ t) * ⨍⁻ x in s, f x ∂μ + μ t / (μ s + μ t) * ⨍⁻ x in t, f x ∂μ := by
rw [restrict_union₀ hd ht, laverage_add_measure, restrict_apply_univ, restrict_apply_univ]
#align measure_theory.laverage_union MeasureTheory.laverage_union
| Mathlib/MeasureTheory/Integral/Average.lean | 195 | 202 | theorem laverage_union_mem_openSegment (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
(hs₀ : μ s ≠ 0) (ht₀ : μ t ≠ 0) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) :
⨍⁻ x in s ∪ t, f x ∂μ ∈ openSegment ℝ≥0∞ (⨍⁻ x in s, f x ∂μ) (⨍⁻ x in t, f x ∂μ) := by |
refine
⟨μ s / (μ s + μ t), μ t / (μ s + μ t), ENNReal.div_pos hs₀ <| add_ne_top.2 ⟨hsμ, htμ⟩,
ENNReal.div_pos ht₀ <| add_ne_top.2 ⟨hsμ, htμ⟩, ?_, (laverage_union hd ht).symm⟩
rw [← ENNReal.add_div,
ENNReal.div_self (add_eq_zero.not.2 fun h => hs₀ h.1) (add_ne_top.2 ⟨hsμ, htμ⟩)]
|
import Mathlib.Algebra.GroupWithZero.Indicator
import Mathlib.Topology.ContinuousOn
import Mathlib.Topology.Instances.ENNReal
#align_import topology.semicontinuous from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
open Topology ENNReal
open Set Function Filter
variable {α : Type*} [TopologicalSpace α] {β : Type*} [Preorder β] {f g : α → β} {x : α}
{s t : Set α} {y z : β}
def LowerSemicontinuousWithinAt (f : α → β) (s : Set α) (x : α) :=
∀ y < f x, ∀ᶠ x' in 𝓝[s] x, y < f x'
#align lower_semicontinuous_within_at LowerSemicontinuousWithinAt
def LowerSemicontinuousOn (f : α → β) (s : Set α) :=
∀ x ∈ s, LowerSemicontinuousWithinAt f s x
#align lower_semicontinuous_on LowerSemicontinuousOn
def LowerSemicontinuousAt (f : α → β) (x : α) :=
∀ y < f x, ∀ᶠ x' in 𝓝 x, y < f x'
#align lower_semicontinuous_at LowerSemicontinuousAt
def LowerSemicontinuous (f : α → β) :=
∀ x, LowerSemicontinuousAt f x
#align lower_semicontinuous LowerSemicontinuous
def UpperSemicontinuousWithinAt (f : α → β) (s : Set α) (x : α) :=
∀ y, f x < y → ∀ᶠ x' in 𝓝[s] x, f x' < y
#align upper_semicontinuous_within_at UpperSemicontinuousWithinAt
def UpperSemicontinuousOn (f : α → β) (s : Set α) :=
∀ x ∈ s, UpperSemicontinuousWithinAt f s x
#align upper_semicontinuous_on UpperSemicontinuousOn
def UpperSemicontinuousAt (f : α → β) (x : α) :=
∀ y, f x < y → ∀ᶠ x' in 𝓝 x, f x' < y
#align upper_semicontinuous_at UpperSemicontinuousAt
def UpperSemicontinuous (f : α → β) :=
∀ x, UpperSemicontinuousAt f x
#align upper_semicontinuous UpperSemicontinuous
theorem LowerSemicontinuousWithinAt.mono (h : LowerSemicontinuousWithinAt f s x) (hst : t ⊆ s) :
LowerSemicontinuousWithinAt f t x := fun y hy =>
Filter.Eventually.filter_mono (nhdsWithin_mono _ hst) (h y hy)
#align lower_semicontinuous_within_at.mono LowerSemicontinuousWithinAt.mono
theorem lowerSemicontinuousWithinAt_univ_iff :
LowerSemicontinuousWithinAt f univ x ↔ LowerSemicontinuousAt f x := by
simp [LowerSemicontinuousWithinAt, LowerSemicontinuousAt, nhdsWithin_univ]
#align lower_semicontinuous_within_at_univ_iff lowerSemicontinuousWithinAt_univ_iff
theorem LowerSemicontinuousAt.lowerSemicontinuousWithinAt (s : Set α)
(h : LowerSemicontinuousAt f x) : LowerSemicontinuousWithinAt f s x := fun y hy =>
Filter.Eventually.filter_mono nhdsWithin_le_nhds (h y hy)
#align lower_semicontinuous_at.lower_semicontinuous_within_at LowerSemicontinuousAt.lowerSemicontinuousWithinAt
theorem LowerSemicontinuousOn.lowerSemicontinuousWithinAt (h : LowerSemicontinuousOn f s)
(hx : x ∈ s) : LowerSemicontinuousWithinAt f s x :=
h x hx
#align lower_semicontinuous_on.lower_semicontinuous_within_at LowerSemicontinuousOn.lowerSemicontinuousWithinAt
theorem LowerSemicontinuousOn.mono (h : LowerSemicontinuousOn f s) (hst : t ⊆ s) :
LowerSemicontinuousOn f t := fun x hx => (h x (hst hx)).mono hst
#align lower_semicontinuous_on.mono LowerSemicontinuousOn.mono
theorem lowerSemicontinuousOn_univ_iff : LowerSemicontinuousOn f univ ↔ LowerSemicontinuous f := by
simp [LowerSemicontinuousOn, LowerSemicontinuous, lowerSemicontinuousWithinAt_univ_iff]
#align lower_semicontinuous_on_univ_iff lowerSemicontinuousOn_univ_iff
theorem LowerSemicontinuous.lowerSemicontinuousAt (h : LowerSemicontinuous f) (x : α) :
LowerSemicontinuousAt f x :=
h x
#align lower_semicontinuous.lower_semicontinuous_at LowerSemicontinuous.lowerSemicontinuousAt
theorem LowerSemicontinuous.lowerSemicontinuousWithinAt (h : LowerSemicontinuous f) (s : Set α)
(x : α) : LowerSemicontinuousWithinAt f s x :=
(h x).lowerSemicontinuousWithinAt s
#align lower_semicontinuous.lower_semicontinuous_within_at LowerSemicontinuous.lowerSemicontinuousWithinAt
theorem LowerSemicontinuous.lowerSemicontinuousOn (h : LowerSemicontinuous f) (s : Set α) :
LowerSemicontinuousOn f s := fun x _hx => h.lowerSemicontinuousWithinAt s x
#align lower_semicontinuous.lower_semicontinuous_on LowerSemicontinuous.lowerSemicontinuousOn
theorem lowerSemicontinuousWithinAt_const : LowerSemicontinuousWithinAt (fun _x => z) s x :=
fun _y hy => Filter.eventually_of_forall fun _x => hy
#align lower_semicontinuous_within_at_const lowerSemicontinuousWithinAt_const
theorem lowerSemicontinuousAt_const : LowerSemicontinuousAt (fun _x => z) x := fun _y hy =>
Filter.eventually_of_forall fun _x => hy
#align lower_semicontinuous_at_const lowerSemicontinuousAt_const
theorem lowerSemicontinuousOn_const : LowerSemicontinuousOn (fun _x => z) s := fun _x _hx =>
lowerSemicontinuousWithinAt_const
#align lower_semicontinuous_on_const lowerSemicontinuousOn_const
theorem lowerSemicontinuous_const : LowerSemicontinuous fun _x : α => z := fun _x =>
lowerSemicontinuousAt_const
#align lower_semicontinuous_const lowerSemicontinuous_const
section
variable [Zero β]
theorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) :
LowerSemicontinuous (indicator s fun _x => y) := by
intro x z hz
by_cases h : x ∈ s <;> simp [h] at hz
· filter_upwards [hs.mem_nhds h]
simp (config := { contextual := true }) [hz]
· refine Filter.eventually_of_forall fun x' => ?_
by_cases h' : x' ∈ s <;> simp [h', hz.trans_le hy, hz]
#align is_open.lower_semicontinuous_indicator IsOpen.lowerSemicontinuous_indicator
theorem IsOpen.lowerSemicontinuousOn_indicator (hs : IsOpen s) (hy : 0 ≤ y) :
LowerSemicontinuousOn (indicator s fun _x => y) t :=
(hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousOn t
#align is_open.lower_semicontinuous_on_indicator IsOpen.lowerSemicontinuousOn_indicator
theorem IsOpen.lowerSemicontinuousAt_indicator (hs : IsOpen s) (hy : 0 ≤ y) :
LowerSemicontinuousAt (indicator s fun _x => y) x :=
(hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousAt x
#align is_open.lower_semicontinuous_at_indicator IsOpen.lowerSemicontinuousAt_indicator
theorem IsOpen.lowerSemicontinuousWithinAt_indicator (hs : IsOpen s) (hy : 0 ≤ y) :
LowerSemicontinuousWithinAt (indicator s fun _x => y) t x :=
(hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousWithinAt t x
#align is_open.lower_semicontinuous_within_at_indicator IsOpen.lowerSemicontinuousWithinAt_indicator
theorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) :
LowerSemicontinuous (indicator s fun _x => y) := by
intro x z hz
by_cases h : x ∈ s <;> simp [h] at hz
· refine Filter.eventually_of_forall fun x' => ?_
by_cases h' : x' ∈ s <;> simp [h', hz, hz.trans_le hy]
· filter_upwards [hs.isOpen_compl.mem_nhds h]
simp (config := { contextual := true }) [hz]
#align is_closed.lower_semicontinuous_indicator IsClosed.lowerSemicontinuous_indicator
theorem IsClosed.lowerSemicontinuousOn_indicator (hs : IsClosed s) (hy : y ≤ 0) :
LowerSemicontinuousOn (indicator s fun _x => y) t :=
(hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousOn t
#align is_closed.lower_semicontinuous_on_indicator IsClosed.lowerSemicontinuousOn_indicator
theorem IsClosed.lowerSemicontinuousAt_indicator (hs : IsClosed s) (hy : y ≤ 0) :
LowerSemicontinuousAt (indicator s fun _x => y) x :=
(hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousAt x
#align is_closed.lower_semicontinuous_at_indicator IsClosed.lowerSemicontinuousAt_indicator
theorem IsClosed.lowerSemicontinuousWithinAt_indicator (hs : IsClosed s) (hy : y ≤ 0) :
LowerSemicontinuousWithinAt (indicator s fun _x => y) t x :=
(hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousWithinAt t x
#align is_closed.lower_semicontinuous_within_at_indicator IsClosed.lowerSemicontinuousWithinAt_indicator
end
theorem lowerSemicontinuous_iff_isOpen_preimage :
LowerSemicontinuous f ↔ ∀ y, IsOpen (f ⁻¹' Ioi y) :=
⟨fun H y => isOpen_iff_mem_nhds.2 fun x hx => H x y hx, fun H _x y y_lt =>
IsOpen.mem_nhds (H y) y_lt⟩
#align lower_semicontinuous_iff_is_open_preimage lowerSemicontinuous_iff_isOpen_preimage
theorem LowerSemicontinuous.isOpen_preimage (hf : LowerSemicontinuous f) (y : β) :
IsOpen (f ⁻¹' Ioi y) :=
lowerSemicontinuous_iff_isOpen_preimage.1 hf y
#align lower_semicontinuous.is_open_preimage LowerSemicontinuous.isOpen_preimage
section
variable {γ : Type*} [LinearOrder γ]
| Mathlib/Topology/Semicontinuous.lean | 283 | 286 | theorem lowerSemicontinuous_iff_isClosed_preimage {f : α → γ} :
LowerSemicontinuous f ↔ ∀ y, IsClosed (f ⁻¹' Iic y) := by |
rw [lowerSemicontinuous_iff_isOpen_preimage]
simp only [← isOpen_compl_iff, ← preimage_compl, compl_Iic]
|
import Mathlib.Tactic.Qify
import Mathlib.Data.ZMod.Basic
import Mathlib.NumberTheory.DiophantineApproximation
import Mathlib.NumberTheory.Zsqrtd.Basic
#align_import number_theory.pell from "leanprover-community/mathlib"@"7ad820c4997738e2f542f8a20f32911f52020e26"
namespace Pell
open Zsqrtd
theorem is_pell_solution_iff_mem_unitary {d : ℤ} {a : ℤ√d} :
a.re ^ 2 - d * a.im ^ 2 = 1 ↔ a ∈ unitary (ℤ√d) := by
rw [← norm_eq_one_iff_mem_unitary, norm_def, sq, sq, ← mul_assoc]
#align pell.is_pell_solution_iff_mem_unitary Pell.is_pell_solution_iff_mem_unitary
-- We use `solution₁ d` to allow for a more general structure `solution d m` that
-- encodes solutions to `x^2 - d*y^2 = m` to be added later.
def Solution₁ (d : ℤ) : Type :=
↥(unitary (ℤ√d))
#align pell.solution₁ Pell.Solution₁
section Existence
variable {d : ℤ}
open Set Real
theorem exists_of_not_isSquare (h₀ : 0 < d) (hd : ¬IsSquare d) :
∃ x y : ℤ, x ^ 2 - d * y ^ 2 = 1 ∧ y ≠ 0 := by
let ξ : ℝ := √d
have hξ : Irrational ξ := by
refine irrational_nrt_of_notint_nrt 2 d (sq_sqrt <| Int.cast_nonneg.mpr h₀.le) ?_ two_pos
rintro ⟨x, hx⟩
refine hd ⟨x, @Int.cast_injective ℝ _ _ d (x * x) ?_⟩
rw [← sq_sqrt <| Int.cast_nonneg.mpr h₀.le, Int.cast_mul, ← hx, sq]
obtain ⟨M, hM₁⟩ := exists_int_gt (2 * |ξ| + 1)
have hM : {q : ℚ | |q.1 ^ 2 - d * (q.2 : ℤ) ^ 2| < M}.Infinite := by
refine Infinite.mono (fun q h => ?_) (infinite_rat_abs_sub_lt_one_div_den_sq_of_irrational hξ)
have h0 : 0 < (q.2 : ℝ) ^ 2 := pow_pos (Nat.cast_pos.mpr q.pos) 2
have h1 : (q.num : ℝ) / (q.den : ℝ) = q := mod_cast q.num_div_den
rw [mem_setOf, abs_sub_comm, ← @Int.cast_lt ℝ, ← div_lt_div_right (abs_pos_of_pos h0)]
push_cast
rw [← abs_div, abs_sq, sub_div, mul_div_cancel_right₀ _ h0.ne', ← div_pow, h1, ←
sq_sqrt (Int.cast_pos.mpr h₀).le, sq_sub_sq, abs_mul, ← mul_one_div]
refine mul_lt_mul'' (((abs_add ξ q).trans ?_).trans_lt hM₁) h (abs_nonneg _) (abs_nonneg _)
rw [two_mul, add_assoc, add_le_add_iff_left, ← sub_le_iff_le_add']
rw [mem_setOf, abs_sub_comm] at h
refine (abs_sub_abs_le_abs_sub (q : ℝ) ξ).trans (h.le.trans ?_)
rw [div_le_one h0, one_le_sq_iff_one_le_abs, Nat.abs_cast, Nat.one_le_cast]
exact q.pos
obtain ⟨m, hm⟩ : ∃ m : ℤ, {q : ℚ | q.1 ^ 2 - d * (q.den : ℤ) ^ 2 = m}.Infinite := by
contrapose! hM
simp only [not_infinite] at hM ⊢
refine (congr_arg _ (ext fun x => ?_)).mp (Finite.biUnion (finite_Ioo (-M) M) fun m _ => hM m)
simp only [abs_lt, mem_setOf, mem_Ioo, mem_iUnion, exists_prop, exists_eq_right']
have hm₀ : m ≠ 0 := by
rintro rfl
obtain ⟨q, hq⟩ := hm.nonempty
rw [mem_setOf, sub_eq_zero, mul_comm] at hq
obtain ⟨a, ha⟩ := (Int.pow_dvd_pow_iff two_ne_zero).mp ⟨d, hq⟩
rw [ha, mul_pow, mul_right_inj' (pow_pos (Int.natCast_pos.mpr q.pos) 2).ne'] at hq
exact hd ⟨a, sq a ▸ hq.symm⟩
haveI := neZero_iff.mpr (Int.natAbs_ne_zero.mpr hm₀)
let f : ℚ → ZMod m.natAbs × ZMod m.natAbs := fun q => (q.num, q.den)
obtain ⟨q₁, h₁ : q₁.num ^ 2 - d * (q₁.den : ℤ) ^ 2 = m,
q₂, h₂ : q₂.num ^ 2 - d * (q₂.den : ℤ) ^ 2 = m, hne, hqf⟩ :=
hm.exists_ne_map_eq_of_mapsTo (mapsTo_univ f _) finite_univ
obtain ⟨hq1 : (q₁.num : ZMod m.natAbs) = q₂.num, hq2 : (q₁.den : ZMod m.natAbs) = q₂.den⟩ :=
Prod.ext_iff.mp hqf
have hd₁ : m ∣ q₁.num * q₂.num - d * (q₁.den * q₂.den) := by
rw [← Int.natAbs_dvd, ← ZMod.intCast_zmod_eq_zero_iff_dvd]
push_cast
rw [hq1, hq2, ← sq, ← sq]
norm_cast
rw [ZMod.intCast_zmod_eq_zero_iff_dvd, Int.natAbs_dvd, Nat.cast_pow, ← h₂]
have hd₂ : m ∣ q₁.num * q₂.den - q₂.num * q₁.den := by
rw [← Int.natAbs_dvd, ← ZMod.intCast_eq_intCast_iff_dvd_sub]
push_cast
rw [hq1, hq2]
replace hm₀ : (m : ℚ) ≠ 0 := Int.cast_ne_zero.mpr hm₀
refine ⟨(q₁.num * q₂.num - d * (q₁.den * q₂.den)) / m, (q₁.num * q₂.den - q₂.num * q₁.den) / m,
?_, ?_⟩
· qify [hd₁, hd₂]
field_simp [hm₀]
norm_cast
conv_rhs =>
rw [sq]
congr
· rw [← h₁]
· rw [← h₂]
push_cast
ring
· qify [hd₂]
refine div_ne_zero_iff.mpr ⟨?_, hm₀⟩
exact mod_cast mt sub_eq_zero.mp (mt Rat.eq_iff_mul_eq_mul.mpr hne)
#align pell.exists_of_not_is_square Pell.exists_of_not_isSquare
| Mathlib/NumberTheory/Pell.lean | 439 | 444 | theorem exists_iff_not_isSquare (h₀ : 0 < d) :
(∃ x y : ℤ, x ^ 2 - d * y ^ 2 = 1 ∧ y ≠ 0) ↔ ¬IsSquare d := by |
refine ⟨?_, exists_of_not_isSquare h₀⟩
rintro ⟨x, y, hxy, hy⟩ ⟨a, rfl⟩
rw [← sq, ← mul_pow, sq_sub_sq] at hxy
simpa [hy, mul_self_pos.mp h₀, sub_eq_add_neg, eq_neg_self_iff] using Int.eq_of_mul_eq_one hxy
|
import Mathlib.Topology.Order.MonotoneContinuity
import Mathlib.Topology.Algebra.Order.LiminfLimsup
import Mathlib.Topology.Instances.NNReal
import Mathlib.Topology.EMetricSpace.Lipschitz
import Mathlib.Topology.Metrizable.Basic
import Mathlib.Topology.Order.T5
#align_import topology.instances.ennreal from "leanprover-community/mathlib"@"ec4b2eeb50364487f80421c0b4c41328a611f30d"
noncomputable section
open Set Filter Metric Function
open scoped Classical Topology ENNReal NNReal Filter
variable {α : Type*} {β : Type*} {γ : Type*}
namespace ENNReal
variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0} {x y z : ℝ≥0∞} {ε ε₁ ε₂ : ℝ≥0∞} {s : Set ℝ≥0∞}
section TopologicalSpace
open TopologicalSpace
instance : TopologicalSpace ℝ≥0∞ := Preorder.topology ℝ≥0∞
instance : OrderTopology ℝ≥0∞ := ⟨rfl⟩
-- short-circuit type class inference
instance : T2Space ℝ≥0∞ := inferInstance
instance : T5Space ℝ≥0∞ := inferInstance
instance : T4Space ℝ≥0∞ := inferInstance
instance : SecondCountableTopology ℝ≥0∞ :=
orderIsoUnitIntervalBirational.toHomeomorph.embedding.secondCountableTopology
instance : MetrizableSpace ENNReal :=
orderIsoUnitIntervalBirational.toHomeomorph.embedding.metrizableSpace
theorem embedding_coe : Embedding ((↑) : ℝ≥0 → ℝ≥0∞) :=
coe_strictMono.embedding_of_ordConnected <| by rw [range_coe']; exact ordConnected_Iio
#align ennreal.embedding_coe ENNReal.embedding_coe
theorem isOpen_ne_top : IsOpen { a : ℝ≥0∞ | a ≠ ∞ } := isOpen_ne
#align ennreal.is_open_ne_top ENNReal.isOpen_ne_top
theorem isOpen_Ico_zero : IsOpen (Ico 0 b) := by
rw [ENNReal.Ico_eq_Iio]
exact isOpen_Iio
#align ennreal.is_open_Ico_zero ENNReal.isOpen_Ico_zero
theorem openEmbedding_coe : OpenEmbedding ((↑) : ℝ≥0 → ℝ≥0∞) :=
⟨embedding_coe, by rw [range_coe']; exact isOpen_Iio⟩
#align ennreal.open_embedding_coe ENNReal.openEmbedding_coe
theorem coe_range_mem_nhds : range ((↑) : ℝ≥0 → ℝ≥0∞) ∈ 𝓝 (r : ℝ≥0∞) :=
IsOpen.mem_nhds openEmbedding_coe.isOpen_range <| mem_range_self _
#align ennreal.coe_range_mem_nhds ENNReal.coe_range_mem_nhds
@[norm_cast]
theorem tendsto_coe {f : Filter α} {m : α → ℝ≥0} {a : ℝ≥0} :
Tendsto (fun a => (m a : ℝ≥0∞)) f (𝓝 ↑a) ↔ Tendsto m f (𝓝 a) :=
embedding_coe.tendsto_nhds_iff.symm
#align ennreal.tendsto_coe ENNReal.tendsto_coe
theorem continuous_coe : Continuous ((↑) : ℝ≥0 → ℝ≥0∞) :=
embedding_coe.continuous
#align ennreal.continuous_coe ENNReal.continuous_coe
theorem continuous_coe_iff {α} [TopologicalSpace α] {f : α → ℝ≥0} :
(Continuous fun a => (f a : ℝ≥0∞)) ↔ Continuous f :=
embedding_coe.continuous_iff.symm
#align ennreal.continuous_coe_iff ENNReal.continuous_coe_iff
theorem nhds_coe {r : ℝ≥0} : 𝓝 (r : ℝ≥0∞) = (𝓝 r).map (↑) :=
(openEmbedding_coe.map_nhds_eq r).symm
#align ennreal.nhds_coe ENNReal.nhds_coe
theorem tendsto_nhds_coe_iff {α : Type*} {l : Filter α} {x : ℝ≥0} {f : ℝ≥0∞ → α} :
Tendsto f (𝓝 ↑x) l ↔ Tendsto (f ∘ (↑) : ℝ≥0 → α) (𝓝 x) l := by
rw [nhds_coe, tendsto_map'_iff]
#align ennreal.tendsto_nhds_coe_iff ENNReal.tendsto_nhds_coe_iff
theorem continuousAt_coe_iff {α : Type*} [TopologicalSpace α] {x : ℝ≥0} {f : ℝ≥0∞ → α} :
ContinuousAt f ↑x ↔ ContinuousAt (f ∘ (↑) : ℝ≥0 → α) x :=
tendsto_nhds_coe_iff
#align ennreal.continuous_at_coe_iff ENNReal.continuousAt_coe_iff
theorem nhds_coe_coe {r p : ℝ≥0} :
𝓝 ((r : ℝ≥0∞), (p : ℝ≥0∞)) = (𝓝 (r, p)).map fun p : ℝ≥0 × ℝ≥0 => (↑p.1, ↑p.2) :=
((openEmbedding_coe.prod openEmbedding_coe).map_nhds_eq (r, p)).symm
#align ennreal.nhds_coe_coe ENNReal.nhds_coe_coe
theorem continuous_ofReal : Continuous ENNReal.ofReal :=
(continuous_coe_iff.2 continuous_id).comp continuous_real_toNNReal
#align ennreal.continuous_of_real ENNReal.continuous_ofReal
theorem tendsto_ofReal {f : Filter α} {m : α → ℝ} {a : ℝ} (h : Tendsto m f (𝓝 a)) :
Tendsto (fun a => ENNReal.ofReal (m a)) f (𝓝 (ENNReal.ofReal a)) :=
(continuous_ofReal.tendsto a).comp h
#align ennreal.tendsto_of_real ENNReal.tendsto_ofReal
theorem tendsto_toNNReal {a : ℝ≥0∞} (ha : a ≠ ∞) :
Tendsto ENNReal.toNNReal (𝓝 a) (𝓝 a.toNNReal) := by
lift a to ℝ≥0 using ha
rw [nhds_coe, tendsto_map'_iff]
exact tendsto_id
#align ennreal.tendsto_to_nnreal ENNReal.tendsto_toNNReal
theorem eventuallyEq_of_toReal_eventuallyEq {l : Filter α} {f g : α → ℝ≥0∞}
(hfi : ∀ᶠ x in l, f x ≠ ∞) (hgi : ∀ᶠ x in l, g x ≠ ∞)
(hfg : (fun x => (f x).toReal) =ᶠ[l] fun x => (g x).toReal) : f =ᶠ[l] g := by
filter_upwards [hfi, hgi, hfg] with _ hfx hgx _
rwa [← ENNReal.toReal_eq_toReal hfx hgx]
#align ennreal.eventually_eq_of_to_real_eventually_eq ENNReal.eventuallyEq_of_toReal_eventuallyEq
theorem continuousOn_toNNReal : ContinuousOn ENNReal.toNNReal { a | a ≠ ∞ } := fun _a ha =>
ContinuousAt.continuousWithinAt (tendsto_toNNReal ha)
#align ennreal.continuous_on_to_nnreal ENNReal.continuousOn_toNNReal
theorem tendsto_toReal {a : ℝ≥0∞} (ha : a ≠ ∞) : Tendsto ENNReal.toReal (𝓝 a) (𝓝 a.toReal) :=
NNReal.tendsto_coe.2 <| tendsto_toNNReal ha
#align ennreal.tendsto_to_real ENNReal.tendsto_toReal
lemma continuousOn_toReal : ContinuousOn ENNReal.toReal { a | a ≠ ∞ } :=
NNReal.continuous_coe.comp_continuousOn continuousOn_toNNReal
lemma continuousAt_toReal (hx : x ≠ ∞) : ContinuousAt ENNReal.toReal x :=
continuousOn_toReal.continuousAt (isOpen_ne_top.mem_nhds_iff.mpr hx)
def neTopHomeomorphNNReal : { a | a ≠ ∞ } ≃ₜ ℝ≥0 where
toEquiv := neTopEquivNNReal
continuous_toFun := continuousOn_iff_continuous_restrict.1 continuousOn_toNNReal
continuous_invFun := continuous_coe.subtype_mk _
#align ennreal.ne_top_homeomorph_nnreal ENNReal.neTopHomeomorphNNReal
def ltTopHomeomorphNNReal : { a | a < ∞ } ≃ₜ ℝ≥0 := by
refine (Homeomorph.setCongr ?_).trans neTopHomeomorphNNReal
simp only [mem_setOf_eq, lt_top_iff_ne_top]
#align ennreal.lt_top_homeomorph_nnreal ENNReal.ltTopHomeomorphNNReal
theorem nhds_top : 𝓝 ∞ = ⨅ (a) (_ : a ≠ ∞), 𝓟 (Ioi a) :=
nhds_top_order.trans <| by simp [lt_top_iff_ne_top, Ioi]
#align ennreal.nhds_top ENNReal.nhds_top
theorem nhds_top' : 𝓝 ∞ = ⨅ r : ℝ≥0, 𝓟 (Ioi ↑r) :=
nhds_top.trans <| iInf_ne_top _
#align ennreal.nhds_top' ENNReal.nhds_top'
theorem nhds_top_basis : (𝓝 ∞).HasBasis (fun a => a < ∞) fun a => Ioi a :=
_root_.nhds_top_basis
#align ennreal.nhds_top_basis ENNReal.nhds_top_basis
theorem tendsto_nhds_top_iff_nnreal {m : α → ℝ≥0∞} {f : Filter α} :
Tendsto m f (𝓝 ∞) ↔ ∀ x : ℝ≥0, ∀ᶠ a in f, ↑x < m a := by
simp only [nhds_top', tendsto_iInf, tendsto_principal, mem_Ioi]
#align ennreal.tendsto_nhds_top_iff_nnreal ENNReal.tendsto_nhds_top_iff_nnreal
theorem tendsto_nhds_top_iff_nat {m : α → ℝ≥0∞} {f : Filter α} :
Tendsto m f (𝓝 ∞) ↔ ∀ n : ℕ, ∀ᶠ a in f, ↑n < m a :=
tendsto_nhds_top_iff_nnreal.trans
⟨fun h n => by simpa only [ENNReal.coe_natCast] using h n, fun h x =>
let ⟨n, hn⟩ := exists_nat_gt x
(h n).mono fun y => lt_trans <| by rwa [← ENNReal.coe_natCast, coe_lt_coe]⟩
#align ennreal.tendsto_nhds_top_iff_nat ENNReal.tendsto_nhds_top_iff_nat
theorem tendsto_nhds_top {m : α → ℝ≥0∞} {f : Filter α} (h : ∀ n : ℕ, ∀ᶠ a in f, ↑n < m a) :
Tendsto m f (𝓝 ∞) :=
tendsto_nhds_top_iff_nat.2 h
#align ennreal.tendsto_nhds_top ENNReal.tendsto_nhds_top
theorem tendsto_nat_nhds_top : Tendsto (fun n : ℕ => ↑n) atTop (𝓝 ∞) :=
tendsto_nhds_top fun n =>
mem_atTop_sets.2 ⟨n + 1, fun _m hm => mem_setOf.2 <| Nat.cast_lt.2 <| Nat.lt_of_succ_le hm⟩
#align ennreal.tendsto_nat_nhds_top ENNReal.tendsto_nat_nhds_top
@[simp, norm_cast]
theorem tendsto_coe_nhds_top {f : α → ℝ≥0} {l : Filter α} :
Tendsto (fun x => (f x : ℝ≥0∞)) l (𝓝 ∞) ↔ Tendsto f l atTop := by
rw [tendsto_nhds_top_iff_nnreal, atTop_basis_Ioi.tendsto_right_iff]; simp
#align ennreal.tendsto_coe_nhds_top ENNReal.tendsto_coe_nhds_top
theorem tendsto_ofReal_atTop : Tendsto ENNReal.ofReal atTop (𝓝 ∞) :=
tendsto_coe_nhds_top.2 tendsto_real_toNNReal_atTop
#align ennreal.tendsto_of_real_at_top ENNReal.tendsto_ofReal_atTop
theorem nhds_zero : 𝓝 (0 : ℝ≥0∞) = ⨅ (a) (_ : a ≠ 0), 𝓟 (Iio a) :=
nhds_bot_order.trans <| by simp [pos_iff_ne_zero, Iio]
#align ennreal.nhds_zero ENNReal.nhds_zero
theorem nhds_zero_basis : (𝓝 (0 : ℝ≥0∞)).HasBasis (fun a : ℝ≥0∞ => 0 < a) fun a => Iio a :=
nhds_bot_basis
#align ennreal.nhds_zero_basis ENNReal.nhds_zero_basis
theorem nhds_zero_basis_Iic : (𝓝 (0 : ℝ≥0∞)).HasBasis (fun a : ℝ≥0∞ => 0 < a) Iic :=
nhds_bot_basis_Iic
#align ennreal.nhds_zero_basis_Iic ENNReal.nhds_zero_basis_Iic
-- Porting note (#11215): TODO: add a TC for `≠ ∞`?
@[instance]
theorem nhdsWithin_Ioi_coe_neBot {r : ℝ≥0} : (𝓝[>] (r : ℝ≥0∞)).NeBot :=
nhdsWithin_Ioi_self_neBot' ⟨∞, ENNReal.coe_lt_top⟩
#align ennreal.nhds_within_Ioi_coe_ne_bot ENNReal.nhdsWithin_Ioi_coe_neBot
@[instance]
theorem nhdsWithin_Ioi_zero_neBot : (𝓝[>] (0 : ℝ≥0∞)).NeBot :=
nhdsWithin_Ioi_coe_neBot
#align ennreal.nhds_within_Ioi_zero_ne_bot ENNReal.nhdsWithin_Ioi_zero_neBot
@[instance]
theorem nhdsWithin_Ioi_one_neBot : (𝓝[>] (1 : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_coe_neBot
@[instance]
theorem nhdsWithin_Ioi_nat_neBot (n : ℕ) : (𝓝[>] (n : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_coe_neBot
@[instance]
theorem nhdsWithin_Ioi_ofNat_nebot (n : ℕ) [n.AtLeastTwo] :
(𝓝[>] (OfNat.ofNat n : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_coe_neBot
@[instance]
theorem nhdsWithin_Iio_neBot [NeZero x] : (𝓝[<] x).NeBot :=
nhdsWithin_Iio_self_neBot' ⟨0, NeZero.pos x⟩
theorem hasBasis_nhds_of_ne_top' (xt : x ≠ ∞) :
(𝓝 x).HasBasis (· ≠ 0) (fun ε => Icc (x - ε) (x + ε)) := by
rcases (zero_le x).eq_or_gt with rfl | x0
· simp_rw [zero_tsub, zero_add, ← bot_eq_zero, Icc_bot, ← bot_lt_iff_ne_bot]
exact nhds_bot_basis_Iic
· refine (nhds_basis_Ioo' ⟨_, x0⟩ ⟨_, xt.lt_top⟩).to_hasBasis ?_ fun ε ε0 => ?_
· rintro ⟨a, b⟩ ⟨ha, hb⟩
rcases exists_between (tsub_pos_of_lt ha) with ⟨ε, ε0, hε⟩
rcases lt_iff_exists_add_pos_lt.1 hb with ⟨δ, δ0, hδ⟩
refine ⟨min ε δ, (lt_min ε0 (coe_pos.2 δ0)).ne', Icc_subset_Ioo ?_ ?_⟩
· exact lt_tsub_comm.2 ((min_le_left _ _).trans_lt hε)
· exact (add_le_add_left (min_le_right _ _) _).trans_lt hδ
· exact ⟨(x - ε, x + ε), ⟨ENNReal.sub_lt_self xt x0.ne' ε0,
lt_add_right xt ε0⟩, Ioo_subset_Icc_self⟩
theorem hasBasis_nhds_of_ne_top (xt : x ≠ ∞) :
(𝓝 x).HasBasis (0 < ·) (fun ε => Icc (x - ε) (x + ε)) := by
simpa only [pos_iff_ne_zero] using hasBasis_nhds_of_ne_top' xt
theorem Icc_mem_nhds (xt : x ≠ ∞) (ε0 : ε ≠ 0) : Icc (x - ε) (x + ε) ∈ 𝓝 x :=
(hasBasis_nhds_of_ne_top' xt).mem_of_mem ε0
#align ennreal.Icc_mem_nhds ENNReal.Icc_mem_nhds
theorem nhds_of_ne_top (xt : x ≠ ∞) : 𝓝 x = ⨅ ε > 0, 𝓟 (Icc (x - ε) (x + ε)) :=
(hasBasis_nhds_of_ne_top xt).eq_biInf
#align ennreal.nhds_of_ne_top ENNReal.nhds_of_ne_top
theorem biInf_le_nhds : ∀ x : ℝ≥0∞, ⨅ ε > 0, 𝓟 (Icc (x - ε) (x + ε)) ≤ 𝓝 x
| ∞ => iInf₂_le_of_le 1 one_pos <| by
simpa only [← coe_one, top_sub_coe, top_add, Icc_self, principal_singleton] using pure_le_nhds _
| (x : ℝ≥0) => (nhds_of_ne_top coe_ne_top).ge
-- Porting note (#10756): new lemma
protected theorem tendsto_nhds_of_Icc {f : Filter α} {u : α → ℝ≥0∞} {a : ℝ≥0∞}
(h : ∀ ε > 0, ∀ᶠ x in f, u x ∈ Icc (a - ε) (a + ε)) : Tendsto u f (𝓝 a) := by
refine Tendsto.mono_right ?_ (biInf_le_nhds _)
simpa only [tendsto_iInf, tendsto_principal]
protected theorem tendsto_nhds {f : Filter α} {u : α → ℝ≥0∞} {a : ℝ≥0∞} (ha : a ≠ ∞) :
Tendsto u f (𝓝 a) ↔ ∀ ε > 0, ∀ᶠ x in f, u x ∈ Icc (a - ε) (a + ε) := by
simp only [nhds_of_ne_top ha, tendsto_iInf, tendsto_principal]
#align ennreal.tendsto_nhds ENNReal.tendsto_nhds
protected theorem tendsto_nhds_zero {f : Filter α} {u : α → ℝ≥0∞} :
Tendsto u f (𝓝 0) ↔ ∀ ε > 0, ∀ᶠ x in f, u x ≤ ε :=
nhds_zero_basis_Iic.tendsto_right_iff
#align ennreal.tendsto_nhds_zero ENNReal.tendsto_nhds_zero
protected theorem tendsto_atTop [Nonempty β] [SemilatticeSup β] {f : β → ℝ≥0∞} {a : ℝ≥0∞}
(ha : a ≠ ∞) : Tendsto f atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, f n ∈ Icc (a - ε) (a + ε) :=
.trans (atTop_basis.tendsto_iff (hasBasis_nhds_of_ne_top ha)) (by simp only [true_and]; rfl)
#align ennreal.tendsto_at_top ENNReal.tendsto_atTop
instance : ContinuousAdd ℝ≥0∞ := by
refine ⟨continuous_iff_continuousAt.2 ?_⟩
rintro ⟨_ | a, b⟩
· exact tendsto_nhds_top_mono' continuousAt_fst fun p => le_add_right le_rfl
rcases b with (_ | b)
· exact tendsto_nhds_top_mono' continuousAt_snd fun p => le_add_left le_rfl
simp only [ContinuousAt, some_eq_coe, nhds_coe_coe, ← coe_add, tendsto_map'_iff, (· ∘ ·),
tendsto_coe, tendsto_add]
protected theorem tendsto_atTop_zero [Nonempty β] [SemilatticeSup β] {f : β → ℝ≥0∞} :
Tendsto f atTop (𝓝 0) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, f n ≤ ε :=
.trans (atTop_basis.tendsto_iff nhds_zero_basis_Iic) (by simp only [true_and]; rfl)
#align ennreal.tendsto_at_top_zero ENNReal.tendsto_atTop_zero
theorem tendsto_sub : ∀ {a b : ℝ≥0∞}, (a ≠ ∞ ∨ b ≠ ∞) →
Tendsto (fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 - p.2) (𝓝 (a, b)) (𝓝 (a - b))
| ∞, ∞, h => by simp only [ne_eq, not_true_eq_false, or_self] at h
| ∞, (b : ℝ≥0), _ => by
rw [top_sub_coe, tendsto_nhds_top_iff_nnreal]
refine fun x => ((lt_mem_nhds <| @coe_lt_top (b + 1 + x)).prod_nhds
(ge_mem_nhds <| coe_lt_coe.2 <| lt_add_one b)).mono fun y hy => ?_
rw [lt_tsub_iff_left]
calc y.2 + x ≤ ↑(b + 1) + x := add_le_add_right hy.2 _
_ < y.1 := hy.1
| (a : ℝ≥0), ∞, _ => by
rw [sub_top]
refine (tendsto_pure.2 ?_).mono_right (pure_le_nhds _)
exact ((gt_mem_nhds <| coe_lt_coe.2 <| lt_add_one a).prod_nhds
(lt_mem_nhds <| @coe_lt_top (a + 1))).mono fun x hx =>
tsub_eq_zero_iff_le.2 (hx.1.trans hx.2).le
| (a : ℝ≥0), (b : ℝ≥0), _ => by
simp only [nhds_coe_coe, tendsto_map'_iff, ← ENNReal.coe_sub, (· ∘ ·), tendsto_coe]
exact continuous_sub.tendsto (a, b)
#align ennreal.tendsto_sub ENNReal.tendsto_sub
protected theorem Tendsto.sub {f : Filter α} {ma : α → ℝ≥0∞} {mb : α → ℝ≥0∞} {a b : ℝ≥0∞}
(hma : Tendsto ma f (𝓝 a)) (hmb : Tendsto mb f (𝓝 b)) (h : a ≠ ∞ ∨ b ≠ ∞) :
Tendsto (fun a => ma a - mb a) f (𝓝 (a - b)) :=
show Tendsto ((fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 - p.2) ∘ fun a => (ma a, mb a)) f (𝓝 (a - b)) from
Tendsto.comp (ENNReal.tendsto_sub h) (hma.prod_mk_nhds hmb)
#align ennreal.tendsto.sub ENNReal.Tendsto.sub
protected theorem tendsto_mul (ha : a ≠ 0 ∨ b ≠ ∞) (hb : b ≠ 0 ∨ a ≠ ∞) :
Tendsto (fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 * p.2) (𝓝 (a, b)) (𝓝 (a * b)) := by
have ht : ∀ b : ℝ≥0∞, b ≠ 0 →
Tendsto (fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 * p.2) (𝓝 (∞, b)) (𝓝 ∞) := fun b hb => by
refine tendsto_nhds_top_iff_nnreal.2 fun n => ?_
rcases lt_iff_exists_nnreal_btwn.1 (pos_iff_ne_zero.2 hb) with ⟨ε, hε, hεb⟩
have : ∀ᶠ c : ℝ≥0∞ × ℝ≥0∞ in 𝓝 (∞, b), ↑n / ↑ε < c.1 ∧ ↑ε < c.2 :=
(lt_mem_nhds <| div_lt_top coe_ne_top hε.ne').prod_nhds (lt_mem_nhds hεb)
refine this.mono fun c hc => ?_
exact (ENNReal.div_mul_cancel hε.ne' coe_ne_top).symm.trans_lt (mul_lt_mul hc.1 hc.2)
induction a with
| top => simp only [ne_eq, or_false, not_true_eq_false] at hb; simp [ht b hb, top_mul hb]
| coe a =>
induction b with
| top =>
simp only [ne_eq, or_false, not_true_eq_false] at ha
simpa [(· ∘ ·), mul_comm, mul_top ha]
using (ht a ha).comp (continuous_swap.tendsto (ofNNReal a, ∞))
| coe b =>
simp only [nhds_coe_coe, ← coe_mul, tendsto_coe, tendsto_map'_iff, (· ∘ ·), tendsto_mul]
#align ennreal.tendsto_mul ENNReal.tendsto_mul
protected theorem Tendsto.mul {f : Filter α} {ma : α → ℝ≥0∞} {mb : α → ℝ≥0∞} {a b : ℝ≥0∞}
(hma : Tendsto ma f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ ∞) (hmb : Tendsto mb f (𝓝 b))
(hb : b ≠ 0 ∨ a ≠ ∞) : Tendsto (fun a => ma a * mb a) f (𝓝 (a * b)) :=
show Tendsto ((fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 * p.2) ∘ fun a => (ma a, mb a)) f (𝓝 (a * b)) from
Tendsto.comp (ENNReal.tendsto_mul ha hb) (hma.prod_mk_nhds hmb)
#align ennreal.tendsto.mul ENNReal.Tendsto.mul
theorem _root_.ContinuousOn.ennreal_mul [TopologicalSpace α] {f g : α → ℝ≥0∞} {s : Set α}
(hf : ContinuousOn f s) (hg : ContinuousOn g s) (h₁ : ∀ x ∈ s, f x ≠ 0 ∨ g x ≠ ∞)
(h₂ : ∀ x ∈ s, g x ≠ 0 ∨ f x ≠ ∞) : ContinuousOn (fun x => f x * g x) s := fun x hx =>
ENNReal.Tendsto.mul (hf x hx) (h₁ x hx) (hg x hx) (h₂ x hx)
#align continuous_on.ennreal_mul ContinuousOn.ennreal_mul
theorem _root_.Continuous.ennreal_mul [TopologicalSpace α] {f g : α → ℝ≥0∞} (hf : Continuous f)
(hg : Continuous g) (h₁ : ∀ x, f x ≠ 0 ∨ g x ≠ ∞) (h₂ : ∀ x, g x ≠ 0 ∨ f x ≠ ∞) :
Continuous fun x => f x * g x :=
continuous_iff_continuousAt.2 fun x =>
ENNReal.Tendsto.mul hf.continuousAt (h₁ x) hg.continuousAt (h₂ x)
#align continuous.ennreal_mul Continuous.ennreal_mul
protected theorem Tendsto.const_mul {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞}
(hm : Tendsto m f (𝓝 b)) (hb : b ≠ 0 ∨ a ≠ ∞) : Tendsto (fun b => a * m b) f (𝓝 (a * b)) :=
by_cases (fun (this : a = 0) => by simp [this, tendsto_const_nhds]) fun ha : a ≠ 0 =>
ENNReal.Tendsto.mul tendsto_const_nhds (Or.inl ha) hm hb
#align ennreal.tendsto.const_mul ENNReal.Tendsto.const_mul
protected theorem Tendsto.mul_const {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞}
(hm : Tendsto m f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ ∞) : Tendsto (fun x => m x * b) f (𝓝 (a * b)) := by
simpa only [mul_comm] using ENNReal.Tendsto.const_mul hm ha
#align ennreal.tendsto.mul_const ENNReal.Tendsto.mul_const
theorem tendsto_finset_prod_of_ne_top {ι : Type*} {f : ι → α → ℝ≥0∞} {x : Filter α} {a : ι → ℝ≥0∞}
(s : Finset ι) (h : ∀ i ∈ s, Tendsto (f i) x (𝓝 (a i))) (h' : ∀ i ∈ s, a i ≠ ∞) :
Tendsto (fun b => ∏ c ∈ s, f c b) x (𝓝 (∏ c ∈ s, a c)) := by
induction' s using Finset.induction with a s has IH
· simp [tendsto_const_nhds]
simp only [Finset.prod_insert has]
apply Tendsto.mul (h _ (Finset.mem_insert_self _ _))
· right
exact (prod_lt_top fun i hi => h' _ (Finset.mem_insert_of_mem hi)).ne
· exact IH (fun i hi => h _ (Finset.mem_insert_of_mem hi)) fun i hi =>
h' _ (Finset.mem_insert_of_mem hi)
· exact Or.inr (h' _ (Finset.mem_insert_self _ _))
#align ennreal.tendsto_finset_prod_of_ne_top ENNReal.tendsto_finset_prod_of_ne_top
protected theorem continuousAt_const_mul {a b : ℝ≥0∞} (h : a ≠ ∞ ∨ b ≠ 0) :
ContinuousAt (a * ·) b :=
Tendsto.const_mul tendsto_id h.symm
#align ennreal.continuous_at_const_mul ENNReal.continuousAt_const_mul
protected theorem continuousAt_mul_const {a b : ℝ≥0∞} (h : a ≠ ∞ ∨ b ≠ 0) :
ContinuousAt (fun x => x * a) b :=
Tendsto.mul_const tendsto_id h.symm
#align ennreal.continuous_at_mul_const ENNReal.continuousAt_mul_const
protected theorem continuous_const_mul {a : ℝ≥0∞} (ha : a ≠ ∞) : Continuous (a * ·) :=
continuous_iff_continuousAt.2 fun _ => ENNReal.continuousAt_const_mul (Or.inl ha)
#align ennreal.continuous_const_mul ENNReal.continuous_const_mul
protected theorem continuous_mul_const {a : ℝ≥0∞} (ha : a ≠ ∞) : Continuous fun x => x * a :=
continuous_iff_continuousAt.2 fun _ => ENNReal.continuousAt_mul_const (Or.inl ha)
#align ennreal.continuous_mul_const ENNReal.continuous_mul_const
protected theorem continuous_div_const (c : ℝ≥0∞) (c_ne_zero : c ≠ 0) :
Continuous fun x : ℝ≥0∞ => x / c := by
simp_rw [div_eq_mul_inv, continuous_iff_continuousAt]
intro x
exact ENNReal.continuousAt_mul_const (Or.intro_left _ (inv_ne_top.mpr c_ne_zero))
#align ennreal.continuous_div_const ENNReal.continuous_div_const
@[continuity]
theorem continuous_pow (n : ℕ) : Continuous fun a : ℝ≥0∞ => a ^ n := by
induction' n with n IH
· simp [continuous_const]
simp_rw [pow_add, pow_one, continuous_iff_continuousAt]
intro x
refine ENNReal.Tendsto.mul (IH.tendsto _) ?_ tendsto_id ?_ <;> by_cases H : x = 0
· simp only [H, zero_ne_top, Ne, or_true_iff, not_false_iff]
· exact Or.inl fun h => H (pow_eq_zero h)
· simp only [H, pow_eq_top_iff, zero_ne_top, false_or_iff, eq_self_iff_true, not_true, Ne,
not_false_iff, false_and_iff]
· simp only [H, true_or_iff, Ne, not_false_iff]
#align ennreal.continuous_pow ENNReal.continuous_pow
theorem continuousOn_sub :
ContinuousOn (fun p : ℝ≥0∞ × ℝ≥0∞ => p.fst - p.snd) { p : ℝ≥0∞ × ℝ≥0∞ | p ≠ ⟨∞, ∞⟩ } := by
rw [ContinuousOn]
rintro ⟨x, y⟩ hp
simp only [Ne, Set.mem_setOf_eq, Prod.mk.inj_iff] at hp
exact tendsto_nhdsWithin_of_tendsto_nhds (tendsto_sub (not_and_or.mp hp))
#align ennreal.continuous_on_sub ENNReal.continuousOn_sub
theorem continuous_sub_left {a : ℝ≥0∞} (a_ne_top : a ≠ ∞) : Continuous (a - ·) := by
change Continuous (Function.uncurry Sub.sub ∘ (a, ·))
refine continuousOn_sub.comp_continuous (Continuous.Prod.mk a) fun x => ?_
simp only [a_ne_top, Ne, mem_setOf_eq, Prod.mk.inj_iff, false_and_iff, not_false_iff]
#align ennreal.continuous_sub_left ENNReal.continuous_sub_left
theorem continuous_nnreal_sub {a : ℝ≥0} : Continuous fun x : ℝ≥0∞ => (a : ℝ≥0∞) - x :=
continuous_sub_left coe_ne_top
#align ennreal.continuous_nnreal_sub ENNReal.continuous_nnreal_sub
theorem continuousOn_sub_left (a : ℝ≥0∞) : ContinuousOn (a - ·) { x : ℝ≥0∞ | x ≠ ∞ } := by
rw [show (fun x => a - x) = (fun p : ℝ≥0∞ × ℝ≥0∞ => p.fst - p.snd) ∘ fun x => ⟨a, x⟩ by rfl]
apply ContinuousOn.comp continuousOn_sub (Continuous.continuousOn (Continuous.Prod.mk a))
rintro _ h (_ | _)
exact h none_eq_top
#align ennreal.continuous_on_sub_left ENNReal.continuousOn_sub_left
theorem continuous_sub_right (a : ℝ≥0∞) : Continuous fun x : ℝ≥0∞ => x - a := by
by_cases a_infty : a = ∞
· simp [a_infty, continuous_const]
· rw [show (fun x => x - a) = (fun p : ℝ≥0∞ × ℝ≥0∞ => p.fst - p.snd) ∘ fun x => ⟨x, a⟩ by rfl]
apply ContinuousOn.comp_continuous continuousOn_sub (continuous_id'.prod_mk continuous_const)
intro x
simp only [a_infty, Ne, mem_setOf_eq, Prod.mk.inj_iff, and_false_iff, not_false_iff]
#align ennreal.continuous_sub_right ENNReal.continuous_sub_right
protected theorem Tendsto.pow {f : Filter α} {m : α → ℝ≥0∞} {a : ℝ≥0∞} {n : ℕ}
(hm : Tendsto m f (𝓝 a)) : Tendsto (fun x => m x ^ n) f (𝓝 (a ^ n)) :=
((continuous_pow n).tendsto a).comp hm
#align ennreal.tendsto.pow ENNReal.Tendsto.pow
theorem le_of_forall_lt_one_mul_le {x y : ℝ≥0∞} (h : ∀ a < 1, a * x ≤ y) : x ≤ y := by
have : Tendsto (· * x) (𝓝[<] 1) (𝓝 (1 * x)) :=
(ENNReal.continuousAt_mul_const (Or.inr one_ne_zero)).mono_left inf_le_left
rw [one_mul] at this
exact le_of_tendsto this (eventually_nhdsWithin_iff.2 <| eventually_of_forall h)
#align ennreal.le_of_forall_lt_one_mul_le ENNReal.le_of_forall_lt_one_mul_le
theorem iInf_mul_left' {ι} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} (h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0)
(h0 : a = 0 → Nonempty ι) : ⨅ i, a * f i = a * ⨅ i, f i := by
by_cases H : a = ∞ ∧ ⨅ i, f i = 0
· rcases h H.1 H.2 with ⟨i, hi⟩
rw [H.2, mul_zero, ← bot_eq_zero, iInf_eq_bot]
exact fun b hb => ⟨i, by rwa [hi, mul_zero, ← bot_eq_zero]⟩
· rw [not_and_or] at H
cases isEmpty_or_nonempty ι
· rw [iInf_of_empty, iInf_of_empty, mul_top]
exact mt h0 (not_nonempty_iff.2 ‹_›)
· exact (ENNReal.mul_left_mono.map_iInf_of_continuousAt'
(ENNReal.continuousAt_const_mul H)).symm
#align ennreal.infi_mul_left' ENNReal.iInf_mul_left'
theorem iInf_mul_left {ι} [Nonempty ι] {f : ι → ℝ≥0∞} {a : ℝ≥0∞}
(h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0) : ⨅ i, a * f i = a * ⨅ i, f i :=
iInf_mul_left' h fun _ => ‹Nonempty ι›
#align ennreal.infi_mul_left ENNReal.iInf_mul_left
theorem iInf_mul_right' {ι} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} (h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0)
(h0 : a = 0 → Nonempty ι) : ⨅ i, f i * a = (⨅ i, f i) * a := by
simpa only [mul_comm a] using iInf_mul_left' h h0
#align ennreal.infi_mul_right' ENNReal.iInf_mul_right'
theorem iInf_mul_right {ι} [Nonempty ι] {f : ι → ℝ≥0∞} {a : ℝ≥0∞}
(h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0) : ⨅ i, f i * a = (⨅ i, f i) * a :=
iInf_mul_right' h fun _ => ‹Nonempty ι›
#align ennreal.infi_mul_right ENNReal.iInf_mul_right
theorem inv_map_iInf {ι : Sort*} {x : ι → ℝ≥0∞} : (iInf x)⁻¹ = ⨆ i, (x i)⁻¹ :=
OrderIso.invENNReal.map_iInf x
#align ennreal.inv_map_infi ENNReal.inv_map_iInf
theorem inv_map_iSup {ι : Sort*} {x : ι → ℝ≥0∞} : (iSup x)⁻¹ = ⨅ i, (x i)⁻¹ :=
OrderIso.invENNReal.map_iSup x
#align ennreal.inv_map_supr ENNReal.inv_map_iSup
theorem inv_limsup {ι : Sort _} {x : ι → ℝ≥0∞} {l : Filter ι} :
(limsup x l)⁻¹ = liminf (fun i => (x i)⁻¹) l :=
OrderIso.invENNReal.limsup_apply
#align ennreal.inv_limsup ENNReal.inv_limsup
theorem inv_liminf {ι : Sort _} {x : ι → ℝ≥0∞} {l : Filter ι} :
(liminf x l)⁻¹ = limsup (fun i => (x i)⁻¹) l :=
OrderIso.invENNReal.liminf_apply
#align ennreal.inv_liminf ENNReal.inv_liminf
instance : ContinuousInv ℝ≥0∞ := ⟨OrderIso.invENNReal.continuous⟩
@[simp] -- Porting note (#11215): TODO: generalize to `[InvolutiveInv _] [ContinuousInv _]`
protected theorem tendsto_inv_iff {f : Filter α} {m : α → ℝ≥0∞} {a : ℝ≥0∞} :
Tendsto (fun x => (m x)⁻¹) f (𝓝 a⁻¹) ↔ Tendsto m f (𝓝 a) :=
⟨fun h => by simpa only [inv_inv] using Tendsto.inv h, Tendsto.inv⟩
#align ennreal.tendsto_inv_iff ENNReal.tendsto_inv_iff
protected theorem Tendsto.div {f : Filter α} {ma : α → ℝ≥0∞} {mb : α → ℝ≥0∞} {a b : ℝ≥0∞}
(hma : Tendsto ma f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ 0) (hmb : Tendsto mb f (𝓝 b))
(hb : b ≠ ∞ ∨ a ≠ ∞) : Tendsto (fun a => ma a / mb a) f (𝓝 (a / b)) := by
apply Tendsto.mul hma _ (ENNReal.tendsto_inv_iff.2 hmb) _ <;> simp [ha, hb]
#align ennreal.tendsto.div ENNReal.Tendsto.div
protected theorem Tendsto.const_div {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞}
(hm : Tendsto m f (𝓝 b)) (hb : b ≠ ∞ ∨ a ≠ ∞) : Tendsto (fun b => a / m b) f (𝓝 (a / b)) := by
apply Tendsto.const_mul (ENNReal.tendsto_inv_iff.2 hm)
simp [hb]
#align ennreal.tendsto.const_div ENNReal.Tendsto.const_div
protected theorem Tendsto.div_const {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞}
(hm : Tendsto m f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ 0) : Tendsto (fun x => m x / b) f (𝓝 (a / b)) := by
apply Tendsto.mul_const hm
simp [ha]
#align ennreal.tendsto.div_const ENNReal.Tendsto.div_const
protected theorem tendsto_inv_nat_nhds_zero : Tendsto (fun n : ℕ => (n : ℝ≥0∞)⁻¹) atTop (𝓝 0) :=
ENNReal.inv_top ▸ ENNReal.tendsto_inv_iff.2 tendsto_nat_nhds_top
#align ennreal.tendsto_inv_nat_nhds_zero ENNReal.tendsto_inv_nat_nhds_zero
theorem iSup_add {ι : Sort*} {s : ι → ℝ≥0∞} [Nonempty ι] : iSup s + a = ⨆ b, s b + a :=
Monotone.map_iSup_of_continuousAt' (continuousAt_id.add continuousAt_const) <|
monotone_id.add monotone_const
#align ennreal.supr_add ENNReal.iSup_add
theorem biSup_add' {ι : Sort*} {p : ι → Prop} (h : ∃ i, p i) {f : ι → ℝ≥0∞} :
(⨆ (i) (_ : p i), f i) + a = ⨆ (i) (_ : p i), f i + a := by
haveI : Nonempty { i // p i } := nonempty_subtype.2 h
simp only [iSup_subtype', iSup_add]
#align ennreal.bsupr_add' ENNReal.biSup_add'
theorem add_biSup' {ι : Sort*} {p : ι → Prop} (h : ∃ i, p i) {f : ι → ℝ≥0∞} :
(a + ⨆ (i) (_ : p i), f i) = ⨆ (i) (_ : p i), a + f i := by
simp only [add_comm a, biSup_add' h]
#align ennreal.add_bsupr' ENNReal.add_biSup'
theorem biSup_add {ι} {s : Set ι} (hs : s.Nonempty) {f : ι → ℝ≥0∞} :
(⨆ i ∈ s, f i) + a = ⨆ i ∈ s, f i + a :=
biSup_add' hs
#align ennreal.bsupr_add ENNReal.biSup_add
theorem add_biSup {ι} {s : Set ι} (hs : s.Nonempty) {f : ι → ℝ≥0∞} :
(a + ⨆ i ∈ s, f i) = ⨆ i ∈ s, a + f i :=
add_biSup' hs
#align ennreal.add_bsupr ENNReal.add_biSup
theorem sSup_add {s : Set ℝ≥0∞} (hs : s.Nonempty) : sSup s + a = ⨆ b ∈ s, b + a := by
rw [sSup_eq_iSup, biSup_add hs]
#align ennreal.Sup_add ENNReal.sSup_add
| Mathlib/Topology/Instances/ENNReal.lean | 599 | 600 | theorem add_iSup {ι : Sort*} {s : ι → ℝ≥0∞} [Nonempty ι] : a + iSup s = ⨆ b, a + s b := by |
rw [add_comm, iSup_add]; simp [add_comm]
|
import Mathlib.Data.List.Forall2
#align_import data.list.zip from "leanprover-community/mathlib"@"134625f523e737f650a6ea7f0c82a6177e45e622"
-- Make sure we don't import algebra
assert_not_exists Monoid
universe u
open Nat
namespace List
variable {α : Type u} {β γ δ ε : Type*}
#align list.zip_with_cons_cons List.zipWith_cons_cons
#align list.zip_cons_cons List.zip_cons_cons
#align list.zip_with_nil_left List.zipWith_nil_left
#align list.zip_with_nil_right List.zipWith_nil_right
#align list.zip_with_eq_nil_iff List.zipWith_eq_nil_iff
#align list.zip_nil_left List.zip_nil_left
#align list.zip_nil_right List.zip_nil_right
@[simp]
theorem zip_swap : ∀ (l₁ : List α) (l₂ : List β), (zip l₁ l₂).map Prod.swap = zip l₂ l₁
| [], l₂ => zip_nil_right.symm
| l₁, [] => by rw [zip_nil_right]; rfl
| a :: l₁, b :: l₂ => by
simp only [zip_cons_cons, map_cons, zip_swap l₁ l₂, Prod.swap_prod_mk]
#align list.zip_swap List.zip_swap
#align list.length_zip_with List.length_zipWith
#align list.length_zip List.length_zip
theorem forall_zipWith {f : α → β → γ} {p : γ → Prop} :
∀ {l₁ : List α} {l₂ : List β}, length l₁ = length l₂ →
(Forall p (zipWith f l₁ l₂) ↔ Forall₂ (fun x y => p (f x y)) l₁ l₂)
| [], [], _ => by simp
| a :: l₁, b :: l₂, h => by
simp only [length_cons, succ_inj'] at h
simp [forall_zipWith h]
#align list.all₂_zip_with List.forall_zipWith
theorem lt_length_left_of_zipWith {f : α → β → γ} {i : ℕ} {l : List α} {l' : List β}
(h : i < (zipWith f l l').length) : i < l.length := by rw [length_zipWith] at h; omega
#align list.lt_length_left_of_zip_with List.lt_length_left_of_zipWith
theorem lt_length_right_of_zipWith {f : α → β → γ} {i : ℕ} {l : List α} {l' : List β}
(h : i < (zipWith f l l').length) : i < l'.length := by rw [length_zipWith] at h; omega
#align list.lt_length_right_of_zip_with List.lt_length_right_of_zipWith
theorem lt_length_left_of_zip {i : ℕ} {l : List α} {l' : List β} (h : i < (zip l l').length) :
i < l.length :=
lt_length_left_of_zipWith h
#align list.lt_length_left_of_zip List.lt_length_left_of_zip
theorem lt_length_right_of_zip {i : ℕ} {l : List α} {l' : List β} (h : i < (zip l l').length) :
i < l'.length :=
lt_length_right_of_zipWith h
#align list.lt_length_right_of_zip List.lt_length_right_of_zip
#align list.zip_append List.zip_append
#align list.zip_map List.zip_map
#align list.zip_map_left List.zip_map_left
#align list.zip_map_right List.zip_map_right
#align list.zip_with_map List.zipWith_map
#align list.zip_with_map_left List.zipWith_map_left
#align list.zip_with_map_right List.zipWith_map_right
#align list.zip_map' List.zip_map'
#align list.map_zip_with List.map_zipWith
theorem mem_zip {a b} : ∀ {l₁ : List α} {l₂ : List β}, (a, b) ∈ zip l₁ l₂ → a ∈ l₁ ∧ b ∈ l₂
| _ :: l₁, _ :: l₂, h => by
cases' h with _ _ _ h
· simp
· have := mem_zip h
exact ⟨Mem.tail _ this.1, Mem.tail _ this.2⟩
#align list.mem_zip List.mem_zip
#align list.map_fst_zip List.map_fst_zip
#align list.map_snd_zip List.map_snd_zip
#align list.unzip_nil List.unzip_nil
#align list.unzip_cons List.unzip_cons
theorem unzip_eq_map : ∀ l : List (α × β), unzip l = (l.map Prod.fst, l.map Prod.snd)
| [] => rfl
| (a, b) :: l => by simp only [unzip_cons, map_cons, unzip_eq_map l]
#align list.unzip_eq_map List.unzip_eq_map
theorem unzip_left (l : List (α × β)) : (unzip l).1 = l.map Prod.fst := by simp only [unzip_eq_map]
#align list.unzip_left List.unzip_left
theorem unzip_right (l : List (α × β)) : (unzip l).2 = l.map Prod.snd := by simp only [unzip_eq_map]
#align list.unzip_right List.unzip_right
| Mathlib/Data/List/Zip.lean | 115 | 117 | theorem unzip_swap (l : List (α × β)) : unzip (l.map Prod.swap) = (unzip l).swap := by |
simp only [unzip_eq_map, map_map]
rfl
|
import Mathlib.Algebra.MvPolynomial.Equiv
import Mathlib.Algebra.MvPolynomial.Supported
import Mathlib.LinearAlgebra.LinearIndependent
import Mathlib.RingTheory.Adjoin.Basic
import Mathlib.RingTheory.Algebraic
import Mathlib.RingTheory.MvPolynomial.Basic
#align_import ring_theory.algebraic_independent from "leanprover-community/mathlib"@"949dc57e616a621462062668c9f39e4e17b64b69"
noncomputable section
open Function Set Subalgebra MvPolynomial Algebra
open scoped Classical
universe x u v w
variable {ι : Type*} {ι' : Type*} (R : Type*) {K : Type*}
variable {A : Type*} {A' A'' : Type*} {V : Type u} {V' : Type*}
variable (x : ι → A)
variable [CommRing R] [CommRing A] [CommRing A'] [CommRing A'']
variable [Algebra R A] [Algebra R A'] [Algebra R A'']
variable {a b : R}
def AlgebraicIndependent : Prop :=
Injective (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A)
#align algebraic_independent AlgebraicIndependent
variable {R} {x}
theorem algebraicIndependent_iff_ker_eq_bot :
AlgebraicIndependent R x ↔
RingHom.ker (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A).toRingHom = ⊥ :=
RingHom.injective_iff_ker_eq_bot _
#align algebraic_independent_iff_ker_eq_bot algebraicIndependent_iff_ker_eq_bot
theorem algebraicIndependent_iff :
AlgebraicIndependent R x ↔
∀ p : MvPolynomial ι R, MvPolynomial.aeval (x : ι → A) p = 0 → p = 0 :=
injective_iff_map_eq_zero _
#align algebraic_independent_iff algebraicIndependent_iff
theorem AlgebraicIndependent.eq_zero_of_aeval_eq_zero (h : AlgebraicIndependent R x) :
∀ p : MvPolynomial ι R, MvPolynomial.aeval (x : ι → A) p = 0 → p = 0 :=
algebraicIndependent_iff.1 h
#align algebraic_independent.eq_zero_of_aeval_eq_zero AlgebraicIndependent.eq_zero_of_aeval_eq_zero
theorem algebraicIndependent_iff_injective_aeval :
AlgebraicIndependent R x ↔ Injective (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A) :=
Iff.rfl
#align algebraic_independent_iff_injective_aeval algebraicIndependent_iff_injective_aeval
@[simp]
theorem algebraicIndependent_empty_type_iff [IsEmpty ι] :
AlgebraicIndependent R x ↔ Injective (algebraMap R A) := by
have : aeval x = (Algebra.ofId R A).comp (@isEmptyAlgEquiv R ι _ _).toAlgHom := by
ext i
exact IsEmpty.elim' ‹IsEmpty ι› i
rw [AlgebraicIndependent, this, ← Injective.of_comp_iff' _ (@isEmptyAlgEquiv R ι _ _).bijective]
rfl
#align algebraic_independent_empty_type_iff algebraicIndependent_empty_type_iff
namespace AlgebraicIndependent
variable (hx : AlgebraicIndependent R x)
theorem algebraMap_injective : Injective (algebraMap R A) := by
simpa [Function.comp] using
(Injective.of_comp_iff (algebraicIndependent_iff_injective_aeval.1 hx) MvPolynomial.C).2
(MvPolynomial.C_injective _ _)
#align algebraic_independent.algebra_map_injective AlgebraicIndependent.algebraMap_injective
theorem linearIndependent : LinearIndependent R x := by
rw [linearIndependent_iff_injective_total]
have : Finsupp.total ι A R x =
(MvPolynomial.aeval x).toLinearMap.comp (Finsupp.total ι _ R X) := by
ext
simp
rw [this]
refine hx.comp ?_
rw [← linearIndependent_iff_injective_total]
exact linearIndependent_X _ _
#align algebraic_independent.linear_independent AlgebraicIndependent.linearIndependent
protected theorem injective [Nontrivial R] : Injective x :=
hx.linearIndependent.injective
#align algebraic_independent.injective AlgebraicIndependent.injective
theorem ne_zero [Nontrivial R] (i : ι) : x i ≠ 0 :=
hx.linearIndependent.ne_zero i
#align algebraic_independent.ne_zero AlgebraicIndependent.ne_zero
| Mathlib/RingTheory/AlgebraicIndependent.lean | 129 | 131 | theorem comp (f : ι' → ι) (hf : Function.Injective f) : AlgebraicIndependent R (x ∘ f) := by |
intro p q
simpa [aeval_rename, (rename_injective f hf).eq_iff] using @hx (rename f p) (rename f q)
|
import Mathlib.Data.Vector.Basic
import Mathlib.Data.Vector.Snoc
set_option autoImplicit true
namespace Vector
section Fold
section Bisim
variable {xs : Vector α n}
theorem mapAccumr_bisim {f₁ : α → σ₁ → σ₁ × β} {f₂ : α → σ₂ → σ₂ × β} {s₁ : σ₁} {s₂ : σ₂}
(R : σ₁ → σ₂ → Prop) (h₀ : R s₁ s₂)
(hR : ∀ {s q} a, R s q → R (f₁ a s).1 (f₂ a q).1 ∧ (f₁ a s).2 = (f₂ a q).2) :
R (mapAccumr f₁ xs s₁).fst (mapAccumr f₂ xs s₂).fst
∧ (mapAccumr f₁ xs s₁).snd = (mapAccumr f₂ xs s₂).snd := by
induction xs using Vector.revInductionOn generalizing s₁ s₂
next => exact ⟨h₀, rfl⟩
next xs x ih =>
rcases (hR x h₀) with ⟨hR, _⟩
simp only [mapAccumr_snoc, ih hR, true_and]
congr 1
| Mathlib/Data/Vector/MapLemmas.lean | 185 | 190 | theorem mapAccumr_bisim_tail {f₁ : α → σ₁ → σ₁ × β} {f₂ : α → σ₂ → σ₂ × β} {s₁ : σ₁} {s₂ : σ₂}
(h : ∃ R : σ₁ → σ₂ → Prop, R s₁ s₂ ∧
∀ {s q} a, R s q → R (f₁ a s).1 (f₂ a q).1 ∧ (f₁ a s).2 = (f₂ a q).2) :
(mapAccumr f₁ xs s₁).snd = (mapAccumr f₂ xs s₂).snd := by |
rcases h with ⟨R, h₀, hR⟩
exact (mapAccumr_bisim R h₀ hR).2
|
import Mathlib.Algebra.Ring.Prod
import Mathlib.GroupTheory.OrderOfElement
import Mathlib.Tactic.FinCases
#align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7"
assert_not_exists Submodule
open Function
namespace ZMod
instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ)
def val : ∀ {n : ℕ}, ZMod n → ℕ
| 0 => Int.natAbs
| n + 1 => ((↑) : Fin (n + 1) → ℕ)
#align zmod.val ZMod.val
theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by
cases n
· cases NeZero.ne 0 rfl
exact Fin.is_lt a
#align zmod.val_lt ZMod.val_lt
theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n :=
a.val_lt.le
#align zmod.val_le ZMod.val_le
@[simp]
theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0
| 0 => rfl
| _ + 1 => rfl
#align zmod.val_zero ZMod.val_zero
@[simp]
theorem val_one' : (1 : ZMod 0).val = 1 :=
rfl
#align zmod.val_one' ZMod.val_one'
@[simp]
theorem val_neg' {n : ZMod 0} : (-n).val = n.val :=
Int.natAbs_neg n
#align zmod.val_neg' ZMod.val_neg'
@[simp]
theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val :=
Int.natAbs_mul m n
#align zmod.val_mul' ZMod.val_mul'
@[simp]
theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by
cases n
· rw [Nat.mod_zero]
exact Int.natAbs_ofNat a
· apply Fin.val_natCast
#align zmod.val_nat_cast ZMod.val_natCast
@[deprecated (since := "2024-04-17")]
alias val_nat_cast := val_natCast
theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by
simp only [val]
rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one]
lemma eq_one_of_isUnit_natCast {n : ℕ} (h : IsUnit (n : ZMod 0)) : n = 1 := by
rw [← Nat.mod_zero n, ← val_natCast, val_unit'.mp h]
theorem val_natCast_of_lt {n a : ℕ} (h : a < n) : (a : ZMod n).val = a := by
rwa [val_natCast, Nat.mod_eq_of_lt]
@[deprecated (since := "2024-04-17")]
alias val_nat_cast_of_lt := val_natCast_of_lt
instance charP (n : ℕ) : CharP (ZMod n) n where
cast_eq_zero_iff' := by
intro k
cases' n with n
· simp [zero_dvd_iff, Int.natCast_eq_zero, Nat.zero_eq]
· exact Fin.natCast_eq_zero
@[simp]
theorem addOrderOf_one (n : ℕ) : addOrderOf (1 : ZMod n) = n :=
CharP.eq _ (CharP.addOrderOf_one _) (ZMod.charP n)
#align zmod.add_order_of_one ZMod.addOrderOf_one
@[simp]
theorem addOrderOf_coe (a : ℕ) {n : ℕ} (n0 : n ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by
cases' a with a
· simp only [Nat.zero_eq, Nat.cast_zero, addOrderOf_zero, Nat.gcd_zero_right,
Nat.pos_of_ne_zero n0, Nat.div_self]
rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a.succ_ne_zero, ZMod.addOrderOf_one]
#align zmod.add_order_of_coe ZMod.addOrderOf_coe
@[simp]
theorem addOrderOf_coe' {a : ℕ} (n : ℕ) (a0 : a ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by
rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a0, ZMod.addOrderOf_one]
#align zmod.add_order_of_coe' ZMod.addOrderOf_coe'
theorem ringChar_zmod_n (n : ℕ) : ringChar (ZMod n) = n := by
rw [ringChar.eq_iff]
exact ZMod.charP n
#align zmod.ring_char_zmod_n ZMod.ringChar_zmod_n
-- @[simp] -- Porting note (#10618): simp can prove this
theorem natCast_self (n : ℕ) : (n : ZMod n) = 0 :=
CharP.cast_eq_zero (ZMod n) n
#align zmod.nat_cast_self ZMod.natCast_self
@[deprecated (since := "2024-04-17")]
alias nat_cast_self := natCast_self
@[simp]
theorem natCast_self' (n : ℕ) : (n + 1 : ZMod (n + 1)) = 0 := by
rw [← Nat.cast_add_one, natCast_self (n + 1)]
#align zmod.nat_cast_self' ZMod.natCast_self'
@[deprecated (since := "2024-04-17")]
alias nat_cast_self' := natCast_self'
section UniversalProperty
variable {n : ℕ} {R : Type*}
section
variable [AddGroupWithOne R]
def cast : ∀ {n : ℕ}, ZMod n → R
| 0 => Int.cast
| _ + 1 => fun i => i.val
#align zmod.cast ZMod.cast
@[simp]
theorem cast_zero : (cast (0 : ZMod n) : R) = 0 := by
delta ZMod.cast
cases n
· exact Int.cast_zero
· simp
#align zmod.cast_zero ZMod.cast_zero
theorem cast_eq_val [NeZero n] (a : ZMod n) : (cast a : R) = a.val := by
cases n
· cases NeZero.ne 0 rfl
rfl
#align zmod.cast_eq_val ZMod.cast_eq_val
variable {S : Type*} [AddGroupWithOne S]
@[simp]
theorem _root_.Prod.fst_zmod_cast (a : ZMod n) : (cast a : R × S).fst = cast a := by
cases n
· rfl
· simp [ZMod.cast]
#align prod.fst_zmod_cast Prod.fst_zmod_cast
@[simp]
theorem _root_.Prod.snd_zmod_cast (a : ZMod n) : (cast a : R × S).snd = cast a := by
cases n
· rfl
· simp [ZMod.cast]
#align prod.snd_zmod_cast Prod.snd_zmod_cast
end
theorem natCast_zmod_val {n : ℕ} [NeZero n] (a : ZMod n) : (a.val : ZMod n) = a := by
cases n
· cases NeZero.ne 0 rfl
· apply Fin.cast_val_eq_self
#align zmod.nat_cast_zmod_val ZMod.natCast_zmod_val
@[deprecated (since := "2024-04-17")]
alias nat_cast_zmod_val := natCast_zmod_val
theorem natCast_rightInverse [NeZero n] : Function.RightInverse val ((↑) : ℕ → ZMod n) :=
natCast_zmod_val
#align zmod.nat_cast_right_inverse ZMod.natCast_rightInverse
@[deprecated (since := "2024-04-17")]
alias nat_cast_rightInverse := natCast_rightInverse
theorem natCast_zmod_surjective [NeZero n] : Function.Surjective ((↑) : ℕ → ZMod n) :=
natCast_rightInverse.surjective
#align zmod.nat_cast_zmod_surjective ZMod.natCast_zmod_surjective
@[deprecated (since := "2024-04-17")]
alias nat_cast_zmod_surjective := natCast_zmod_surjective
@[norm_cast]
theorem intCast_zmod_cast (a : ZMod n) : ((cast a : ℤ) : ZMod n) = a := by
cases n
· simp [ZMod.cast, ZMod]
· dsimp [ZMod.cast, ZMod]
erw [Int.cast_natCast, Fin.cast_val_eq_self]
#align zmod.int_cast_zmod_cast ZMod.intCast_zmod_cast
@[deprecated (since := "2024-04-17")]
alias int_cast_zmod_cast := intCast_zmod_cast
theorem intCast_rightInverse : Function.RightInverse (cast : ZMod n → ℤ) ((↑) : ℤ → ZMod n) :=
intCast_zmod_cast
#align zmod.int_cast_right_inverse ZMod.intCast_rightInverse
@[deprecated (since := "2024-04-17")]
alias int_cast_rightInverse := intCast_rightInverse
theorem intCast_surjective : Function.Surjective ((↑) : ℤ → ZMod n) :=
intCast_rightInverse.surjective
#align zmod.int_cast_surjective ZMod.intCast_surjective
@[deprecated (since := "2024-04-17")]
alias int_cast_surjective := intCast_surjective
theorem cast_id : ∀ (n) (i : ZMod n), (ZMod.cast i : ZMod n) = i
| 0, _ => Int.cast_id
| _ + 1, i => natCast_zmod_val i
#align zmod.cast_id ZMod.cast_id
@[simp]
theorem cast_id' : (ZMod.cast : ZMod n → ZMod n) = id :=
funext (cast_id n)
#align zmod.cast_id' ZMod.cast_id'
variable (R) [Ring R]
@[simp]
theorem natCast_comp_val [NeZero n] : ((↑) : ℕ → R) ∘ (val : ZMod n → ℕ) = cast := by
cases n
· cases NeZero.ne 0 rfl
rfl
#align zmod.nat_cast_comp_val ZMod.natCast_comp_val
@[deprecated (since := "2024-04-17")]
alias nat_cast_comp_val := natCast_comp_val
@[simp]
theorem intCast_comp_cast : ((↑) : ℤ → R) ∘ (cast : ZMod n → ℤ) = cast := by
cases n
· exact congr_arg (Int.cast ∘ ·) ZMod.cast_id'
· ext
simp [ZMod, ZMod.cast]
#align zmod.int_cast_comp_cast ZMod.intCast_comp_cast
@[deprecated (since := "2024-04-17")]
alias int_cast_comp_cast := intCast_comp_cast
variable {R}
@[simp]
theorem natCast_val [NeZero n] (i : ZMod n) : (i.val : R) = cast i :=
congr_fun (natCast_comp_val R) i
#align zmod.nat_cast_val ZMod.natCast_val
@[deprecated (since := "2024-04-17")]
alias nat_cast_val := natCast_val
@[simp]
theorem intCast_cast (i : ZMod n) : ((cast i : ℤ) : R) = cast i :=
congr_fun (intCast_comp_cast R) i
#align zmod.int_cast_cast ZMod.intCast_cast
@[deprecated (since := "2024-04-17")]
alias int_cast_cast := intCast_cast
theorem cast_add_eq_ite {n : ℕ} (a b : ZMod n) :
(cast (a + b) : ℤ) =
if (n : ℤ) ≤ cast a + cast b then (cast a + cast b - n : ℤ) else cast a + cast b := by
cases' n with n
· simp; rfl
change Fin (n + 1) at a b
change ((((a + b) : Fin (n + 1)) : ℕ) : ℤ) = if ((n + 1 : ℕ) : ℤ) ≤ (a : ℕ) + b then _ else _
simp only [Fin.val_add_eq_ite, Int.ofNat_succ, Int.ofNat_le]
norm_cast
split_ifs with h
· rw [Nat.cast_sub h]
congr
· rfl
#align zmod.coe_add_eq_ite ZMod.cast_add_eq_ite
theorem intCast_eq_intCast_iff (a b : ℤ) (c : ℕ) : (a : ZMod c) = (b : ZMod c) ↔ a ≡ b [ZMOD c] :=
CharP.intCast_eq_intCast (ZMod c) c
#align zmod.int_coe_eq_int_coe_iff ZMod.intCast_eq_intCast_iff
@[deprecated (since := "2024-04-17")]
alias int_cast_eq_int_cast_iff := intCast_eq_intCast_iff
theorem intCast_eq_intCast_iff' (a b : ℤ) (c : ℕ) : (a : ZMod c) = (b : ZMod c) ↔ a % c = b % c :=
ZMod.intCast_eq_intCast_iff a b c
#align zmod.int_coe_eq_int_coe_iff' ZMod.intCast_eq_intCast_iff'
@[deprecated (since := "2024-04-17")]
alias int_cast_eq_int_cast_iff' := intCast_eq_intCast_iff'
theorem natCast_eq_natCast_iff (a b c : ℕ) : (a : ZMod c) = (b : ZMod c) ↔ a ≡ b [MOD c] := by
simpa [Int.natCast_modEq_iff] using ZMod.intCast_eq_intCast_iff a b c
#align zmod.nat_coe_eq_nat_coe_iff ZMod.natCast_eq_natCast_iff
@[deprecated (since := "2024-04-17")]
alias nat_cast_eq_nat_cast_iff := natCast_eq_natCast_iff
theorem natCast_eq_natCast_iff' (a b c : ℕ) : (a : ZMod c) = (b : ZMod c) ↔ a % c = b % c :=
ZMod.natCast_eq_natCast_iff a b c
#align zmod.nat_coe_eq_nat_coe_iff' ZMod.natCast_eq_natCast_iff'
@[deprecated (since := "2024-04-17")]
alias nat_cast_eq_nat_cast_iff' := natCast_eq_natCast_iff'
theorem intCast_zmod_eq_zero_iff_dvd (a : ℤ) (b : ℕ) : (a : ZMod b) = 0 ↔ (b : ℤ) ∣ a := by
rw [← Int.cast_zero, ZMod.intCast_eq_intCast_iff, Int.modEq_zero_iff_dvd]
#align zmod.int_coe_zmod_eq_zero_iff_dvd ZMod.intCast_zmod_eq_zero_iff_dvd
@[deprecated (since := "2024-04-17")]
alias int_cast_zmod_eq_zero_iff_dvd := intCast_zmod_eq_zero_iff_dvd
theorem intCast_eq_intCast_iff_dvd_sub (a b : ℤ) (c : ℕ) : (a : ZMod c) = ↑b ↔ ↑c ∣ b - a := by
rw [ZMod.intCast_eq_intCast_iff, Int.modEq_iff_dvd]
#align zmod.int_coe_eq_int_coe_iff_dvd_sub ZMod.intCast_eq_intCast_iff_dvd_sub
@[deprecated (since := "2024-04-17")]
alias int_cast_eq_int_cast_iff_dvd_sub := intCast_eq_intCast_iff_dvd_sub
theorem natCast_zmod_eq_zero_iff_dvd (a b : ℕ) : (a : ZMod b) = 0 ↔ b ∣ a := by
rw [← Nat.cast_zero, ZMod.natCast_eq_natCast_iff, Nat.modEq_zero_iff_dvd]
#align zmod.nat_coe_zmod_eq_zero_iff_dvd ZMod.natCast_zmod_eq_zero_iff_dvd
@[deprecated (since := "2024-04-17")]
alias nat_cast_zmod_eq_zero_iff_dvd := natCast_zmod_eq_zero_iff_dvd
theorem val_intCast {n : ℕ} (a : ℤ) [NeZero n] : ↑(a : ZMod n).val = a % n := by
have hle : (0 : ℤ) ≤ ↑(a : ZMod n).val := Int.natCast_nonneg _
have hlt : ↑(a : ZMod n).val < (n : ℤ) := Int.ofNat_lt.mpr (ZMod.val_lt a)
refine (Int.emod_eq_of_lt hle hlt).symm.trans ?_
rw [← ZMod.intCast_eq_intCast_iff', Int.cast_natCast, ZMod.natCast_val, ZMod.cast_id]
#align zmod.val_int_cast ZMod.val_intCast
@[deprecated (since := "2024-04-17")]
alias val_int_cast := val_intCast
theorem coe_intCast {n : ℕ} (a : ℤ) : cast (a : ZMod n) = a % n := by
cases n
· rw [Int.ofNat_zero, Int.emod_zero, Int.cast_id]; rfl
· rw [← val_intCast, val]; rfl
#align zmod.coe_int_cast ZMod.coe_intCast
@[deprecated (since := "2024-04-17")]
alias coe_int_cast := coe_intCast
@[simp]
theorem val_neg_one (n : ℕ) : (-1 : ZMod n.succ).val = n := by
dsimp [val, Fin.coe_neg]
cases n
· simp [Nat.mod_one]
· dsimp [ZMod, ZMod.cast]
rw [Fin.coe_neg_one]
#align zmod.val_neg_one ZMod.val_neg_one
theorem cast_neg_one {R : Type*} [Ring R] (n : ℕ) : cast (-1 : ZMod n) = (n - 1 : R) := by
cases' n with n
· dsimp [ZMod, ZMod.cast]; simp
· rw [← natCast_val, val_neg_one, Nat.cast_succ, add_sub_cancel_right]
#align zmod.cast_neg_one ZMod.cast_neg_one
theorem cast_sub_one {R : Type*} [Ring R] {n : ℕ} (k : ZMod n) :
(cast (k - 1 : ZMod n) : R) = (if k = 0 then (n : R) else cast k) - 1 := by
split_ifs with hk
· rw [hk, zero_sub, ZMod.cast_neg_one]
· cases n
· dsimp [ZMod, ZMod.cast]
rw [Int.cast_sub, Int.cast_one]
· dsimp [ZMod, ZMod.cast, ZMod.val]
rw [Fin.coe_sub_one, if_neg]
· rw [Nat.cast_sub, Nat.cast_one]
rwa [Fin.ext_iff, Fin.val_zero, ← Ne, ← Nat.one_le_iff_ne_zero] at hk
· exact hk
#align zmod.cast_sub_one ZMod.cast_sub_one
theorem natCast_eq_iff (p : ℕ) (n : ℕ) (z : ZMod p) [NeZero p] :
↑n = z ↔ ∃ k, n = z.val + p * k := by
constructor
· rintro rfl
refine ⟨n / p, ?_⟩
rw [val_natCast, Nat.mod_add_div]
· rintro ⟨k, rfl⟩
rw [Nat.cast_add, natCast_zmod_val, Nat.cast_mul, natCast_self, zero_mul,
add_zero]
#align zmod.nat_coe_zmod_eq_iff ZMod.natCast_eq_iff
theorem intCast_eq_iff (p : ℕ) (n : ℤ) (z : ZMod p) [NeZero p] :
↑n = z ↔ ∃ k, n = z.val + p * k := by
constructor
· rintro rfl
refine ⟨n / p, ?_⟩
rw [val_intCast, Int.emod_add_ediv]
· rintro ⟨k, rfl⟩
rw [Int.cast_add, Int.cast_mul, Int.cast_natCast, Int.cast_natCast, natCast_val,
ZMod.natCast_self, zero_mul, add_zero, cast_id]
#align zmod.int_coe_zmod_eq_iff ZMod.intCast_eq_iff
@[deprecated (since := "2024-05-25")] alias nat_coe_zmod_eq_iff := natCast_eq_iff
@[deprecated (since := "2024-05-25")] alias int_coe_zmod_eq_iff := intCast_eq_iff
@[push_cast, simp]
theorem intCast_mod (a : ℤ) (b : ℕ) : ((a % b : ℤ) : ZMod b) = (a : ZMod b) := by
rw [ZMod.intCast_eq_intCast_iff]
apply Int.mod_modEq
#align zmod.int_cast_mod ZMod.intCast_mod
@[deprecated (since := "2024-04-17")]
alias int_cast_mod := intCast_mod
theorem ker_intCastAddHom (n : ℕ) :
(Int.castAddHom (ZMod n)).ker = AddSubgroup.zmultiples (n : ℤ) := by
ext
rw [Int.mem_zmultiples_iff, AddMonoidHom.mem_ker, Int.coe_castAddHom,
intCast_zmod_eq_zero_iff_dvd]
#align zmod.ker_int_cast_add_hom ZMod.ker_intCastAddHom
@[deprecated (since := "2024-04-17")]
alias ker_int_castAddHom := ker_intCastAddHom
theorem cast_injective_of_le {m n : ℕ} [nzm : NeZero m] (h : m ≤ n) :
Function.Injective (@cast (ZMod n) _ m) := by
cases m with
| zero => cases nzm; simp_all
| succ m =>
rintro ⟨x, hx⟩ ⟨y, hy⟩ f
simp only [cast, val, natCast_eq_natCast_iff',
Nat.mod_eq_of_lt (hx.trans_le h), Nat.mod_eq_of_lt (hy.trans_le h)] at f
apply Fin.ext
exact f
theorem cast_zmod_eq_zero_iff_of_le {m n : ℕ} [NeZero m] (h : m ≤ n) (a : ZMod m) :
(cast a : ZMod n) = 0 ↔ a = 0 := by
rw [← ZMod.cast_zero (n := m)]
exact Injective.eq_iff' (cast_injective_of_le h) rfl
-- Porting note: commented
-- unseal Int.NonNeg
@[simp]
theorem natCast_toNat (p : ℕ) : ∀ {z : ℤ} (_h : 0 ≤ z), (z.toNat : ZMod p) = z
| (n : ℕ), _h => by simp only [Int.cast_natCast, Int.toNat_natCast]
| Int.negSucc n, h => by simp at h
#align zmod.nat_cast_to_nat ZMod.natCast_toNat
@[deprecated (since := "2024-04-17")]
alias nat_cast_toNat := natCast_toNat
theorem val_injective (n : ℕ) [NeZero n] : Function.Injective (val : ZMod n → ℕ) := by
cases n
· cases NeZero.ne 0 rfl
intro a b h
dsimp [ZMod]
ext
exact h
#align zmod.val_injective ZMod.val_injective
theorem val_one_eq_one_mod (n : ℕ) : (1 : ZMod n).val = 1 % n := by
rw [← Nat.cast_one, val_natCast]
#align zmod.val_one_eq_one_mod ZMod.val_one_eq_one_mod
theorem val_one (n : ℕ) [Fact (1 < n)] : (1 : ZMod n).val = 1 := by
rw [val_one_eq_one_mod]
exact Nat.mod_eq_of_lt Fact.out
#align zmod.val_one ZMod.val_one
| Mathlib/Data/ZMod/Basic.lean | 740 | 743 | theorem val_add {n : ℕ} [NeZero n] (a b : ZMod n) : (a + b).val = (a.val + b.val) % n := by |
cases n
· cases NeZero.ne 0 rfl
· apply Fin.val_add
|
import Mathlib.Topology.ContinuousOn
import Mathlib.Order.Filter.SmallSets
#align_import topology.locally_finite from "leanprover-community/mathlib"@"55d771df074d0dd020139ee1cd4b95521422df9f"
-- locally finite family [General Topology (Bourbaki, 1995)]
open Set Function Filter Topology
variable {ι ι' α X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] {f g : ι → Set X}
def LocallyFinite (f : ι → Set X) :=
∀ x : X, ∃ t ∈ 𝓝 x, { i | (f i ∩ t).Nonempty }.Finite
#align locally_finite LocallyFinite
theorem locallyFinite_of_finite [Finite ι] (f : ι → Set X) : LocallyFinite f := fun _ =>
⟨univ, univ_mem, toFinite _⟩
#align locally_finite_of_finite locallyFinite_of_finite
namespace LocallyFinite
theorem point_finite (hf : LocallyFinite f) (x : X) : { b | x ∈ f b }.Finite :=
let ⟨_t, hxt, ht⟩ := hf x
ht.subset fun _b hb => ⟨x, hb, mem_of_mem_nhds hxt⟩
#align locally_finite.point_finite LocallyFinite.point_finite
protected theorem subset (hf : LocallyFinite f) (hg : ∀ i, g i ⊆ f i) : LocallyFinite g := fun a =>
let ⟨t, ht₁, ht₂⟩ := hf a
⟨t, ht₁, ht₂.subset fun i hi => hi.mono <| inter_subset_inter (hg i) Subset.rfl⟩
#align locally_finite.subset LocallyFinite.subset
theorem comp_injOn {g : ι' → ι} (hf : LocallyFinite f) (hg : InjOn g { i | (f (g i)).Nonempty }) :
LocallyFinite (f ∘ g) := fun x => by
let ⟨t, htx, htf⟩ := hf x
refine ⟨t, htx, htf.preimage <| ?_⟩
exact hg.mono fun i (hi : Set.Nonempty _) => hi.left
#align locally_finite.comp_inj_on LocallyFinite.comp_injOn
theorem comp_injective {g : ι' → ι} (hf : LocallyFinite f) (hg : Injective g) :
LocallyFinite (f ∘ g) :=
hf.comp_injOn hg.injOn
#align locally_finite.comp_injective LocallyFinite.comp_injective
theorem _root_.locallyFinite_iff_smallSets :
LocallyFinite f ↔ ∀ x, ∀ᶠ s in (𝓝 x).smallSets, { i | (f i ∩ s).Nonempty }.Finite :=
forall_congr' fun _ => Iff.symm <|
eventually_smallSets' fun _s _t hst ht =>
ht.subset fun _i hi => hi.mono <| inter_subset_inter_right _ hst
#align locally_finite_iff_small_sets locallyFinite_iff_smallSets
protected theorem eventually_smallSets (hf : LocallyFinite f) (x : X) :
∀ᶠ s in (𝓝 x).smallSets, { i | (f i ∩ s).Nonempty }.Finite :=
locallyFinite_iff_smallSets.mp hf x
#align locally_finite.eventually_small_sets LocallyFinite.eventually_smallSets
theorem exists_mem_basis {ι' : Sort*} (hf : LocallyFinite f) {p : ι' → Prop} {s : ι' → Set X}
{x : X} (hb : (𝓝 x).HasBasis p s) : ∃ i, p i ∧ { j | (f j ∩ s i).Nonempty }.Finite :=
let ⟨i, hpi, hi⟩ := hb.smallSets.eventually_iff.mp (hf.eventually_smallSets x)
⟨i, hpi, hi Subset.rfl⟩
#align locally_finite.exists_mem_basis LocallyFinite.exists_mem_basis
protected theorem nhdsWithin_iUnion (hf : LocallyFinite f) (a : X) :
𝓝[⋃ i, f i] a = ⨆ i, 𝓝[f i] a := by
rcases hf a with ⟨U, haU, hfin⟩
refine le_antisymm ?_ (Monotone.le_map_iSup fun _ _ ↦ nhdsWithin_mono _)
calc
𝓝[⋃ i, f i] a = 𝓝[⋃ i, f i ∩ U] a := by
rw [← iUnion_inter, ← nhdsWithin_inter_of_mem' (nhdsWithin_le_nhds haU)]
_ = 𝓝[⋃ i ∈ {j | (f j ∩ U).Nonempty}, (f i ∩ U)] a := by
simp only [mem_setOf_eq, iUnion_nonempty_self]
_ = ⨆ i ∈ {j | (f j ∩ U).Nonempty}, 𝓝[f i ∩ U] a := nhdsWithin_biUnion hfin _ _
_ ≤ ⨆ i, 𝓝[f i ∩ U] a := iSup₂_le_iSup _ _
_ ≤ ⨆ i, 𝓝[f i] a := iSup_mono fun i ↦ nhdsWithin_mono _ inter_subset_left
#align locally_finite.nhds_within_Union LocallyFinite.nhdsWithin_iUnion
theorem continuousOn_iUnion' {g : X → Y} (hf : LocallyFinite f)
(hc : ∀ i x, x ∈ closure (f i) → ContinuousWithinAt g (f i) x) :
ContinuousOn g (⋃ i, f i) := by
rintro x -
rw [ContinuousWithinAt, hf.nhdsWithin_iUnion, tendsto_iSup]
intro i
by_cases hx : x ∈ closure (f i)
· exact hc i _ hx
· rw [mem_closure_iff_nhdsWithin_neBot, not_neBot] at hx
rw [hx]
exact tendsto_bot
#align locally_finite.continuous_on_Union' LocallyFinite.continuousOn_iUnion'
theorem continuousOn_iUnion {g : X → Y} (hf : LocallyFinite f) (h_cl : ∀ i, IsClosed (f i))
(h_cont : ∀ i, ContinuousOn g (f i)) : ContinuousOn g (⋃ i, f i) :=
hf.continuousOn_iUnion' fun i x hx ↦ h_cont i x <| (h_cl i).closure_subset hx
#align locally_finite.continuous_on_Union LocallyFinite.continuousOn_iUnion
protected theorem continuous' {g : X → Y} (hf : LocallyFinite f) (h_cov : ⋃ i, f i = univ)
(hc : ∀ i x, x ∈ closure (f i) → ContinuousWithinAt g (f i) x) :
Continuous g :=
continuous_iff_continuousOn_univ.2 <| h_cov ▸ hf.continuousOn_iUnion' hc
#align locally_finite.continuous' LocallyFinite.continuous'
protected theorem continuous {g : X → Y} (hf : LocallyFinite f) (h_cov : ⋃ i, f i = univ)
(h_cl : ∀ i, IsClosed (f i)) (h_cont : ∀ i, ContinuousOn g (f i)) :
Continuous g :=
continuous_iff_continuousOn_univ.2 <| h_cov ▸ hf.continuousOn_iUnion h_cl h_cont
#align locally_finite.continuous LocallyFinite.continuous
protected theorem closure (hf : LocallyFinite f) : LocallyFinite fun i => closure (f i) := by
intro x
rcases hf x with ⟨s, hsx, hsf⟩
refine ⟨interior s, interior_mem_nhds.2 hsx, hsf.subset fun i hi => ?_⟩
exact (hi.mono isOpen_interior.closure_inter).of_closure.mono
(inter_subset_inter_right _ interior_subset)
#align locally_finite.closure LocallyFinite.closure
theorem closure_iUnion (h : LocallyFinite f) : closure (⋃ i, f i) = ⋃ i, closure (f i) := by
ext x
simp only [mem_closure_iff_nhdsWithin_neBot, h.nhdsWithin_iUnion, iSup_neBot, mem_iUnion]
#align locally_finite.closure_Union LocallyFinite.closure_iUnion
theorem isClosed_iUnion (hf : LocallyFinite f) (hc : ∀ i, IsClosed (f i)) :
IsClosed (⋃ i, f i) := by
simp only [← closure_eq_iff_isClosed, hf.closure_iUnion, (hc _).closure_eq]
#align locally_finite.is_closed_Union LocallyFinite.isClosed_iUnion
| Mathlib/Topology/LocallyFinite.lean | 141 | 146 | theorem iInter_compl_mem_nhds (hf : LocallyFinite f) (hc : ∀ i, IsClosed (f i)) (x : X) :
(⋂ (i) (_ : x ∉ f i), (f i)ᶜ) ∈ 𝓝 x := by |
refine IsOpen.mem_nhds ?_ (mem_iInter₂.2 fun i => id)
suffices IsClosed (⋃ i : { i // x ∉ f i }, f i) by
rwa [← isOpen_compl_iff, compl_iUnion, iInter_subtype] at this
exact (hf.comp_injective Subtype.val_injective).isClosed_iUnion fun i => hc _
|
import Mathlib.Analysis.BoxIntegral.Partition.Basic
#align_import analysis.box_integral.partition.split from "leanprover-community/mathlib"@"6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f"
noncomputable section
open scoped Classical
open Filter
open Function Set Filter
namespace BoxIntegral
variable {ι M : Type*} {n : ℕ}
namespace Box
variable {I : Box ι} {i : ι} {x : ℝ} {y : ι → ℝ}
def splitLower (I : Box ι) (i : ι) (x : ℝ) : WithBot (Box ι) :=
mk' I.lower (update I.upper i (min x (I.upper i)))
#align box_integral.box.split_lower BoxIntegral.Box.splitLower
@[simp]
theorem coe_splitLower : (splitLower I i x : Set (ι → ℝ)) = ↑I ∩ { y | y i ≤ x } := by
rw [splitLower, coe_mk']
ext y
simp only [mem_univ_pi, mem_Ioc, mem_inter_iff, mem_coe, mem_setOf_eq, forall_and, ← Pi.le_def,
le_update_iff, le_min_iff, and_assoc, and_forall_ne (p := fun j => y j ≤ upper I j) i, mem_def]
rw [and_comm (a := y i ≤ x)]
#align box_integral.box.coe_split_lower BoxIntegral.Box.coe_splitLower
theorem splitLower_le : I.splitLower i x ≤ I :=
withBotCoe_subset_iff.1 <| by simp
#align box_integral.box.split_lower_le BoxIntegral.Box.splitLower_le
@[simp]
| Mathlib/Analysis/BoxIntegral/Partition/Split.lean | 78 | 80 | theorem splitLower_eq_bot {i x} : I.splitLower i x = ⊥ ↔ x ≤ I.lower i := by |
rw [splitLower, mk'_eq_bot, exists_update_iff I.upper fun j y => y ≤ I.lower j]
simp [(I.lower_lt_upper _).not_le]
|
import Mathlib.Order.Filter.Prod
#align_import order.filter.n_ary from "leanprover-community/mathlib"@"78f647f8517f021d839a7553d5dc97e79b508dea"
open Function Set
open Filter
namespace Filter
variable {α α' β β' γ γ' δ δ' ε ε' : Type*} {m : α → β → γ} {f f₁ f₂ : Filter α}
{g g₁ g₂ : Filter β} {h h₁ h₂ : Filter γ} {s s₁ s₂ : Set α} {t t₁ t₂ : Set β} {u : Set γ}
{v : Set δ} {a : α} {b : β} {c : γ}
def map₂ (m : α → β → γ) (f : Filter α) (g : Filter β) : Filter γ :=
((f ×ˢ g).map (uncurry m)).copy { s | ∃ u ∈ f, ∃ v ∈ g, image2 m u v ⊆ s } fun _ ↦ by
simp only [mem_map, mem_prod_iff, image2_subset_iff, prod_subset_iff]; rfl
#align filter.map₂ Filter.map₂
@[simp 900]
theorem mem_map₂_iff : u ∈ map₂ m f g ↔ ∃ s ∈ f, ∃ t ∈ g, image2 m s t ⊆ u :=
Iff.rfl
#align filter.mem_map₂_iff Filter.mem_map₂_iff
theorem image2_mem_map₂ (hs : s ∈ f) (ht : t ∈ g) : image2 m s t ∈ map₂ m f g :=
⟨_, hs, _, ht, Subset.rfl⟩
#align filter.image2_mem_map₂ Filter.image2_mem_map₂
theorem map_prod_eq_map₂ (m : α → β → γ) (f : Filter α) (g : Filter β) :
Filter.map (fun p : α × β => m p.1 p.2) (f ×ˢ g) = map₂ m f g := by
rw [map₂, copy_eq, uncurry_def]
#align filter.map_prod_eq_map₂ Filter.map_prod_eq_map₂
theorem map_prod_eq_map₂' (m : α × β → γ) (f : Filter α) (g : Filter β) :
Filter.map m (f ×ˢ g) = map₂ (fun a b => m (a, b)) f g :=
map_prod_eq_map₂ (curry m) f g
#align filter.map_prod_eq_map₂' Filter.map_prod_eq_map₂'
@[simp]
theorem map₂_mk_eq_prod (f : Filter α) (g : Filter β) : map₂ Prod.mk f g = f ×ˢ g := by
simp only [← map_prod_eq_map₂, map_id']
#align filter.map₂_mk_eq_prod Filter.map₂_mk_eq_prod
-- lemma image2_mem_map₂_iff (hm : injective2 m) : image2 m s t ∈ map₂ m f g ↔ s ∈ f ∧ t ∈ g :=
-- ⟨by { rintro ⟨u, v, hu, hv, h⟩, rw image2_subset_image2_iff hm at h,
-- exact ⟨mem_of_superset hu h.1, mem_of_superset hv h.2⟩ }, λ h, image2_mem_map₂ h.1 h.2⟩
theorem map₂_mono (hf : f₁ ≤ f₂) (hg : g₁ ≤ g₂) : map₂ m f₁ g₁ ≤ map₂ m f₂ g₂ :=
fun _ ⟨s, hs, t, ht, hst⟩ => ⟨s, hf hs, t, hg ht, hst⟩
#align filter.map₂_mono Filter.map₂_mono
theorem map₂_mono_left (h : g₁ ≤ g₂) : map₂ m f g₁ ≤ map₂ m f g₂ :=
map₂_mono Subset.rfl h
#align filter.map₂_mono_left Filter.map₂_mono_left
theorem map₂_mono_right (h : f₁ ≤ f₂) : map₂ m f₁ g ≤ map₂ m f₂ g :=
map₂_mono h Subset.rfl
#align filter.map₂_mono_right Filter.map₂_mono_right
@[simp]
theorem le_map₂_iff {h : Filter γ} :
h ≤ map₂ m f g ↔ ∀ ⦃s⦄, s ∈ f → ∀ ⦃t⦄, t ∈ g → image2 m s t ∈ h :=
⟨fun H _ hs _ ht => H <| image2_mem_map₂ hs ht, fun H _ ⟨_, hs, _, ht, hu⟩ =>
mem_of_superset (H hs ht) hu⟩
#align filter.le_map₂_iff Filter.le_map₂_iff
@[simp]
theorem map₂_eq_bot_iff : map₂ m f g = ⊥ ↔ f = ⊥ ∨ g = ⊥ := by simp [← map_prod_eq_map₂]
#align filter.map₂_eq_bot_iff Filter.map₂_eq_bot_iff
@[simp]
theorem map₂_bot_left : map₂ m ⊥ g = ⊥ := map₂_eq_bot_iff.2 <| .inl rfl
#align filter.map₂_bot_left Filter.map₂_bot_left
@[simp]
theorem map₂_bot_right : map₂ m f ⊥ = ⊥ := map₂_eq_bot_iff.2 <| .inr rfl
#align filter.map₂_bot_right Filter.map₂_bot_right
@[simp]
theorem map₂_neBot_iff : (map₂ m f g).NeBot ↔ f.NeBot ∧ g.NeBot := by simp [neBot_iff, not_or]
#align filter.map₂_ne_bot_iff Filter.map₂_neBot_iff
protected theorem NeBot.map₂ (hf : f.NeBot) (hg : g.NeBot) : (map₂ m f g).NeBot :=
map₂_neBot_iff.2 ⟨hf, hg⟩
#align filter.ne_bot.map₂ Filter.NeBot.map₂
instance map₂.neBot [NeBot f] [NeBot g] : NeBot (map₂ m f g) := .map₂ ‹_› ‹_›
theorem NeBot.of_map₂_left (h : (map₂ m f g).NeBot) : f.NeBot :=
(map₂_neBot_iff.1 h).1
#align filter.ne_bot.of_map₂_left Filter.NeBot.of_map₂_left
theorem NeBot.of_map₂_right (h : (map₂ m f g).NeBot) : g.NeBot :=
(map₂_neBot_iff.1 h).2
#align filter.ne_bot.of_map₂_right Filter.NeBot.of_map₂_right
| Mathlib/Order/Filter/NAry.lean | 120 | 121 | theorem map₂_sup_left : map₂ m (f₁ ⊔ f₂) g = map₂ m f₁ g ⊔ map₂ m f₂ g := by |
simp_rw [← map_prod_eq_map₂, sup_prod, map_sup]
|
import Mathlib.Analysis.InnerProductSpace.Rayleigh
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Algebra.DirectSum.Decomposition
import Mathlib.LinearAlgebra.Eigenspace.Minpoly
#align_import analysis.inner_product_space.spectrum from "leanprover-community/mathlib"@"6b0169218d01f2837d79ea2784882009a0da1aa1"
variable {𝕜 : Type*} [RCLike 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => @inner 𝕜 E _ x y
open scoped ComplexConjugate
open Module.End
namespace LinearMap
namespace IsSymmetric
variable {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric)
theorem invariant_orthogonalComplement_eigenspace (μ : 𝕜) (v : E) (hv : v ∈ (eigenspace T μ)ᗮ) :
T v ∈ (eigenspace T μ)ᗮ := by
intro w hw
have : T w = (μ : 𝕜) • w := by rwa [mem_eigenspace_iff] at hw
simp [← hT w, this, inner_smul_left, hv w hw]
#align linear_map.is_symmetric.invariant_orthogonal_eigenspace LinearMap.IsSymmetric.invariant_orthogonalComplement_eigenspace
theorem conj_eigenvalue_eq_self {μ : 𝕜} (hμ : HasEigenvalue T μ) : conj μ = μ := by
obtain ⟨v, hv₁, hv₂⟩ := hμ.exists_hasEigenvector
rw [mem_eigenspace_iff] at hv₁
simpa [hv₂, inner_smul_left, inner_smul_right, hv₁] using hT v v
#align linear_map.is_symmetric.conj_eigenvalue_eq_self LinearMap.IsSymmetric.conj_eigenvalue_eq_self
theorem orthogonalFamily_eigenspaces :
OrthogonalFamily 𝕜 (fun μ => eigenspace T μ) fun μ => (eigenspace T μ).subtypeₗᵢ := by
rintro μ ν hμν ⟨v, hv⟩ ⟨w, hw⟩
by_cases hv' : v = 0
· simp [hv']
have H := hT.conj_eigenvalue_eq_self (hasEigenvalue_of_hasEigenvector ⟨hv, hv'⟩)
rw [mem_eigenspace_iff] at hv hw
refine Or.resolve_left ?_ hμν.symm
simpa [inner_smul_left, inner_smul_right, hv, hw, H] using (hT v w).symm
#align linear_map.is_symmetric.orthogonal_family_eigenspaces LinearMap.IsSymmetric.orthogonalFamily_eigenspaces
theorem orthogonalFamily_eigenspaces' :
OrthogonalFamily 𝕜 (fun μ : Eigenvalues T => eigenspace T μ) fun μ =>
(eigenspace T μ).subtypeₗᵢ :=
hT.orthogonalFamily_eigenspaces.comp Subtype.coe_injective
#align linear_map.is_symmetric.orthogonal_family_eigenspaces' LinearMap.IsSymmetric.orthogonalFamily_eigenspaces'
theorem orthogonalComplement_iSup_eigenspaces_invariant ⦃v : E⦄ (hv : v ∈ (⨆ μ, eigenspace T μ)ᗮ) :
T v ∈ (⨆ μ, eigenspace T μ)ᗮ := by
rw [← Submodule.iInf_orthogonal] at hv ⊢
exact T.iInf_invariant hT.invariant_orthogonalComplement_eigenspace v hv
#align linear_map.is_symmetric.orthogonal_supr_eigenspaces_invariant LinearMap.IsSymmetric.orthogonalComplement_iSup_eigenspaces_invariant
theorem orthogonalComplement_iSup_eigenspaces (μ : 𝕜) :
eigenspace (T.restrict hT.orthogonalComplement_iSup_eigenspaces_invariant) μ = ⊥ := by
set p : Submodule 𝕜 E := (⨆ μ, eigenspace T μ)ᗮ
refine eigenspace_restrict_eq_bot hT.orthogonalComplement_iSup_eigenspaces_invariant ?_
have H₂ : eigenspace T μ ⟂ p := (Submodule.isOrtho_orthogonal_right _).mono_left (le_iSup _ _)
exact H₂.disjoint
#align linear_map.is_symmetric.orthogonal_supr_eigenspaces LinearMap.IsSymmetric.orthogonalComplement_iSup_eigenspaces
variable [FiniteDimensional 𝕜 E]
| Mathlib/Analysis/InnerProductSpace/Spectrum.lean | 125 | 131 | theorem orthogonalComplement_iSup_eigenspaces_eq_bot : (⨆ μ, eigenspace T μ)ᗮ = ⊥ := by |
have hT' : IsSymmetric _ :=
hT.restrict_invariant hT.orthogonalComplement_iSup_eigenspaces_invariant
-- a self-adjoint operator on a nontrivial inner product space has an eigenvalue
haveI :=
hT'.subsingleton_of_no_eigenvalue_finiteDimensional hT.orthogonalComplement_iSup_eigenspaces
exact Submodule.eq_bot_of_subsingleton
|
import Mathlib.Algebra.Module.BigOperators
import Mathlib.Data.Fintype.Perm
import Mathlib.GroupTheory.Perm.Finite
import Mathlib.GroupTheory.Perm.List
#align_import group_theory.perm.cycle.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
open Equiv Function Finset
variable {ι α β : Type*}
namespace Equiv.Perm
section SameCycle
variable {f g : Perm α} {p : α → Prop} {x y z : α}
def SameCycle (f : Perm α) (x y : α) : Prop :=
∃ i : ℤ, (f ^ i) x = y
#align equiv.perm.same_cycle Equiv.Perm.SameCycle
@[refl]
theorem SameCycle.refl (f : Perm α) (x : α) : SameCycle f x x :=
⟨0, rfl⟩
#align equiv.perm.same_cycle.refl Equiv.Perm.SameCycle.refl
theorem SameCycle.rfl : SameCycle f x x :=
SameCycle.refl _ _
#align equiv.perm.same_cycle.rfl Equiv.Perm.SameCycle.rfl
protected theorem _root_.Eq.sameCycle (h : x = y) (f : Perm α) : f.SameCycle x y := by rw [h]
#align eq.same_cycle Eq.sameCycle
@[symm]
theorem SameCycle.symm : SameCycle f x y → SameCycle f y x := fun ⟨i, hi⟩ =>
⟨-i, by rw [zpow_neg, ← hi, inv_apply_self]⟩
#align equiv.perm.same_cycle.symm Equiv.Perm.SameCycle.symm
theorem sameCycle_comm : SameCycle f x y ↔ SameCycle f y x :=
⟨SameCycle.symm, SameCycle.symm⟩
#align equiv.perm.same_cycle_comm Equiv.Perm.sameCycle_comm
@[trans]
theorem SameCycle.trans : SameCycle f x y → SameCycle f y z → SameCycle f x z :=
fun ⟨i, hi⟩ ⟨j, hj⟩ => ⟨j + i, by rw [zpow_add, mul_apply, hi, hj]⟩
#align equiv.perm.same_cycle.trans Equiv.Perm.SameCycle.trans
variable (f) in
theorem SameCycle.equivalence : Equivalence (SameCycle f) :=
⟨SameCycle.refl f, SameCycle.symm, SameCycle.trans⟩
def SameCycle.setoid (f : Perm α) : Setoid α where
iseqv := SameCycle.equivalence f
@[simp]
theorem sameCycle_one : SameCycle 1 x y ↔ x = y := by simp [SameCycle]
#align equiv.perm.same_cycle_one Equiv.Perm.sameCycle_one
@[simp]
theorem sameCycle_inv : SameCycle f⁻¹ x y ↔ SameCycle f x y :=
(Equiv.neg _).exists_congr_left.trans <| by simp [SameCycle]
#align equiv.perm.same_cycle_inv Equiv.Perm.sameCycle_inv
alias ⟨SameCycle.of_inv, SameCycle.inv⟩ := sameCycle_inv
#align equiv.perm.same_cycle.of_inv Equiv.Perm.SameCycle.of_inv
#align equiv.perm.same_cycle.inv Equiv.Perm.SameCycle.inv
@[simp]
theorem sameCycle_conj : SameCycle (g * f * g⁻¹) x y ↔ SameCycle f (g⁻¹ x) (g⁻¹ y) :=
exists_congr fun i => by simp [conj_zpow, eq_inv_iff_eq]
#align equiv.perm.same_cycle_conj Equiv.Perm.sameCycle_conj
| Mathlib/GroupTheory/Perm/Cycle/Basic.lean | 107 | 108 | theorem SameCycle.conj : SameCycle f x y → SameCycle (g * f * g⁻¹) (g x) (g y) := by |
simp [sameCycle_conj]
|
import Mathlib.Combinatorics.SimpleGraph.Subgraph
import Mathlib.Data.List.Rotate
#align_import combinatorics.simple_graph.connectivity from "leanprover-community/mathlib"@"b99e2d58a5e6861833fa8de11e51a81144258db4"
open Function
universe u v w
namespace SimpleGraph
variable {V : Type u} {V' : Type v} {V'' : Type w}
variable (G : SimpleGraph V) (G' : SimpleGraph V') (G'' : SimpleGraph V'')
inductive Walk : V → V → Type u
| nil {u : V} : Walk u u
| cons {u v w : V} (h : G.Adj u v) (p : Walk v w) : Walk u w
deriving DecidableEq
#align simple_graph.walk SimpleGraph.Walk
attribute [refl] Walk.nil
@[simps]
instance Walk.instInhabited (v : V) : Inhabited (G.Walk v v) := ⟨Walk.nil⟩
#align simple_graph.walk.inhabited SimpleGraph.Walk.instInhabited
@[match_pattern, reducible]
def Adj.toWalk {G : SimpleGraph V} {u v : V} (h : G.Adj u v) : G.Walk u v :=
Walk.cons h Walk.nil
#align simple_graph.adj.to_walk SimpleGraph.Adj.toWalk
namespace Walk
variable {G}
@[match_pattern]
abbrev nil' (u : V) : G.Walk u u := Walk.nil
#align simple_graph.walk.nil' SimpleGraph.Walk.nil'
@[match_pattern]
abbrev cons' (u v w : V) (h : G.Adj u v) (p : G.Walk v w) : G.Walk u w := Walk.cons h p
#align simple_graph.walk.cons' SimpleGraph.Walk.cons'
protected def copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') : G.Walk u' v' :=
hu ▸ hv ▸ p
#align simple_graph.walk.copy SimpleGraph.Walk.copy
@[simp]
theorem copy_rfl_rfl {u v} (p : G.Walk u v) : p.copy rfl rfl = p := rfl
#align simple_graph.walk.copy_rfl_rfl SimpleGraph.Walk.copy_rfl_rfl
@[simp]
theorem copy_copy {u v u' v' u'' v''} (p : G.Walk u v)
(hu : u = u') (hv : v = v') (hu' : u' = u'') (hv' : v' = v'') :
(p.copy hu hv).copy hu' hv' = p.copy (hu.trans hu') (hv.trans hv') := by
subst_vars
rfl
#align simple_graph.walk.copy_copy SimpleGraph.Walk.copy_copy
@[simp]
theorem copy_nil {u u'} (hu : u = u') : (Walk.nil : G.Walk u u).copy hu hu = Walk.nil := by
subst_vars
rfl
#align simple_graph.walk.copy_nil SimpleGraph.Walk.copy_nil
theorem copy_cons {u v w u' w'} (h : G.Adj u v) (p : G.Walk v w) (hu : u = u') (hw : w = w') :
(Walk.cons h p).copy hu hw = Walk.cons (hu ▸ h) (p.copy rfl hw) := by
subst_vars
rfl
#align simple_graph.walk.copy_cons SimpleGraph.Walk.copy_cons
@[simp]
theorem cons_copy {u v w v' w'} (h : G.Adj u v) (p : G.Walk v' w') (hv : v' = v) (hw : w' = w) :
Walk.cons h (p.copy hv hw) = (Walk.cons (hv ▸ h) p).copy rfl hw := by
subst_vars
rfl
#align simple_graph.walk.cons_copy SimpleGraph.Walk.cons_copy
theorem exists_eq_cons_of_ne {u v : V} (hne : u ≠ v) :
∀ (p : G.Walk u v), ∃ (w : V) (h : G.Adj u w) (p' : G.Walk w v), p = cons h p'
| nil => (hne rfl).elim
| cons h p' => ⟨_, h, p', rfl⟩
#align simple_graph.walk.exists_eq_cons_of_ne SimpleGraph.Walk.exists_eq_cons_of_ne
def length {u v : V} : G.Walk u v → ℕ
| nil => 0
| cons _ q => q.length.succ
#align simple_graph.walk.length SimpleGraph.Walk.length
@[trans]
def append {u v w : V} : G.Walk u v → G.Walk v w → G.Walk u w
| nil, q => q
| cons h p, q => cons h (p.append q)
#align simple_graph.walk.append SimpleGraph.Walk.append
def concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) : G.Walk u w := p.append (cons h nil)
#align simple_graph.walk.concat SimpleGraph.Walk.concat
theorem concat_eq_append {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
p.concat h = p.append (cons h nil) := rfl
#align simple_graph.walk.concat_eq_append SimpleGraph.Walk.concat_eq_append
protected def reverseAux {u v w : V} : G.Walk u v → G.Walk u w → G.Walk v w
| nil, q => q
| cons h p, q => Walk.reverseAux p (cons (G.symm h) q)
#align simple_graph.walk.reverse_aux SimpleGraph.Walk.reverseAux
@[symm]
def reverse {u v : V} (w : G.Walk u v) : G.Walk v u := w.reverseAux nil
#align simple_graph.walk.reverse SimpleGraph.Walk.reverse
def getVert {u v : V} : G.Walk u v → ℕ → V
| nil, _ => u
| cons _ _, 0 => u
| cons _ q, n + 1 => q.getVert n
#align simple_graph.walk.get_vert SimpleGraph.Walk.getVert
@[simp]
theorem getVert_zero {u v} (w : G.Walk u v) : w.getVert 0 = u := by cases w <;> rfl
#align simple_graph.walk.get_vert_zero SimpleGraph.Walk.getVert_zero
theorem getVert_of_length_le {u v} (w : G.Walk u v) {i : ℕ} (hi : w.length ≤ i) :
w.getVert i = v := by
induction w generalizing i with
| nil => rfl
| cons _ _ ih =>
cases i
· cases hi
· exact ih (Nat.succ_le_succ_iff.1 hi)
#align simple_graph.walk.get_vert_of_length_le SimpleGraph.Walk.getVert_of_length_le
@[simp]
theorem getVert_length {u v} (w : G.Walk u v) : w.getVert w.length = v :=
w.getVert_of_length_le rfl.le
#align simple_graph.walk.get_vert_length SimpleGraph.Walk.getVert_length
theorem adj_getVert_succ {u v} (w : G.Walk u v) {i : ℕ} (hi : i < w.length) :
G.Adj (w.getVert i) (w.getVert (i + 1)) := by
induction w generalizing i with
| nil => cases hi
| cons hxy _ ih =>
cases i
· simp [getVert, hxy]
· exact ih (Nat.succ_lt_succ_iff.1 hi)
#align simple_graph.walk.adj_get_vert_succ SimpleGraph.Walk.adj_getVert_succ
@[simp]
theorem cons_append {u v w x : V} (h : G.Adj u v) (p : G.Walk v w) (q : G.Walk w x) :
(cons h p).append q = cons h (p.append q) := rfl
#align simple_graph.walk.cons_append SimpleGraph.Walk.cons_append
@[simp]
theorem cons_nil_append {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h nil).append p = cons h p := rfl
#align simple_graph.walk.cons_nil_append SimpleGraph.Walk.cons_nil_append
@[simp]
theorem append_nil {u v : V} (p : G.Walk u v) : p.append nil = p := by
induction p with
| nil => rfl
| cons _ _ ih => rw [cons_append, ih]
#align simple_graph.walk.append_nil SimpleGraph.Walk.append_nil
@[simp]
theorem nil_append {u v : V} (p : G.Walk u v) : nil.append p = p :=
rfl
#align simple_graph.walk.nil_append SimpleGraph.Walk.nil_append
theorem append_assoc {u v w x : V} (p : G.Walk u v) (q : G.Walk v w) (r : G.Walk w x) :
p.append (q.append r) = (p.append q).append r := by
induction p with
| nil => rfl
| cons h p' ih =>
dsimp only [append]
rw [ih]
#align simple_graph.walk.append_assoc SimpleGraph.Walk.append_assoc
@[simp]
theorem append_copy_copy {u v w u' v' w'} (p : G.Walk u v) (q : G.Walk v w)
(hu : u = u') (hv : v = v') (hw : w = w') :
(p.copy hu hv).append (q.copy hv hw) = (p.append q).copy hu hw := by
subst_vars
rfl
#align simple_graph.walk.append_copy_copy SimpleGraph.Walk.append_copy_copy
theorem concat_nil {u v : V} (h : G.Adj u v) : nil.concat h = cons h nil := rfl
#align simple_graph.walk.concat_nil SimpleGraph.Walk.concat_nil
@[simp]
theorem concat_cons {u v w x : V} (h : G.Adj u v) (p : G.Walk v w) (h' : G.Adj w x) :
(cons h p).concat h' = cons h (p.concat h') := rfl
#align simple_graph.walk.concat_cons SimpleGraph.Walk.concat_cons
theorem append_concat {u v w x : V} (p : G.Walk u v) (q : G.Walk v w) (h : G.Adj w x) :
p.append (q.concat h) = (p.append q).concat h := append_assoc _ _ _
#align simple_graph.walk.append_concat SimpleGraph.Walk.append_concat
theorem concat_append {u v w x : V} (p : G.Walk u v) (h : G.Adj v w) (q : G.Walk w x) :
(p.concat h).append q = p.append (cons h q) := by
rw [concat_eq_append, ← append_assoc, cons_nil_append]
#align simple_graph.walk.concat_append SimpleGraph.Walk.concat_append
theorem exists_cons_eq_concat {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
∃ (x : V) (q : G.Walk u x) (h' : G.Adj x w), cons h p = q.concat h' := by
induction p generalizing u with
| nil => exact ⟨_, nil, h, rfl⟩
| cons h' p ih =>
obtain ⟨y, q, h'', hc⟩ := ih h'
refine ⟨y, cons h q, h'', ?_⟩
rw [concat_cons, hc]
#align simple_graph.walk.exists_cons_eq_concat SimpleGraph.Walk.exists_cons_eq_concat
theorem exists_concat_eq_cons {u v w : V} :
∀ (p : G.Walk u v) (h : G.Adj v w),
∃ (x : V) (h' : G.Adj u x) (q : G.Walk x w), p.concat h = cons h' q
| nil, h => ⟨_, h, nil, rfl⟩
| cons h' p, h => ⟨_, h', Walk.concat p h, concat_cons _ _ _⟩
#align simple_graph.walk.exists_concat_eq_cons SimpleGraph.Walk.exists_concat_eq_cons
@[simp]
theorem reverse_nil {u : V} : (nil : G.Walk u u).reverse = nil := rfl
#align simple_graph.walk.reverse_nil SimpleGraph.Walk.reverse_nil
theorem reverse_singleton {u v : V} (h : G.Adj u v) : (cons h nil).reverse = cons (G.symm h) nil :=
rfl
#align simple_graph.walk.reverse_singleton SimpleGraph.Walk.reverse_singleton
@[simp]
theorem cons_reverseAux {u v w x : V} (p : G.Walk u v) (q : G.Walk w x) (h : G.Adj w u) :
(cons h p).reverseAux q = p.reverseAux (cons (G.symm h) q) := rfl
#align simple_graph.walk.cons_reverse_aux SimpleGraph.Walk.cons_reverseAux
@[simp]
protected theorem append_reverseAux {u v w x : V}
(p : G.Walk u v) (q : G.Walk v w) (r : G.Walk u x) :
(p.append q).reverseAux r = q.reverseAux (p.reverseAux r) := by
induction p with
| nil => rfl
| cons h _ ih => exact ih q (cons (G.symm h) r)
#align simple_graph.walk.append_reverse_aux SimpleGraph.Walk.append_reverseAux
@[simp]
protected theorem reverseAux_append {u v w x : V}
(p : G.Walk u v) (q : G.Walk u w) (r : G.Walk w x) :
(p.reverseAux q).append r = p.reverseAux (q.append r) := by
induction p with
| nil => rfl
| cons h _ ih => simp [ih (cons (G.symm h) q)]
#align simple_graph.walk.reverse_aux_append SimpleGraph.Walk.reverseAux_append
protected theorem reverseAux_eq_reverse_append {u v w : V} (p : G.Walk u v) (q : G.Walk u w) :
p.reverseAux q = p.reverse.append q := by simp [reverse]
#align simple_graph.walk.reverse_aux_eq_reverse_append SimpleGraph.Walk.reverseAux_eq_reverse_append
@[simp]
theorem reverse_cons {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h p).reverse = p.reverse.append (cons (G.symm h) nil) := by simp [reverse]
#align simple_graph.walk.reverse_cons SimpleGraph.Walk.reverse_cons
@[simp]
theorem reverse_copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') :
(p.copy hu hv).reverse = p.reverse.copy hv hu := by
subst_vars
rfl
#align simple_graph.walk.reverse_copy SimpleGraph.Walk.reverse_copy
@[simp]
theorem reverse_append {u v w : V} (p : G.Walk u v) (q : G.Walk v w) :
(p.append q).reverse = q.reverse.append p.reverse := by simp [reverse]
#align simple_graph.walk.reverse_append SimpleGraph.Walk.reverse_append
@[simp]
theorem reverse_concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
(p.concat h).reverse = cons (G.symm h) p.reverse := by simp [concat_eq_append]
#align simple_graph.walk.reverse_concat SimpleGraph.Walk.reverse_concat
@[simp]
theorem reverse_reverse {u v : V} (p : G.Walk u v) : p.reverse.reverse = p := by
induction p with
| nil => rfl
| cons _ _ ih => simp [ih]
#align simple_graph.walk.reverse_reverse SimpleGraph.Walk.reverse_reverse
@[simp]
theorem length_nil {u : V} : (nil : G.Walk u u).length = 0 := rfl
#align simple_graph.walk.length_nil SimpleGraph.Walk.length_nil
@[simp]
theorem length_cons {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h p).length = p.length + 1 := rfl
#align simple_graph.walk.length_cons SimpleGraph.Walk.length_cons
@[simp]
theorem length_copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') :
(p.copy hu hv).length = p.length := by
subst_vars
rfl
#align simple_graph.walk.length_copy SimpleGraph.Walk.length_copy
@[simp]
theorem length_append {u v w : V} (p : G.Walk u v) (q : G.Walk v w) :
(p.append q).length = p.length + q.length := by
induction p with
| nil => simp
| cons _ _ ih => simp [ih, add_comm, add_left_comm, add_assoc]
#align simple_graph.walk.length_append SimpleGraph.Walk.length_append
@[simp]
theorem length_concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
(p.concat h).length = p.length + 1 := length_append _ _
#align simple_graph.walk.length_concat SimpleGraph.Walk.length_concat
@[simp]
protected theorem length_reverseAux {u v w : V} (p : G.Walk u v) (q : G.Walk u w) :
(p.reverseAux q).length = p.length + q.length := by
induction p with
| nil => simp!
| cons _ _ ih => simp [ih, Nat.succ_add, Nat.add_assoc]
#align simple_graph.walk.length_reverse_aux SimpleGraph.Walk.length_reverseAux
@[simp]
theorem length_reverse {u v : V} (p : G.Walk u v) : p.reverse.length = p.length := by simp [reverse]
#align simple_graph.walk.length_reverse SimpleGraph.Walk.length_reverse
theorem eq_of_length_eq_zero {u v : V} : ∀ {p : G.Walk u v}, p.length = 0 → u = v
| nil, _ => rfl
#align simple_graph.walk.eq_of_length_eq_zero SimpleGraph.Walk.eq_of_length_eq_zero
theorem adj_of_length_eq_one {u v : V} : ∀ {p : G.Walk u v}, p.length = 1 → G.Adj u v
| cons h nil, _ => h
@[simp]
theorem exists_length_eq_zero_iff {u v : V} : (∃ p : G.Walk u v, p.length = 0) ↔ u = v := by
constructor
· rintro ⟨p, hp⟩
exact eq_of_length_eq_zero hp
· rintro rfl
exact ⟨nil, rfl⟩
#align simple_graph.walk.exists_length_eq_zero_iff SimpleGraph.Walk.exists_length_eq_zero_iff
@[simp]
theorem length_eq_zero_iff {u : V} {p : G.Walk u u} : p.length = 0 ↔ p = nil := by cases p <;> simp
#align simple_graph.walk.length_eq_zero_iff SimpleGraph.Walk.length_eq_zero_iff
theorem getVert_append {u v w : V} (p : G.Walk u v) (q : G.Walk v w) (i : ℕ) :
(p.append q).getVert i = if i < p.length then p.getVert i else q.getVert (i - p.length) := by
induction p generalizing i with
| nil => simp
| cons h p ih => cases i <;> simp [getVert, ih, Nat.succ_lt_succ_iff]
theorem getVert_reverse {u v : V} (p : G.Walk u v) (i : ℕ) :
p.reverse.getVert i = p.getVert (p.length - i) := by
induction p with
| nil => rfl
| cons h p ih =>
simp only [reverse_cons, getVert_append, length_reverse, ih, length_cons]
split_ifs
next hi =>
rw [Nat.succ_sub hi.le]
simp [getVert]
next hi =>
obtain rfl | hi' := Nat.eq_or_lt_of_not_lt hi
· simp [getVert]
· rw [Nat.eq_add_of_sub_eq (Nat.sub_pos_of_lt hi') rfl, Nat.sub_eq_zero_of_le hi']
simp [getVert]
theorem concat_ne_nil {u v : V} (p : G.Walk u v) (h : G.Adj v u) : p.concat h ≠ nil := by
cases p <;> simp [concat]
#align simple_graph.walk.concat_ne_nil SimpleGraph.Walk.concat_ne_nil
theorem concat_inj {u v v' w : V} {p : G.Walk u v} {h : G.Adj v w} {p' : G.Walk u v'}
{h' : G.Adj v' w} (he : p.concat h = p'.concat h') : ∃ hv : v = v', p.copy rfl hv = p' := by
induction p with
| nil =>
cases p'
· exact ⟨rfl, rfl⟩
· exfalso
simp only [concat_nil, concat_cons, cons.injEq] at he
obtain ⟨rfl, he⟩ := he
simp only [heq_iff_eq] at he
exact concat_ne_nil _ _ he.symm
| cons _ _ ih =>
rw [concat_cons] at he
cases p'
· exfalso
simp only [concat_nil, cons.injEq] at he
obtain ⟨rfl, he⟩ := he
rw [heq_iff_eq] at he
exact concat_ne_nil _ _ he
· rw [concat_cons, cons.injEq] at he
obtain ⟨rfl, he⟩ := he
rw [heq_iff_eq] at he
obtain ⟨rfl, rfl⟩ := ih he
exact ⟨rfl, rfl⟩
#align simple_graph.walk.concat_inj SimpleGraph.Walk.concat_inj
def support {u v : V} : G.Walk u v → List V
| nil => [u]
| cons _ p => u :: p.support
#align simple_graph.walk.support SimpleGraph.Walk.support
def darts {u v : V} : G.Walk u v → List G.Dart
| nil => []
| cons h p => ⟨(u, _), h⟩ :: p.darts
#align simple_graph.walk.darts SimpleGraph.Walk.darts
def edges {u v : V} (p : G.Walk u v) : List (Sym2 V) := p.darts.map Dart.edge
#align simple_graph.walk.edges SimpleGraph.Walk.edges
@[simp]
theorem support_nil {u : V} : (nil : G.Walk u u).support = [u] := rfl
#align simple_graph.walk.support_nil SimpleGraph.Walk.support_nil
@[simp]
theorem support_cons {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h p).support = u :: p.support := rfl
#align simple_graph.walk.support_cons SimpleGraph.Walk.support_cons
@[simp]
theorem support_concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
(p.concat h).support = p.support.concat w := by
induction p <;> simp [*, concat_nil]
#align simple_graph.walk.support_concat SimpleGraph.Walk.support_concat
@[simp]
theorem support_copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') :
(p.copy hu hv).support = p.support := by
subst_vars
rfl
#align simple_graph.walk.support_copy SimpleGraph.Walk.support_copy
theorem support_append {u v w : V} (p : G.Walk u v) (p' : G.Walk v w) :
(p.append p').support = p.support ++ p'.support.tail := by
induction p <;> cases p' <;> simp [*]
#align simple_graph.walk.support_append SimpleGraph.Walk.support_append
@[simp]
theorem support_reverse {u v : V} (p : G.Walk u v) : p.reverse.support = p.support.reverse := by
induction p <;> simp [support_append, *]
#align simple_graph.walk.support_reverse SimpleGraph.Walk.support_reverse
@[simp]
theorem support_ne_nil {u v : V} (p : G.Walk u v) : p.support ≠ [] := by cases p <;> simp
#align simple_graph.walk.support_ne_nil SimpleGraph.Walk.support_ne_nil
theorem tail_support_append {u v w : V} (p : G.Walk u v) (p' : G.Walk v w) :
(p.append p').support.tail = p.support.tail ++ p'.support.tail := by
rw [support_append, List.tail_append_of_ne_nil _ _ (support_ne_nil _)]
#align simple_graph.walk.tail_support_append SimpleGraph.Walk.tail_support_append
theorem support_eq_cons {u v : V} (p : G.Walk u v) : p.support = u :: p.support.tail := by
cases p <;> simp
#align simple_graph.walk.support_eq_cons SimpleGraph.Walk.support_eq_cons
@[simp]
theorem start_mem_support {u v : V} (p : G.Walk u v) : u ∈ p.support := by cases p <;> simp
#align simple_graph.walk.start_mem_support SimpleGraph.Walk.start_mem_support
@[simp]
theorem end_mem_support {u v : V} (p : G.Walk u v) : v ∈ p.support := by induction p <;> simp [*]
#align simple_graph.walk.end_mem_support SimpleGraph.Walk.end_mem_support
@[simp]
theorem support_nonempty {u v : V} (p : G.Walk u v) : { w | w ∈ p.support }.Nonempty :=
⟨u, by simp⟩
#align simple_graph.walk.support_nonempty SimpleGraph.Walk.support_nonempty
theorem mem_support_iff {u v w : V} (p : G.Walk u v) :
w ∈ p.support ↔ w = u ∨ w ∈ p.support.tail := by cases p <;> simp
#align simple_graph.walk.mem_support_iff SimpleGraph.Walk.mem_support_iff
theorem mem_support_nil_iff {u v : V} : u ∈ (nil : G.Walk v v).support ↔ u = v := by simp
#align simple_graph.walk.mem_support_nil_iff SimpleGraph.Walk.mem_support_nil_iff
@[simp]
theorem mem_tail_support_append_iff {t u v w : V} (p : G.Walk u v) (p' : G.Walk v w) :
t ∈ (p.append p').support.tail ↔ t ∈ p.support.tail ∨ t ∈ p'.support.tail := by
rw [tail_support_append, List.mem_append]
#align simple_graph.walk.mem_tail_support_append_iff SimpleGraph.Walk.mem_tail_support_append_iff
@[simp]
theorem end_mem_tail_support_of_ne {u v : V} (h : u ≠ v) (p : G.Walk u v) : v ∈ p.support.tail := by
obtain ⟨_, _, _, rfl⟩ := exists_eq_cons_of_ne h p
simp
#align simple_graph.walk.end_mem_tail_support_of_ne SimpleGraph.Walk.end_mem_tail_support_of_ne
@[simp, nolint unusedHavesSuffices]
theorem mem_support_append_iff {t u v w : V} (p : G.Walk u v) (p' : G.Walk v w) :
t ∈ (p.append p').support ↔ t ∈ p.support ∨ t ∈ p'.support := by
simp only [mem_support_iff, mem_tail_support_append_iff]
obtain rfl | h := eq_or_ne t v <;> obtain rfl | h' := eq_or_ne t u <;>
-- this `have` triggers the unusedHavesSuffices linter:
(try have := h'.symm) <;> simp [*]
#align simple_graph.walk.mem_support_append_iff SimpleGraph.Walk.mem_support_append_iff
@[simp]
theorem subset_support_append_left {V : Type u} {G : SimpleGraph V} {u v w : V}
(p : G.Walk u v) (q : G.Walk v w) : p.support ⊆ (p.append q).support := by
simp only [Walk.support_append, List.subset_append_left]
#align simple_graph.walk.subset_support_append_left SimpleGraph.Walk.subset_support_append_left
@[simp]
theorem subset_support_append_right {V : Type u} {G : SimpleGraph V} {u v w : V}
(p : G.Walk u v) (q : G.Walk v w) : q.support ⊆ (p.append q).support := by
intro h
simp (config := { contextual := true }) only [mem_support_append_iff, or_true_iff, imp_true_iff]
#align simple_graph.walk.subset_support_append_right SimpleGraph.Walk.subset_support_append_right
theorem coe_support {u v : V} (p : G.Walk u v) :
(p.support : Multiset V) = {u} + p.support.tail := by cases p <;> rfl
#align simple_graph.walk.coe_support SimpleGraph.Walk.coe_support
theorem coe_support_append {u v w : V} (p : G.Walk u v) (p' : G.Walk v w) :
((p.append p').support : Multiset V) = {u} + p.support.tail + p'.support.tail := by
rw [support_append, ← Multiset.coe_add, coe_support]
#align simple_graph.walk.coe_support_append SimpleGraph.Walk.coe_support_append
theorem coe_support_append' [DecidableEq V] {u v w : V} (p : G.Walk u v) (p' : G.Walk v w) :
((p.append p').support : Multiset V) = p.support + p'.support - {v} := by
rw [support_append, ← Multiset.coe_add]
simp only [coe_support]
rw [add_comm ({v} : Multiset V)]
simp only [← add_assoc, add_tsub_cancel_right]
#align simple_graph.walk.coe_support_append' SimpleGraph.Walk.coe_support_append'
theorem chain_adj_support {u v w : V} (h : G.Adj u v) :
∀ (p : G.Walk v w), List.Chain G.Adj u p.support
| nil => List.Chain.cons h List.Chain.nil
| cons h' p => List.Chain.cons h (chain_adj_support h' p)
#align simple_graph.walk.chain_adj_support SimpleGraph.Walk.chain_adj_support
theorem chain'_adj_support {u v : V} : ∀ (p : G.Walk u v), List.Chain' G.Adj p.support
| nil => List.Chain.nil
| cons h p => chain_adj_support h p
#align simple_graph.walk.chain'_adj_support SimpleGraph.Walk.chain'_adj_support
theorem chain_dartAdj_darts {d : G.Dart} {v w : V} (h : d.snd = v) (p : G.Walk v w) :
List.Chain G.DartAdj d p.darts := by
induction p generalizing d with
| nil => exact List.Chain.nil
-- Porting note: needed to defer `h` and `rfl` to help elaboration
| cons h' p ih => exact List.Chain.cons (by exact h) (ih (by rfl))
#align simple_graph.walk.chain_dart_adj_darts SimpleGraph.Walk.chain_dartAdj_darts
theorem chain'_dartAdj_darts {u v : V} : ∀ (p : G.Walk u v), List.Chain' G.DartAdj p.darts
| nil => trivial
-- Porting note: needed to defer `rfl` to help elaboration
| cons h p => chain_dartAdj_darts (by rfl) p
#align simple_graph.walk.chain'_dart_adj_darts SimpleGraph.Walk.chain'_dartAdj_darts
theorem edges_subset_edgeSet {u v : V} :
∀ (p : G.Walk u v) ⦃e : Sym2 V⦄, e ∈ p.edges → e ∈ G.edgeSet
| cons h' p', e, h => by
cases h
· exact h'
next h' => exact edges_subset_edgeSet p' h'
#align simple_graph.walk.edges_subset_edge_set SimpleGraph.Walk.edges_subset_edgeSet
theorem adj_of_mem_edges {u v x y : V} (p : G.Walk u v) (h : s(x, y) ∈ p.edges) : G.Adj x y :=
edges_subset_edgeSet p h
#align simple_graph.walk.adj_of_mem_edges SimpleGraph.Walk.adj_of_mem_edges
@[simp]
theorem darts_nil {u : V} : (nil : G.Walk u u).darts = [] := rfl
#align simple_graph.walk.darts_nil SimpleGraph.Walk.darts_nil
@[simp]
theorem darts_cons {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h p).darts = ⟨(u, v), h⟩ :: p.darts := rfl
#align simple_graph.walk.darts_cons SimpleGraph.Walk.darts_cons
@[simp]
theorem darts_concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
(p.concat h).darts = p.darts.concat ⟨(v, w), h⟩ := by
induction p <;> simp [*, concat_nil]
#align simple_graph.walk.darts_concat SimpleGraph.Walk.darts_concat
@[simp]
theorem darts_copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') :
(p.copy hu hv).darts = p.darts := by
subst_vars
rfl
#align simple_graph.walk.darts_copy SimpleGraph.Walk.darts_copy
@[simp]
theorem darts_append {u v w : V} (p : G.Walk u v) (p' : G.Walk v w) :
(p.append p').darts = p.darts ++ p'.darts := by
induction p <;> simp [*]
#align simple_graph.walk.darts_append SimpleGraph.Walk.darts_append
@[simp]
theorem darts_reverse {u v : V} (p : G.Walk u v) :
p.reverse.darts = (p.darts.map Dart.symm).reverse := by
induction p <;> simp [*, Sym2.eq_swap]
#align simple_graph.walk.darts_reverse SimpleGraph.Walk.darts_reverse
theorem mem_darts_reverse {u v : V} {d : G.Dart} {p : G.Walk u v} :
d ∈ p.reverse.darts ↔ d.symm ∈ p.darts := by simp
#align simple_graph.walk.mem_darts_reverse SimpleGraph.Walk.mem_darts_reverse
theorem cons_map_snd_darts {u v : V} (p : G.Walk u v) : (u :: p.darts.map (·.snd)) = p.support := by
induction p <;> simp! [*]
#align simple_graph.walk.cons_map_snd_darts SimpleGraph.Walk.cons_map_snd_darts
theorem map_snd_darts {u v : V} (p : G.Walk u v) : p.darts.map (·.snd) = p.support.tail := by
simpa using congr_arg List.tail (cons_map_snd_darts p)
#align simple_graph.walk.map_snd_darts SimpleGraph.Walk.map_snd_darts
theorem map_fst_darts_append {u v : V} (p : G.Walk u v) :
p.darts.map (·.fst) ++ [v] = p.support := by
induction p <;> simp! [*]
#align simple_graph.walk.map_fst_darts_append SimpleGraph.Walk.map_fst_darts_append
theorem map_fst_darts {u v : V} (p : G.Walk u v) : p.darts.map (·.fst) = p.support.dropLast := by
simpa! using congr_arg List.dropLast (map_fst_darts_append p)
#align simple_graph.walk.map_fst_darts SimpleGraph.Walk.map_fst_darts
@[simp]
theorem edges_nil {u : V} : (nil : G.Walk u u).edges = [] := rfl
#align simple_graph.walk.edges_nil SimpleGraph.Walk.edges_nil
@[simp]
theorem edges_cons {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h p).edges = s(u, v) :: p.edges := rfl
#align simple_graph.walk.edges_cons SimpleGraph.Walk.edges_cons
@[simp]
theorem edges_concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
(p.concat h).edges = p.edges.concat s(v, w) := by simp [edges]
#align simple_graph.walk.edges_concat SimpleGraph.Walk.edges_concat
@[simp]
theorem edges_copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') :
(p.copy hu hv).edges = p.edges := by
subst_vars
rfl
#align simple_graph.walk.edges_copy SimpleGraph.Walk.edges_copy
@[simp]
theorem edges_append {u v w : V} (p : G.Walk u v) (p' : G.Walk v w) :
(p.append p').edges = p.edges ++ p'.edges := by simp [edges]
#align simple_graph.walk.edges_append SimpleGraph.Walk.edges_append
@[simp]
theorem edges_reverse {u v : V} (p : G.Walk u v) : p.reverse.edges = p.edges.reverse := by
simp [edges, List.map_reverse]
#align simple_graph.walk.edges_reverse SimpleGraph.Walk.edges_reverse
@[simp]
theorem length_support {u v : V} (p : G.Walk u v) : p.support.length = p.length + 1 := by
induction p <;> simp [*]
#align simple_graph.walk.length_support SimpleGraph.Walk.length_support
@[simp]
theorem length_darts {u v : V} (p : G.Walk u v) : p.darts.length = p.length := by
induction p <;> simp [*]
#align simple_graph.walk.length_darts SimpleGraph.Walk.length_darts
@[simp]
theorem length_edges {u v : V} (p : G.Walk u v) : p.edges.length = p.length := by simp [edges]
#align simple_graph.walk.length_edges SimpleGraph.Walk.length_edges
theorem dart_fst_mem_support_of_mem_darts {u v : V} :
∀ (p : G.Walk u v) {d : G.Dart}, d ∈ p.darts → d.fst ∈ p.support
| cons h p', d, hd => by
simp only [support_cons, darts_cons, List.mem_cons] at hd ⊢
rcases hd with (rfl | hd)
· exact Or.inl rfl
· exact Or.inr (dart_fst_mem_support_of_mem_darts _ hd)
#align simple_graph.walk.dart_fst_mem_support_of_mem_darts SimpleGraph.Walk.dart_fst_mem_support_of_mem_darts
theorem dart_snd_mem_support_of_mem_darts {u v : V} (p : G.Walk u v) {d : G.Dart}
(h : d ∈ p.darts) : d.snd ∈ p.support := by
simpa using p.reverse.dart_fst_mem_support_of_mem_darts (by simp [h] : d.symm ∈ p.reverse.darts)
#align simple_graph.walk.dart_snd_mem_support_of_mem_darts SimpleGraph.Walk.dart_snd_mem_support_of_mem_darts
theorem fst_mem_support_of_mem_edges {t u v w : V} (p : G.Walk v w) (he : s(t, u) ∈ p.edges) :
t ∈ p.support := by
obtain ⟨d, hd, he⟩ := List.mem_map.mp he
rw [dart_edge_eq_mk'_iff'] at he
rcases he with (⟨rfl, rfl⟩ | ⟨rfl, rfl⟩)
· exact dart_fst_mem_support_of_mem_darts _ hd
· exact dart_snd_mem_support_of_mem_darts _ hd
#align simple_graph.walk.fst_mem_support_of_mem_edges SimpleGraph.Walk.fst_mem_support_of_mem_edges
theorem snd_mem_support_of_mem_edges {t u v w : V} (p : G.Walk v w) (he : s(t, u) ∈ p.edges) :
u ∈ p.support := by
rw [Sym2.eq_swap] at he
exact p.fst_mem_support_of_mem_edges he
#align simple_graph.walk.snd_mem_support_of_mem_edges SimpleGraph.Walk.snd_mem_support_of_mem_edges
theorem darts_nodup_of_support_nodup {u v : V} {p : G.Walk u v} (h : p.support.Nodup) :
p.darts.Nodup := by
induction p with
| nil => simp
| cons _ p' ih =>
simp only [darts_cons, support_cons, List.nodup_cons] at h ⊢
exact ⟨fun h' => h.1 (dart_fst_mem_support_of_mem_darts p' h'), ih h.2⟩
#align simple_graph.walk.darts_nodup_of_support_nodup SimpleGraph.Walk.darts_nodup_of_support_nodup
theorem edges_nodup_of_support_nodup {u v : V} {p : G.Walk u v} (h : p.support.Nodup) :
p.edges.Nodup := by
induction p with
| nil => simp
| cons _ p' ih =>
simp only [edges_cons, support_cons, List.nodup_cons] at h ⊢
exact ⟨fun h' => h.1 (fst_mem_support_of_mem_edges p' h'), ih h.2⟩
#align simple_graph.walk.edges_nodup_of_support_nodup SimpleGraph.Walk.edges_nodup_of_support_nodup
inductive Nil : {v w : V} → G.Walk v w → Prop
| nil {u : V} : Nil (nil : G.Walk u u)
variable {u v w : V}
@[simp] lemma nil_nil : (nil : G.Walk u u).Nil := Nil.nil
@[simp] lemma not_nil_cons {h : G.Adj u v} {p : G.Walk v w} : ¬ (cons h p).Nil := nofun
instance (p : G.Walk v w) : Decidable p.Nil :=
match p with
| nil => isTrue .nil
| cons _ _ => isFalse nofun
protected lemma Nil.eq {p : G.Walk v w} : p.Nil → v = w | .nil => rfl
lemma not_nil_of_ne {p : G.Walk v w} : v ≠ w → ¬ p.Nil := mt Nil.eq
lemma nil_iff_support_eq {p : G.Walk v w} : p.Nil ↔ p.support = [v] := by
cases p <;> simp
lemma nil_iff_length_eq {p : G.Walk v w} : p.Nil ↔ p.length = 0 := by
cases p <;> simp
lemma not_nil_iff {p : G.Walk v w} :
¬ p.Nil ↔ ∃ (u : V) (h : G.Adj v u) (q : G.Walk u w), p = cons h q := by
cases p <;> simp [*]
lemma nil_iff_eq_nil : ∀ {p : G.Walk v v}, p.Nil ↔ p = nil
| .nil | .cons _ _ => by simp
alias ⟨Nil.eq_nil, _⟩ := nil_iff_eq_nil
@[elab_as_elim]
def notNilRec {motive : {u w : V} → (p : G.Walk u w) → (h : ¬ p.Nil) → Sort*}
(cons : {u v w : V} → (h : G.Adj u v) → (q : G.Walk v w) → motive (cons h q) not_nil_cons)
(p : G.Walk u w) : (hp : ¬ p.Nil) → motive p hp :=
match p with
| nil => fun hp => absurd .nil hp
| .cons h q => fun _ => cons h q
def sndOfNotNil (p : G.Walk v w) (hp : ¬ p.Nil) : V :=
p.notNilRec (@fun _ u _ _ _ => u) hp
@[simp] lemma adj_sndOfNotNil {p : G.Walk v w} (hp : ¬ p.Nil) :
G.Adj v (p.sndOfNotNil hp) :=
p.notNilRec (fun h _ => h) hp
def tail (p : G.Walk u v) (hp : ¬ p.Nil) : G.Walk (p.sndOfNotNil hp) v :=
p.notNilRec (fun _ q => q) hp
@[simps]
def firstDart (p : G.Walk v w) (hp : ¬ p.Nil) : G.Dart where
fst := v
snd := p.sndOfNotNil hp
adj := p.adj_sndOfNotNil hp
lemma edge_firstDart (p : G.Walk v w) (hp : ¬ p.Nil) :
(p.firstDart hp).edge = s(v, p.sndOfNotNil hp) := rfl
variable {x y : V} -- TODO: rename to u, v, w instead?
@[simp] lemma cons_tail_eq (p : G.Walk x y) (hp : ¬ p.Nil) :
cons (p.adj_sndOfNotNil hp) (p.tail hp) = p :=
p.notNilRec (fun _ _ => rfl) hp
@[simp] lemma cons_support_tail (p : G.Walk x y) (hp : ¬p.Nil) :
x :: (p.tail hp).support = p.support := by
rw [← support_cons, cons_tail_eq]
@[simp] lemma length_tail_add_one {p : G.Walk x y} (hp : ¬ p.Nil) :
(p.tail hp).length + 1 = p.length := by
rw [← length_cons, cons_tail_eq]
@[simp] lemma nil_copy {x' y' : V} {p : G.Walk x y} (hx : x = x') (hy : y = y') :
(p.copy hx hy).Nil = p.Nil := by
subst_vars; rfl
@[simp] lemma support_tail (p : G.Walk v v) (hp) :
(p.tail hp).support = p.support.tail := by
rw [← cons_support_tail p hp, List.tail_cons]
@[mk_iff isTrail_def]
structure IsTrail {u v : V} (p : G.Walk u v) : Prop where
edges_nodup : p.edges.Nodup
#align simple_graph.walk.is_trail SimpleGraph.Walk.IsTrail
#align simple_graph.walk.is_trail_def SimpleGraph.Walk.isTrail_def
structure IsPath {u v : V} (p : G.Walk u v) extends IsTrail p : Prop where
support_nodup : p.support.Nodup
#align simple_graph.walk.is_path SimpleGraph.Walk.IsPath
-- Porting note: used to use `extends to_trail : is_trail p` in structure
protected lemma IsPath.isTrail {p : Walk G u v}(h : IsPath p) : IsTrail p := h.toIsTrail
#align simple_graph.walk.is_path.to_trail SimpleGraph.Walk.IsPath.isTrail
@[mk_iff isCircuit_def]
structure IsCircuit {u : V} (p : G.Walk u u) extends IsTrail p : Prop where
ne_nil : p ≠ nil
#align simple_graph.walk.is_circuit SimpleGraph.Walk.IsCircuit
#align simple_graph.walk.is_circuit_def SimpleGraph.Walk.isCircuit_def
-- Porting note: used to use `extends to_trail : is_trail p` in structure
protected lemma IsCircuit.isTrail {p : Walk G u u} (h : IsCircuit p) : IsTrail p := h.toIsTrail
#align simple_graph.walk.is_circuit.to_trail SimpleGraph.Walk.IsCircuit.isTrail
structure IsCycle {u : V} (p : G.Walk u u) extends IsCircuit p : Prop where
support_nodup : p.support.tail.Nodup
#align simple_graph.walk.is_cycle SimpleGraph.Walk.IsCycle
-- Porting note: used to use `extends to_circuit : is_circuit p` in structure
protected lemma IsCycle.isCircuit {p : Walk G u u} (h : IsCycle p) : IsCircuit p := h.toIsCircuit
#align simple_graph.walk.is_cycle.to_circuit SimpleGraph.Walk.IsCycle.isCircuit
@[simp]
theorem isTrail_copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') :
(p.copy hu hv).IsTrail ↔ p.IsTrail := by
subst_vars
rfl
#align simple_graph.walk.is_trail_copy SimpleGraph.Walk.isTrail_copy
theorem IsPath.mk' {u v : V} {p : G.Walk u v} (h : p.support.Nodup) : p.IsPath :=
⟨⟨edges_nodup_of_support_nodup h⟩, h⟩
#align simple_graph.walk.is_path.mk' SimpleGraph.Walk.IsPath.mk'
theorem isPath_def {u v : V} (p : G.Walk u v) : p.IsPath ↔ p.support.Nodup :=
⟨IsPath.support_nodup, IsPath.mk'⟩
#align simple_graph.walk.is_path_def SimpleGraph.Walk.isPath_def
@[simp]
theorem isPath_copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') :
(p.copy hu hv).IsPath ↔ p.IsPath := by
subst_vars
rfl
#align simple_graph.walk.is_path_copy SimpleGraph.Walk.isPath_copy
@[simp]
theorem isCircuit_copy {u u'} (p : G.Walk u u) (hu : u = u') :
(p.copy hu hu).IsCircuit ↔ p.IsCircuit := by
subst_vars
rfl
#align simple_graph.walk.is_circuit_copy SimpleGraph.Walk.isCircuit_copy
lemma IsCircuit.not_nil {p : G.Walk v v} (hp : IsCircuit p) : ¬ p.Nil := (hp.ne_nil ·.eq_nil)
theorem isCycle_def {u : V} (p : G.Walk u u) :
p.IsCycle ↔ p.IsTrail ∧ p ≠ nil ∧ p.support.tail.Nodup :=
Iff.intro (fun h => ⟨h.1.1, h.1.2, h.2⟩) fun h => ⟨⟨h.1, h.2.1⟩, h.2.2⟩
#align simple_graph.walk.is_cycle_def SimpleGraph.Walk.isCycle_def
@[simp]
theorem isCycle_copy {u u'} (p : G.Walk u u) (hu : u = u') :
(p.copy hu hu).IsCycle ↔ p.IsCycle := by
subst_vars
rfl
#align simple_graph.walk.is_cycle_copy SimpleGraph.Walk.isCycle_copy
lemma IsCycle.not_nil {p : G.Walk v v} (hp : IsCycle p) : ¬ p.Nil := (hp.ne_nil ·.eq_nil)
@[simp]
theorem IsTrail.nil {u : V} : (nil : G.Walk u u).IsTrail :=
⟨by simp [edges]⟩
#align simple_graph.walk.is_trail.nil SimpleGraph.Walk.IsTrail.nil
theorem IsTrail.of_cons {u v w : V} {h : G.Adj u v} {p : G.Walk v w} :
(cons h p).IsTrail → p.IsTrail := by simp [isTrail_def]
#align simple_graph.walk.is_trail.of_cons SimpleGraph.Walk.IsTrail.of_cons
@[simp]
theorem cons_isTrail_iff {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h p).IsTrail ↔ p.IsTrail ∧ s(u, v) ∉ p.edges := by simp [isTrail_def, and_comm]
#align simple_graph.walk.cons_is_trail_iff SimpleGraph.Walk.cons_isTrail_iff
theorem IsTrail.reverse {u v : V} (p : G.Walk u v) (h : p.IsTrail) : p.reverse.IsTrail := by
simpa [isTrail_def] using h
#align simple_graph.walk.is_trail.reverse SimpleGraph.Walk.IsTrail.reverse
@[simp]
theorem reverse_isTrail_iff {u v : V} (p : G.Walk u v) : p.reverse.IsTrail ↔ p.IsTrail := by
constructor <;>
· intro h
convert h.reverse _
try rw [reverse_reverse]
#align simple_graph.walk.reverse_is_trail_iff SimpleGraph.Walk.reverse_isTrail_iff
| Mathlib/Combinatorics/SimpleGraph/Connectivity.lean | 1,049 | 1,052 | theorem IsTrail.of_append_left {u v w : V} {p : G.Walk u v} {q : G.Walk v w}
(h : (p.append q).IsTrail) : p.IsTrail := by |
rw [isTrail_def, edges_append, List.nodup_append] at h
exact ⟨h.1⟩
|
import Mathlib.Algebra.BigOperators.Ring
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Fintype.Fin
import Mathlib.GroupTheory.GroupAction.Pi
import Mathlib.Logic.Equiv.Fin
#align_import algebra.big_operators.fin from "leanprover-community/mathlib"@"cc5dd6244981976cc9da7afc4eee5682b037a013"
open Finset
variable {α : Type*} {β : Type*}
namespace Fin
@[to_additive]
theorem prod_ofFn [CommMonoid β] {n : ℕ} (f : Fin n → β) : (List.ofFn f).prod = ∏ i, f i := by
simp [prod_eq_multiset_prod]
#align fin.prod_of_fn Fin.prod_ofFn
#align fin.sum_of_fn Fin.sum_ofFn
@[to_additive]
theorem prod_univ_def [CommMonoid β] {n : ℕ} (f : Fin n → β) :
∏ i, f i = ((List.finRange n).map f).prod := by
rw [← List.ofFn_eq_map, prod_ofFn]
#align fin.prod_univ_def Fin.prod_univ_def
#align fin.sum_univ_def Fin.sum_univ_def
@[to_additive "A sum of a function `f : Fin 0 → β` is `0` because `Fin 0` is empty"]
theorem prod_univ_zero [CommMonoid β] (f : Fin 0 → β) : ∏ i, f i = 1 :=
rfl
#align fin.prod_univ_zero Fin.prod_univ_zero
#align fin.sum_univ_zero Fin.sum_univ_zero
@[to_additive "A sum of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)` is the sum of
`f x`, for some `x : Fin (n + 1)` plus the remaining product"]
theorem prod_univ_succAbove [CommMonoid β] {n : ℕ} (f : Fin (n + 1) → β) (x : Fin (n + 1)) :
∏ i, f i = f x * ∏ i : Fin n, f (x.succAbove i) := by
rw [univ_succAbove, prod_cons, Finset.prod_map _ x.succAboveEmb]
rfl
#align fin.prod_univ_succ_above Fin.prod_univ_succAbove
#align fin.sum_univ_succ_above Fin.sum_univ_succAbove
@[to_additive "A sum of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)` is the sum of
`f 0` plus the remaining product"]
theorem prod_univ_succ [CommMonoid β] {n : ℕ} (f : Fin (n + 1) → β) :
∏ i, f i = f 0 * ∏ i : Fin n, f i.succ :=
prod_univ_succAbove f 0
#align fin.prod_univ_succ Fin.prod_univ_succ
#align fin.sum_univ_succ Fin.sum_univ_succ
@[to_additive "A sum of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)` is the sum of
`f (Fin.last n)` plus the remaining sum"]
theorem prod_univ_castSucc [CommMonoid β] {n : ℕ} (f : Fin (n + 1) → β) :
∏ i, f i = (∏ i : Fin n, f (Fin.castSucc i)) * f (last n) := by
simpa [mul_comm] using prod_univ_succAbove f (last n)
#align fin.prod_univ_cast_succ Fin.prod_univ_castSucc
#align fin.sum_univ_cast_succ Fin.sum_univ_castSucc
@[to_additive (attr := simp)]
theorem prod_univ_get [CommMonoid α] (l : List α) : ∏ i, l.get i = l.prod := by
simp [Finset.prod_eq_multiset_prod]
@[to_additive (attr := simp)]
theorem prod_univ_get' [CommMonoid β] (l : List α) (f : α → β) :
∏ i, f (l.get i) = (l.map f).prod := by
simp [Finset.prod_eq_multiset_prod]
@[to_additive]
theorem prod_cons [CommMonoid β] {n : ℕ} (x : β) (f : Fin n → β) :
(∏ i : Fin n.succ, (cons x f : Fin n.succ → β) i) = x * ∏ i : Fin n, f i := by
simp_rw [prod_univ_succ, cons_zero, cons_succ]
#align fin.prod_cons Fin.prod_cons
#align fin.sum_cons Fin.sum_cons
@[to_additive sum_univ_one]
theorem prod_univ_one [CommMonoid β] (f : Fin 1 → β) : ∏ i, f i = f 0 := by simp
#align fin.prod_univ_one Fin.prod_univ_one
#align fin.sum_univ_one Fin.sum_univ_one
@[to_additive (attr := simp)]
theorem prod_univ_two [CommMonoid β] (f : Fin 2 → β) : ∏ i, f i = f 0 * f 1 := by
simp [prod_univ_succ]
#align fin.prod_univ_two Fin.prod_univ_two
#align fin.sum_univ_two Fin.sum_univ_two
@[to_additive]
theorem prod_univ_two' [CommMonoid β] (f : α → β) (a b : α) :
∏ i, f (![a, b] i) = f a * f b :=
prod_univ_two _
@[to_additive]
theorem prod_univ_three [CommMonoid β] (f : Fin 3 → β) : ∏ i, f i = f 0 * f 1 * f 2 := by
rw [prod_univ_castSucc, prod_univ_two]
rfl
#align fin.prod_univ_three Fin.prod_univ_three
#align fin.sum_univ_three Fin.sum_univ_three
@[to_additive]
theorem prod_univ_four [CommMonoid β] (f : Fin 4 → β) : ∏ i, f i = f 0 * f 1 * f 2 * f 3 := by
rw [prod_univ_castSucc, prod_univ_three]
rfl
#align fin.prod_univ_four Fin.prod_univ_four
#align fin.sum_univ_four Fin.sum_univ_four
@[to_additive]
theorem prod_univ_five [CommMonoid β] (f : Fin 5 → β) :
∏ i, f i = f 0 * f 1 * f 2 * f 3 * f 4 := by
rw [prod_univ_castSucc, prod_univ_four]
rfl
#align fin.prod_univ_five Fin.prod_univ_five
#align fin.sum_univ_five Fin.sum_univ_five
@[to_additive]
theorem prod_univ_six [CommMonoid β] (f : Fin 6 → β) :
∏ i, f i = f 0 * f 1 * f 2 * f 3 * f 4 * f 5 := by
rw [prod_univ_castSucc, prod_univ_five]
rfl
#align fin.prod_univ_six Fin.prod_univ_six
#align fin.sum_univ_six Fin.sum_univ_six
@[to_additive]
| Mathlib/Algebra/BigOperators/Fin.lean | 159 | 162 | theorem prod_univ_seven [CommMonoid β] (f : Fin 7 → β) :
∏ i, f i = f 0 * f 1 * f 2 * f 3 * f 4 * f 5 * f 6 := by |
rw [prod_univ_castSucc, prod_univ_six]
rfl
|
import Mathlib.Data.Int.ModEq
import Mathlib.GroupTheory.QuotientGroup
#align_import algebra.modeq from "leanprover-community/mathlib"@"a07d750983b94c530ab69a726862c2ab6802b38c"
namespace AddCommGroup
variable {α : Type*}
section AddCommGroup
variable [AddCommGroup α] {p a a₁ a₂ b b₁ b₂ c : α} {n : ℕ} {z : ℤ}
def ModEq (p a b : α) : Prop :=
∃ z : ℤ, b - a = z • p
#align add_comm_group.modeq AddCommGroup.ModEq
@[inherit_doc]
notation:50 a " ≡ " b " [PMOD " p "]" => ModEq p a b
@[refl, simp]
theorem modEq_refl (a : α) : a ≡ a [PMOD p] :=
⟨0, by simp⟩
#align add_comm_group.modeq_refl AddCommGroup.modEq_refl
theorem modEq_rfl : a ≡ a [PMOD p] :=
modEq_refl _
#align add_comm_group.modeq_rfl AddCommGroup.modEq_rfl
theorem modEq_comm : a ≡ b [PMOD p] ↔ b ≡ a [PMOD p] :=
(Equiv.neg _).exists_congr_left.trans <| by simp [ModEq, ← neg_eq_iff_eq_neg]
#align add_comm_group.modeq_comm AddCommGroup.modEq_comm
alias ⟨ModEq.symm, _⟩ := modEq_comm
#align add_comm_group.modeq.symm AddCommGroup.ModEq.symm
attribute [symm] ModEq.symm
@[trans]
theorem ModEq.trans : a ≡ b [PMOD p] → b ≡ c [PMOD p] → a ≡ c [PMOD p] := fun ⟨m, hm⟩ ⟨n, hn⟩ =>
⟨m + n, by simp [add_smul, ← hm, ← hn]⟩
#align add_comm_group.modeq.trans AddCommGroup.ModEq.trans
instance : IsRefl _ (ModEq p) :=
⟨modEq_refl⟩
@[simp]
theorem neg_modEq_neg : -a ≡ -b [PMOD p] ↔ a ≡ b [PMOD p] :=
modEq_comm.trans <| by simp [ModEq, neg_add_eq_sub]
#align add_comm_group.neg_modeq_neg AddCommGroup.neg_modEq_neg
alias ⟨ModEq.of_neg, ModEq.neg⟩ := neg_modEq_neg
#align add_comm_group.modeq.of_neg AddCommGroup.ModEq.of_neg
#align add_comm_group.modeq.neg AddCommGroup.ModEq.neg
@[simp]
theorem modEq_neg : a ≡ b [PMOD -p] ↔ a ≡ b [PMOD p] :=
modEq_comm.trans <| by simp [ModEq, ← neg_eq_iff_eq_neg]
#align add_comm_group.modeq_neg AddCommGroup.modEq_neg
alias ⟨ModEq.of_neg', ModEq.neg'⟩ := modEq_neg
#align add_comm_group.modeq.of_neg' AddCommGroup.ModEq.of_neg'
#align add_comm_group.modeq.neg' AddCommGroup.ModEq.neg'
theorem modEq_sub (a b : α) : a ≡ b [PMOD b - a] :=
⟨1, (one_smul _ _).symm⟩
#align add_comm_group.modeq_sub AddCommGroup.modEq_sub
@[simp]
theorem modEq_zero : a ≡ b [PMOD 0] ↔ a = b := by simp [ModEq, sub_eq_zero, eq_comm]
#align add_comm_group.modeq_zero AddCommGroup.modEq_zero
@[simp]
theorem self_modEq_zero : p ≡ 0 [PMOD p] :=
⟨-1, by simp⟩
#align add_comm_group.self_modeq_zero AddCommGroup.self_modEq_zero
@[simp]
theorem zsmul_modEq_zero (z : ℤ) : z • p ≡ 0 [PMOD p] :=
⟨-z, by simp⟩
#align add_comm_group.zsmul_modeq_zero AddCommGroup.zsmul_modEq_zero
theorem add_zsmul_modEq (z : ℤ) : a + z • p ≡ a [PMOD p] :=
⟨-z, by simp⟩
#align add_comm_group.add_zsmul_modeq AddCommGroup.add_zsmul_modEq
theorem zsmul_add_modEq (z : ℤ) : z • p + a ≡ a [PMOD p] :=
⟨-z, by simp [← sub_sub]⟩
#align add_comm_group.zsmul_add_modeq AddCommGroup.zsmul_add_modEq
theorem add_nsmul_modEq (n : ℕ) : a + n • p ≡ a [PMOD p] :=
⟨-n, by simp⟩
#align add_comm_group.add_nsmul_modeq AddCommGroup.add_nsmul_modEq
theorem nsmul_add_modEq (n : ℕ) : n • p + a ≡ a [PMOD p] :=
⟨-n, by simp [← sub_sub]⟩
#align add_comm_group.nsmul_add_modeq AddCommGroup.nsmul_add_modEq
theorem modEq_sub_iff_add_modEq' : a ≡ b - c [PMOD p] ↔ c + a ≡ b [PMOD p] := by
simp [ModEq, sub_sub]
#align add_comm_group.modeq_sub_iff_add_modeq' AddCommGroup.modEq_sub_iff_add_modEq'
theorem modEq_sub_iff_add_modEq : a ≡ b - c [PMOD p] ↔ a + c ≡ b [PMOD p] :=
modEq_sub_iff_add_modEq'.trans <| by rw [add_comm]
#align add_comm_group.modeq_sub_iff_add_modeq AddCommGroup.modEq_sub_iff_add_modEq
theorem sub_modEq_iff_modEq_add' : a - b ≡ c [PMOD p] ↔ a ≡ b + c [PMOD p] :=
modEq_comm.trans <| modEq_sub_iff_add_modEq'.trans modEq_comm
#align add_comm_group.sub_modeq_iff_modeq_add' AddCommGroup.sub_modEq_iff_modEq_add'
theorem sub_modEq_iff_modEq_add : a - b ≡ c [PMOD p] ↔ a ≡ c + b [PMOD p] :=
modEq_comm.trans <| modEq_sub_iff_add_modEq.trans modEq_comm
#align add_comm_group.sub_modeq_iff_modeq_add AddCommGroup.sub_modEq_iff_modEq_add
@[simp]
theorem sub_modEq_zero : a - b ≡ 0 [PMOD p] ↔ a ≡ b [PMOD p] := by simp [sub_modEq_iff_modEq_add]
#align add_comm_group.sub_modeq_zero AddCommGroup.sub_modEq_zero
@[simp]
theorem add_modEq_left : a + b ≡ a [PMOD p] ↔ b ≡ 0 [PMOD p] := by simp [← modEq_sub_iff_add_modEq']
#align add_comm_group.add_modeq_left AddCommGroup.add_modEq_left
@[simp]
theorem add_modEq_right : a + b ≡ b [PMOD p] ↔ a ≡ 0 [PMOD p] := by simp [← modEq_sub_iff_add_modEq]
#align add_comm_group.add_modeq_right AddCommGroup.add_modEq_right
theorem modEq_iff_eq_add_zsmul : a ≡ b [PMOD p] ↔ ∃ z : ℤ, b = a + z • p := by
simp_rw [ModEq, sub_eq_iff_eq_add']
#align add_comm_group.modeq_iff_eq_add_zsmul AddCommGroup.modEq_iff_eq_add_zsmul
theorem not_modEq_iff_ne_add_zsmul : ¬a ≡ b [PMOD p] ↔ ∀ z : ℤ, b ≠ a + z • p := by
rw [modEq_iff_eq_add_zsmul, not_exists]
#align add_comm_group.not_modeq_iff_ne_add_zsmul AddCommGroup.not_modEq_iff_ne_add_zsmul
| Mathlib/Algebra/ModEq.lean | 298 | 300 | theorem modEq_iff_eq_mod_zmultiples : a ≡ b [PMOD p] ↔ (b : α ⧸ AddSubgroup.zmultiples p) = a := by |
simp_rw [modEq_iff_eq_add_zsmul, QuotientAddGroup.eq_iff_sub_mem, AddSubgroup.mem_zmultiples_iff,
eq_sub_iff_add_eq', eq_comm]
|
import Mathlib.Logic.Pairwise
import Mathlib.Order.CompleteBooleanAlgebra
import Mathlib.Order.Directed
import Mathlib.Order.GaloisConnection
#align_import data.set.lattice from "leanprover-community/mathlib"@"b86832321b586c6ac23ef8cdef6a7a27e42b13bd"
open Function Set
universe u
variable {α β γ : Type*} {ι ι' ι₂ : Sort*} {κ κ₁ κ₂ : ι → Sort*} {κ' : ι' → Sort*}
namespace Set
theorem mem_iUnion₂ {x : γ} {s : ∀ i, κ i → Set γ} : (x ∈ ⋃ (i) (j), s i j) ↔ ∃ i j, x ∈ s i j := by
simp_rw [mem_iUnion]
#align set.mem_Union₂ Set.mem_iUnion₂
theorem mem_iInter₂ {x : γ} {s : ∀ i, κ i → Set γ} : (x ∈ ⋂ (i) (j), s i j) ↔ ∀ i j, x ∈ s i j := by
simp_rw [mem_iInter]
#align set.mem_Inter₂ Set.mem_iInter₂
theorem mem_iUnion_of_mem {s : ι → Set α} {a : α} (i : ι) (ha : a ∈ s i) : a ∈ ⋃ i, s i :=
mem_iUnion.2 ⟨i, ha⟩
#align set.mem_Union_of_mem Set.mem_iUnion_of_mem
theorem mem_iUnion₂_of_mem {s : ∀ i, κ i → Set α} {a : α} {i : ι} (j : κ i) (ha : a ∈ s i j) :
a ∈ ⋃ (i) (j), s i j :=
mem_iUnion₂.2 ⟨i, j, ha⟩
#align set.mem_Union₂_of_mem Set.mem_iUnion₂_of_mem
theorem mem_iInter_of_mem {s : ι → Set α} {a : α} (h : ∀ i, a ∈ s i) : a ∈ ⋂ i, s i :=
mem_iInter.2 h
#align set.mem_Inter_of_mem Set.mem_iInter_of_mem
theorem mem_iInter₂_of_mem {s : ∀ i, κ i → Set α} {a : α} (h : ∀ i j, a ∈ s i j) :
a ∈ ⋂ (i) (j), s i j :=
mem_iInter₂.2 h
#align set.mem_Inter₂_of_mem Set.mem_iInter₂_of_mem
instance completeAtomicBooleanAlgebra : CompleteAtomicBooleanAlgebra (Set α) :=
{ instBooleanAlgebraSet with
le_sSup := fun s t t_in a a_in => ⟨t, t_in, a_in⟩
sSup_le := fun s t h a ⟨t', ⟨t'_in, a_in⟩⟩ => h t' t'_in a_in
le_sInf := fun s t h a a_in t' t'_in => h t' t'_in a_in
sInf_le := fun s t t_in a h => h _ t_in
iInf_iSup_eq := by intros; ext; simp [Classical.skolem] }
instance : OrderTop (Set α) where
top := univ
le_top := by simp
@[congr]
theorem iUnion_congr_Prop {p q : Prop} {f₁ : p → Set α} {f₂ : q → Set α} (pq : p ↔ q)
(f : ∀ x, f₁ (pq.mpr x) = f₂ x) : iUnion f₁ = iUnion f₂ :=
iSup_congr_Prop pq f
#align set.Union_congr_Prop Set.iUnion_congr_Prop
@[congr]
theorem iInter_congr_Prop {p q : Prop} {f₁ : p → Set α} {f₂ : q → Set α} (pq : p ↔ q)
(f : ∀ x, f₁ (pq.mpr x) = f₂ x) : iInter f₁ = iInter f₂ :=
iInf_congr_Prop pq f
#align set.Inter_congr_Prop Set.iInter_congr_Prop
theorem iUnion_plift_up (f : PLift ι → Set α) : ⋃ i, f (PLift.up i) = ⋃ i, f i :=
iSup_plift_up _
#align set.Union_plift_up Set.iUnion_plift_up
theorem iUnion_plift_down (f : ι → Set α) : ⋃ i, f (PLift.down i) = ⋃ i, f i :=
iSup_plift_down _
#align set.Union_plift_down Set.iUnion_plift_down
theorem iInter_plift_up (f : PLift ι → Set α) : ⋂ i, f (PLift.up i) = ⋂ i, f i :=
iInf_plift_up _
#align set.Inter_plift_up Set.iInter_plift_up
theorem iInter_plift_down (f : ι → Set α) : ⋂ i, f (PLift.down i) = ⋂ i, f i :=
iInf_plift_down _
#align set.Inter_plift_down Set.iInter_plift_down
theorem iUnion_eq_if {p : Prop} [Decidable p] (s : Set α) : ⋃ _ : p, s = if p then s else ∅ :=
iSup_eq_if _
#align set.Union_eq_if Set.iUnion_eq_if
theorem iUnion_eq_dif {p : Prop} [Decidable p] (s : p → Set α) :
⋃ h : p, s h = if h : p then s h else ∅ :=
iSup_eq_dif _
#align set.Union_eq_dif Set.iUnion_eq_dif
theorem iInter_eq_if {p : Prop} [Decidable p] (s : Set α) : ⋂ _ : p, s = if p then s else univ :=
iInf_eq_if _
#align set.Inter_eq_if Set.iInter_eq_if
theorem iInf_eq_dif {p : Prop} [Decidable p] (s : p → Set α) :
⋂ h : p, s h = if h : p then s h else univ :=
_root_.iInf_eq_dif _
#align set.Infi_eq_dif Set.iInf_eq_dif
theorem exists_set_mem_of_union_eq_top {ι : Type*} (t : Set ι) (s : ι → Set β)
(w : ⋃ i ∈ t, s i = ⊤) (x : β) : ∃ i ∈ t, x ∈ s i := by
have p : x ∈ ⊤ := Set.mem_univ x
rw [← w, Set.mem_iUnion] at p
simpa using p
#align set.exists_set_mem_of_union_eq_top Set.exists_set_mem_of_union_eq_top
theorem nonempty_of_union_eq_top_of_nonempty {ι : Type*} (t : Set ι) (s : ι → Set α)
(H : Nonempty α) (w : ⋃ i ∈ t, s i = ⊤) : t.Nonempty := by
obtain ⟨x, m, -⟩ := exists_set_mem_of_union_eq_top t s w H.some
exact ⟨x, m⟩
#align set.nonempty_of_union_eq_top_of_nonempty Set.nonempty_of_union_eq_top_of_nonempty
theorem nonempty_of_nonempty_iUnion
{s : ι → Set α} (h_Union : (⋃ i, s i).Nonempty) : Nonempty ι := by
obtain ⟨x, hx⟩ := h_Union
exact ⟨Classical.choose <| mem_iUnion.mp hx⟩
theorem nonempty_of_nonempty_iUnion_eq_univ
{s : ι → Set α} [Nonempty α] (h_Union : ⋃ i, s i = univ) : Nonempty ι :=
nonempty_of_nonempty_iUnion (s := s) (by simpa only [h_Union] using univ_nonempty)
theorem setOf_exists (p : ι → β → Prop) : { x | ∃ i, p i x } = ⋃ i, { x | p i x } :=
ext fun _ => mem_iUnion.symm
#align set.set_of_exists Set.setOf_exists
theorem setOf_forall (p : ι → β → Prop) : { x | ∀ i, p i x } = ⋂ i, { x | p i x } :=
ext fun _ => mem_iInter.symm
#align set.set_of_forall Set.setOf_forall
theorem iUnion_subset {s : ι → Set α} {t : Set α} (h : ∀ i, s i ⊆ t) : ⋃ i, s i ⊆ t :=
iSup_le h
#align set.Union_subset Set.iUnion_subset
theorem iUnion₂_subset {s : ∀ i, κ i → Set α} {t : Set α} (h : ∀ i j, s i j ⊆ t) :
⋃ (i) (j), s i j ⊆ t :=
iUnion_subset fun x => iUnion_subset (h x)
#align set.Union₂_subset Set.iUnion₂_subset
theorem subset_iInter {t : Set β} {s : ι → Set β} (h : ∀ i, t ⊆ s i) : t ⊆ ⋂ i, s i :=
le_iInf h
#align set.subset_Inter Set.subset_iInter
theorem subset_iInter₂ {s : Set α} {t : ∀ i, κ i → Set α} (h : ∀ i j, s ⊆ t i j) :
s ⊆ ⋂ (i) (j), t i j :=
subset_iInter fun x => subset_iInter <| h x
#align set.subset_Inter₂ Set.subset_iInter₂
@[simp]
theorem iUnion_subset_iff {s : ι → Set α} {t : Set α} : ⋃ i, s i ⊆ t ↔ ∀ i, s i ⊆ t :=
⟨fun h _ => Subset.trans (le_iSup s _) h, iUnion_subset⟩
#align set.Union_subset_iff Set.iUnion_subset_iff
theorem iUnion₂_subset_iff {s : ∀ i, κ i → Set α} {t : Set α} :
⋃ (i) (j), s i j ⊆ t ↔ ∀ i j, s i j ⊆ t := by simp_rw [iUnion_subset_iff]
#align set.Union₂_subset_iff Set.iUnion₂_subset_iff
@[simp]
theorem subset_iInter_iff {s : Set α} {t : ι → Set α} : (s ⊆ ⋂ i, t i) ↔ ∀ i, s ⊆ t i :=
le_iInf_iff
#align set.subset_Inter_iff Set.subset_iInter_iff
-- Porting note (#10618): removing `simp`. `simp` can prove it
theorem subset_iInter₂_iff {s : Set α} {t : ∀ i, κ i → Set α} :
(s ⊆ ⋂ (i) (j), t i j) ↔ ∀ i j, s ⊆ t i j := by simp_rw [subset_iInter_iff]
#align set.subset_Inter₂_iff Set.subset_iInter₂_iff
theorem subset_iUnion : ∀ (s : ι → Set β) (i : ι), s i ⊆ ⋃ i, s i :=
le_iSup
#align set.subset_Union Set.subset_iUnion
theorem iInter_subset : ∀ (s : ι → Set β) (i : ι), ⋂ i, s i ⊆ s i :=
iInf_le
#align set.Inter_subset Set.iInter_subset
theorem subset_iUnion₂ {s : ∀ i, κ i → Set α} (i : ι) (j : κ i) : s i j ⊆ ⋃ (i') (j'), s i' j' :=
le_iSup₂ i j
#align set.subset_Union₂ Set.subset_iUnion₂
theorem iInter₂_subset {s : ∀ i, κ i → Set α} (i : ι) (j : κ i) : ⋂ (i) (j), s i j ⊆ s i j :=
iInf₂_le i j
#align set.Inter₂_subset Set.iInter₂_subset
theorem subset_iUnion_of_subset {s : Set α} {t : ι → Set α} (i : ι) (h : s ⊆ t i) : s ⊆ ⋃ i, t i :=
le_iSup_of_le i h
#align set.subset_Union_of_subset Set.subset_iUnion_of_subset
theorem iInter_subset_of_subset {s : ι → Set α} {t : Set α} (i : ι) (h : s i ⊆ t) :
⋂ i, s i ⊆ t :=
iInf_le_of_le i h
#align set.Inter_subset_of_subset Set.iInter_subset_of_subset
theorem subset_iUnion₂_of_subset {s : Set α} {t : ∀ i, κ i → Set α} (i : ι) (j : κ i)
(h : s ⊆ t i j) : s ⊆ ⋃ (i) (j), t i j :=
le_iSup₂_of_le i j h
#align set.subset_Union₂_of_subset Set.subset_iUnion₂_of_subset
theorem iInter₂_subset_of_subset {s : ∀ i, κ i → Set α} {t : Set α} (i : ι) (j : κ i)
(h : s i j ⊆ t) : ⋂ (i) (j), s i j ⊆ t :=
iInf₂_le_of_le i j h
#align set.Inter₂_subset_of_subset Set.iInter₂_subset_of_subset
theorem iUnion_mono {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : ⋃ i, s i ⊆ ⋃ i, t i :=
iSup_mono h
#align set.Union_mono Set.iUnion_mono
@[gcongr]
theorem iUnion_mono'' {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : iUnion s ⊆ iUnion t :=
iSup_mono h
theorem iUnion₂_mono {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j ⊆ t i j) :
⋃ (i) (j), s i j ⊆ ⋃ (i) (j), t i j :=
iSup₂_mono h
#align set.Union₂_mono Set.iUnion₂_mono
theorem iInter_mono {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : ⋂ i, s i ⊆ ⋂ i, t i :=
iInf_mono h
#align set.Inter_mono Set.iInter_mono
@[gcongr]
theorem iInter_mono'' {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : iInter s ⊆ iInter t :=
iInf_mono h
theorem iInter₂_mono {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j ⊆ t i j) :
⋂ (i) (j), s i j ⊆ ⋂ (i) (j), t i j :=
iInf₂_mono h
#align set.Inter₂_mono Set.iInter₂_mono
theorem iUnion_mono' {s : ι → Set α} {t : ι₂ → Set α} (h : ∀ i, ∃ j, s i ⊆ t j) :
⋃ i, s i ⊆ ⋃ i, t i :=
iSup_mono' h
#align set.Union_mono' Set.iUnion_mono'
theorem iUnion₂_mono' {s : ∀ i, κ i → Set α} {t : ∀ i', κ' i' → Set α}
(h : ∀ i j, ∃ i' j', s i j ⊆ t i' j') : ⋃ (i) (j), s i j ⊆ ⋃ (i') (j'), t i' j' :=
iSup₂_mono' h
#align set.Union₂_mono' Set.iUnion₂_mono'
theorem iInter_mono' {s : ι → Set α} {t : ι' → Set α} (h : ∀ j, ∃ i, s i ⊆ t j) :
⋂ i, s i ⊆ ⋂ j, t j :=
Set.subset_iInter fun j =>
let ⟨i, hi⟩ := h j
iInter_subset_of_subset i hi
#align set.Inter_mono' Set.iInter_mono'
theorem iInter₂_mono' {s : ∀ i, κ i → Set α} {t : ∀ i', κ' i' → Set α}
(h : ∀ i' j', ∃ i j, s i j ⊆ t i' j') : ⋂ (i) (j), s i j ⊆ ⋂ (i') (j'), t i' j' :=
subset_iInter₂_iff.2 fun i' j' =>
let ⟨_, _, hst⟩ := h i' j'
(iInter₂_subset _ _).trans hst
#align set.Inter₂_mono' Set.iInter₂_mono'
theorem iUnion₂_subset_iUnion (κ : ι → Sort*) (s : ι → Set α) :
⋃ (i) (_ : κ i), s i ⊆ ⋃ i, s i :=
iUnion_mono fun _ => iUnion_subset fun _ => Subset.rfl
#align set.Union₂_subset_Union Set.iUnion₂_subset_iUnion
theorem iInter_subset_iInter₂ (κ : ι → Sort*) (s : ι → Set α) :
⋂ i, s i ⊆ ⋂ (i) (_ : κ i), s i :=
iInter_mono fun _ => subset_iInter fun _ => Subset.rfl
#align set.Inter_subset_Inter₂ Set.iInter_subset_iInter₂
theorem iUnion_setOf (P : ι → α → Prop) : ⋃ i, { x : α | P i x } = { x : α | ∃ i, P i x } := by
ext
exact mem_iUnion
#align set.Union_set_of Set.iUnion_setOf
theorem iInter_setOf (P : ι → α → Prop) : ⋂ i, { x : α | P i x } = { x : α | ∀ i, P i x } := by
ext
exact mem_iInter
#align set.Inter_set_of Set.iInter_setOf
theorem iUnion_congr_of_surjective {f : ι → Set α} {g : ι₂ → Set α} (h : ι → ι₂) (h1 : Surjective h)
(h2 : ∀ x, g (h x) = f x) : ⋃ x, f x = ⋃ y, g y :=
h1.iSup_congr h h2
#align set.Union_congr_of_surjective Set.iUnion_congr_of_surjective
theorem iInter_congr_of_surjective {f : ι → Set α} {g : ι₂ → Set α} (h : ι → ι₂) (h1 : Surjective h)
(h2 : ∀ x, g (h x) = f x) : ⋂ x, f x = ⋂ y, g y :=
h1.iInf_congr h h2
#align set.Inter_congr_of_surjective Set.iInter_congr_of_surjective
lemma iUnion_congr {s t : ι → Set α} (h : ∀ i, s i = t i) : ⋃ i, s i = ⋃ i, t i := iSup_congr h
#align set.Union_congr Set.iUnion_congr
lemma iInter_congr {s t : ι → Set α} (h : ∀ i, s i = t i) : ⋂ i, s i = ⋂ i, t i := iInf_congr h
#align set.Inter_congr Set.iInter_congr
lemma iUnion₂_congr {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j = t i j) :
⋃ (i) (j), s i j = ⋃ (i) (j), t i j :=
iUnion_congr fun i => iUnion_congr <| h i
#align set.Union₂_congr Set.iUnion₂_congr
lemma iInter₂_congr {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j = t i j) :
⋂ (i) (j), s i j = ⋂ (i) (j), t i j :=
iInter_congr fun i => iInter_congr <| h i
#align set.Inter₂_congr Set.iInter₂_congr
@[simp]
theorem compl_iUnion (s : ι → Set β) : (⋃ i, s i)ᶜ = ⋂ i, (s i)ᶜ :=
compl_iSup
#align set.compl_Union Set.compl_iUnion
theorem compl_iUnion₂ (s : ∀ i, κ i → Set α) : (⋃ (i) (j), s i j)ᶜ = ⋂ (i) (j), (s i j)ᶜ := by
simp_rw [compl_iUnion]
#align set.compl_Union₂ Set.compl_iUnion₂
@[simp]
theorem compl_iInter (s : ι → Set β) : (⋂ i, s i)ᶜ = ⋃ i, (s i)ᶜ :=
compl_iInf
#align set.compl_Inter Set.compl_iInter
theorem compl_iInter₂ (s : ∀ i, κ i → Set α) : (⋂ (i) (j), s i j)ᶜ = ⋃ (i) (j), (s i j)ᶜ := by
simp_rw [compl_iInter]
#align set.compl_Inter₂ Set.compl_iInter₂
-- classical -- complete_boolean_algebra
theorem iUnion_eq_compl_iInter_compl (s : ι → Set β) : ⋃ i, s i = (⋂ i, (s i)ᶜ)ᶜ := by
simp only [compl_iInter, compl_compl]
#align set.Union_eq_compl_Inter_compl Set.iUnion_eq_compl_iInter_compl
-- classical -- complete_boolean_algebra
theorem iInter_eq_compl_iUnion_compl (s : ι → Set β) : ⋂ i, s i = (⋃ i, (s i)ᶜ)ᶜ := by
simp only [compl_iUnion, compl_compl]
#align set.Inter_eq_compl_Union_compl Set.iInter_eq_compl_iUnion_compl
theorem inter_iUnion (s : Set β) (t : ι → Set β) : (s ∩ ⋃ i, t i) = ⋃ i, s ∩ t i :=
inf_iSup_eq _ _
#align set.inter_Union Set.inter_iUnion
theorem iUnion_inter (s : Set β) (t : ι → Set β) : (⋃ i, t i) ∩ s = ⋃ i, t i ∩ s :=
iSup_inf_eq _ _
#align set.Union_inter Set.iUnion_inter
theorem iUnion_union_distrib (s : ι → Set β) (t : ι → Set β) :
⋃ i, s i ∪ t i = (⋃ i, s i) ∪ ⋃ i, t i :=
iSup_sup_eq
#align set.Union_union_distrib Set.iUnion_union_distrib
theorem iInter_inter_distrib (s : ι → Set β) (t : ι → Set β) :
⋂ i, s i ∩ t i = (⋂ i, s i) ∩ ⋂ i, t i :=
iInf_inf_eq
#align set.Inter_inter_distrib Set.iInter_inter_distrib
theorem union_iUnion [Nonempty ι] (s : Set β) (t : ι → Set β) : (s ∪ ⋃ i, t i) = ⋃ i, s ∪ t i :=
sup_iSup
#align set.union_Union Set.union_iUnion
theorem iUnion_union [Nonempty ι] (s : Set β) (t : ι → Set β) : (⋃ i, t i) ∪ s = ⋃ i, t i ∪ s :=
iSup_sup
#align set.Union_union Set.iUnion_union
theorem inter_iInter [Nonempty ι] (s : Set β) (t : ι → Set β) : (s ∩ ⋂ i, t i) = ⋂ i, s ∩ t i :=
inf_iInf
#align set.inter_Inter Set.inter_iInter
theorem iInter_inter [Nonempty ι] (s : Set β) (t : ι → Set β) : (⋂ i, t i) ∩ s = ⋂ i, t i ∩ s :=
iInf_inf
#align set.Inter_inter Set.iInter_inter
-- classical
theorem union_iInter (s : Set β) (t : ι → Set β) : (s ∪ ⋂ i, t i) = ⋂ i, s ∪ t i :=
sup_iInf_eq _ _
#align set.union_Inter Set.union_iInter
theorem iInter_union (s : ι → Set β) (t : Set β) : (⋂ i, s i) ∪ t = ⋂ i, s i ∪ t :=
iInf_sup_eq _ _
#align set.Inter_union Set.iInter_union
theorem iUnion_diff (s : Set β) (t : ι → Set β) : (⋃ i, t i) \ s = ⋃ i, t i \ s :=
iUnion_inter _ _
#align set.Union_diff Set.iUnion_diff
theorem diff_iUnion [Nonempty ι] (s : Set β) (t : ι → Set β) : (s \ ⋃ i, t i) = ⋂ i, s \ t i := by
rw [diff_eq, compl_iUnion, inter_iInter]; rfl
#align set.diff_Union Set.diff_iUnion
theorem diff_iInter (s : Set β) (t : ι → Set β) : (s \ ⋂ i, t i) = ⋃ i, s \ t i := by
rw [diff_eq, compl_iInter, inter_iUnion]; rfl
#align set.diff_Inter Set.diff_iInter
theorem iUnion_inter_subset {ι α} {s t : ι → Set α} : ⋃ i, s i ∩ t i ⊆ (⋃ i, s i) ∩ ⋃ i, t i :=
le_iSup_inf_iSup s t
#align set.Union_inter_subset Set.iUnion_inter_subset
theorem iUnion_inter_of_monotone {ι α} [Preorder ι] [IsDirected ι (· ≤ ·)] {s t : ι → Set α}
(hs : Monotone s) (ht : Monotone t) : ⋃ i, s i ∩ t i = (⋃ i, s i) ∩ ⋃ i, t i :=
iSup_inf_of_monotone hs ht
#align set.Union_inter_of_monotone Set.iUnion_inter_of_monotone
theorem iUnion_inter_of_antitone {ι α} [Preorder ι] [IsDirected ι (swap (· ≤ ·))] {s t : ι → Set α}
(hs : Antitone s) (ht : Antitone t) : ⋃ i, s i ∩ t i = (⋃ i, s i) ∩ ⋃ i, t i :=
iSup_inf_of_antitone hs ht
#align set.Union_inter_of_antitone Set.iUnion_inter_of_antitone
theorem iInter_union_of_monotone {ι α} [Preorder ι] [IsDirected ι (swap (· ≤ ·))] {s t : ι → Set α}
(hs : Monotone s) (ht : Monotone t) : ⋂ i, s i ∪ t i = (⋂ i, s i) ∪ ⋂ i, t i :=
iInf_sup_of_monotone hs ht
#align set.Inter_union_of_monotone Set.iInter_union_of_monotone
theorem iInter_union_of_antitone {ι α} [Preorder ι] [IsDirected ι (· ≤ ·)] {s t : ι → Set α}
(hs : Antitone s) (ht : Antitone t) : ⋂ i, s i ∪ t i = (⋂ i, s i) ∪ ⋂ i, t i :=
iInf_sup_of_antitone hs ht
#align set.Inter_union_of_antitone Set.iInter_union_of_antitone
theorem iUnion_iInter_subset {s : ι → ι' → Set α} : (⋃ j, ⋂ i, s i j) ⊆ ⋂ i, ⋃ j, s i j :=
iSup_iInf_le_iInf_iSup (flip s)
#align set.Union_Inter_subset Set.iUnion_iInter_subset
theorem iUnion_option {ι} (s : Option ι → Set α) : ⋃ o, s o = s none ∪ ⋃ i, s (some i) :=
iSup_option s
#align set.Union_option Set.iUnion_option
theorem iInter_option {ι} (s : Option ι → Set α) : ⋂ o, s o = s none ∩ ⋂ i, s (some i) :=
iInf_option s
#align set.Inter_option Set.iInter_option
section
variable (p : ι → Prop) [DecidablePred p]
theorem iUnion_dite (f : ∀ i, p i → Set α) (g : ∀ i, ¬p i → Set α) :
⋃ i, (if h : p i then f i h else g i h) = (⋃ (i) (h : p i), f i h) ∪ ⋃ (i) (h : ¬p i), g i h :=
iSup_dite _ _ _
#align set.Union_dite Set.iUnion_dite
theorem iUnion_ite (f g : ι → Set α) :
⋃ i, (if p i then f i else g i) = (⋃ (i) (_ : p i), f i) ∪ ⋃ (i) (_ : ¬p i), g i :=
iUnion_dite _ _ _
#align set.Union_ite Set.iUnion_ite
theorem iInter_dite (f : ∀ i, p i → Set α) (g : ∀ i, ¬p i → Set α) :
⋂ i, (if h : p i then f i h else g i h) = (⋂ (i) (h : p i), f i h) ∩ ⋂ (i) (h : ¬p i), g i h :=
iInf_dite _ _ _
#align set.Inter_dite Set.iInter_dite
theorem iInter_ite (f g : ι → Set α) :
⋂ i, (if p i then f i else g i) = (⋂ (i) (_ : p i), f i) ∩ ⋂ (i) (_ : ¬p i), g i :=
iInter_dite _ _ _
#align set.Inter_ite Set.iInter_ite
end
theorem image_projection_prod {ι : Type*} {α : ι → Type*} {v : ∀ i : ι, Set (α i)}
(hv : (pi univ v).Nonempty) (i : ι) :
((fun x : ∀ i : ι, α i => x i) '' ⋂ k, (fun x : ∀ j : ι, α j => x k) ⁻¹' v k) = v i := by
classical
apply Subset.antisymm
· simp [iInter_subset]
· intro y y_in
simp only [mem_image, mem_iInter, mem_preimage]
rcases hv with ⟨z, hz⟩
refine ⟨Function.update z i y, ?_, update_same i y z⟩
rw [@forall_update_iff ι α _ z i y fun i t => t ∈ v i]
exact ⟨y_in, fun j _ => by simpa using hz j⟩
#align set.image_projection_prod Set.image_projection_prod
theorem iInter_false {s : False → Set α} : iInter s = univ :=
iInf_false
#align set.Inter_false Set.iInter_false
theorem iUnion_false {s : False → Set α} : iUnion s = ∅ :=
iSup_false
#align set.Union_false Set.iUnion_false
@[simp]
theorem iInter_true {s : True → Set α} : iInter s = s trivial :=
iInf_true
#align set.Inter_true Set.iInter_true
@[simp]
theorem iUnion_true {s : True → Set α} : iUnion s = s trivial :=
iSup_true
#align set.Union_true Set.iUnion_true
@[simp]
theorem iInter_exists {p : ι → Prop} {f : Exists p → Set α} :
⋂ x, f x = ⋂ (i) (h : p i), f ⟨i, h⟩ :=
iInf_exists
#align set.Inter_exists Set.iInter_exists
@[simp]
theorem iUnion_exists {p : ι → Prop} {f : Exists p → Set α} :
⋃ x, f x = ⋃ (i) (h : p i), f ⟨i, h⟩ :=
iSup_exists
#align set.Union_exists Set.iUnion_exists
@[simp]
theorem iUnion_empty : (⋃ _ : ι, ∅ : Set α) = ∅ :=
iSup_bot
#align set.Union_empty Set.iUnion_empty
@[simp]
theorem iInter_univ : (⋂ _ : ι, univ : Set α) = univ :=
iInf_top
#align set.Inter_univ Set.iInter_univ
section
variable {s : ι → Set α}
@[simp]
theorem iUnion_eq_empty : ⋃ i, s i = ∅ ↔ ∀ i, s i = ∅ :=
iSup_eq_bot
#align set.Union_eq_empty Set.iUnion_eq_empty
@[simp]
theorem iInter_eq_univ : ⋂ i, s i = univ ↔ ∀ i, s i = univ :=
iInf_eq_top
#align set.Inter_eq_univ Set.iInter_eq_univ
@[simp]
theorem nonempty_iUnion : (⋃ i, s i).Nonempty ↔ ∃ i, (s i).Nonempty := by
simp [nonempty_iff_ne_empty]
#align set.nonempty_Union Set.nonempty_iUnion
-- Porting note (#10618): removing `simp`. `simp` can prove it
theorem nonempty_biUnion {t : Set α} {s : α → Set β} :
(⋃ i ∈ t, s i).Nonempty ↔ ∃ i ∈ t, (s i).Nonempty := by simp
#align set.nonempty_bUnion Set.nonempty_biUnion
theorem iUnion_nonempty_index (s : Set α) (t : s.Nonempty → Set β) :
⋃ h, t h = ⋃ x ∈ s, t ⟨x, ‹_›⟩ :=
iSup_exists
#align set.Union_nonempty_index Set.iUnion_nonempty_index
end
@[simp]
theorem iInter_iInter_eq_left {b : β} {s : ∀ x : β, x = b → Set α} :
⋂ (x) (h : x = b), s x h = s b rfl :=
iInf_iInf_eq_left
#align set.Inter_Inter_eq_left Set.iInter_iInter_eq_left
@[simp]
theorem iInter_iInter_eq_right {b : β} {s : ∀ x : β, b = x → Set α} :
⋂ (x) (h : b = x), s x h = s b rfl :=
iInf_iInf_eq_right
#align set.Inter_Inter_eq_right Set.iInter_iInter_eq_right
@[simp]
theorem iUnion_iUnion_eq_left {b : β} {s : ∀ x : β, x = b → Set α} :
⋃ (x) (h : x = b), s x h = s b rfl :=
iSup_iSup_eq_left
#align set.Union_Union_eq_left Set.iUnion_iUnion_eq_left
@[simp]
theorem iUnion_iUnion_eq_right {b : β} {s : ∀ x : β, b = x → Set α} :
⋃ (x) (h : b = x), s x h = s b rfl :=
iSup_iSup_eq_right
#align set.Union_Union_eq_right Set.iUnion_iUnion_eq_right
theorem iInter_or {p q : Prop} (s : p ∨ q → Set α) :
⋂ h, s h = (⋂ h : p, s (Or.inl h)) ∩ ⋂ h : q, s (Or.inr h) :=
iInf_or
#align set.Inter_or Set.iInter_or
theorem iUnion_or {p q : Prop} (s : p ∨ q → Set α) :
⋃ h, s h = (⋃ i, s (Or.inl i)) ∪ ⋃ j, s (Or.inr j) :=
iSup_or
#align set.Union_or Set.iUnion_or
theorem iUnion_and {p q : Prop} (s : p ∧ q → Set α) : ⋃ h, s h = ⋃ (hp) (hq), s ⟨hp, hq⟩ :=
iSup_and
#align set.Union_and Set.iUnion_and
theorem iInter_and {p q : Prop} (s : p ∧ q → Set α) : ⋂ h, s h = ⋂ (hp) (hq), s ⟨hp, hq⟩ :=
iInf_and
#align set.Inter_and Set.iInter_and
theorem iUnion_comm (s : ι → ι' → Set α) : ⋃ (i) (i'), s i i' = ⋃ (i') (i), s i i' :=
iSup_comm
#align set.Union_comm Set.iUnion_comm
theorem iInter_comm (s : ι → ι' → Set α) : ⋂ (i) (i'), s i i' = ⋂ (i') (i), s i i' :=
iInf_comm
#align set.Inter_comm Set.iInter_comm
theorem iUnion_sigma {γ : α → Type*} (s : Sigma γ → Set β) : ⋃ ia, s ia = ⋃ i, ⋃ a, s ⟨i, a⟩ :=
iSup_sigma
theorem iUnion_sigma' {γ : α → Type*} (s : ∀ i, γ i → Set β) :
⋃ i, ⋃ a, s i a = ⋃ ia : Sigma γ, s ia.1 ia.2 :=
iSup_sigma' _
theorem iInter_sigma {γ : α → Type*} (s : Sigma γ → Set β) : ⋂ ia, s ia = ⋂ i, ⋂ a, s ⟨i, a⟩ :=
iInf_sigma
theorem iInter_sigma' {γ : α → Type*} (s : ∀ i, γ i → Set β) :
⋂ i, ⋂ a, s i a = ⋂ ia : Sigma γ, s ia.1 ia.2 :=
iInf_sigma' _
theorem iUnion₂_comm (s : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → Set α) :
⋃ (i₁) (j₁) (i₂) (j₂), s i₁ j₁ i₂ j₂ = ⋃ (i₂) (j₂) (i₁) (j₁), s i₁ j₁ i₂ j₂ :=
iSup₂_comm _
#align set.Union₂_comm Set.iUnion₂_comm
theorem iInter₂_comm (s : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → Set α) :
⋂ (i₁) (j₁) (i₂) (j₂), s i₁ j₁ i₂ j₂ = ⋂ (i₂) (j₂) (i₁) (j₁), s i₁ j₁ i₂ j₂ :=
iInf₂_comm _
#align set.Inter₂_comm Set.iInter₂_comm
@[simp]
theorem biUnion_and (p : ι → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p x ∧ q x y → Set α) :
⋃ (x : ι) (y : ι') (h : p x ∧ q x y), s x y h =
⋃ (x : ι) (hx : p x) (y : ι') (hy : q x y), s x y ⟨hx, hy⟩ := by
simp only [iUnion_and, @iUnion_comm _ ι']
#align set.bUnion_and Set.biUnion_and
@[simp]
theorem biUnion_and' (p : ι' → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p y ∧ q x y → Set α) :
⋃ (x : ι) (y : ι') (h : p y ∧ q x y), s x y h =
⋃ (y : ι') (hy : p y) (x : ι) (hx : q x y), s x y ⟨hy, hx⟩ := by
simp only [iUnion_and, @iUnion_comm _ ι]
#align set.bUnion_and' Set.biUnion_and'
@[simp]
theorem biInter_and (p : ι → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p x ∧ q x y → Set α) :
⋂ (x : ι) (y : ι') (h : p x ∧ q x y), s x y h =
⋂ (x : ι) (hx : p x) (y : ι') (hy : q x y), s x y ⟨hx, hy⟩ := by
simp only [iInter_and, @iInter_comm _ ι']
#align set.bInter_and Set.biInter_and
@[simp]
theorem biInter_and' (p : ι' → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p y ∧ q x y → Set α) :
⋂ (x : ι) (y : ι') (h : p y ∧ q x y), s x y h =
⋂ (y : ι') (hy : p y) (x : ι) (hx : q x y), s x y ⟨hy, hx⟩ := by
simp only [iInter_and, @iInter_comm _ ι]
#align set.bInter_and' Set.biInter_and'
@[simp]
theorem iUnion_iUnion_eq_or_left {b : β} {p : β → Prop} {s : ∀ x : β, x = b ∨ p x → Set α} :
⋃ (x) (h), s x h = s b (Or.inl rfl) ∪ ⋃ (x) (h : p x), s x (Or.inr h) := by
simp only [iUnion_or, iUnion_union_distrib, iUnion_iUnion_eq_left]
#align set.Union_Union_eq_or_left Set.iUnion_iUnion_eq_or_left
@[simp]
theorem iInter_iInter_eq_or_left {b : β} {p : β → Prop} {s : ∀ x : β, x = b ∨ p x → Set α} :
⋂ (x) (h), s x h = s b (Or.inl rfl) ∩ ⋂ (x) (h : p x), s x (Or.inr h) := by
simp only [iInter_or, iInter_inter_distrib, iInter_iInter_eq_left]
#align set.Inter_Inter_eq_or_left Set.iInter_iInter_eq_or_left
theorem mem_biUnion {s : Set α} {t : α → Set β} {x : α} {y : β} (xs : x ∈ s) (ytx : y ∈ t x) :
y ∈ ⋃ x ∈ s, t x :=
mem_iUnion₂_of_mem xs ytx
#align set.mem_bUnion Set.mem_biUnion
theorem mem_biInter {s : Set α} {t : α → Set β} {y : β} (h : ∀ x ∈ s, y ∈ t x) :
y ∈ ⋂ x ∈ s, t x :=
mem_iInter₂_of_mem h
#align set.mem_bInter Set.mem_biInter
theorem subset_biUnion_of_mem {s : Set α} {u : α → Set β} {x : α} (xs : x ∈ s) :
u x ⊆ ⋃ x ∈ s, u x :=
-- Porting note: Why is this not just `subset_iUnion₂ x xs`?
@subset_iUnion₂ β α (· ∈ s) (fun i _ => u i) x xs
#align set.subset_bUnion_of_mem Set.subset_biUnion_of_mem
theorem biInter_subset_of_mem {s : Set α} {t : α → Set β} {x : α} (xs : x ∈ s) :
⋂ x ∈ s, t x ⊆ t x :=
iInter₂_subset x xs
#align set.bInter_subset_of_mem Set.biInter_subset_of_mem
theorem biUnion_subset_biUnion_left {s s' : Set α} {t : α → Set β} (h : s ⊆ s') :
⋃ x ∈ s, t x ⊆ ⋃ x ∈ s', t x :=
iUnion₂_subset fun _ hx => subset_biUnion_of_mem <| h hx
#align set.bUnion_subset_bUnion_left Set.biUnion_subset_biUnion_left
theorem biInter_subset_biInter_left {s s' : Set α} {t : α → Set β} (h : s' ⊆ s) :
⋂ x ∈ s, t x ⊆ ⋂ x ∈ s', t x :=
subset_iInter₂ fun _ hx => biInter_subset_of_mem <| h hx
#align set.bInter_subset_bInter_left Set.biInter_subset_biInter_left
theorem biUnion_mono {s s' : Set α} {t t' : α → Set β} (hs : s' ⊆ s) (h : ∀ x ∈ s, t x ⊆ t' x) :
⋃ x ∈ s', t x ⊆ ⋃ x ∈ s, t' x :=
(biUnion_subset_biUnion_left hs).trans <| iUnion₂_mono h
#align set.bUnion_mono Set.biUnion_mono
theorem biInter_mono {s s' : Set α} {t t' : α → Set β} (hs : s ⊆ s') (h : ∀ x ∈ s, t x ⊆ t' x) :
⋂ x ∈ s', t x ⊆ ⋂ x ∈ s, t' x :=
(biInter_subset_biInter_left hs).trans <| iInter₂_mono h
#align set.bInter_mono Set.biInter_mono
theorem biUnion_eq_iUnion (s : Set α) (t : ∀ x ∈ s, Set β) :
⋃ x ∈ s, t x ‹_› = ⋃ x : s, t x x.2 :=
iSup_subtype'
#align set.bUnion_eq_Union Set.biUnion_eq_iUnion
theorem biInter_eq_iInter (s : Set α) (t : ∀ x ∈ s, Set β) :
⋂ x ∈ s, t x ‹_› = ⋂ x : s, t x x.2 :=
iInf_subtype'
#align set.bInter_eq_Inter Set.biInter_eq_iInter
theorem iUnion_subtype (p : α → Prop) (s : { x // p x } → Set β) :
⋃ x : { x // p x }, s x = ⋃ (x) (hx : p x), s ⟨x, hx⟩ :=
iSup_subtype
#align set.Union_subtype Set.iUnion_subtype
theorem iInter_subtype (p : α → Prop) (s : { x // p x } → Set β) :
⋂ x : { x // p x }, s x = ⋂ (x) (hx : p x), s ⟨x, hx⟩ :=
iInf_subtype
#align set.Inter_subtype Set.iInter_subtype
theorem biInter_empty (u : α → Set β) : ⋂ x ∈ (∅ : Set α), u x = univ :=
iInf_emptyset
#align set.bInter_empty Set.biInter_empty
theorem biInter_univ (u : α → Set β) : ⋂ x ∈ @univ α, u x = ⋂ x, u x :=
iInf_univ
#align set.bInter_univ Set.biInter_univ
@[simp]
theorem biUnion_self (s : Set α) : ⋃ x ∈ s, s = s :=
Subset.antisymm (iUnion₂_subset fun _ _ => Subset.refl s) fun _ hx => mem_biUnion hx hx
#align set.bUnion_self Set.biUnion_self
@[simp]
theorem iUnion_nonempty_self (s : Set α) : ⋃ _ : s.Nonempty, s = s := by
rw [iUnion_nonempty_index, biUnion_self]
#align set.Union_nonempty_self Set.iUnion_nonempty_self
theorem biInter_singleton (a : α) (s : α → Set β) : ⋂ x ∈ ({a} : Set α), s x = s a :=
iInf_singleton
#align set.bInter_singleton Set.biInter_singleton
theorem biInter_union (s t : Set α) (u : α → Set β) :
⋂ x ∈ s ∪ t, u x = (⋂ x ∈ s, u x) ∩ ⋂ x ∈ t, u x :=
iInf_union
#align set.bInter_union Set.biInter_union
theorem biInter_insert (a : α) (s : Set α) (t : α → Set β) :
⋂ x ∈ insert a s, t x = t a ∩ ⋂ x ∈ s, t x := by simp
#align set.bInter_insert Set.biInter_insert
theorem biInter_pair (a b : α) (s : α → Set β) : ⋂ x ∈ ({a, b} : Set α), s x = s a ∩ s b := by
rw [biInter_insert, biInter_singleton]
#align set.bInter_pair Set.biInter_pair
theorem biInter_inter {ι α : Type*} {s : Set ι} (hs : s.Nonempty) (f : ι → Set α) (t : Set α) :
⋂ i ∈ s, f i ∩ t = (⋂ i ∈ s, f i) ∩ t := by
haveI : Nonempty s := hs.to_subtype
simp [biInter_eq_iInter, ← iInter_inter]
#align set.bInter_inter Set.biInter_inter
theorem inter_biInter {ι α : Type*} {s : Set ι} (hs : s.Nonempty) (f : ι → Set α) (t : Set α) :
⋂ i ∈ s, t ∩ f i = t ∩ ⋂ i ∈ s, f i := by
rw [inter_comm, ← biInter_inter hs]
simp [inter_comm]
#align set.inter_bInter Set.inter_biInter
theorem biUnion_empty (s : α → Set β) : ⋃ x ∈ (∅ : Set α), s x = ∅ :=
iSup_emptyset
#align set.bUnion_empty Set.biUnion_empty
theorem biUnion_univ (s : α → Set β) : ⋃ x ∈ @univ α, s x = ⋃ x, s x :=
iSup_univ
#align set.bUnion_univ Set.biUnion_univ
theorem biUnion_singleton (a : α) (s : α → Set β) : ⋃ x ∈ ({a} : Set α), s x = s a :=
iSup_singleton
#align set.bUnion_singleton Set.biUnion_singleton
@[simp]
theorem biUnion_of_singleton (s : Set α) : ⋃ x ∈ s, {x} = s :=
ext <| by simp
#align set.bUnion_of_singleton Set.biUnion_of_singleton
theorem biUnion_union (s t : Set α) (u : α → Set β) :
⋃ x ∈ s ∪ t, u x = (⋃ x ∈ s, u x) ∪ ⋃ x ∈ t, u x :=
iSup_union
#align set.bUnion_union Set.biUnion_union
@[simp]
theorem iUnion_coe_set {α β : Type*} (s : Set α) (f : s → Set β) :
⋃ i, f i = ⋃ i ∈ s, f ⟨i, ‹i ∈ s›⟩ :=
iUnion_subtype _ _
#align set.Union_coe_set Set.iUnion_coe_set
@[simp]
theorem iInter_coe_set {α β : Type*} (s : Set α) (f : s → Set β) :
⋂ i, f i = ⋂ i ∈ s, f ⟨i, ‹i ∈ s›⟩ :=
iInter_subtype _ _
#align set.Inter_coe_set Set.iInter_coe_set
theorem biUnion_insert (a : α) (s : Set α) (t : α → Set β) :
⋃ x ∈ insert a s, t x = t a ∪ ⋃ x ∈ s, t x := by simp
#align set.bUnion_insert Set.biUnion_insert
theorem biUnion_pair (a b : α) (s : α → Set β) : ⋃ x ∈ ({a, b} : Set α), s x = s a ∪ s b := by
simp
#align set.bUnion_pair Set.biUnion_pair
theorem inter_iUnion₂ (s : Set α) (t : ∀ i, κ i → Set α) :
(s ∩ ⋃ (i) (j), t i j) = ⋃ (i) (j), s ∩ t i j := by simp only [inter_iUnion]
#align set.inter_Union₂ Set.inter_iUnion₂
theorem iUnion₂_inter (s : ∀ i, κ i → Set α) (t : Set α) :
(⋃ (i) (j), s i j) ∩ t = ⋃ (i) (j), s i j ∩ t := by simp_rw [iUnion_inter]
#align set.Union₂_inter Set.iUnion₂_inter
theorem union_iInter₂ (s : Set α) (t : ∀ i, κ i → Set α) :
(s ∪ ⋂ (i) (j), t i j) = ⋂ (i) (j), s ∪ t i j := by simp_rw [union_iInter]
#align set.union_Inter₂ Set.union_iInter₂
theorem iInter₂_union (s : ∀ i, κ i → Set α) (t : Set α) :
(⋂ (i) (j), s i j) ∪ t = ⋂ (i) (j), s i j ∪ t := by simp_rw [iInter_union]
#align set.Inter₂_union Set.iInter₂_union
theorem mem_sUnion_of_mem {x : α} {t : Set α} {S : Set (Set α)} (hx : x ∈ t) (ht : t ∈ S) :
x ∈ ⋃₀S :=
⟨t, ht, hx⟩
#align set.mem_sUnion_of_mem Set.mem_sUnion_of_mem
-- is this theorem really necessary?
theorem not_mem_of_not_mem_sUnion {x : α} {t : Set α} {S : Set (Set α)} (hx : x ∉ ⋃₀S)
(ht : t ∈ S) : x ∉ t := fun h => hx ⟨t, ht, h⟩
#align set.not_mem_of_not_mem_sUnion Set.not_mem_of_not_mem_sUnion
theorem sInter_subset_of_mem {S : Set (Set α)} {t : Set α} (tS : t ∈ S) : ⋂₀ S ⊆ t :=
sInf_le tS
#align set.sInter_subset_of_mem Set.sInter_subset_of_mem
theorem subset_sUnion_of_mem {S : Set (Set α)} {t : Set α} (tS : t ∈ S) : t ⊆ ⋃₀S :=
le_sSup tS
#align set.subset_sUnion_of_mem Set.subset_sUnion_of_mem
theorem subset_sUnion_of_subset {s : Set α} (t : Set (Set α)) (u : Set α) (h₁ : s ⊆ u)
(h₂ : u ∈ t) : s ⊆ ⋃₀t :=
Subset.trans h₁ (subset_sUnion_of_mem h₂)
#align set.subset_sUnion_of_subset Set.subset_sUnion_of_subset
theorem sUnion_subset {S : Set (Set α)} {t : Set α} (h : ∀ t' ∈ S, t' ⊆ t) : ⋃₀S ⊆ t :=
sSup_le h
#align set.sUnion_subset Set.sUnion_subset
@[simp]
theorem sUnion_subset_iff {s : Set (Set α)} {t : Set α} : ⋃₀s ⊆ t ↔ ∀ t' ∈ s, t' ⊆ t :=
sSup_le_iff
#align set.sUnion_subset_iff Set.sUnion_subset_iff
lemma sUnion_mono_subsets {s : Set (Set α)} {f : Set α → Set α} (hf : ∀ t : Set α, t ⊆ f t) :
⋃₀ s ⊆ ⋃₀ (f '' s) :=
fun _ ⟨t, htx, hxt⟩ ↦ ⟨f t, mem_image_of_mem f htx, hf t hxt⟩
lemma sUnion_mono_supsets {s : Set (Set α)} {f : Set α → Set α} (hf : ∀ t : Set α, f t ⊆ t) :
⋃₀ (f '' s) ⊆ ⋃₀ s :=
-- If t ∈ f '' s is arbitrary; t = f u for some u : Set α.
fun _ ⟨_, ⟨u, hus, hut⟩, hxt⟩ ↦ ⟨u, hus, (hut ▸ hf u) hxt⟩
theorem subset_sInter {S : Set (Set α)} {t : Set α} (h : ∀ t' ∈ S, t ⊆ t') : t ⊆ ⋂₀ S :=
le_sInf h
#align set.subset_sInter Set.subset_sInter
@[simp]
theorem subset_sInter_iff {S : Set (Set α)} {t : Set α} : t ⊆ ⋂₀ S ↔ ∀ t' ∈ S, t ⊆ t' :=
le_sInf_iff
#align set.subset_sInter_iff Set.subset_sInter_iff
@[gcongr]
theorem sUnion_subset_sUnion {S T : Set (Set α)} (h : S ⊆ T) : ⋃₀S ⊆ ⋃₀T :=
sUnion_subset fun _ hs => subset_sUnion_of_mem (h hs)
#align set.sUnion_subset_sUnion Set.sUnion_subset_sUnion
@[gcongr]
theorem sInter_subset_sInter {S T : Set (Set α)} (h : S ⊆ T) : ⋂₀ T ⊆ ⋂₀ S :=
subset_sInter fun _ hs => sInter_subset_of_mem (h hs)
#align set.sInter_subset_sInter Set.sInter_subset_sInter
@[simp]
theorem sUnion_empty : ⋃₀∅ = (∅ : Set α) :=
sSup_empty
#align set.sUnion_empty Set.sUnion_empty
@[simp]
theorem sInter_empty : ⋂₀ ∅ = (univ : Set α) :=
sInf_empty
#align set.sInter_empty Set.sInter_empty
@[simp]
theorem sUnion_singleton (s : Set α) : ⋃₀{s} = s :=
sSup_singleton
#align set.sUnion_singleton Set.sUnion_singleton
@[simp]
theorem sInter_singleton (s : Set α) : ⋂₀ {s} = s :=
sInf_singleton
#align set.sInter_singleton Set.sInter_singleton
@[simp]
theorem sUnion_eq_empty {S : Set (Set α)} : ⋃₀S = ∅ ↔ ∀ s ∈ S, s = ∅ :=
sSup_eq_bot
#align set.sUnion_eq_empty Set.sUnion_eq_empty
@[simp]
theorem sInter_eq_univ {S : Set (Set α)} : ⋂₀ S = univ ↔ ∀ s ∈ S, s = univ :=
sInf_eq_top
#align set.sInter_eq_univ Set.sInter_eq_univ
theorem subset_powerset_iff {s : Set (Set α)} {t : Set α} : s ⊆ 𝒫 t ↔ ⋃₀ s ⊆ t :=
sUnion_subset_iff.symm
theorem sUnion_powerset_gc :
GaloisConnection (⋃₀ · : Set (Set α) → Set α) (𝒫 · : Set α → Set (Set α)) :=
gc_sSup_Iic
def sUnion_powerset_gi :
GaloisInsertion (⋃₀ · : Set (Set α) → Set α) (𝒫 · : Set α → Set (Set α)) :=
gi_sSup_Iic
theorem sUnion_mem_empty_univ {S : Set (Set α)} (h : S ⊆ {∅, univ}) :
⋃₀ S ∈ ({∅, univ} : Set (Set α)) := by
simp only [mem_insert_iff, mem_singleton_iff, or_iff_not_imp_left, sUnion_eq_empty, not_forall]
rintro ⟨s, hs, hne⟩
obtain rfl : s = univ := (h hs).resolve_left hne
exact univ_subset_iff.1 <| subset_sUnion_of_mem hs
@[simp]
theorem nonempty_sUnion {S : Set (Set α)} : (⋃₀S).Nonempty ↔ ∃ s ∈ S, Set.Nonempty s := by
simp [nonempty_iff_ne_empty]
#align set.nonempty_sUnion Set.nonempty_sUnion
theorem Nonempty.of_sUnion {s : Set (Set α)} (h : (⋃₀s).Nonempty) : s.Nonempty :=
let ⟨s, hs, _⟩ := nonempty_sUnion.1 h
⟨s, hs⟩
#align set.nonempty.of_sUnion Set.Nonempty.of_sUnion
theorem Nonempty.of_sUnion_eq_univ [Nonempty α] {s : Set (Set α)} (h : ⋃₀s = univ) : s.Nonempty :=
Nonempty.of_sUnion <| h.symm ▸ univ_nonempty
#align set.nonempty.of_sUnion_eq_univ Set.Nonempty.of_sUnion_eq_univ
theorem sUnion_union (S T : Set (Set α)) : ⋃₀(S ∪ T) = ⋃₀S ∪ ⋃₀T :=
sSup_union
#align set.sUnion_union Set.sUnion_union
theorem sInter_union (S T : Set (Set α)) : ⋂₀ (S ∪ T) = ⋂₀ S ∩ ⋂₀ T :=
sInf_union
#align set.sInter_union Set.sInter_union
@[simp]
theorem sUnion_insert (s : Set α) (T : Set (Set α)) : ⋃₀insert s T = s ∪ ⋃₀T :=
sSup_insert
#align set.sUnion_insert Set.sUnion_insert
@[simp]
theorem sInter_insert (s : Set α) (T : Set (Set α)) : ⋂₀ insert s T = s ∩ ⋂₀ T :=
sInf_insert
#align set.sInter_insert Set.sInter_insert
@[simp]
theorem sUnion_diff_singleton_empty (s : Set (Set α)) : ⋃₀(s \ {∅}) = ⋃₀s :=
sSup_diff_singleton_bot s
#align set.sUnion_diff_singleton_empty Set.sUnion_diff_singleton_empty
@[simp]
theorem sInter_diff_singleton_univ (s : Set (Set α)) : ⋂₀ (s \ {univ}) = ⋂₀ s :=
sInf_diff_singleton_top s
#align set.sInter_diff_singleton_univ Set.sInter_diff_singleton_univ
theorem sUnion_pair (s t : Set α) : ⋃₀{s, t} = s ∪ t :=
sSup_pair
#align set.sUnion_pair Set.sUnion_pair
theorem sInter_pair (s t : Set α) : ⋂₀ {s, t} = s ∩ t :=
sInf_pair
#align set.sInter_pair Set.sInter_pair
@[simp]
theorem sUnion_image (f : α → Set β) (s : Set α) : ⋃₀(f '' s) = ⋃ x ∈ s, f x :=
sSup_image
#align set.sUnion_image Set.sUnion_image
@[simp]
theorem sInter_image (f : α → Set β) (s : Set α) : ⋂₀ (f '' s) = ⋂ x ∈ s, f x :=
sInf_image
#align set.sInter_image Set.sInter_image
@[simp]
theorem sUnion_range (f : ι → Set β) : ⋃₀range f = ⋃ x, f x :=
rfl
#align set.sUnion_range Set.sUnion_range
@[simp]
theorem sInter_range (f : ι → Set β) : ⋂₀ range f = ⋂ x, f x :=
rfl
#align set.sInter_range Set.sInter_range
theorem iUnion_eq_univ_iff {f : ι → Set α} : ⋃ i, f i = univ ↔ ∀ x, ∃ i, x ∈ f i := by
simp only [eq_univ_iff_forall, mem_iUnion]
#align set.Union_eq_univ_iff Set.iUnion_eq_univ_iff
theorem iUnion₂_eq_univ_iff {s : ∀ i, κ i → Set α} :
⋃ (i) (j), s i j = univ ↔ ∀ a, ∃ i j, a ∈ s i j := by
simp only [iUnion_eq_univ_iff, mem_iUnion]
#align set.Union₂_eq_univ_iff Set.iUnion₂_eq_univ_iff
theorem sUnion_eq_univ_iff {c : Set (Set α)} : ⋃₀c = univ ↔ ∀ a, ∃ b ∈ c, a ∈ b := by
simp only [eq_univ_iff_forall, mem_sUnion]
#align set.sUnion_eq_univ_iff Set.sUnion_eq_univ_iff
-- classical
theorem iInter_eq_empty_iff {f : ι → Set α} : ⋂ i, f i = ∅ ↔ ∀ x, ∃ i, x ∉ f i := by
simp [Set.eq_empty_iff_forall_not_mem]
#align set.Inter_eq_empty_iff Set.iInter_eq_empty_iff
-- classical
theorem iInter₂_eq_empty_iff {s : ∀ i, κ i → Set α} :
⋂ (i) (j), s i j = ∅ ↔ ∀ a, ∃ i j, a ∉ s i j := by
simp only [eq_empty_iff_forall_not_mem, mem_iInter, not_forall]
#align set.Inter₂_eq_empty_iff Set.iInter₂_eq_empty_iff
-- classical
theorem sInter_eq_empty_iff {c : Set (Set α)} : ⋂₀ c = ∅ ↔ ∀ a, ∃ b ∈ c, a ∉ b := by
simp [Set.eq_empty_iff_forall_not_mem]
#align set.sInter_eq_empty_iff Set.sInter_eq_empty_iff
-- classical
@[simp]
theorem nonempty_iInter {f : ι → Set α} : (⋂ i, f i).Nonempty ↔ ∃ x, ∀ i, x ∈ f i := by
simp [nonempty_iff_ne_empty, iInter_eq_empty_iff]
#align set.nonempty_Inter Set.nonempty_iInter
-- classical
-- Porting note (#10618): removing `simp`. `simp` can prove it
theorem nonempty_iInter₂ {s : ∀ i, κ i → Set α} :
(⋂ (i) (j), s i j).Nonempty ↔ ∃ a, ∀ i j, a ∈ s i j := by
simp
#align set.nonempty_Inter₂ Set.nonempty_iInter₂
-- classical
@[simp]
theorem nonempty_sInter {c : Set (Set α)} : (⋂₀ c).Nonempty ↔ ∃ a, ∀ b ∈ c, a ∈ b := by
simp [nonempty_iff_ne_empty, sInter_eq_empty_iff]
#align set.nonempty_sInter Set.nonempty_sInter
-- classical
theorem compl_sUnion (S : Set (Set α)) : (⋃₀S)ᶜ = ⋂₀ (compl '' S) :=
ext fun x => by simp
#align set.compl_sUnion Set.compl_sUnion
-- classical
theorem sUnion_eq_compl_sInter_compl (S : Set (Set α)) : ⋃₀S = (⋂₀ (compl '' S))ᶜ := by
rw [← compl_compl (⋃₀S), compl_sUnion]
#align set.sUnion_eq_compl_sInter_compl Set.sUnion_eq_compl_sInter_compl
-- classical
theorem compl_sInter (S : Set (Set α)) : (⋂₀ S)ᶜ = ⋃₀(compl '' S) := by
rw [sUnion_eq_compl_sInter_compl, compl_compl_image]
#align set.compl_sInter Set.compl_sInter
-- classical
theorem sInter_eq_compl_sUnion_compl (S : Set (Set α)) : ⋂₀ S = (⋃₀(compl '' S))ᶜ := by
rw [← compl_compl (⋂₀ S), compl_sInter]
#align set.sInter_eq_compl_sUnion_compl Set.sInter_eq_compl_sUnion_compl
theorem inter_empty_of_inter_sUnion_empty {s t : Set α} {S : Set (Set α)} (hs : t ∈ S)
(h : s ∩ ⋃₀S = ∅) : s ∩ t = ∅ :=
eq_empty_of_subset_empty <| by
rw [← h]; exact inter_subset_inter_right _ (subset_sUnion_of_mem hs)
#align set.inter_empty_of_inter_sUnion_empty Set.inter_empty_of_inter_sUnion_empty
theorem range_sigma_eq_iUnion_range {γ : α → Type*} (f : Sigma γ → β) :
range f = ⋃ a, range fun b => f ⟨a, b⟩ :=
Set.ext <| by simp
#align set.range_sigma_eq_Union_range Set.range_sigma_eq_iUnion_range
theorem iUnion_eq_range_sigma (s : α → Set β) : ⋃ i, s i = range fun a : Σi, s i => a.2 := by
simp [Set.ext_iff]
#align set.Union_eq_range_sigma Set.iUnion_eq_range_sigma
theorem iUnion_eq_range_psigma (s : ι → Set β) : ⋃ i, s i = range fun a : Σ'i, s i => a.2 := by
simp [Set.ext_iff]
#align set.Union_eq_range_psigma Set.iUnion_eq_range_psigma
theorem iUnion_image_preimage_sigma_mk_eq_self {ι : Type*} {σ : ι → Type*} (s : Set (Sigma σ)) :
⋃ i, Sigma.mk i '' (Sigma.mk i ⁻¹' s) = s := by
ext x
simp only [mem_iUnion, mem_image, mem_preimage]
constructor
· rintro ⟨i, a, h, rfl⟩
exact h
· intro h
cases' x with i a
exact ⟨i, a, h, rfl⟩
#align set.Union_image_preimage_sigma_mk_eq_self Set.iUnion_image_preimage_sigma_mk_eq_self
theorem Sigma.univ (X : α → Type*) : (Set.univ : Set (Σa, X a)) = ⋃ a, range (Sigma.mk a) :=
Set.ext fun x =>
iff_of_true trivial ⟨range (Sigma.mk x.1), Set.mem_range_self _, x.2, Sigma.eta x⟩
#align set.sigma.univ Set.Sigma.univ
alias sUnion_mono := sUnion_subset_sUnion
#align set.sUnion_mono Set.sUnion_mono
theorem iUnion_subset_iUnion_const {s : Set α} (h : ι → ι₂) : ⋃ _ : ι, s ⊆ ⋃ _ : ι₂, s :=
iSup_const_mono (α := Set α) h
#align set.Union_subset_Union_const Set.iUnion_subset_iUnion_const
@[simp]
theorem iUnion_singleton_eq_range {α β : Type*} (f : α → β) : ⋃ x : α, {f x} = range f := by
ext x
simp [@eq_comm _ x]
#align set.Union_singleton_eq_range Set.iUnion_singleton_eq_range
theorem iUnion_of_singleton (α : Type*) : (⋃ x, {x} : Set α) = univ := by simp [Set.ext_iff]
#align set.Union_of_singleton Set.iUnion_of_singleton
theorem iUnion_of_singleton_coe (s : Set α) : ⋃ i : s, ({(i : α)} : Set α) = s := by simp
#align set.Union_of_singleton_coe Set.iUnion_of_singleton_coe
| Mathlib/Data/Set/Lattice.lean | 1,304 | 1,305 | theorem sUnion_eq_biUnion {s : Set (Set α)} : ⋃₀s = ⋃ (i : Set α) (_ : i ∈ s), i := by |
rw [← sUnion_image, image_id']
|
import Mathlib.Algebra.ContinuedFractions.Basic
import Mathlib.Algebra.GroupWithZero.Basic
#align_import algebra.continued_fractions.translations from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
namespace GeneralizedContinuedFraction
section General
variable {α : Type*} {g : GeneralizedContinuedFraction α} {n : ℕ}
| Mathlib/Algebra/ContinuedFractions/Translations.lean | 35 | 35 | theorem terminatedAt_iff_s_terminatedAt : g.TerminatedAt n ↔ g.s.TerminatedAt n := by | rfl
|
import Mathlib.Data.List.Nodup
import Mathlib.Data.List.Zip
import Mathlib.Data.Nat.Defs
import Mathlib.Data.List.Infix
#align_import data.list.rotate from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
universe u
variable {α : Type u}
open Nat Function
namespace List
theorem rotate_mod (l : List α) (n : ℕ) : l.rotate (n % l.length) = l.rotate n := by simp [rotate]
#align list.rotate_mod List.rotate_mod
@[simp]
theorem rotate_nil (n : ℕ) : ([] : List α).rotate n = [] := by simp [rotate]
#align list.rotate_nil List.rotate_nil
@[simp]
theorem rotate_zero (l : List α) : l.rotate 0 = l := by simp [rotate]
#align list.rotate_zero List.rotate_zero
-- Porting note: removing simp, simp can prove it
theorem rotate'_nil (n : ℕ) : ([] : List α).rotate' n = [] := by cases n <;> rfl
#align list.rotate'_nil List.rotate'_nil
@[simp]
theorem rotate'_zero (l : List α) : l.rotate' 0 = l := by cases l <;> rfl
#align list.rotate'_zero List.rotate'_zero
theorem rotate'_cons_succ (l : List α) (a : α) (n : ℕ) :
(a :: l : List α).rotate' n.succ = (l ++ [a]).rotate' n := by simp [rotate']
#align list.rotate'_cons_succ List.rotate'_cons_succ
@[simp]
theorem length_rotate' : ∀ (l : List α) (n : ℕ), (l.rotate' n).length = l.length
| [], _ => by simp
| a :: l, 0 => rfl
| a :: l, n + 1 => by rw [List.rotate', length_rotate' (l ++ [a]) n]; simp
#align list.length_rotate' List.length_rotate'
theorem rotate'_eq_drop_append_take :
∀ {l : List α} {n : ℕ}, n ≤ l.length → l.rotate' n = l.drop n ++ l.take n
| [], n, h => by simp [drop_append_of_le_length h]
| l, 0, h => by simp [take_append_of_le_length h]
| a :: l, n + 1, h => by
have hnl : n ≤ l.length := le_of_succ_le_succ h
have hnl' : n ≤ (l ++ [a]).length := by
rw [length_append, length_cons, List.length]; exact le_of_succ_le h
rw [rotate'_cons_succ, rotate'_eq_drop_append_take hnl', drop, take,
drop_append_of_le_length hnl, take_append_of_le_length hnl]; simp
#align list.rotate'_eq_drop_append_take List.rotate'_eq_drop_append_take
theorem rotate'_rotate' : ∀ (l : List α) (n m : ℕ), (l.rotate' n).rotate' m = l.rotate' (n + m)
| a :: l, 0, m => by simp
| [], n, m => by simp
| a :: l, n + 1, m => by
rw [rotate'_cons_succ, rotate'_rotate' _ n, Nat.add_right_comm, ← rotate'_cons_succ,
Nat.succ_eq_add_one]
#align list.rotate'_rotate' List.rotate'_rotate'
@[simp]
theorem rotate'_length (l : List α) : rotate' l l.length = l := by
rw [rotate'_eq_drop_append_take le_rfl]; simp
#align list.rotate'_length List.rotate'_length
@[simp]
theorem rotate'_length_mul (l : List α) : ∀ n : ℕ, l.rotate' (l.length * n) = l
| 0 => by simp
| n + 1 =>
calc
l.rotate' (l.length * (n + 1)) =
(l.rotate' (l.length * n)).rotate' (l.rotate' (l.length * n)).length := by
simp [-rotate'_length, Nat.mul_succ, rotate'_rotate']
_ = l := by rw [rotate'_length, rotate'_length_mul l n]
#align list.rotate'_length_mul List.rotate'_length_mul
theorem rotate'_mod (l : List α) (n : ℕ) : l.rotate' (n % l.length) = l.rotate' n :=
calc
l.rotate' (n % l.length) =
(l.rotate' (n % l.length)).rotate' ((l.rotate' (n % l.length)).length * (n / l.length)) :=
by rw [rotate'_length_mul]
_ = l.rotate' n := by rw [rotate'_rotate', length_rotate', Nat.mod_add_div]
#align list.rotate'_mod List.rotate'_mod
theorem rotate_eq_rotate' (l : List α) (n : ℕ) : l.rotate n = l.rotate' n :=
if h : l.length = 0 then by simp_all [length_eq_zero]
else by
rw [← rotate'_mod,
rotate'_eq_drop_append_take (le_of_lt (Nat.mod_lt _ (Nat.pos_of_ne_zero h)))];
simp [rotate]
#align list.rotate_eq_rotate' List.rotate_eq_rotate'
theorem rotate_cons_succ (l : List α) (a : α) (n : ℕ) :
(a :: l : List α).rotate (n + 1) = (l ++ [a]).rotate n := by
rw [rotate_eq_rotate', rotate_eq_rotate', rotate'_cons_succ]
#align list.rotate_cons_succ List.rotate_cons_succ
@[simp]
theorem mem_rotate : ∀ {l : List α} {a : α} {n : ℕ}, a ∈ l.rotate n ↔ a ∈ l
| [], _, n => by simp
| a :: l, _, 0 => by simp
| a :: l, _, n + 1 => by simp [rotate_cons_succ, mem_rotate, or_comm]
#align list.mem_rotate List.mem_rotate
@[simp]
theorem length_rotate (l : List α) (n : ℕ) : (l.rotate n).length = l.length := by
rw [rotate_eq_rotate', length_rotate']
#align list.length_rotate List.length_rotate
@[simp]
theorem rotate_replicate (a : α) (n : ℕ) (k : ℕ) : (replicate n a).rotate k = replicate n a :=
eq_replicate.2 ⟨by rw [length_rotate, length_replicate], fun b hb =>
eq_of_mem_replicate <| mem_rotate.1 hb⟩
#align list.rotate_replicate List.rotate_replicate
theorem rotate_eq_drop_append_take {l : List α} {n : ℕ} :
n ≤ l.length → l.rotate n = l.drop n ++ l.take n := by
rw [rotate_eq_rotate']; exact rotate'_eq_drop_append_take
#align list.rotate_eq_drop_append_take List.rotate_eq_drop_append_take
theorem rotate_eq_drop_append_take_mod {l : List α} {n : ℕ} :
l.rotate n = l.drop (n % l.length) ++ l.take (n % l.length) := by
rcases l.length.zero_le.eq_or_lt with hl | hl
· simp [eq_nil_of_length_eq_zero hl.symm]
rw [← rotate_eq_drop_append_take (n.mod_lt hl).le, rotate_mod]
#align list.rotate_eq_drop_append_take_mod List.rotate_eq_drop_append_take_mod
@[simp]
theorem rotate_append_length_eq (l l' : List α) : (l ++ l').rotate l.length = l' ++ l := by
rw [rotate_eq_rotate']
induction l generalizing l'
· simp
· simp_all [rotate']
#align list.rotate_append_length_eq List.rotate_append_length_eq
theorem rotate_rotate (l : List α) (n m : ℕ) : (l.rotate n).rotate m = l.rotate (n + m) := by
rw [rotate_eq_rotate', rotate_eq_rotate', rotate_eq_rotate', rotate'_rotate']
#align list.rotate_rotate List.rotate_rotate
@[simp]
theorem rotate_length (l : List α) : rotate l l.length = l := by
rw [rotate_eq_rotate', rotate'_length]
#align list.rotate_length List.rotate_length
@[simp]
theorem rotate_length_mul (l : List α) (n : ℕ) : l.rotate (l.length * n) = l := by
rw [rotate_eq_rotate', rotate'_length_mul]
#align list.rotate_length_mul List.rotate_length_mul
theorem rotate_perm (l : List α) (n : ℕ) : l.rotate n ~ l := by
rw [rotate_eq_rotate']
induction' n with n hn generalizing l
· simp
· cases' l with hd tl
· simp
· rw [rotate'_cons_succ]
exact (hn _).trans (perm_append_singleton _ _)
#align list.rotate_perm List.rotate_perm
@[simp]
theorem nodup_rotate {l : List α} {n : ℕ} : Nodup (l.rotate n) ↔ Nodup l :=
(rotate_perm l n).nodup_iff
#align list.nodup_rotate List.nodup_rotate
@[simp]
theorem rotate_eq_nil_iff {l : List α} {n : ℕ} : l.rotate n = [] ↔ l = [] := by
induction' n with n hn generalizing l
· simp
· cases' l with hd tl
· simp
· simp [rotate_cons_succ, hn]
#align list.rotate_eq_nil_iff List.rotate_eq_nil_iff
@[simp]
theorem nil_eq_rotate_iff {l : List α} {n : ℕ} : [] = l.rotate n ↔ [] = l := by
rw [eq_comm, rotate_eq_nil_iff, eq_comm]
#align list.nil_eq_rotate_iff List.nil_eq_rotate_iff
@[simp]
theorem rotate_singleton (x : α) (n : ℕ) : [x].rotate n = [x] :=
rotate_replicate x 1 n
#align list.rotate_singleton List.rotate_singleton
theorem zipWith_rotate_distrib {β γ : Type*} (f : α → β → γ) (l : List α) (l' : List β) (n : ℕ)
(h : l.length = l'.length) :
(zipWith f l l').rotate n = zipWith f (l.rotate n) (l'.rotate n) := by
rw [rotate_eq_drop_append_take_mod, rotate_eq_drop_append_take_mod,
rotate_eq_drop_append_take_mod, h, zipWith_append, ← zipWith_distrib_drop, ←
zipWith_distrib_take, List.length_zipWith, h, min_self]
rw [length_drop, length_drop, h]
#align list.zip_with_rotate_distrib List.zipWith_rotate_distrib
attribute [local simp] rotate_cons_succ
-- Porting note: removing @[simp], simp can prove it
theorem zipWith_rotate_one {β : Type*} (f : α → α → β) (x y : α) (l : List α) :
zipWith f (x :: y :: l) ((x :: y :: l).rotate 1) = f x y :: zipWith f (y :: l) (l ++ [x]) := by
simp
#align list.zip_with_rotate_one List.zipWith_rotate_one
theorem get?_rotate {l : List α} {n m : ℕ} (hml : m < l.length) :
(l.rotate n).get? m = l.get? ((m + n) % l.length) := by
rw [rotate_eq_drop_append_take_mod]
rcases lt_or_le m (l.drop (n % l.length)).length with hm | hm
· rw [get?_append hm, get?_drop, ← add_mod_mod]
rw [length_drop, Nat.lt_sub_iff_add_lt] at hm
rw [mod_eq_of_lt hm, Nat.add_comm]
· have hlt : n % length l < length l := mod_lt _ (m.zero_le.trans_lt hml)
rw [get?_append_right hm, get?_take, length_drop]
· congr 1
rw [length_drop] at hm
have hm' := Nat.sub_le_iff_le_add'.1 hm
have : n % length l + m - length l < length l := by
rw [Nat.sub_lt_iff_lt_add' hm']
exact Nat.add_lt_add hlt hml
conv_rhs => rw [Nat.add_comm m, ← mod_add_mod, mod_eq_sub_mod hm', mod_eq_of_lt this]
rw [← Nat.add_right_inj, ← Nat.add_sub_assoc, Nat.add_sub_sub_cancel, Nat.add_sub_cancel',
Nat.add_comm]
exacts [hm', hlt.le, hm]
· rwa [Nat.sub_lt_iff_lt_add hm, length_drop, Nat.sub_add_cancel hlt.le]
#align list.nth_rotate List.get?_rotate
-- Porting note (#10756): new lemma
theorem get_rotate (l : List α) (n : ℕ) (k : Fin (l.rotate n).length) :
(l.rotate n).get k =
l.get ⟨(k + n) % l.length, mod_lt _ (length_rotate l n ▸ k.1.zero_le.trans_lt k.2)⟩ := by
rw [← Option.some_inj, ← get?_eq_get, ← get?_eq_get, get?_rotate]
exact k.2.trans_eq (length_rotate _ _)
theorem head?_rotate {l : List α} {n : ℕ} (h : n < l.length) : head? (l.rotate n) = l.get? n := by
rw [← get?_zero, get?_rotate (n.zero_le.trans_lt h), Nat.zero_add, Nat.mod_eq_of_lt h]
#align list.head'_rotate List.head?_rotate
-- Porting note: moved down from its original location below `get_rotate` so that the
-- non-deprecated lemma does not use the deprecated version
set_option linter.deprecated false in
@[deprecated get_rotate (since := "2023-01-13")]
theorem nthLe_rotate (l : List α) (n k : ℕ) (hk : k < (l.rotate n).length) :
(l.rotate n).nthLe k hk =
l.nthLe ((k + n) % l.length) (mod_lt _ (length_rotate l n ▸ k.zero_le.trans_lt hk)) :=
get_rotate l n ⟨k, hk⟩
#align list.nth_le_rotate List.nthLe_rotate
set_option linter.deprecated false in
theorem nthLe_rotate_one (l : List α) (k : ℕ) (hk : k < (l.rotate 1).length) :
(l.rotate 1).nthLe k hk =
l.nthLe ((k + 1) % l.length) (mod_lt _ (length_rotate l 1 ▸ k.zero_le.trans_lt hk)) :=
nthLe_rotate l 1 k hk
#align list.nth_le_rotate_one List.nthLe_rotate_one
-- Porting note (#10756): new lemma
theorem get_eq_get_rotate (l : List α) (n : ℕ) (k : Fin l.length) :
l.get k = (l.rotate n).get ⟨(l.length - n % l.length + k) % l.length,
(Nat.mod_lt _ (k.1.zero_le.trans_lt k.2)).trans_eq (length_rotate _ _).symm⟩ := by
rw [get_rotate]
refine congr_arg l.get (Fin.eq_of_val_eq ?_)
simp only [mod_add_mod]
rw [← add_mod_mod, Nat.add_right_comm, Nat.sub_add_cancel, add_mod_left, mod_eq_of_lt]
exacts [k.2, (mod_lt _ (k.1.zero_le.trans_lt k.2)).le]
set_option linter.deprecated false in
@[deprecated get_eq_get_rotate]
theorem nthLe_rotate' (l : List α) (n k : ℕ) (hk : k < l.length) :
(l.rotate n).nthLe ((l.length - n % l.length + k) % l.length)
((Nat.mod_lt _ (k.zero_le.trans_lt hk)).trans_le (length_rotate _ _).ge) =
l.nthLe k hk :=
(get_eq_get_rotate l n ⟨k, hk⟩).symm
#align list.nth_le_rotate' List.nthLe_rotate'
theorem rotate_eq_self_iff_eq_replicate [hα : Nonempty α] :
∀ {l : List α}, (∀ n, l.rotate n = l) ↔ ∃ a, l = replicate l.length a
| [] => by simp
| a :: l => ⟨fun h => ⟨a, ext_get (length_replicate _ _).symm fun n h₁ h₂ => by
rw [get_replicate, ← Option.some_inj, ← get?_eq_get, ← head?_rotate h₁, h, head?_cons]⟩,
fun ⟨b, hb⟩ n => by rw [hb, rotate_replicate]⟩
#align list.rotate_eq_self_iff_eq_replicate List.rotate_eq_self_iff_eq_replicate
theorem rotate_one_eq_self_iff_eq_replicate [Nonempty α] {l : List α} :
l.rotate 1 = l ↔ ∃ a : α, l = List.replicate l.length a :=
⟨fun h =>
rotate_eq_self_iff_eq_replicate.mp fun n =>
Nat.rec l.rotate_zero (fun n hn => by rwa [Nat.succ_eq_add_one, ← l.rotate_rotate, hn]) n,
fun h => rotate_eq_self_iff_eq_replicate.mpr h 1⟩
#align list.rotate_one_eq_self_iff_eq_replicate List.rotate_one_eq_self_iff_eq_replicate
theorem rotate_injective (n : ℕ) : Function.Injective fun l : List α => l.rotate n := by
rintro l l' (h : l.rotate n = l'.rotate n)
have hle : l.length = l'.length := (l.length_rotate n).symm.trans (h.symm ▸ l'.length_rotate n)
rw [rotate_eq_drop_append_take_mod, rotate_eq_drop_append_take_mod] at h
obtain ⟨hd, ht⟩ := append_inj h (by simp_all)
rw [← take_append_drop _ l, ht, hd, take_append_drop]
#align list.rotate_injective List.rotate_injective
@[simp]
theorem rotate_eq_rotate {l l' : List α} {n : ℕ} : l.rotate n = l'.rotate n ↔ l = l' :=
(rotate_injective n).eq_iff
#align list.rotate_eq_rotate List.rotate_eq_rotate
theorem rotate_eq_iff {l l' : List α} {n : ℕ} :
l.rotate n = l' ↔ l = l'.rotate (l'.length - n % l'.length) := by
rw [← @rotate_eq_rotate _ l _ n, rotate_rotate, ← rotate_mod l', add_mod]
rcases l'.length.zero_le.eq_or_lt with hl | hl
· rw [eq_nil_of_length_eq_zero hl.symm, rotate_nil]
· rcases (Nat.zero_le (n % l'.length)).eq_or_lt with hn | hn
· simp [← hn]
· rw [mod_eq_of_lt (Nat.sub_lt hl hn), Nat.sub_add_cancel, mod_self, rotate_zero]
exact (Nat.mod_lt _ hl).le
#align list.rotate_eq_iff List.rotate_eq_iff
@[simp]
theorem rotate_eq_singleton_iff {l : List α} {n : ℕ} {x : α} : l.rotate n = [x] ↔ l = [x] := by
rw [rotate_eq_iff, rotate_singleton]
#align list.rotate_eq_singleton_iff List.rotate_eq_singleton_iff
@[simp]
theorem singleton_eq_rotate_iff {l : List α} {n : ℕ} {x : α} : [x] = l.rotate n ↔ [x] = l := by
rw [eq_comm, rotate_eq_singleton_iff, eq_comm]
#align list.singleton_eq_rotate_iff List.singleton_eq_rotate_iff
theorem reverse_rotate (l : List α) (n : ℕ) :
(l.rotate n).reverse = l.reverse.rotate (l.length - n % l.length) := by
rw [← length_reverse l, ← rotate_eq_iff]
induction' n with n hn generalizing l
· simp
· cases' l with hd tl
· simp
· rw [rotate_cons_succ, ← rotate_rotate, hn]
simp
#align list.reverse_rotate List.reverse_rotate
theorem rotate_reverse (l : List α) (n : ℕ) :
l.reverse.rotate n = (l.rotate (l.length - n % l.length)).reverse := by
rw [← reverse_reverse l]
simp_rw [reverse_rotate, reverse_reverse, rotate_eq_iff, rotate_rotate, length_rotate,
length_reverse]
rw [← length_reverse l]
let k := n % l.reverse.length
cases' hk' : k with k'
· simp_all! [k, length_reverse, ← rotate_rotate]
· cases' l with x l
· simp
· rw [Nat.mod_eq_of_lt, Nat.sub_add_cancel, rotate_length]
· exact Nat.sub_le _ _
· exact Nat.sub_lt (by simp) (by simp_all! [k])
#align list.rotate_reverse List.rotate_reverse
theorem map_rotate {β : Type*} (f : α → β) (l : List α) (n : ℕ) :
map f (l.rotate n) = (map f l).rotate n := by
induction' n with n hn IH generalizing l
· simp
· cases' l with hd tl
· simp
· simp [hn]
#align list.map_rotate List.map_rotate
theorem Nodup.rotate_congr {l : List α} (hl : l.Nodup) (hn : l ≠ []) (i j : ℕ)
(h : l.rotate i = l.rotate j) : i % l.length = j % l.length := by
rw [← rotate_mod l i, ← rotate_mod l j] at h
simpa only [head?_rotate, mod_lt, length_pos_of_ne_nil hn, get?_eq_get, Option.some_inj,
hl.get_inj_iff, Fin.ext_iff] using congr_arg head? h
#align list.nodup.rotate_congr List.Nodup.rotate_congr
theorem Nodup.rotate_congr_iff {l : List α} (hl : l.Nodup) {i j : ℕ} :
l.rotate i = l.rotate j ↔ i % l.length = j % l.length ∨ l = [] := by
rcases eq_or_ne l [] with rfl | hn
· simp
· simp only [hn, or_false]
refine ⟨hl.rotate_congr hn _ _, fun h ↦ ?_⟩
rw [← rotate_mod, h, rotate_mod]
theorem Nodup.rotate_eq_self_iff {l : List α} (hl : l.Nodup) {n : ℕ} :
l.rotate n = l ↔ n % l.length = 0 ∨ l = [] := by
rw [← zero_mod, ← hl.rotate_congr_iff, rotate_zero]
#align list.nodup.rotate_eq_self_iff List.Nodup.rotate_eq_self_iff
section IsRotated
variable (l l' : List α)
def IsRotated : Prop :=
∃ n, l.rotate n = l'
#align list.is_rotated List.IsRotated
@[inherit_doc List.IsRotated]
infixr:1000 " ~r " => IsRotated
variable {l l'}
@[refl]
theorem IsRotated.refl (l : List α) : l ~r l :=
⟨0, by simp⟩
#align list.is_rotated.refl List.IsRotated.refl
@[symm]
theorem IsRotated.symm (h : l ~r l') : l' ~r l := by
obtain ⟨n, rfl⟩ := h
cases' l with hd tl
· exists 0
· use (hd :: tl).length * n - n
rw [rotate_rotate, Nat.add_sub_cancel', rotate_length_mul]
exact Nat.le_mul_of_pos_left _ (by simp)
#align list.is_rotated.symm List.IsRotated.symm
theorem isRotated_comm : l ~r l' ↔ l' ~r l :=
⟨IsRotated.symm, IsRotated.symm⟩
#align list.is_rotated_comm List.isRotated_comm
@[simp]
protected theorem IsRotated.forall (l : List α) (n : ℕ) : l.rotate n ~r l :=
IsRotated.symm ⟨n, rfl⟩
#align list.is_rotated.forall List.IsRotated.forall
@[trans]
theorem IsRotated.trans : ∀ {l l' l'' : List α}, l ~r l' → l' ~r l'' → l ~r l''
| _, _, _, ⟨n, rfl⟩, ⟨m, rfl⟩ => ⟨n + m, by rw [rotate_rotate]⟩
#align list.is_rotated.trans List.IsRotated.trans
theorem IsRotated.eqv : Equivalence (@IsRotated α) :=
Equivalence.mk IsRotated.refl IsRotated.symm IsRotated.trans
#align list.is_rotated.eqv List.IsRotated.eqv
def IsRotated.setoid (α : Type*) : Setoid (List α) where
r := IsRotated
iseqv := IsRotated.eqv
#align list.is_rotated.setoid List.IsRotated.setoid
theorem IsRotated.perm (h : l ~r l') : l ~ l' :=
Exists.elim h fun _ hl => hl ▸ (rotate_perm _ _).symm
#align list.is_rotated.perm List.IsRotated.perm
theorem IsRotated.nodup_iff (h : l ~r l') : Nodup l ↔ Nodup l' :=
h.perm.nodup_iff
#align list.is_rotated.nodup_iff List.IsRotated.nodup_iff
theorem IsRotated.mem_iff (h : l ~r l') {a : α} : a ∈ l ↔ a ∈ l' :=
h.perm.mem_iff
#align list.is_rotated.mem_iff List.IsRotated.mem_iff
@[simp]
theorem isRotated_nil_iff : l ~r [] ↔ l = [] :=
⟨fun ⟨n, hn⟩ => by simpa using hn, fun h => h ▸ by rfl⟩
#align list.is_rotated_nil_iff List.isRotated_nil_iff
@[simp]
| Mathlib/Data/List/Rotate.lean | 478 | 479 | theorem isRotated_nil_iff' : [] ~r l ↔ [] = l := by |
rw [isRotated_comm, isRotated_nil_iff, eq_comm]
|
import Mathlib.Data.ENNReal.Operations
#align_import data.real.ennreal from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"
open Set NNReal
namespace ENNReal
noncomputable section Inv
variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0}
protected theorem div_eq_inv_mul : a / b = b⁻¹ * a := by rw [div_eq_mul_inv, mul_comm]
#align ennreal.div_eq_inv_mul ENNReal.div_eq_inv_mul
@[simp] theorem inv_zero : (0 : ℝ≥0∞)⁻¹ = ∞ :=
show sInf { b : ℝ≥0∞ | 1 ≤ 0 * b } = ∞ by simp
#align ennreal.inv_zero ENNReal.inv_zero
@[simp] theorem inv_top : ∞⁻¹ = 0 :=
bot_unique <| le_of_forall_le_of_dense fun a (h : 0 < a) => sInf_le <| by simp [*, h.ne', top_mul]
#align ennreal.inv_top ENNReal.inv_top
theorem coe_inv_le : (↑r⁻¹ : ℝ≥0∞) ≤ (↑r)⁻¹ :=
le_sInf fun b (hb : 1 ≤ ↑r * b) =>
coe_le_iff.2 <| by
rintro b rfl
apply NNReal.inv_le_of_le_mul
rwa [← coe_mul, ← coe_one, coe_le_coe] at hb
#align ennreal.coe_inv_le ENNReal.coe_inv_le
@[simp, norm_cast]
theorem coe_inv (hr : r ≠ 0) : (↑r⁻¹ : ℝ≥0∞) = (↑r)⁻¹ :=
coe_inv_le.antisymm <| sInf_le <| mem_setOf.2 <| by rw [← coe_mul, mul_inv_cancel hr, coe_one]
#align ennreal.coe_inv ENNReal.coe_inv
@[norm_cast]
theorem coe_inv_two : ((2⁻¹ : ℝ≥0) : ℝ≥0∞) = 2⁻¹ := by rw [coe_inv _root_.two_ne_zero, coe_two]
#align ennreal.coe_inv_two ENNReal.coe_inv_two
@[simp, norm_cast]
| Mathlib/Data/ENNReal/Inv.lean | 72 | 73 | theorem coe_div (hr : r ≠ 0) : (↑(p / r) : ℝ≥0∞) = p / r := by |
rw [div_eq_mul_inv, div_eq_mul_inv, coe_mul, coe_inv hr]
|
import Mathlib.Algebra.CharP.Pi
import Mathlib.Algebra.CharP.Quotient
import Mathlib.Algebra.CharP.Subring
import Mathlib.Algebra.Ring.Pi
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
import Mathlib.FieldTheory.Perfect
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.Algebra.Ring.Subring.Basic
import Mathlib.RingTheory.Valuation.Integers
#align_import ring_theory.perfection from "leanprover-community/mathlib"@"0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8"
universe u₁ u₂ u₃ u₄
open scoped NNReal
def Monoid.perfection (M : Type u₁) [CommMonoid M] (p : ℕ) : Submonoid (ℕ → M) where
carrier := { f | ∀ n, f (n + 1) ^ p = f n }
one_mem' _ := one_pow _
mul_mem' hf hg n := (mul_pow _ _ _).trans <| congr_arg₂ _ (hf n) (hg n)
#align monoid.perfection Monoid.perfection
def Ring.perfectionSubsemiring (R : Type u₁) [CommSemiring R] (p : ℕ) [hp : Fact p.Prime]
[CharP R p] : Subsemiring (ℕ → R) :=
{ Monoid.perfection R p with
zero_mem' := fun _ ↦ zero_pow hp.1.ne_zero
add_mem' := fun hf hg n => (frobenius_add R p _ _).trans <| congr_arg₂ _ (hf n) (hg n) }
#align ring.perfection_subsemiring Ring.perfectionSubsemiring
def Ring.perfectionSubring (R : Type u₁) [CommRing R] (p : ℕ) [hp : Fact p.Prime] [CharP R p] :
Subring (ℕ → R) :=
(Ring.perfectionSubsemiring R p).toSubring fun n => by
simp_rw [← frobenius_def, Pi.neg_apply, Pi.one_apply, RingHom.map_neg, RingHom.map_one]
#align ring.perfection_subring Ring.perfectionSubring
def Ring.Perfection (R : Type u₁) [CommSemiring R] (p : ℕ) : Type u₁ :=
{ f // ∀ n : ℕ, (f : ℕ → R) (n + 1) ^ p = f n }
#align ring.perfection Ring.Perfection
namespace Perfection
variable (R : Type u₁) [CommSemiring R] (p : ℕ) [hp : Fact p.Prime] [CharP R p]
instance commSemiring : CommSemiring (Ring.Perfection R p) :=
(Ring.perfectionSubsemiring R p).toCommSemiring
#align perfection.ring.perfection.comm_semiring Perfection.commSemiring
instance charP : CharP (Ring.Perfection R p) p :=
CharP.subsemiring (ℕ → R) p (Ring.perfectionSubsemiring R p)
#align perfection.char_p Perfection.charP
instance ring (R : Type u₁) [CommRing R] [CharP R p] : Ring (Ring.Perfection R p) :=
(Ring.perfectionSubring R p).toRing
#align perfection.ring Perfection.ring
instance commRing (R : Type u₁) [CommRing R] [CharP R p] : CommRing (Ring.Perfection R p) :=
(Ring.perfectionSubring R p).toCommRing
#align perfection.comm_ring Perfection.commRing
instance : Inhabited (Ring.Perfection R p) := ⟨0⟩
def coeff (n : ℕ) : Ring.Perfection R p →+* R where
toFun f := f.1 n
map_one' := rfl
map_mul' _ _ := rfl
map_zero' := rfl
map_add' _ _ := rfl
#align perfection.coeff Perfection.coeff
variable {R p}
@[ext]
theorem ext {f g : Ring.Perfection R p} (h : ∀ n, coeff R p n f = coeff R p n g) : f = g :=
Subtype.eq <| funext h
#align perfection.ext Perfection.ext
variable (R p)
def pthRoot : Ring.Perfection R p →+* Ring.Perfection R p where
toFun f := ⟨fun n => coeff R p (n + 1) f, fun _ => f.2 _⟩
map_one' := rfl
map_mul' _ _ := rfl
map_zero' := rfl
map_add' _ _ := rfl
#align perfection.pth_root Perfection.pthRoot
variable {R p}
@[simp]
theorem coeff_mk (f : ℕ → R) (hf) (n : ℕ) : coeff R p n ⟨f, hf⟩ = f n := rfl
#align perfection.coeff_mk Perfection.coeff_mk
theorem coeff_pthRoot (f : Ring.Perfection R p) (n : ℕ) :
coeff R p n (pthRoot R p f) = coeff R p (n + 1) f := rfl
#align perfection.coeff_pth_root Perfection.coeff_pthRoot
theorem coeff_pow_p (f : Ring.Perfection R p) (n : ℕ) :
coeff R p (n + 1) (f ^ p) = coeff R p n f := by rw [RingHom.map_pow]; exact f.2 n
#align perfection.coeff_pow_p Perfection.coeff_pow_p
theorem coeff_pow_p' (f : Ring.Perfection R p) (n : ℕ) : coeff R p (n + 1) f ^ p = coeff R p n f :=
f.2 n
#align perfection.coeff_pow_p' Perfection.coeff_pow_p'
| Mathlib/RingTheory/Perfection.lean | 137 | 138 | theorem coeff_frobenius (f : Ring.Perfection R p) (n : ℕ) :
coeff R p (n + 1) (frobenius _ p f) = coeff R p n f := by | apply coeff_pow_p f n
|
import Mathlib.Algebra.BigOperators.Intervals
import Mathlib.Algebra.BigOperators.Ring.List
import Mathlib.Data.Int.ModEq
import Mathlib.Data.Nat.Bits
import Mathlib.Data.Nat.Log
import Mathlib.Data.List.Indexes
import Mathlib.Data.List.Palindrome
import Mathlib.Tactic.IntervalCases
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring
#align_import data.nat.digits from "leanprover-community/mathlib"@"369525b73f229ccd76a6ec0e0e0bf2be57599768"
namespace Nat
variable {n : ℕ}
def digitsAux0 : ℕ → List ℕ
| 0 => []
| n + 1 => [n + 1]
#align nat.digits_aux_0 Nat.digitsAux0
def digitsAux1 (n : ℕ) : List ℕ :=
List.replicate n 1
#align nat.digits_aux_1 Nat.digitsAux1
def digitsAux (b : ℕ) (h : 2 ≤ b) : ℕ → List ℕ
| 0 => []
| n + 1 =>
((n + 1) % b) :: digitsAux b h ((n + 1) / b)
decreasing_by exact Nat.div_lt_self (Nat.succ_pos _) h
#align nat.digits_aux Nat.digitsAux
@[simp]
theorem digitsAux_zero (b : ℕ) (h : 2 ≤ b) : digitsAux b h 0 = [] := by rw [digitsAux]
#align nat.digits_aux_zero Nat.digitsAux_zero
theorem digitsAux_def (b : ℕ) (h : 2 ≤ b) (n : ℕ) (w : 0 < n) :
digitsAux b h n = (n % b) :: digitsAux b h (n / b) := by
cases n
· cases w
· rw [digitsAux]
#align nat.digits_aux_def Nat.digitsAux_def
def digits : ℕ → ℕ → List ℕ
| 0 => digitsAux0
| 1 => digitsAux1
| b + 2 => digitsAux (b + 2) (by norm_num)
#align nat.digits Nat.digits
@[simp]
theorem digits_zero (b : ℕ) : digits b 0 = [] := by
rcases b with (_ | ⟨_ | ⟨_⟩⟩) <;> simp [digits, digitsAux0, digitsAux1]
#align nat.digits_zero Nat.digits_zero
-- @[simp] -- Porting note (#10618): simp can prove this
theorem digits_zero_zero : digits 0 0 = [] :=
rfl
#align nat.digits_zero_zero Nat.digits_zero_zero
@[simp]
theorem digits_zero_succ (n : ℕ) : digits 0 n.succ = [n + 1] :=
rfl
#align nat.digits_zero_succ Nat.digits_zero_succ
theorem digits_zero_succ' : ∀ {n : ℕ}, n ≠ 0 → digits 0 n = [n]
| 0, h => (h rfl).elim
| _ + 1, _ => rfl
#align nat.digits_zero_succ' Nat.digits_zero_succ'
@[simp]
theorem digits_one (n : ℕ) : digits 1 n = List.replicate n 1 :=
rfl
#align nat.digits_one Nat.digits_one
-- @[simp] -- Porting note (#10685): dsimp can prove this
theorem digits_one_succ (n : ℕ) : digits 1 (n + 1) = 1 :: digits 1 n :=
rfl
#align nat.digits_one_succ Nat.digits_one_succ
theorem digits_add_two_add_one (b n : ℕ) :
digits (b + 2) (n + 1) = ((n + 1) % (b + 2)) :: digits (b + 2) ((n + 1) / (b + 2)) := by
simp [digits, digitsAux_def]
#align nat.digits_add_two_add_one Nat.digits_add_two_add_one
@[simp]
lemma digits_of_two_le_of_pos {b : ℕ} (hb : 2 ≤ b) (hn : 0 < n) :
Nat.digits b n = n % b :: Nat.digits b (n / b) := by
rw [Nat.eq_add_of_sub_eq hb rfl, Nat.eq_add_of_sub_eq hn rfl, Nat.digits_add_two_add_one]
theorem digits_def' :
∀ {b : ℕ} (_ : 1 < b) {n : ℕ} (_ : 0 < n), digits b n = (n % b) :: digits b (n / b)
| 0, h => absurd h (by decide)
| 1, h => absurd h (by decide)
| b + 2, _ => digitsAux_def _ (by simp) _
#align nat.digits_def' Nat.digits_def'
@[simp]
theorem digits_of_lt (b x : ℕ) (hx : x ≠ 0) (hxb : x < b) : digits b x = [x] := by
rcases exists_eq_succ_of_ne_zero hx with ⟨x, rfl⟩
rcases Nat.exists_eq_add_of_le' ((Nat.le_add_left 1 x).trans_lt hxb) with ⟨b, rfl⟩
rw [digits_add_two_add_one, div_eq_of_lt hxb, digits_zero, mod_eq_of_lt hxb]
#align nat.digits_of_lt Nat.digits_of_lt
theorem digits_add (b : ℕ) (h : 1 < b) (x y : ℕ) (hxb : x < b) (hxy : x ≠ 0 ∨ y ≠ 0) :
digits b (x + b * y) = x :: digits b y := by
rcases Nat.exists_eq_add_of_le' h with ⟨b, rfl : _ = _ + 2⟩
cases y
· simp [hxb, hxy.resolve_right (absurd rfl)]
dsimp [digits]
rw [digitsAux_def]
· congr
· simp [Nat.add_mod, mod_eq_of_lt hxb]
· simp [add_mul_div_left, div_eq_of_lt hxb]
· apply Nat.succ_pos
#align nat.digits_add Nat.digits_add
-- If we had a function converting a list into a polynomial,
-- and appropriate lemmas about that function,
-- we could rewrite this in terms of that.
def ofDigits {α : Type*} [Semiring α] (b : α) : List ℕ → α
| [] => 0
| h :: t => h + b * ofDigits b t
#align nat.of_digits Nat.ofDigits
theorem ofDigits_eq_foldr {α : Type*} [Semiring α] (b : α) (L : List ℕ) :
ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L := by
induction' L with d L ih
· rfl
· dsimp [ofDigits]
rw [ih]
#align nat.of_digits_eq_foldr Nat.ofDigits_eq_foldr
theorem ofDigits_eq_sum_map_with_index_aux (b : ℕ) (l : List ℕ) :
((List.range l.length).zipWith ((fun i a : ℕ => a * b ^ (i + 1))) l).sum =
b * ((List.range l.length).zipWith (fun i a => a * b ^ i) l).sum := by
suffices
(List.range l.length).zipWith (fun i a : ℕ => a * b ^ (i + 1)) l =
(List.range l.length).zipWith (fun i a => b * (a * b ^ i)) l
by simp [this]
congr; ext; simp [pow_succ]; ring
#align nat.of_digits_eq_sum_map_with_index_aux Nat.ofDigits_eq_sum_map_with_index_aux
theorem ofDigits_eq_sum_mapIdx (b : ℕ) (L : List ℕ) :
ofDigits b L = (L.mapIdx fun i a => a * b ^ i).sum := by
rw [List.mapIdx_eq_enum_map, List.enum_eq_zip_range, List.map_uncurry_zip_eq_zipWith,
ofDigits_eq_foldr]
induction' L with hd tl hl
· simp
· simpa [List.range_succ_eq_map, List.zipWith_map_left, ofDigits_eq_sum_map_with_index_aux] using
Or.inl hl
#align nat.of_digits_eq_sum_map_with_index Nat.ofDigits_eq_sum_mapIdx
@[simp]
theorem ofDigits_nil {b : ℕ} : ofDigits b [] = 0 := rfl
@[simp]
theorem ofDigits_singleton {b n : ℕ} : ofDigits b [n] = n := by simp [ofDigits]
#align nat.of_digits_singleton Nat.ofDigits_singleton
@[simp]
theorem ofDigits_one_cons {α : Type*} [Semiring α] (h : ℕ) (L : List ℕ) :
ofDigits (1 : α) (h :: L) = h + ofDigits 1 L := by simp [ofDigits]
#align nat.of_digits_one_cons Nat.ofDigits_one_cons
theorem ofDigits_cons {b hd} {tl : List ℕ} :
ofDigits b (hd :: tl) = hd + b * ofDigits b tl := rfl
theorem ofDigits_append {b : ℕ} {l1 l2 : List ℕ} :
ofDigits b (l1 ++ l2) = ofDigits b l1 + b ^ l1.length * ofDigits b l2 := by
induction' l1 with hd tl IH
· simp [ofDigits]
· rw [ofDigits, List.cons_append, ofDigits, IH, List.length_cons, pow_succ']
ring
#align nat.of_digits_append Nat.ofDigits_append
@[norm_cast]
theorem coe_ofDigits (α : Type*) [Semiring α] (b : ℕ) (L : List ℕ) :
((ofDigits b L : ℕ) : α) = ofDigits (b : α) L := by
induction' L with d L ih
· simp [ofDigits]
· dsimp [ofDigits]; push_cast; rw [ih]
#align nat.coe_of_digits Nat.coe_ofDigits
@[norm_cast]
theorem coe_int_ofDigits (b : ℕ) (L : List ℕ) : ((ofDigits b L : ℕ) : ℤ) = ofDigits (b : ℤ) L := by
induction' L with d L _
· rfl
· dsimp [ofDigits]; push_cast; simp only
#align nat.coe_int_of_digits Nat.coe_int_ofDigits
theorem digits_zero_of_eq_zero {b : ℕ} (h : b ≠ 0) :
∀ {L : List ℕ} (_ : ofDigits b L = 0), ∀ l ∈ L, l = 0
| _ :: _, h0, _, List.Mem.head .. => Nat.eq_zero_of_add_eq_zero_right h0
| _ :: _, h0, _, List.Mem.tail _ hL =>
digits_zero_of_eq_zero h (mul_right_injective₀ h (Nat.eq_zero_of_add_eq_zero_left h0)) _ hL
#align nat.digits_zero_of_eq_zero Nat.digits_zero_of_eq_zero
| Mathlib/Data/Nat/Digits.lean | 240 | 264 | theorem digits_ofDigits (b : ℕ) (h : 1 < b) (L : List ℕ) (w₁ : ∀ l ∈ L, l < b)
(w₂ : ∀ h : L ≠ [], L.getLast h ≠ 0) : digits b (ofDigits b L) = L := by |
induction' L with d L ih
· dsimp [ofDigits]
simp
· dsimp [ofDigits]
replace w₂ := w₂ (by simp)
rw [digits_add b h]
· rw [ih]
· intro l m
apply w₁
exact List.mem_cons_of_mem _ m
· intro h
rw [List.getLast_cons h] at w₂
convert w₂
· exact w₁ d (List.mem_cons_self _ _)
· by_cases h' : L = []
· rcases h' with rfl
left
simpa using w₂
· right
contrapose! w₂
refine digits_zero_of_eq_zero h.ne_bot w₂ _ ?_
rw [List.getLast_cons h']
exact List.getLast_mem h'
|
import Mathlib.Topology.ContinuousFunction.Basic
#align_import topology.compact_open from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514"
open Set Filter TopologicalSpace
open scoped Topology
namespace ContinuousMap
section CompactOpen
variable {α X Y Z T : Type*}
variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] [TopologicalSpace T]
variable {K : Set X} {U : Set Y}
#noalign continuous_map.compact_open.gen
#noalign continuous_map.gen_empty
#noalign continuous_map.gen_univ
#noalign continuous_map.gen_inter
#noalign continuous_map.gen_union
#noalign continuous_map.gen_empty_right
instance compactOpen : TopologicalSpace C(X, Y) :=
.generateFrom <| image2 (fun K U ↦ {f | MapsTo f K U}) {K | IsCompact K} {U | IsOpen U}
#align continuous_map.compact_open ContinuousMap.compactOpen
theorem compactOpen_eq : @compactOpen X Y _ _ =
.generateFrom (image2 (fun K U ↦ {f | MapsTo f K U}) {K | IsCompact K} {t | IsOpen t}) :=
rfl
theorem isOpen_setOf_mapsTo (hK : IsCompact K) (hU : IsOpen U) :
IsOpen {f : C(X, Y) | MapsTo f K U} :=
isOpen_generateFrom_of_mem <| mem_image2_of_mem hK hU
#align continuous_map.is_open_gen ContinuousMap.isOpen_setOf_mapsTo
lemma eventually_mapsTo {f : C(X, Y)} (hK : IsCompact K) (hU : IsOpen U) (h : MapsTo f K U) :
∀ᶠ g : C(X, Y) in 𝓝 f, MapsTo g K U :=
(isOpen_setOf_mapsTo hK hU).mem_nhds h
lemma nhds_compactOpen (f : C(X, Y)) :
𝓝 f = ⨅ (K : Set X) (_ : IsCompact K) (U : Set Y) (_ : IsOpen U) (_ : MapsTo f K U),
𝓟 {g : C(X, Y) | MapsTo g K U} := by
simp_rw [compactOpen_eq, nhds_generateFrom, mem_setOf_eq, @and_comm (f ∈ _), iInf_and,
← image_prod, iInf_image, biInf_prod, mem_setOf_eq]
lemma tendsto_nhds_compactOpen {l : Filter α} {f : α → C(Y, Z)} {g : C(Y, Z)} :
Tendsto f l (𝓝 g) ↔
∀ K, IsCompact K → ∀ U, IsOpen U → MapsTo g K U → ∀ᶠ a in l, MapsTo (f a) K U := by
simp [nhds_compactOpen]
lemma continuous_compactOpen {f : X → C(Y, Z)} :
Continuous f ↔ ∀ K, IsCompact K → ∀ U, IsOpen U → IsOpen {x | MapsTo (f x) K U} :=
continuous_generateFrom_iff.trans forall_image2_iff
section Ev
@[continuity]
| Mathlib/Topology/CompactOpen.lean | 178 | 182 | theorem continuous_eval [LocallyCompactPair X Y] : Continuous fun p : C(X, Y) × X => p.1 p.2 := by |
simp_rw [continuous_iff_continuousAt, ContinuousAt, (nhds_basis_opens _).tendsto_right_iff]
rintro ⟨f, x⟩ U ⟨hx : f x ∈ U, hU : IsOpen U⟩
rcases exists_mem_nhds_isCompact_mapsTo f.continuous (hU.mem_nhds hx) with ⟨K, hxK, hK, hKU⟩
filter_upwards [prod_mem_nhds (eventually_mapsTo hK hU hKU) hxK] using fun _ h ↦ h.1 h.2
|
import Mathlib.Analysis.SpecialFunctions.Log.Base
import Mathlib.MeasureTheory.Measure.MeasureSpaceDef
#align_import measure_theory.measure.doubling from "leanprover-community/mathlib"@"5f6e827d81dfbeb6151d7016586ceeb0099b9655"
noncomputable section
open Set Filter Metric MeasureTheory TopologicalSpace ENNReal NNReal Topology
class IsUnifLocDoublingMeasure {α : Type*} [MetricSpace α] [MeasurableSpace α]
(μ : Measure α) : Prop where
exists_measure_closedBall_le_mul'' :
∃ C : ℝ≥0, ∀ᶠ ε in 𝓝[>] 0, ∀ x, μ (closedBall x (2 * ε)) ≤ C * μ (closedBall x ε)
#align is_unif_loc_doubling_measure IsUnifLocDoublingMeasure
namespace IsUnifLocDoublingMeasure
variable {α : Type*} [MetricSpace α] [MeasurableSpace α] (μ : Measure α)
[IsUnifLocDoublingMeasure μ]
-- Porting note: added for missing infer kinds
theorem exists_measure_closedBall_le_mul :
∃ C : ℝ≥0, ∀ᶠ ε in 𝓝[>] 0, ∀ x, μ (closedBall x (2 * ε)) ≤ C * μ (closedBall x ε) :=
exists_measure_closedBall_le_mul''
def doublingConstant : ℝ≥0 :=
Classical.choose <| exists_measure_closedBall_le_mul μ
#align is_unif_loc_doubling_measure.doubling_constant IsUnifLocDoublingMeasure.doublingConstant
theorem exists_measure_closedBall_le_mul' :
∀ᶠ ε in 𝓝[>] 0, ∀ x, μ (closedBall x (2 * ε)) ≤ doublingConstant μ * μ (closedBall x ε) :=
Classical.choose_spec <| exists_measure_closedBall_le_mul μ
#align is_unif_loc_doubling_measure.exists_measure_closed_ball_le_mul' IsUnifLocDoublingMeasure.exists_measure_closedBall_le_mul'
| Mathlib/MeasureTheory/Measure/Doubling.lean | 69 | 99 | theorem exists_eventually_forall_measure_closedBall_le_mul (K : ℝ) :
∃ C : ℝ≥0, ∀ᶠ ε in 𝓝[>] 0, ∀ x, ∀ t ≤ K, μ (closedBall x (t * ε)) ≤ C * μ (closedBall x ε) := by |
let C := doublingConstant μ
have hμ :
∀ n : ℕ, ∀ᶠ ε in 𝓝[>] 0, ∀ x,
μ (closedBall x ((2 : ℝ) ^ n * ε)) ≤ ↑(C ^ n) * μ (closedBall x ε) := by
intro n
induction' n with n ih
· simp
replace ih := eventually_nhdsWithin_pos_mul_left (two_pos : 0 < (2 : ℝ)) ih
refine (ih.and (exists_measure_closedBall_le_mul' μ)).mono fun ε hε x => ?_
calc
μ (closedBall x ((2 : ℝ) ^ (n + 1) * ε)) = μ (closedBall x ((2 : ℝ) ^ n * (2 * ε))) := by
rw [pow_succ, mul_assoc]
_ ≤ ↑(C ^ n) * μ (closedBall x (2 * ε)) := hε.1 x
_ ≤ ↑(C ^ n) * (C * μ (closedBall x ε)) := by gcongr; exact hε.2 x
_ = ↑(C ^ (n + 1)) * μ (closedBall x ε) := by rw [← mul_assoc, pow_succ, ENNReal.coe_mul]
rcases lt_or_le K 1 with (hK | hK)
· refine ⟨1, ?_⟩
simp only [ENNReal.coe_one, one_mul]
refine eventually_mem_nhdsWithin.mono fun ε hε x t ht ↦ ?_
gcongr
nlinarith [mem_Ioi.mp hε]
· use C ^ ⌈Real.logb 2 K⌉₊
filter_upwards [hμ ⌈Real.logb 2 K⌉₊, eventually_mem_nhdsWithin] with ε hε hε₀ x t ht
refine le_trans ?_ (hε x)
gcongr
· exact (mem_Ioi.mp hε₀).le
· refine ht.trans ?_
rw [← Real.rpow_natCast, ← Real.logb_le_iff_le_rpow]
exacts [Nat.le_ceil _, by norm_num, by linarith]
|
import Mathlib.MeasureTheory.Measure.Lebesgue.Basic
import Mathlib.NumberTheory.Liouville.Residual
import Mathlib.NumberTheory.Liouville.LiouvilleWith
import Mathlib.Analysis.PSeries
#align_import number_theory.liouville.measure from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
open scoped Filter ENNReal Topology NNReal
open Filter Set Metric MeasureTheory Real
theorem setOf_liouvilleWith_subset_aux :
{ x : ℝ | ∃ p > 2, LiouvilleWith p x } ⊆
⋃ m : ℤ, (· + (m : ℝ)) ⁻¹' ⋃ n > (0 : ℕ),
{ x : ℝ | ∃ᶠ b : ℕ in atTop, ∃ a ∈ Finset.Icc (0 : ℤ) b,
|x - (a : ℤ) / b| < 1 / (b : ℝ) ^ (2 + 1 / n : ℝ) } := by
rintro x ⟨p, hp, hxp⟩
rcases exists_nat_one_div_lt (sub_pos.2 hp) with ⟨n, hn⟩
rw [lt_sub_iff_add_lt'] at hn
suffices ∀ y : ℝ, LiouvilleWith p y → y ∈ Ico (0 : ℝ) 1 → ∃ᶠ b : ℕ in atTop,
∃ a ∈ Finset.Icc (0 : ℤ) b, |y - a / b| < 1 / (b : ℝ) ^ (2 + 1 / (n + 1 : ℕ) : ℝ) by
simp only [mem_iUnion, mem_preimage]
have hx : x + ↑(-⌊x⌋) ∈ Ico (0 : ℝ) 1 := by
simp only [Int.floor_le, Int.lt_floor_add_one, add_neg_lt_iff_le_add', zero_add, and_self_iff,
mem_Ico, Int.cast_neg, le_add_neg_iff_add_le]
exact ⟨-⌊x⌋, n + 1, n.succ_pos, this _ (hxp.add_int _) hx⟩
clear hxp x; intro x hxp hx01
refine ((hxp.frequently_lt_rpow_neg hn).and_eventually (eventually_ge_atTop 1)).mono ?_
rintro b ⟨⟨a, -, hlt⟩, hb⟩
rw [rpow_neg b.cast_nonneg, ← one_div, ← Nat.cast_succ] at hlt
refine ⟨a, ?_, hlt⟩
replace hb : (1 : ℝ) ≤ b := Nat.one_le_cast.2 hb
have hb0 : (0 : ℝ) < b := zero_lt_one.trans_le hb
replace hlt : |x - a / b| < 1 / b := by
refine hlt.trans_le (one_div_le_one_div_of_le hb0 ?_)
calc
(b : ℝ) = (b : ℝ) ^ (1 : ℝ) := (rpow_one _).symm
_ ≤ (b : ℝ) ^ (2 + 1 / (n + 1 : ℕ) : ℝ) :=
rpow_le_rpow_of_exponent_le hb (one_le_two.trans ?_)
simpa using n.cast_add_one_pos.le
rw [sub_div' _ _ _ hb0.ne', abs_div, abs_of_pos hb0, div_lt_div_right hb0, abs_sub_lt_iff,
sub_lt_iff_lt_add, sub_lt_iff_lt_add, ← sub_lt_iff_lt_add'] at hlt
rw [Finset.mem_Icc, ← Int.lt_add_one_iff, ← Int.lt_add_one_iff, ← neg_lt_iff_pos_add, add_comm, ←
@Int.cast_lt ℝ, ← @Int.cast_lt ℝ]
push_cast
refine ⟨lt_of_le_of_lt ?_ hlt.1, hlt.2.trans_le ?_⟩
· simp only [mul_nonneg hx01.left b.cast_nonneg, neg_le_sub_iff_le_add, le_add_iff_nonneg_left]
· rw [add_le_add_iff_left]
exact mul_le_of_le_one_left hb0.le hx01.2.le
#align set_of_liouville_with_subset_aux setOf_liouvilleWith_subset_aux
@[simp]
theorem volume_iUnion_setOf_liouvilleWith :
volume (⋃ (p : ℝ) (_hp : 2 < p), { x : ℝ | LiouvilleWith p x }) = 0 := by
simp only [← setOf_exists, exists_prop]
refine measure_mono_null setOf_liouvilleWith_subset_aux ?_
rw [measure_iUnion_null_iff]; intro m; rw [measure_preimage_add_right]; clear m
refine (measure_biUnion_null_iff <| to_countable _).2 fun n (hn : 1 ≤ n) => ?_
generalize hr : (2 + 1 / n : ℝ) = r
replace hr : 2 < r := by simp [← hr, zero_lt_one.trans_le hn]
clear hn n
refine measure_setOf_frequently_eq_zero ?_
simp only [setOf_exists, ← exists_prop, ← Real.dist_eq, ← mem_ball, setOf_mem_eq]
set B : ℤ → ℕ → Set ℝ := fun a b => ball (a / b) (1 / (b : ℝ) ^ r)
have hB : ∀ a b, volume (B a b) = ↑((2 : ℝ≥0) / (b : ℝ≥0) ^ r) := fun a b ↦ by
rw [Real.volume_ball, mul_one_div, ← NNReal.coe_two, ← NNReal.coe_natCast, ← NNReal.coe_rpow,
← NNReal.coe_div, ENNReal.ofReal_coe_nnreal]
have : ∀ b : ℕ, volume (⋃ a ∈ Finset.Icc (0 : ℤ) b, B a b) ≤
↑(2 * ((b : ℝ≥0) ^ (1 - r) + (b : ℝ≥0) ^ (-r))) := fun b ↦
calc
volume (⋃ a ∈ Finset.Icc (0 : ℤ) b, B a b) ≤ ∑ a ∈ Finset.Icc (0 : ℤ) b, volume (B a b) :=
measure_biUnion_finset_le _ _
_ = ↑((b + 1) * (2 / (b : ℝ≥0) ^ r)) := by
simp only [hB, Int.card_Icc, Finset.sum_const, nsmul_eq_mul, sub_zero, ← Int.ofNat_succ,
Int.toNat_natCast, ← Nat.cast_succ, ENNReal.coe_mul, ENNReal.coe_natCast]
_ = _ := by
have : 1 - r ≠ 0 := by linarith
rw [ENNReal.coe_inj]
simp [add_mul, div_eq_mul_inv, NNReal.rpow_neg, NNReal.rpow_sub' _ this, mul_add,
mul_left_comm]
refine ne_top_of_le_ne_top (ENNReal.tsum_coe_ne_top_iff_summable.2 ?_) (ENNReal.tsum_le_tsum this)
refine (Summable.add ?_ ?_).mul_left _ <;> simp only [NNReal.summable_rpow] <;> linarith
#align volume_Union_set_of_liouville_with volume_iUnion_setOf_liouvilleWith
theorem ae_not_liouvilleWith : ∀ᵐ x, ∀ p > (2 : ℝ), ¬LiouvilleWith p x := by
simpa only [ae_iff, not_forall, Classical.not_not, setOf_exists] using
volume_iUnion_setOf_liouvilleWith
#align ae_not_liouville_with ae_not_liouvilleWith
theorem ae_not_liouville : ∀ᵐ x, ¬Liouville x :=
ae_not_liouvilleWith.mono fun x h₁ h₂ => h₁ 3 (by norm_num) (h₂.liouvilleWith 3)
#align ae_not_liouville ae_not_liouville
@[simp]
| Mathlib/NumberTheory/Liouville/Measure.lean | 120 | 121 | theorem volume_setOf_liouville : volume { x : ℝ | Liouville x } = 0 := by |
simpa only [ae_iff, Classical.not_not] using ae_not_liouville
|
import Mathlib.Data.Fintype.List
#align_import data.list.cycle from "leanprover-community/mathlib"@"7413128c3bcb3b0818e3e18720abc9ea3100fb49"
assert_not_exists MonoidWithZero
open List
def Cycle (α : Type*) : Type _ :=
Quotient (IsRotated.setoid α)
#align cycle Cycle
namespace Cycle
variable {α : Type*}
-- Porting note (#11445): new definition
@[coe] def ofList : List α → Cycle α :=
Quot.mk _
instance : Coe (List α) (Cycle α) :=
⟨ofList⟩
@[simp]
theorem coe_eq_coe {l₁ l₂ : List α} : (l₁ : Cycle α) = (l₂ : Cycle α) ↔ l₁ ~r l₂ :=
@Quotient.eq _ (IsRotated.setoid _) _ _
#align cycle.coe_eq_coe Cycle.coe_eq_coe
@[simp]
theorem mk_eq_coe (l : List α) : Quot.mk _ l = (l : Cycle α) :=
rfl
#align cycle.mk_eq_coe Cycle.mk_eq_coe
@[simp]
theorem mk''_eq_coe (l : List α) : Quotient.mk'' l = (l : Cycle α) :=
rfl
#align cycle.mk'_eq_coe Cycle.mk''_eq_coe
theorem coe_cons_eq_coe_append (l : List α) (a : α) :
(↑(a :: l) : Cycle α) = (↑(l ++ [a]) : Cycle α) :=
Quot.sound ⟨1, by rw [rotate_cons_succ, rotate_zero]⟩
#align cycle.coe_cons_eq_coe_append Cycle.coe_cons_eq_coe_append
def nil : Cycle α :=
([] : List α)
#align cycle.nil Cycle.nil
@[simp]
theorem coe_nil : ↑([] : List α) = @nil α :=
rfl
#align cycle.coe_nil Cycle.coe_nil
@[simp]
theorem coe_eq_nil (l : List α) : (l : Cycle α) = nil ↔ l = [] :=
coe_eq_coe.trans isRotated_nil_iff
#align cycle.coe_eq_nil Cycle.coe_eq_nil
instance : EmptyCollection (Cycle α) :=
⟨nil⟩
@[simp]
theorem empty_eq : ∅ = @nil α :=
rfl
#align cycle.empty_eq Cycle.empty_eq
instance : Inhabited (Cycle α) :=
⟨nil⟩
@[elab_as_elim]
theorem induction_on {C : Cycle α → Prop} (s : Cycle α) (H0 : C nil)
(HI : ∀ (a) (l : List α), C ↑l → C ↑(a :: l)) : C s :=
Quotient.inductionOn' s fun l => by
refine List.recOn l ?_ ?_ <;> simp
assumption'
#align cycle.induction_on Cycle.induction_on
def Mem (a : α) (s : Cycle α) : Prop :=
Quot.liftOn s (fun l => a ∈ l) fun _ _ e => propext <| e.mem_iff
#align cycle.mem Cycle.Mem
instance : Membership α (Cycle α) :=
⟨Mem⟩
@[simp]
theorem mem_coe_iff {a : α} {l : List α} : a ∈ (↑l : Cycle α) ↔ a ∈ l :=
Iff.rfl
#align cycle.mem_coe_iff Cycle.mem_coe_iff
@[simp]
theorem not_mem_nil : ∀ a, a ∉ @nil α :=
List.not_mem_nil
#align cycle.not_mem_nil Cycle.not_mem_nil
instance [DecidableEq α] : DecidableEq (Cycle α) := fun s₁ s₂ =>
Quotient.recOnSubsingleton₂' s₁ s₂ fun _ _ => decidable_of_iff' _ Quotient.eq''
instance [DecidableEq α] (x : α) (s : Cycle α) : Decidable (x ∈ s) :=
Quotient.recOnSubsingleton' s fun l => show Decidable (x ∈ l) from inferInstance
nonrec def reverse (s : Cycle α) : Cycle α :=
Quot.map reverse (fun _ _ => IsRotated.reverse) s
#align cycle.reverse Cycle.reverse
@[simp]
theorem reverse_coe (l : List α) : (l : Cycle α).reverse = l.reverse :=
rfl
#align cycle.reverse_coe Cycle.reverse_coe
@[simp]
theorem mem_reverse_iff {a : α} {s : Cycle α} : a ∈ s.reverse ↔ a ∈ s :=
Quot.inductionOn s fun _ => mem_reverse
#align cycle.mem_reverse_iff Cycle.mem_reverse_iff
@[simp]
theorem reverse_reverse (s : Cycle α) : s.reverse.reverse = s :=
Quot.inductionOn s fun _ => by simp
#align cycle.reverse_reverse Cycle.reverse_reverse
@[simp]
theorem reverse_nil : nil.reverse = @nil α :=
rfl
#align cycle.reverse_nil Cycle.reverse_nil
def length (s : Cycle α) : ℕ :=
Quot.liftOn s List.length fun _ _ e => e.perm.length_eq
#align cycle.length Cycle.length
@[simp]
theorem length_coe (l : List α) : length (l : Cycle α) = l.length :=
rfl
#align cycle.length_coe Cycle.length_coe
@[simp]
theorem length_nil : length (@nil α) = 0 :=
rfl
#align cycle.length_nil Cycle.length_nil
@[simp]
theorem length_reverse (s : Cycle α) : s.reverse.length = s.length :=
Quot.inductionOn s List.length_reverse
#align cycle.length_reverse Cycle.length_reverse
def Subsingleton (s : Cycle α) : Prop :=
s.length ≤ 1
#align cycle.subsingleton Cycle.Subsingleton
theorem subsingleton_nil : Subsingleton (@nil α) := Nat.zero_le _
#align cycle.subsingleton_nil Cycle.subsingleton_nil
theorem length_subsingleton_iff {s : Cycle α} : Subsingleton s ↔ length s ≤ 1 :=
Iff.rfl
#align cycle.length_subsingleton_iff Cycle.length_subsingleton_iff
@[simp]
theorem subsingleton_reverse_iff {s : Cycle α} : s.reverse.Subsingleton ↔ s.Subsingleton := by
simp [length_subsingleton_iff]
#align cycle.subsingleton_reverse_iff Cycle.subsingleton_reverse_iff
theorem Subsingleton.congr {s : Cycle α} (h : Subsingleton s) :
∀ ⦃x⦄ (_hx : x ∈ s) ⦃y⦄ (_hy : y ∈ s), x = y := by
induction' s using Quot.inductionOn with l
simp only [length_subsingleton_iff, length_coe, mk_eq_coe, le_iff_lt_or_eq, Nat.lt_add_one_iff,
length_eq_zero, length_eq_one, Nat.not_lt_zero, false_or_iff] at h
rcases h with (rfl | ⟨z, rfl⟩) <;> simp
#align cycle.subsingleton.congr Cycle.Subsingleton.congr
def Nontrivial (s : Cycle α) : Prop :=
∃ x y : α, x ≠ y ∧ x ∈ s ∧ y ∈ s
#align cycle.nontrivial Cycle.Nontrivial
@[simp]
theorem nontrivial_coe_nodup_iff {l : List α} (hl : l.Nodup) :
Nontrivial (l : Cycle α) ↔ 2 ≤ l.length := by
rw [Nontrivial]
rcases l with (_ | ⟨hd, _ | ⟨hd', tl⟩⟩)
· simp
· simp
· simp only [mem_cons, exists_prop, mem_coe_iff, List.length, Ne, Nat.succ_le_succ_iff,
Nat.zero_le, iff_true_iff]
refine ⟨hd, hd', ?_, by simp⟩
simp only [not_or, mem_cons, nodup_cons] at hl
exact hl.left.left
#align cycle.nontrivial_coe_nodup_iff Cycle.nontrivial_coe_nodup_iff
@[simp]
theorem nontrivial_reverse_iff {s : Cycle α} : s.reverse.Nontrivial ↔ s.Nontrivial := by
simp [Nontrivial]
#align cycle.nontrivial_reverse_iff Cycle.nontrivial_reverse_iff
theorem length_nontrivial {s : Cycle α} (h : Nontrivial s) : 2 ≤ length s := by
obtain ⟨x, y, hxy, hx, hy⟩ := h
induction' s using Quot.inductionOn with l
rcases l with (_ | ⟨hd, _ | ⟨hd', tl⟩⟩)
· simp at hx
· simp only [mem_coe_iff, mk_eq_coe, mem_singleton] at hx hy
simp [hx, hy] at hxy
· simp [Nat.succ_le_succ_iff]
#align cycle.length_nontrivial Cycle.length_nontrivial
nonrec def Nodup (s : Cycle α) : Prop :=
Quot.liftOn s Nodup fun _l₁ _l₂ e => propext <| e.nodup_iff
#align cycle.nodup Cycle.Nodup
@[simp]
nonrec theorem nodup_nil : Nodup (@nil α) :=
nodup_nil
#align cycle.nodup_nil Cycle.nodup_nil
@[simp]
theorem nodup_coe_iff {l : List α} : Nodup (l : Cycle α) ↔ l.Nodup :=
Iff.rfl
#align cycle.nodup_coe_iff Cycle.nodup_coe_iff
@[simp]
theorem nodup_reverse_iff {s : Cycle α} : s.reverse.Nodup ↔ s.Nodup :=
Quot.inductionOn s fun _ => nodup_reverse
#align cycle.nodup_reverse_iff Cycle.nodup_reverse_iff
theorem Subsingleton.nodup {s : Cycle α} (h : Subsingleton s) : Nodup s := by
induction' s using Quot.inductionOn with l
cases' l with hd tl
· simp
· have : tl = [] := by simpa [Subsingleton, length_eq_zero, Nat.succ_le_succ_iff] using h
simp [this]
#align cycle.subsingleton.nodup Cycle.Subsingleton.nodup
theorem Nodup.nontrivial_iff {s : Cycle α} (h : Nodup s) : Nontrivial s ↔ ¬Subsingleton s := by
rw [length_subsingleton_iff]
induction s using Quotient.inductionOn'
simp only [mk''_eq_coe, nodup_coe_iff] at h
simp [h, Nat.succ_le_iff]
#align cycle.nodup.nontrivial_iff Cycle.Nodup.nontrivial_iff
def toMultiset (s : Cycle α) : Multiset α :=
Quotient.liftOn' s (↑) fun _ _ h => Multiset.coe_eq_coe.mpr h.perm
#align cycle.to_multiset Cycle.toMultiset
@[simp]
theorem coe_toMultiset (l : List α) : (l : Cycle α).toMultiset = l :=
rfl
#align cycle.coe_to_multiset Cycle.coe_toMultiset
@[simp]
theorem nil_toMultiset : nil.toMultiset = (0 : Multiset α) :=
rfl
#align cycle.nil_to_multiset Cycle.nil_toMultiset
@[simp]
theorem card_toMultiset (s : Cycle α) : Multiset.card s.toMultiset = s.length :=
Quotient.inductionOn' s (by simp)
#align cycle.card_to_multiset Cycle.card_toMultiset
@[simp]
theorem toMultiset_eq_nil {s : Cycle α} : s.toMultiset = 0 ↔ s = Cycle.nil :=
Quotient.inductionOn' s (by simp)
#align cycle.to_multiset_eq_nil Cycle.toMultiset_eq_nil
def map {β : Type*} (f : α → β) : Cycle α → Cycle β :=
Quotient.map' (List.map f) fun _ _ h => h.map _
#align cycle.map Cycle.map
@[simp]
theorem map_nil {β : Type*} (f : α → β) : map f nil = nil :=
rfl
#align cycle.map_nil Cycle.map_nil
@[simp]
theorem map_coe {β : Type*} (f : α → β) (l : List α) : map f ↑l = List.map f l :=
rfl
#align cycle.map_coe Cycle.map_coe
@[simp]
theorem map_eq_nil {β : Type*} (f : α → β) (s : Cycle α) : map f s = nil ↔ s = nil :=
Quotient.inductionOn' s (by simp)
#align cycle.map_eq_nil Cycle.map_eq_nil
@[simp]
theorem mem_map {β : Type*} {f : α → β} {b : β} {s : Cycle α} :
b ∈ s.map f ↔ ∃ a, a ∈ s ∧ f a = b :=
Quotient.inductionOn' s (by simp)
#align cycle.mem_map Cycle.mem_map
def lists (s : Cycle α) : Multiset (List α) :=
Quotient.liftOn' s (fun l => (l.cyclicPermutations : Multiset (List α))) fun l₁ l₂ h => by
simpa using h.cyclicPermutations.perm
#align cycle.lists Cycle.lists
@[simp]
theorem lists_coe (l : List α) : lists (l : Cycle α) = ↑l.cyclicPermutations :=
rfl
#align cycle.lists_coe Cycle.lists_coe
@[simp]
theorem mem_lists_iff_coe_eq {s : Cycle α} {l : List α} : l ∈ s.lists ↔ (l : Cycle α) = s :=
Quotient.inductionOn' s fun l => by
rw [lists, Quotient.liftOn'_mk'']
simp
#align cycle.mem_lists_iff_coe_eq Cycle.mem_lists_iff_coe_eq
@[simp]
| Mathlib/Data/List/Cycle.lean | 753 | 754 | theorem lists_nil : lists (@nil α) = [([] : List α)] := by |
rw [nil, lists_coe, cyclicPermutations_nil]
|
import Mathlib.Analysis.Asymptotics.Asymptotics
import Mathlib.Analysis.NormedSpace.Basic
#align_import analysis.asymptotics.theta from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
open Filter
open Topology
namespace Asymptotics
set_option linter.uppercaseLean3 false -- is_Theta
variable {α : Type*} {β : Type*} {E : Type*} {F : Type*} {G : Type*} {E' : Type*}
{F' : Type*} {G' : Type*} {E'' : Type*} {F'' : Type*} {G'' : Type*} {R : Type*}
{R' : Type*} {𝕜 : Type*} {𝕜' : Type*}
variable [Norm E] [Norm F] [Norm G]
variable [SeminormedAddCommGroup E'] [SeminormedAddCommGroup F'] [SeminormedAddCommGroup G']
[NormedAddCommGroup E''] [NormedAddCommGroup F''] [NormedAddCommGroup G''] [SeminormedRing R]
[SeminormedRing R']
variable [NormedField 𝕜] [NormedField 𝕜']
variable {c c' c₁ c₂ : ℝ} {f : α → E} {g : α → F} {k : α → G}
variable {f' : α → E'} {g' : α → F'} {k' : α → G'}
variable {f'' : α → E''} {g'' : α → F''}
variable {l l' : Filter α}
def IsTheta (l : Filter α) (f : α → E) (g : α → F) : Prop :=
IsBigO l f g ∧ IsBigO l g f
#align asymptotics.is_Theta Asymptotics.IsTheta
@[inherit_doc]
notation:100 f " =Θ[" l "] " g:100 => IsTheta l f g
theorem IsBigO.antisymm (h₁ : f =O[l] g) (h₂ : g =O[l] f) : f =Θ[l] g :=
⟨h₁, h₂⟩
#align asymptotics.is_O.antisymm Asymptotics.IsBigO.antisymm
lemma IsTheta.isBigO (h : f =Θ[l] g) : f =O[l] g := h.1
lemma IsTheta.isBigO_symm (h : f =Θ[l] g) : g =O[l] f := h.2
@[refl]
theorem isTheta_refl (f : α → E) (l : Filter α) : f =Θ[l] f :=
⟨isBigO_refl _ _, isBigO_refl _ _⟩
#align asymptotics.is_Theta_refl Asymptotics.isTheta_refl
theorem isTheta_rfl : f =Θ[l] f :=
isTheta_refl _ _
#align asymptotics.is_Theta_rfl Asymptotics.isTheta_rfl
@[symm]
nonrec theorem IsTheta.symm (h : f =Θ[l] g) : g =Θ[l] f :=
h.symm
#align asymptotics.is_Theta.symm Asymptotics.IsTheta.symm
theorem isTheta_comm : f =Θ[l] g ↔ g =Θ[l] f :=
⟨fun h ↦ h.symm, fun h ↦ h.symm⟩
#align asymptotics.is_Theta_comm Asymptotics.isTheta_comm
@[trans]
theorem IsTheta.trans {f : α → E} {g : α → F'} {k : α → G} (h₁ : f =Θ[l] g) (h₂ : g =Θ[l] k) :
f =Θ[l] k :=
⟨h₁.1.trans h₂.1, h₂.2.trans h₁.2⟩
#align asymptotics.is_Theta.trans Asymptotics.IsTheta.trans
-- Porting note (#10754): added instance
instance : Trans (α := α → E) (β := α → F') (γ := α → G) (IsTheta l) (IsTheta l) (IsTheta l) :=
⟨IsTheta.trans⟩
@[trans]
theorem IsBigO.trans_isTheta {f : α → E} {g : α → F'} {k : α → G} (h₁ : f =O[l] g)
(h₂ : g =Θ[l] k) : f =O[l] k :=
h₁.trans h₂.1
#align asymptotics.is_O.trans_is_Theta Asymptotics.IsBigO.trans_isTheta
-- Porting note (#10754): added instance
instance : Trans (α := α → E) (β := α → F') (γ := α → G) (IsBigO l) (IsTheta l) (IsBigO l) :=
⟨IsBigO.trans_isTheta⟩
@[trans]
theorem IsTheta.trans_isBigO {f : α → E} {g : α → F'} {k : α → G} (h₁ : f =Θ[l] g)
(h₂ : g =O[l] k) : f =O[l] k :=
h₁.1.trans h₂
#align asymptotics.is_Theta.trans_is_O Asymptotics.IsTheta.trans_isBigO
-- Porting note (#10754): added instance
instance : Trans (α := α → E) (β := α → F') (γ := α → G) (IsTheta l) (IsBigO l) (IsBigO l) :=
⟨IsTheta.trans_isBigO⟩
@[trans]
theorem IsLittleO.trans_isTheta {f : α → E} {g : α → F} {k : α → G'} (h₁ : f =o[l] g)
(h₂ : g =Θ[l] k) : f =o[l] k :=
h₁.trans_isBigO h₂.1
#align asymptotics.is_o.trans_is_Theta Asymptotics.IsLittleO.trans_isTheta
-- Porting note (#10754): added instance
instance : Trans (α := α → E) (β := α → F') (γ := α → G') (IsLittleO l) (IsTheta l) (IsLittleO l) :=
⟨IsLittleO.trans_isTheta⟩
@[trans]
theorem IsTheta.trans_isLittleO {f : α → E} {g : α → F'} {k : α → G} (h₁ : f =Θ[l] g)
(h₂ : g =o[l] k) : f =o[l] k :=
h₁.1.trans_isLittleO h₂
#align asymptotics.is_Theta.trans_is_o Asymptotics.IsTheta.trans_isLittleO
-- Porting note (#10754): added instance
instance : Trans (α := α → E) (β := α → F') (γ := α → G) (IsTheta l) (IsLittleO l) (IsLittleO l) :=
⟨IsTheta.trans_isLittleO⟩
@[trans]
theorem IsTheta.trans_eventuallyEq {f : α → E} {g₁ g₂ : α → F} (h : f =Θ[l] g₁) (hg : g₁ =ᶠ[l] g₂) :
f =Θ[l] g₂ :=
⟨h.1.trans_eventuallyEq hg, hg.symm.trans_isBigO h.2⟩
#align asymptotics.is_Theta.trans_eventually_eq Asymptotics.IsTheta.trans_eventuallyEq
-- Porting note (#10754): added instance
instance : Trans (α := α → E) (β := α → F) (γ := α → F) (IsTheta l) (EventuallyEq l) (IsTheta l) :=
⟨IsTheta.trans_eventuallyEq⟩
@[trans]
theorem _root_.Filter.EventuallyEq.trans_isTheta {f₁ f₂ : α → E} {g : α → F} (hf : f₁ =ᶠ[l] f₂)
(h : f₂ =Θ[l] g) : f₁ =Θ[l] g :=
⟨hf.trans_isBigO h.1, h.2.trans_eventuallyEq hf.symm⟩
#align filter.eventually_eq.trans_is_Theta Filter.EventuallyEq.trans_isTheta
-- Porting note (#10754): added instance
instance : Trans (α := α → E) (β := α → E) (γ := α → F) (EventuallyEq l) (IsTheta l) (IsTheta l) :=
⟨EventuallyEq.trans_isTheta⟩
lemma _root_.Filter.EventuallyEq.isTheta {f g : α → E} (h : f =ᶠ[l] g) : f =Θ[l] g :=
h.trans_isTheta isTheta_rfl
@[simp]
theorem isTheta_norm_left : (fun x ↦ ‖f' x‖) =Θ[l] g ↔ f' =Θ[l] g := by simp [IsTheta]
#align asymptotics.is_Theta_norm_left Asymptotics.isTheta_norm_left
@[simp]
theorem isTheta_norm_right : (f =Θ[l] fun x ↦ ‖g' x‖) ↔ f =Θ[l] g' := by simp [IsTheta]
#align asymptotics.is_Theta_norm_right Asymptotics.isTheta_norm_right
alias ⟨IsTheta.of_norm_left, IsTheta.norm_left⟩ := isTheta_norm_left
#align asymptotics.is_Theta.of_norm_left Asymptotics.IsTheta.of_norm_left
#align asymptotics.is_Theta.norm_left Asymptotics.IsTheta.norm_left
alias ⟨IsTheta.of_norm_right, IsTheta.norm_right⟩ := isTheta_norm_right
#align asymptotics.is_Theta.of_norm_right Asymptotics.IsTheta.of_norm_right
#align asymptotics.is_Theta.norm_right Asymptotics.IsTheta.norm_right
theorem isTheta_of_norm_eventuallyEq (h : (fun x ↦ ‖f x‖) =ᶠ[l] fun x ↦ ‖g x‖) : f =Θ[l] g :=
⟨IsBigO.of_bound 1 <| by simpa only [one_mul] using h.le,
IsBigO.of_bound 1 <| by simpa only [one_mul] using h.symm.le⟩
#align asymptotics.is_Theta_of_norm_eventually_eq Asymptotics.isTheta_of_norm_eventuallyEq
theorem isTheta_of_norm_eventuallyEq' {g : α → ℝ} (h : (fun x ↦ ‖f' x‖) =ᶠ[l] g) : f' =Θ[l] g :=
isTheta_of_norm_eventuallyEq <| h.mono fun x hx ↦ by simp only [← hx, norm_norm]
#align asymptotics.is_Theta_of_norm_eventually_eq' Asymptotics.isTheta_of_norm_eventuallyEq'
theorem IsTheta.isLittleO_congr_left (h : f' =Θ[l] g') : f' =o[l] k ↔ g' =o[l] k :=
⟨h.symm.trans_isLittleO, h.trans_isLittleO⟩
#align asymptotics.is_Theta.is_o_congr_left Asymptotics.IsTheta.isLittleO_congr_left
theorem IsTheta.isLittleO_congr_right (h : g' =Θ[l] k') : f =o[l] g' ↔ f =o[l] k' :=
⟨fun H ↦ H.trans_isTheta h, fun H ↦ H.trans_isTheta h.symm⟩
#align asymptotics.is_Theta.is_o_congr_right Asymptotics.IsTheta.isLittleO_congr_right
theorem IsTheta.isBigO_congr_left (h : f' =Θ[l] g') : f' =O[l] k ↔ g' =O[l] k :=
⟨h.symm.trans_isBigO, h.trans_isBigO⟩
#align asymptotics.is_Theta.is_O_congr_left Asymptotics.IsTheta.isBigO_congr_left
theorem IsTheta.isBigO_congr_right (h : g' =Θ[l] k') : f =O[l] g' ↔ f =O[l] k' :=
⟨fun H ↦ H.trans_isTheta h, fun H ↦ H.trans_isTheta h.symm⟩
#align asymptotics.is_Theta.is_O_congr_right Asymptotics.IsTheta.isBigO_congr_right
lemma IsTheta.isTheta_congr_left (h : f' =Θ[l] g') : f' =Θ[l] k ↔ g' =Θ[l] k :=
h.isBigO_congr_left.and h.isBigO_congr_right
lemma IsTheta.isTheta_congr_right (h : f' =Θ[l] g') : k =Θ[l] f' ↔ k =Θ[l] g' :=
h.isBigO_congr_right.and h.isBigO_congr_left
theorem IsTheta.mono (h : f =Θ[l] g) (hl : l' ≤ l) : f =Θ[l'] g :=
⟨h.1.mono hl, h.2.mono hl⟩
#align asymptotics.is_Theta.mono Asymptotics.IsTheta.mono
theorem IsTheta.sup (h : f' =Θ[l] g') (h' : f' =Θ[l'] g') : f' =Θ[l ⊔ l'] g' :=
⟨h.1.sup h'.1, h.2.sup h'.2⟩
#align asymptotics.is_Theta.sup Asymptotics.IsTheta.sup
@[simp]
theorem isTheta_sup : f' =Θ[l ⊔ l'] g' ↔ f' =Θ[l] g' ∧ f' =Θ[l'] g' :=
⟨fun h ↦ ⟨h.mono le_sup_left, h.mono le_sup_right⟩, fun h ↦ h.1.sup h.2⟩
#align asymptotics.is_Theta_sup Asymptotics.isTheta_sup
theorem IsTheta.eq_zero_iff (h : f'' =Θ[l] g'') : ∀ᶠ x in l, f'' x = 0 ↔ g'' x = 0 :=
h.1.eq_zero_imp.mp <| h.2.eq_zero_imp.mono fun _ ↦ Iff.intro
#align asymptotics.is_Theta.eq_zero_iff Asymptotics.IsTheta.eq_zero_iff
theorem IsTheta.tendsto_zero_iff (h : f'' =Θ[l] g'') :
Tendsto f'' l (𝓝 0) ↔ Tendsto g'' l (𝓝 0) := by
simp only [← isLittleO_one_iff ℝ, h.isLittleO_congr_left]
#align asymptotics.is_Theta.tendsto_zero_iff Asymptotics.IsTheta.tendsto_zero_iff
theorem IsTheta.tendsto_norm_atTop_iff (h : f' =Θ[l] g') :
Tendsto (norm ∘ f') l atTop ↔ Tendsto (norm ∘ g') l atTop := by
simp only [Function.comp, ← isLittleO_const_left_of_ne (one_ne_zero' ℝ), h.isLittleO_congr_right]
#align asymptotics.is_Theta.tendsto_norm_at_top_iff Asymptotics.IsTheta.tendsto_norm_atTop_iff
theorem IsTheta.isBoundedUnder_le_iff (h : f' =Θ[l] g') :
IsBoundedUnder (· ≤ ·) l (norm ∘ f') ↔ IsBoundedUnder (· ≤ ·) l (norm ∘ g') := by
simp only [← isBigO_const_of_ne (one_ne_zero' ℝ), h.isBigO_congr_left]
#align asymptotics.is_Theta.is_bounded_under_le_iff Asymptotics.IsTheta.isBoundedUnder_le_iff
theorem IsTheta.smul [NormedSpace 𝕜 E'] [NormedSpace 𝕜' F'] {f₁ : α → 𝕜} {f₂ : α → 𝕜'} {g₁ : α → E'}
{g₂ : α → F'} (hf : f₁ =Θ[l] f₂) (hg : g₁ =Θ[l] g₂) :
(fun x ↦ f₁ x • g₁ x) =Θ[l] fun x ↦ f₂ x • g₂ x :=
⟨hf.1.smul hg.1, hf.2.smul hg.2⟩
#align asymptotics.is_Theta.smul Asymptotics.IsTheta.smul
theorem IsTheta.mul {f₁ f₂ : α → 𝕜} {g₁ g₂ : α → 𝕜'} (h₁ : f₁ =Θ[l] g₁) (h₂ : f₂ =Θ[l] g₂) :
(fun x ↦ f₁ x * f₂ x) =Θ[l] fun x ↦ g₁ x * g₂ x :=
h₁.smul h₂
#align asymptotics.is_Theta.mul Asymptotics.IsTheta.mul
theorem IsTheta.inv {f : α → 𝕜} {g : α → 𝕜'} (h : f =Θ[l] g) :
(fun x ↦ (f x)⁻¹) =Θ[l] fun x ↦ (g x)⁻¹ :=
⟨h.2.inv_rev h.1.eq_zero_imp, h.1.inv_rev h.2.eq_zero_imp⟩
#align asymptotics.is_Theta.inv Asymptotics.IsTheta.inv
@[simp]
theorem isTheta_inv {f : α → 𝕜} {g : α → 𝕜'} :
((fun x ↦ (f x)⁻¹) =Θ[l] fun x ↦ (g x)⁻¹) ↔ f =Θ[l] g :=
⟨fun h ↦ by simpa only [inv_inv] using h.inv, IsTheta.inv⟩
#align asymptotics.is_Theta_inv Asymptotics.isTheta_inv
theorem IsTheta.div {f₁ f₂ : α → 𝕜} {g₁ g₂ : α → 𝕜'} (h₁ : f₁ =Θ[l] g₁) (h₂ : f₂ =Θ[l] g₂) :
(fun x ↦ f₁ x / f₂ x) =Θ[l] fun x ↦ g₁ x / g₂ x := by
simpa only [div_eq_mul_inv] using h₁.mul h₂.inv
#align asymptotics.is_Theta.div Asymptotics.IsTheta.div
theorem IsTheta.pow {f : α → 𝕜} {g : α → 𝕜'} (h : f =Θ[l] g) (n : ℕ) :
(fun x ↦ f x ^ n) =Θ[l] fun x ↦ g x ^ n :=
⟨h.1.pow n, h.2.pow n⟩
#align asymptotics.is_Theta.pow Asymptotics.IsTheta.pow
theorem IsTheta.zpow {f : α → 𝕜} {g : α → 𝕜'} (h : f =Θ[l] g) (n : ℤ) :
(fun x ↦ f x ^ n) =Θ[l] fun x ↦ g x ^ n := by
cases n
· simpa only [Int.ofNat_eq_coe, zpow_natCast] using h.pow _
· simpa only [zpow_negSucc] using (h.pow _).inv
#align asymptotics.is_Theta.zpow Asymptotics.IsTheta.zpow
theorem isTheta_const_const {c₁ : E''} {c₂ : F''} (h₁ : c₁ ≠ 0) (h₂ : c₂ ≠ 0) :
(fun _ : α ↦ c₁) =Θ[l] fun _ ↦ c₂ :=
⟨isBigO_const_const _ h₂ _, isBigO_const_const _ h₁ _⟩
#align asymptotics.is_Theta_const_const Asymptotics.isTheta_const_const
@[simp]
theorem isTheta_const_const_iff [NeBot l] {c₁ : E''} {c₂ : F''} :
((fun _ : α ↦ c₁) =Θ[l] fun _ ↦ c₂) ↔ (c₁ = 0 ↔ c₂ = 0) := by
simpa only [IsTheta, isBigO_const_const_iff, ← iff_def] using Iff.comm
#align asymptotics.is_Theta_const_const_iff Asymptotics.isTheta_const_const_iff
@[simp]
| Mathlib/Analysis/Asymptotics/Theta.lean | 280 | 281 | theorem isTheta_zero_left : (fun _ ↦ (0 : E')) =Θ[l] g'' ↔ g'' =ᶠ[l] 0 := by |
simp only [IsTheta, isBigO_zero, isBigO_zero_right_iff, true_and_iff]
|
import Mathlib.Analysis.InnerProductSpace.Basic
import Mathlib.Analysis.SpecialFunctions.Complex.Arg
#align_import analysis.complex.arg from "leanprover-community/mathlib"@"45a46f4f03f8ae41491bf3605e8e0e363ba192fd"
variable {x y : ℂ}
namespace Complex
theorem sameRay_iff : SameRay ℝ x y ↔ x = 0 ∨ y = 0 ∨ x.arg = y.arg := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
rcases eq_or_ne y 0 with (rfl | hy)
· simp
simp only [hx, hy, false_or_iff, sameRay_iff_norm_smul_eq, arg_eq_arg_iff hx hy]
field_simp [hx, hy]
rw [mul_comm, eq_comm]
#align complex.same_ray_iff Complex.sameRay_iff
| Mathlib/Analysis/Complex/Arg.lean | 41 | 45 | theorem sameRay_iff_arg_div_eq_zero : SameRay ℝ x y ↔ arg (x / y) = 0 := by |
rw [← Real.Angle.toReal_zero, ← arg_coe_angle_eq_iff_eq_toReal, sameRay_iff]
by_cases hx : x = 0; · simp [hx]
by_cases hy : y = 0; · simp [hy]
simp [hx, hy, arg_div_coe_angle, sub_eq_zero]
|
import Mathlib.Algebra.Order.Field.Power
import Mathlib.NumberTheory.Padics.PadicVal
#align_import number_theory.padics.padic_norm from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7"
def padicNorm (p : ℕ) (q : ℚ) : ℚ :=
if q = 0 then 0 else (p : ℚ) ^ (-padicValRat p q)
#align padic_norm padicNorm
namespace padicNorm
open padicValRat
variable {p : ℕ}
@[simp]
protected theorem eq_zpow_of_nonzero {q : ℚ} (hq : q ≠ 0) :
padicNorm p q = (p : ℚ) ^ (-padicValRat p q) := by simp [hq, padicNorm]
#align padic_norm.eq_zpow_of_nonzero padicNorm.eq_zpow_of_nonzero
protected theorem nonneg (q : ℚ) : 0 ≤ padicNorm p q :=
if hq : q = 0 then by simp [hq, padicNorm]
else by
unfold padicNorm
split_ifs
apply zpow_nonneg
exact mod_cast Nat.zero_le _
#align padic_norm.nonneg padicNorm.nonneg
@[simp]
protected theorem zero : padicNorm p 0 = 0 := by simp [padicNorm]
#align padic_norm.zero padicNorm.zero
-- @[simp] -- Porting note (#10618): simp can prove this
protected theorem one : padicNorm p 1 = 1 := by simp [padicNorm]
#align padic_norm.one padicNorm.one
| Mathlib/NumberTheory/Padics/PadicNorm.lean | 81 | 82 | theorem padicNorm_p (hp : 1 < p) : padicNorm p p = (p : ℚ)⁻¹ := by |
simp [padicNorm, (pos_of_gt hp).ne', padicValNat.self hp]
|
import Mathlib.Data.Nat.Defs
import Mathlib.Order.Interval.Set.Basic
import Mathlib.Tactic.Monotonicity.Attr
#align_import data.nat.log from "leanprover-community/mathlib"@"3e00d81bdcbf77c8188bbd18f5524ddc3ed8cac6"
namespace Nat
--@[pp_nodot] porting note: unknown attribute
def log (b : ℕ) : ℕ → ℕ
| n => if h : b ≤ n ∧ 1 < b then log b (n / b) + 1 else 0
decreasing_by
-- putting this in the def triggers the `unusedHavesSuffices` linter:
-- https://github.com/leanprover-community/batteries/issues/428
have : n / b < n := div_lt_self ((Nat.zero_lt_one.trans h.2).trans_le h.1) h.2
decreasing_trivial
#align nat.log Nat.log
@[simp]
theorem log_eq_zero_iff {b n : ℕ} : log b n = 0 ↔ n < b ∨ b ≤ 1 := by
rw [log, dite_eq_right_iff]
simp only [Nat.add_eq_zero_iff, Nat.one_ne_zero, and_false, imp_false, not_and_or, not_le, not_lt]
#align nat.log_eq_zero_iff Nat.log_eq_zero_iff
theorem log_of_lt {b n : ℕ} (hb : n < b) : log b n = 0 :=
log_eq_zero_iff.2 (Or.inl hb)
#align nat.log_of_lt Nat.log_of_lt
theorem log_of_left_le_one {b : ℕ} (hb : b ≤ 1) (n) : log b n = 0 :=
log_eq_zero_iff.2 (Or.inr hb)
#align nat.log_of_left_le_one Nat.log_of_left_le_one
@[simp]
theorem log_pos_iff {b n : ℕ} : 0 < log b n ↔ b ≤ n ∧ 1 < b := by
rw [Nat.pos_iff_ne_zero, Ne, log_eq_zero_iff, not_or, not_lt, not_le]
#align nat.log_pos_iff Nat.log_pos_iff
theorem log_pos {b n : ℕ} (hb : 1 < b) (hbn : b ≤ n) : 0 < log b n :=
log_pos_iff.2 ⟨hbn, hb⟩
#align nat.log_pos Nat.log_pos
theorem log_of_one_lt_of_le {b n : ℕ} (h : 1 < b) (hn : b ≤ n) : log b n = log b (n / b) + 1 := by
rw [log]
exact if_pos ⟨hn, h⟩
#align nat.log_of_one_lt_of_le Nat.log_of_one_lt_of_le
@[simp] lemma log_zero_left : ∀ n, log 0 n = 0 := log_of_left_le_one $ Nat.zero_le _
#align nat.log_zero_left Nat.log_zero_left
@[simp]
theorem log_zero_right (b : ℕ) : log b 0 = 0 :=
log_eq_zero_iff.2 (le_total 1 b)
#align nat.log_zero_right Nat.log_zero_right
@[simp]
theorem log_one_left : ∀ n, log 1 n = 0 :=
log_of_left_le_one le_rfl
#align nat.log_one_left Nat.log_one_left
@[simp]
theorem log_one_right (b : ℕ) : log b 1 = 0 :=
log_eq_zero_iff.2 (lt_or_le _ _)
#align nat.log_one_right Nat.log_one_right
| Mathlib/Data/Nat/Log.lean | 89 | 101 | theorem pow_le_iff_le_log {b : ℕ} (hb : 1 < b) {x y : ℕ} (hy : y ≠ 0) :
b ^ x ≤ y ↔ x ≤ log b y := by |
induction' y using Nat.strong_induction_on with y ih generalizing x
cases x with
| zero => dsimp; omega
| succ x =>
rw [log]; split_ifs with h
· have b_pos : 0 < b := lt_of_succ_lt hb
rw [Nat.add_le_add_iff_right, ← ih (y / b) (div_lt_self
(Nat.pos_iff_ne_zero.2 hy) hb) (Nat.div_pos h.1 b_pos).ne', le_div_iff_mul_le b_pos,
pow_succ', Nat.mul_comm]
· exact iff_of_false (fun hby => h ⟨(le_self_pow x.succ_ne_zero _).trans hby, hb⟩)
(not_succ_le_zero _)
|
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
| Mathlib/Algebra/ContinuedFractions/Computation/TerminatesIffRat.lean | 278 | 292 | 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
|
import Mathlib.Algebra.Order.Ring.Basic
import Mathlib.Computability.Primrec
import Mathlib.Tactic.Ring
import Mathlib.Tactic.Linarith
#align_import computability.ackermann from "leanprover-community/mathlib"@"9b2660e1b25419042c8da10bf411aa3c67f14383"
open Nat
def ack : ℕ → ℕ → ℕ
| 0, n => n + 1
| m + 1, 0 => ack m 1
| m + 1, n + 1 => ack m (ack (m + 1) n)
#align ack ack
@[simp]
| Mathlib/Computability/Ackermann.lean | 70 | 70 | theorem ack_zero (n : ℕ) : ack 0 n = n + 1 := by | rw [ack]
|
import Mathlib.Probability.Variance
#align_import probability.moments from "leanprover-community/mathlib"@"85453a2a14be8da64caf15ca50930cf4c6e5d8de"
open MeasureTheory Filter Finset Real
noncomputable section
open scoped MeasureTheory ProbabilityTheory ENNReal NNReal
namespace ProbabilityTheory
variable {Ω ι : Type*} {m : MeasurableSpace Ω} {X : Ω → ℝ} {p : ℕ} {μ : Measure Ω}
def moment (X : Ω → ℝ) (p : ℕ) (μ : Measure Ω) : ℝ :=
μ[X ^ p]
#align probability_theory.moment ProbabilityTheory.moment
def centralMoment (X : Ω → ℝ) (p : ℕ) (μ : Measure Ω) : ℝ := by
have m := fun (x : Ω) => μ[X] -- Porting note: Lean deems `μ[(X - fun x => μ[X]) ^ p]` ambiguous
exact μ[(X - m) ^ p]
#align probability_theory.central_moment ProbabilityTheory.centralMoment
@[simp]
| Mathlib/Probability/Moments.lean | 62 | 64 | theorem moment_zero (hp : p ≠ 0) : moment 0 p μ = 0 := by |
simp only [moment, hp, zero_pow, Ne, not_false_iff, Pi.zero_apply, integral_const,
smul_eq_mul, mul_zero, integral_zero]
|
import Mathlib.Algebra.Module.Submodule.EqLocus
import Mathlib.Algebra.Module.Submodule.RestrictScalars
import Mathlib.Algebra.Ring.Idempotents
import Mathlib.Data.Set.Pointwise.SMul
import Mathlib.LinearAlgebra.Basic
import Mathlib.Order.CompactlyGenerated.Basic
import Mathlib.Order.OmegaCompletePartialOrder
#align_import linear_algebra.span from "leanprover-community/mathlib"@"10878f6bf1dab863445907ab23fbfcefcb5845d0"
variable {R R₂ K M M₂ V S : Type*}
namespace Submodule
open Function Set
open Pointwise
section AddCommMonoid
variable [Semiring R] [AddCommMonoid M] [Module R M]
variable {x : M} (p p' : Submodule R M)
variable [Semiring R₂] {σ₁₂ : R →+* R₂}
variable [AddCommMonoid M₂] [Module R₂ M₂]
variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂]
section
variable (R)
def span (s : Set M) : Submodule R M :=
sInf { p | s ⊆ p }
#align submodule.span Submodule.span
variable {R}
-- Porting note: renamed field to `principal'` and added `principal` to fix explicit argument
@[mk_iff]
class IsPrincipal (S : Submodule R M) : Prop where
principal' : ∃ a, S = span R {a}
#align submodule.is_principal Submodule.IsPrincipal
theorem IsPrincipal.principal (S : Submodule R M) [S.IsPrincipal] :
∃ a, S = span R {a} :=
Submodule.IsPrincipal.principal'
#align submodule.is_principal.principal Submodule.IsPrincipal.principal
end
variable {s t : Set M}
theorem mem_span : x ∈ span R s ↔ ∀ p : Submodule R M, s ⊆ p → x ∈ p :=
mem_iInter₂
#align submodule.mem_span Submodule.mem_span
@[aesop safe 20 apply (rule_sets := [SetLike])]
theorem subset_span : s ⊆ span R s := fun _ h => mem_span.2 fun _ hp => hp h
#align submodule.subset_span Submodule.subset_span
theorem span_le {p} : span R s ≤ p ↔ s ⊆ p :=
⟨Subset.trans subset_span, fun ss _ h => mem_span.1 h _ ss⟩
#align submodule.span_le Submodule.span_le
theorem span_mono (h : s ⊆ t) : span R s ≤ span R t :=
span_le.2 <| Subset.trans h subset_span
#align submodule.span_mono Submodule.span_mono
theorem span_monotone : Monotone (span R : Set M → Submodule R M) := fun _ _ => span_mono
#align submodule.span_monotone Submodule.span_monotone
theorem span_eq_of_le (h₁ : s ⊆ p) (h₂ : p ≤ span R s) : span R s = p :=
le_antisymm (span_le.2 h₁) h₂
#align submodule.span_eq_of_le Submodule.span_eq_of_le
theorem span_eq : span R (p : Set M) = p :=
span_eq_of_le _ (Subset.refl _) subset_span
#align submodule.span_eq Submodule.span_eq
theorem span_eq_span (hs : s ⊆ span R t) (ht : t ⊆ span R s) : span R s = span R t :=
le_antisymm (span_le.2 hs) (span_le.2 ht)
#align submodule.span_eq_span Submodule.span_eq_span
lemma coe_span_eq_self [SetLike S M] [AddSubmonoidClass S M] [SMulMemClass S R M] (s : S) :
(span R (s : Set M) : Set M) = s := by
refine le_antisymm ?_ subset_span
let s' : Submodule R M :=
{ carrier := s
add_mem' := add_mem
zero_mem' := zero_mem _
smul_mem' := SMulMemClass.smul_mem }
exact span_le (p := s') |>.mpr le_rfl
@[simp]
theorem span_coe_eq_restrictScalars [Semiring S] [SMul S R] [Module S M] [IsScalarTower S R M] :
span S (p : Set M) = p.restrictScalars S :=
span_eq (p.restrictScalars S)
#align submodule.span_coe_eq_restrict_scalars Submodule.span_coe_eq_restrictScalars
theorem image_span_subset (f : F) (s : Set M) (N : Submodule R₂ M₂) :
f '' span R s ⊆ N ↔ ∀ m ∈ s, f m ∈ N := image_subset_iff.trans <| span_le (p := N.comap f)
theorem image_span_subset_span (f : F) (s : Set M) : f '' span R s ⊆ span R₂ (f '' s) :=
(image_span_subset f s _).2 fun x hx ↦ subset_span ⟨x, hx, rfl⟩
theorem map_span [RingHomSurjective σ₁₂] (f : F) (s : Set M) :
(span R s).map f = span R₂ (f '' s) :=
Eq.symm <| span_eq_of_le _ (Set.image_subset f subset_span) (image_span_subset_span f s)
#align submodule.map_span Submodule.map_span
alias _root_.LinearMap.map_span := Submodule.map_span
#align linear_map.map_span LinearMap.map_span
theorem map_span_le [RingHomSurjective σ₁₂] (f : F) (s : Set M) (N : Submodule R₂ M₂) :
map f (span R s) ≤ N ↔ ∀ m ∈ s, f m ∈ N := image_span_subset f s N
#align submodule.map_span_le Submodule.map_span_le
alias _root_.LinearMap.map_span_le := Submodule.map_span_le
#align linear_map.map_span_le LinearMap.map_span_le
@[simp]
theorem span_insert_zero : span R (insert (0 : M) s) = span R s := by
refine le_antisymm ?_ (Submodule.span_mono (Set.subset_insert 0 s))
rw [span_le, Set.insert_subset_iff]
exact ⟨by simp only [SetLike.mem_coe, Submodule.zero_mem], Submodule.subset_span⟩
#align submodule.span_insert_zero Submodule.span_insert_zero
-- See also `span_preimage_eq` below.
theorem span_preimage_le (f : F) (s : Set M₂) :
span R (f ⁻¹' s) ≤ (span R₂ s).comap f := by
rw [span_le, comap_coe]
exact preimage_mono subset_span
#align submodule.span_preimage_le Submodule.span_preimage_le
alias _root_.LinearMap.span_preimage_le := Submodule.span_preimage_le
#align linear_map.span_preimage_le LinearMap.span_preimage_le
theorem closure_subset_span {s : Set M} : (AddSubmonoid.closure s : Set M) ⊆ span R s :=
(@AddSubmonoid.closure_le _ _ _ (span R s).toAddSubmonoid).mpr subset_span
#align submodule.closure_subset_span Submodule.closure_subset_span
theorem closure_le_toAddSubmonoid_span {s : Set M} :
AddSubmonoid.closure s ≤ (span R s).toAddSubmonoid :=
closure_subset_span
#align submodule.closure_le_to_add_submonoid_span Submodule.closure_le_toAddSubmonoid_span
@[simp]
theorem span_closure {s : Set M} : span R (AddSubmonoid.closure s : Set M) = span R s :=
le_antisymm (span_le.mpr closure_subset_span) (span_mono AddSubmonoid.subset_closure)
#align submodule.span_closure Submodule.span_closure
@[elab_as_elim]
theorem span_induction {p : M → Prop} (h : x ∈ span R s) (mem : ∀ x ∈ s, p x) (zero : p 0)
(add : ∀ x y, p x → p y → p (x + y)) (smul : ∀ (a : R) (x), p x → p (a • x)) : p x :=
((@span_le (p := ⟨⟨⟨p, by intros x y; exact add x y⟩, zero⟩, smul⟩)) s).2 mem h
#align submodule.span_induction Submodule.span_induction
theorem span_induction₂ {p : M → M → Prop} {a b : M} (ha : a ∈ Submodule.span R s)
(hb : b ∈ Submodule.span R s) (mem_mem : ∀ x ∈ s, ∀ y ∈ s, p x y)
(zero_left : ∀ y, p 0 y) (zero_right : ∀ x, p x 0)
(add_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ + x₂) y)
(add_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ + y₂))
(smul_left : ∀ (r : R) x y, p x y → p (r • x) y)
(smul_right : ∀ (r : R) x y, p x y → p x (r • y)) : p a b :=
Submodule.span_induction ha
(fun x hx => Submodule.span_induction hb (mem_mem x hx) (zero_right x) (add_right x) fun r =>
smul_right r x)
(zero_left b) (fun x₁ x₂ => add_left x₁ x₂ b) fun r x => smul_left r x b
@[elab_as_elim]
theorem span_induction' {p : ∀ x, x ∈ span R s → Prop}
(mem : ∀ (x) (h : x ∈ s), p x (subset_span h))
(zero : p 0 (Submodule.zero_mem _))
(add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›))
(smul : ∀ (a : R) (x hx), p x hx → p (a • x) (Submodule.smul_mem _ _ ‹_›)) {x}
(hx : x ∈ span R s) : p x hx := by
refine Exists.elim ?_ fun (hx : x ∈ span R s) (hc : p x hx) => hc
refine
span_induction hx (fun m hm => ⟨subset_span hm, mem m hm⟩) ⟨zero_mem _, zero⟩
(fun x y hx hy =>
Exists.elim hx fun hx' hx =>
Exists.elim hy fun hy' hy => ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩)
fun r x hx => Exists.elim hx fun hx' hx => ⟨smul_mem _ _ hx', smul r _ _ hx⟩
#align submodule.span_induction' Submodule.span_induction'
open AddSubmonoid in
theorem span_eq_closure {s : Set M} : (span R s).toAddSubmonoid = closure (@univ R • s) := by
refine le_antisymm
(fun x hx ↦ span_induction hx (fun x hx ↦ subset_closure ⟨1, trivial, x, hx, one_smul R x⟩)
(zero_mem _) (fun _ _ ↦ add_mem) fun r m hm ↦ closure_induction hm ?_ ?_ fun _ _ h h' ↦ ?_)
(closure_le.2 ?_)
· rintro _ ⟨r, -, m, hm, rfl⟩; exact smul_mem _ _ (subset_span hm)
· rintro _ ⟨r', -, m, hm, rfl⟩; exact subset_closure ⟨r * r', trivial, m, hm, mul_smul r r' m⟩
· rw [smul_zero]; apply zero_mem
· rw [smul_add]; exact add_mem h h'
@[elab_as_elim]
theorem closure_induction {p : M → Prop} (h : x ∈ span R s) (zero : p 0)
(add : ∀ x y, p x → p y → p (x + y)) (smul_mem : ∀ r : R, ∀ x ∈ s, p (r • x)) : p x := by
rw [← mem_toAddSubmonoid, span_eq_closure] at h
refine AddSubmonoid.closure_induction h ?_ zero add
rintro _ ⟨r, -, m, hm, rfl⟩
exact smul_mem r m hm
@[elab_as_elim]
theorem closure_induction' {p : ∀ x, x ∈ span R s → Prop}
(zero : p 0 (Submodule.zero_mem _))
(add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›))
(smul_mem : ∀ (r x) (h : x ∈ s), p (r • x) (Submodule.smul_mem _ _ <| subset_span h)) {x}
(hx : x ∈ span R s) : p x hx := by
refine Exists.elim ?_ fun (hx : x ∈ span R s) (hc : p x hx) ↦ hc
refine closure_induction hx ⟨zero_mem _, zero⟩
(fun x y hx hy ↦ Exists.elim hx fun hx' hx ↦
Exists.elim hy fun hy' hy ↦ ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩)
fun r x hx ↦ ⟨Submodule.smul_mem _ _ (subset_span hx), smul_mem r x hx⟩
@[simp]
theorem span_span_coe_preimage : span R (((↑) : span R s → M) ⁻¹' s) = ⊤ :=
eq_top_iff.2 fun x ↦ Subtype.recOn x fun x hx _ ↦ by
refine span_induction' (p := fun x hx ↦ (⟨x, hx⟩ : span R s) ∈ span R (Subtype.val ⁻¹' s))
(fun x' hx' ↦ subset_span hx') ?_ (fun x _ y _ ↦ ?_) (fun r x _ ↦ ?_) hx
· exact zero_mem _
· exact add_mem
· exact smul_mem _ _
#align submodule.span_span_coe_preimage Submodule.span_span_coe_preimage
@[simp]
lemma span_setOf_mem_eq_top :
span R {x : span R s | (x : M) ∈ s} = ⊤ :=
span_span_coe_preimage
theorem span_nat_eq_addSubmonoid_closure (s : Set M) :
(span ℕ s).toAddSubmonoid = AddSubmonoid.closure s := by
refine Eq.symm (AddSubmonoid.closure_eq_of_le subset_span ?_)
apply (OrderIso.to_galoisConnection (AddSubmonoid.toNatSubmodule (M := M)).symm).l_le
(a := span ℕ s) (b := AddSubmonoid.closure s)
rw [span_le]
exact AddSubmonoid.subset_closure
#align submodule.span_nat_eq_add_submonoid_closure Submodule.span_nat_eq_addSubmonoid_closure
@[simp]
theorem span_nat_eq (s : AddSubmonoid M) : (span ℕ (s : Set M)).toAddSubmonoid = s := by
rw [span_nat_eq_addSubmonoid_closure, s.closure_eq]
#align submodule.span_nat_eq Submodule.span_nat_eq
theorem span_int_eq_addSubgroup_closure {M : Type*} [AddCommGroup M] (s : Set M) :
(span ℤ s).toAddSubgroup = AddSubgroup.closure s :=
Eq.symm <|
AddSubgroup.closure_eq_of_le _ subset_span fun x hx =>
span_induction hx (fun x hx => AddSubgroup.subset_closure hx) (AddSubgroup.zero_mem _)
(fun _ _ => AddSubgroup.add_mem _) fun _ _ _ => AddSubgroup.zsmul_mem _ ‹_› _
#align submodule.span_int_eq_add_subgroup_closure Submodule.span_int_eq_addSubgroup_closure
@[simp]
theorem span_int_eq {M : Type*} [AddCommGroup M] (s : AddSubgroup M) :
(span ℤ (s : Set M)).toAddSubgroup = s := by rw [span_int_eq_addSubgroup_closure, s.closure_eq]
#align submodule.span_int_eq Submodule.span_int_eq
section
variable (R M)
protected def gi : GaloisInsertion (@span R M _ _ _) (↑) where
choice s _ := span R s
gc _ _ := span_le
le_l_u _ := subset_span
choice_eq _ _ := rfl
#align submodule.gi Submodule.gi
end
@[simp]
theorem span_empty : span R (∅ : Set M) = ⊥ :=
(Submodule.gi R M).gc.l_bot
#align submodule.span_empty Submodule.span_empty
@[simp]
theorem span_univ : span R (univ : Set M) = ⊤ :=
eq_top_iff.2 <| SetLike.le_def.2 <| subset_span
#align submodule.span_univ Submodule.span_univ
theorem span_union (s t : Set M) : span R (s ∪ t) = span R s ⊔ span R t :=
(Submodule.gi R M).gc.l_sup
#align submodule.span_union Submodule.span_union
theorem span_iUnion {ι} (s : ι → Set M) : span R (⋃ i, s i) = ⨆ i, span R (s i) :=
(Submodule.gi R M).gc.l_iSup
#align submodule.span_Union Submodule.span_iUnion
theorem span_iUnion₂ {ι} {κ : ι → Sort*} (s : ∀ i, κ i → Set M) :
span R (⋃ (i) (j), s i j) = ⨆ (i) (j), span R (s i j) :=
(Submodule.gi R M).gc.l_iSup₂
#align submodule.span_Union₂ Submodule.span_iUnion₂
theorem span_attach_biUnion [DecidableEq M] {α : Type*} (s : Finset α) (f : s → Finset M) :
span R (s.attach.biUnion f : Set M) = ⨆ x, span R (f x) := by simp [span_iUnion]
#align submodule.span_attach_bUnion Submodule.span_attach_biUnion
theorem sup_span : p ⊔ span R s = span R (p ∪ s) := by rw [Submodule.span_union, p.span_eq]
#align submodule.sup_span Submodule.sup_span
theorem span_sup : span R s ⊔ p = span R (s ∪ p) := by rw [Submodule.span_union, p.span_eq]
#align submodule.span_sup Submodule.span_sup
notation:1000
R " ∙ " x => span R (singleton x)
theorem span_eq_iSup_of_singleton_spans (s : Set M) : span R s = ⨆ x ∈ s, R ∙ x := by
simp only [← span_iUnion, Set.biUnion_of_singleton s]
#align submodule.span_eq_supr_of_singleton_spans Submodule.span_eq_iSup_of_singleton_spans
theorem span_range_eq_iSup {ι : Sort*} {v : ι → M} : span R (range v) = ⨆ i, R ∙ v i := by
rw [span_eq_iSup_of_singleton_spans, iSup_range]
#align submodule.span_range_eq_supr Submodule.span_range_eq_iSup
theorem span_smul_le (s : Set M) (r : R) : span R (r • s) ≤ span R s := by
rw [span_le]
rintro _ ⟨x, hx, rfl⟩
exact smul_mem (span R s) r (subset_span hx)
#align submodule.span_smul_le Submodule.span_smul_le
theorem subset_span_trans {U V W : Set M} (hUV : U ⊆ Submodule.span R V)
(hVW : V ⊆ Submodule.span R W) : U ⊆ Submodule.span R W :=
(Submodule.gi R M).gc.le_u_l_trans hUV hVW
#align submodule.subset_span_trans Submodule.subset_span_trans
theorem span_smul_eq_of_isUnit (s : Set M) (r : R) (hr : IsUnit r) : span R (r • s) = span R s := by
apply le_antisymm
· apply span_smul_le
· convert span_smul_le (r • s) ((hr.unit⁻¹ : _) : R)
rw [smul_smul]
erw [hr.unit.inv_val]
rw [one_smul]
#align submodule.span_smul_eq_of_is_unit Submodule.span_smul_eq_of_isUnit
@[simp]
theorem coe_iSup_of_directed {ι} [Nonempty ι] (S : ι → Submodule R M)
(H : Directed (· ≤ ·) S) : ((iSup S: Submodule R M) : Set M) = ⋃ i, S i :=
let s : Submodule R M :=
{ __ := AddSubmonoid.copy _ _ (AddSubmonoid.coe_iSup_of_directed H).symm
smul_mem' := fun r _ hx ↦ have ⟨i, hi⟩ := Set.mem_iUnion.mp hx
Set.mem_iUnion.mpr ⟨i, (S i).smul_mem' r hi⟩ }
have : iSup S = s := le_antisymm
(iSup_le fun i ↦ le_iSup (fun i ↦ (S i : Set M)) i) (Set.iUnion_subset fun _ ↦ le_iSup S _)
this.symm ▸ rfl
#align submodule.coe_supr_of_directed Submodule.coe_iSup_of_directed
@[simp]
theorem mem_iSup_of_directed {ι} [Nonempty ι] (S : ι → Submodule R M) (H : Directed (· ≤ ·) S) {x} :
x ∈ iSup S ↔ ∃ i, x ∈ S i := by
rw [← SetLike.mem_coe, coe_iSup_of_directed S H, mem_iUnion]
rfl
#align submodule.mem_supr_of_directed Submodule.mem_iSup_of_directed
theorem mem_sSup_of_directed {s : Set (Submodule R M)} {z} (hs : s.Nonempty)
(hdir : DirectedOn (· ≤ ·) s) : z ∈ sSup s ↔ ∃ y ∈ s, z ∈ y := by
have : Nonempty s := hs.to_subtype
simp only [sSup_eq_iSup', mem_iSup_of_directed _ hdir.directed_val, SetCoe.exists, Subtype.coe_mk,
exists_prop]
#align submodule.mem_Sup_of_directed Submodule.mem_sSup_of_directed
@[norm_cast, simp]
theorem coe_iSup_of_chain (a : ℕ →o Submodule R M) : (↑(⨆ k, a k) : Set M) = ⋃ k, (a k : Set M) :=
coe_iSup_of_directed a a.monotone.directed_le
#align submodule.coe_supr_of_chain Submodule.coe_iSup_of_chain
theorem coe_scott_continuous :
OmegaCompletePartialOrder.Continuous' ((↑) : Submodule R M → Set M) :=
⟨SetLike.coe_mono, coe_iSup_of_chain⟩
#align submodule.coe_scott_continuous Submodule.coe_scott_continuous
@[simp]
theorem mem_iSup_of_chain (a : ℕ →o Submodule R M) (m : M) : (m ∈ ⨆ k, a k) ↔ ∃ k, m ∈ a k :=
mem_iSup_of_directed a a.monotone.directed_le
#align submodule.mem_supr_of_chain Submodule.mem_iSup_of_chain
section
variable {p p'}
theorem mem_sup : x ∈ p ⊔ p' ↔ ∃ y ∈ p, ∃ z ∈ p', y + z = x :=
⟨fun h => by
rw [← span_eq p, ← span_eq p', ← span_union] at h
refine span_induction h ?_ ?_ ?_ ?_
· rintro y (h | h)
· exact ⟨y, h, 0, by simp, by simp⟩
· exact ⟨0, by simp, y, h, by simp⟩
· exact ⟨0, by simp, 0, by simp⟩
· rintro _ _ ⟨y₁, hy₁, z₁, hz₁, rfl⟩ ⟨y₂, hy₂, z₂, hz₂, rfl⟩
exact ⟨_, add_mem hy₁ hy₂, _, add_mem hz₁ hz₂, by
rw [add_assoc, add_assoc, ← add_assoc y₂, ← add_assoc z₁, add_comm y₂]⟩
· rintro a _ ⟨y, hy, z, hz, rfl⟩
exact ⟨_, smul_mem _ a hy, _, smul_mem _ a hz, by simp [smul_add]⟩, by
rintro ⟨y, hy, z, hz, rfl⟩
exact add_mem ((le_sup_left : p ≤ p ⊔ p') hy) ((le_sup_right : p' ≤ p ⊔ p') hz)⟩
#align submodule.mem_sup Submodule.mem_sup
theorem mem_sup' : x ∈ p ⊔ p' ↔ ∃ (y : p) (z : p'), (y : M) + z = x :=
mem_sup.trans <| by simp only [Subtype.exists, exists_prop]
#align submodule.mem_sup' Submodule.mem_sup'
lemma exists_add_eq_of_codisjoint (h : Codisjoint p p') (x : M) :
∃ y ∈ p, ∃ z ∈ p', y + z = x := by
suffices x ∈ p ⊔ p' by exact Submodule.mem_sup.mp this
simpa only [h.eq_top] using Submodule.mem_top
variable (p p')
theorem coe_sup : ↑(p ⊔ p') = (p + p' : Set M) := by
ext
rw [SetLike.mem_coe, mem_sup, Set.mem_add]
simp
#align submodule.coe_sup Submodule.coe_sup
theorem sup_toAddSubmonoid : (p ⊔ p').toAddSubmonoid = p.toAddSubmonoid ⊔ p'.toAddSubmonoid := by
ext x
rw [mem_toAddSubmonoid, mem_sup, AddSubmonoid.mem_sup]
rfl
#align submodule.sup_to_add_submonoid Submodule.sup_toAddSubmonoid
theorem sup_toAddSubgroup {R M : Type*} [Ring R] [AddCommGroup M] [Module R M]
(p p' : Submodule R M) : (p ⊔ p').toAddSubgroup = p.toAddSubgroup ⊔ p'.toAddSubgroup := by
ext x
rw [mem_toAddSubgroup, mem_sup, AddSubgroup.mem_sup]
rfl
#align submodule.sup_to_add_subgroup Submodule.sup_toAddSubgroup
end
theorem mem_span_singleton_self (x : M) : x ∈ R ∙ x :=
subset_span rfl
#align submodule.mem_span_singleton_self Submodule.mem_span_singleton_self
theorem nontrivial_span_singleton {x : M} (h : x ≠ 0) : Nontrivial (R ∙ x) :=
⟨by
use 0, ⟨x, Submodule.mem_span_singleton_self x⟩
intro H
rw [eq_comm, Submodule.mk_eq_zero] at H
exact h H⟩
#align submodule.nontrivial_span_singleton Submodule.nontrivial_span_singleton
theorem mem_span_singleton {y : M} : (x ∈ R ∙ y) ↔ ∃ a : R, a • y = x :=
⟨fun h => by
refine span_induction h ?_ ?_ ?_ ?_
· rintro y (rfl | ⟨⟨_⟩⟩)
exact ⟨1, by simp⟩
· exact ⟨0, by simp⟩
· rintro _ _ ⟨a, rfl⟩ ⟨b, rfl⟩
exact ⟨a + b, by simp [add_smul]⟩
· rintro a _ ⟨b, rfl⟩
exact ⟨a * b, by simp [smul_smul]⟩, by
rintro ⟨a, y, rfl⟩; exact smul_mem _ _ (subset_span <| by simp)⟩
#align submodule.mem_span_singleton Submodule.mem_span_singleton
theorem le_span_singleton_iff {s : Submodule R M} {v₀ : M} :
(s ≤ R ∙ v₀) ↔ ∀ v ∈ s, ∃ r : R, r • v₀ = v := by simp_rw [SetLike.le_def, mem_span_singleton]
#align submodule.le_span_singleton_iff Submodule.le_span_singleton_iff
variable (R)
theorem span_singleton_eq_top_iff (x : M) : (R ∙ x) = ⊤ ↔ ∀ v, ∃ r : R, r • x = v := by
rw [eq_top_iff, le_span_singleton_iff]
tauto
#align submodule.span_singleton_eq_top_iff Submodule.span_singleton_eq_top_iff
@[simp]
theorem span_zero_singleton : (R ∙ (0 : M)) = ⊥ := by
ext
simp [mem_span_singleton, eq_comm]
#align submodule.span_zero_singleton Submodule.span_zero_singleton
theorem span_singleton_eq_range (y : M) : ↑(R ∙ y) = range ((· • y) : R → M) :=
Set.ext fun _ => mem_span_singleton
#align submodule.span_singleton_eq_range Submodule.span_singleton_eq_range
theorem span_singleton_smul_le {S} [Monoid S] [SMul S R] [MulAction S M] [IsScalarTower S R M]
(r : S) (x : M) : (R ∙ r • x) ≤ R ∙ x := by
rw [span_le, Set.singleton_subset_iff, SetLike.mem_coe]
exact smul_of_tower_mem _ _ (mem_span_singleton_self _)
#align submodule.span_singleton_smul_le Submodule.span_singleton_smul_le
theorem span_singleton_group_smul_eq {G} [Group G] [SMul G R] [MulAction G M] [IsScalarTower G R M]
(g : G) (x : M) : (R ∙ g • x) = R ∙ x := by
refine le_antisymm (span_singleton_smul_le R g x) ?_
convert span_singleton_smul_le R g⁻¹ (g • x)
exact (inv_smul_smul g x).symm
#align submodule.span_singleton_group_smul_eq Submodule.span_singleton_group_smul_eq
variable {R}
theorem span_singleton_smul_eq {r : R} (hr : IsUnit r) (x : M) : (R ∙ r • x) = R ∙ x := by
lift r to Rˣ using hr
rw [← Units.smul_def]
exact span_singleton_group_smul_eq R r x
#align submodule.span_singleton_smul_eq Submodule.span_singleton_smul_eq
theorem disjoint_span_singleton {K E : Type*} [DivisionRing K] [AddCommGroup E] [Module K E]
{s : Submodule K E} {x : E} : Disjoint s (K ∙ x) ↔ x ∈ s → x = 0 := by
refine disjoint_def.trans ⟨fun H hx => H x hx <| subset_span <| mem_singleton x, ?_⟩
intro H y hy hyx
obtain ⟨c, rfl⟩ := mem_span_singleton.1 hyx
by_cases hc : c = 0
· rw [hc, zero_smul]
· rw [s.smul_mem_iff hc] at hy
rw [H hy, smul_zero]
#align submodule.disjoint_span_singleton Submodule.disjoint_span_singleton
theorem disjoint_span_singleton' {K E : Type*} [DivisionRing K] [AddCommGroup E] [Module K E]
{p : Submodule K E} {x : E} (x0 : x ≠ 0) : Disjoint p (K ∙ x) ↔ x ∉ p :=
disjoint_span_singleton.trans ⟨fun h₁ h₂ => x0 (h₁ h₂), fun h₁ h₂ => (h₁ h₂).elim⟩
#align submodule.disjoint_span_singleton' Submodule.disjoint_span_singleton'
theorem mem_span_singleton_trans {x y z : M} (hxy : x ∈ R ∙ y) (hyz : y ∈ R ∙ z) : x ∈ R ∙ z := by
rw [← SetLike.mem_coe, ← singleton_subset_iff] at *
exact Submodule.subset_span_trans hxy hyz
#align submodule.mem_span_singleton_trans Submodule.mem_span_singleton_trans
theorem span_insert (x) (s : Set M) : span R (insert x s) = (R ∙ x) ⊔ span R s := by
rw [insert_eq, span_union]
#align submodule.span_insert Submodule.span_insert
theorem span_insert_eq_span (h : x ∈ span R s) : span R (insert x s) = span R s :=
span_eq_of_le _ (Set.insert_subset_iff.mpr ⟨h, subset_span⟩) (span_mono <| subset_insert _ _)
#align submodule.span_insert_eq_span Submodule.span_insert_eq_span
theorem span_span : span R (span R s : Set M) = span R s :=
span_eq _
#align submodule.span_span Submodule.span_span
theorem mem_span_insert {y} :
x ∈ span R (insert y s) ↔ ∃ a : R, ∃ z ∈ span R s, x = a • y + z := by
simp [span_insert, mem_sup, mem_span_singleton, eq_comm (a := x)]
#align submodule.mem_span_insert Submodule.mem_span_insert
theorem mem_span_pair {x y z : M} :
z ∈ span R ({x, y} : Set M) ↔ ∃ a b : R, a • x + b • y = z := by
simp_rw [mem_span_insert, mem_span_singleton, exists_exists_eq_and, eq_comm]
#align submodule.mem_span_pair Submodule.mem_span_pair
variable (R S s)
theorem span_le_restrictScalars [Semiring S] [SMul R S] [Module S M] [IsScalarTower R S M] :
span R s ≤ (span S s).restrictScalars R :=
Submodule.span_le.2 Submodule.subset_span
#align submodule.span_le_restrict_scalars Submodule.span_le_restrictScalars
@[simp]
theorem span_subset_span [Semiring S] [SMul R S] [Module S M] [IsScalarTower R S M] :
↑(span R s) ⊆ (span S s : Set M) :=
span_le_restrictScalars R S s
#align submodule.span_subset_span Submodule.span_subset_span
theorem span_span_of_tower [Semiring S] [SMul R S] [Module S M] [IsScalarTower R S M] :
span S (span R s : Set M) = span S s :=
le_antisymm (span_le.2 <| span_subset_span R S s) (span_mono subset_span)
#align submodule.span_span_of_tower Submodule.span_span_of_tower
variable {R S s}
theorem span_eq_bot : span R (s : Set M) = ⊥ ↔ ∀ x ∈ s, (x : M) = 0 :=
eq_bot_iff.trans
⟨fun H _ h => (mem_bot R).1 <| H <| subset_span h, fun H =>
span_le.2 fun x h => (mem_bot R).2 <| H x h⟩
#align submodule.span_eq_bot Submodule.span_eq_bot
@[simp]
theorem span_singleton_eq_bot : (R ∙ x) = ⊥ ↔ x = 0 :=
span_eq_bot.trans <| by simp
#align submodule.span_singleton_eq_bot Submodule.span_singleton_eq_bot
@[simp]
theorem span_zero : span R (0 : Set M) = ⊥ := by rw [← singleton_zero, span_singleton_eq_bot]
#align submodule.span_zero Submodule.span_zero
@[simp]
theorem span_singleton_le_iff_mem (m : M) (p : Submodule R M) : (R ∙ m) ≤ p ↔ m ∈ p := by
rw [span_le, singleton_subset_iff, SetLike.mem_coe]
#align submodule.span_singleton_le_iff_mem Submodule.span_singleton_le_iff_mem
theorem span_singleton_eq_span_singleton {R M : Type*} [Ring R] [AddCommGroup M] [Module R M]
[NoZeroSMulDivisors R M] {x y : M} : ((R ∙ x) = R ∙ y) ↔ ∃ z : Rˣ, z • x = y := by
constructor
· simp only [le_antisymm_iff, span_singleton_le_iff_mem, mem_span_singleton]
rintro ⟨⟨a, rfl⟩, b, hb⟩
rcases eq_or_ne y 0 with rfl | hy; · simp
refine ⟨⟨b, a, ?_, ?_⟩, hb⟩
· apply smul_left_injective R hy
simpa only [mul_smul, one_smul]
· rw [← hb] at hy
apply smul_left_injective R (smul_ne_zero_iff.1 hy).2
simp only [mul_smul, one_smul, hb]
· rintro ⟨u, rfl⟩
exact (span_singleton_group_smul_eq _ _ _).symm
#align submodule.span_singleton_eq_span_singleton Submodule.span_singleton_eq_span_singleton
-- Should be `@[simp]` but doesn't fire due to `lean4#3701`.
theorem span_image [RingHomSurjective σ₁₂] (f : F) :
span R₂ (f '' s) = map f (span R s) :=
(map_span f s).symm
#align submodule.span_image Submodule.span_image
@[simp] -- Should be replaced with `Submodule.span_image` when `lean4#3701` is fixed.
theorem span_image' [RingHomSurjective σ₁₂] (f : M →ₛₗ[σ₁₂] M₂) :
span R₂ (f '' s) = map f (span R s) :=
span_image _
theorem apply_mem_span_image_of_mem_span [RingHomSurjective σ₁₂] (f : F) {x : M}
{s : Set M} (h : x ∈ Submodule.span R s) : f x ∈ Submodule.span R₂ (f '' s) := by
rw [Submodule.span_image]
exact Submodule.mem_map_of_mem h
#align submodule.apply_mem_span_image_of_mem_span Submodule.apply_mem_span_image_of_mem_span
theorem apply_mem_span_image_iff_mem_span [RingHomSurjective σ₁₂] {f : F} {x : M}
{s : Set M} (hf : Function.Injective f) :
f x ∈ Submodule.span R₂ (f '' s) ↔ x ∈ Submodule.span R s := by
rw [← Submodule.mem_comap, ← Submodule.map_span, Submodule.comap_map_eq_of_injective hf]
@[simp]
theorem map_subtype_span_singleton {p : Submodule R M} (x : p) :
map p.subtype (R ∙ x) = R ∙ (x : M) := by simp [← span_image]
#align submodule.map_subtype_span_singleton Submodule.map_subtype_span_singleton
theorem not_mem_span_of_apply_not_mem_span_image [RingHomSurjective σ₁₂] (f : F) {x : M}
{s : Set M} (h : f x ∉ Submodule.span R₂ (f '' s)) : x ∉ Submodule.span R s :=
h.imp (apply_mem_span_image_of_mem_span f)
#align submodule.not_mem_span_of_apply_not_mem_span_image Submodule.not_mem_span_of_apply_not_mem_span_image
theorem iSup_span {ι : Sort*} (p : ι → Set M) : ⨆ i, span R (p i) = span R (⋃ i, p i) :=
le_antisymm (iSup_le fun i => span_mono <| subset_iUnion _ i) <|
span_le.mpr <| iUnion_subset fun i _ hm => mem_iSup_of_mem i <| subset_span hm
#align submodule.supr_span Submodule.iSup_span
theorem iSup_eq_span {ι : Sort*} (p : ι → Submodule R M) : ⨆ i, p i = span R (⋃ i, ↑(p i)) := by
simp_rw [← iSup_span, span_eq]
#align submodule.supr_eq_span Submodule.iSup_eq_span
theorem iSup_toAddSubmonoid {ι : Sort*} (p : ι → Submodule R M) :
(⨆ i, p i).toAddSubmonoid = ⨆ i, (p i).toAddSubmonoid := by
refine le_antisymm (fun x => ?_) (iSup_le fun i => toAddSubmonoid_mono <| le_iSup _ i)
simp_rw [iSup_eq_span, AddSubmonoid.iSup_eq_closure, mem_toAddSubmonoid, coe_toAddSubmonoid]
intro hx
refine Submodule.span_induction hx (fun x hx => ?_) ?_ (fun x y hx hy => ?_) fun r x hx => ?_
· exact AddSubmonoid.subset_closure hx
· exact AddSubmonoid.zero_mem _
· exact AddSubmonoid.add_mem _ hx hy
· refine AddSubmonoid.closure_induction hx ?_ ?_ ?_
· rintro x ⟨_, ⟨i, rfl⟩, hix : x ∈ p i⟩
apply AddSubmonoid.subset_closure (Set.mem_iUnion.mpr ⟨i, _⟩)
exact smul_mem _ r hix
· rw [smul_zero]
exact AddSubmonoid.zero_mem _
· intro x y hx hy
rw [smul_add]
exact AddSubmonoid.add_mem _ hx hy
#align submodule.supr_to_add_submonoid Submodule.iSup_toAddSubmonoid
@[elab_as_elim]
theorem iSup_induction {ι : Sort*} (p : ι → Submodule R M) {C : M → Prop} {x : M}
(hx : x ∈ ⨆ i, p i) (hp : ∀ (i), ∀ x ∈ p i, C x) (h0 : C 0)
(hadd : ∀ x y, C x → C y → C (x + y)) : C x := by
rw [← mem_toAddSubmonoid, iSup_toAddSubmonoid] at hx
exact AddSubmonoid.iSup_induction (x := x) _ hx hp h0 hadd
#align submodule.supr_induction Submodule.iSup_induction
@[elab_as_elim]
theorem iSup_induction' {ι : Sort*} (p : ι → Submodule R M) {C : ∀ x, (x ∈ ⨆ i, p i) → Prop}
(mem : ∀ (i) (x) (hx : x ∈ p i), C x (mem_iSup_of_mem i hx)) (zero : C 0 (zero_mem _))
(add : ∀ x y hx hy, C x hx → C y hy → C (x + y) (add_mem ‹_› ‹_›)) {x : M}
(hx : x ∈ ⨆ i, p i) : C x hx := by
refine Exists.elim ?_ fun (hx : x ∈ ⨆ i, p i) (hc : C x hx) => hc
refine iSup_induction p (C := fun x : M ↦ ∃ (hx : x ∈ ⨆ i, p i), C x hx) hx
(fun i x hx => ?_) ?_ fun x y => ?_
· exact ⟨_, mem _ _ hx⟩
· exact ⟨_, zero⟩
· rintro ⟨_, Cx⟩ ⟨_, Cy⟩
exact ⟨_, add _ _ _ _ Cx Cy⟩
#align submodule.supr_induction' Submodule.iSup_induction'
theorem singleton_span_isCompactElement (x : M) :
CompleteLattice.IsCompactElement (span R {x} : Submodule R M) := by
rw [CompleteLattice.isCompactElement_iff_le_of_directed_sSup_le]
intro d hemp hdir hsup
have : x ∈ (sSup d) := (SetLike.le_def.mp hsup) (mem_span_singleton_self x)
obtain ⟨y, ⟨hyd, hxy⟩⟩ := (mem_sSup_of_directed hemp hdir).mp this
exact ⟨y, ⟨hyd, by simpa only [span_le, singleton_subset_iff] ⟩⟩
#align submodule.singleton_span_is_compact_element Submodule.singleton_span_isCompactElement
theorem finset_span_isCompactElement (S : Finset M) :
CompleteLattice.IsCompactElement (span R S : Submodule R M) := by
rw [span_eq_iSup_of_singleton_spans]
simp only [Finset.mem_coe]
rw [← Finset.sup_eq_iSup]
exact
CompleteLattice.isCompactElement_finsetSup S fun x _ => singleton_span_isCompactElement x
#align submodule.finset_span_is_compact_element Submodule.finset_span_isCompactElement
theorem finite_span_isCompactElement (S : Set M) (h : S.Finite) :
CompleteLattice.IsCompactElement (span R S : Submodule R M) :=
Finite.coe_toFinset h ▸ finset_span_isCompactElement h.toFinset
#align submodule.finite_span_is_compact_element Submodule.finite_span_isCompactElement
instance : IsCompactlyGenerated (Submodule R M) :=
⟨fun s =>
⟨(fun x => span R {x}) '' s,
⟨fun t ht => by
rcases (Set.mem_image _ _ _).1 ht with ⟨x, _, rfl⟩
apply singleton_span_isCompactElement, by
rw [sSup_eq_iSup, iSup_image, ← span_eq_iSup_of_singleton_spans, span_eq]⟩⟩⟩
| Mathlib/LinearAlgebra/Span.lean | 765 | 776 | theorem submodule_eq_sSup_le_nonzero_spans (p : Submodule R M) :
p = sSup { T : Submodule R M | ∃ m ∈ p, m ≠ 0 ∧ T = span R {m} } := by |
let S := { T : Submodule R M | ∃ m ∈ p, m ≠ 0 ∧ T = span R {m} }
apply le_antisymm
· intro m hm
by_cases h : m = 0
· rw [h]
simp
· exact @le_sSup _ _ S _ ⟨m, ⟨hm, ⟨h, rfl⟩⟩⟩ m (mem_span_singleton_self m)
· rw [sSup_le_iff]
rintro S ⟨_, ⟨_, ⟨_, rfl⟩⟩⟩
rwa [span_singleton_le_iff_mem]
|
import Mathlib.Algebra.Group.NatPowAssoc
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Induction
import Mathlib.Algebra.Polynomial.Eval
namespace Polynomial
section MulActionWithZero
variable {R : Type*} [Semiring R] (r : R) (p : R[X]) {S : Type*} [AddCommMonoid S] [Pow S ℕ]
[MulActionWithZero R S] (x : S)
def smul_pow : ℕ → R → S := fun n r => r • x^n
irreducible_def smeval : S := p.sum (smul_pow x)
theorem smeval_eq_sum : p.smeval x = p.sum (smul_pow x) := by rw [smeval_def]
@[simp]
theorem smeval_C : (C r).smeval x = r • x ^ 0 := by
simp only [smeval_eq_sum, smul_pow, zero_smul, sum_C_index]
@[simp]
theorem smeval_monomial (n : ℕ) :
(monomial n r).smeval x = r • x ^ n := by
simp only [smeval_eq_sum, smul_pow, zero_smul, sum_monomial_index]
theorem eval_eq_smeval : p.eval r = p.smeval r := by
rw [eval_eq_sum, smeval_eq_sum]
rfl
theorem eval₂_eq_smeval (R : Type*) [Semiring R] {S : Type*} [Semiring S] (f : R →+* S) (p : R[X])
(x: S) : letI : Module R S := RingHom.toModule f
p.eval₂ f x = p.smeval x := by
letI : Module R S := RingHom.toModule f
rw [smeval_eq_sum, eval₂_eq_sum]
rfl
variable (R)
@[simp]
| Mathlib/Algebra/Polynomial/Smeval.lean | 79 | 80 | theorem smeval_zero : (0 : R[X]).smeval x = 0 := by |
simp only [smeval_eq_sum, smul_pow, sum_zero_index]
|
import Mathlib.SetTheory.Game.Basic
import Mathlib.Tactic.NthRewrite
#align_import set_theory.game.impartial from "leanprover-community/mathlib"@"2e0975f6a25dd3fbfb9e41556a77f075f6269748"
universe u
namespace SetTheory
open scoped PGame
namespace PGame
def ImpartialAux : PGame → Prop
| G => (G ≈ -G) ∧ (∀ i, ImpartialAux (G.moveLeft i)) ∧ ∀ j, ImpartialAux (G.moveRight j)
termination_by G => G -- Porting note: Added `termination_by`
#align pgame.impartial_aux SetTheory.PGame.ImpartialAux
theorem impartialAux_def {G : PGame} :
G.ImpartialAux ↔
(G ≈ -G) ∧ (∀ i, ImpartialAux (G.moveLeft i)) ∧ ∀ j, ImpartialAux (G.moveRight j) := by
rw [ImpartialAux]
#align pgame.impartial_aux_def SetTheory.PGame.impartialAux_def
class Impartial (G : PGame) : Prop where
out : ImpartialAux G
#align pgame.impartial SetTheory.PGame.Impartial
theorem impartial_iff_aux {G : PGame} : G.Impartial ↔ G.ImpartialAux :=
⟨fun h => h.1, fun h => ⟨h⟩⟩
#align pgame.impartial_iff_aux SetTheory.PGame.impartial_iff_aux
theorem impartial_def {G : PGame} :
G.Impartial ↔ (G ≈ -G) ∧ (∀ i, Impartial (G.moveLeft i)) ∧ ∀ j, Impartial (G.moveRight j) := by
simpa only [impartial_iff_aux] using impartialAux_def
#align pgame.impartial_def SetTheory.PGame.impartial_def
namespace Impartial
instance impartial_zero : Impartial 0 := by rw [impartial_def]; dsimp; simp
#align pgame.impartial.impartial_zero SetTheory.PGame.Impartial.impartial_zero
instance impartial_star : Impartial star := by
rw [impartial_def]; simpa using Impartial.impartial_zero
#align pgame.impartial.impartial_star SetTheory.PGame.Impartial.impartial_star
theorem neg_equiv_self (G : PGame) [h : G.Impartial] : G ≈ -G :=
(impartial_def.1 h).1
#align pgame.impartial.neg_equiv_self SetTheory.PGame.Impartial.neg_equiv_self
-- Porting note: Changed `-⟦G⟧` to `-(⟦G⟧ : Quotient setoid)`
@[simp]
theorem mk'_neg_equiv_self (G : PGame) [G.Impartial] : -(⟦G⟧ : Quotient setoid) = ⟦G⟧ :=
Quot.sound (Equiv.symm (neg_equiv_self G))
#align pgame.impartial.mk_neg_equiv_self SetTheory.PGame.Impartial.mk'_neg_equiv_self
instance moveLeft_impartial {G : PGame} [h : G.Impartial] (i : G.LeftMoves) :
(G.moveLeft i).Impartial :=
(impartial_def.1 h).2.1 i
#align pgame.impartial.move_left_impartial SetTheory.PGame.Impartial.moveLeft_impartial
instance moveRight_impartial {G : PGame} [h : G.Impartial] (j : G.RightMoves) :
(G.moveRight j).Impartial :=
(impartial_def.1 h).2.2 j
#align pgame.impartial.move_right_impartial SetTheory.PGame.Impartial.moveRight_impartial
theorem impartial_congr : ∀ {G H : PGame} (_ : G ≡r H) [G.Impartial], H.Impartial
| G, H => fun e => by
intro h
exact impartial_def.2
⟨Equiv.trans e.symm.equiv (Equiv.trans (neg_equiv_self G) (neg_equiv_neg_iff.2 e.equiv)),
fun i => impartial_congr (e.moveLeftSymm i), fun j => impartial_congr (e.moveRightSymm j)⟩
termination_by G H => (G, H)
#align pgame.impartial.impartial_congr SetTheory.PGame.Impartial.impartial_congr
instance impartial_add : ∀ (G H : PGame) [G.Impartial] [H.Impartial], (G + H).Impartial
| G, H, _, _ => by
rw [impartial_def]
refine ⟨Equiv.trans (add_congr (neg_equiv_self G) (neg_equiv_self _))
(Equiv.symm (negAddRelabelling _ _).equiv), fun k => ?_, fun k => ?_⟩
· apply leftMoves_add_cases k
all_goals
intro i; simp only [add_moveLeft_inl, add_moveLeft_inr]
apply impartial_add
· apply rightMoves_add_cases k
all_goals
intro i; simp only [add_moveRight_inl, add_moveRight_inr]
apply impartial_add
termination_by G H => (G, H)
#align pgame.impartial.impartial_add SetTheory.PGame.Impartial.impartial_add
instance impartial_neg : ∀ (G : PGame) [G.Impartial], (-G).Impartial
| G, _ => by
rw [impartial_def]
refine ⟨?_, fun i => ?_, fun i => ?_⟩
· rw [neg_neg]
exact Equiv.symm (neg_equiv_self G)
· rw [moveLeft_neg']
apply impartial_neg
· rw [moveRight_neg']
apply impartial_neg
termination_by G => G
#align pgame.impartial.impartial_neg SetTheory.PGame.Impartial.impartial_neg
variable (G : PGame) [Impartial G]
theorem nonpos : ¬0 < G := fun h => by
have h' := neg_lt_neg_iff.2 h
rw [neg_zero, lt_congr_left (Equiv.symm (neg_equiv_self G))] at h'
exact (h.trans h').false
#align pgame.impartial.nonpos SetTheory.PGame.Impartial.nonpos
theorem nonneg : ¬G < 0 := fun h => by
have h' := neg_lt_neg_iff.2 h
rw [neg_zero, lt_congr_right (Equiv.symm (neg_equiv_self G))] at h'
exact (h.trans h').false
#align pgame.impartial.nonneg SetTheory.PGame.Impartial.nonneg
theorem equiv_or_fuzzy_zero : (G ≈ 0) ∨ G ‖ 0 := by
rcases lt_or_equiv_or_gt_or_fuzzy G 0 with (h | h | h | h)
· exact ((nonneg G) h).elim
· exact Or.inl h
· exact ((nonpos G) h).elim
· exact Or.inr h
#align pgame.impartial.equiv_or_fuzzy_zero SetTheory.PGame.Impartial.equiv_or_fuzzy_zero
@[simp]
theorem not_equiv_zero_iff : ¬(G ≈ 0) ↔ G ‖ 0 :=
⟨(equiv_or_fuzzy_zero G).resolve_left, Fuzzy.not_equiv⟩
#align pgame.impartial.not_equiv_zero_iff SetTheory.PGame.Impartial.not_equiv_zero_iff
@[simp]
theorem not_fuzzy_zero_iff : ¬G ‖ 0 ↔ (G ≈ 0) :=
⟨(equiv_or_fuzzy_zero G).resolve_right, Equiv.not_fuzzy⟩
#align pgame.impartial.not_fuzzy_zero_iff SetTheory.PGame.Impartial.not_fuzzy_zero_iff
theorem add_self : G + G ≈ 0 :=
Equiv.trans (add_congr_left (neg_equiv_self G)) (add_left_neg_equiv G)
#align pgame.impartial.add_self SetTheory.PGame.Impartial.add_self
-- Porting note: Changed `⟦G⟧` to `(⟦G⟧ : Quotient setoid)`
@[simp]
theorem mk'_add_self : (⟦G⟧ : Quotient setoid) + ⟦G⟧ = 0 :=
Quot.sound (add_self G)
#align pgame.impartial.mk_add_self SetTheory.PGame.Impartial.mk'_add_self
theorem equiv_iff_add_equiv_zero (H : PGame) : (H ≈ G) ↔ (H + G ≈ 0) := by
rw [Game.PGame.equiv_iff_game_eq, ← @add_right_cancel_iff _ _ _ ⟦G⟧, mk'_add_self, ← quot_add,
Game.PGame.equiv_iff_game_eq]
rfl
#align pgame.impartial.equiv_iff_add_equiv_zero SetTheory.PGame.Impartial.equiv_iff_add_equiv_zero
theorem equiv_iff_add_equiv_zero' (H : PGame) : (G ≈ H) ↔ (G + H ≈ 0) := by
rw [Game.PGame.equiv_iff_game_eq, ← @add_left_cancel_iff _ _ _ ⟦G⟧, mk'_add_self, ← quot_add,
Game.PGame.equiv_iff_game_eq]
exact ⟨Eq.symm, Eq.symm⟩
#align pgame.impartial.equiv_iff_add_equiv_zero' SetTheory.PGame.Impartial.equiv_iff_add_equiv_zero'
| Mathlib/SetTheory/Game/Impartial.lean | 179 | 180 | theorem le_zero_iff {G : PGame} [G.Impartial] : G ≤ 0 ↔ 0 ≤ G := by |
rw [← zero_le_neg_iff, le_congr_right (neg_equiv_self G)]
|
import Mathlib.Data.SetLike.Basic
import Mathlib.Data.Finset.Preimage
import Mathlib.ModelTheory.Semantics
#align_import model_theory.definability from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
universe u v w u₁
namespace Set
variable {M : Type w} (A : Set M) (L : FirstOrder.Language.{u, v}) [L.Structure M]
open FirstOrder FirstOrder.Language FirstOrder.Language.Structure
variable {α : Type u₁} {β : Type*}
def Definable (s : Set (α → M)) : Prop :=
∃ φ : L[[A]].Formula α, s = setOf φ.Realize
#align set.definable Set.Definable
variable {L} {A} {B : Set M} {s : Set (α → M)}
theorem Definable.map_expansion {L' : FirstOrder.Language} [L'.Structure M] (h : A.Definable L s)
(φ : L →ᴸ L') [φ.IsExpansionOn M] : A.Definable L' s := by
obtain ⟨ψ, rfl⟩ := h
refine ⟨(φ.addConstants A).onFormula ψ, ?_⟩
ext x
simp only [mem_setOf_eq, LHom.realize_onFormula]
#align set.definable.map_expansion Set.Definable.map_expansion
theorem definable_iff_exists_formula_sum :
A.Definable L s ↔ ∃ φ : L.Formula (A ⊕ α), s = {v | φ.Realize (Sum.elim (↑) v)} := by
rw [Definable, Equiv.exists_congr_left (BoundedFormula.constantsVarsEquiv)]
refine exists_congr (fun φ => iff_iff_eq.2 (congr_arg (s = ·) ?_))
ext
simp only [Formula.Realize, BoundedFormula.constantsVarsEquiv, constantsOn, mk₂_Relations,
BoundedFormula.mapTermRelEquiv_symm_apply, mem_setOf_eq]
refine BoundedFormula.realize_mapTermRel_id ?_ (fun _ _ _ => rfl)
intros
simp only [Term.constantsVarsEquivLeft_symm_apply, Term.realize_varsToConstants,
coe_con, Term.realize_relabel]
congr
ext a
rcases a with (_ | _) | _ <;> rfl
theorem empty_definable_iff :
(∅ : Set M).Definable L s ↔ ∃ φ : L.Formula α, s = setOf φ.Realize := by
rw [Definable, Equiv.exists_congr_left (LEquiv.addEmptyConstants L (∅ : Set M)).onFormula]
simp [-constantsOn]
#align set.empty_definable_iff Set.empty_definable_iff
theorem definable_iff_empty_definable_with_params :
A.Definable L s ↔ (∅ : Set M).Definable (L[[A]]) s :=
empty_definable_iff.symm
#align set.definable_iff_empty_definable_with_params Set.definable_iff_empty_definable_with_params
| Mathlib/ModelTheory/Definability.lean | 86 | 88 | theorem Definable.mono (hAs : A.Definable L s) (hAB : A ⊆ B) : B.Definable L s := by |
rw [definable_iff_empty_definable_with_params] at *
exact hAs.map_expansion (L.lhomWithConstantsMap (Set.inclusion hAB))
|
import Mathlib.LinearAlgebra.Finsupp
import Mathlib.RingTheory.Ideal.Over
import Mathlib.RingTheory.Ideal.Prod
import Mathlib.RingTheory.Ideal.MinimalPrime
import Mathlib.RingTheory.Localization.Away.Basic
import Mathlib.RingTheory.Nilpotent.Lemmas
import Mathlib.Topology.Sets.Closeds
import Mathlib.Topology.Sober
#align_import algebraic_geometry.prime_spectrum.basic from "leanprover-community/mathlib"@"a7c017d750512a352b623b1824d75da5998457d0"
noncomputable section
open scoped Classical
universe u v
variable (R : Type u) (S : Type v)
@[ext]
structure PrimeSpectrum [CommSemiring R] where
asIdeal : Ideal R
IsPrime : asIdeal.IsPrime
#align prime_spectrum PrimeSpectrum
attribute [instance] PrimeSpectrum.IsPrime
namespace PrimeSpectrum
section CommSemiRing
variable [CommSemiring R] [CommSemiring S]
variable {R S}
instance [Nontrivial R] : Nonempty <| PrimeSpectrum R :=
let ⟨I, hI⟩ := Ideal.exists_maximal R
⟨⟨I, hI.isPrime⟩⟩
instance [Subsingleton R] : IsEmpty (PrimeSpectrum R) :=
⟨fun x ↦ x.IsPrime.ne_top <| SetLike.ext' <| Subsingleton.eq_univ_of_nonempty x.asIdeal.nonempty⟩
#noalign prime_spectrum.punit
variable (R S)
@[simp]
def primeSpectrumProdOfSum : Sum (PrimeSpectrum R) (PrimeSpectrum S) → PrimeSpectrum (R × S)
| Sum.inl ⟨I, _⟩ => ⟨Ideal.prod I ⊤, Ideal.isPrime_ideal_prod_top⟩
| Sum.inr ⟨J, _⟩ => ⟨Ideal.prod ⊤ J, Ideal.isPrime_ideal_prod_top'⟩
#align prime_spectrum.prime_spectrum_prod_of_sum PrimeSpectrum.primeSpectrumProdOfSum
noncomputable def primeSpectrumProd :
PrimeSpectrum (R × S) ≃ Sum (PrimeSpectrum R) (PrimeSpectrum S) :=
Equiv.symm <|
Equiv.ofBijective (primeSpectrumProdOfSum R S) (by
constructor
· rintro (⟨I, hI⟩ | ⟨J, hJ⟩) (⟨I', hI'⟩ | ⟨J', hJ'⟩) h <;>
simp only [mk.injEq, Ideal.prod.ext_iff, primeSpectrumProdOfSum] at h
· simp only [h]
· exact False.elim (hI.ne_top h.left)
· exact False.elim (hJ.ne_top h.right)
· simp only [h]
· rintro ⟨I, hI⟩
rcases (Ideal.ideal_prod_prime I).mp hI with (⟨p, ⟨hp, rfl⟩⟩ | ⟨p, ⟨hp, rfl⟩⟩)
· exact ⟨Sum.inl ⟨p, hp⟩, rfl⟩
· exact ⟨Sum.inr ⟨p, hp⟩, rfl⟩)
#align prime_spectrum.prime_spectrum_prod PrimeSpectrum.primeSpectrumProd
variable {R S}
@[simp]
theorem primeSpectrumProd_symm_inl_asIdeal (x : PrimeSpectrum R) :
((primeSpectrumProd R S).symm <| Sum.inl x).asIdeal = Ideal.prod x.asIdeal ⊤ := by
cases x
rfl
#align prime_spectrum.prime_spectrum_prod_symm_inl_as_ideal PrimeSpectrum.primeSpectrumProd_symm_inl_asIdeal
@[simp]
theorem primeSpectrumProd_symm_inr_asIdeal (x : PrimeSpectrum S) :
((primeSpectrumProd R S).symm <| Sum.inr x).asIdeal = Ideal.prod ⊤ x.asIdeal := by
cases x
rfl
#align prime_spectrum.prime_spectrum_prod_symm_inr_as_ideal PrimeSpectrum.primeSpectrumProd_symm_inr_asIdeal
def zeroLocus (s : Set R) : Set (PrimeSpectrum R) :=
{ x | s ⊆ x.asIdeal }
#align prime_spectrum.zero_locus PrimeSpectrum.zeroLocus
@[simp]
theorem mem_zeroLocus (x : PrimeSpectrum R) (s : Set R) : x ∈ zeroLocus s ↔ s ⊆ x.asIdeal :=
Iff.rfl
#align prime_spectrum.mem_zero_locus PrimeSpectrum.mem_zeroLocus
@[simp]
theorem zeroLocus_span (s : Set R) : zeroLocus (Ideal.span s : Set R) = zeroLocus s := by
ext x
exact (Submodule.gi R R).gc s x.asIdeal
#align prime_spectrum.zero_locus_span PrimeSpectrum.zeroLocus_span
def vanishingIdeal (t : Set (PrimeSpectrum R)) : Ideal R :=
⨅ (x : PrimeSpectrum R) (_ : x ∈ t), x.asIdeal
#align prime_spectrum.vanishing_ideal PrimeSpectrum.vanishingIdeal
theorem coe_vanishingIdeal (t : Set (PrimeSpectrum R)) :
(vanishingIdeal t : Set R) = { f : R | ∀ x : PrimeSpectrum R, x ∈ t → f ∈ x.asIdeal } := by
ext f
rw [vanishingIdeal, SetLike.mem_coe, Submodule.mem_iInf]
apply forall_congr'; intro x
rw [Submodule.mem_iInf]
#align prime_spectrum.coe_vanishing_ideal PrimeSpectrum.coe_vanishingIdeal
theorem mem_vanishingIdeal (t : Set (PrimeSpectrum R)) (f : R) :
f ∈ vanishingIdeal t ↔ ∀ x : PrimeSpectrum R, x ∈ t → f ∈ x.asIdeal := by
rw [← SetLike.mem_coe, coe_vanishingIdeal, Set.mem_setOf_eq]
#align prime_spectrum.mem_vanishing_ideal PrimeSpectrum.mem_vanishingIdeal
@[simp]
| Mathlib/AlgebraicGeometry/PrimeSpectrum/Basic.lean | 178 | 179 | theorem vanishingIdeal_singleton (x : PrimeSpectrum R) :
vanishingIdeal ({x} : Set (PrimeSpectrum R)) = x.asIdeal := by | simp [vanishingIdeal]
|
import Mathlib.Data.List.Basic
open Function
open Nat hiding one_pos
assert_not_exists Set.range
namespace List
universe u v w
variable {ι : Type*} {α : Type u} {β : Type v} {γ : Type w} {l₁ l₂ : List α}
section InsertNth
variable {a : α}
@[simp]
theorem insertNth_zero (s : List α) (x : α) : insertNth 0 x s = x :: s :=
rfl
#align list.insert_nth_zero List.insertNth_zero
@[simp]
theorem insertNth_succ_nil (n : ℕ) (a : α) : insertNth (n + 1) a [] = [] :=
rfl
#align list.insert_nth_succ_nil List.insertNth_succ_nil
@[simp]
theorem insertNth_succ_cons (s : List α) (hd x : α) (n : ℕ) :
insertNth (n + 1) x (hd :: s) = hd :: insertNth n x s :=
rfl
#align list.insert_nth_succ_cons List.insertNth_succ_cons
theorem length_insertNth : ∀ n as, n ≤ length as → length (insertNth n a as) = length as + 1
| 0, _, _ => rfl
| _ + 1, [], h => (Nat.not_succ_le_zero _ h).elim
| n + 1, _ :: as, h => congr_arg Nat.succ <| length_insertNth n as (Nat.le_of_succ_le_succ h)
#align list.length_insert_nth List.length_insertNth
theorem eraseIdx_insertNth (n : ℕ) (l : List α) : (l.insertNth n a).eraseIdx n = l := by
rw [eraseIdx_eq_modifyNthTail, insertNth, modifyNthTail_modifyNthTail_same]
exact modifyNthTail_id _ _
#align list.remove_nth_insert_nth List.eraseIdx_insertNth
@[deprecated (since := "2024-05-04")] alias removeNth_insertNth := eraseIdx_insertNth
theorem insertNth_eraseIdx_of_ge :
∀ n m as,
n < length as → n ≤ m → insertNth m a (as.eraseIdx n) = (as.insertNth (m + 1) a).eraseIdx n
| 0, 0, [], has, _ => (lt_irrefl _ has).elim
| 0, 0, _ :: as, _, _ => by simp [eraseIdx, insertNth]
| 0, m + 1, a :: as, _, _ => rfl
| n + 1, m + 1, a :: as, has, hmn =>
congr_arg (cons a) <|
insertNth_eraseIdx_of_ge n m as (Nat.lt_of_succ_lt_succ has) (Nat.le_of_succ_le_succ hmn)
#align list.insert_nth_remove_nth_of_ge List.insertNth_eraseIdx_of_ge
@[deprecated (since := "2024-05-04")] alias insertNth_removeNth_of_ge := insertNth_eraseIdx_of_ge
theorem insertNth_eraseIdx_of_le :
∀ n m as,
n < length as → m ≤ n → insertNth m a (as.eraseIdx n) = (as.insertNth m a).eraseIdx (n + 1)
| _, 0, _ :: _, _, _ => rfl
| n + 1, m + 1, a :: as, has, hmn =>
congr_arg (cons a) <|
insertNth_eraseIdx_of_le n m as (Nat.lt_of_succ_lt_succ has) (Nat.le_of_succ_le_succ hmn)
#align list.insert_nth_remove_nth_of_le List.insertNth_eraseIdx_of_le
@[deprecated (since := "2024-05-04")] alias insertNth_removeNth_of_le := insertNth_eraseIdx_of_le
theorem insertNth_comm (a b : α) :
∀ (i j : ℕ) (l : List α) (_ : i ≤ j) (_ : j ≤ length l),
(l.insertNth i a).insertNth (j + 1) b = (l.insertNth j b).insertNth i a
| 0, j, l => by simp [insertNth]
| i + 1, 0, l => fun h => (Nat.not_lt_zero _ h).elim
| i + 1, j + 1, [] => by simp
| i + 1, j + 1, c :: l => fun h₀ h₁ => by
simp only [insertNth_succ_cons, cons.injEq, true_and]
exact insertNth_comm a b i j l (Nat.le_of_succ_le_succ h₀) (Nat.le_of_succ_le_succ h₁)
#align list.insert_nth_comm List.insertNth_comm
theorem mem_insertNth {a b : α} :
∀ {n : ℕ} {l : List α} (_ : n ≤ l.length), a ∈ l.insertNth n b ↔ a = b ∨ a ∈ l
| 0, as, _ => by simp
| n + 1, [], h => (Nat.not_succ_le_zero _ h).elim
| n + 1, a' :: as, h => by
rw [List.insertNth_succ_cons, mem_cons, mem_insertNth (Nat.le_of_succ_le_succ h),
← or_assoc, @or_comm (a = a'), or_assoc, mem_cons]
#align list.mem_insert_nth List.mem_insertNth
| Mathlib/Data/List/InsertNth.lean | 103 | 112 | theorem insertNth_of_length_lt (l : List α) (x : α) (n : ℕ) (h : l.length < n) :
insertNth n x l = l := by |
induction' l with hd tl IH generalizing n
· cases n
· simp at h
· simp
· cases n
· simp at h
· simp only [Nat.succ_lt_succ_iff, length] at h
simpa using IH _ h
|
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 : ℕ)
namespace IntFractPair
theorem coe_of_rat_eq : ((IntFractPair.of q).mapFr (↑) : IntFractPair K) = IntFractPair.of v := by
simp [IntFractPair.of, v_eq_q]
#align generalized_continued_fraction.int_fract_pair.coe_of_rat_eq GeneralizedContinuedFraction.IntFractPair.coe_of_rat_eq
theorem coe_stream_nth_rat_eq :
((IntFractPair.stream q n).map (mapFr (↑)) : Option <| IntFractPair K) =
IntFractPair.stream v n := by
induction n with
| zero =>
-- Porting note: was
-- simp [IntFractPair.stream, coe_of_rat_eq v_eq_q]
simp only [IntFractPair.stream, Option.map_some', coe_of_rat_eq v_eq_q]
| succ n IH =>
rw [v_eq_q] at IH
cases stream_q_nth_eq : IntFractPair.stream q n with
| none => simp [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq]
| some ifp_n =>
cases' ifp_n with b fr
cases' Decidable.em (fr = 0) with fr_zero fr_ne_zero
· simp [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq, fr_zero]
· replace IH : some (IntFractPair.mk b (fr : K)) = IntFractPair.stream (↑q) n := by
rwa [stream_q_nth_eq] at IH
have : (fr : K)⁻¹ = ((fr⁻¹ : ℚ) : K) := by norm_cast
have coe_of_fr := coe_of_rat_eq this
simpa [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq, fr_ne_zero]
#align generalized_continued_fraction.int_fract_pair.coe_stream_nth_rat_eq GeneralizedContinuedFraction.IntFractPair.coe_stream_nth_rat_eq
| Mathlib/Algebra/ContinuedFractions/Computation/TerminatesIffRat.lean | 197 | 200 | theorem coe_stream'_rat_eq :
((IntFractPair.stream q).map (Option.map (mapFr (↑))) : Stream' <| Option <| IntFractPair K) =
IntFractPair.stream v := by |
funext n; exact IntFractPair.coe_stream_nth_rat_eq v_eq_q n
|
import Mathlib.Data.List.OfFn
import Mathlib.Data.List.Range
#align_import data.list.fin_range from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
universe u
namespace List
variable {α : Type u}
@[simp]
theorem map_coe_finRange (n : ℕ) : ((finRange n) : List (Fin n)).map (Fin.val) = List.range n := by
simp_rw [finRange, map_pmap, pmap_eq_map]
exact List.map_id _
#align list.map_coe_fin_range List.map_coe_finRange
theorem finRange_succ_eq_map (n : ℕ) : finRange n.succ = 0 :: (finRange n).map Fin.succ := by
apply map_injective_iff.mpr Fin.val_injective
rw [map_cons, map_coe_finRange, range_succ_eq_map, Fin.val_zero, ← map_coe_finRange, map_map,
map_map]
simp only [Function.comp, Fin.val_succ]
#align list.fin_range_succ_eq_map List.finRange_succ_eq_map
theorem finRange_succ (n : ℕ) :
finRange n.succ = (finRange n |>.map Fin.castSucc |>.concat (.last _)) := by
apply map_injective_iff.mpr Fin.val_injective
simp [range_succ, Function.comp_def]
-- Porting note: `map_nth_le` moved to `List.finRange_map_get` in Data.List.Range
theorem ofFn_eq_pmap {n} {f : Fin n → α} :
ofFn f = pmap (fun i hi => f ⟨i, hi⟩) (range n) fun _ => mem_range.1 := by
rw [pmap_eq_map_attach]
exact ext_get (by simp) fun i hi1 hi2 => by simp [get_ofFn f ⟨i, hi1⟩]
#align list.of_fn_eq_pmap List.ofFn_eq_pmap
theorem ofFn_id (n) : ofFn id = finRange n :=
ofFn_eq_pmap
#align list.of_fn_id List.ofFn_id
theorem ofFn_eq_map {n} {f : Fin n → α} : ofFn f = (finRange n).map f := by
rw [← ofFn_id, map_ofFn, Function.comp_id]
#align list.of_fn_eq_map List.ofFn_eq_map
theorem nodup_ofFn_ofInjective {n} {f : Fin n → α} (hf : Function.Injective f) :
Nodup (ofFn f) := by
rw [ofFn_eq_pmap]
exact (nodup_range n).pmap fun _ _ _ _ H => Fin.val_eq_of_eq <| hf H
#align list.nodup_of_fn_of_injective List.nodup_ofFn_ofInjective
| Mathlib/Data/List/FinRange.lean | 64 | 72 | theorem nodup_ofFn {n} {f : Fin n → α} : Nodup (ofFn f) ↔ Function.Injective f := by |
refine ⟨?_, nodup_ofFn_ofInjective⟩
refine Fin.consInduction ?_ (fun x₀ xs ih => ?_) f
· intro _
exact Function.injective_of_subsingleton _
· intro h
rw [Fin.cons_injective_iff]
simp_rw [ofFn_succ, Fin.cons_succ, nodup_cons, Fin.cons_zero, mem_ofFn] at h
exact h.imp_right ih
|
import Mathlib.Probability.Independence.Basic
import Mathlib.Probability.Independence.Conditional
#align_import probability.independence.zero_one from "leanprover-community/mathlib"@"2f8347015b12b0864dfaf366ec4909eb70c78740"
open MeasureTheory MeasurableSpace
open scoped MeasureTheory ENNReal
namespace ProbabilityTheory
variable {α Ω ι : Type*} {_mα : MeasurableSpace α} {s : ι → MeasurableSpace Ω}
{m m0 : MeasurableSpace Ω} {κ : kernel α Ω} {μα : Measure α} {μ : Measure Ω}
theorem kernel.measure_eq_zero_or_one_or_top_of_indepSet_self {t : Set Ω}
(h_indep : kernel.IndepSet t t κ μα) :
∀ᵐ a ∂μα, κ a t = 0 ∨ κ a t = 1 ∨ κ a t = ∞ := by
specialize h_indep t t (measurableSet_generateFrom (Set.mem_singleton t))
(measurableSet_generateFrom (Set.mem_singleton t))
filter_upwards [h_indep] with a ha
by_cases h0 : κ a t = 0
· exact Or.inl h0
by_cases h_top : κ a t = ∞
· exact Or.inr (Or.inr h_top)
rw [← one_mul (κ a (t ∩ t)), Set.inter_self, ENNReal.mul_eq_mul_right h0 h_top] at ha
exact Or.inr (Or.inl ha.symm)
theorem measure_eq_zero_or_one_or_top_of_indepSet_self {t : Set Ω}
(h_indep : IndepSet t t μ) : μ t = 0 ∨ μ t = 1 ∨ μ t = ∞ := by
simpa only [ae_dirac_eq, Filter.eventually_pure]
using kernel.measure_eq_zero_or_one_or_top_of_indepSet_self h_indep
#align probability_theory.measure_eq_zero_or_one_or_top_of_indep_set_self ProbabilityTheory.measure_eq_zero_or_one_or_top_of_indepSet_self
theorem kernel.measure_eq_zero_or_one_of_indepSet_self [∀ a, IsFiniteMeasure (κ a)] {t : Set Ω}
(h_indep : IndepSet t t κ μα) :
∀ᵐ a ∂μα, κ a t = 0 ∨ κ a t = 1 := by
filter_upwards [measure_eq_zero_or_one_or_top_of_indepSet_self h_indep] with a h_0_1_top
simpa only [measure_ne_top (κ a), or_false] using h_0_1_top
theorem measure_eq_zero_or_one_of_indepSet_self [IsFiniteMeasure μ] {t : Set Ω}
(h_indep : IndepSet t t μ) : μ t = 0 ∨ μ t = 1 := by
simpa only [ae_dirac_eq, Filter.eventually_pure]
using kernel.measure_eq_zero_or_one_of_indepSet_self h_indep
#align probability_theory.measure_eq_zero_or_one_of_indep_set_self ProbabilityTheory.measure_eq_zero_or_one_of_indepSet_self
theorem condexp_eq_zero_or_one_of_condIndepSet_self
[StandardBorelSpace Ω] [Nonempty Ω]
(hm : m ≤ m0) [hμ : IsFiniteMeasure μ] {t : Set Ω} (ht : MeasurableSet t)
(h_indep : CondIndepSet m hm t t μ) :
∀ᵐ ω ∂μ, (μ⟦t | m⟧) ω = 0 ∨ (μ⟦t | m⟧) ω = 1 := by
have h := ae_of_ae_trim hm (kernel.measure_eq_zero_or_one_of_indepSet_self h_indep)
filter_upwards [condexpKernel_ae_eq_condexp hm ht, h] with ω hω_eq hω
rw [← hω_eq, ENNReal.toReal_eq_zero_iff, ENNReal.toReal_eq_one_iff]
cases hω with
| inl h => exact Or.inl (Or.inl h)
| inr h => exact Or.inr h
variable [IsMarkovKernel κ] [IsProbabilityMeasure μ]
open Filter
theorem kernel.indep_biSup_compl (h_le : ∀ n, s n ≤ m0) (h_indep : iIndep s κ μα) (t : Set ι) :
Indep (⨆ n ∈ t, s n) (⨆ n ∈ tᶜ, s n) κ μα :=
indep_iSup_of_disjoint h_le h_indep disjoint_compl_right
theorem indep_biSup_compl (h_le : ∀ n, s n ≤ m0) (h_indep : iIndep s μ) (t : Set ι) :
Indep (⨆ n ∈ t, s n) (⨆ n ∈ tᶜ, s n) μ :=
kernel.indep_biSup_compl h_le h_indep t
#align probability_theory.indep_bsupr_compl ProbabilityTheory.indep_biSup_compl
theorem condIndep_biSup_compl [StandardBorelSpace Ω] [Nonempty Ω]
(hm : m ≤ m0) [IsFiniteMeasure μ]
(h_le : ∀ n, s n ≤ m0) (h_indep : iCondIndep m hm s μ) (t : Set ι) :
CondIndep m (⨆ n ∈ t, s n) (⨆ n ∈ tᶜ, s n) hm μ :=
kernel.indep_biSup_compl h_le h_indep t
section Abstract
variable {α : Type*} {p : Set ι → Prop} {f : Filter ι} {ns : α → Set ι}
| Mathlib/Probability/Independence/ZeroOne.lean | 109 | 115 | theorem kernel.indep_biSup_limsup (h_le : ∀ n, s n ≤ m0) (h_indep : iIndep s κ μα)
(hf : ∀ t, p t → tᶜ ∈ f) {t : Set ι} (ht : p t) :
Indep (⨆ n ∈ t, s n) (limsup s f) κ μα := by |
refine indep_of_indep_of_le_right (indep_biSup_compl h_le h_indep t) ?_
refine limsSup_le_of_le (by isBoundedDefault) ?_
simp only [Set.mem_compl_iff, eventually_map]
exact eventually_of_mem (hf t ht) le_iSup₂
|
import Mathlib.AlgebraicGeometry.Gluing
import Mathlib.CategoryTheory.Limits.Opposites
import Mathlib.AlgebraicGeometry.AffineScheme
import Mathlib.CategoryTheory.Limits.Shapes.Diagonal
#align_import algebraic_geometry.pullbacks from "leanprover-community/mathlib"@"7316286ff2942aa14e540add9058c6b0aa1c8070"
set_option linter.uppercaseLean3 false
universe v u
noncomputable section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry
namespace AlgebraicGeometry.Scheme
namespace Pullback
variable {C : Type u} [Category.{v} C]
variable {X Y Z : Scheme.{u}} (𝒰 : OpenCover.{u} X) (f : X ⟶ Z) (g : Y ⟶ Z)
variable [∀ i, HasPullback (𝒰.map i ≫ f) g]
def v (i j : 𝒰.J) : Scheme :=
pullback ((pullback.fst : pullback (𝒰.map i ≫ f) g ⟶ _) ≫ 𝒰.map i) (𝒰.map j)
#align algebraic_geometry.Scheme.pullback.V AlgebraicGeometry.Scheme.Pullback.v
def t (i j : 𝒰.J) : v 𝒰 f g i j ⟶ v 𝒰 f g j i := by
have : HasPullback (pullback.snd ≫ 𝒰.map i ≫ f) g :=
hasPullback_assoc_symm (𝒰.map j) (𝒰.map i) (𝒰.map i ≫ f) g
have : HasPullback (pullback.snd ≫ 𝒰.map j ≫ f) g :=
hasPullback_assoc_symm (𝒰.map i) (𝒰.map j) (𝒰.map j ≫ f) g
refine (pullbackSymmetry ..).hom ≫ (pullbackAssoc ..).inv ≫ ?_
refine ?_ ≫ (pullbackAssoc ..).hom ≫ (pullbackSymmetry ..).hom
refine pullback.map _ _ _ _ (pullbackSymmetry _ _).hom (𝟙 _) (𝟙 _) ?_ ?_
· rw [pullbackSymmetry_hom_comp_snd_assoc, pullback.condition_assoc, Category.comp_id]
· rw [Category.comp_id, Category.id_comp]
#align algebraic_geometry.Scheme.pullback.t AlgebraicGeometry.Scheme.Pullback.t
@[simp, reassoc]
theorem t_fst_fst (i j : 𝒰.J) : t 𝒰 f g i j ≫ pullback.fst ≫ pullback.fst = pullback.snd := by
simp only [t, Category.assoc, pullbackSymmetry_hom_comp_fst_assoc, pullbackAssoc_hom_snd_fst,
pullback.lift_fst_assoc, pullbackSymmetry_hom_comp_snd, pullbackAssoc_inv_fst_fst,
pullbackSymmetry_hom_comp_fst]
#align algebraic_geometry.Scheme.pullback.t_fst_fst AlgebraicGeometry.Scheme.Pullback.t_fst_fst
@[simp, reassoc]
theorem t_fst_snd (i j : 𝒰.J) :
t 𝒰 f g i j ≫ pullback.fst ≫ pullback.snd = pullback.fst ≫ pullback.snd := by
simp only [t, Category.assoc, pullbackSymmetry_hom_comp_fst_assoc, pullbackAssoc_hom_snd_snd,
pullback.lift_snd, Category.comp_id, pullbackAssoc_inv_snd, pullbackSymmetry_hom_comp_snd_assoc]
#align algebraic_geometry.Scheme.pullback.t_fst_snd AlgebraicGeometry.Scheme.Pullback.t_fst_snd
@[simp, reassoc]
theorem t_snd (i j : 𝒰.J) : t 𝒰 f g i j ≫ pullback.snd = pullback.fst ≫ pullback.fst := by
simp only [t, Category.assoc, pullbackSymmetry_hom_comp_snd, pullbackAssoc_hom_fst,
pullback.lift_fst_assoc, pullbackSymmetry_hom_comp_fst, pullbackAssoc_inv_fst_snd,
pullbackSymmetry_hom_comp_snd_assoc]
#align algebraic_geometry.Scheme.pullback.t_snd AlgebraicGeometry.Scheme.Pullback.t_snd
theorem t_id (i : 𝒰.J) : t 𝒰 f g i i = 𝟙 _ := by
apply pullback.hom_ext <;> rw [Category.id_comp]
· apply pullback.hom_ext
· rw [← cancel_mono (𝒰.map i)]; simp only [pullback.condition, Category.assoc, t_fst_fst]
· simp only [Category.assoc, t_fst_snd]
· rw [← cancel_mono (𝒰.map i)]; simp only [pullback.condition, t_snd, Category.assoc]
#align algebraic_geometry.Scheme.pullback.t_id AlgebraicGeometry.Scheme.Pullback.t_id
abbrev fV (i j : 𝒰.J) : v 𝒰 f g i j ⟶ pullback (𝒰.map i ≫ f) g :=
pullback.fst
#align algebraic_geometry.Scheme.pullback.fV AlgebraicGeometry.Scheme.Pullback.fV
def t' (i j k : 𝒰.J) :
pullback (fV 𝒰 f g i j) (fV 𝒰 f g i k) ⟶ pullback (fV 𝒰 f g j k) (fV 𝒰 f g j i) := by
refine (pullbackRightPullbackFstIso ..).hom ≫ ?_
refine ?_ ≫ (pullbackSymmetry _ _).hom
refine ?_ ≫ (pullbackRightPullbackFstIso ..).inv
refine pullback.map _ _ _ _ (t 𝒰 f g i j) (𝟙 _) (𝟙 _) ?_ ?_
· simp_rw [Category.comp_id, t_fst_fst_assoc, ← pullback.condition]
· rw [Category.comp_id, Category.id_comp]
#align algebraic_geometry.Scheme.pullback.t' AlgebraicGeometry.Scheme.Pullback.t'
@[simp, reassoc]
theorem t'_fst_fst_fst (i j k : 𝒰.J) :
t' 𝒰 f g i j k ≫ pullback.fst ≫ pullback.fst ≫ pullback.fst = pullback.fst ≫ pullback.snd := by
simp only [t', Category.assoc, pullbackSymmetry_hom_comp_fst_assoc,
pullbackRightPullbackFstIso_inv_snd_fst_assoc, pullback.lift_fst_assoc, t_fst_fst,
pullbackRightPullbackFstIso_hom_fst_assoc]
#align algebraic_geometry.Scheme.pullback.t'_fst_fst_fst AlgebraicGeometry.Scheme.Pullback.t'_fst_fst_fst
@[simp, reassoc]
theorem t'_fst_fst_snd (i j k : 𝒰.J) :
t' 𝒰 f g i j k ≫ pullback.fst ≫ pullback.fst ≫ pullback.snd =
pullback.fst ≫ pullback.fst ≫ pullback.snd := by
simp only [t', Category.assoc, pullbackSymmetry_hom_comp_fst_assoc,
pullbackRightPullbackFstIso_inv_snd_fst_assoc, pullback.lift_fst_assoc, t_fst_snd,
pullbackRightPullbackFstIso_hom_fst_assoc]
#align algebraic_geometry.Scheme.pullback.t'_fst_fst_snd AlgebraicGeometry.Scheme.Pullback.t'_fst_fst_snd
@[simp, reassoc]
theorem t'_fst_snd (i j k : 𝒰.J) :
t' 𝒰 f g i j k ≫ pullback.fst ≫ pullback.snd = pullback.snd ≫ pullback.snd := by
simp only [t', Category.assoc, pullbackSymmetry_hom_comp_fst_assoc,
pullbackRightPullbackFstIso_inv_snd_snd, pullback.lift_snd, Category.comp_id,
pullbackRightPullbackFstIso_hom_snd]
#align algebraic_geometry.Scheme.pullback.t'_fst_snd AlgebraicGeometry.Scheme.Pullback.t'_fst_snd
@[simp, reassoc]
theorem t'_snd_fst_fst (i j k : 𝒰.J) :
t' 𝒰 f g i j k ≫ pullback.snd ≫ pullback.fst ≫ pullback.fst = pullback.fst ≫ pullback.snd := by
simp only [t', Category.assoc, pullbackSymmetry_hom_comp_snd_assoc,
pullbackRightPullbackFstIso_inv_fst_assoc, pullback.lift_fst_assoc, t_fst_fst,
pullbackRightPullbackFstIso_hom_fst_assoc]
#align algebraic_geometry.Scheme.pullback.t'_snd_fst_fst AlgebraicGeometry.Scheme.Pullback.t'_snd_fst_fst
@[simp, reassoc]
theorem t'_snd_fst_snd (i j k : 𝒰.J) :
t' 𝒰 f g i j k ≫ pullback.snd ≫ pullback.fst ≫ pullback.snd =
pullback.fst ≫ pullback.fst ≫ pullback.snd := by
simp only [t', Category.assoc, pullbackSymmetry_hom_comp_snd_assoc,
pullbackRightPullbackFstIso_inv_fst_assoc, pullback.lift_fst_assoc, t_fst_snd,
pullbackRightPullbackFstIso_hom_fst_assoc]
#align algebraic_geometry.Scheme.pullback.t'_snd_fst_snd AlgebraicGeometry.Scheme.Pullback.t'_snd_fst_snd
@[simp, reassoc]
theorem t'_snd_snd (i j k : 𝒰.J) :
t' 𝒰 f g i j k ≫ pullback.snd ≫ pullback.snd = pullback.fst ≫ pullback.fst ≫ pullback.fst := by
simp only [t', Category.assoc, pullbackSymmetry_hom_comp_snd_assoc,
pullbackRightPullbackFstIso_inv_fst_assoc, pullback.lift_fst_assoc, t_snd,
pullbackRightPullbackFstIso_hom_fst_assoc]
#align algebraic_geometry.Scheme.pullback.t'_snd_snd AlgebraicGeometry.Scheme.Pullback.t'_snd_snd
theorem cocycle_fst_fst_fst (i j k : 𝒰.J) :
t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.fst ≫ pullback.fst ≫ pullback.fst =
pullback.fst ≫ pullback.fst ≫ pullback.fst := by
simp only [t'_fst_fst_fst, t'_fst_snd, t'_snd_snd]
#align algebraic_geometry.Scheme.pullback.cocycle_fst_fst_fst AlgebraicGeometry.Scheme.Pullback.cocycle_fst_fst_fst
theorem cocycle_fst_fst_snd (i j k : 𝒰.J) :
t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.fst ≫ pullback.fst ≫ pullback.snd =
pullback.fst ≫ pullback.fst ≫ pullback.snd := by
simp only [t'_fst_fst_snd]
#align algebraic_geometry.Scheme.pullback.cocycle_fst_fst_snd AlgebraicGeometry.Scheme.Pullback.cocycle_fst_fst_snd
theorem cocycle_fst_snd (i j k : 𝒰.J) :
t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.fst ≫ pullback.snd =
pullback.fst ≫ pullback.snd := by
simp only [t'_fst_snd, t'_snd_snd, t'_fst_fst_fst]
#align algebraic_geometry.Scheme.pullback.cocycle_fst_snd AlgebraicGeometry.Scheme.Pullback.cocycle_fst_snd
theorem cocycle_snd_fst_fst (i j k : 𝒰.J) :
t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.snd ≫ pullback.fst ≫ pullback.fst =
pullback.snd ≫ pullback.fst ≫ pullback.fst := by
rw [← cancel_mono (𝒰.map i)]
simp only [pullback.condition_assoc, t'_snd_fst_fst, t'_fst_snd, t'_snd_snd]
#align algebraic_geometry.Scheme.pullback.cocycle_snd_fst_fst AlgebraicGeometry.Scheme.Pullback.cocycle_snd_fst_fst
theorem cocycle_snd_fst_snd (i j k : 𝒰.J) :
t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.snd ≫ pullback.fst ≫ pullback.snd =
pullback.snd ≫ pullback.fst ≫ pullback.snd := by
simp only [pullback.condition_assoc, t'_snd_fst_snd]
#align algebraic_geometry.Scheme.pullback.cocycle_snd_fst_snd AlgebraicGeometry.Scheme.Pullback.cocycle_snd_fst_snd
theorem cocycle_snd_snd (i j k : 𝒰.J) :
t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.snd ≫ pullback.snd =
pullback.snd ≫ pullback.snd := by
simp only [t'_snd_snd, t'_fst_fst_fst, t'_fst_snd]
#align algebraic_geometry.Scheme.pullback.cocycle_snd_snd AlgebraicGeometry.Scheme.Pullback.cocycle_snd_snd
-- `by tidy` should solve it, but it times out.
theorem cocycle (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j = 𝟙 _ := by
apply pullback.hom_ext <;> rw [Category.id_comp]
· apply pullback.hom_ext
· apply pullback.hom_ext
· simp_rw [Category.assoc, cocycle_fst_fst_fst 𝒰 f g i j k]
· simp_rw [Category.assoc, cocycle_fst_fst_snd 𝒰 f g i j k]
· simp_rw [Category.assoc, cocycle_fst_snd 𝒰 f g i j k]
· apply pullback.hom_ext
· apply pullback.hom_ext
· simp_rw [Category.assoc, cocycle_snd_fst_fst 𝒰 f g i j k]
· simp_rw [Category.assoc, cocycle_snd_fst_snd 𝒰 f g i j k]
· simp_rw [Category.assoc, cocycle_snd_snd 𝒰 f g i j k]
#align algebraic_geometry.Scheme.pullback.cocycle AlgebraicGeometry.Scheme.Pullback.cocycle
@[simps U V f t t', simps (config := .lemmasOnly) J]
def gluing : Scheme.GlueData.{u} where
J := 𝒰.J
U i := pullback (𝒰.map i ≫ f) g
V := fun ⟨i, j⟩ => v 𝒰 f g i j
-- `p⁻¹(Uᵢ ∩ Uⱼ)` where `p : Uᵢ ×[Z] Y ⟶ Uᵢ ⟶ X`.
f i j := pullback.fst
f_id i := inferInstance
f_open := inferInstance
t i j := t 𝒰 f g i j
t_id i := t_id 𝒰 f g i
t' i j k := t' 𝒰 f g i j k
t_fac i j k := by
apply pullback.hom_ext
on_goal 1 => apply pullback.hom_ext
all_goals
simp only [t'_snd_fst_fst, t'_snd_fst_snd, t'_snd_snd, t_fst_fst, t_fst_snd, t_snd,
Category.assoc]
cocycle i j k := cocycle 𝒰 f g i j k
#align algebraic_geometry.Scheme.pullback.gluing AlgebraicGeometry.Scheme.Pullback.gluing
@[simp]
lemma gluing_ι (j : 𝒰.J) :
(gluing 𝒰 f g).ι j = Multicoequalizer.π (gluing 𝒰 f g).diagram j := rfl
def p1 : (gluing 𝒰 f g).glued ⟶ X := by
apply Multicoequalizer.desc (gluing 𝒰 f g).diagram _ fun i ↦ pullback.fst ≫ 𝒰.map i
simp [t_fst_fst_assoc, ← pullback.condition]
#align algebraic_geometry.Scheme.pullback.p1 AlgebraicGeometry.Scheme.Pullback.p1
def p2 : (gluing 𝒰 f g).glued ⟶ Y := by
apply Multicoequalizer.desc _ _ fun i ↦ pullback.snd
simp [t_fst_snd]
#align algebraic_geometry.Scheme.pullback.p2 AlgebraicGeometry.Scheme.Pullback.p2
theorem p_comm : p1 𝒰 f g ≫ f = p2 𝒰 f g ≫ g := by
apply Multicoequalizer.hom_ext
simp [p1, p2, pullback.condition]
#align algebraic_geometry.Scheme.pullback.p_comm AlgebraicGeometry.Scheme.Pullback.p_comm
variable (s : PullbackCone f g)
def gluedLiftPullbackMap (i j : 𝒰.J) :
pullback ((𝒰.pullbackCover s.fst).map i) ((𝒰.pullbackCover s.fst).map j) ⟶
(gluing 𝒰 f g).V ⟨i, j⟩ := by
refine (pullbackRightPullbackFstIso _ _ _).hom ≫ ?_
refine pullback.map _ _ _ _ ?_ (𝟙 _) (𝟙 _) ?_ ?_
· exact (pullbackSymmetry _ _).hom ≫
pullback.map _ _ _ _ (𝟙 _) s.snd f (Category.id_comp _).symm s.condition
· simpa using pullback.condition
· simp only [Category.comp_id, Category.id_comp]
#align algebraic_geometry.Scheme.pullback.glued_lift_pullback_map AlgebraicGeometry.Scheme.Pullback.gluedLiftPullbackMap
@[reassoc]
theorem gluedLiftPullbackMap_fst (i j : 𝒰.J) :
gluedLiftPullbackMap 𝒰 f g s i j ≫ pullback.fst =
pullback.fst ≫
(pullbackSymmetry _ _).hom ≫
pullback.map _ _ _ _ (𝟙 _) s.snd f (Category.id_comp _).symm s.condition := by
simp [gluedLiftPullbackMap]
#align algebraic_geometry.Scheme.pullback.glued_lift_pullback_map_fst AlgebraicGeometry.Scheme.Pullback.gluedLiftPullbackMap_fst
@[reassoc]
theorem gluedLiftPullbackMap_snd (i j : 𝒰.J) :
gluedLiftPullbackMap 𝒰 f g s i j ≫ pullback.snd = pullback.snd ≫ pullback.snd := by
simp [gluedLiftPullbackMap]
#align algebraic_geometry.Scheme.pullback.glued_lift_pullback_map_snd AlgebraicGeometry.Scheme.Pullback.gluedLiftPullbackMap_snd
def gluedLift : s.pt ⟶ (gluing 𝒰 f g).glued := by
fapply (𝒰.pullbackCover s.fst).glueMorphisms
· exact fun i ↦ (pullbackSymmetry _ _).hom ≫
pullback.map _ _ _ _ (𝟙 _) s.snd f (Category.id_comp _).symm s.condition ≫ (gluing 𝒰 f g).ι i
intro i j
rw [← gluedLiftPullbackMap_fst_assoc, ← gluing_f, ← (gluing 𝒰 f g).glue_condition i j,
gluing_t, gluing_f]
simp_rw [← Category.assoc]
congr 1
apply pullback.hom_ext <;> simp_rw [Category.assoc]
· rw [t_fst_fst, gluedLiftPullbackMap_snd]
congr 1
rw [← Iso.inv_comp_eq, pullbackSymmetry_inv_comp_snd, pullback.lift_fst, Category.comp_id]
· rw [t_fst_snd, gluedLiftPullbackMap_fst_assoc, pullback.lift_snd, pullback.lift_snd]
simp_rw [pullbackSymmetry_hom_comp_snd_assoc]
exact pullback.condition_assoc _
#align algebraic_geometry.Scheme.pullback.glued_lift AlgebraicGeometry.Scheme.Pullback.gluedLift
theorem gluedLift_p1 : gluedLift 𝒰 f g s ≫ p1 𝒰 f g = s.fst := by
rw [← cancel_epi (𝒰.pullbackCover s.fst).fromGlued]
apply Multicoequalizer.hom_ext
intro b
simp_rw [OpenCover.fromGlued, Multicoequalizer.π_desc_assoc, gluedLift, ← Category.assoc]
simp_rw [(𝒰.pullbackCover s.fst).ι_glueMorphisms]
simp [p1, pullback.condition]
#align algebraic_geometry.Scheme.pullback.glued_lift_p1 AlgebraicGeometry.Scheme.Pullback.gluedLift_p1
| Mathlib/AlgebraicGeometry/Pullbacks.lean | 323 | 329 | theorem gluedLift_p2 : gluedLift 𝒰 f g s ≫ p2 𝒰 f g = s.snd := by |
rw [← cancel_epi (𝒰.pullbackCover s.fst).fromGlued]
apply Multicoequalizer.hom_ext
intro b
simp_rw [OpenCover.fromGlued, Multicoequalizer.π_desc_assoc, gluedLift, ← Category.assoc]
simp_rw [(𝒰.pullbackCover s.fst).ι_glueMorphisms]
simp [p2, pullback.condition]
|
import Mathlib.Data.Nat.Defs
import Mathlib.Order.Interval.Set.Basic
import Mathlib.Tactic.Monotonicity.Attr
#align_import data.nat.log from "leanprover-community/mathlib"@"3e00d81bdcbf77c8188bbd18f5524ddc3ed8cac6"
namespace Nat
--@[pp_nodot] porting note: unknown attribute
def log (b : ℕ) : ℕ → ℕ
| n => if h : b ≤ n ∧ 1 < b then log b (n / b) + 1 else 0
decreasing_by
-- putting this in the def triggers the `unusedHavesSuffices` linter:
-- https://github.com/leanprover-community/batteries/issues/428
have : n / b < n := div_lt_self ((Nat.zero_lt_one.trans h.2).trans_le h.1) h.2
decreasing_trivial
#align nat.log Nat.log
@[simp]
| Mathlib/Data/Nat/Log.lean | 42 | 44 | theorem log_eq_zero_iff {b n : ℕ} : log b n = 0 ↔ n < b ∨ b ≤ 1 := by |
rw [log, dite_eq_right_iff]
simp only [Nat.add_eq_zero_iff, Nat.one_ne_zero, and_false, imp_false, not_and_or, not_le, not_lt]
|
import Mathlib.Algebra.BigOperators.Option
import Mathlib.Analysis.BoxIntegral.Box.Basic
import Mathlib.Data.Set.Pairwise.Lattice
#align_import analysis.box_integral.partition.basic from "leanprover-community/mathlib"@"84dc0bd6619acaea625086d6f53cb35cdd554219"
open Set Finset Function
open scoped Classical
open NNReal
noncomputable section
namespace BoxIntegral
variable {ι : Type*}
structure Prepartition (I : Box ι) where
boxes : Finset (Box ι)
le_of_mem' : ∀ J ∈ boxes, J ≤ I
pairwiseDisjoint : Set.Pairwise (↑boxes) (Disjoint on ((↑) : Box ι → Set (ι → ℝ)))
#align box_integral.prepartition BoxIntegral.Prepartition
namespace Prepartition
variable {I J J₁ J₂ : Box ι} (π : Prepartition I) {π₁ π₂ : Prepartition I} {x : ι → ℝ}
instance : Membership (Box ι) (Prepartition I) :=
⟨fun J π => J ∈ π.boxes⟩
@[simp]
theorem mem_boxes : J ∈ π.boxes ↔ J ∈ π := Iff.rfl
#align box_integral.prepartition.mem_boxes BoxIntegral.Prepartition.mem_boxes
@[simp]
theorem mem_mk {s h₁ h₂} : J ∈ (mk s h₁ h₂ : Prepartition I) ↔ J ∈ s := Iff.rfl
#align box_integral.prepartition.mem_mk BoxIntegral.Prepartition.mem_mk
theorem disjoint_coe_of_mem (h₁ : J₁ ∈ π) (h₂ : J₂ ∈ π) (h : J₁ ≠ J₂) :
Disjoint (J₁ : Set (ι → ℝ)) J₂ :=
π.pairwiseDisjoint h₁ h₂ h
#align box_integral.prepartition.disjoint_coe_of_mem BoxIntegral.Prepartition.disjoint_coe_of_mem
theorem eq_of_mem_of_mem (h₁ : J₁ ∈ π) (h₂ : J₂ ∈ π) (hx₁ : x ∈ J₁) (hx₂ : x ∈ J₂) : J₁ = J₂ :=
by_contra fun H => (π.disjoint_coe_of_mem h₁ h₂ H).le_bot ⟨hx₁, hx₂⟩
#align box_integral.prepartition.eq_of_mem_of_mem BoxIntegral.Prepartition.eq_of_mem_of_mem
theorem eq_of_le_of_le (h₁ : J₁ ∈ π) (h₂ : J₂ ∈ π) (hle₁ : J ≤ J₁) (hle₂ : J ≤ J₂) : J₁ = J₂ :=
π.eq_of_mem_of_mem h₁ h₂ (hle₁ J.upper_mem) (hle₂ J.upper_mem)
#align box_integral.prepartition.eq_of_le_of_le BoxIntegral.Prepartition.eq_of_le_of_le
theorem eq_of_le (h₁ : J₁ ∈ π) (h₂ : J₂ ∈ π) (hle : J₁ ≤ J₂) : J₁ = J₂ :=
π.eq_of_le_of_le h₁ h₂ le_rfl hle
#align box_integral.prepartition.eq_of_le BoxIntegral.Prepartition.eq_of_le
theorem le_of_mem (hJ : J ∈ π) : J ≤ I :=
π.le_of_mem' J hJ
#align box_integral.prepartition.le_of_mem BoxIntegral.Prepartition.le_of_mem
theorem lower_le_lower (hJ : J ∈ π) : I.lower ≤ J.lower :=
Box.antitone_lower (π.le_of_mem hJ)
#align box_integral.prepartition.lower_le_lower BoxIntegral.Prepartition.lower_le_lower
theorem upper_le_upper (hJ : J ∈ π) : J.upper ≤ I.upper :=
Box.monotone_upper (π.le_of_mem hJ)
#align box_integral.prepartition.upper_le_upper BoxIntegral.Prepartition.upper_le_upper
theorem injective_boxes : Function.Injective (boxes : Prepartition I → Finset (Box ι)) := by
rintro ⟨s₁, h₁, h₁'⟩ ⟨s₂, h₂, h₂'⟩ (rfl : s₁ = s₂)
rfl
#align box_integral.prepartition.injective_boxes BoxIntegral.Prepartition.injective_boxes
@[ext]
theorem ext (h : ∀ J, J ∈ π₁ ↔ J ∈ π₂) : π₁ = π₂ :=
injective_boxes <| Finset.ext h
#align box_integral.prepartition.ext BoxIntegral.Prepartition.ext
@[simps]
def single (I J : Box ι) (h : J ≤ I) : Prepartition I :=
⟨{J}, by simpa, by simp⟩
#align box_integral.prepartition.single BoxIntegral.Prepartition.single
@[simp]
theorem mem_single {J'} (h : J ≤ I) : J' ∈ single I J h ↔ J' = J :=
mem_singleton
#align box_integral.prepartition.mem_single BoxIntegral.Prepartition.mem_single
instance : LE (Prepartition I) :=
⟨fun π π' => ∀ ⦃I⦄, I ∈ π → ∃ I' ∈ π', I ≤ I'⟩
instance partialOrder : PartialOrder (Prepartition I) where
le := (· ≤ ·)
le_refl π I hI := ⟨I, hI, le_rfl⟩
le_trans π₁ π₂ π₃ h₁₂ h₂₃ I₁ hI₁ :=
let ⟨I₂, hI₂, hI₁₂⟩ := h₁₂ hI₁
let ⟨I₃, hI₃, hI₂₃⟩ := h₂₃ hI₂
⟨I₃, hI₃, hI₁₂.trans hI₂₃⟩
le_antisymm := by
suffices ∀ {π₁ π₂ : Prepartition I}, π₁ ≤ π₂ → π₂ ≤ π₁ → π₁.boxes ⊆ π₂.boxes from
fun π₁ π₂ h₁ h₂ => injective_boxes (Subset.antisymm (this h₁ h₂) (this h₂ h₁))
intro π₁ π₂ h₁ h₂ J hJ
rcases h₁ hJ with ⟨J', hJ', hle⟩; rcases h₂ hJ' with ⟨J'', hJ'', hle'⟩
obtain rfl : J = J'' := π₁.eq_of_le hJ hJ'' (hle.trans hle')
obtain rfl : J' = J := le_antisymm ‹_› ‹_›
assumption
instance : OrderTop (Prepartition I) where
top := single I I le_rfl
le_top π J hJ := ⟨I, by simp, π.le_of_mem hJ⟩
instance : OrderBot (Prepartition I) where
bot := ⟨∅,
fun _ hJ => (Finset.not_mem_empty _ hJ).elim,
fun _ hJ => (Set.not_mem_empty _ <| Finset.coe_empty ▸ hJ).elim⟩
bot_le _ _ hJ := (Finset.not_mem_empty _ hJ).elim
instance : Inhabited (Prepartition I) := ⟨⊤⟩
theorem le_def : π₁ ≤ π₂ ↔ ∀ J ∈ π₁, ∃ J' ∈ π₂, J ≤ J' := Iff.rfl
#align box_integral.prepartition.le_def BoxIntegral.Prepartition.le_def
@[simp]
theorem mem_top : J ∈ (⊤ : Prepartition I) ↔ J = I :=
mem_singleton
#align box_integral.prepartition.mem_top BoxIntegral.Prepartition.mem_top
@[simp]
theorem top_boxes : (⊤ : Prepartition I).boxes = {I} := rfl
#align box_integral.prepartition.top_boxes BoxIntegral.Prepartition.top_boxes
@[simp]
theorem not_mem_bot : J ∉ (⊥ : Prepartition I) :=
Finset.not_mem_empty _
#align box_integral.prepartition.not_mem_bot BoxIntegral.Prepartition.not_mem_bot
@[simp]
theorem bot_boxes : (⊥ : Prepartition I).boxes = ∅ := rfl
#align box_integral.prepartition.bot_boxes BoxIntegral.Prepartition.bot_boxes
theorem injOn_setOf_mem_Icc_setOf_lower_eq (x : ι → ℝ) :
InjOn (fun J : Box ι => { i | J.lower i = x i }) { J | J ∈ π ∧ x ∈ Box.Icc J } := by
rintro J₁ ⟨h₁, hx₁⟩ J₂ ⟨h₂, hx₂⟩ (H : { i | J₁.lower i = x i } = { i | J₂.lower i = x i })
suffices ∀ i, (Ioc (J₁.lower i) (J₁.upper i) ∩ Ioc (J₂.lower i) (J₂.upper i)).Nonempty by
choose y hy₁ hy₂ using this
exact π.eq_of_mem_of_mem h₁ h₂ hy₁ hy₂
intro i
simp only [Set.ext_iff, mem_setOf] at H
rcases (hx₁.1 i).eq_or_lt with hi₁ | hi₁
· have hi₂ : J₂.lower i = x i := (H _).1 hi₁
have H₁ : x i < J₁.upper i := by simpa only [hi₁] using J₁.lower_lt_upper i
have H₂ : x i < J₂.upper i := by simpa only [hi₂] using J₂.lower_lt_upper i
rw [Ioc_inter_Ioc, hi₁, hi₂, sup_idem, Set.nonempty_Ioc]
exact lt_min H₁ H₂
· have hi₂ : J₂.lower i < x i := (hx₂.1 i).lt_of_ne (mt (H _).2 hi₁.ne)
exact ⟨x i, ⟨hi₁, hx₁.2 i⟩, ⟨hi₂, hx₂.2 i⟩⟩
#align box_integral.prepartition.inj_on_set_of_mem_Icc_set_of_lower_eq BoxIntegral.Prepartition.injOn_setOf_mem_Icc_setOf_lower_eq
theorem card_filter_mem_Icc_le [Fintype ι] (x : ι → ℝ) :
(π.boxes.filter fun J : Box ι => x ∈ Box.Icc J).card ≤ 2 ^ Fintype.card ι := by
rw [← Fintype.card_set]
refine Finset.card_le_card_of_inj_on (fun J : Box ι => { i | J.lower i = x i })
(fun _ _ => Finset.mem_univ _) ?_
simpa only [Finset.mem_filter] using π.injOn_setOf_mem_Icc_setOf_lower_eq x
#align box_integral.prepartition.card_filter_mem_Icc_le BoxIntegral.Prepartition.card_filter_mem_Icc_le
protected def iUnion : Set (ι → ℝ) :=
⋃ J ∈ π, ↑J
#align box_integral.prepartition.Union BoxIntegral.Prepartition.iUnion
theorem iUnion_def : π.iUnion = ⋃ J ∈ π, ↑J := rfl
#align box_integral.prepartition.Union_def BoxIntegral.Prepartition.iUnion_def
theorem iUnion_def' : π.iUnion = ⋃ J ∈ π.boxes, ↑J := rfl
#align box_integral.prepartition.Union_def' BoxIntegral.Prepartition.iUnion_def'
-- Porting note: Previous proof was `:= Set.mem_iUnion₂`
@[simp]
theorem mem_iUnion : x ∈ π.iUnion ↔ ∃ J ∈ π, x ∈ J := by
convert Set.mem_iUnion₂
rw [Box.mem_coe, exists_prop]
#align box_integral.prepartition.mem_Union BoxIntegral.Prepartition.mem_iUnion
@[simp]
theorem iUnion_single (h : J ≤ I) : (single I J h).iUnion = J := by simp [iUnion_def]
#align box_integral.prepartition.Union_single BoxIntegral.Prepartition.iUnion_single
@[simp]
theorem iUnion_top : (⊤ : Prepartition I).iUnion = I := by simp [Prepartition.iUnion]
#align box_integral.prepartition.Union_top BoxIntegral.Prepartition.iUnion_top
@[simp]
theorem iUnion_eq_empty : π₁.iUnion = ∅ ↔ π₁ = ⊥ := by
simp [← injective_boxes.eq_iff, Finset.ext_iff, Prepartition.iUnion, imp_false]
#align box_integral.prepartition.Union_eq_empty BoxIntegral.Prepartition.iUnion_eq_empty
@[simp]
theorem iUnion_bot : (⊥ : Prepartition I).iUnion = ∅ :=
iUnion_eq_empty.2 rfl
#align box_integral.prepartition.Union_bot BoxIntegral.Prepartition.iUnion_bot
theorem subset_iUnion (h : J ∈ π) : ↑J ⊆ π.iUnion :=
subset_biUnion_of_mem h
#align box_integral.prepartition.subset_Union BoxIntegral.Prepartition.subset_iUnion
theorem iUnion_subset : π.iUnion ⊆ I :=
iUnion₂_subset π.le_of_mem'
#align box_integral.prepartition.Union_subset BoxIntegral.Prepartition.iUnion_subset
@[mono]
theorem iUnion_mono (h : π₁ ≤ π₂) : π₁.iUnion ⊆ π₂.iUnion := fun _ hx =>
let ⟨_, hJ₁, hx⟩ := π₁.mem_iUnion.1 hx
let ⟨J₂, hJ₂, hle⟩ := h hJ₁
π₂.mem_iUnion.2 ⟨J₂, hJ₂, hle hx⟩
#align box_integral.prepartition.Union_mono BoxIntegral.Prepartition.iUnion_mono
theorem disjoint_boxes_of_disjoint_iUnion (h : Disjoint π₁.iUnion π₂.iUnion) :
Disjoint π₁.boxes π₂.boxes :=
Finset.disjoint_left.2 fun J h₁ h₂ =>
Disjoint.le_bot (h.mono (π₁.subset_iUnion h₁) (π₂.subset_iUnion h₂)) ⟨J.upper_mem, J.upper_mem⟩
#align box_integral.prepartition.disjoint_boxes_of_disjoint_Union BoxIntegral.Prepartition.disjoint_boxes_of_disjoint_iUnion
theorem le_iff_nonempty_imp_le_and_iUnion_subset :
π₁ ≤ π₂ ↔
(∀ J ∈ π₁, ∀ J' ∈ π₂, (J ∩ J' : Set (ι → ℝ)).Nonempty → J ≤ J') ∧ π₁.iUnion ⊆ π₂.iUnion := by
constructor
· refine fun H => ⟨fun J hJ J' hJ' Hne => ?_, iUnion_mono H⟩
rcases H hJ with ⟨J'', hJ'', Hle⟩
rcases Hne with ⟨x, hx, hx'⟩
rwa [π₂.eq_of_mem_of_mem hJ' hJ'' hx' (Hle hx)]
· rintro ⟨H, HU⟩ J hJ
simp only [Set.subset_def, mem_iUnion] at HU
rcases HU J.upper ⟨J, hJ, J.upper_mem⟩ with ⟨J₂, hJ₂, hx⟩
exact ⟨J₂, hJ₂, H _ hJ _ hJ₂ ⟨_, J.upper_mem, hx⟩⟩
#align box_integral.prepartition.le_iff_nonempty_imp_le_and_Union_subset BoxIntegral.Prepartition.le_iff_nonempty_imp_le_and_iUnion_subset
theorem eq_of_boxes_subset_iUnion_superset (h₁ : π₁.boxes ⊆ π₂.boxes) (h₂ : π₂.iUnion ⊆ π₁.iUnion) :
π₁ = π₂ :=
le_antisymm (fun J hJ => ⟨J, h₁ hJ, le_rfl⟩) <|
le_iff_nonempty_imp_le_and_iUnion_subset.2
⟨fun _ hJ₁ _ hJ₂ Hne =>
(π₂.eq_of_mem_of_mem hJ₁ (h₁ hJ₂) Hne.choose_spec.1 Hne.choose_spec.2).le, h₂⟩
#align box_integral.prepartition.eq_of_boxes_subset_Union_superset BoxIntegral.Prepartition.eq_of_boxes_subset_iUnion_superset
@[simps]
def biUnion (πi : ∀ J : Box ι, Prepartition J) : Prepartition I where
boxes := π.boxes.biUnion fun J => (πi J).boxes
le_of_mem' J hJ := by
simp only [Finset.mem_biUnion, exists_prop, mem_boxes] at hJ
rcases hJ with ⟨J', hJ', hJ⟩
exact ((πi J').le_of_mem hJ).trans (π.le_of_mem hJ')
pairwiseDisjoint := by
simp only [Set.Pairwise, Finset.mem_coe, Finset.mem_biUnion]
rintro J₁' ⟨J₁, hJ₁, hJ₁'⟩ J₂' ⟨J₂, hJ₂, hJ₂'⟩ Hne
rw [Function.onFun, Set.disjoint_left]
rintro x hx₁ hx₂; apply Hne
obtain rfl : J₁ = J₂ :=
π.eq_of_mem_of_mem hJ₁ hJ₂ ((πi J₁).le_of_mem hJ₁' hx₁) ((πi J₂).le_of_mem hJ₂' hx₂)
exact (πi J₁).eq_of_mem_of_mem hJ₁' hJ₂' hx₁ hx₂
#align box_integral.prepartition.bUnion BoxIntegral.Prepartition.biUnion
variable {πi πi₁ πi₂ : ∀ J : Box ι, Prepartition J}
@[simp]
theorem mem_biUnion : J ∈ π.biUnion πi ↔ ∃ J' ∈ π, J ∈ πi J' := by simp [biUnion]
#align box_integral.prepartition.mem_bUnion BoxIntegral.Prepartition.mem_biUnion
theorem biUnion_le (πi : ∀ J, Prepartition J) : π.biUnion πi ≤ π := fun _ hJ =>
let ⟨J', hJ', hJ⟩ := π.mem_biUnion.1 hJ
⟨J', hJ', (πi J').le_of_mem hJ⟩
#align box_integral.prepartition.bUnion_le BoxIntegral.Prepartition.biUnion_le
@[simp]
theorem biUnion_top : (π.biUnion fun _ => ⊤) = π := by
ext
simp
#align box_integral.prepartition.bUnion_top BoxIntegral.Prepartition.biUnion_top
@[congr]
theorem biUnion_congr (h : π₁ = π₂) (hi : ∀ J ∈ π₁, πi₁ J = πi₂ J) :
π₁.biUnion πi₁ = π₂.biUnion πi₂ := by
subst π₂
ext J
simp only [mem_biUnion]
constructor <;> exact fun ⟨J', h₁, h₂⟩ => ⟨J', h₁, hi J' h₁ ▸ h₂⟩
#align box_integral.prepartition.bUnion_congr BoxIntegral.Prepartition.biUnion_congr
theorem biUnion_congr_of_le (h : π₁ = π₂) (hi : ∀ J ≤ I, πi₁ J = πi₂ J) :
π₁.biUnion πi₁ = π₂.biUnion πi₂ :=
biUnion_congr h fun J hJ => hi J (π₁.le_of_mem hJ)
#align box_integral.prepartition.bUnion_congr_of_le BoxIntegral.Prepartition.biUnion_congr_of_le
@[simp]
theorem iUnion_biUnion (πi : ∀ J : Box ι, Prepartition J) :
(π.biUnion πi).iUnion = ⋃ J ∈ π, (πi J).iUnion := by simp [Prepartition.iUnion]
#align box_integral.prepartition.Union_bUnion BoxIntegral.Prepartition.iUnion_biUnion
@[simp]
theorem sum_biUnion_boxes {M : Type*} [AddCommMonoid M] (π : Prepartition I)
(πi : ∀ J, Prepartition J) (f : Box ι → M) :
(∑ J ∈ π.boxes.biUnion fun J => (πi J).boxes, f J) =
∑ J ∈ π.boxes, ∑ J' ∈ (πi J).boxes, f J' := by
refine Finset.sum_biUnion fun J₁ h₁ J₂ h₂ hne => Finset.disjoint_left.2 fun J' h₁' h₂' => ?_
exact hne (π.eq_of_le_of_le h₁ h₂ ((πi J₁).le_of_mem h₁') ((πi J₂).le_of_mem h₂'))
#align box_integral.prepartition.sum_bUnion_boxes BoxIntegral.Prepartition.sum_biUnion_boxes
def biUnionIndex (πi : ∀ (J : Box ι), Prepartition J) (J : Box ι) : Box ι :=
if hJ : J ∈ π.biUnion πi then (π.mem_biUnion.1 hJ).choose else I
#align box_integral.prepartition.bUnion_index BoxIntegral.Prepartition.biUnionIndex
theorem biUnionIndex_mem (hJ : J ∈ π.biUnion πi) : π.biUnionIndex πi J ∈ π := by
rw [biUnionIndex, dif_pos hJ]
exact (π.mem_biUnion.1 hJ).choose_spec.1
#align box_integral.prepartition.bUnion_index_mem BoxIntegral.Prepartition.biUnionIndex_mem
theorem biUnionIndex_le (πi : ∀ J, Prepartition J) (J : Box ι) : π.biUnionIndex πi J ≤ I := by
by_cases hJ : J ∈ π.biUnion πi
· exact π.le_of_mem (π.biUnionIndex_mem hJ)
· rw [biUnionIndex, dif_neg hJ]
#align box_integral.prepartition.bUnion_index_le BoxIntegral.Prepartition.biUnionIndex_le
theorem mem_biUnionIndex (hJ : J ∈ π.biUnion πi) : J ∈ πi (π.biUnionIndex πi J) := by
convert (π.mem_biUnion.1 hJ).choose_spec.2 <;> exact dif_pos hJ
#align box_integral.prepartition.mem_bUnion_index BoxIntegral.Prepartition.mem_biUnionIndex
theorem le_biUnionIndex (hJ : J ∈ π.biUnion πi) : J ≤ π.biUnionIndex πi J :=
le_of_mem _ (π.mem_biUnionIndex hJ)
#align box_integral.prepartition.le_bUnion_index BoxIntegral.Prepartition.le_biUnionIndex
theorem biUnionIndex_of_mem (hJ : J ∈ π) {J'} (hJ' : J' ∈ πi J) : π.biUnionIndex πi J' = J :=
have : J' ∈ π.biUnion πi := π.mem_biUnion.2 ⟨J, hJ, hJ'⟩
π.eq_of_le_of_le (π.biUnionIndex_mem this) hJ (π.le_biUnionIndex this) (le_of_mem _ hJ')
#align box_integral.prepartition.bUnion_index_of_mem BoxIntegral.Prepartition.biUnionIndex_of_mem
theorem biUnion_assoc (πi : ∀ J, Prepartition J) (πi' : Box ι → ∀ J : Box ι, Prepartition J) :
(π.biUnion fun J => (πi J).biUnion (πi' J)) =
(π.biUnion πi).biUnion fun J => πi' (π.biUnionIndex πi J) J := by
ext J
simp only [mem_biUnion, exists_prop]
constructor
· rintro ⟨J₁, hJ₁, J₂, hJ₂, hJ⟩
refine ⟨J₂, ⟨J₁, hJ₁, hJ₂⟩, ?_⟩
rwa [π.biUnionIndex_of_mem hJ₁ hJ₂]
· rintro ⟨J₁, ⟨J₂, hJ₂, hJ₁⟩, hJ⟩
refine ⟨J₂, hJ₂, J₁, hJ₁, ?_⟩
rwa [π.biUnionIndex_of_mem hJ₂ hJ₁] at hJ
#align box_integral.prepartition.bUnion_assoc BoxIntegral.Prepartition.biUnion_assoc
def ofWithBot (boxes : Finset (WithBot (Box ι)))
(le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I)
(pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint) :
Prepartition I where
boxes := Finset.eraseNone boxes
le_of_mem' J hJ := by
rw [mem_eraseNone] at hJ
simpa only [WithBot.some_eq_coe, WithBot.coe_le_coe] using le_of_mem _ hJ
pairwiseDisjoint J₁ h₁ J₂ h₂ hne := by
simp only [mem_coe, mem_eraseNone] at h₁ h₂
exact Box.disjoint_coe.1 (pairwise_disjoint h₁ h₂ (mt Option.some_inj.1 hne))
#align box_integral.prepartition.of_with_bot BoxIntegral.Prepartition.ofWithBot
@[simp]
theorem mem_ofWithBot {boxes : Finset (WithBot (Box ι))} {h₁ h₂} :
J ∈ (ofWithBot boxes h₁ h₂ : Prepartition I) ↔ (J : WithBot (Box ι)) ∈ boxes :=
mem_eraseNone
#align box_integral.prepartition.mem_of_with_bot BoxIntegral.Prepartition.mem_ofWithBot
@[simp]
theorem iUnion_ofWithBot (boxes : Finset (WithBot (Box ι)))
(le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I)
(pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint) :
(ofWithBot boxes le_of_mem pairwise_disjoint).iUnion = ⋃ J ∈ boxes, ↑J := by
suffices ⋃ (J : Box ι) (_ : ↑J ∈ boxes), ↑J = ⋃ J ∈ boxes, (J : Set (ι → ℝ)) by
simpa [ofWithBot, Prepartition.iUnion]
simp only [← Box.biUnion_coe_eq_coe, @iUnion_comm _ _ (Box ι), @iUnion_comm _ _ (@Eq _ _ _),
iUnion_iUnion_eq_right]
#align box_integral.prepartition.Union_of_with_bot BoxIntegral.Prepartition.iUnion_ofWithBot
theorem ofWithBot_le {boxes : Finset (WithBot (Box ι))}
{le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I}
{pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint}
(H : ∀ J ∈ boxes, J ≠ ⊥ → ∃ J' ∈ π, J ≤ ↑J') :
ofWithBot boxes le_of_mem pairwise_disjoint ≤ π := by
have : ∀ J : Box ι, ↑J ∈ boxes → ∃ J' ∈ π, J ≤ J' := fun J hJ => by
simpa only [WithBot.coe_le_coe] using H J hJ WithBot.coe_ne_bot
simpa [ofWithBot, le_def]
#align box_integral.prepartition.of_with_bot_le BoxIntegral.Prepartition.ofWithBot_le
theorem le_ofWithBot {boxes : Finset (WithBot (Box ι))}
{le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I}
{pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint}
(H : ∀ J ∈ π, ∃ J' ∈ boxes, ↑J ≤ J') : π ≤ ofWithBot boxes le_of_mem pairwise_disjoint := by
intro J hJ
rcases H J hJ with ⟨J', J'mem, hle⟩
lift J' to Box ι using ne_bot_of_le_ne_bot WithBot.coe_ne_bot hle
exact ⟨J', mem_ofWithBot.2 J'mem, WithBot.coe_le_coe.1 hle⟩
#align box_integral.prepartition.le_of_with_bot BoxIntegral.Prepartition.le_ofWithBot
theorem ofWithBot_mono {boxes₁ : Finset (WithBot (Box ι))}
{le_of_mem₁ : ∀ J ∈ boxes₁, (J : WithBot (Box ι)) ≤ I}
{pairwise_disjoint₁ : Set.Pairwise (boxes₁ : Set (WithBot (Box ι))) Disjoint}
{boxes₂ : Finset (WithBot (Box ι))} {le_of_mem₂ : ∀ J ∈ boxes₂, (J : WithBot (Box ι)) ≤ I}
{pairwise_disjoint₂ : Set.Pairwise (boxes₂ : Set (WithBot (Box ι))) Disjoint}
(H : ∀ J ∈ boxes₁, J ≠ ⊥ → ∃ J' ∈ boxes₂, J ≤ J') :
ofWithBot boxes₁ le_of_mem₁ pairwise_disjoint₁ ≤
ofWithBot boxes₂ le_of_mem₂ pairwise_disjoint₂ :=
le_ofWithBot _ fun J hJ => H J (mem_ofWithBot.1 hJ) WithBot.coe_ne_bot
#align box_integral.prepartition.of_with_bot_mono BoxIntegral.Prepartition.ofWithBot_mono
theorem sum_ofWithBot {M : Type*} [AddCommMonoid M] (boxes : Finset (WithBot (Box ι)))
(le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I)
(pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint) (f : Box ι → M) :
(∑ J ∈ (ofWithBot boxes le_of_mem pairwise_disjoint).boxes, f J) =
∑ J ∈ boxes, Option.elim' 0 f J :=
Finset.sum_eraseNone _ _
#align box_integral.prepartition.sum_of_with_bot BoxIntegral.Prepartition.sum_ofWithBot
def restrict (π : Prepartition I) (J : Box ι) : Prepartition J :=
ofWithBot (π.boxes.image fun J' : Box ι => J ⊓ J')
(fun J' hJ' => by
rcases Finset.mem_image.1 hJ' with ⟨J', -, rfl⟩
exact inf_le_left)
(by
simp only [Set.Pairwise, onFun, Finset.mem_coe, Finset.mem_image]
rintro _ ⟨J₁, h₁, rfl⟩ _ ⟨J₂, h₂, rfl⟩ Hne
have : J₁ ≠ J₂ := by
rintro rfl
exact Hne rfl
exact ((Box.disjoint_coe.2 <| π.disjoint_coe_of_mem h₁ h₂ this).inf_left' _).inf_right' _)
#align box_integral.prepartition.restrict BoxIntegral.Prepartition.restrict
@[simp]
theorem mem_restrict : J₁ ∈ π.restrict J ↔ ∃ J' ∈ π, (J₁ : WithBot (Box ι)) = ↑J ⊓ ↑J' := by
simp [restrict, eq_comm]
#align box_integral.prepartition.mem_restrict BoxIntegral.Prepartition.mem_restrict
theorem mem_restrict' : J₁ ∈ π.restrict J ↔ ∃ J' ∈ π, (J₁ : Set (ι → ℝ)) = ↑J ∩ ↑J' := by
simp only [mem_restrict, ← Box.withBotCoe_inj, Box.coe_inf, Box.coe_coe]
#align box_integral.prepartition.mem_restrict' BoxIntegral.Prepartition.mem_restrict'
@[mono]
theorem restrict_mono {π₁ π₂ : Prepartition I} (Hle : π₁ ≤ π₂) : π₁.restrict J ≤ π₂.restrict J := by
refine ofWithBot_mono fun J₁ hJ₁ hne => ?_
rw [Finset.mem_image] at hJ₁; rcases hJ₁ with ⟨J₁, hJ₁, rfl⟩
rcases Hle hJ₁ with ⟨J₂, hJ₂, hle⟩
exact ⟨_, Finset.mem_image_of_mem _ hJ₂, inf_le_inf_left _ <| WithBot.coe_le_coe.2 hle⟩
#align box_integral.prepartition.restrict_mono BoxIntegral.Prepartition.restrict_mono
theorem monotone_restrict : Monotone fun π : Prepartition I => restrict π J :=
fun _ _ => restrict_mono
#align box_integral.prepartition.monotone_restrict BoxIntegral.Prepartition.monotone_restrict
theorem restrict_boxes_of_le (π : Prepartition I) (h : I ≤ J) : (π.restrict J).boxes = π.boxes := by
simp only [restrict, ofWithBot, eraseNone_eq_biUnion]
refine Finset.image_biUnion.trans ?_
refine (Finset.biUnion_congr rfl ?_).trans Finset.biUnion_singleton_eq_self
intro J' hJ'
rw [inf_of_le_right, ← WithBot.some_eq_coe, Option.toFinset_some]
exact WithBot.coe_le_coe.2 ((π.le_of_mem hJ').trans h)
#align box_integral.prepartition.restrict_boxes_of_le BoxIntegral.Prepartition.restrict_boxes_of_le
@[simp]
theorem restrict_self : π.restrict I = π :=
injective_boxes <| restrict_boxes_of_le π le_rfl
#align box_integral.prepartition.restrict_self BoxIntegral.Prepartition.restrict_self
@[simp]
theorem iUnion_restrict : (π.restrict J).iUnion = (J : Set (ι → ℝ)) ∩ (π.iUnion) := by
simp [restrict, ← inter_iUnion, ← iUnion_def]
#align box_integral.prepartition.Union_restrict BoxIntegral.Prepartition.iUnion_restrict
@[simp]
theorem restrict_biUnion (πi : ∀ J, Prepartition J) (hJ : J ∈ π) :
(π.biUnion πi).restrict J = πi J := by
refine (eq_of_boxes_subset_iUnion_superset (fun J₁ h₁ => ?_) ?_).symm
· refine (mem_restrict _).2 ⟨J₁, π.mem_biUnion.2 ⟨J, hJ, h₁⟩, (inf_of_le_right ?_).symm⟩
exact WithBot.coe_le_coe.2 (le_of_mem _ h₁)
· simp only [iUnion_restrict, iUnion_biUnion, Set.subset_def, Set.mem_inter_iff, Set.mem_iUnion]
rintro x ⟨hxJ, J₁, h₁, hx⟩
obtain rfl : J = J₁ := π.eq_of_mem_of_mem hJ h₁ hxJ (iUnion_subset _ hx)
exact hx
#align box_integral.prepartition.restrict_bUnion BoxIntegral.Prepartition.restrict_biUnion
theorem biUnion_le_iff {πi : ∀ J, Prepartition J} {π' : Prepartition I} :
π.biUnion πi ≤ π' ↔ ∀ J ∈ π, πi J ≤ π'.restrict J := by
constructor <;> intro H J hJ
· rw [← π.restrict_biUnion πi hJ]
exact restrict_mono H
· rw [mem_biUnion] at hJ
rcases hJ with ⟨J₁, h₁, hJ⟩
rcases H J₁ h₁ hJ with ⟨J₂, h₂, Hle⟩
rcases π'.mem_restrict.mp h₂ with ⟨J₃, h₃, H⟩
exact ⟨J₃, h₃, Hle.trans <| WithBot.coe_le_coe.1 <| H.trans_le inf_le_right⟩
#align box_integral.prepartition.bUnion_le_iff BoxIntegral.Prepartition.biUnion_le_iff
theorem le_biUnion_iff {πi : ∀ J, Prepartition J} {π' : Prepartition I} :
π' ≤ π.biUnion πi ↔ π' ≤ π ∧ ∀ J ∈ π, π'.restrict J ≤ πi J := by
refine ⟨fun H => ⟨H.trans (π.biUnion_le πi), fun J hJ => ?_⟩, ?_⟩
· rw [← π.restrict_biUnion πi hJ]
exact restrict_mono H
· rintro ⟨H, Hi⟩ J' hJ'
rcases H hJ' with ⟨J, hJ, hle⟩
have : J' ∈ π'.restrict J :=
π'.mem_restrict.2 ⟨J', hJ', (inf_of_le_right <| WithBot.coe_le_coe.2 hle).symm⟩
rcases Hi J hJ this with ⟨Ji, hJi, hlei⟩
exact ⟨Ji, π.mem_biUnion.2 ⟨J, hJ, hJi⟩, hlei⟩
#align box_integral.prepartition.le_bUnion_iff BoxIntegral.Prepartition.le_biUnion_iff
instance inf : Inf (Prepartition I) :=
⟨fun π₁ π₂ => π₁.biUnion fun J => π₂.restrict J⟩
theorem inf_def (π₁ π₂ : Prepartition I) : π₁ ⊓ π₂ = π₁.biUnion fun J => π₂.restrict J := rfl
#align box_integral.prepartition.inf_def BoxIntegral.Prepartition.inf_def
@[simp]
theorem mem_inf {π₁ π₂ : Prepartition I} :
J ∈ π₁ ⊓ π₂ ↔ ∃ J₁ ∈ π₁, ∃ J₂ ∈ π₂, (J : WithBot (Box ι)) = ↑J₁ ⊓ ↑J₂ := by
simp only [inf_def, mem_biUnion, mem_restrict]
#align box_integral.prepartition.mem_inf BoxIntegral.Prepartition.mem_inf
@[simp]
theorem iUnion_inf (π₁ π₂ : Prepartition I) : (π₁ ⊓ π₂).iUnion = π₁.iUnion ∩ π₂.iUnion := by
simp only [inf_def, iUnion_biUnion, iUnion_restrict, ← iUnion_inter, ← iUnion_def]
#align box_integral.prepartition.Union_inf BoxIntegral.Prepartition.iUnion_inf
instance : SemilatticeInf (Prepartition I) :=
{ Prepartition.inf,
Prepartition.partialOrder with
inf_le_left := fun π₁ _ => π₁.biUnion_le _
inf_le_right := fun _ _ => (biUnion_le_iff _).2 fun _ _ => le_rfl
le_inf := fun _ π₁ _ h₁ h₂ => π₁.le_biUnion_iff.2 ⟨h₁, fun _ _ => restrict_mono h₂⟩ }
@[simps]
def filter (π : Prepartition I) (p : Box ι → Prop) : Prepartition I where
boxes := π.boxes.filter p
le_of_mem' _ hJ := π.le_of_mem (mem_filter.1 hJ).1
pairwiseDisjoint _ h₁ _ h₂ := π.disjoint_coe_of_mem (mem_filter.1 h₁).1 (mem_filter.1 h₂).1
#align box_integral.prepartition.filter BoxIntegral.Prepartition.filter
@[simp]
theorem mem_filter {p : Box ι → Prop} : J ∈ π.filter p ↔ J ∈ π ∧ p J :=
Finset.mem_filter
#align box_integral.prepartition.mem_filter BoxIntegral.Prepartition.mem_filter
theorem filter_le (π : Prepartition I) (p : Box ι → Prop) : π.filter p ≤ π := fun J hJ =>
let ⟨hπ, _⟩ := π.mem_filter.1 hJ
⟨J, hπ, le_rfl⟩
#align box_integral.prepartition.filter_le BoxIntegral.Prepartition.filter_le
theorem filter_of_true {p : Box ι → Prop} (hp : ∀ J ∈ π, p J) : π.filter p = π := by
ext J
simpa using hp J
#align box_integral.prepartition.filter_of_true BoxIntegral.Prepartition.filter_of_true
@[simp]
theorem filter_true : (π.filter fun _ => True) = π :=
π.filter_of_true fun _ _ => trivial
#align box_integral.prepartition.filter_true BoxIntegral.Prepartition.filter_true
@[simp]
theorem iUnion_filter_not (π : Prepartition I) (p : Box ι → Prop) :
(π.filter fun J => ¬p J).iUnion = π.iUnion \ (π.filter p).iUnion := by
simp only [Prepartition.iUnion]
convert (@Set.biUnion_diff_biUnion_eq (ι → ℝ) (Box ι) π.boxes (π.filter p).boxes (↑) _).symm
· simp (config := { contextual := true })
· rw [Set.PairwiseDisjoint]
convert π.pairwiseDisjoint
rw [Set.union_eq_left, filter_boxes, coe_filter]
exact fun _ ⟨h, _⟩ => h
#align box_integral.prepartition.Union_filter_not BoxIntegral.Prepartition.iUnion_filter_not
theorem sum_fiberwise {α M} [AddCommMonoid M] (π : Prepartition I) (f : Box ι → α) (g : Box ι → M) :
(∑ y ∈ π.boxes.image f, ∑ J ∈ (π.filter fun J => f J = y).boxes, g J) =
∑ J ∈ π.boxes, g J := by
convert sum_fiberwise_of_maps_to (fun _ => Finset.mem_image_of_mem f) g
#align box_integral.prepartition.sum_fiberwise BoxIntegral.Prepartition.sum_fiberwise
@[simps]
def disjUnion (π₁ π₂ : Prepartition I) (h : Disjoint π₁.iUnion π₂.iUnion) : Prepartition I where
boxes := π₁.boxes ∪ π₂.boxes
le_of_mem' J hJ := (Finset.mem_union.1 hJ).elim π₁.le_of_mem π₂.le_of_mem
pairwiseDisjoint :=
suffices ∀ J₁ ∈ π₁, ∀ J₂ ∈ π₂, J₁ ≠ J₂ → Disjoint (J₁ : Set (ι → ℝ)) J₂ by
simpa [pairwise_union_of_symmetric (symmetric_disjoint.comap _), pairwiseDisjoint]
fun J₁ h₁ J₂ h₂ _ => h.mono (π₁.subset_iUnion h₁) (π₂.subset_iUnion h₂)
#align box_integral.prepartition.disj_union BoxIntegral.Prepartition.disjUnion
@[simp]
theorem mem_disjUnion (H : Disjoint π₁.iUnion π₂.iUnion) :
J ∈ π₁.disjUnion π₂ H ↔ J ∈ π₁ ∨ J ∈ π₂ :=
Finset.mem_union
#align box_integral.prepartition.mem_disj_union BoxIntegral.Prepartition.mem_disjUnion
@[simp]
theorem iUnion_disjUnion (h : Disjoint π₁.iUnion π₂.iUnion) :
(π₁.disjUnion π₂ h).iUnion = π₁.iUnion ∪ π₂.iUnion := by
simp [disjUnion, Prepartition.iUnion, iUnion_or, iUnion_union_distrib]
#align box_integral.prepartition.Union_disj_union BoxIntegral.Prepartition.iUnion_disjUnion
@[simp]
theorem sum_disj_union_boxes {M : Type*} [AddCommMonoid M] (h : Disjoint π₁.iUnion π₂.iUnion)
(f : Box ι → M) :
∑ J ∈ π₁.boxes ∪ π₂.boxes, f J = (∑ J ∈ π₁.boxes, f J) + ∑ J ∈ π₂.boxes, f J :=
sum_union <| disjoint_boxes_of_disjoint_iUnion h
#align box_integral.prepartition.sum_disj_union_boxes BoxIntegral.Prepartition.sum_disj_union_boxes
def IsPartition (π : Prepartition I) :=
∀ x ∈ I, ∃ J ∈ π, x ∈ J
#align box_integral.prepartition.is_partition BoxIntegral.Prepartition.IsPartition
| Mathlib/Analysis/BoxIntegral/Partition/Basic.lean | 720 | 722 | theorem isPartition_iff_iUnion_eq {π : Prepartition I} : π.IsPartition ↔ π.iUnion = I := by |
simp_rw [IsPartition, Set.Subset.antisymm_iff, π.iUnion_subset, true_and_iff, Set.subset_def,
mem_iUnion, Box.mem_coe]
|
import Mathlib.Algebra.Group.Subgroup.Pointwise
import Mathlib.Data.Set.Basic
import Mathlib.Data.Setoid.Basic
import Mathlib.GroupTheory.Coset
#align_import group_theory.double_coset from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514"
-- Porting note: removed import
-- import Mathlib.Tactic.Group
variable {G : Type*} [Group G] {α : Type*} [Mul α] (J : Subgroup G) (g : G)
open MulOpposite
open scoped Pointwise
namespace Doset
def doset (a : α) (s t : Set α) : Set α :=
s * {a} * t
#align doset Doset.doset
lemma doset_eq_image2 (a : α) (s t : Set α) : doset a s t = Set.image2 (· * a * ·) s t := by
simp_rw [doset, Set.mul_singleton, ← Set.image2_mul, Set.image2_image_left]
theorem mem_doset {s t : Set α} {a b : α} : b ∈ doset a s t ↔ ∃ x ∈ s, ∃ y ∈ t, b = x * a * y := by
simp only [doset_eq_image2, Set.mem_image2, eq_comm]
#align doset.mem_doset Doset.mem_doset
theorem mem_doset_self (H K : Subgroup G) (a : G) : a ∈ doset a H K :=
mem_doset.mpr ⟨1, H.one_mem, 1, K.one_mem, (one_mul a).symm.trans (mul_one (1 * a)).symm⟩
#align doset.mem_doset_self Doset.mem_doset_self
theorem doset_eq_of_mem {H K : Subgroup G} {a b : G} (hb : b ∈ doset a H K) :
doset b H K = doset a H K := by
obtain ⟨h, hh, k, hk, rfl⟩ := mem_doset.1 hb
rw [doset, doset, ← Set.singleton_mul_singleton, ← Set.singleton_mul_singleton, mul_assoc,
mul_assoc, Subgroup.singleton_mul_subgroup hk, ← mul_assoc, ← mul_assoc,
Subgroup.subgroup_mul_singleton hh]
#align doset.doset_eq_of_mem Doset.doset_eq_of_mem
theorem mem_doset_of_not_disjoint {H K : Subgroup G} {a b : G}
(h : ¬Disjoint (doset a H K) (doset b H K)) : b ∈ doset a H K := by
rw [Set.not_disjoint_iff] at h
simp only [mem_doset] at *
obtain ⟨x, ⟨l, hl, r, hr, hrx⟩, y, hy, ⟨r', hr', rfl⟩⟩ := h
refine ⟨y⁻¹ * l, H.mul_mem (H.inv_mem hy) hl, r * r'⁻¹, K.mul_mem hr (K.inv_mem hr'), ?_⟩
rwa [mul_assoc, mul_assoc, eq_inv_mul_iff_mul_eq, ← mul_assoc, ← mul_assoc, eq_mul_inv_iff_mul_eq]
#align doset.mem_doset_of_not_disjoint Doset.mem_doset_of_not_disjoint
theorem eq_of_not_disjoint {H K : Subgroup G} {a b : G}
(h : ¬Disjoint (doset a H K) (doset b H K)) : doset a H K = doset b H K := by
rw [disjoint_comm] at h
have ha : a ∈ doset b H K := mem_doset_of_not_disjoint h
apply doset_eq_of_mem ha
#align doset.eq_of_not_disjoint Doset.eq_of_not_disjoint
def setoid (H K : Set G) : Setoid G :=
Setoid.ker fun x => doset x H K
#align doset.setoid Doset.setoid
def Quotient (H K : Set G) : Type _ :=
_root_.Quotient (setoid H K)
#align doset.quotient Doset.Quotient
theorem rel_iff {H K : Subgroup G} {x y : G} :
(setoid ↑H ↑K).Rel x y ↔ ∃ a ∈ H, ∃ b ∈ K, y = a * x * b :=
Iff.trans
⟨fun hxy => (congr_arg _ hxy).mpr (mem_doset_self H K y), fun hxy => (doset_eq_of_mem hxy).symm⟩
mem_doset
#align doset.rel_iff Doset.rel_iff
theorem bot_rel_eq_leftRel (H : Subgroup G) :
(setoid ↑(⊥ : Subgroup G) ↑H).Rel = (QuotientGroup.leftRel H).Rel := by
ext a b
rw [rel_iff, Setoid.Rel, QuotientGroup.leftRel_apply]
constructor
· rintro ⟨a, rfl : a = 1, b, hb, rfl⟩
change a⁻¹ * (1 * a * b) ∈ H
rwa [one_mul, inv_mul_cancel_left]
· rintro (h : a⁻¹ * b ∈ H)
exact ⟨1, rfl, a⁻¹ * b, h, by rw [one_mul, mul_inv_cancel_left]⟩
#align doset.bot_rel_eq_left_rel Doset.bot_rel_eq_leftRel
theorem rel_bot_eq_right_group_rel (H : Subgroup G) :
(setoid ↑H ↑(⊥ : Subgroup G)).Rel = (QuotientGroup.rightRel H).Rel := by
ext a b
rw [rel_iff, Setoid.Rel, QuotientGroup.rightRel_apply]
constructor
· rintro ⟨b, hb, a, rfl : a = 1, rfl⟩
change b * a * 1 * a⁻¹ ∈ H
rwa [mul_one, mul_inv_cancel_right]
· rintro (h : b * a⁻¹ ∈ H)
exact ⟨b * a⁻¹, h, 1, rfl, by rw [mul_one, inv_mul_cancel_right]⟩
#align doset.rel_bot_eq_right_group_rel Doset.rel_bot_eq_right_group_rel
def quotToDoset (H K : Subgroup G) (q : Quotient (H : Set G) K) : Set G :=
doset q.out' H K
#align doset.quot_to_doset Doset.quotToDoset
abbrev mk (H K : Subgroup G) (a : G) : Quotient (H : Set G) K :=
Quotient.mk'' a
#align doset.mk Doset.mk
instance (H K : Subgroup G) : Inhabited (Quotient (H : Set G) K) :=
⟨mk H K (1 : G)⟩
theorem eq (H K : Subgroup G) (a b : G) :
mk H K a = mk H K b ↔ ∃ h ∈ H, ∃ k ∈ K, b = h * a * k := by
rw [Quotient.eq'']
apply rel_iff
#align doset.eq Doset.eq
theorem out_eq' (H K : Subgroup G) (q : Quotient ↑H ↑K) : mk H K q.out' = q :=
Quotient.out_eq' q
#align doset.out_eq' Doset.out_eq'
| Mathlib/GroupTheory/DoubleCoset.lean | 140 | 146 | theorem mk_out'_eq_mul (H K : Subgroup G) (g : G) :
∃ h k : G, h ∈ H ∧ k ∈ K ∧ (mk H K g : Quotient ↑H ↑K).out' = h * g * k := by |
have := eq H K (mk H K g : Quotient ↑H ↑K).out' g
rw [out_eq'] at this
obtain ⟨h, h_h, k, hk, T⟩ := this.1 rfl
refine ⟨h⁻¹, k⁻¹, H.inv_mem h_h, K.inv_mem hk, eq_mul_inv_of_mul_eq (eq_inv_mul_of_mul_eq ?_)⟩
rw [← mul_assoc, ← T]
|
import Mathlib.Algebra.Bounds
import Mathlib.Algebra.Order.Archimedean
import Mathlib.Data.Real.Basic
import Mathlib.Order.Interval.Set.Disjoint
#align_import data.real.basic from "leanprover-community/mathlib"@"cb42593171ba005beaaf4549fcfe0dece9ada4c9"
open scoped Classical
open Pointwise CauSeq
namespace Real
instance instArchimedean : Archimedean ℝ :=
archimedean_iff_rat_le.2 fun x =>
Real.ind_mk x fun f =>
let ⟨M, _, H⟩ := f.bounded' 0
⟨M, mk_le_of_forall_le ⟨0, fun i _ => Rat.cast_le.2 <| le_of_lt (abs_lt.1 (H i)).2⟩⟩
#align real.archimedean Real.instArchimedean
noncomputable instance : FloorRing ℝ :=
Archimedean.floorRing _
theorem isCauSeq_iff_lift {f : ℕ → ℚ} : IsCauSeq abs f ↔ IsCauSeq abs fun i => (f i : ℝ) where
mp H ε ε0 :=
let ⟨δ, δ0, δε⟩ := exists_pos_rat_lt ε0
(H _ δ0).imp fun i hi j ij => by dsimp; exact lt_trans (mod_cast hi _ ij) δε
mpr H ε ε0 :=
(H _ (Rat.cast_pos.2 ε0)).imp fun i hi j ij => by dsimp at hi; exact mod_cast hi _ ij
#align real.is_cau_seq_iff_lift Real.isCauSeq_iff_lift
theorem of_near (f : ℕ → ℚ) (x : ℝ) (h : ∀ ε > 0, ∃ i, ∀ j ≥ i, |(f j : ℝ) - x| < ε) :
∃ h', Real.mk ⟨f, h'⟩ = x :=
⟨isCauSeq_iff_lift.2 (CauSeq.of_near _ (const abs x) h),
sub_eq_zero.1 <|
abs_eq_zero.1 <|
(eq_of_le_of_forall_le_of_dense (abs_nonneg _)) fun _ε ε0 =>
mk_near_of_forall_near <| (h _ ε0).imp fun _i h j ij => le_of_lt (h j ij)⟩
#align real.of_near Real.of_near
theorem exists_floor (x : ℝ) : ∃ ub : ℤ, (ub : ℝ) ≤ x ∧ ∀ z : ℤ, (z : ℝ) ≤ x → z ≤ ub :=
Int.exists_greatest_of_bdd
(let ⟨n, hn⟩ := exists_int_gt x
⟨n, fun _ h' => Int.cast_le.1 <| le_trans h' <| le_of_lt hn⟩)
(let ⟨n, hn⟩ := exists_int_lt x
⟨n, le_of_lt hn⟩)
#align real.exists_floor Real.exists_floor
theorem exists_isLUB {S : Set ℝ} (hne : S.Nonempty) (hbdd : BddAbove S) : ∃ x, IsLUB S x := by
rcases hne, hbdd with ⟨⟨L, hL⟩, ⟨U, hU⟩⟩
have : ∀ d : ℕ, BddAbove { m : ℤ | ∃ y ∈ S, (m : ℝ) ≤ y * d } := by
cases' exists_int_gt U with k hk
refine fun d => ⟨k * d, fun z h => ?_⟩
rcases h with ⟨y, yS, hy⟩
refine Int.cast_le.1 (hy.trans ?_)
push_cast
exact mul_le_mul_of_nonneg_right ((hU yS).trans hk.le) d.cast_nonneg
choose f hf using fun d : ℕ =>
Int.exists_greatest_of_bdd (this d) ⟨⌊L * d⌋, L, hL, Int.floor_le _⟩
have hf₁ : ∀ n > 0, ∃ y ∈ S, ((f n / n : ℚ) : ℝ) ≤ y := fun n n0 =>
let ⟨y, yS, hy⟩ := (hf n).1
⟨y, yS, by simpa using (div_le_iff (Nat.cast_pos.2 n0 : (_ : ℝ) < _)).2 hy⟩
have hf₂ : ∀ n > 0, ∀ y ∈ S, (y - ((n : ℕ) : ℝ)⁻¹) < (f n / n : ℚ) := by
intro n n0 y yS
have := (Int.sub_one_lt_floor _).trans_le (Int.cast_le.2 <| (hf n).2 _ ⟨y, yS, Int.floor_le _⟩)
simp only [Rat.cast_div, Rat.cast_intCast, Rat.cast_natCast, gt_iff_lt]
rwa [lt_div_iff (Nat.cast_pos.2 n0 : (_ : ℝ) < _), sub_mul, _root_.inv_mul_cancel]
exact ne_of_gt (Nat.cast_pos.2 n0)
have hg : IsCauSeq abs (fun n => f n / n : ℕ → ℚ) := by
intro ε ε0
suffices ∀ j ≥ ⌈ε⁻¹⌉₊, ∀ k ≥ ⌈ε⁻¹⌉₊, (f j / j - f k / k : ℚ) < ε by
refine ⟨_, fun j ij => abs_lt.2 ⟨?_, this _ ij _ le_rfl⟩⟩
rw [neg_lt, neg_sub]
exact this _ le_rfl _ ij
intro j ij k ik
replace ij := le_trans (Nat.le_ceil _) (Nat.cast_le.2 ij)
replace ik := le_trans (Nat.le_ceil _) (Nat.cast_le.2 ik)
have j0 := Nat.cast_pos.1 ((inv_pos.2 ε0).trans_le ij)
have k0 := Nat.cast_pos.1 ((inv_pos.2 ε0).trans_le ik)
rcases hf₁ _ j0 with ⟨y, yS, hy⟩
refine lt_of_lt_of_le ((Rat.cast_lt (K := ℝ)).1 ?_) ((inv_le ε0 (Nat.cast_pos.2 k0)).1 ik)
simpa using sub_lt_iff_lt_add'.2 (lt_of_le_of_lt hy <| sub_lt_iff_lt_add.1 <| hf₂ _ k0 _ yS)
let g : CauSeq ℚ abs := ⟨fun n => f n / n, hg⟩
refine ⟨mk g, ⟨fun x xS => ?_, fun y h => ?_⟩⟩
· refine le_of_forall_ge_of_dense fun z xz => ?_
cases' exists_nat_gt (x - z)⁻¹ with K hK
refine le_mk_of_forall_le ⟨K, fun n nK => ?_⟩
replace xz := sub_pos.2 xz
replace hK := hK.le.trans (Nat.cast_le.2 nK)
have n0 : 0 < n := Nat.cast_pos.1 ((inv_pos.2 xz).trans_le hK)
refine le_trans ?_ (hf₂ _ n0 _ xS).le
rwa [le_sub_comm, inv_le (Nat.cast_pos.2 n0 : (_ : ℝ) < _) xz]
· exact
mk_le_of_forall_le
⟨1, fun n n1 =>
let ⟨x, xS, hx⟩ := hf₁ _ n1
le_trans hx (h xS)⟩
#align real.exists_is_lub Real.exists_isLUB
theorem exists_isGLB {S : Set ℝ} (hne : S.Nonempty) (hbdd : BddBelow S) : ∃ x, IsGLB S x := by
have hne' : (-S).Nonempty := Set.nonempty_neg.mpr hne
have hbdd' : BddAbove (-S) := bddAbove_neg.mpr hbdd
use -Classical.choose (Real.exists_isLUB hne' hbdd')
rw [← isLUB_neg]
exact Classical.choose_spec (Real.exists_isLUB hne' hbdd')
noncomputable instance : SupSet ℝ :=
⟨fun S => if h : S.Nonempty ∧ BddAbove S then Classical.choose (exists_isLUB h.1 h.2) else 0⟩
theorem sSup_def (S : Set ℝ) :
sSup S = if h : S.Nonempty ∧ BddAbove S then Classical.choose (exists_isLUB h.1 h.2) else 0 :=
rfl
#align real.Sup_def Real.sSup_def
protected theorem isLUB_sSup (S : Set ℝ) (h₁ : S.Nonempty) (h₂ : BddAbove S) :
IsLUB S (sSup S) := by
simp only [sSup_def, dif_pos (And.intro h₁ h₂)]
apply Classical.choose_spec
#align real.is_lub_Sup Real.isLUB_sSup
noncomputable instance : InfSet ℝ :=
⟨fun S => -sSup (-S)⟩
theorem sInf_def (S : Set ℝ) : sInf S = -sSup (-S) :=
rfl
#align real.Inf_def Real.sInf_def
protected theorem is_glb_sInf (S : Set ℝ) (h₁ : S.Nonempty) (h₂ : BddBelow S) :
IsGLB S (sInf S) := by
rw [sInf_def, ← isLUB_neg', neg_neg]
exact Real.isLUB_sSup _ h₁.neg h₂.neg
#align real.is_glb_Inf Real.is_glb_sInf
noncomputable instance : ConditionallyCompleteLinearOrder ℝ :=
{ Real.linearOrder, Real.lattice with
sSup := SupSet.sSup
sInf := InfSet.sInf
le_csSup := fun s a hs ha => (Real.isLUB_sSup s ⟨a, ha⟩ hs).1 ha
csSup_le := fun s a hs ha => (Real.isLUB_sSup s hs ⟨a, ha⟩).2 ha
csInf_le := fun s a hs ha => (Real.is_glb_sInf s ⟨a, ha⟩ hs).1 ha
le_csInf := fun s a hs ha => (Real.is_glb_sInf s hs ⟨a, ha⟩).2 ha
csSup_of_not_bddAbove := fun s hs ↦ by simp [hs, sSup_def]
csInf_of_not_bddBelow := fun s hs ↦ by simp [hs, sInf_def, sSup_def] }
theorem lt_sInf_add_pos {s : Set ℝ} (h : s.Nonempty) {ε : ℝ} (hε : 0 < ε) :
∃ a ∈ s, a < sInf s + ε :=
exists_lt_of_csInf_lt h <| lt_add_of_pos_right _ hε
#align real.lt_Inf_add_pos Real.lt_sInf_add_pos
theorem add_neg_lt_sSup {s : Set ℝ} (h : s.Nonempty) {ε : ℝ} (hε : ε < 0) :
∃ a ∈ s, sSup s + ε < a :=
exists_lt_of_lt_csSup h <| add_lt_iff_neg_left.2 hε
#align real.add_neg_lt_Sup Real.add_neg_lt_sSup
theorem sInf_le_iff {s : Set ℝ} (h : BddBelow s) (h' : s.Nonempty) {a : ℝ} :
sInf s ≤ a ↔ ∀ ε, 0 < ε → ∃ x ∈ s, x < a + ε := by
rw [le_iff_forall_pos_lt_add]
constructor <;> intro H ε ε_pos
· exact exists_lt_of_csInf_lt h' (H ε ε_pos)
· rcases H ε ε_pos with ⟨x, x_in, hx⟩
exact csInf_lt_of_lt h x_in hx
#align real.Inf_le_iff Real.sInf_le_iff
theorem le_sSup_iff {s : Set ℝ} (h : BddAbove s) (h' : s.Nonempty) {a : ℝ} :
a ≤ sSup s ↔ ∀ ε, ε < 0 → ∃ x ∈ s, a + ε < x := by
rw [le_iff_forall_pos_lt_add]
refine ⟨fun H ε ε_neg => ?_, fun H ε ε_pos => ?_⟩
· exact exists_lt_of_lt_csSup h' (lt_sub_iff_add_lt.mp (H _ (neg_pos.mpr ε_neg)))
· rcases H _ (neg_lt_zero.mpr ε_pos) with ⟨x, x_in, hx⟩
exact sub_lt_iff_lt_add.mp (lt_csSup_of_lt h x_in hx)
#align real.le_Sup_iff Real.le_sSup_iff
@[simp]
theorem sSup_empty : sSup (∅ : Set ℝ) = 0 :=
dif_neg <| by simp
#align real.Sup_empty Real.sSup_empty
@[simp] lemma iSup_of_isEmpty {α : Sort*} [IsEmpty α] (f : α → ℝ) : ⨆ i, f i = 0 := by
dsimp [iSup]
convert Real.sSup_empty
rw [Set.range_eq_empty_iff]
infer_instance
#align real.csupr_empty Real.iSup_of_isEmpty
@[simp]
theorem ciSup_const_zero {α : Sort*} : ⨆ _ : α, (0 : ℝ) = 0 := by
cases isEmpty_or_nonempty α
· exact Real.iSup_of_isEmpty _
· exact ciSup_const
#align real.csupr_const_zero Real.ciSup_const_zero
theorem sSup_of_not_bddAbove {s : Set ℝ} (hs : ¬BddAbove s) : sSup s = 0 :=
dif_neg fun h => hs h.2
#align real.Sup_of_not_bdd_above Real.sSup_of_not_bddAbove
theorem iSup_of_not_bddAbove {α : Sort*} {f : α → ℝ} (hf : ¬BddAbove (Set.range f)) :
⨆ i, f i = 0 :=
sSup_of_not_bddAbove hf
#align real.supr_of_not_bdd_above Real.iSup_of_not_bddAbove
theorem sSup_univ : sSup (@Set.univ ℝ) = 0 := Real.sSup_of_not_bddAbove not_bddAbove_univ
#align real.Sup_univ Real.sSup_univ
@[simp]
theorem sInf_empty : sInf (∅ : Set ℝ) = 0 := by simp [sInf_def, sSup_empty]
#align real.Inf_empty Real.sInf_empty
@[simp] nonrec lemma iInf_of_isEmpty {α : Sort*} [IsEmpty α] (f : α → ℝ) : ⨅ i, f i = 0 := by
rw [iInf_of_isEmpty, sInf_empty]
#align real.cinfi_empty Real.iInf_of_isEmpty
@[simp]
| Mathlib/Data/Real/Archimedean.lean | 223 | 226 | theorem ciInf_const_zero {α : Sort*} : ⨅ _ : α, (0 : ℝ) = 0 := by |
cases isEmpty_or_nonempty α
· exact Real.iInf_of_isEmpty _
· exact ciInf_const
|
import Mathlib.Algebra.EuclideanDomain.Defs
import Mathlib.Algebra.Ring.Divisibility.Basic
import Mathlib.Algebra.Ring.Regular
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Algebra.Ring.Basic
#align_import algebra.euclidean_domain.basic from "leanprover-community/mathlib"@"bf9bbbcf0c1c1ead18280b0d010e417b10abb1b6"
universe u
namespace EuclideanDomain
variable {R : Type u}
variable [EuclideanDomain R]
local infixl:50 " ≺ " => EuclideanDomain.R
-- See note [lower instance priority]
instance (priority := 100) toMulDivCancelClass : MulDivCancelClass R where
mul_div_cancel a b hb := by
refine (eq_of_sub_eq_zero ?_).symm
by_contra h
have := mul_right_not_lt b h
rw [sub_mul, mul_comm (_ / _), sub_eq_iff_eq_add'.2 (div_add_mod (a * b) b).symm] at this
exact this (mod_lt _ hb)
#align euclidean_domain.mul_div_cancel_left mul_div_cancel_left₀
#align euclidean_domain.mul_div_cancel mul_div_cancel_right₀
@[simp]
theorem mod_eq_zero {a b : R} : a % b = 0 ↔ b ∣ a :=
⟨fun h => by
rw [← div_add_mod a b, h, add_zero]
exact dvd_mul_right _ _, fun ⟨c, e⟩ => by
rw [e, ← add_left_cancel_iff, div_add_mod, add_zero]
haveI := Classical.dec
by_cases b0 : b = 0
· simp only [b0, zero_mul]
· rw [mul_div_cancel_left₀ _ b0]⟩
#align euclidean_domain.mod_eq_zero EuclideanDomain.mod_eq_zero
@[simp]
theorem mod_self (a : R) : a % a = 0 :=
mod_eq_zero.2 dvd_rfl
#align euclidean_domain.mod_self EuclideanDomain.mod_self
theorem dvd_mod_iff {a b c : R} (h : c ∣ b) : c ∣ a % b ↔ c ∣ a := by
rw [← dvd_add_right (h.mul_right _), div_add_mod]
#align euclidean_domain.dvd_mod_iff EuclideanDomain.dvd_mod_iff
@[simp]
theorem mod_one (a : R) : a % 1 = 0 :=
mod_eq_zero.2 (one_dvd _)
#align euclidean_domain.mod_one EuclideanDomain.mod_one
@[simp]
theorem zero_mod (b : R) : 0 % b = 0 :=
mod_eq_zero.2 (dvd_zero _)
#align euclidean_domain.zero_mod EuclideanDomain.zero_mod
@[simp]
theorem zero_div {a : R} : 0 / a = 0 :=
by_cases (fun a0 : a = 0 => a0.symm ▸ div_zero 0) fun a0 => by
simpa only [zero_mul] using mul_div_cancel_right₀ 0 a0
#align euclidean_domain.zero_div EuclideanDomain.zero_div
@[simp]
theorem div_self {a : R} (a0 : a ≠ 0) : a / a = 1 := by
simpa only [one_mul] using mul_div_cancel_right₀ 1 a0
#align euclidean_domain.div_self EuclideanDomain.div_self
theorem eq_div_of_mul_eq_left {a b c : R} (hb : b ≠ 0) (h : a * b = c) : a = c / b := by
rw [← h, mul_div_cancel_right₀ _ hb]
#align euclidean_domain.eq_div_of_mul_eq_left EuclideanDomain.eq_div_of_mul_eq_left
theorem eq_div_of_mul_eq_right {a b c : R} (ha : a ≠ 0) (h : a * b = c) : b = c / a := by
rw [← h, mul_div_cancel_left₀ _ ha]
#align euclidean_domain.eq_div_of_mul_eq_right EuclideanDomain.eq_div_of_mul_eq_right
theorem mul_div_assoc (x : R) {y z : R} (h : z ∣ y) : x * y / z = x * (y / z) := by
by_cases hz : z = 0
· subst hz
rw [div_zero, div_zero, mul_zero]
rcases h with ⟨p, rfl⟩
rw [mul_div_cancel_left₀ _ hz, mul_left_comm, mul_div_cancel_left₀ _ hz]
#align euclidean_domain.mul_div_assoc EuclideanDomain.mul_div_assoc
protected theorem mul_div_cancel' {a b : R} (hb : b ≠ 0) (hab : b ∣ a) : b * (a / b) = a := by
rw [← mul_div_assoc _ hab, mul_div_cancel_left₀ _ hb]
#align euclidean_domain.mul_div_cancel' EuclideanDomain.mul_div_cancel'
-- This generalizes `Int.div_one`, see note [simp-normal form]
@[simp]
theorem div_one (p : R) : p / 1 = p :=
(EuclideanDomain.eq_div_of_mul_eq_left (one_ne_zero' R) (mul_one p)).symm
#align euclidean_domain.div_one EuclideanDomain.div_one
theorem div_dvd_of_dvd {p q : R} (hpq : q ∣ p) : p / q ∣ p := by
by_cases hq : q = 0
· rw [hq, zero_dvd_iff] at hpq
rw [hpq]
exact dvd_zero _
use q
rw [mul_comm, ← EuclideanDomain.mul_div_assoc _ hpq, mul_comm, mul_div_cancel_right₀ _ hq]
#align euclidean_domain.div_dvd_of_dvd EuclideanDomain.div_dvd_of_dvd
| Mathlib/Algebra/EuclideanDomain/Basic.lean | 123 | 128 | theorem dvd_div_of_mul_dvd {a b c : R} (h : a * b ∣ c) : b ∣ c / a := by |
rcases eq_or_ne a 0 with (rfl | ha)
· simp only [div_zero, dvd_zero]
rcases h with ⟨d, rfl⟩
refine ⟨d, ?_⟩
rw [mul_assoc, mul_div_cancel_left₀ _ ha]
|
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.Calculus.BumpFunction.Normed
import Mathlib.MeasureTheory.Integral.Average
import Mathlib.MeasureTheory.Covering.Differentiation
import Mathlib.MeasureTheory.Covering.BesicovitchVectorSpace
import Mathlib.MeasureTheory.Measure.Haar.Unique
#align_import analysis.convolution from "leanprover-community/mathlib"@"8905e5ed90859939681a725b00f6063e65096d95"
universe uG uE'
open ContinuousLinearMap Metric MeasureTheory Filter Function Measure Set
open scoped Convolution Topology
namespace ContDiffBump
variable {G : Type uG} {E' : Type uE'} [NormedAddCommGroup E'] {g : G → E'} [MeasurableSpace G]
{μ : MeasureTheory.Measure G} [NormedSpace ℝ E'] [NormedAddCommGroup G] [NormedSpace ℝ G]
[HasContDiffBump G] [CompleteSpace E'] {φ : ContDiffBump (0 : G)} {x₀ : G}
theorem convolution_eq_right {x₀ : G} (hg : ∀ x ∈ ball x₀ φ.rOut, g x = g x₀) :
(φ ⋆[lsmul ℝ ℝ, μ] g : G → E') x₀ = integral μ φ • g x₀ := by
simp_rw [convolution_eq_right' _ φ.support_eq.subset hg, lsmul_apply, integral_smul_const]
#align cont_diff_bump.convolution_eq_right ContDiffBump.convolution_eq_right
variable [BorelSpace G]
variable [IsLocallyFiniteMeasure μ] [μ.IsOpenPosMeasure]
variable [FiniteDimensional ℝ G]
| Mathlib/Analysis/Calculus/BumpFunction/Convolution.lean | 65 | 68 | theorem normed_convolution_eq_right {x₀ : G} (hg : ∀ x ∈ ball x₀ φ.rOut, g x = g x₀) :
(φ.normed μ ⋆[lsmul ℝ ℝ, μ] g : G → E') x₀ = g x₀ := by |
rw [convolution_eq_right' _ φ.support_normed_eq.subset hg]
exact integral_normed_smul φ μ (g x₀)
|
import Mathlib.Analysis.Calculus.ContDiff.Basic
import Mathlib.Analysis.Calculus.Deriv.Linear
import Mathlib.Analysis.Complex.Conformal
import Mathlib.Analysis.Calculus.Conformal.NormedSpace
#align_import analysis.complex.real_deriv from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
section RealDerivOfComplex
open Complex
variable {e : ℂ → ℂ} {e' : ℂ} {z : ℝ}
theorem HasStrictDerivAt.real_of_complex (h : HasStrictDerivAt e e' z) :
HasStrictDerivAt (fun x : ℝ => (e x).re) e'.re z := by
have A : HasStrictFDerivAt ((↑) : ℝ → ℂ) ofRealCLM z := ofRealCLM.hasStrictFDerivAt
have B :
HasStrictFDerivAt e ((ContinuousLinearMap.smulRight 1 e' : ℂ →L[ℂ] ℂ).restrictScalars ℝ)
(ofRealCLM z) :=
h.hasStrictFDerivAt.restrictScalars ℝ
have C : HasStrictFDerivAt re reCLM (e (ofRealCLM z)) := reCLM.hasStrictFDerivAt
-- Porting note: this should be by:
-- simpa using (C.comp z (B.comp z A)).hasStrictDerivAt
-- but for some reason simp can not use `ContinuousLinearMap.comp_apply`
convert (C.comp z (B.comp z A)).hasStrictDerivAt
rw [ContinuousLinearMap.comp_apply, ContinuousLinearMap.comp_apply]
simp
#align has_strict_deriv_at.real_of_complex HasStrictDerivAt.real_of_complex
theorem HasDerivAt.real_of_complex (h : HasDerivAt e e' z) :
HasDerivAt (fun x : ℝ => (e x).re) e'.re z := by
have A : HasFDerivAt ((↑) : ℝ → ℂ) ofRealCLM z := ofRealCLM.hasFDerivAt
have B :
HasFDerivAt e ((ContinuousLinearMap.smulRight 1 e' : ℂ →L[ℂ] ℂ).restrictScalars ℝ)
(ofRealCLM z) :=
h.hasFDerivAt.restrictScalars ℝ
have C : HasFDerivAt re reCLM (e (ofRealCLM z)) := reCLM.hasFDerivAt
-- Porting note: this should be by:
-- simpa using (C.comp z (B.comp z A)).hasStrictDerivAt
-- but for some reason simp can not use `ContinuousLinearMap.comp_apply`
convert (C.comp z (B.comp z A)).hasDerivAt
rw [ContinuousLinearMap.comp_apply, ContinuousLinearMap.comp_apply]
simp
#align has_deriv_at.real_of_complex HasDerivAt.real_of_complex
theorem ContDiffAt.real_of_complex {n : ℕ∞} (h : ContDiffAt ℂ n e z) :
ContDiffAt ℝ n (fun x : ℝ => (e x).re) z := by
have A : ContDiffAt ℝ n ((↑) : ℝ → ℂ) z := ofRealCLM.contDiff.contDiffAt
have B : ContDiffAt ℝ n e z := h.restrict_scalars ℝ
have C : ContDiffAt ℝ n re (e z) := reCLM.contDiff.contDiffAt
exact C.comp z (B.comp z A)
#align cont_diff_at.real_of_complex ContDiffAt.real_of_complex
theorem ContDiff.real_of_complex {n : ℕ∞} (h : ContDiff ℂ n e) :
ContDiff ℝ n fun x : ℝ => (e x).re :=
contDiff_iff_contDiffAt.2 fun _ => h.contDiffAt.real_of_complex
#align cont_diff.real_of_complex ContDiff.real_of_complex
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E]
theorem HasStrictDerivAt.complexToReal_fderiv' {f : ℂ → E} {x : ℂ} {f' : E}
(h : HasStrictDerivAt f f' x) :
HasStrictFDerivAt f (reCLM.smulRight f' + I • imCLM.smulRight f') x := by
simpa only [Complex.restrictScalars_one_smulRight'] using
h.hasStrictFDerivAt.restrictScalars ℝ
#align has_strict_deriv_at.complex_to_real_fderiv' HasStrictDerivAt.complexToReal_fderiv'
| Mathlib/Analysis/Complex/RealDeriv.lean | 106 | 108 | theorem HasDerivAt.complexToReal_fderiv' {f : ℂ → E} {x : ℂ} {f' : E} (h : HasDerivAt f f' x) :
HasFDerivAt f (reCLM.smulRight f' + I • imCLM.smulRight f') x := by |
simpa only [Complex.restrictScalars_one_smulRight'] using h.hasFDerivAt.restrictScalars ℝ
|
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
namespace Relation
open Multiset Prod
variable {α : Type*}
def CutExpand (r : α → α → Prop) (s' s : Multiset α) : Prop :=
∃ (t : Multiset α) (a : α), (∀ a' ∈ t, r a' a) ∧ s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : α → α → Prop}
theorem cutExpand_le_invImage_lex [DecidableEq α] [IsIrrefl α r] :
CutExpand r ≤ InvImage (Finsupp.Lex (rᶜ ⊓ (· ≠ ·)) (· < ·)) toFinsupp := by
rintro s t ⟨u, a, hr, he⟩
replace hr := fun a' ↦ mt (hr a')
classical
refine ⟨a, fun b h ↦ ?_, ?_⟩ <;> simp_rw [toFinsupp_apply]
· apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
· apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he ▸ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : ∀ x' ∈ s, r x' x) : CutExpand r s {x} :=
⟨s, x, h, add_comm s _⟩
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h ↦ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) ↔ CutExpand r t u :=
exists₂_congr fun _ _ ↦ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq α] [IsIrrefl α r] {s' s : Multiset α} :
CutExpand r s' s ↔
∃ (t : Multiset α) (a : α), (∀ a' ∈ t, r a' a) ∧ a ∈ s ∧ s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine exists₂_congr fun t a ↦ ⟨?_, ?_⟩
· rintro ⟨ht, ha, rfl⟩
obtain h | h := mem_add.1 ha
exacts [⟨ht, h, erase_add_left_pos t h⟩, (@irrefl α r _ a (ht a h)).elim]
· rintro ⟨ht, h, rfl⟩
exact ⟨ht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symm⟩
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl α r] (s) : ¬CutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro ⟨_, _, _, ⟨⟩, _⟩
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
theorem cutExpand_fibration (r : α → α → Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s ↦ s.1 + s.2 := by
rintro ⟨s₁, s₂⟩ s ⟨t, a, hr, he⟩; dsimp at he ⊢
classical
obtain ⟨ha, rfl⟩ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
· refine ⟨(s₁.erase a + t, s₂), GameAdd.fst ⟨t, a, hr, ?_⟩, ?_⟩
· rw [add_comm, ← add_assoc, singleton_add, cons_erase h]
· rw [add_assoc s₁, erase_add_left_pos _ h, add_right_comm, add_assoc]
· refine ⟨(s₁, (s₂ + t).erase a), GameAdd.snd ⟨t, a, hr, ?_⟩, ?_⟩
· rw [add_comm, singleton_add, cons_erase h]
· rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
theorem acc_of_singleton [IsIrrefl α r] {s : Multiset α} (hs : ∀ a ∈ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction with
| empty => exact Acc.intro 0 fun s h ↦ (not_cutExpand_zero s h).elim
| cons a s ihs =>
rw [← s.singleton_add a]
rw [forall_mem_cons] at hs
exact (hs.1.prod_gameAdd <| ihs fun a ha ↦ hs.2 a ha).of_fibration _ (cutExpand_fibration r)
#align relation.acc_of_singleton Relation.acc_of_singleton
| Mathlib/Logic/Hydra.lean | 138 | 146 | theorem _root_.Acc.cutExpand [IsIrrefl α r] {a : α} (hacc : Acc r a) : Acc (CutExpand r) {a} := by |
induction' hacc with a h ih
refine Acc.intro _ fun s ↦ ?_
classical
simp only [cutExpand_iff, mem_singleton]
rintro ⟨t, a, hr, rfl, rfl⟩
refine acc_of_singleton fun a' ↦ ?_
rw [erase_singleton, zero_add]
exact ih a' ∘ hr a'
|
import Mathlib.Probability.Independence.Basic
import Mathlib.Probability.Independence.Conditional
#align_import probability.independence.zero_one from "leanprover-community/mathlib"@"2f8347015b12b0864dfaf366ec4909eb70c78740"
open MeasureTheory MeasurableSpace
open scoped MeasureTheory ENNReal
namespace ProbabilityTheory
variable {α Ω ι : Type*} {_mα : MeasurableSpace α} {s : ι → MeasurableSpace Ω}
{m m0 : MeasurableSpace Ω} {κ : kernel α Ω} {μα : Measure α} {μ : Measure Ω}
theorem kernel.measure_eq_zero_or_one_or_top_of_indepSet_self {t : Set Ω}
(h_indep : kernel.IndepSet t t κ μα) :
∀ᵐ a ∂μα, κ a t = 0 ∨ κ a t = 1 ∨ κ a t = ∞ := by
specialize h_indep t t (measurableSet_generateFrom (Set.mem_singleton t))
(measurableSet_generateFrom (Set.mem_singleton t))
filter_upwards [h_indep] with a ha
by_cases h0 : κ a t = 0
· exact Or.inl h0
by_cases h_top : κ a t = ∞
· exact Or.inr (Or.inr h_top)
rw [← one_mul (κ a (t ∩ t)), Set.inter_self, ENNReal.mul_eq_mul_right h0 h_top] at ha
exact Or.inr (Or.inl ha.symm)
| Mathlib/Probability/Independence/ZeroOne.lean | 46 | 49 | theorem measure_eq_zero_or_one_or_top_of_indepSet_self {t : Set Ω}
(h_indep : IndepSet t t μ) : μ t = 0 ∨ μ t = 1 ∨ μ t = ∞ := by |
simpa only [ae_dirac_eq, Filter.eventually_pure]
using kernel.measure_eq_zero_or_one_or_top_of_indepSet_self h_indep
|
import Mathlib.AlgebraicGeometry.AffineScheme
import Mathlib.RingTheory.Nilpotent.Lemmas
import Mathlib.Topology.Sheaves.SheafCondition.Sites
import Mathlib.Algebra.Category.Ring.Constructions
import Mathlib.RingTheory.LocalProperties
#align_import algebraic_geometry.properties from "leanprover-community/mathlib"@"88474d1b5af6d37c2ab728b757771bced7f5194c"
-- Explicit universe annotations were used in this file to improve perfomance #12737
universe u
open TopologicalSpace Opposite CategoryTheory CategoryTheory.Limits TopCat
namespace AlgebraicGeometry
variable (X : Scheme)
instance : T0Space X.carrier := by
refine T0Space.of_open_cover fun x => ?_
obtain ⟨U, R, ⟨e⟩⟩ := X.local_affine x
let e' : U.1 ≃ₜ PrimeSpectrum R :=
homeoOfIso ((LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _).mapIso e)
exact ⟨U.1.1, U.2, U.1.2, e'.embedding.t0Space⟩
instance : QuasiSober X.carrier := by
apply (config := { allowSynthFailures := true })
quasiSober_of_open_cover (Set.range fun x => Set.range <| (X.affineCover.map x).1.base)
· rintro ⟨_, i, rfl⟩; exact (X.affineCover.IsOpen i).base_open.isOpen_range
· rintro ⟨_, i, rfl⟩
exact @OpenEmbedding.quasiSober _ _ _ _ _ (Homeomorph.ofEmbedding _
(X.affineCover.IsOpen i).base_open.toEmbedding).symm.openEmbedding PrimeSpectrum.quasiSober
· rw [Set.top_eq_univ, Set.sUnion_range, Set.eq_univ_iff_forall]
intro x; exact ⟨_, ⟨_, rfl⟩, X.affineCover.Covers x⟩
class IsReduced : Prop where
component_reduced : ∀ U, IsReduced (X.presheaf.obj (op U)) := by infer_instance
#align algebraic_geometry.is_reduced AlgebraicGeometry.IsReduced
attribute [instance] IsReduced.component_reduced
theorem isReducedOfStalkIsReduced [∀ x : X.carrier, _root_.IsReduced (X.presheaf.stalk x)] :
IsReduced X := by
refine ⟨fun U => ⟨fun s hs => ?_⟩⟩
apply Presheaf.section_ext X.sheaf U s 0
intro x
rw [RingHom.map_zero]
change X.presheaf.germ x s = 0
exact (hs.map _).eq_zero
#align algebraic_geometry.is_reduced_of_stalk_is_reduced AlgebraicGeometry.isReducedOfStalkIsReduced
instance stalk_isReduced_of_reduced [IsReduced X] (x : X.carrier) :
_root_.IsReduced (X.presheaf.stalk x) := by
constructor
rintro g ⟨n, e⟩
obtain ⟨U, hxU, s, rfl⟩ := X.presheaf.germ_exist x g
rw [← map_pow, ← map_zero (X.presheaf.germ ⟨x, hxU⟩)] at e
obtain ⟨V, hxV, iU, iV, e'⟩ := X.presheaf.germ_eq x hxU hxU _ 0 e
rw [map_pow, map_zero] at e'
replace e' := (IsNilpotent.mk _ _ e').eq_zero (R := X.presheaf.obj <| op V)
erw [← ConcreteCategory.congr_hom (X.presheaf.germ_res iU ⟨x, hxV⟩) s]
rw [comp_apply, e', map_zero]
#align algebraic_geometry.stalk_is_reduced_of_reduced AlgebraicGeometry.stalk_isReduced_of_reduced
theorem isReducedOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
[IsReduced Y] : IsReduced X := by
constructor
intro U
have : U = (Opens.map f.1.base).obj (H.base_open.isOpenMap.functor.obj U) := by
ext1; exact (Set.preimage_image_eq _ H.base_open.inj).symm
rw [this]
exact isReduced_of_injective (inv <| f.1.c.app (op <| H.base_open.isOpenMap.functor.obj U))
(asIso <| f.1.c.app (op <| H.base_open.isOpenMap.functor.obj U) :
Y.presheaf.obj _ ≅ _).symm.commRingCatIsoToRingEquiv.injective
#align algebraic_geometry.is_reduced_of_open_immersion AlgebraicGeometry.isReducedOfOpenImmersion
instance {R : CommRingCat.{u}} [H : _root_.IsReduced R] : IsReduced (Scheme.Spec.obj <| op R) := by
apply (config := { allowSynthFailures := true }) isReducedOfStalkIsReduced
intro x; dsimp
have : _root_.IsReduced (CommRingCat.of <| Localization.AtPrime (PrimeSpectrum.asIdeal x)) := by
dsimp; infer_instance
rw [show (Scheme.Spec.obj <| op R).presheaf = (Spec.structureSheaf R).presheaf from rfl]
exact isReduced_of_injective (StructureSheaf.stalkIso R x).hom
(StructureSheaf.stalkIso R x).commRingCatIsoToRingEquiv.injective
theorem affine_isReduced_iff (R : CommRingCat) :
IsReduced (Scheme.Spec.obj <| op R) ↔ _root_.IsReduced R := by
refine ⟨?_, fun h => inferInstance⟩
intro h
have : _root_.IsReduced
(LocallyRingedSpace.Γ.obj (op <| Spec.toLocallyRingedSpace.obj <| op R)) := by
change _root_.IsReduced ((Scheme.Spec.obj <| op R).presheaf.obj <| op ⊤); infer_instance
exact isReduced_of_injective (toSpecΓ R) (asIso <| toSpecΓ R).commRingCatIsoToRingEquiv.injective
#align algebraic_geometry.affine_is_reduced_iff AlgebraicGeometry.affine_isReduced_iff
theorem isReducedOfIsAffineIsReduced [IsAffine X] [h : _root_.IsReduced (X.presheaf.obj (op ⊤))] :
IsReduced X :=
haveI : IsReduced (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))) := by
rw [affine_isReduced_iff]; exact h
isReducedOfOpenImmersion X.isoSpec.hom
#align algebraic_geometry.is_reduced_of_is_affine_is_reduced AlgebraicGeometry.isReducedOfIsAffineIsReduced
theorem reduce_to_affine_global (P : ∀ (X : Scheme) (_ : Opens X.carrier), Prop)
(h₁ : ∀ (X : Scheme) (U : Opens X.carrier),
(∀ x : U, ∃ (V : _) (_ : x.1 ∈ V) (_ : V ⟶ U), P X V) → P X U)
(h₂ : ∀ {X Y} (f : X ⟶ Y) [hf : IsOpenImmersion f],
∃ (U : Set X.carrier) (V : Set Y.carrier) (hU : U = ⊤) (hV : V = Set.range f.1.base),
P X ⟨U, hU.symm ▸ isOpen_univ⟩ → P Y ⟨V, hV.symm ▸ hf.base_open.isOpen_range⟩)
(h₃ : ∀ R : CommRingCat, P (Scheme.Spec.obj <| op R) ⊤) :
∀ (X : Scheme) (U : Opens X.carrier), P X U := by
intro X U
apply h₁
intro x
obtain ⟨_, ⟨j, rfl⟩, hx, i⟩ :=
X.affineBasisCover_is_basis.exists_subset_of_mem_open (SetLike.mem_coe.2 x.prop) U.isOpen
let U' : Opens _ := ⟨_, (X.affineBasisCover.IsOpen j).base_open.isOpen_range⟩
let i' : U' ⟶ U := homOfLE i
refine ⟨U', hx, i', ?_⟩
obtain ⟨_, _, rfl, rfl, h₂'⟩ := h₂ (X.affineBasisCover.map j)
apply h₂'
apply h₃
#align algebraic_geometry.reduce_to_affine_global AlgebraicGeometry.reduce_to_affine_global
theorem reduce_to_affine_nbhd (P : ∀ (X : Scheme) (_ : X.carrier), Prop)
(h₁ : ∀ (R : CommRingCat) (x : PrimeSpectrum R), P (Scheme.Spec.obj <| op R) x)
(h₂ : ∀ {X Y} (f : X ⟶ Y) [IsOpenImmersion f] (x : X.carrier), P X x → P Y (f.1.base x)) :
∀ (X : Scheme) (x : X.carrier), P X x := by
intro X x
obtain ⟨y, e⟩ := X.affineCover.Covers x
convert h₂ (X.affineCover.map (X.affineCover.f x)) y _
· rw [e]
apply h₁
#align algebraic_geometry.reduce_to_affine_nbhd AlgebraicGeometry.reduce_to_affine_nbhd
theorem eq_zero_of_basicOpen_eq_bot {X : Scheme} [hX : IsReduced X] {U : Opens X.carrier}
(s : X.presheaf.obj (op U)) (hs : X.basicOpen s = ⊥) : s = 0 := by
apply TopCat.Presheaf.section_ext X.sheaf U
conv => intro x; rw [RingHom.map_zero]
refine (@reduce_to_affine_global (fun X U =>
∀ [IsReduced X] (s : X.presheaf.obj (op U)),
X.basicOpen s = ⊥ → ∀ x, (X.sheaf.presheaf.germ x) s = 0) ?_ ?_ ?_) X U s hs
· intro X U hx hX s hs x
obtain ⟨V, hx, i, H⟩ := hx x
specialize H (X.presheaf.map i.op s)
erw [Scheme.basicOpen_res] at H
rw [hs] at H
specialize H (inf_bot_eq _) ⟨x, hx⟩
erw [TopCat.Presheaf.germ_res_apply] at H
exact H
· rintro X Y f hf
have e : f.val.base ⁻¹' Set.range ↑f.val.base = Set.univ := by
rw [← Set.image_univ, Set.preimage_image_eq _ hf.base_open.inj]
refine ⟨_, _, e, rfl, ?_⟩
rintro H hX s hs ⟨_, x, rfl⟩
haveI := isReducedOfOpenImmersion f
specialize H (f.1.c.app _ s) _ ⟨x, by rw [Opens.mem_mk, e]; trivial⟩
· rw [← Scheme.preimage_basicOpen, hs]; ext1; simp [Opens.map]
· erw [← PresheafedSpace.stalkMap_germ_apply f.1 ⟨_, _⟩ ⟨x, _⟩] at H
apply_fun inv <| PresheafedSpace.stalkMap f.val x at H
erw [CategoryTheory.IsIso.hom_inv_id_apply, map_zero] at H
exact H
· intro R hX s hs x
erw [basicOpen_eq_of_affine', PrimeSpectrum.basicOpen_eq_bot_iff] at hs
replace hs := hs.map (SpecΓIdentity.app R).inv
-- what the hell?!
replace hs := @IsNilpotent.eq_zero _ _ _ _ (show _ from ?_) hs
· rw [Iso.hom_inv_id_apply] at hs
rw [hs, map_zero]
exact @IsReduced.component_reduced _ hX ⊤
#align algebraic_geometry.eq_zero_of_basic_open_eq_bot AlgebraicGeometry.eq_zero_of_basicOpen_eq_bot
@[simp]
| Mathlib/AlgebraicGeometry/Properties.lean | 198 | 202 | theorem basicOpen_eq_bot_iff {X : Scheme} [IsReduced X] {U : Opens X.carrier}
(s : X.presheaf.obj <| op U) : X.basicOpen s = ⊥ ↔ s = 0 := by |
refine ⟨eq_zero_of_basicOpen_eq_bot s, ?_⟩
rintro rfl
simp
|
import Mathlib.Init.Function
import Mathlib.Init.Order.Defs
#align_import data.bool.basic from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
namespace Bool
@[deprecated (since := "2024-06-07")] alias decide_True := decide_true_eq_true
#align bool.to_bool_true decide_true_eq_true
@[deprecated (since := "2024-06-07")] alias decide_False := decide_false_eq_false
#align bool.to_bool_false decide_false_eq_false
#align bool.to_bool_coe Bool.decide_coe
@[deprecated (since := "2024-06-07")] alias coe_decide := decide_eq_true_iff
#align bool.coe_to_bool decide_eq_true_iff
@[deprecated decide_eq_true_iff (since := "2024-06-07")]
alias of_decide_iff := decide_eq_true_iff
#align bool.of_to_bool_iff decide_eq_true_iff
#align bool.tt_eq_to_bool_iff true_eq_decide_iff
#align bool.ff_eq_to_bool_iff false_eq_decide_iff
@[deprecated (since := "2024-06-07")] alias decide_not := decide_not
#align bool.to_bool_not decide_not
#align bool.to_bool_and Bool.decide_and
#align bool.to_bool_or Bool.decide_or
#align bool.to_bool_eq decide_eq_decide
@[deprecated (since := "2024-06-07")] alias not_false' := false_ne_true
#align bool.not_ff Bool.false_ne_true
@[deprecated (since := "2024-06-07")] alias eq_iff_eq_true_iff := eq_iff_iff
#align bool.default_bool Bool.default_bool
theorem dichotomy (b : Bool) : b = false ∨ b = true := by cases b <;> simp
#align bool.dichotomy Bool.dichotomy
theorem forall_bool' {p : Bool → Prop} (b : Bool) : (∀ x, p x) ↔ p b ∧ p !b :=
⟨fun h ↦ ⟨h _, h _⟩, fun ⟨h₁, h₂⟩ x ↦ by cases b <;> cases x <;> assumption⟩
@[simp]
theorem forall_bool {p : Bool → Prop} : (∀ b, p b) ↔ p false ∧ p true :=
forall_bool' false
#align bool.forall_bool Bool.forall_bool
theorem exists_bool' {p : Bool → Prop} (b : Bool) : (∃ x, p x) ↔ p b ∨ p !b :=
⟨fun ⟨x, hx⟩ ↦ by cases x <;> cases b <;> first | exact .inl ‹_› | exact .inr ‹_›,
fun h ↦ by cases h <;> exact ⟨_, ‹_›⟩⟩
@[simp]
theorem exists_bool {p : Bool → Prop} : (∃ b, p b) ↔ p false ∨ p true :=
exists_bool' false
#align bool.exists_bool Bool.exists_bool
#align bool.decidable_forall_bool Bool.instDecidableForallOfDecidablePred
#align bool.decidable_exists_bool Bool.instDecidableExistsOfDecidablePred
#align bool.cond_eq_ite Bool.cond_eq_ite
#align bool.cond_to_bool Bool.cond_decide
#align bool.cond_bnot Bool.cond_not
theorem not_ne_id : not ≠ id := fun h ↦ false_ne_true <| congrFun h true
#align bool.bnot_ne_id Bool.not_ne_id
#align bool.coe_bool_iff Bool.coe_iff_coe
@[deprecated (since := "2024-06-07")] alias eq_true_of_ne_false := eq_true_of_ne_false
#align bool.eq_tt_of_ne_ff eq_true_of_ne_false
@[deprecated (since := "2024-06-07")] alias eq_false_of_ne_true := eq_false_of_ne_true
#align bool.eq_ff_of_ne_tt eq_true_of_ne_false
#align bool.bor_comm Bool.or_comm
#align bool.bor_assoc Bool.or_assoc
#align bool.bor_left_comm Bool.or_left_comm
theorem or_inl {a b : Bool} (H : a) : a || b := by simp [H]
#align bool.bor_inl Bool.or_inl
theorem or_inr {a b : Bool} (H : b) : a || b := by cases a <;> simp [H]
#align bool.bor_inr Bool.or_inr
#align bool.band_comm Bool.and_comm
#align bool.band_assoc Bool.and_assoc
#align bool.band_left_comm Bool.and_left_comm
theorem and_elim_left : ∀ {a b : Bool}, a && b → a := by decide
#align bool.band_elim_left Bool.and_elim_left
| Mathlib/Data/Bool/Basic.lean | 112 | 112 | theorem and_intro : ∀ {a b : Bool}, a → b → a && b := by | decide
|
import Mathlib.MeasureTheory.Measure.MeasureSpace
open scoped ENNReal NNReal Topology
open Set MeasureTheory Measure Filter MeasurableSpace ENNReal Function
variable {R α β δ γ ι : Type*}
namespace MeasureTheory
variable {m0 : MeasurableSpace α} [MeasurableSpace β] [MeasurableSpace γ]
variable {μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α} {s s' t : Set α}
namespace Measure
noncomputable def restrictₗ {m0 : MeasurableSpace α} (s : Set α) : Measure α →ₗ[ℝ≥0∞] Measure α :=
liftLinear (OuterMeasure.restrict s) fun μ s' hs' t => by
suffices μ (s ∩ t) = μ (s ∩ t ∩ s') + μ ((s ∩ t) \ s') by
simpa [← Set.inter_assoc, Set.inter_comm _ s, ← inter_diff_assoc]
exact le_toOuterMeasure_caratheodory _ _ hs' _
#align measure_theory.measure.restrictₗ MeasureTheory.Measure.restrictₗ
noncomputable def restrict {_m0 : MeasurableSpace α} (μ : Measure α) (s : Set α) : Measure α :=
restrictₗ s μ
#align measure_theory.measure.restrict MeasureTheory.Measure.restrict
@[simp]
theorem restrictₗ_apply {_m0 : MeasurableSpace α} (s : Set α) (μ : Measure α) :
restrictₗ s μ = μ.restrict s :=
rfl
#align measure_theory.measure.restrictₗ_apply MeasureTheory.Measure.restrictₗ_apply
theorem restrict_toOuterMeasure_eq_toOuterMeasure_restrict (h : MeasurableSet s) :
(μ.restrict s).toOuterMeasure = OuterMeasure.restrict s μ.toOuterMeasure := by
simp_rw [restrict, restrictₗ, liftLinear, LinearMap.coe_mk, AddHom.coe_mk,
toMeasure_toOuterMeasure, OuterMeasure.restrict_trim h, μ.trimmed]
#align measure_theory.measure.restrict_to_outer_measure_eq_to_outer_measure_restrict MeasureTheory.Measure.restrict_toOuterMeasure_eq_toOuterMeasure_restrict
theorem restrict_apply₀ (ht : NullMeasurableSet t (μ.restrict s)) : μ.restrict s t = μ (t ∩ s) := by
rw [← restrictₗ_apply, restrictₗ, liftLinear_apply₀ _ ht, OuterMeasure.restrict_apply,
coe_toOuterMeasure]
#align measure_theory.measure.restrict_apply₀ MeasureTheory.Measure.restrict_apply₀
@[simp]
theorem restrict_apply (ht : MeasurableSet t) : μ.restrict s t = μ (t ∩ s) :=
restrict_apply₀ ht.nullMeasurableSet
#align measure_theory.measure.restrict_apply MeasureTheory.Measure.restrict_apply
theorem restrict_mono' {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ ⦃μ ν : Measure α⦄ (hs : s ≤ᵐ[μ] s')
(hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' :=
Measure.le_iff.2 fun t ht => calc
μ.restrict s t = μ (t ∩ s) := restrict_apply ht
_ ≤ μ (t ∩ s') := (measure_mono_ae <| hs.mono fun _x hx ⟨hxt, hxs⟩ => ⟨hxt, hx hxs⟩)
_ ≤ ν (t ∩ s') := le_iff'.1 hμν (t ∩ s')
_ = ν.restrict s' t := (restrict_apply ht).symm
#align measure_theory.measure.restrict_mono' MeasureTheory.Measure.restrict_mono'
@[mono]
theorem restrict_mono {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ (hs : s ⊆ s') ⦃μ ν : Measure α⦄
(hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' :=
restrict_mono' (ae_of_all _ hs) hμν
#align measure_theory.measure.restrict_mono MeasureTheory.Measure.restrict_mono
theorem restrict_mono_ae (h : s ≤ᵐ[μ] t) : μ.restrict s ≤ μ.restrict t :=
restrict_mono' h (le_refl μ)
#align measure_theory.measure.restrict_mono_ae MeasureTheory.Measure.restrict_mono_ae
theorem restrict_congr_set (h : s =ᵐ[μ] t) : μ.restrict s = μ.restrict t :=
le_antisymm (restrict_mono_ae h.le) (restrict_mono_ae h.symm.le)
#align measure_theory.measure.restrict_congr_set MeasureTheory.Measure.restrict_congr_set
@[simp]
theorem restrict_apply' (hs : MeasurableSet s) : μ.restrict s t = μ (t ∩ s) := by
rw [← toOuterMeasure_apply,
Measure.restrict_toOuterMeasure_eq_toOuterMeasure_restrict hs,
OuterMeasure.restrict_apply s t _, toOuterMeasure_apply]
#align measure_theory.measure.restrict_apply' MeasureTheory.Measure.restrict_apply'
theorem restrict_apply₀' (hs : NullMeasurableSet s μ) : μ.restrict s t = μ (t ∩ s) := by
rw [← restrict_congr_set hs.toMeasurable_ae_eq,
restrict_apply' (measurableSet_toMeasurable _ _),
measure_congr ((ae_eq_refl t).inter hs.toMeasurable_ae_eq)]
#align measure_theory.measure.restrict_apply₀' MeasureTheory.Measure.restrict_apply₀'
theorem restrict_le_self : μ.restrict s ≤ μ :=
Measure.le_iff.2 fun t ht => calc
μ.restrict s t = μ (t ∩ s) := restrict_apply ht
_ ≤ μ t := measure_mono inter_subset_left
#align measure_theory.measure.restrict_le_self MeasureTheory.Measure.restrict_le_self
variable (μ)
theorem restrict_eq_self (h : s ⊆ t) : μ.restrict t s = μ s :=
(le_iff'.1 restrict_le_self s).antisymm <|
calc
μ s ≤ μ (toMeasurable (μ.restrict t) s ∩ t) :=
measure_mono (subset_inter (subset_toMeasurable _ _) h)
_ = μ.restrict t s := by
rw [← restrict_apply (measurableSet_toMeasurable _ _), measure_toMeasurable]
#align measure_theory.measure.restrict_eq_self MeasureTheory.Measure.restrict_eq_self
@[simp]
theorem restrict_apply_self (s : Set α) : (μ.restrict s) s = μ s :=
restrict_eq_self μ Subset.rfl
#align measure_theory.measure.restrict_apply_self MeasureTheory.Measure.restrict_apply_self
variable {μ}
theorem restrict_apply_univ (s : Set α) : μ.restrict s univ = μ s := by
rw [restrict_apply MeasurableSet.univ, Set.univ_inter]
#align measure_theory.measure.restrict_apply_univ MeasureTheory.Measure.restrict_apply_univ
theorem le_restrict_apply (s t : Set α) : μ (t ∩ s) ≤ μ.restrict s t :=
calc
μ (t ∩ s) = μ.restrict s (t ∩ s) := (restrict_eq_self μ inter_subset_right).symm
_ ≤ μ.restrict s t := measure_mono inter_subset_left
#align measure_theory.measure.le_restrict_apply MeasureTheory.Measure.le_restrict_apply
theorem restrict_apply_le (s t : Set α) : μ.restrict s t ≤ μ t :=
Measure.le_iff'.1 restrict_le_self _
theorem restrict_apply_superset (h : s ⊆ t) : μ.restrict s t = μ s :=
((measure_mono (subset_univ _)).trans_eq <| restrict_apply_univ _).antisymm
((restrict_apply_self μ s).symm.trans_le <| measure_mono h)
#align measure_theory.measure.restrict_apply_superset MeasureTheory.Measure.restrict_apply_superset
@[simp]
theorem restrict_add {_m0 : MeasurableSpace α} (μ ν : Measure α) (s : Set α) :
(μ + ν).restrict s = μ.restrict s + ν.restrict s :=
(restrictₗ s).map_add μ ν
#align measure_theory.measure.restrict_add MeasureTheory.Measure.restrict_add
@[simp]
theorem restrict_zero {_m0 : MeasurableSpace α} (s : Set α) : (0 : Measure α).restrict s = 0 :=
(restrictₗ s).map_zero
#align measure_theory.measure.restrict_zero MeasureTheory.Measure.restrict_zero
@[simp]
theorem restrict_smul {_m0 : MeasurableSpace α} (c : ℝ≥0∞) (μ : Measure α) (s : Set α) :
(c • μ).restrict s = c • μ.restrict s :=
(restrictₗ s).map_smul c μ
#align measure_theory.measure.restrict_smul MeasureTheory.Measure.restrict_smul
theorem restrict_restrict₀ (hs : NullMeasurableSet s (μ.restrict t)) :
(μ.restrict t).restrict s = μ.restrict (s ∩ t) :=
ext fun u hu => by
simp only [Set.inter_assoc, restrict_apply hu,
restrict_apply₀ (hu.nullMeasurableSet.inter hs)]
#align measure_theory.measure.restrict_restrict₀ MeasureTheory.Measure.restrict_restrict₀
@[simp]
theorem restrict_restrict (hs : MeasurableSet s) : (μ.restrict t).restrict s = μ.restrict (s ∩ t) :=
restrict_restrict₀ hs.nullMeasurableSet
#align measure_theory.measure.restrict_restrict MeasureTheory.Measure.restrict_restrict
theorem restrict_restrict_of_subset (h : s ⊆ t) : (μ.restrict t).restrict s = μ.restrict s := by
ext1 u hu
rw [restrict_apply hu, restrict_apply hu, restrict_eq_self]
exact inter_subset_right.trans h
#align measure_theory.measure.restrict_restrict_of_subset MeasureTheory.Measure.restrict_restrict_of_subset
theorem restrict_restrict₀' (ht : NullMeasurableSet t μ) :
(μ.restrict t).restrict s = μ.restrict (s ∩ t) :=
ext fun u hu => by simp only [restrict_apply hu, restrict_apply₀' ht, inter_assoc]
#align measure_theory.measure.restrict_restrict₀' MeasureTheory.Measure.restrict_restrict₀'
theorem restrict_restrict' (ht : MeasurableSet t) :
(μ.restrict t).restrict s = μ.restrict (s ∩ t) :=
restrict_restrict₀' ht.nullMeasurableSet
#align measure_theory.measure.restrict_restrict' MeasureTheory.Measure.restrict_restrict'
theorem restrict_comm (hs : MeasurableSet s) :
(μ.restrict t).restrict s = (μ.restrict s).restrict t := by
rw [restrict_restrict hs, restrict_restrict' hs, inter_comm]
#align measure_theory.measure.restrict_comm MeasureTheory.Measure.restrict_comm
theorem restrict_apply_eq_zero (ht : MeasurableSet t) : μ.restrict s t = 0 ↔ μ (t ∩ s) = 0 := by
rw [restrict_apply ht]
#align measure_theory.measure.restrict_apply_eq_zero MeasureTheory.Measure.restrict_apply_eq_zero
theorem measure_inter_eq_zero_of_restrict (h : μ.restrict s t = 0) : μ (t ∩ s) = 0 :=
nonpos_iff_eq_zero.1 (h ▸ le_restrict_apply _ _)
#align measure_theory.measure.measure_inter_eq_zero_of_restrict MeasureTheory.Measure.measure_inter_eq_zero_of_restrict
theorem restrict_apply_eq_zero' (hs : MeasurableSet s) : μ.restrict s t = 0 ↔ μ (t ∩ s) = 0 := by
rw [restrict_apply' hs]
#align measure_theory.measure.restrict_apply_eq_zero' MeasureTheory.Measure.restrict_apply_eq_zero'
@[simp]
theorem restrict_eq_zero : μ.restrict s = 0 ↔ μ s = 0 := by
rw [← measure_univ_eq_zero, restrict_apply_univ]
#align measure_theory.measure.restrict_eq_zero MeasureTheory.Measure.restrict_eq_zero
instance restrict.neZero [NeZero (μ s)] : NeZero (μ.restrict s) :=
⟨mt restrict_eq_zero.mp <| NeZero.ne _⟩
theorem restrict_zero_set {s : Set α} (h : μ s = 0) : μ.restrict s = 0 :=
restrict_eq_zero.2 h
#align measure_theory.measure.restrict_zero_set MeasureTheory.Measure.restrict_zero_set
@[simp]
theorem restrict_empty : μ.restrict ∅ = 0 :=
restrict_zero_set measure_empty
#align measure_theory.measure.restrict_empty MeasureTheory.Measure.restrict_empty
@[simp]
theorem restrict_univ : μ.restrict univ = μ :=
ext fun s hs => by simp [hs]
#align measure_theory.measure.restrict_univ MeasureTheory.Measure.restrict_univ
theorem restrict_inter_add_diff₀ (s : Set α) (ht : NullMeasurableSet t μ) :
μ.restrict (s ∩ t) + μ.restrict (s \ t) = μ.restrict s := by
ext1 u hu
simp only [add_apply, restrict_apply hu, ← inter_assoc, diff_eq]
exact measure_inter_add_diff₀ (u ∩ s) ht
#align measure_theory.measure.restrict_inter_add_diff₀ MeasureTheory.Measure.restrict_inter_add_diff₀
theorem restrict_inter_add_diff (s : Set α) (ht : MeasurableSet t) :
μ.restrict (s ∩ t) + μ.restrict (s \ t) = μ.restrict s :=
restrict_inter_add_diff₀ s ht.nullMeasurableSet
#align measure_theory.measure.restrict_inter_add_diff MeasureTheory.Measure.restrict_inter_add_diff
theorem restrict_union_add_inter₀ (s : Set α) (ht : NullMeasurableSet t μ) :
μ.restrict (s ∪ t) + μ.restrict (s ∩ t) = μ.restrict s + μ.restrict t := by
rw [← restrict_inter_add_diff₀ (s ∪ t) ht, union_inter_cancel_right, union_diff_right, ←
restrict_inter_add_diff₀ s ht, add_comm, ← add_assoc, add_right_comm]
#align measure_theory.measure.restrict_union_add_inter₀ MeasureTheory.Measure.restrict_union_add_inter₀
theorem restrict_union_add_inter (s : Set α) (ht : MeasurableSet t) :
μ.restrict (s ∪ t) + μ.restrict (s ∩ t) = μ.restrict s + μ.restrict t :=
restrict_union_add_inter₀ s ht.nullMeasurableSet
#align measure_theory.measure.restrict_union_add_inter MeasureTheory.Measure.restrict_union_add_inter
theorem restrict_union_add_inter' (hs : MeasurableSet s) (t : Set α) :
μ.restrict (s ∪ t) + μ.restrict (s ∩ t) = μ.restrict s + μ.restrict t := by
simpa only [union_comm, inter_comm, add_comm] using restrict_union_add_inter t hs
#align measure_theory.measure.restrict_union_add_inter' MeasureTheory.Measure.restrict_union_add_inter'
theorem restrict_union₀ (h : AEDisjoint μ s t) (ht : NullMeasurableSet t μ) :
μ.restrict (s ∪ t) = μ.restrict s + μ.restrict t := by
simp [← restrict_union_add_inter₀ s ht, restrict_zero_set h]
#align measure_theory.measure.restrict_union₀ MeasureTheory.Measure.restrict_union₀
theorem restrict_union (h : Disjoint s t) (ht : MeasurableSet t) :
μ.restrict (s ∪ t) = μ.restrict s + μ.restrict t :=
restrict_union₀ h.aedisjoint ht.nullMeasurableSet
#align measure_theory.measure.restrict_union MeasureTheory.Measure.restrict_union
theorem restrict_union' (h : Disjoint s t) (hs : MeasurableSet s) :
μ.restrict (s ∪ t) = μ.restrict s + μ.restrict t := by
rw [union_comm, restrict_union h.symm hs, add_comm]
#align measure_theory.measure.restrict_union' MeasureTheory.Measure.restrict_union'
@[simp]
theorem restrict_add_restrict_compl (hs : MeasurableSet s) :
μ.restrict s + μ.restrict sᶜ = μ := by
rw [← restrict_union (@disjoint_compl_right (Set α) _ _) hs.compl, union_compl_self,
restrict_univ]
#align measure_theory.measure.restrict_add_restrict_compl MeasureTheory.Measure.restrict_add_restrict_compl
@[simp]
theorem restrict_compl_add_restrict (hs : MeasurableSet s) : μ.restrict sᶜ + μ.restrict s = μ := by
rw [add_comm, restrict_add_restrict_compl hs]
#align measure_theory.measure.restrict_compl_add_restrict MeasureTheory.Measure.restrict_compl_add_restrict
theorem restrict_union_le (s s' : Set α) : μ.restrict (s ∪ s') ≤ μ.restrict s + μ.restrict s' :=
le_iff.2 fun t ht ↦ by
simpa [ht, inter_union_distrib_left] using measure_union_le (t ∩ s) (t ∩ s')
#align measure_theory.measure.restrict_union_le MeasureTheory.Measure.restrict_union_le
theorem restrict_iUnion_apply_ae [Countable ι] {s : ι → Set α} (hd : Pairwise (AEDisjoint μ on s))
(hm : ∀ i, NullMeasurableSet (s i) μ) {t : Set α} (ht : MeasurableSet t) :
μ.restrict (⋃ i, s i) t = ∑' i, μ.restrict (s i) t := by
simp only [restrict_apply, ht, inter_iUnion]
exact
measure_iUnion₀ (hd.mono fun i j h => h.mono inter_subset_right inter_subset_right)
fun i => ht.nullMeasurableSet.inter (hm i)
#align measure_theory.measure.restrict_Union_apply_ae MeasureTheory.Measure.restrict_iUnion_apply_ae
theorem restrict_iUnion_apply [Countable ι] {s : ι → Set α} (hd : Pairwise (Disjoint on s))
(hm : ∀ i, MeasurableSet (s i)) {t : Set α} (ht : MeasurableSet t) :
μ.restrict (⋃ i, s i) t = ∑' i, μ.restrict (s i) t :=
restrict_iUnion_apply_ae hd.aedisjoint (fun i => (hm i).nullMeasurableSet) ht
#align measure_theory.measure.restrict_Union_apply MeasureTheory.Measure.restrict_iUnion_apply
theorem restrict_iUnion_apply_eq_iSup [Countable ι] {s : ι → Set α} (hd : Directed (· ⊆ ·) s)
{t : Set α} (ht : MeasurableSet t) : μ.restrict (⋃ i, s i) t = ⨆ i, μ.restrict (s i) t := by
simp only [restrict_apply ht, inter_iUnion]
rw [measure_iUnion_eq_iSup]
exacts [hd.mono_comp _ fun s₁ s₂ => inter_subset_inter_right _]
#align measure_theory.measure.restrict_Union_apply_eq_supr MeasureTheory.Measure.restrict_iUnion_apply_eq_iSup
theorem restrict_map {f : α → β} (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) :
(μ.map f).restrict s = (μ.restrict <| f ⁻¹' s).map f :=
ext fun t ht => by simp [*, hf ht]
#align measure_theory.measure.restrict_map MeasureTheory.Measure.restrict_map
theorem restrict_toMeasurable (h : μ s ≠ ∞) : μ.restrict (toMeasurable μ s) = μ.restrict s :=
ext fun t ht => by
rw [restrict_apply ht, restrict_apply ht, inter_comm, measure_toMeasurable_inter ht h,
inter_comm]
#align measure_theory.measure.restrict_to_measurable MeasureTheory.Measure.restrict_toMeasurable
theorem restrict_eq_self_of_ae_mem {_m0 : MeasurableSpace α} ⦃s : Set α⦄ ⦃μ : Measure α⦄
(hs : ∀ᵐ x ∂μ, x ∈ s) : μ.restrict s = μ :=
calc
μ.restrict s = μ.restrict univ := restrict_congr_set (eventuallyEq_univ.mpr hs)
_ = μ := restrict_univ
#align measure_theory.measure.restrict_eq_self_of_ae_mem MeasureTheory.Measure.restrict_eq_self_of_ae_mem
theorem restrict_congr_meas (hs : MeasurableSet s) :
μ.restrict s = ν.restrict s ↔ ∀ t ⊆ s, MeasurableSet t → μ t = ν t :=
⟨fun H t hts ht => by
rw [← inter_eq_self_of_subset_left hts, ← restrict_apply ht, H, restrict_apply ht], fun H =>
ext fun t ht => by
rw [restrict_apply ht, restrict_apply ht, H _ inter_subset_right (ht.inter hs)]⟩
#align measure_theory.measure.restrict_congr_meas MeasureTheory.Measure.restrict_congr_meas
theorem restrict_congr_mono (hs : s ⊆ t) (h : μ.restrict t = ν.restrict t) :
μ.restrict s = ν.restrict s := by
rw [← restrict_restrict_of_subset hs, h, restrict_restrict_of_subset hs]
#align measure_theory.measure.restrict_congr_mono MeasureTheory.Measure.restrict_congr_mono
theorem restrict_union_congr :
μ.restrict (s ∪ t) = ν.restrict (s ∪ t) ↔
μ.restrict s = ν.restrict s ∧ μ.restrict t = ν.restrict t := by
refine
⟨fun h =>
⟨restrict_congr_mono subset_union_left h,
restrict_congr_mono subset_union_right h⟩,
?_⟩
rintro ⟨hs, ht⟩
ext1 u hu
simp only [restrict_apply hu, inter_union_distrib_left]
rcases exists_measurable_superset₂ μ ν (u ∩ s) with ⟨US, hsub, hm, hμ, hν⟩
calc
μ (u ∩ s ∪ u ∩ t) = μ (US ∪ u ∩ t) :=
measure_union_congr_of_subset hsub hμ.le Subset.rfl le_rfl
_ = μ US + μ ((u ∩ t) \ US) := (measure_add_diff hm _).symm
_ = restrict μ s u + restrict μ t (u \ US) := by
simp only [restrict_apply, hu, hu.diff hm, hμ, ← inter_comm t, inter_diff_assoc]
_ = restrict ν s u + restrict ν t (u \ US) := by rw [hs, ht]
_ = ν US + ν ((u ∩ t) \ US) := by
simp only [restrict_apply, hu, hu.diff hm, hν, ← inter_comm t, inter_diff_assoc]
_ = ν (US ∪ u ∩ t) := measure_add_diff hm _
_ = ν (u ∩ s ∪ u ∩ t) := Eq.symm <| measure_union_congr_of_subset hsub hν.le Subset.rfl le_rfl
#align measure_theory.measure.restrict_union_congr MeasureTheory.Measure.restrict_union_congr
| Mathlib/MeasureTheory/Measure/Restrict.lean | 385 | 391 | theorem restrict_finset_biUnion_congr {s : Finset ι} {t : ι → Set α} :
μ.restrict (⋃ i ∈ s, t i) = ν.restrict (⋃ i ∈ s, t i) ↔
∀ i ∈ s, μ.restrict (t i) = ν.restrict (t i) := by |
classical
induction' s using Finset.induction_on with i s _ hs; · simp
simp only [forall_eq_or_imp, iUnion_iUnion_eq_or_left, Finset.mem_insert]
rw [restrict_union_congr, ← hs]
|
import Mathlib.Order.Interval.Set.UnorderedInterval
import Mathlib.Algebra.Order.Interval.Set.Monoid
import Mathlib.Data.Set.Pointwise.Basic
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Algebra.Order.Group.MinMax
#align_import data.set.pointwise.interval from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
open Interval Pointwise
variable {α : Type*}
namespace Set
section OrderedAddCommGroup
variable [OrderedAddCommGroup α] (a b c : α)
@[simp]
theorem preimage_const_add_Ici : (fun x => a + x) ⁻¹' Ici b = Ici (b - a) :=
ext fun _x => sub_le_iff_le_add'.symm
#align set.preimage_const_add_Ici Set.preimage_const_add_Ici
@[simp]
theorem preimage_const_add_Ioi : (fun x => a + x) ⁻¹' Ioi b = Ioi (b - a) :=
ext fun _x => sub_lt_iff_lt_add'.symm
#align set.preimage_const_add_Ioi Set.preimage_const_add_Ioi
@[simp]
theorem preimage_const_add_Iic : (fun x => a + x) ⁻¹' Iic b = Iic (b - a) :=
ext fun _x => le_sub_iff_add_le'.symm
#align set.preimage_const_add_Iic Set.preimage_const_add_Iic
@[simp]
theorem preimage_const_add_Iio : (fun x => a + x) ⁻¹' Iio b = Iio (b - a) :=
ext fun _x => lt_sub_iff_add_lt'.symm
#align set.preimage_const_add_Iio Set.preimage_const_add_Iio
@[simp]
theorem preimage_const_add_Icc : (fun x => a + x) ⁻¹' Icc b c = Icc (b - a) (c - a) := by
simp [← Ici_inter_Iic]
#align set.preimage_const_add_Icc Set.preimage_const_add_Icc
@[simp]
theorem preimage_const_add_Ico : (fun x => a + x) ⁻¹' Ico b c = Ico (b - a) (c - a) := by
simp [← Ici_inter_Iio]
#align set.preimage_const_add_Ico Set.preimage_const_add_Ico
@[simp]
theorem preimage_const_add_Ioc : (fun x => a + x) ⁻¹' Ioc b c = Ioc (b - a) (c - a) := by
simp [← Ioi_inter_Iic]
#align set.preimage_const_add_Ioc Set.preimage_const_add_Ioc
@[simp]
theorem preimage_const_add_Ioo : (fun x => a + x) ⁻¹' Ioo b c = Ioo (b - a) (c - a) := by
simp [← Ioi_inter_Iio]
#align set.preimage_const_add_Ioo Set.preimage_const_add_Ioo
@[simp]
theorem preimage_add_const_Ici : (fun x => x + a) ⁻¹' Ici b = Ici (b - a) :=
ext fun _x => sub_le_iff_le_add.symm
#align set.preimage_add_const_Ici Set.preimage_add_const_Ici
@[simp]
theorem preimage_add_const_Ioi : (fun x => x + a) ⁻¹' Ioi b = Ioi (b - a) :=
ext fun _x => sub_lt_iff_lt_add.symm
#align set.preimage_add_const_Ioi Set.preimage_add_const_Ioi
@[simp]
theorem preimage_add_const_Iic : (fun x => x + a) ⁻¹' Iic b = Iic (b - a) :=
ext fun _x => le_sub_iff_add_le.symm
#align set.preimage_add_const_Iic Set.preimage_add_const_Iic
@[simp]
theorem preimage_add_const_Iio : (fun x => x + a) ⁻¹' Iio b = Iio (b - a) :=
ext fun _x => lt_sub_iff_add_lt.symm
#align set.preimage_add_const_Iio Set.preimage_add_const_Iio
@[simp]
theorem preimage_add_const_Icc : (fun x => x + a) ⁻¹' Icc b c = Icc (b - a) (c - a) := by
simp [← Ici_inter_Iic]
#align set.preimage_add_const_Icc Set.preimage_add_const_Icc
@[simp]
theorem preimage_add_const_Ico : (fun x => x + a) ⁻¹' Ico b c = Ico (b - a) (c - a) := by
simp [← Ici_inter_Iio]
#align set.preimage_add_const_Ico Set.preimage_add_const_Ico
@[simp]
theorem preimage_add_const_Ioc : (fun x => x + a) ⁻¹' Ioc b c = Ioc (b - a) (c - a) := by
simp [← Ioi_inter_Iic]
#align set.preimage_add_const_Ioc Set.preimage_add_const_Ioc
@[simp]
theorem preimage_add_const_Ioo : (fun x => x + a) ⁻¹' Ioo b c = Ioo (b - a) (c - a) := by
simp [← Ioi_inter_Iio]
#align set.preimage_add_const_Ioo Set.preimage_add_const_Ioo
@[simp]
theorem preimage_neg_Ici : -Ici a = Iic (-a) :=
ext fun _x => le_neg
#align set.preimage_neg_Ici Set.preimage_neg_Ici
@[simp]
theorem preimage_neg_Iic : -Iic a = Ici (-a) :=
ext fun _x => neg_le
#align set.preimage_neg_Iic Set.preimage_neg_Iic
@[simp]
theorem preimage_neg_Ioi : -Ioi a = Iio (-a) :=
ext fun _x => lt_neg
#align set.preimage_neg_Ioi Set.preimage_neg_Ioi
@[simp]
theorem preimage_neg_Iio : -Iio a = Ioi (-a) :=
ext fun _x => neg_lt
#align set.preimage_neg_Iio Set.preimage_neg_Iio
@[simp]
theorem preimage_neg_Icc : -Icc a b = Icc (-b) (-a) := by simp [← Ici_inter_Iic, inter_comm]
#align set.preimage_neg_Icc Set.preimage_neg_Icc
@[simp]
theorem preimage_neg_Ico : -Ico a b = Ioc (-b) (-a) := by
simp [← Ici_inter_Iio, ← Ioi_inter_Iic, inter_comm]
#align set.preimage_neg_Ico Set.preimage_neg_Ico
@[simp]
theorem preimage_neg_Ioc : -Ioc a b = Ico (-b) (-a) := by
simp [← Ioi_inter_Iic, ← Ici_inter_Iio, inter_comm]
#align set.preimage_neg_Ioc Set.preimage_neg_Ioc
@[simp]
theorem preimage_neg_Ioo : -Ioo a b = Ioo (-b) (-a) := by simp [← Ioi_inter_Iio, inter_comm]
#align set.preimage_neg_Ioo Set.preimage_neg_Ioo
@[simp]
theorem preimage_sub_const_Ici : (fun x => x - a) ⁻¹' Ici b = Ici (b + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Ici Set.preimage_sub_const_Ici
@[simp]
theorem preimage_sub_const_Ioi : (fun x => x - a) ⁻¹' Ioi b = Ioi (b + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Ioi Set.preimage_sub_const_Ioi
@[simp]
theorem preimage_sub_const_Iic : (fun x => x - a) ⁻¹' Iic b = Iic (b + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Iic Set.preimage_sub_const_Iic
@[simp]
theorem preimage_sub_const_Iio : (fun x => x - a) ⁻¹' Iio b = Iio (b + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Iio Set.preimage_sub_const_Iio
@[simp]
theorem preimage_sub_const_Icc : (fun x => x - a) ⁻¹' Icc b c = Icc (b + a) (c + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Icc Set.preimage_sub_const_Icc
@[simp]
theorem preimage_sub_const_Ico : (fun x => x - a) ⁻¹' Ico b c = Ico (b + a) (c + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Ico Set.preimage_sub_const_Ico
@[simp]
theorem preimage_sub_const_Ioc : (fun x => x - a) ⁻¹' Ioc b c = Ioc (b + a) (c + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Ioc Set.preimage_sub_const_Ioc
@[simp]
theorem preimage_sub_const_Ioo : (fun x => x - a) ⁻¹' Ioo b c = Ioo (b + a) (c + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Ioo Set.preimage_sub_const_Ioo
@[simp]
theorem preimage_const_sub_Ici : (fun x => a - x) ⁻¹' Ici b = Iic (a - b) :=
ext fun _x => le_sub_comm
#align set.preimage_const_sub_Ici Set.preimage_const_sub_Ici
@[simp]
theorem preimage_const_sub_Iic : (fun x => a - x) ⁻¹' Iic b = Ici (a - b) :=
ext fun _x => sub_le_comm
#align set.preimage_const_sub_Iic Set.preimage_const_sub_Iic
@[simp]
theorem preimage_const_sub_Ioi : (fun x => a - x) ⁻¹' Ioi b = Iio (a - b) :=
ext fun _x => lt_sub_comm
#align set.preimage_const_sub_Ioi Set.preimage_const_sub_Ioi
@[simp]
theorem preimage_const_sub_Iio : (fun x => a - x) ⁻¹' Iio b = Ioi (a - b) :=
ext fun _x => sub_lt_comm
#align set.preimage_const_sub_Iio Set.preimage_const_sub_Iio
@[simp]
theorem preimage_const_sub_Icc : (fun x => a - x) ⁻¹' Icc b c = Icc (a - c) (a - b) := by
simp [← Ici_inter_Iic, inter_comm]
#align set.preimage_const_sub_Icc Set.preimage_const_sub_Icc
@[simp]
theorem preimage_const_sub_Ico : (fun x => a - x) ⁻¹' Ico b c = Ioc (a - c) (a - b) := by
simp [← Ioi_inter_Iic, ← Ici_inter_Iio, inter_comm]
#align set.preimage_const_sub_Ico Set.preimage_const_sub_Ico
@[simp]
theorem preimage_const_sub_Ioc : (fun x => a - x) ⁻¹' Ioc b c = Ico (a - c) (a - b) := by
simp [← Ioi_inter_Iic, ← Ici_inter_Iio, inter_comm]
#align set.preimage_const_sub_Ioc Set.preimage_const_sub_Ioc
@[simp]
theorem preimage_const_sub_Ioo : (fun x => a - x) ⁻¹' Ioo b c = Ioo (a - c) (a - b) := by
simp [← Ioi_inter_Iio, inter_comm]
#align set.preimage_const_sub_Ioo Set.preimage_const_sub_Ioo
-- @[simp] -- Porting note (#10618): simp can prove this modulo `add_comm`
theorem image_const_add_Iic : (fun x => a + x) '' Iic b = Iic (a + b) := by simp [add_comm]
#align set.image_const_add_Iic Set.image_const_add_Iic
-- @[simp] -- Porting note (#10618): simp can prove this modulo `add_comm`
theorem image_const_add_Iio : (fun x => a + x) '' Iio b = Iio (a + b) := by simp [add_comm]
#align set.image_const_add_Iio Set.image_const_add_Iio
-- @[simp] -- Porting note (#10618): simp can prove this
theorem image_add_const_Iic : (fun x => x + a) '' Iic b = Iic (b + a) := by simp
#align set.image_add_const_Iic Set.image_add_const_Iic
-- @[simp] -- Porting note (#10618): simp can prove this
theorem image_add_const_Iio : (fun x => x + a) '' Iio b = Iio (b + a) := by simp
#align set.image_add_const_Iio Set.image_add_const_Iio
theorem image_neg_Ici : Neg.neg '' Ici a = Iic (-a) := by simp
#align set.image_neg_Ici Set.image_neg_Ici
theorem image_neg_Iic : Neg.neg '' Iic a = Ici (-a) := by simp
#align set.image_neg_Iic Set.image_neg_Iic
theorem image_neg_Ioi : Neg.neg '' Ioi a = Iio (-a) := by simp
#align set.image_neg_Ioi Set.image_neg_Ioi
theorem image_neg_Iio : Neg.neg '' Iio a = Ioi (-a) := by simp
#align set.image_neg_Iio Set.image_neg_Iio
| Mathlib/Data/Set/Pointwise/Interval.lean | 387 | 387 | theorem image_neg_Icc : Neg.neg '' Icc a b = Icc (-b) (-a) := by | simp
|
import Mathlib.Algebra.Homology.ComplexShape
import Mathlib.CategoryTheory.Subobject.Limits
import Mathlib.CategoryTheory.GradedObject
import Mathlib.Algebra.Homology.ShortComplex.Basic
#align_import algebra.homology.homological_complex from "leanprover-community/mathlib"@"88bca0ce5d22ebfd9e73e682e51d60ea13b48347"
universe v u
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
variable {ι : Type*}
variable (V : Type u) [Category.{v} V] [HasZeroMorphisms V]
structure HomologicalComplex (c : ComplexShape ι) where
X : ι → V
d : ∀ i j, X i ⟶ X j
shape : ∀ i j, ¬c.Rel i j → d i j = 0 := by aesop_cat
d_comp_d' : ∀ i j k, c.Rel i j → c.Rel j k → d i j ≫ d j k = 0 := by aesop_cat
#align homological_complex HomologicalComplex
abbrev ChainComplex (α : Type*) [AddRightCancelSemigroup α] [One α] : Type _ :=
HomologicalComplex V (ComplexShape.down α)
#align chain_complex ChainComplex
abbrev CochainComplex (α : Type*) [AddRightCancelSemigroup α] [One α] : Type _ :=
HomologicalComplex V (ComplexShape.up α)
#align cochain_complex CochainComplex
namespace ChainComplex
@[simp]
theorem prev (α : Type*) [AddRightCancelSemigroup α] [One α] (i : α) :
(ComplexShape.down α).prev i = i + 1 :=
(ComplexShape.down α).prev_eq' rfl
#align chain_complex.prev ChainComplex.prev
@[simp]
theorem next (α : Type*) [AddGroup α] [One α] (i : α) : (ComplexShape.down α).next i = i - 1 :=
(ComplexShape.down α).next_eq' <| sub_add_cancel _ _
#align chain_complex.next ChainComplex.next
@[simp]
| Mathlib/Algebra/Homology/HomologicalComplex.lean | 177 | 182 | theorem next_nat_zero : (ComplexShape.down ℕ).next 0 = 0 := by |
classical
refine dif_neg ?_
push_neg
intro
apply Nat.noConfusion
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.