Skip to content

Commit d9bda25

Browse files
authored
Merge branch 'master' into limsup_const_mul
2 parents 49130b3 + e6da408 commit d9bda25

5 files changed

Lines changed: 50 additions & 21 deletions

File tree

.github/workflows/label_new_contributor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106
## Welcome new contributor!
107107
Thank you for contributing to Mathlib! If you haven't done so already, please review our [contribution guidelines](https://leanprover-community.github.io/contribute/index.html), as well as the [style guide](https://leanprover-community.github.io/contribute/style.html) and [naming conventions](https://leanprover-community.github.io/contribute/naming.html).
108108
109-
We use a [review queue](https://leanprover-community.github.io/queueboard/review_dashboard.html) to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the `awaiting-author` tag, or another reason described in the [Lifecycle of a PR](https://leanprover-community.github.io/contribute/index.html#lifecycle-of-a-pr).
109+
We use a [review queue](https://leanprover-community.github.io/queueboard/review_dashboard.html) to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the `awaiting-author` tag, or another reason described in the [Lifecycle of a PR](https://leanprover-community.github.io/contribute/index.html#lifecycle-of-a-pr). The review dashboard has [a dedicated webpage](https://leanprover-community.github.io/queueboard/on_the_queue.html?search=${{ github.event.pull_request.number }}) which shows whether your PR is on the review queue, and (if not), why.
110110
111111
If you haven't already done so, please come to [https://leanprover.zulipchat.com/](https://leanprover.zulipchat.com/), introduce yourself, and mention your new PR.
112112

Mathlib/Data/Set/Card.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ theorem encard_pi_eq_prod_encard [h : Fintype α] {ι : α → Type*} {s : ∀ i
188188

189189
section Lattice
190190

191+
@[gcongr]
191192
theorem encard_le_encard (h : s ⊆ t) : s.encard ≤ t.encard := by
192193
rw [← union_diff_cancel h, encard_union_eq disjoint_sdiff_right]; exact le_self_add
193194

@@ -296,7 +297,7 @@ theorem one_le_encard_insert (s : Set α) : 1 ≤ (insert a s).encard :=
296297
ENat.one_le_iff_ne_zero.mpr <| encard_ne_zero_of_mem (mem_insert a s)
297298

298299
theorem encard_singleton_inter (s : Set α) (x : α) : ({x} ∩ s).encard ≤ 1 := by
299-
rw [← encard_singleton x]; exact encard_le_encard inter_subset_left
300+
grw [← encard_singleton x, inter_subset_left]
300301

301302
theorem encard_diff_singleton_add_one (h : a ∈ s) :
302303
(s \ {a}).encard + 1 = s.encard := by
@@ -485,9 +486,7 @@ theorem _root_.Function.Embedding.encard_le (e : s ↪ t) : s.encard ≤ t.encar
485486
theorem encard_image_le (f : α → β) (s : Set α) : (f '' s).encard ≤ s.encard := by
486487
obtain (h | h) := isEmpty_or_nonempty α
487488
· rw [s.eq_empty_of_isEmpty]; simp
488-
rw [← (f.invFunOn_injOn_image s).encard_image]
489-
apply encard_le_encard
490-
exact f.invFunOn_image_image_subset s
489+
grw [← (f.invFunOn_injOn_image s).encard_image, f.invFunOn_image_image_subset s]
491490

492491
theorem Finite.injOn_of_encard_image_eq (hs : s.Finite) (h : (f '' s).encard = s.encard) :
493492
InjOn f s := by
@@ -506,7 +505,7 @@ lemma encard_preimage_of_bijective (hf : f.Bijective) (t : Set β) : (f ⁻¹' t
506505

507506
theorem encard_le_encard_of_injOn (hf : MapsTo f s t) (f_inj : InjOn f s) :
508507
s.encard ≤ t.encard := by
509-
rw [← f_inj.encard_image]; apply encard_le_encard; rintro _ ⟨x, hx, rfl⟩; exact hf hx
508+
grw [← f_inj.encard_image, hf.image_subset]
510509

511510
open Notation in
512511
lemma encard_preimage_val_le_encard_left (P Q : Set α) : (P ↓∩ Q).encard ≤ P.encard :=

Mathlib/SetTheory/Ordinal/Arithmetic.lean

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -941,10 +941,9 @@ theorem dvd_antisymm {a b : Ordinal} (h₁ : a ∣ b) (h₂ : b ∣ a) : a = b :
941941
instance antisymm : @Std.Antisymm Ordinal (· ∣ ·) :=
942942
⟨@dvd_antisymm⟩
943943

944-
/-- `a % b` is the unique ordinal `o'` satisfying
945-
`a = b * o + o'` with `o' < b`. -/
946-
instance mod : Mod Ordinal :=
947-
fun a b => a - b * (a / b)⟩
944+
/-- `a % b` is the unique ordinal `r` satisfying `a = b * q + r` with `r < b`. -/
945+
instance mod : Mod Ordinal where
946+
mod a b := a - b * (a / b)
948947

949948
theorem mod_def (a b : Ordinal) : a % b = a - b * (a / b) :=
950949
rfl
@@ -953,27 +952,29 @@ theorem mod_le (a b : Ordinal) : a % b ≤ a :=
953952
sub_le_self a _
954953

955954
@[simp]
956-
theorem mod_zero (a : Ordinal) : a % 0 = a := by simp only [mod_def, div_zero, zero_mul, sub_zero]
955+
theorem mod_zero (a : Ordinal) : a % 0 = a := by simp [mod_def]
957956

958957
theorem mod_eq_of_lt {a b : Ordinal} (h : a < b) : a % b = a := by
959-
simp only [mod_def, div_eq_zero_of_lt h, mul_zero, sub_zero]
958+
simp [mod_def, div_eq_zero_of_lt h]
960959

961960
@[simp]
962-
theorem zero_mod (b : Ordinal) : 0 % b = 0 := by simp only [mod_def, zero_div, mul_zero, sub_self]
961+
theorem zero_mod (b : Ordinal) : 0 % b = 0 := by simp [mod_def]
963962

964963
theorem div_add_mod (a b : Ordinal) : b * (a / b) + a % b = a :=
965964
Ordinal.add_sub_cancel_of_le <| mul_div_le _ _
966965

967-
theorem mod_lt (a) {b : Ordinal} (h : b ≠ 0) : a % b < b :=
968-
(add_lt_add_iff_left (b * (a / b))).1 <| by rw [div_add_mod]; exact lt_mul_div_add a h
966+
theorem mod_lt (a) {b : Ordinal} (h : b ≠ 0) : a % b < b := by
967+
rw [← add_lt_add_iff_left, div_add_mod]
968+
exact lt_mul_div_add a h
969969

970970
@[simp]
971-
theorem mod_self (a : Ordinal) : a % a = 0 :=
972-
if a0 : a = 0 then by simp only [a0, zero_mod]
973-
else by simp only [mod_def, div_self a0, mul_one, sub_self]
971+
theorem mod_self (a : Ordinal) : a % a = 0 := by
972+
obtain rfl | ha := eq_or_ne a 0
973+
· simp
974+
· simp [mod_def, ha]
974975

975976
@[simp]
976-
theorem mod_one (a : Ordinal) : a % 1 = 0 := by simp only [mod_def, div_one, one_mul, sub_self]
977+
theorem mod_one (a : Ordinal) : a % 1 = 0 := by simp [mod_def]
977978

978979
theorem dvd_of_mod_eq_zero {a b : Ordinal} (H : a % b = 0) : b ∣ a :=
979980
⟨a / b, by simpa [H] using (div_add_mod a b).symm⟩

Mathlib/Topology/Algebra/Ring/Ideal.lean

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/!4.234852.
4545
theorem Ideal.closure_eq_of_isClosed (I : Ideal R) (hI : IsClosed (I : Set R)) : I.closure = I :=
4646
SetLike.ext' hI.closure_eq
4747

48+
variable (R)
49+
50+
/-- The connected component of zero in a topological ring as an ideal. -/
51+
def Ideal.connectedComponentOfZero : Ideal R where
52+
__ := AddSubgroup.connectedComponentOfZero R
53+
smul_mem' c x h := IsConnected.subset_connectedComponent
54+
(isConnected_connectedComponent.image _ (continuous_const_mul c).continuousOn)
55+
0, mem_connectedComponent, mul_zero c⟩ ⟨x, h, rfl⟩
56+
57+
@[simp]
58+
theorem Ideal.coe_connectedComponentOfZero :
59+
(Ideal.connectedComponentOfZero R : Set R) = connectedComponent 0 :=
60+
rfl
61+
4862
end Ring
4963

5064
section CommRing

scripts/autolabel.lean

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ structure LabelData (label : Label) where
166166
/-- Array of paths which should be excluded.
167167
Any modifications to a file in an excluded path are ignored for the purposes of labelling. -/
168168
exclusions : Array FilePath := #[]
169+
/-- Labels which are "lower" in the Mathlib import order. These labels will not be added
170+
alongside the label. For example any PR to `t-ring-theory` might modify files from `t-algebra`
171+
but should only get the former label -/
172+
dependencies : Array Label := #[]
169173
deriving BEq, Hashable
170174

171175
/-- Mathlib labels and their corresponding folders -/
@@ -277,6 +281,18 @@ def getMatchingLabels (files : Array FilePath) : Array Label :=
277281
-- return sorted list of labels
278282
applicable |>.qsort (·.toString < ·.toString)
279283

284+
/-- Helper function: union of all labels an all their dependent labels -/
285+
partial def collectLabelsAndDependentLabels (labels: Array Label) : Array Label :=
286+
labels.flatMap fun label ↦
287+
(collectLabelsAndDependentLabels (mathlibLabelData label).dependencies).push label
288+
289+
/-- Reduce a list of labels to not include any which are dependencies of other
290+
labels in the list -/
291+
def dropDependentLabels (labels: Array Label) : Array Label :=
292+
let dependentLabels := labels.flatMap fun label ↦
293+
(mathlibLabelData label).dependencies
294+
labels.filter (!dependentLabels.contains ·)
295+
280296
/-!
281297
Testing the functionality of the declarations defined in this script
282298
-/
@@ -414,8 +430,7 @@ unsafe def main (args : List String): IO UInt32 := do
414430
let modifiedFiles : Array FilePath := (gitDiff.splitOn "\n").toArray.map (⟨·⟩)
415431

416432
-- find labels covering the modified files
417-
let labels := getMatchingLabels modifiedFiles
418-
433+
let labels := dropDependentLabels <| getMatchingLabels modifiedFiles
419434
println s!"::notice::Applicable labels: {labels}"
420435

421436
match labels with

0 commit comments

Comments
 (0)