Skip to content

Commit 079368f

Browse files
committed
Merge remote-tracking branch 'origin/master' into structured-arrow-abbrev
2 parents dbde87d + b43655d commit 079368f

File tree

81 files changed

+2072
-1028
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2072
-1028
lines changed

Cache/Requests.lean

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ namespace Cache.Requests
1313

1414
open System (FilePath)
1515

16+
/-- The full name of the main Mathlib GitHub repository. -/
17+
def MATHLIBREPO := "leanprover-community/mathlib4"
18+
1619
/--
1720
Structure to hold repository information with priority ordering
1821
-/
@@ -37,7 +40,7 @@ def isRemoteURL (url : String) : Bool :=
3740
/--
3841
Helper function to get repository from a remote name
3942
-/
40-
def getRepoFromRemote (mathlibDepPath : FilePath) (remoteName : String) (errorContext : String) : IO String := do
43+
def getRepoFromRemote (mathlibDepPath : FilePath) (remoteName : String) (errorContext : String) : IO (Option String) := do
4144
-- If the remote is already a valid URL, attempt to extract the repo from it. This happens with `gh pr checkout`
4245
if isRemoteURL remoteName then
4346
repoFromURL remoteName
@@ -46,23 +49,25 @@ def getRepoFromRemote (mathlibDepPath : FilePath) (remoteName : String) (errorCo
4649
-- standard name like `origin` or `upstream` or it errors out.
4750
let out ← IO.Process.output
4851
{cmd := "git", args := #["remote", "get-url", remoteName], cwd := mathlibDepPath}
49-
-- If `git remote get-url` fails then bail out with an error to help debug
52+
-- If `git remote get-url` fails then return none.
5053
let output := out.stdout.trimAscii
5154
unless out.exitCode == 0 do
52-
throw <| IO.userError s!"\
53-
Failed to run Git to determine Mathlib's repository from {remoteName} remote (exit code: {out.exitCode}).\n\
55+
IO.println s!"\
56+
Warning: failed to run Git to determine Mathlib's repository from {remoteName} remote\n\
5457
{errorContext}\n\
55-
Stdout:\n{output}\nStderr:\n{out.stderr.trimAscii}\n"
58+
Continuing to fetch the cache from {MATHLIBREPO}."
59+
return none
5660
-- Finally attempt to extract the repository from the remote URL returned by `git remote get-url`
5761
repoFromURL output.copy
58-
where repoFromURL (url : String) : IO String := do
62+
where repoFromURL (url : String) : IO (Option String) := do
5963
if let some repo := extractRepoFromUrl url then
60-
return repo
64+
return some repo
6165
else
62-
throw <| IO.userError s!"\
63-
Failed to extract repository from remote URL: {url}.\n\
66+
IO.println s!"\
67+
Warning: Failed to extract repository from remote URL: {url}.\n\
6468
{errorContext}\n\
65-
Please ensure the remote URL is valid and points to a GitHub repository."
69+
Continuing to fetch the cache from {MATHLIBREPO}."
70+
return none
6671

6772
/--
6873
Finds the remote name that points to `leanprover-community/mathlib4` repository.
@@ -146,7 +151,7 @@ Attempts to determine the GitHub repository of a version of Mathlib from its Git
146151
If the current commit coincides with a PR ref, it will determine the source fork
147152
of that PR rather than just using the origin remote.
148153
-/
149-
def getRemoteRepo (mathlibDepPath : FilePath) : IO RepoInfo := do
154+
def getRemoteRepo (mathlibDepPath : FilePath) : IO (Option RepoInfo) := do
150155

151156
-- Since currently we need to push a PR to `leanprover-community/mathlib` build a user cache,
152157
-- we check if we are a special branch or a branch with PR. This leaves out non-PRed fork
@@ -176,7 +181,7 @@ def getRemoteRepo (mathlibDepPath : FilePath) : IO RepoInfo := do
176181
let repo := "leanprover-community/mathlib4-nightly-testing"
177182
let cacheService := if useCloudflareCache then "Cloudflare" else "Azure"
178183
IO.println s!"Using cache ({cacheService}) from nightly-testing remote: {repo}"
179-
return {repo := repo, useFirst := true}
184+
return some {repo := repo, useFirst := true}
180185

181186
-- Only search for PR refs if we're not on a regular branch like master, bump/*, or nightly-testing*
182187
-- let isSpecialBranch := branchName == "master" || branchName.startsWith "bump/" ||
@@ -234,11 +239,16 @@ def getRemoteRepo (mathlibDepPath : FilePath) : IO RepoInfo := do
234239
-- If no tracking remote is configured, fall back to origin
235240
"origin"
236241

237-
let repo ← getRepoFromRemote mathlibDepPath remoteName
242+
let repo? ← getRepoFromRemote mathlibDepPath remoteName
238243
s!"Ensure Git is installed and the '{remoteName}' remote points to its GitHub repository."
239244
let cacheService := if useCloudflareCache then "Cloudflare" else "Azure"
240-
IO.println s!"Using cache ({cacheService}) from {remoteName}: {repo}"
241-
return {repo := repo, useFirst := false}
245+
match repo? with
246+
| some repo =>
247+
IO.println s!"Using cache ({cacheService}) from {remoteName}: {repo?}"
248+
return some {repo := repo, useFirst := false}
249+
| none =>
250+
IO.println s!"Using cache ({cacheService}) from {MATHLIBREPO}."
251+
return none
242252

243253
/-- Public URL for mathlib cache -/
244254
initialize URL : String ← do
@@ -275,9 +285,6 @@ def getUploadAuth : IO UploadAuth := do
275285
throw <| IO.userError
276286
"environment variable MATHLIB_CACHE_AZURE_BEARER_TOKEN or MATHLIB_CACHE_SAS must be set to upload caches"
277287

278-
/-- The full name of the main Mathlib GitHub repository. -/
279-
def MATHLIBREPO := "leanprover-community/mathlib4"
280-
281288
/--
282289
Given a file name like `"1234.tar.gz"`, makes the URL to that file on the server.
283290
@@ -663,16 +670,19 @@ def getFiles
663670
isMathlibRoot mathlibDepPath
664671
if failed > 0 then IO.Process.exit 1
665672
else
666-
let repoInfo ← getRemoteRepo (← read).mathlibDepPath
673+
let repoInfo? ← getRemoteRepo (← read).mathlibDepPath
667674

668675
-- Build list of repositories to download from in order
669676
let repos : List String :=
670-
if repoInfo.repo == MATHLIBREPO then
671-
[repoInfo.repo]
672-
else if repoInfo.useFirst then
673-
[repoInfo.repo, MATHLIBREPO]
677+
if let some repoInfo := repoInfo? then
678+
if repoInfo.repo == MATHLIBREPO then
679+
[MATHLIBREPO]
680+
else if repoInfo.useFirst then
681+
[repoInfo.repo, MATHLIBREPO]
682+
else
683+
[MATHLIBREPO, repoInfo.repo]
674684
else
675-
[MATHLIBREPO, repoInfo.repo]
685+
[MATHLIBREPO]
676686

677687
let mut failed : Nat := 0
678688
for h : i in [0:repos.length] do

Mathlib.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,7 @@ public import Mathlib.Algebra.Order.Antidiag.Pi
899899
public import Mathlib.Algebra.Order.Antidiag.Prod
900900
public import Mathlib.Algebra.Order.Archimedean.Basic
901901
public import Mathlib.Algebra.Order.Archimedean.Class
902+
public import Mathlib.Algebra.Order.Archimedean.Defs
902903
public import Mathlib.Algebra.Order.Archimedean.Hom
903904
public import Mathlib.Algebra.Order.Archimedean.IndicatorCard
904905
public import Mathlib.Algebra.Order.Archimedean.Submonoid
@@ -1493,6 +1494,7 @@ public import Mathlib.AlgebraicTopology.SimplexCategory.GeneratorsRelations.EpiM
14931494
public import Mathlib.AlgebraicTopology.SimplexCategory.GeneratorsRelations.NormalForms
14941495
public import Mathlib.AlgebraicTopology.SimplexCategory.MorphismProperty
14951496
public import Mathlib.AlgebraicTopology.SimplexCategory.Rev
1497+
public import Mathlib.AlgebraicTopology.SimplexCategory.SemiSimplexCategory
14961498
public import Mathlib.AlgebraicTopology.SimplexCategory.ToMkOne
14971499
public import Mathlib.AlgebraicTopology.SimplexCategory.Truncated
14981500
public import Mathlib.AlgebraicTopology.SimplicialCategory.Basic
@@ -1536,8 +1538,10 @@ public import Mathlib.AlgebraicTopology.SimplicialSet.NerveAdjunction
15361538
public import Mathlib.AlgebraicTopology.SimplicialSet.NerveNondegenerate
15371539
public import Mathlib.AlgebraicTopology.SimplicialSet.NonDegenerateSimplices
15381540
public import Mathlib.AlgebraicTopology.SimplicialSet.NonDegenerateSimplicesSubcomplex
1541+
public import Mathlib.AlgebraicTopology.SimplicialSet.Nonempty
15391542
public import Mathlib.AlgebraicTopology.SimplicialSet.Op
15401543
public import Mathlib.AlgebraicTopology.SimplicialSet.Path
1544+
public import Mathlib.AlgebraicTopology.SimplicialSet.PiZero
15411545
public import Mathlib.AlgebraicTopology.SimplicialSet.Presentable
15421546
public import Mathlib.AlgebraicTopology.SimplicialSet.ProdStdSimplex
15431547
public import Mathlib.AlgebraicTopology.SimplicialSet.ProdStdSimplexOne
@@ -6229,6 +6233,7 @@ public import Mathlib.RingTheory.AlgebraicIndependent.RankAndCardinality
62296233
public import Mathlib.RingTheory.AlgebraicIndependent.TranscendenceBasis
62306234
public import Mathlib.RingTheory.AlgebraicIndependent.Transcendental
62316235
public import Mathlib.RingTheory.Artinian.Algebra
6236+
public import Mathlib.RingTheory.Artinian.Defs
62326237
public import Mathlib.RingTheory.Artinian.Instances
62336238
public import Mathlib.RingTheory.Artinian.Module
62346239
public import Mathlib.RingTheory.Artinian.Ring
@@ -6243,6 +6248,7 @@ public import Mathlib.RingTheory.Binomial
62436248
public import Mathlib.RingTheory.ChainOfDivisors
62446249
public import Mathlib.RingTheory.ClassGroup
62456250
public import Mathlib.RingTheory.Coalgebra.Basic
6251+
public import Mathlib.RingTheory.Coalgebra.CoassocSimps
62466252
public import Mathlib.RingTheory.Coalgebra.Convolution
62476253
public import Mathlib.RingTheory.Coalgebra.Equiv
62486254
public import Mathlib.RingTheory.Coalgebra.GroupLike

Mathlib/Algebra/Algebra/Equiv.lean

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ def toAlgEquiv {F R A B : Type*} [CommSemiring R] [Semiring A] [Semiring B] [Alg
6969
[Algebra R B] [EquivLike F A B] [AlgEquivClass F R A B] (f : F) : A ≃ₐ[R] B :=
7070
{ (f : A ≃ B), (f : A ≃+* B) with commutes' := commutes f }
7171

72-
instance (F R A B : Type*) [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]
73-
[EquivLike F A B] [AlgEquivClass F R A B] : CoeTC F (A ≃ₐ[R] B) :=
74-
⟨toAlgEquiv⟩
7572
end AlgEquivClass
7673

7774
namespace AlgEquiv
@@ -137,7 +134,7 @@ theorem toEquiv_eq_coe : e.toEquiv = e :=
137134

138135
@[simp]
139136
protected theorem coe_coe {F : Type*} [EquivLike F A₁ A₂] [AlgEquivClass F R A₁ A₂] (f : F) :
140-
⇑(f : A₁ ≃ₐ[R] A₂) = f :=
137+
⇑(AlgEquivClass.toAlgEquiv f) = f :=
141138
rfl
142139

143140
theorem coe_fun_injective : @Function.Injective (A₁ ≃ₐ[R] A₂) (A₁ → A₂) fun e => (e : A₁ → A₂) :=
@@ -255,13 +252,13 @@ theorem invFun_eq_symm {e : A₁ ≃ₐ[R] A₂} : e.invFun = e.symm :=
255252
@[simp]
256253
theorem coe_apply_coe_coe_symm_apply {F : Type*} [EquivLike F A₁ A₂] [AlgEquivClass F R A₁ A₂]
257254
(f : F) (x : A₂) :
258-
f ((f : A₁ ≃ₐ[R] A₂).symm x) = x :=
255+
f ((AlgEquivClass.toAlgEquiv f).symm x) = x :=
259256
EquivLike.right_inv f x
260257

261258
@[simp]
262259
theorem coe_coe_symm_apply_coe_apply {F : Type*} [EquivLike F A₁ A₂] [AlgEquivClass F R A₁ A₂]
263260
(f : F) (x : A₁) :
264-
(f : A₁ ≃ₐ[R] A₂).symm (f x) = x :=
261+
(AlgEquivClass.toAlgEquiv f).symm (f x) = x :=
265262
EquivLike.left_inv f x
266263

267264
/-- `simp` normal form of `invFun_eq_symm` -/

Mathlib/Algebra/Algebra/Spectrum/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ theorem AlgEquiv.spectrum_eq {F R A B : Type*} [CommSemiring R] [Ring A] [Ring B
424424
spectrum R (f a) = spectrum R a :=
425425
Set.Subset.antisymm (AlgHom.spectrum_apply_subset _ _) <| by
426426
simpa only [AlgEquiv.coe_algHom, AlgEquiv.coe_coe_symm_apply_coe_apply] using
427-
AlgHom.spectrum_apply_subset (f : A ≃ₐ[R] B).symm (f a)
427+
AlgHom.spectrum_apply_subset (AlgEquivClass.toAlgEquiv f : A ≃ₐ[R] B).symm (f a)
428428

429429
section ConjugateUnits
430430

Mathlib/Algebra/BigOperators/Intervals.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ theorem prod_Icc_succ_top {a b : ℕ} (hab : a ≤ b + 1) (f : ℕ → M) :
7878
@[to_additive]
7979
theorem prod_range_mul_prod_Ico (f : ℕ → M) {m n : ℕ} (h : m ≤ n) :
8080
((∏ k ∈ range m, f k) * ∏ k ∈ Ico m n, f k) = ∏ k ∈ range n, f k :=
81-
Nat.Ico_zero_eq_range ▸ Nat.Ico_zero_eq_range ▸ prod_Ico_consecutive f m.zero_le h
81+
Nat.Ico_zero_eq_range m ▸ Nat.Ico_zero_eq_range n ▸ prod_Ico_consecutive f m.zero_le h
8282

8383
@[to_additive]
8484
theorem prod_range_eq_mul_Ico (f : ℕ → M) {n : ℕ} (hn : 0 < n) :
8585
∏ x ∈ Finset.range n, f x = f 0 * ∏ x ∈ Ico 1 n, f x :=
86-
Finset.range_eq_Ico ▸ Finset.prod_eq_prod_Ico_succ_bot hn f
86+
Finset.range_eq_Ico n ▸ Finset.prod_eq_prod_Ico_succ_bot hn f
8787

8888
@[to_additive]
8989
theorem prod_Ico_eq_mul_inv {δ : Type*} [CommGroup δ] (f : ℕ → δ) {m n : ℕ} (h : m ≤ n) :

Mathlib/Algebra/BigOperators/Module.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ theorem sum_range_by_parts :
5959
f (n - 1) • G n - ∑ i ∈ range (n - 1), (f (i + 1) - f i) • G (i + 1) := by
6060
by_cases hn : n = 0
6161
· simp [hn]
62-
· rw [range_eq_Ico, sum_Ico_by_parts f g (Nat.pos_of_ne_zero hn), sum_range_zero, smul_zero,
63-
sub_zero, range_eq_Ico]
62+
· simp only [range_eq_Ico]
63+
rw [sum_Ico_by_parts f g (Nat.pos_of_ne_zero hn), sum_range_zero, smul_zero, sub_zero]
64+
simp only [← range_eq_Ico]
6465

6566
end Finset

Mathlib/Algebra/Exact.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ lemma iff_rangeFactorization [One P] (hg : 1 ∈ Set.range g) :
9292
MulExact f g ↔ MulExact ((↑) : Set.range f → N) (Set.rangeFactorization g) := by
9393
letI : One (Set.range g) := ⟨⟨1, hg⟩⟩
9494
have : ((1 : Set.range g) : P) = 1 := rfl
95-
simp [MulExact, Set.rangeFactorization, Subtype.ext_iff, this]
95+
simp [MulExact, Subtype.ext_iff, this]
9696

9797
/-- If two maps `f : M → N` and `g : N → P` are exact, then the induced maps
9898
`Set.range f → N → Set.range g` are exact.
@@ -430,8 +430,7 @@ def Exact.splitInjectiveEquiv
430430
· intro x y e
431431
simp only [prod_apply, Pi.prod, Prod.mk.injEq] at e
432432
obtain ⟨z, hz⟩ := (h (x - y)).mp (by simpa [sub_eq_zero] using e.2)
433-
suffices z = 0 by rw [← sub_eq_zero, ← hz, this, map_zero]
434-
rw [← h₁ z, hz, map_sub, e.1, sub_self]
433+
rw [← sub_eq_zero, ← hz, ← h₁ z, hz, map_sub, e.1, sub_self, map_zero]
435434
· rintro ⟨x, y⟩
436435
obtain ⟨y, rfl⟩ := hg y
437436
refine ⟨f x + y - f (l.1 y), by ext <;> simp [h₁, h₂]⟩

Mathlib/Algebra/Module/Torsion/Basic.lean

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,8 @@ namespace Module
534534
variable [Ring R] [AddCommGroup M] [Module R M]
535535
variable {I : Ideal R} {r : R}
536536

537-
-- adding `@[implicit_reducible]` causes downstream breakage
538-
set_option warn.classDefReducibility false in
539537
/-- can't be an instance because `hM` can't be inferred -/
538+
@[implicit_reducible]
540539
def IsTorsionBySet.hasSMul (hM : IsTorsionBySet R M I) : SMul (R ⧸ I) M where
541540
smul b := QuotientAddGroup.lift I.toAddSubgroup (smulAddHom R M)
542541
(by rwa [isTorsionBySet_iff_subset_annihilator] at hM) b
@@ -557,17 +556,16 @@ theorem IsTorsionBy.mk_smul [(Ideal.span {r}).IsTwoSided] (hM : IsTorsionBy R M
557556
Ideal.Quotient.mk (Ideal.span {r}) b • x = b • x :=
558557
rfl
559558

560-
-- adding `@[implicit_reducible]` causes downstream breakage
561-
set_option warn.classDefReducibility false in
562559
/-- An `(R ⧸ I)`-module is an `R`-module which `IsTorsionBySet R M I`. -/
560+
@[implicit_reducible]
563561
def IsTorsionBySet.module [I.IsTwoSided] (hM : IsTorsionBySet R M I) : Module (R ⧸ I) M :=
564-
letI := hM.hasSMul; I.mkQ_surjective.moduleLeft _ (IsTorsionBySet.mk_smul hM)
562+
letI := hM.hasSMul; fast_instance% I.mkQ_surjective.moduleLeft _ (IsTorsionBySet.mk_smul hM)
565563

566564
instance IsTorsionBySet.isScalarTower [I.IsTwoSided] (hM : IsTorsionBySet R M I)
567565
{S : Type*} [SMul S R] [SMul S M] [IsScalarTower S R M] [IsScalarTower S R R] :
568-
@IsScalarTower S (R ⧸ I) M _ (IsTorsionBySet.module hM).toSMul _ :=
566+
@IsScalarTower S (R ⧸ I) M _ hM.hasSMul _ :=
569567
-- Porting note: still needed to be fed the Module R / I M instance
570-
@IsScalarTower.mk S (R ⧸ I) M _ (IsTorsionBySet.module hM).toSMul _
568+
@IsScalarTower.mk S (R ⧸ I) M _ hM.hasSMul _
571569
(fun b d x => Quotient.inductionOn' d fun c => (smul_assoc b c x :))
572570

573571
/-- If an `R`-module `M` is annihilated by a two-sided ideal `I`, then the identity is a semilinear
@@ -580,20 +578,19 @@ def IsTorsionBySet.semilinearMap [I.IsTwoSided] (hM : IsTorsionBySet R M I) :
580578
map_smul' := fun _ _ ↦ rfl }
581579

582580
theorem IsTorsionBySet.isSemisimpleModule_iff [I.IsTwoSided]
583-
(hM : Module.IsTorsionBySet R M I) : let _ := hM.module
581+
(hM : Module.IsTorsionBySet R M I) : letI := hM.module
584582
IsSemisimpleModule (R ⧸ I) M ↔ IsSemisimpleModule R M :=
585-
let _ := hM.module
583+
letI := hM.module
586584
(hM.semilinearMap.isSemisimpleModule_iff_of_bijective Function.bijective_id).symm
587585

588586
/-- An `(R ⧸ Ideal.span {r})`-module is an `R`-module for which `IsTorsionBy R M r`. -/
589587
abbrev IsTorsionBy.module [h : (Ideal.span {r}).IsTwoSided] (hM : IsTorsionBy R M r) :
590588
Module (R ⧸ Ideal.span {r}) M := by
591589
rw [Ideal.span] at h; exact ((isTorsionBySet_span_singleton_iff r).mpr hM).module
592590

593-
-- adding `@[implicit_reducible]` causes downstream breakage
594-
set_option warn.classDefReducibility false in
595591
/-- Any module is also a module over the quotient of the ring by the annihilator.
596592
Not an instance because it causes synthesis failures / timeouts. -/
593+
@[implicit_reducible]
597594
def quotientAnnihilator : Module (R ⧸ Module.annihilator R M) M :=
598595
(isTorsionBySet_annihilator R M).module
599596

@@ -989,9 +986,8 @@ lemma torsionBy.mod_self_nsmul' (s : ℕ) {x : A} (h : x ∈ A[n]) :
989986
s • x = (s % n) • x :=
990987
nsmul_eq_mod_nsmul s (torsionBy.nsmul_iff.mp h)
991988

992-
-- adding `@[implicit_reducible]` causes downstream breakage
993-
set_option warn.classDefReducibility false in
994989
/-- For a natural number `n`, the `n`-torsion subgroup of `A` is a `ZMod n` module. -/
990+
@[implicit_reducible]
995991
def torsionBy.zmodModule : Module (ZMod n) A[n] :=
996992
AddCommGroup.zmodModule torsionBy.nsmul
997993

0 commit comments

Comments
 (0)