Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - chore: gcongr attributes for sup/inf, min/max, union/intersection/complement, image/preimage #6016

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Mathlib/Data/Set/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -828,14 +828,17 @@ theorem union_subset_iff {s t u : Set α} : s ∪ t ⊆ u ↔ s ⊆ u ∧ t ⊆
(forall_congr' fun _ => or_imp).trans forall_and
#align set.union_subset_iff Set.union_subset_iff

@[gcongr]
theorem union_subset_union {s₁ s₂ t₁ t₂ : Set α} (h₁ : s₁ ⊆ s₂) (h₂ : t₁ ⊆ t₂) :
s₁ ∪ t₁ ⊆ s₂ ∪ t₂ := fun _ => Or.imp (@h₁ _) (@h₂ _)
#align set.union_subset_union Set.union_subset_union

@[gcongr]
theorem union_subset_union_left {s₁ s₂ : Set α} (t) (h : s₁ ⊆ s₂) : s₁ ∪ t ⊆ s₂ ∪ t :=
union_subset_union h Subset.rfl
#align set.union_subset_union_left Set.union_subset_union_left

@[gcongr]
theorem union_subset_union_right (s) {t₁ t₂ : Set α} (h : t₁ ⊆ t₂) : s ∪ t₁ ⊆ s ∪ t₂ :=
union_subset_union Subset.rfl h
#align set.union_subset_union_right Set.union_subset_union_right
Expand Down Expand Up @@ -1005,14 +1008,17 @@ theorem univ_inter (a : Set α) : univ ∩ a = a :=
top_inf_eq
#align set.univ_inter Set.univ_inter

@[gcongr]
theorem inter_subset_inter {s₁ s₂ t₁ t₂ : Set α} (h₁ : s₁ ⊆ t₁) (h₂ : s₂ ⊆ t₂) :
s₁ ∩ s₂ ⊆ t₁ ∩ t₂ := fun _ => And.imp (@h₁ _) (@h₂ _)
#align set.inter_subset_inter Set.inter_subset_inter

@[gcongr]
theorem inter_subset_inter_left {s t : Set α} (u : Set α) (H : s ⊆ t) : s ∩ u ⊆ t ∩ u :=
inter_subset_inter H Subset.rfl
#align set.inter_subset_inter_left Set.inter_subset_inter_left

@[gcongr]
theorem inter_subset_inter_right {s t : Set α} (u : Set α) (H : s ⊆ t) : u ∩ s ⊆ u ∩ t :=
inter_subset_inter Subset.rfl H
#align set.inter_subset_inter_right Set.inter_subset_inter_right
Expand Down Expand Up @@ -1737,6 +1743,8 @@ theorem compl_subset_compl : sᶜ ⊆ tᶜ ↔ t ⊆ s :=
@compl_le_compl_iff_le (Set α) _ _ _
#align set.compl_subset_compl Set.compl_subset_compl

@[gcongr] theorem compl_subset_compl_of_subset (h : t ⊆ s) : sᶜ ⊆ tᶜ := compl_subset_compl.2 h

theorem subset_compl_iff_disjoint_left : s ⊆ tᶜ ↔ Disjoint t s :=
@le_compl_iff_disjoint_left (Set α) _ _ _
#align set.subset_compl_iff_disjoint_left Set.subset_compl_iff_disjoint_left
Expand Down
2 changes: 2 additions & 0 deletions Mathlib/Data/Set/Image.lean
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ theorem preimage_congr {f g : α → β} {s : Set β} (h : ∀ x : α, f x = g x
simp [h]
#align set.preimage_congr Set.preimage_congr

@[gcongr]
theorem preimage_mono {s t : Set β} (h : s ⊆ t) : f ⁻¹' s ⊆ f ⁻¹' t := fun _ hx => h hx
#align set.preimage_mono Set.preimage_mono

Expand Down Expand Up @@ -295,6 +296,7 @@ theorem _root_.Function.Commute.set_image {f g : α → α} (h : Function.Commut

/-- Image is monotone with respect to `⊆`. See `Set.monotone_image` for the statement in
terms of `≤`. -/
@[gcongr]
theorem image_subset {a b : Set α} (f : α → β) (h : a ⊆ b) : f '' a ⊆ f '' b := by
simp only [subset_def, mem_image]
exact fun x => fun ⟨w, h1, h2⟩ => ⟨w, h h1, h2⟩
Expand Down
14 changes: 12 additions & 2 deletions Mathlib/Data/Set/Lattice.lean
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ theorem iUnion_mono {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : ⋃ i, s 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

/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/
/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/
theorem iUnion₂_mono {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j ⊆ t i j) :
Expand All @@ -390,6 +394,10 @@ theorem iInter_mono {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : ⋂ i, s 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

/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/
/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/
theorem iInter₂_mono {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j ⊆ t i j) :
Expand Down Expand Up @@ -1073,10 +1081,12 @@ theorem subset_sInter_iff {S : Set (Set α)} {t : Set α} : t ⊆ ⋂₀ S ↔
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
Expand Down Expand Up @@ -1296,8 +1306,7 @@ theorem Sigma.univ (X : α → Type _) : (Set.univ : Set (Σa, X a)) = ⋃ a, ra
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

theorem sUnion_mono {s t : Set (Set α)} (h : s ⊆ t) : ⋃₀s ⊆ ⋃₀t :=
sUnion_subset fun _' ht' => subset_sUnion_of_mem <| h ht'
alias sUnion_subset_sUnion ← sUnion_mono
#align set.sUnion_mono Set.sUnion_mono

theorem iUnion_subset_iUnion_const {s : Set α} (h : ι → ι₂) : ⋃ _ : ι, s ⊆ ⋃ _ : ι₂, s :=
Expand Down Expand Up @@ -1969,6 +1978,7 @@ theorem seq_subset {s : Set (α → β)} {t : Set α} {u : Set β} :
eq ▸ h f hf a ha
#align set.seq_subset Set.seq_subset

@[gcongr]
theorem seq_mono {s₀ s₁ : Set (α → β)} {t₀ t₁ : Set α} (hs : s₀ ⊆ s₁) (ht : t₀ ⊆ t₁) :
seq s₀ t₀ ⊆ seq s₁ t₁ := fun _ ⟨f, hf, a, ha, eq⟩ => ⟨f, hs hf, a, ht ha, eq⟩
#align set.seq_mono Set.seq_mono
Expand Down
4 changes: 4 additions & 0 deletions Mathlib/Order/CompleteLattice.lean
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ theorem le_sSup_of_le (hb : b ∈ s) (h : a ≤ b) : a ≤ sSup s :=
le_trans h (le_sSup hb)
#align le_Sup_of_le le_sSup_of_le

@[gcongr]
theorem sSup_le_sSup (h : s ⊆ t) : sSup s ≤ sSup t :=
(isLUB_sSup s).mono (isLUB_sSup t) h
#align Sup_le_Sup sSup_le_sSup
Expand Down Expand Up @@ -219,6 +220,7 @@ theorem sInf_le_of_le (hb : b ∈ s) (h : b ≤ a) : sInf s ≤ a :=
le_trans (sInf_le hb) h
#align Inf_le_of_le sInf_le_of_le

@[gcongr]
theorem sInf_le_sInf (h : s ⊆ t) : sInf t ≤ sInf s :=
(isGLB_sInf s).mono (isGLB_sInf t) h
#align Inf_le_Inf sInf_le_sInf
Expand Down Expand Up @@ -832,10 +834,12 @@ theorem iInf_le_iInf₂ (κ : ι → Sort _) (f : ι → α) : ⨅ i, f i ≤
le_iInf₂ fun i _ => iInf_le f i
#align infi_le_infi₂ iInf_le_iInf₂

@[gcongr]
theorem iSup_mono (h : ∀ i, f i ≤ g i) : iSup f ≤ iSup g :=
iSup_le fun i => le_iSup_of_le i <| h i
#align supr_mono iSup_mono

@[gcongr]
theorem iInf_mono (h : ∀ i, f i ≤ g i) : iInf f ≤ iInf g :=
le_iInf fun i => iInf_le_of_le i <| h i
#align infi_mono iInf_mono
Expand Down
1 change: 1 addition & 0 deletions Mathlib/Order/Heyting/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@ theorem compl_anti : Antitone (compl : α → α) := fun _ _ h =>
le_compl_comm.1 <| h.trans le_compl_compl
#align compl_anti compl_anti

@[gcongr]
theorem compl_le_compl (h : a ≤ b) : bᶜ ≤ aᶜ :=
compl_anti h
#align compl_le_compl compl_le_compl
Expand Down
7 changes: 7 additions & 0 deletions Mathlib/Order/Lattice.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Authors: Johannes Hölzl
import Mathlib.Data.Bool.Basic
import Mathlib.Init.Algebra.Order
import Mathlib.Order.Monotone.Basic
import Mathlib.Tactic.GCongr.Core

#align_import order.lattice from "leanprover-community/mathlib"@"e4bc74cbaf429d706cb9140902f7ca6c431e75a4"

Expand Down Expand Up @@ -223,14 +224,17 @@ theorem le_iff_exists_sup : a ≤ b ↔ ∃ c, b = a ⊔ c := by
exact le_sup_left
#align le_iff_exists_sup le_iff_exists_sup

@[gcongr]
theorem sup_le_sup (h₁ : a ≤ b) (h₂ : c ≤ d) : a ⊔ c ≤ b ⊔ d :=
sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right h₂)
#align sup_le_sup sup_le_sup

@[gcongr]
theorem sup_le_sup_left (h₁ : a ≤ b) (c) : c ⊔ a ≤ c ⊔ b :=
sup_le_sup le_rfl h₁
#align sup_le_sup_left sup_le_sup_left

@[gcongr]
theorem sup_le_sup_right (h₁ : a ≤ b) (c) : a ⊔ c ≤ b ⊔ c :=
sup_le_sup h₁ le_rfl
#align sup_le_sup_right sup_le_sup_right
Expand Down Expand Up @@ -469,14 +473,17 @@ theorem inf_lt_left_or_right (h : a ≠ b) : a ⊓ b < a ∨ a ⊓ b < b :=
@left_or_right_lt_sup αᵒᵈ _ _ _ h
#align inf_lt_left_or_right inf_lt_left_or_right

@[gcongr]
theorem inf_le_inf (h₁ : a ≤ b) (h₂ : c ≤ d) : a ⊓ c ≤ b ⊓ d :=
@sup_le_sup αᵒᵈ _ _ _ _ _ h₁ h₂
#align inf_le_inf inf_le_inf

@[gcongr]
theorem inf_le_inf_right (a : α) {b c : α} (h : b ≤ c) : b ⊓ a ≤ c ⊓ a :=
inf_le_inf h le_rfl
#align inf_le_inf_right inf_le_inf_right

@[gcongr]
theorem inf_le_inf_left (a : α) {b c : α} (h : b ≤ c) : a ⊓ b ≤ a ⊓ c :=
inf_le_inf le_rfl h
#align inf_le_inf_left inf_le_inf_left
Expand Down
10 changes: 10 additions & 0 deletions Mathlib/Order/MinMax.lean
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,24 @@ theorem max_lt_iff : max a b < c ↔ a < c ∧ b < c :=
sup_lt_iff
#align max_lt_iff max_lt_iff

@[gcongr]
theorem max_le_max : a ≤ c → b ≤ d → max a b ≤ max c d :=
sup_le_sup
#align max_le_max max_le_max

@[gcongr] theorem max_le_max_left (c) (h : a ≤ b) : max c a ≤ max c b := sup_le_sup_left h c

@[gcongr] theorem max_le_max_right (c) (h : a ≤ b) : max a c ≤ max b c := sup_le_sup_right h c

@[gcongr]
theorem min_le_min : a ≤ c → b ≤ d → min a b ≤ min c d :=
inf_le_inf
#align min_le_min min_le_min

@[gcongr] theorem min_le_min_left (c) (h : a ≤ b) : min c a ≤ min c b := inf_le_inf_left c h

@[gcongr] theorem min_le_min_right (c) (h : a ≤ b) : min a c ≤ min b c := inf_le_inf_right c h

theorem le_max_of_le_left : a ≤ b → a ≤ max b c :=
le_sup_of_le_left
#align le_max_of_le_left le_max_of_le_left
Expand Down
Loading