Skip to content

Commit 9de1959

Browse files
committed
Merge branch 'bump/nightly-2025-11-22' into nightly-testing
2 parents c2f779d + bc69044 commit 9de1959

8 files changed

Lines changed: 125 additions & 44 deletions

File tree

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6289,6 +6289,7 @@ public import Mathlib.SetTheory.Surreal.Basic
62896289
public import Mathlib.SetTheory.Surreal.Dyadic
62906290
public import Mathlib.SetTheory.Surreal.Multiplication
62916291
public import Mathlib.SetTheory.ZFC.Basic
6292+
public import Mathlib.SetTheory.ZFC.Cardinal
62926293
public import Mathlib.SetTheory.ZFC.Class
62936294
public import Mathlib.SetTheory.ZFC.Ordinal
62946295
public import Mathlib.SetTheory.ZFC.PSet

Mathlib/Data/Finset/Basic.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,13 @@ theorem choose_spec (hp : ∃! a, a ∈ l ∧ p a) : choose p l hp ∈ l ∧ p (
551551
theorem choose_mem (hp : ∃! a, a ∈ l ∧ p a) : choose p l hp ∈ l :=
552552
(choose_spec _ _ _).1
553553

554+
grind_pattern choose_mem => choose p l hp
555+
554556
theorem choose_property (hp : ∃! a, a ∈ l ∧ p a) : p (choose p l hp) :=
555557
(choose_spec _ _ _).2
556558

559+
grind_pattern choose_property => choose p l hp
560+
557561
end Choose
558562

559563
end Finset

Mathlib/Logic/Basic.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,10 @@ protected noncomputable def byContradiction' {α : Sort*} (H : ¬(α → False))
727727
def choice_of_byContradiction' {α : Sort*} (contra : ¬(α → False) → α) : Nonempty α → α :=
728728
fun H ↦ contra H.elim
729729

730+
-- This can be removed after https://github.com/leanprover/lean4/pull/11316
731+
-- arrives in a release candidate.
732+
grind_pattern Exists.choose_spec => P.choose
733+
730734
@[simp] lemma choose_eq (a : α) : @Exists.choose _ (· = a) ⟨a, rfl⟩ = a := @choose_spec _ (· = a) _
731735

732736
@[simp]

Mathlib/SetTheory/Cardinal/Basic.lean

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ theorem mk_subtype_le_of_subset {α : Type u} {p q : α → Prop} (h : ∀ ⦃x
628628
#(Subtype p) ≤ #(Subtype q) :=
629629
⟨Embedding.subtypeMap (Embedding.refl α) h⟩
630630

631+
theorem mk_le_mk_of_subset {α} {s t : Set α} (h : s ⊆ t) : #s ≤ #t :=
632+
⟨Set.embeddingOfSubset s t h⟩
633+
631634
theorem mk_emptyCollection (α : Type u) : #(∅ : Set α) = 0 :=
632635
mk_eq_zero _
633636

@@ -707,6 +710,10 @@ theorem mk_image_embedding_lift {β : Type v} (f : α ↪ β) (s : Set α) :
707710
theorem mk_image_embedding (f : α ↪ β) (s : Set α) : #(f '' s) = #s := by
708711
simpa using mk_image_embedding_lift f s
709712

713+
theorem iSup_mk_le_mk_iUnion {α : Type u} {ι : Type v} {f : ι → Set α} :
714+
⨆ i, #(f i) ≤ #(⋃ i, f i) :=
715+
ciSup_le' fun _ => mk_le_mk_of_subset (subset_iUnion _ _)
716+
710717
theorem mk_iUnion_le_sum_mk {α ι : Type u} {f : ι → Set α} : #(⋃ i, f i) ≤ sum fun i => #(f i) :=
711718
calc
712719
#(⋃ i, f i) ≤ #(Σ i, f i) := mk_le_of_surjective (Set.sigmaToiUnion_surjective f)
@@ -808,9 +815,6 @@ theorem mk_sum_compl {α} (s : Set α) : #s + #(sᶜ : Set α) = #α := by
808815
classical
809816
exact mk_congr (Equiv.Set.sumCompl s)
810817

811-
theorem mk_le_mk_of_subset {α} {s t : Set α} (h : s ⊆ t) : #s ≤ #t :=
812-
⟨Set.embeddingOfSubset s t h⟩
813-
814818
theorem mk_le_iff_forall_finset_subset_card_le {α : Type u} {n : ℕ} {t : Set α} :
815819
#t ≤ n ↔ ∀ s : Finset α, (s : Set α) ⊆ t → s.card ≤ n := by
816820
refine ⟨fun H s hs ↦ by simpa using (mk_le_mk_of_subset hs).trans H, fun H ↦ ?_⟩

Mathlib/SetTheory/ZFC/Basic.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,16 @@ lemma coe_sdiff (x y : ZFSet.{u}) : ↑(x \ y) = (↑x \ ↑y : Set ZFSet) := by
600600

601601
@[deprecated (since := "2025-11-05")] alias toSet_sdiff := coe_sdiff
602602

603+
@[simp] lemma inter_eq_left_of_subset (hxy : x ⊆ y) : x ∩ y = x := by ext; simpa using @hxy _
604+
@[simp] lemma inter_eq_right_of_subset (hyx : y ⊆ x) : x ∩ y = y := by ext; simpa using @hyx _
605+
606+
/-- `ZFSet.powerset` is equivalent to `Set.powerset`. -/
607+
def powersetEquiv (x : ZFSet.{u}) : x.powerset ≃ 𝒫 (x : Set ZFSet) where
608+
toFun y := ⟨y.1, Set.mem_powerset (mem_powerset.1 y.2)⟩
609+
invFun s := ⟨x.sep (· ∈ s.1), mem_powerset.2 sep_subset⟩
610+
left_inv := by simp +contextual [Function.LeftInverse]
611+
right_inv := by simp +contextual [Function.LeftInverse, Function.RightInverse, Set.setOf_and]
612+
603613
theorem mem_wf : @WellFounded ZFSet (· ∈ ·) :=
604614
(wellFounded_lift₂_iff (H := fun a b c d hx hy =>
605615
propext ((@Mem.congr_left a c hx).trans (@Mem.congr_right b d hy _)))).mpr PSet.mem_wf
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/-
2+
Copyright (c) 2025 Dexin Zhang. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Dexin Zhang
5+
-/
6+
module
7+
8+
public import Mathlib.SetTheory.Cardinal.Basic
9+
public import Mathlib.SetTheory.ZFC.Basic
10+
11+
/-!
12+
# Cardinalities of ZFC sets
13+
14+
In this file, we define the cardinalities of ZFC sets as `ZFSet.{u} → Cardinal.{u}`.
15+
16+
## Definitions
17+
18+
* `ZFSet.card`: Cardinality of a ZFC set.
19+
-/
20+
21+
@[expose] public section
22+
23+
universe u v
24+
25+
open Cardinal
26+
27+
namespace ZFSet
28+
29+
/-- The cardinality of a ZFC set. -/
30+
def card (x : ZFSet.{u}) : Cardinal.{u} := #(Shrink x)
31+
32+
variable {x y : ZFSet.{u}}
33+
34+
/-- `ZFSet.card x` is equal to the cardinality of `x` as a set of `ZFSet`s. -/
35+
theorem cardinalMk_coe_sort : #x = lift.{u + 1, u} (card x) := by
36+
rw [card, lift_mk_shrink'']
37+
38+
@[gcongr]
39+
theorem card_mono (h : x ⊆ y) : card x ≤ card y := by
40+
simpa [cardinalMk_coe_sort] using mk_le_mk_of_subset (coe_subset_coe.2 h)
41+
42+
@[simp]
43+
theorem card_empty : card ∅ = 0 := by
44+
rw [← lift_inj, ← cardinalMk_coe_sort]
45+
simp
46+
47+
theorem card_insert_le : card (insert x y) ≤ card y + 1 := by
48+
rw [← lift_le.{u + 1}]
49+
simpa [← cardinalMk_coe_sort] using mk_insert_le
50+
51+
theorem card_insert (h : x ∉ y) : card (insert x y) = card y + 1 := by
52+
rw [← lift_inj.{u, u + 1}]
53+
simpa [← cardinalMk_coe_sort] using mk_insert (SetLike.mem_coe.not.2 h)
54+
55+
@[simp]
56+
theorem card_singleton : card {x} = 1 := by
57+
simpa [notMem_singleton] using card_insert (notMem_empty x)
58+
59+
theorem card_pair_of_ne (h : x ≠ y) : card {x, y} = 2 := by
60+
convert card_insert (notMem_singleton.2 h)
61+
rw [card_singleton, one_add_one_eq_two]
62+
63+
theorem card_union_le : card (x ∪ y) ≤ card x + card y := by
64+
rw [← lift_le.{u + 1}]
65+
simpa [← cardinalMk_coe_sort] using mk_union_le (x : Set ZFSet) y
66+
67+
@[simp]
68+
theorem card_powerset (x : ZFSet.{u}) : card (powerset x) = 2 ^ card x := by
69+
rw [← lift_inj.{u, u + 1}]
70+
simpa [← cardinalMk_coe_sort] using mk_congr (powersetEquiv x)
71+
72+
theorem card_image_le {f : ZFSet → ZFSet} [Definable₁ f] :
73+
card (image f x) ≤ card x := by
74+
simpa [cardinalMk_coe_sort, ← coe_image, -mem_image] using mk_image_le (f := f) (s := x)
75+
76+
theorem lift_card_range_le {α} [Small.{v, u} α] {f : α → ZFSet.{v}} :
77+
lift.{u} (card (range f)) ≤ lift.{v} #α := by
78+
rw [← lift_le.{max u (v + 1)}, lift_lift.{v}, lift_umax.{u, v + 1}]
79+
simpa [cardinalMk_coe_sort, ← coe_range, -mem_range] using mk_range_le_lift (f := f)
80+
81+
theorem iSup_card_le_card_iUnion {α} [Small.{v, u} α] {f : α → ZFSet.{v}} :
82+
⨆ i, card (f i) ≤ card (⋃ i, f i) := by
83+
simpa [cardinalMk_coe_sort, ← coe_iUnion, ← lift_iSup (bddAbove_of_small _), -mem_iUnion] using
84+
iSup_mk_le_mk_iUnion (f := SetLike.coe ∘ f)
85+
86+
theorem lift_card_iUnion_le_sum_card {α} [Small.{v, u} α] {f : α → ZFSet.{v}} :
87+
lift (card (⋃ i, f i)) ≤ sum fun i => card (f i) := by
88+
rw [← lift_le.{max u (v + 1)}, lift_umax.{max u v, v + 1}]
89+
simpa [cardinalMk_coe_sort, ← coe_iUnion, -mem_iUnion] using
90+
mk_iUnion_le_sum_mk_lift (f := SetLike.coe ∘ f)
91+
92+
end ZFSet

lakefile.lean

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ open Lake DSL
99
require "leanprover-community" / "batteries" @ git "nightly-testing"
1010
require "leanprover-community" / "Qq" @ git "nightly-testing"
1111
require "leanprover-community" / "aesop" @ git "nightly-testing"
12-
require "leanprover-community" / "proofwidgets" @ git "v0.0.82-pre1" -- ProofWidgets should always be pinned to a specific version
12+
require "leanprover-community" / "proofwidgets" @ git "v0.0.82" -- ProofWidgets should always be pinned to a specific version
1313
with NameMap.empty.insert `errorOnBuild
1414
"ProofWidgets not up-to-date. \
1515
Please run `lake exe cache get` to fetch the latest ProofWidgets. \
@@ -186,9 +186,12 @@ post_update pkg do
186186
let toolchainVersion := match toolchainContent.trimAscii.copy.splitOn ":" with
187187
| [_, version] => version
188188
| _ => toolchainContent.trimAscii.copy -- fallback to full content if format is unexpected
189+
-- Lean.versionString does not start with a `v`, while the `lean-toolchain` file is flexible.
190+
let toolchainVersion := (toolchainVersion.dropPrefix "v").copy
189191
if Lean.versionString ≠ toolchainVersion then
190-
IO.println s!"Not running `lake exe cache get` yet, \
191-
as the `lake` version does not match the toolchain version in the project.\n\
192+
IO.println s!"Not running `lake exe cache get` yet, as \
193+
the `lake` version ({Lean.versionString}) does not match \
194+
the toolchain version ({toolchainVersion}) in the project.\n\
192195
You should run `lake exe cache get` manually."
193196
return
194197
let exeFile ← runBuild cache.fetch

scripts/nolints.json

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@
146146
["docBlame", "HomogeneousLocalization.NumDenSameDeg.num"],
147147
["docBlame", "HomologicalComplex.Hom.f"],
148148
["docBlame", "Ideal.Filtration.N"],
149-
["docBlame", "IntermediateField.delabAdjoinNotation.delabInsertArray"],
150149
["docBlame", "IsDedekindDomain.HeightOneSpectrum.asIdeal"],
151150
["docBlame", "Lean.Export.Alloc"],
152151
["docBlame", "Lean.Export.Entry"],
@@ -227,21 +226,6 @@
227226
["docBlame", "Lean.Export.State.levels"],
228227
["docBlame", "Lean.Export.State.names"],
229228
["docBlame", "Lean.Export.State.stk"],
230-
["docBlame", "Lean.Export.exportDef.axdef"],
231-
["docBlame", "Lean.Export.exportDef.defn"],
232-
["docBlame", "Lean.Export.exportDef.ind"],
233-
["docBlame", "Lean.Export.exportDef.indbody"],
234-
["docBlame", "Lean.Export.exportDef.insert"],
235-
["docBlame", "Lean.MVarId.congrN!.go"],
236-
["docBlame", "Lean.MVarId.congrN!.post"],
237-
["docBlame", "Lean.MVarId.congrSimp?.forSide"],
238-
["docBlame", "Lean.MVarId.introsClean.eqImpOfIffImp"],
239-
["docBlame", "Lean.MVarId.introsClean.heqImpOfEqImp"],
240-
["docBlame", "Lean.MVarId.introsClean.isTrivialType"],
241-
["docBlame", "Lean.MVarId.introsClean.loop"],
242-
["docBlame", "Lean.MVarId.smartHCongr?.forSide"],
243-
["docBlame", "Lean.MVarId.smartHCongr?.loop"],
244-
["docBlame", "Lean.MVarId.userCongr?.forSide"],
245229
["docBlame", "Lean.Parser.Attr.higherOrder"],
246230
["docBlame", "Lean.Parser.Tactic.applyCongr"],
247231
["docBlame", "Mathlib.Command.Variable.completeBinders"],
@@ -265,25 +249,13 @@
265249
["docBlame", "Mathlib.Tactic.GCongr.exact"],
266250
["docBlame", "Mathlib.Tactic.GCongr.tacticGcongr_discharger"],
267251
["docBlame", "Mathlib.Tactic.Propose.proposeLemmas"],
268-
["docBlame", "Mathlib.Tactic.evalIntrov.intro1PStep"],
269-
["docBlame", "Mathlib.Tactic.evalIntrov.introsDep"],
270252
["docBlame", "Module.End.Eigenvalues.val"],
271253
["docBlame", "Order.Ideal.PrimePair.F"],
272254
["docBlame", "Order.Ideal.PrimePair.I"],
273-
["docBlame", "Tactic.Elementwise.elementwiseExpr.mkHomElementwise"],
274255
["docBlame", "Lean.Meta.mkRichHCongr.doubleTelescope.loop"],
275256
["docBlame", "Lean.Meta.mkRichHCongr.withNewEqs.loop"],
276-
["docBlame", "Mathlib.Command.Variable.completeBinders'.isVariableAlias"],
277-
["docBlame", "Mathlib.Command.Variable.elabVariables.extendScope"],
278-
["docBlame", "Mathlib.Command.Variable.elabVariables.process"],
279257
["docBlame", "Mathlib.Command.Variable.variable?.checkRedundant"],
280258
["docBlame", "Mathlib.Command.Variable.variable?.maxSteps"],
281-
["docBlame", "Mathlib.Meta.NormNum.evalEq.intArm"],
282-
["docBlame", "Mathlib.Meta.NormNum.evalEq.nnratArm"],
283-
["docBlame", "Mathlib.Meta.NormNum.evalEq.ratArm"],
284-
["docBlame", "Mathlib.Meta.NormNum.evalMinFac.aux"],
285-
["docBlame", "Mathlib.Meta.NormNum.evalMinFac.core"],
286-
["docBlame", "Mathlib.Meta.NormNum.evalNatPrime.core"],
287259
["docBlame", "Mathlib.Tactic.CC.CCPropagationHandler.propagated"],
288260
["docBlame", "Mathlib.Tactic.CC.CCState.getNumROccs"],
289261
["docBlame", "Mathlib.Tactic.CC.CCState.ppAC"],
@@ -304,13 +276,4 @@
304276
["docBlame", "Mathlib.Tactic.Coherence.LiftObj.lift"],
305277
["docBlame", "Mathlib.Tactic.GCongr.ForwardExt.eval"],
306278
["docBlame", "Mathlib.Tactic.Monotonicity.mono.side"],
307-
["docBlame", "Mathlib.Tactic.Sat.buildReify.mkPS"],
308-
["docBlame", "Mathlib.Meta.NormNum.Result.add.intArm"],
309-
["docBlame", "Mathlib.Meta.NormNum.Result.add.nnratArm"],
310-
["docBlame", "Mathlib.Meta.NormNum.Result.add.ratArm"],
311-
["docBlame", "Mathlib.Meta.NormNum.Result.mul.ratArm"],
312-
["docBlame", "Mathlib.Meta.NormNum.evalLE.core.intArm"],
313-
["docBlame", "Mathlib.Meta.NormNum.evalLE.core.ratArm"],
314-
["docBlame", "Mathlib.Meta.NormNum.evalLT.core.intArm"],
315-
["docBlame", "Mathlib.Meta.NormNum.evalLT.core.nnratArm"],
316-
["docBlame", "Mathlib.Meta.NormNum.evalLT.core.ratArm"]]
279+
["docBlame", "Mathlib.Tactic.Sat.buildReify.mkPS"]]

0 commit comments

Comments
 (0)