Skip to content

Commit 806f7f9

Browse files
committed
chore: revert move utilities into Util directory (#5787) (#5825)
This reverts commit 4dd7b55. Per [zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Warning.3A.20some.20files.20were.20not.20found.20in.20the.20cache.2E/near/374481558) discussion. Co-authored-by: Scott Morrison <[email protected]>
1 parent 1e93cf2 commit 806f7f9

18 files changed

+44
-159
lines changed

.github/workflows/bors.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,9 @@ jobs:
7272
run: |
7373
git ls-files 'Mathlib/*.lean' | LC_ALL=C sort | sed 's/\.lean//;s,/,.,g;s/^/import /' > Mathlib.lean
7474
75-
- name: update TacticCaches.lean
75+
- name: update MathlibExtras.lean
7676
run: |
77-
cd Util
78-
git ls-files 'TacticCaches/*.lean' | LC_ALL=C sort | sed 's/\.lean//;s,/,.,g;s/^/import /' > TacticCaches.lean
77+
git ls-files 'MathlibExtras/*.lean' | LC_ALL=C sort | sed 's/\.lean//;s,/,.,g;s/^/import /' > MathlibExtras.lean
7978
8079
- name: update Mathlib/Tactic.lean
8180
run: |
@@ -132,8 +131,8 @@ jobs:
132131
run: |
133132
! grep "stdout:" stdout.log
134133
135-
- name: build tactic caches
136-
run: lake build TacticCaches
134+
- name: build library_search cache
135+
run: lake build MathlibExtras
137136

138137
- name: upload cache
139138
if: always()

.github/workflows/build.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,9 @@ jobs:
7878
run: |
7979
git ls-files 'Mathlib/*.lean' | LC_ALL=C sort | sed 's/\.lean//;s,/,.,g;s/^/import /' > Mathlib.lean
8080
81-
- name: update TacticCaches.lean
81+
- name: update MathlibExtras.lean
8282
run: |
83-
cd Util
84-
git ls-files 'TacticCaches/*.lean' | LC_ALL=C sort | sed 's/\.lean//;s,/,.,g;s/^/import /' > TacticCaches.lean
83+
git ls-files 'MathlibExtras/*.lean' | LC_ALL=C sort | sed 's/\.lean//;s,/,.,g;s/^/import /' > MathlibExtras.lean
8584
8685
- name: update Mathlib/Tactic.lean
8786
run: |
@@ -138,8 +137,8 @@ jobs:
138137
run: |
139138
! grep "stdout:" stdout.log
140139
141-
- name: build tactic caches
142-
run: lake build TacticCaches
140+
- name: build library_search cache
141+
run: lake build MathlibExtras
143142

144143
- name: upload cache
145144
if: always()

.github/workflows/build.yml.in

+4-5
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ jobs:
5858
run: |
5959
git ls-files 'Mathlib/*.lean' | LC_ALL=C sort | sed 's/\.lean//;s,/,.,g;s/^/import /' > Mathlib.lean
6060

61-
- name: update TacticCaches.lean
61+
- name: update MathlibExtras.lean
6262
run: |
63-
cd Util
64-
git ls-files 'TacticCaches/*.lean' | LC_ALL=C sort | sed 's/\.lean//;s,/,.,g;s/^/import /' > TacticCaches.lean
63+
git ls-files 'MathlibExtras/*.lean' | LC_ALL=C sort | sed 's/\.lean//;s,/,.,g;s/^/import /' > MathlibExtras.lean
6564

6665
- name: update Mathlib/Tactic.lean
6766
run: |
@@ -118,8 +117,8 @@ jobs:
118117
run: |
119118
! grep "stdout:" stdout.log
120119

121-
- name: build tactic caches
122-
run: lake build TacticCaches
120+
- name: build library_search cache
121+
run: lake build MathlibExtras
123122

124123
- name: upload cache
125124
if: always()

.github/workflows/build_fork.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,9 @@ jobs:
7676
run: |
7777
git ls-files 'Mathlib/*.lean' | LC_ALL=C sort | sed 's/\.lean//;s,/,.,g;s/^/import /' > Mathlib.lean
7878
79-
- name: update TacticCaches.lean
79+
- name: update MathlibExtras.lean
8080
run: |
81-
cd Util
82-
git ls-files 'TacticCaches/*.lean' | LC_ALL=C sort | sed 's/\.lean//;s,/,.,g;s/^/import /' > TacticCaches.lean
81+
git ls-files 'MathlibExtras/*.lean' | LC_ALL=C sort | sed 's/\.lean//;s,/,.,g;s/^/import /' > MathlibExtras.lean
8382
8483
- name: update Mathlib/Tactic.lean
8584
run: |
@@ -136,8 +135,8 @@ jobs:
136135
run: |
137136
! grep "stdout:" stdout.log
138137
139-
- name: build tactic caches
140-
run: lake build TacticCaches
138+
- name: build library_search cache
139+
run: lake build MathlibExtras
141140

142141
- name: upload cache
143142
if: always()

Util/Cache/Hashing.lean Cache/Hashing.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ partial def getFileHash (filePath : FilePath) : HashM $ Option UInt64 := do
103103
depsMap := stt.depsMap.insert filePath fileImports })
104104

105105
/-- Files to start hashing from. -/
106-
def roots : Array FilePath := #["Mathlib.lean", "Util/TacticCaches.lean"]
106+
def roots : Array FilePath := #["Mathlib.lean", "MathlibExtras.lean"]
107107

108108
/-- Main API to retrieve the hashes of the Lean files -/
109109
def getHashMemo : IO HashMemo :=

Util/Cache/IO.lean Cache/IO.lean

+4-7
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ def mathlibDepPath : FilePath :=
6969
-- TODO this should be generated automatically from the information in `lakefile.lean`.
7070
def getPackageDirs : IO PackageDirs := return .ofList [
7171
("Mathlib", if ← isMathlibRoot then "." else mathlibDepPath),
72-
-- Note that this prevents downstream projects from using a top-level `Util` directory.
73-
-- I'm not sure a good way around this for now, but hopefully it will be made obsolete
74-
-- by a new `cache` before it affects anyone.
75-
("Util", if ← isMathlibRoot then "." else mathlibDepPath),
72+
("MathlibExtras", if ← isMathlibRoot then "." else mathlibDepPath),
7673
("Aesop", LAKEPACKAGESDIR / "aesop"),
7774
("Std", LAKEPACKAGESDIR / "std"),
7875
("ProofWidgets", LAKEPACKAGESDIR / "proofwidgets"),
@@ -85,7 +82,7 @@ def getPackageDir (path : FilePath) : IO FilePath :=
8582
match path.withExtension "" |>.components.head? with
8683
| none => throw $ IO.userError "Can't find package directory for empty path"
8784
| some pkg => match pkgDirs.find? pkg with
88-
| none => throw $ IO.userError s!"Unknown package directory for {pkg}, {path}"
85+
| none => throw $ IO.userError s!"Unknown package directory for {pkg}"
8986
| some path => return path
9087

9188
/-- Runs a terminal command and retrieves its output, passing the lines to `processLine` -/
@@ -209,8 +206,8 @@ def isPathFromMathlib (path : FilePath) : Bool :=
209206
match path.components with
210207
| "Mathlib" :: _ => true
211208
| ["Mathlib.lean"] => true
212-
| "Util" :: "TacticCaches" :: _ => true
213-
| ["Util", "TacticCaches.lean"] => true
209+
| "MathlibExtras" :: _ => true
210+
| ["MathlibExtras.lean"] => true
214211
| _ => false
215212

216213
/-- Decompresses build files into their respective folders -/
File renamed without changes.

Util/Cache/Requests.lean Cache/Requests.lean

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ section Get
2828

2929
/-- Formats the config file for `curl`, containing the list of files to be downloaded -/
3030
def mkGetConfigContent (hashMap : IO.HashMap) : IO String := do
31-
-- We sort the list so that the large files in `Util/TacticCaches` are requested first.
32-
hashMap.toArray.qsort (fun ⟨p₁, _⟩ ⟨_, _⟩ => p₁.components.take 2 = ["Util", "TacticCaches"])
31+
-- We sort the list so that the large files in `MathlibExtras` are requested first.
32+
hashMap.toArray.qsort (fun ⟨p₁, _⟩ ⟨_, _⟩ => p₁.components.head? = "MathlibExtras")
3333
|>.foldlM (init := "") fun acc ⟨_, hash⟩ => do
3434
let fileName := hash.asTarGz
3535
-- Below we use `String.quote`, which is intended for quoting for use in Lean code

Mathlib/Tactic/LibrarySearch.lean

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def processLemma (name : Name) (constInfo : ConstantInfo) :
6767
/-- Insert a lemma into the discrimination tree. -/
6868
-- Recall that `apply?` caches the discrimination tree on disk.
6969
-- If you are modifying this file, you will probably want to delete
70-
-- `build/lib/Util/TacticCaches/LibrarySearch.extra`
70+
-- `build/lib/MathlibExtras/LibrarySearch.extra`
7171
-- so that the cache is rebuilt.
7272
def addLemma (name : Name) (constInfo : ConstantInfo)
7373
(lemmas : DiscrTree (Name × DeclMod) true) : MetaM (DiscrTree (Name × DeclMod) true) := do
@@ -92,9 +92,9 @@ open System (FilePath)
9292

9393
def cachePath : IO FilePath :=
9494
try
95-
return (← findOLean `TacticCaches.LibrarySearch).withExtension "extra"
95+
return (← findOLean `MathlibExtras.LibrarySearch).withExtension "extra"
9696
catch _ =>
97-
return "build" / "lib" / "Util" / "TacticCaches" / "LibrarySearch.extra"
97+
return "build" / "lib" / "MathlibExtras" / "LibrarySearch.extra"
9898

9999
initialize cachedData : CachedData (Name × DeclMod) ← unsafe do
100100
let path ← cachePath

Mathlib/Tactic/Rewrites.lean

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def processLemma (name : Name) (constInfo : ConstantInfo) :
6464
/-- Insert a lemma into the discrimination tree. -/
6565
-- Recall that `rw?` caches the discrimination tree on disk.
6666
-- If you are modifying this file, you will probably want to delete
67-
-- `build/lib/Util/TacticCaches/Rewrites.extra`
67+
-- `build/lib/MathlibExtras/Rewrites.extra`
6868
-- so that the cache is rebuilt.
6969
def addLemma (name : Name) (constInfo : ConstantInfo)
7070
(lemmas : DiscrTree (Name × Bool × Nat) true) : MetaM (DiscrTree (Name × Bool × Nat) true) := do
@@ -89,9 +89,9 @@ open System (FilePath)
8989

9090
def cachePath : IO FilePath :=
9191
try
92-
return (← findOLean `TacticCaches.Rewrites).withExtension "extra"
92+
return (← findOLean `MathlibExtras.Rewrites).withExtension "extra"
9393
catch _ =>
94-
return "build" / "lib" / "Util" / "TacticCaches" / "Rewrites.extra"
94+
return "build" / "lib" / "MathlibExtras" / "Rewrites.extra"
9595

9696
initialize cachedData : CachedData (Name × Bool × Nat) ← unsafe do
9797
let path ← cachePath

MathlibExtras.lean

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import MathlibExtras.LibrarySearch
2+
import MathlibExtras.Rewrites
File renamed without changes.
File renamed without changes.

Util/ImportGraph/Main.lean

-97
This file was deleted.

Util/TacticCaches.lean

-2
This file was deleted.

lakefile.lean

+11-22
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,24 @@ require aesop from git "https://github.com/JLimperg/aesop" @ "master"
3333
require Cli from git "https://github.com/mhuisi/lean4-cli.git" @ "nightly"
3434
require proofwidgets from git "https://github.com/EdAyers/ProofWidgets4" @ "v0.0.11"
3535

36-
lean_lib Archive where
37-
roots := #[`Archive]
38-
39-
lean_lib Counterexamples where
40-
roots := #[`Counterexamples]
41-
42-
/-!
43-
# Utilities, stored in the `Util` directory.
44-
45-
* `lake exe cache`, providing olean caching
46-
* `lake exe graph`, generating import graphs, as `leanproject import-graph` used to in Lean 3.
47-
* additional caches for tactics, stored in `Util/TacticCaches`.
48-
-/
49-
5036
lean_lib Cache where
5137
moreLeanArgs := moreLeanArgs
5238
roots := #[`Cache]
53-
srcDir := "Util"
5439

5540
lean_exe cache where
56-
root := `Util.Cache.Main
41+
root := `Cache.Main
42+
43+
lean_lib MathlibExtras where
44+
roots := #[`MathlibExtras]
45+
46+
lean_lib Archive where
47+
roots := #[`Archive]
48+
49+
lean_lib Counterexamples where
50+
roots := #[`Counterexamples]
5751

5852
lean_lib ImportGraph where
5953
roots := #[`ImportGraph]
60-
srcDir := "Util"
6154

6255
lean_exe graph where
63-
root := `Util.ImportGraph.Main
64-
65-
lean_lib TacticCaches where
66-
roots := #[`TacticCaches]
67-
srcDir := "Util"
56+
root := `ImportGraph.Main

test/LibrarySearch/basic.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Mathlib.Data.Nat.Prime
1414
-- Recall that `apply?` caches the discrimination tree on disk.
1515
-- If you are modifying the way that `apply?` indexes lemmas,
1616
-- while testing you will probably want to delete
17-
-- `build/lib/Util/TacticCaches/LibrarySearch.extra`
17+
-- `build/lib/MathlibExtras/LibrarySearch.extra`
1818
-- so that the cache is rebuilt.
1919

2020
noncomputable section

test/rewrites.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Mathlib.Algebra.Group.Basic
1010
-- Recall that `rw?` caches the discrimination tree on disk.
1111
-- If you are modifying the way that `rewrites` indexes lemmas,
1212
-- while testing you will probably want to delete
13-
-- `build/lib/Util/TacticCaches/Rewrites.extra`
13+
-- `build/lib/MathlibExtras/Rewrites.extra`
1414
-- so that the cache is rebuilt.
1515

1616
/--

0 commit comments

Comments
 (0)