Skip to content

Commit 3b0bd8c

Browse files
Trigger CI for leanprover/lean4#8470
2 parents 20861d8 + e8511a8 commit 3b0bd8c

File tree

452 files changed

+2500
-1472
lines changed

Some content is hidden

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

452 files changed

+2500
-1472
lines changed

Archive/ZagierTwoSquares.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ has exactly one fixed point, so `|S|` is odd and the involution defined by
1919
`(x, y, z) ↦ (x, z, y)` also has a fixed point." — [Don Zagier](Zagier1990)
2020
2121
This elementary proof (`Nat.Prime.sq_add_sq'`) is independent of `Nat.Prime.sq_add_sq` in
22-
`Mathlib.NumberTheory.SumTwoSquares`, which uses the unique factorisation of `ℤ[i]`.
22+
`Mathlib/NumberTheory/SumTwoSquares.lean`, which uses the unique factorisation of `ℤ[i]`.
2323
For a geometric interpretation of the piecewise involution (`Zagier.complexInvo`)
2424
see [Moritz Firsching's MathOverflow answer](https://mathoverflow.net/a/299696).
2525
-/

Cache/Main.lean

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ def curlArgs : List String :=
5656
def leanTarArgs : List String :=
5757
["get", "get!", "pack", "pack!", "unpack", "lookup"]
5858

59+
/-- Parses an optional `--repo` option. -/
60+
def parseRepo (args : List String) : IO (Option String × List String) := do
61+
if let arg :: args := args then
62+
if arg.startsWith "--" then
63+
if let some repo := arg.dropPrefix? "--repo=" then
64+
return (some repo.toString, args)
65+
else
66+
throw <| IO.userError s!"unknown option: {arg}"
67+
return (none, args)
68+
5969
open Cache IO Hashing Requests System in
6070
def main (args : List String) : IO Unit := do
6171
if Lean.versionString == "4.8.0-rc1" && Lean.githash == "b470eb522bfd68ca96938c23f6a1bce79da8a99f" then do
@@ -67,6 +77,7 @@ def main (args : List String) : IO Unit := do
6777
Process.exit 0
6878
CacheM.run do
6979

80+
let (repo?, args) ← parseRepo args
7081
let mut roots : Std.HashMap Lean.Name FilePath ← parseArgs args
7182
if roots.isEmpty then do
7283
-- No arguments means to start from `Mathlib.lean`
@@ -82,11 +93,12 @@ def main (args : List String) : IO Unit := do
8293
if leanTarArgs.contains (args.headD "") then validateLeanTar
8394
let get (args : List String) (force := false) (decompress := true) := do
8495
let hashMap ← if args.isEmpty then pure hashMap else hashMemo.filterByRootModules roots.keys
85-
getFiles hashMap force force goodCurl decompress
96+
getFiles repo? hashMap force force goodCurl decompress
8697
let pack (overwrite verbose unpackedOnly := false) := do
8798
packCache hashMap overwrite verbose unpackedOnly (← getGitCommitHash)
8899
let put (overwrite unpackedOnly := false) := do
89-
putFiles (← pack overwrite (verbose := true) unpackedOnly) overwrite (← getToken)
100+
let repo := repo?.getD MATHLIBREPO
101+
putFiles repo (← pack overwrite (verbose := true) unpackedOnly) overwrite (← getToken)
90102
match args with
91103
| "get" :: args => get args
92104
| "get!" :: args => get args (force := true)

Cache/Requests.lean

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,29 @@ import Cache.Hashing
88

99
namespace Cache.Requests
1010

11+
/-- Attempts to determine the running project's GitHub repository from its `origin` Git remote. -/
12+
def getRemoteRepo : IO String := do
13+
let out ← IO.Process.output {cmd := "git", args := #["remote", "get-url", "origin"]}
14+
unless out.exitCode == 0 do
15+
throw <| IO.userError s!"\
16+
Failed to run Git to determine project repository (exit code: {out.exitCode}).\n\
17+
Ensure Git is installed and the `origin` remote points to the project's GitHub repository.\n\
18+
Stdout:\n{out.stdout.trim}\nStderr:{out.stderr.trim}\n"
19+
-- No strong validation is done here because this is simply used as a smart default
20+
-- for `lake exe cache get`, which is freely modifiable by any user.
21+
let url := out.stdout.trim.stripSuffix ".git"
22+
let repo? : Option String := do
23+
let pos ← url.revFind (· == '/')
24+
let pos ← url.revFindAux (fun c => c == '/' || c == ':') pos
25+
return url.extract (url.next pos) url.endPos
26+
if let some repo := repo? then
27+
return repo
28+
else
29+
throw <| IO.userError s!"\
30+
Failed to determine project repository from remote URL.\n\
31+
Ensure the `origin` Git remote points to the project's GitHub repository.\n\
32+
Detected URL: {url}"
33+
1134
-- FRO cache is flaky so disable until we work out the kinks: https://leanprover.zulipchat.com/#narrow/channel/113488-general/topic/The.20cache.20doesn't.20work/near/411058849
1235
def useFROCache : Bool := false
1336

@@ -27,18 +50,22 @@ def getToken : IO String := do
2750

2851
open System (FilePath)
2952

53+
/-- The full name of the main Mathlib GitHub repository. -/
54+
def MATHLIBREPO := "leanprover-community/mathlib4"
55+
3056
/--
3157
Given a file name like `"1234.tar.gz"`, makes the URL to that file on the server.
3258
3359
The `f/` prefix means that it's a common file for caching.
3460
-/
35-
def mkFileURL (URL fileName : String) : String :=
36-
s!"{URL}/f/{fileName}"
61+
def mkFileURL (repo URL fileName : String) : String :=
62+
let pre := if repo == MATHLIBREPO then "" else s!"{repo}/"
63+
s!"{URL}/f/{pre}{fileName}"
3764

3865
section Get
3966

4067
/-- Formats the config file for `curl`, containing the list of files to be downloaded -/
41-
def mkGetConfigContent (hashMap : IO.ModuleHashMap) : IO String := do
68+
def mkGetConfigContent (repo : String) (hashMap : IO.ModuleHashMap) : IO String := do
4269
hashMap.toArray.foldlM (init := "") fun acc ⟨_, hash⟩ => do
4370
let fileName := hash.asLTar
4471
-- Below we use `String.quote`, which is intended for quoting for use in Lean code
@@ -54,13 +81,13 @@ def mkGetConfigContent (hashMap : IO.ModuleHashMap) : IO String := do
5481

5582
-- Note we append a '.part' to the filenames here,
5683
-- which `downloadFiles` then removes when the download is successful.
57-
pure <| acc ++ s!"url = {mkFileURL URL fileName}\n\
84+
pure <| acc ++ s!"url = {mkFileURL repo URL fileName}\n\
5885
-o {(IO.CACHEDIR / (fileName ++ ".part")).toString.quote}\n"
5986

6087
/-- Calls `curl` to download a single file from the server to `CACHEDIR` (`.cache`) -/
61-
def downloadFile (hash : UInt64) : IO Bool := do
88+
def downloadFile (repo : String) (hash : UInt64) : IO Bool := do
6289
let fileName := hash.asLTar
63-
let url := mkFileURL URL fileName
90+
let url := mkFileURL repo URL fileName
6491
let path := IO.CACHEDIR / fileName
6592
let partFileName := fileName ++ ".part"
6693
let partPath := IO.CACHEDIR / partFileName
@@ -75,15 +102,16 @@ def downloadFile (hash : UInt64) : IO Bool := do
75102

76103
/-- Call `curl` to download files from the server to `CACHEDIR` (`.cache`).
77104
Exit the process with exit code 1 if any files failed to download. -/
78-
def downloadFiles (hashMap : IO.ModuleHashMap) (forceDownload : Bool) (parallel : Bool) :
79-
IO Unit := do
105+
def downloadFiles
106+
(repo : String) (hashMap : IO.ModuleHashMap)
107+
(forceDownload : Bool) (parallel : Bool) (warnOnMissing : Bool): IO Unit := do
80108
let hashMap ← if forceDownload then pure hashMap else hashMap.filterExists false
81109
let size := hashMap.size
82110
if size > 0 then
83111
IO.FS.createDirAll IO.CACHEDIR
84-
IO.println s!"Attempting to download {size} file(s)"
112+
IO.println s!"Attempting to download {size} file(s) from {repo} cache"
85113
let failed ← if parallel then
86-
IO.FS.writeFile IO.CURLCFG (← mkGetConfigContent hashMap)
114+
IO.FS.writeFile IO.CURLCFG (← mkGetConfigContent repo hashMap)
87115
let args := #["--request", "GET", "--parallel", "--fail", "--silent",
88116
"--retry", "5", -- there seem to be some intermittent failures
89117
"--write-out", "%{json}\n", "--config", IO.CURLCFG.toString]
@@ -125,15 +153,15 @@ def downloadFiles (hashMap : IO.ModuleHashMap) (forceDownload : Bool) (parallel
125153
msg := msg ++ s!", {failed} failed"
126154
IO.eprintln msg
127155
IO.FS.removeFile IO.CURLCFG
128-
if success + failed < done then
156+
if warnOnMissing && success + failed < done then
129157
IO.eprintln "Warning: some files were not found in the cache."
130158
IO.eprintln "This usually means that your local checkout of mathlib4 has diverged from upstream."
131159
IO.eprintln "If you push your commits to a branch of the mathlib4 repository, CI will build the oleans and they will be available later."
132160
IO.eprintln "Alternatively, if you already have pushed your commits to a branch, this may mean the CI build has failed part-way through building."
133161
pure failed
134162
else
135163
let r ← hashMap.foldM (init := []) fun acc _ hash => do
136-
pure <| (← IO.asTask do downloadFile hash) :: acc
164+
pure <| (← IO.asTask do downloadFile repo hash) :: acc
137165
pure <| r.foldl (init := 0) fun f t => if let .ok true := t.get then f else f + 1
138166
if failed > 0 then
139167
IO.println s!"{failed} download(s) failed"
@@ -186,12 +214,21 @@ def getProofWidgets (buildDir : FilePath) : IO Unit := do
186214
throw <| IO.userError s!"Failed to prune ProofWidgets cloud release: {e}"
187215

188216
/-- Downloads missing files, and unpacks files. -/
189-
def getFiles (hashMap : IO.ModuleHashMap) (forceDownload forceUnpack parallel decompress : Bool) :
190-
IO.CacheM Unit := do
217+
def getFiles
218+
(repo? : Option String) (hashMap : IO.ModuleHashMap)
219+
(forceDownload forceUnpack parallel decompress : Bool)
220+
: IO.CacheM Unit := do
191221
let isMathlibRoot ← IO.isMathlibRoot
192222
unless isMathlibRoot do checkForToolchainMismatch
193223
getProofWidgets (← read).proofWidgetsBuildDir
194-
downloadFiles hashMap forceDownload parallel
224+
if let some repo := repo? then
225+
downloadFiles repo hashMap forceDownload parallel (warnOnMissing := true)
226+
else
227+
let repo ← getRemoteRepo
228+
IO.println s!"Project repository: {repo}"
229+
downloadFiles repo hashMap forceDownload parallel (warnOnMissing := false)
230+
unless repo == MATHLIBREPO do
231+
downloadFiles MATHLIBREPO hashMap forceDownload parallel (warnOnMissing := true)
195232
if decompress then
196233
IO.unpackCache hashMap forceUnpack
197234
else
@@ -209,20 +246,22 @@ def UPLOAD_URL : String :=
209246
URL
210247

211248
/-- Formats the config file for `curl`, containing the list of files to be uploaded -/
212-
def mkPutConfigContent (fileNames : Array String) (token : String) : IO String := do
249+
def mkPutConfigContent (repo : String) (fileNames : Array String) (token : String) : IO String := do
213250
let token := if useFROCache then "" else s!"?{token}" -- the FRO cache doesn't pass the token here
214251
let l ← fileNames.toList.mapM fun fileName : String => do
215-
pure s!"-T {(IO.CACHEDIR / fileName).toString}\nurl = {mkFileURL UPLOAD_URL fileName}{token}"
252+
pure s!"-T {(IO.CACHEDIR / fileName).toString}\nurl = {mkFileURL repo UPLOAD_URL fileName}{token}"
216253
return "\n".intercalate l
217254

218255
/-- Calls `curl` to send a set of cached files to the server -/
219-
def putFiles (fileNames : Array String) (overwrite : Bool) (token : String) : IO Unit := do
256+
def putFiles
257+
(repo : String) (fileNames : Array String)
258+
(overwrite : Bool) (token : String) : IO Unit := do
220259
-- TODO: reimplement using HEAD requests?
221260
let _ := overwrite
222261
let size := fileNames.size
223262
if size > 0 then
224-
IO.FS.writeFile IO.CURLCFG (← mkPutConfigContent fileNames token)
225-
IO.println s!"Attempting to upload {size} file(s)"
263+
IO.FS.writeFile IO.CURLCFG (← mkPutConfigContent repo fileNames token)
264+
IO.println s!"Attempting to upload {size} file(s) to {repo} cache"
226265
let args := if useFROCache then
227266
-- TODO: reimplement using HEAD requests?
228267
let _ := overwrite

Mathlib.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4875,6 +4875,7 @@ import Mathlib.Order.UpperLower.Hom
48754875
import Mathlib.Order.UpperLower.LocallyFinite
48764876
import Mathlib.Order.UpperLower.Principal
48774877
import Mathlib.Order.UpperLower.Prod
4878+
import Mathlib.Order.UpperLower.Relative
48784879
import Mathlib.Order.WellFounded
48794880
import Mathlib.Order.WellFoundedSet
48804881
import Mathlib.Order.WellQuasiOrder
@@ -5182,6 +5183,8 @@ import Mathlib.RingTheory.IntegralClosure.IsIntegralClosure.Basic
51825183
import Mathlib.RingTheory.IntegralClosure.IsIntegralClosure.Defs
51835184
import Mathlib.RingTheory.IntegralDomain
51845185
import Mathlib.RingTheory.Invariant
5186+
import Mathlib.RingTheory.Invariant.Basic
5187+
import Mathlib.RingTheory.Invariant.Profinite
51855188
import Mathlib.RingTheory.IsAdjoinRoot
51865189
import Mathlib.RingTheory.IsPrimary
51875190
import Mathlib.RingTheory.IsTensorProduct

Mathlib/Algebra/AddTorsor/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import Mathlib.Algebra.Group.Pointwise.Set.Scalar
1111
/-!
1212
# Torsors of additive group actions
1313
14-
Further results for torsors, that are not in `Mathlib.Algebra.AddTorsor.Defs` to avoid increasing
15-
imports there.
14+
Further results for torsors, that are not in `Mathlib/Algebra/AddTorsor/Defs.lean` to avoid
15+
increasing imports there.
1616
-/
1717

1818
open scoped Pointwise

Mathlib/Algebra/Algebra/Defs.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import Mathlib.Algebra.Module.LinearMap.Defs
1010
1111
In this file we define associative unital `Algebra`s over commutative (semi)rings.
1212
13-
* algebra homomorphisms `AlgHom` are defined in `Mathlib.Algebra.Algebra.Hom`;
13+
* algebra homomorphisms `AlgHom` are defined in `Mathlib/Algebra/Algebra/Hom.lean`;
1414
15-
* algebra equivalences `AlgEquiv` are defined in `Mathlib.Algebra.Algebra.Equiv`;
15+
* algebra equivalences `AlgEquiv` are defined in `Mathlib/Algebra/Algebra/Equiv.lean`;
1616
17-
* `Subalgebra`s are defined in `Mathlib.Algebra.Algebra.Subalgebra`;
17+
* `Subalgebra`s are defined in `Mathlib/Algebra/Algebra/Subalgebra.lean`;
1818
1919
* The category `AlgCat R` of `R`-algebras is defined in the file
20-
`Mathlib.Algebra.Category.Algebra.Basic`.
20+
`Mathlib/Algebra/Category/Algebra/Basic.lean`.
2121
2222
See the implementation notes for remarks about non-associative and non-unital algebras.
2323

Mathlib/Algebra/Algebra/Hom.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class AlgHomClass (F : Type*) (R A B : outParam Type*)
5252
commutes : ∀ (f : F) (r : R), f (algebraMap R A r) = algebraMap R B r
5353

5454
-- For now, don't replace `AlgHom.commutes` and `AlgHomClass.commutes` with the more generic lemma.
55-
-- The file `Mathlib.NumberTheory.NumberField.CanonicalEmbedding.FundamentalCone` slows down by
55+
-- The file `Mathlib/NumberTheory/NumberField/CanonicalEmbedding/FundamentalCone.lean` slows down by
5656
-- 15% if we would do so (see benchmark on PR https://github.com/leanprover-community/mathlib4/pull/18040).
5757
-- attribute [simp] AlgHomClass.commutes
5858

Mathlib/Algebra/Algebra/Subalgebra/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Mathlib.RingTheory.SimpleRing.Basic
1313
In this file we define `Subalgebra`s and the usual operations on them (`map`, `comap`).
1414
1515
The `Algebra.adjoin` operation and complete lattice structure can be found in
16-
`Mathlib.Algebra.Algebra.Subalgebra.Lattice`.
16+
`Mathlib/Algebra/Algebra/Subalgebra/Lattice.lean`.
1717
-/
1818

1919
universe u u' v w w'

Mathlib/Algebra/Algebra/Subalgebra/Lattice.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Mathlib.Algebra.Algebra.Subalgebra.Basic
1111
1212
In this file we define `Algebra.adjoin` and the complete lattice structure on subalgebras.
1313
14-
More lemmas about `adjoin` can be found in `Mathlib.RingTheory.Adjoin.Basic`.
14+
More lemmas about `adjoin` can be found in `Mathlib/RingTheory/Adjoin/Basic.lean`.
1515
-/
1616

1717
assert_not_exists Polynomial

Mathlib/Algebra/Algebra/Subalgebra/Operations.lean

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ Authors: Andrew Yang, Antoine Chambert-Loir
55
-/
66
import Mathlib.Algebra.Algebra.Subalgebra.Basic
77
import Mathlib.RingTheory.Ideal.Maps
8+
import Mathlib.Algebra.Ring.Action.Submonoid
89

910
/-!
1011
# More operations on subalgebras
1112
12-
In this file we relate the definitions in `Mathlib.RingTheory.Ideal.Operations` to subalgebras.
13-
The contents of this file are somewhat random since both `Mathlib.Algebra.Algebra.Subalgebra.Basic`
14-
and `Mathlib.RingTheory.Ideal.Operations` are somewhat of a grab-bag of definitions, and this is
15-
whatever ends up in the intersection.
13+
In this file we relate the definitions in `Mathlib/RingTheory/Ideal/Operations.lean` to subalgebras.
14+
The contents of this file are somewhat random since both
15+
`Mathlib/Algebra/Algebra/Subalgebra/Basic.lean` and `Mathlib/RingTheory/Ideal/Operations.lean` are
16+
somewhat of a grab-bag of definitions, and this is whatever ends up in the intersection.
1617
-/
1718

1819
assert_not_exists Cardinal
@@ -71,3 +72,21 @@ theorem mem_of_span_eq_top_of_smul_pow_mem
7172
mem_of_finset_sum_eq_one_of_pow_smul_mem S' l.support (↑) l hs (fun x => hs' x.2) hl x H
7273

7374
end Subalgebra
75+
76+
section MulSemiringAction
77+
78+
variable (A B : Type*) [CommRing A] [CommRing B] [Algebra A B]
79+
variable (G : Type*) [Monoid G] [MulSemiringAction G B] [SMulCommClass G A B]
80+
81+
/-- The set of fixed points under a group action, as a subring. -/
82+
def FixedPoints.subring : Subring B where
83+
__ := FixedPoints.addSubgroup G B
84+
__ := FixedPoints.submonoid G B
85+
86+
/-- The set of fixed points under a group action, as a subalgebra. -/
87+
def FixedPoints.subalgebra : Subalgebra A B where
88+
__ := FixedPoints.addSubgroup G B
89+
__ := FixedPoints.submonoid G B
90+
algebraMap_mem' r := by simp
91+
92+
end MulSemiringAction

0 commit comments

Comments
 (0)