Skip to content

Commit

Permalink
chore(*): add protected to *.insert theorems (#6142)
Browse files Browse the repository at this point in the history
Otherwise code like
```lean
theorem ContMDiffWithinAt.mythm (h : x ∈ insert y s) : _ = _
```
interprets `insert` as `ContMDiffWithinAt.insert`, not `Insert.insert`.
  • Loading branch information
urkud committed Jul 26, 2023
1 parent 3bbd204 commit 9f14c41
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 25 deletions.
8 changes: 4 additions & 4 deletions Mathlib/Analysis/Asymptotics/Asymptotics.lean
Expand Up @@ -700,8 +700,8 @@ theorem isBigOWith_insert [TopologicalSpace α] {x : α} {s : Set α} {C : ℝ}
simp_rw [IsBigOWith_def, nhdsWithin_insert, eventually_sup, eventually_pure, h, true_and_iff]
#align asymptotics.is_O_with_insert Asymptotics.isBigOWith_insert

theorem IsBigOWith.insert [TopologicalSpace α] {x : α} {s : Set α} {C : ℝ} {g : α → E} {g' : α → F}
(h1 : IsBigOWith C (𝓝[s] x) g g') (h2 : ‖g x‖ ≤ C * ‖g' x‖) :
protected theorem IsBigOWith.insert [TopologicalSpace α] {x : α} {s : Set α} {C : ℝ} {g : α → E}
{g' : α → F} (h1 : IsBigOWith C (𝓝[s] x) g g') (h2 : ‖g x‖ ≤ C * ‖g' x‖) :
IsBigOWith C (𝓝[insert x s] x) g g' :=
(isBigOWith_insert h2).mpr h1
#align asymptotics.is_O_with.insert Asymptotics.IsBigOWith.insert
Expand All @@ -715,8 +715,8 @@ theorem isLittleO_insert [TopologicalSpace α] {x : α} {s : Set α} {g : α →
exact mul_nonneg hc.le (norm_nonneg _)
#align asymptotics.is_o_insert Asymptotics.isLittleO_insert

theorem IsLittleO.insert [TopologicalSpace α] {x : α} {s : Set α} {g : α → E'} {g' : α → F'}
(h1 : g =o[𝓝[s] x] g') (h2 : g x = 0) : g =o[𝓝[insert x s] x] g' :=
protected theorem IsLittleO.insert [TopologicalSpace α] {x : α} {s : Set α} {g : α → E'}
{g' : α → F'} (h1 : g =o[𝓝[s] x] g') (h2 : g x = 0) : g =o[𝓝[insert x s] x] g' :=
(isLittleO_insert h2).mpr h1
#align asymptotics.is_o.insert Asymptotics.IsLittleO.insert

Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Analysis/Calculus/FDeriv/Basic.lean
Expand Up @@ -402,7 +402,7 @@ alias hasFDerivWithinAt_insert ↔ HasFDerivWithinAt.of_insert HasFDerivWithinAt
#align has_fderiv_within_at.of_insert HasFDerivWithinAt.of_insert
#align has_fderiv_within_at.insert' HasFDerivWithinAt.insert'

theorem HasFDerivWithinAt.insert (h : HasFDerivWithinAt g g' s x) :
protected theorem HasFDerivWithinAt.insert (h : HasFDerivWithinAt g g' s x) :
HasFDerivWithinAt g g' (insert x s) x :=
h.insert'
#align has_fderiv_within_at.insert HasFDerivWithinAt.insert
Expand Down
4 changes: 2 additions & 2 deletions Mathlib/Combinatorics/SetFamily/Intersecting.lean
Expand Up @@ -61,8 +61,8 @@ theorem intersecting_empty : (∅ : Set α).Intersecting := fun _ => False.elim
theorem intersecting_singleton : ({a} : Set α).Intersecting ↔ a ≠ ⊥ := by simp [Intersecting]
#align set.intersecting_singleton Set.intersecting_singleton

theorem Intersecting.insert (hs : s.Intersecting) (ha : a ≠ ⊥) (h : ∀ b ∈ s, ¬Disjoint a b) :
(insert a s).Intersecting := by
protected theorem Intersecting.insert (hs : s.Intersecting) (ha : a ≠ ⊥)
(h : ∀ b ∈ s, ¬Disjoint a b) : (insert a s).Intersecting := by
rintro b (rfl | hb) c (rfl | hc)
· rwa [disjoint_self]
· exact h _ hc
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Data/List/Nodup.lean
Expand Up @@ -369,7 +369,7 @@ protected theorem Nodup.concat (h : a ∉ l) (h' : l.Nodup) : (l.concat a).Nodup
rw [concat_eq_append]; exact h'.append (nodup_singleton _) (disjoint_singleton.2 h)
#align list.nodup.concat List.Nodup.concat

theorem Nodup.insert [DecidableEq α] (h : l.Nodup) : (l.insert a).Nodup :=
protected theorem Nodup.insert [DecidableEq α] (h : l.Nodup) : (l.insert a).Nodup :=
if h' : a ∈ l then by rw [insert_of_mem h']; exact h
else by rw [insert_of_not_mem h', nodup_cons]; constructor <;> assumption
#align list.nodup.insert List.Nodup.insert
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Data/List/Perm.lean
Expand Up @@ -957,7 +957,7 @@ theorem Perm.dedup {l₁ l₂ : List α} (p : l₁ ~ l₂) : dedup l₁ ~ dedup
#align list.perm.dedup List.Perm.dedup

-- attribute [congr]
theorem Perm.insert (a : α) {l₁ l₂ : List α} (p : l₁ ~ l₂) : l₁.insert a ~ l₂.insert a :=
protected theorem Perm.insert (a : α) {l₁ l₂ : List α} (p : l₁ ~ l₂) : l₁.insert a ~ l₂.insert a :=
if h : a ∈ l₁ then by simpa [h, p.subset h] using p
else by simpa [h, mt p.mem_iff.2 h] using p.cons a
#align list.perm.insert List.Perm.insert
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Data/Set/Countable.lean
Expand Up @@ -228,7 +228,7 @@ theorem countable_insert {s : Set α} {a : α} : (insert a s).Countable ↔ s.Co
simp only [insert_eq, countable_union, countable_singleton, true_and_iff]
#align set.countable_insert Set.countable_insert

theorem Countable.insert {s : Set α} (a : α) (h : s.Countable) : (insert a s).Countable :=
protected theorem Countable.insert {s : Set α} (a : α) (h : s.Countable) : (insert a s).Countable :=
countable_insert.2 h
#align set.countable.insert Set.Countable.insert

Expand Down
3 changes: 1 addition & 2 deletions Mathlib/Data/Set/Finite.lean
Expand Up @@ -854,8 +854,7 @@ theorem finite_pure (a : α) : (pure a : Set α).Finite :=
#align set.finite_pure Set.finite_pure

@[simp]
protected -- Porting note: added
theorem Finite.insert (a : α) {s : Set α} (hs : s.Finite) : (insert a s).Finite := by
protected theorem Finite.insert (a : α) {s : Set α} (hs : s.Finite) : (insert a s).Finite := by
cases hs
apply toFinite
#align set.finite.insert Set.Finite.insert
Expand Down
7 changes: 6 additions & 1 deletion Mathlib/Geometry/Manifold/ContMDiff.lean
Expand Up @@ -741,7 +741,12 @@ theorem contMDiffWithinAt_insert_self :
refine Iff.rfl.and <| (contDiffWithinAt_congr_nhds ?_).trans contDiffWithinAt_insert_self
simp only [← map_extChartAt_nhdsWithin I, nhdsWithin_insert, Filter.map_sup, Filter.map_pure]

alias contMDiffWithinAt_insert_self ↔ ContMDiffWithinAt.of_insert ContMDiffWithinAt.insert
alias contMDiffWithinAt_insert_self ↔ ContMDiffWithinAt.of_insert _

-- TODO: use `alias` again once it can make protected theorems
theorem ContMDiffWithinAt.insert (h : ContMDiffWithinAt I I' n f s x) :
ContMDiffWithinAt I I' n f (insert x s) x :=
contMDiffWithinAt_insert_self.2 h

theorem ContMDiffAt.contMDiffWithinAt (hf : ContMDiffAt I I' n f x) :
ContMDiffWithinAt I I' n f s x :=
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/LinearAlgebra/LinearIndependent.lean
Expand Up @@ -1169,7 +1169,7 @@ theorem linearIndependent_iff_not_mem_span :
exact False.elim (h _ ((smul_mem_iff _ ha').1 ha))
#align linear_independent_iff_not_mem_span linearIndependent_iff_not_mem_span

theorem LinearIndependent.insert (hs : LinearIndependent K (fun b => b : s → V))
protected theorem LinearIndependent.insert (hs : LinearIndependent K (fun b => b : s → V))
(hx : x ∉ span K s) : LinearIndependent K (fun b => b : ↥(insert x s) → V) := by
rw [← union_singleton]
have x0 : x ≠ 0 := mt (by rintro rfl; apply zero_mem (span K s)) hx
Expand Down
12 changes: 6 additions & 6 deletions Mathlib/Order/Bounds/Basic.lean
Expand Up @@ -924,7 +924,7 @@ theorem bddAbove_insert [SemilatticeSup γ] (a : γ) {s : Set γ} :
simp only [insert_eq, bddAbove_union, bddAbove_singleton, true_and_iff]
#align bdd_above_insert bddAbove_insert

theorem BddAbove.insert [SemilatticeSup γ] (a : γ) {s : Set γ} (hs : BddAbove s) :
protected theorem BddAbove.insert [SemilatticeSup γ] (a : γ) {s : Set γ} (hs : BddAbove s) :
BddAbove (insert a s) :=
(bddAbove_insert a).2 hs
#align bdd_above.insert BddAbove.insert
Expand All @@ -936,30 +936,30 @@ theorem bddBelow_insert [SemilatticeInf γ] (a : γ) {s : Set γ} :
simp only [insert_eq, bddBelow_union, bddBelow_singleton, true_and_iff]
#align bdd_below_insert bddBelow_insert

theorem BddBelow.insert [SemilatticeInf γ] (a : γ) {s : Set γ} (hs : BddBelow s) :
protected theorem BddBelow.insert [SemilatticeInf γ] (a : γ) {s : Set γ} (hs : BddBelow s) :
BddBelow (insert a s) :=
(bddBelow_insert a).2 hs
#align bdd_below.insert BddBelow.insert

theorem IsLUB.insert [SemilatticeSup γ] (a) {b} {s : Set γ} (hs : IsLUB s b) :
protected theorem IsLUB.insert [SemilatticeSup γ] (a) {b} {s : Set γ} (hs : IsLUB s b) :
IsLUB (insert a s) (a ⊔ b) := by
rw [insert_eq]
exact isLUB_singleton.union hs
#align is_lub.insert IsLUB.insert

theorem IsGLB.insert [SemilatticeInf γ] (a) {b} {s : Set γ} (hs : IsGLB s b) :
protected theorem IsGLB.insert [SemilatticeInf γ] (a) {b} {s : Set γ} (hs : IsGLB s b) :
IsGLB (insert a s) (a ⊓ b) := by
rw [insert_eq]
exact isGLB_singleton.union hs
#align is_glb.insert IsGLB.insert

theorem IsGreatest.insert [LinearOrder γ] (a) {b} {s : Set γ} (hs : IsGreatest s b) :
protected theorem IsGreatest.insert [LinearOrder γ] (a) {b} {s : Set γ} (hs : IsGreatest s b) :
IsGreatest (insert a s) (max a b) := by
rw [insert_eq]
exact isGreatest_singleton.union hs
#align is_greatest.insert IsGreatest.insert

theorem IsLeast.insert [LinearOrder γ] (a) {b} {s : Set γ} (hs : IsLeast s b) :
protected theorem IsLeast.insert [LinearOrder γ] (a) {b} {s : Set γ} (hs : IsLeast s b) :
IsLeast (insert a s) (min a b) := by
rw [insert_eq]
exact isLeast_singleton.union hs
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Order/Chain.lean
Expand Up @@ -86,7 +86,7 @@ theorem isChain_of_trichotomous [IsTrichotomous α r] (s : Set α) : IsChain r s
fun a _ b _ hab => (trichotomous_of r a b).imp_right fun h => h.resolve_left hab
#align is_chain_of_trichotomous isChain_of_trichotomous

theorem IsChain.insert (hs : IsChain r s) (ha : ∀ b ∈ s, a ≠ b → a ≺ b ∨ b ≺ a) :
protected theorem IsChain.insert (hs : IsChain r s) (ha : ∀ b ∈ s, a ≠ b → a ≺ b ∨ b ≺ a) :
IsChain r (insert a s) :=
hs.insert_of_symmetric (fun _ _ => Or.symm) ha
#align is_chain.insert IsChain.insert
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Order/Directed.lean
Expand Up @@ -228,7 +228,7 @@ instance OrderDual.isDirected_le [LE α] [IsDirected α (· ≥ ·)] : IsDirecte

section Reflexive

theorem DirectedOn.insert (h : Reflexive r) (a : α) {s : Set α} (hd : DirectedOn r s)
protected theorem DirectedOn.insert (h : Reflexive r) (a : α) {s : Set α} (hd : DirectedOn r s)
(ha : ∀ b ∈ s, ∃ c ∈ s, a ≼ c ∧ b ≼ c) : DirectedOn r (insert a s) := by
rintro x (rfl | hx) y (rfl | hy)
· exact ⟨y, Set.mem_insert _ _, h _, h _⟩
Expand Down
5 changes: 3 additions & 2 deletions Mathlib/Order/WellFoundedSet.lean
Expand Up @@ -508,7 +508,7 @@ theorem isWf_insert {a} : IsWf (insert a s) ↔ IsWf s := by
simp only [← singleton_union, isWf_union, isWf_singleton, true_and_iff]
#align set.is_wf_insert Set.isWf_insert

theorem IsWf.insert (h : IsWf s) (a : α) : IsWf (insert a s) :=
protected theorem IsWf.insert (h : IsWf s) (a : α) : IsWf (insert a s) :=
isWf_insert.2 h
#align set.is_wf.insert Set.IsWf.insert

Expand Down Expand Up @@ -537,7 +537,8 @@ theorem wellFoundedOn_insert : WellFoundedOn (insert a s) r ↔ WellFoundedOn s
simp only [← singleton_union, wellFoundedOn_union, wellFoundedOn_singleton, true_and_iff]
#align set.well_founded_on_insert Set.wellFoundedOn_insert

theorem WellFoundedOn.insert (h : WellFoundedOn s r) (a : α) : WellFoundedOn (insert a s) r :=
protected theorem WellFoundedOn.insert (h : WellFoundedOn s r) (a : α) :
WellFoundedOn (insert a s) r :=
wellFoundedOn_insert.2 h
#align set.well_founded_on.insert Set.WellFoundedOn.insert

Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Topology/SubsetProperties.lean
Expand Up @@ -455,7 +455,7 @@ theorem IsCompact.union (hs : IsCompact s) (ht : IsCompact t) : IsCompact (s ∪
rw [union_eq_iUnion]; exact isCompact_iUnion fun b => by cases b <;> assumption
#align is_compact.union IsCompact.union

theorem IsCompact.insert (hs : IsCompact s) (a) : IsCompact (insert a s) :=
protected theorem IsCompact.insert (hs : IsCompact s) (a) : IsCompact (insert a s) :=
isCompact_singleton.union hs
#align is_compact.insert IsCompact.insert

Expand Down

0 comments on commit 9f14c41

Please sign in to comment.