Skip to content

Commit 3d72b89

Browse files
committed
chore: merge main
1 parent ce7bd25 commit 3d72b89

File tree

118 files changed

+2246
-3425
lines changed

Some content is hidden

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

118 files changed

+2246
-3425
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ jobs:
1818

1919
- id: lean-action
2020
name: build, test, and lint batteries
21-
uses: leanprover/lean-action@v1-beta
21+
uses: leanprover/lean-action@v1
2222
with:
2323
build-args: '-Kwerror'
24-
lint-module: 'Batteries'
2524

2625
- name: Check that all files are imported
2726
run: lake env lean scripts/check_imports.lean

.github/workflows/nightly_detect_failure.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
type: 'stream'
2525
topic: 'Batteries status updates'
2626
content: |
27-
❌ The latest CI for Batteries' [`nightly-testing`](https://github.com/leanprover-community/batteries/tree/nightly-testing) branch has [failed](https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}).
27+
The latest CI for Batteries' [`nightly-testing`](https://github.com/leanprover-community/batteries/tree/nightly-testing) branch has [failed](https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}).
2828
2929
# Whenever `nightly-testing` passes CI,
3030
# push it to `nightly-testing-YYYY-MM-DD` so we have a known good version of Batteries on that nightly release.
@@ -77,13 +77,13 @@ jobs:
7777
}
7878
response = client.get_messages(request)
7979
messages = response['messages']
80-
if not messages or messages[0]['content'] != "✅ The latest CI for Batteries' [`nightly-testing`](https://github.com/leanprover-community/batteries/tree/nightly-testing) branch has succeeded!":
80+
if not messages or messages[0]['content'] != "✅ The latest CI for Batteries' [`nightly-testing`](https://github.com/leanprover-community/batteries/tree/nightly-testing) branch has succeeded!":
8181
# Post the success message
8282
request = {
8383
'type': 'stream',
8484
'to': 'nightly-testing',
8585
'topic': 'Batteries status updates',
86-
'content': "✅ The latest CI for Batteries' [`nightly-testing`](https://github.com/leanprover-community/batteries/tree/nightly-testing) branch has succeeded!"
86+
'content': "✅ The latest CI for Batteries' [`nightly-testing`](https://github.com/leanprover-community/batteries/tree/nightly-testing) branch has succeeded!"
8787
}
8888
result = client.send_message(request)
8989
print(result)

.github/workflows/test_mathlib.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Test Mathlib against a Batteries PR
2+
3+
name: Test Mathlib
4+
5+
on:
6+
workflow_run:
7+
workflows: [ci]
8+
types: [completed]
9+
10+
jobs:
11+
on-success:
12+
runs-on: ubuntu-latest
13+
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' && github.repository == 'leanprover-community/batteries'
14+
steps:
15+
- name: Retrieve information about the original workflow
16+
uses: potiuk/get-workflow-origin@v1_1
17+
id: workflow-info
18+
with:
19+
token: ${{ secrets.GITHUB_TOKEN }}
20+
sourceRunId: ${{ github.event.workflow_run.id }}
21+
22+
- name: Checkout mathlib4 repository
23+
if: steps.workflow-info.outputs.pullRequestNumber != ''
24+
uses: actions/checkout@v4
25+
with:
26+
repository: leanprover-community/mathlib4
27+
token: ${{ secrets.MATHLIB4_BOT }}
28+
ref: master
29+
fetch-depth: 0
30+
31+
- name: install elan
32+
run: |
33+
set -o pipefail
34+
curl -sSfL https://github.com/leanprover/elan/releases/download/v3.0.0/elan-x86_64-unknown-linux-gnu.tar.gz | tar xz
35+
./elan-init -y --default-toolchain none
36+
echo "$HOME/.elan/bin" >> "${GITHUB_PATH}"
37+
38+
- name: Retrieve PR information
39+
if: steps.workflow-info.outputs.pullRequestNumber != ''
40+
id: pr-info
41+
uses: actions/github-script@v6
42+
env:
43+
PR_NUMBER: ${{ steps.workflow-info.outputs.pullRequestNumber }}
44+
with:
45+
script: |
46+
const prNumber = process.env.PR_NUMBER;
47+
const { data: pr } = await github.rest.pulls.get({
48+
owner: context.repo.owner,
49+
repo: context.repo.repo,
50+
pull_number: prNumber
51+
});
52+
core.exportVariable('HEAD_REPO', pr.head.repo.full_name);
53+
core.exportVariable('HEAD_BRANCH', pr.head.ref);
54+
55+
- name: Check if tag exists
56+
if: steps.workflow-info.outputs.pullRequestNumber != ''
57+
id: check_mathlib_tag
58+
env:
59+
PR_NUMBER: ${{ steps.workflow-info.outputs.pullRequestNumber }}
60+
HEAD_REPO: ${{ env.HEAD_REPO }}
61+
HEAD_BRANCH: ${{ env.HEAD_BRANCH }}
62+
run: |
63+
git config user.name "leanprover-community-mathlib4-bot"
64+
git config user.email "[email protected]"
65+
66+
echo "PR info: $HEAD_REPO $HEAD_BRANCH"
67+
68+
BASE=master
69+
echo "Using base tag: $BASE"
70+
71+
EXISTS="$(git ls-remote --heads origin batteries-pr-testing-$PR_NUMBER | wc -l)"
72+
echo "Branch exists: $EXISTS"
73+
if [ "$EXISTS" = "0" ]; then
74+
echo "Branch does not exist, creating it."
75+
git switch -c batteries-pr-testing-$PR_NUMBER "$BASE"
76+
77+
# Use the fork and branch name to modify the lakefile.lean
78+
sed -i "s,require \"leanprover-community\" / \"batteries\" @ git \".\+\",require \"leanprover-community\" / \"batteries\" from git \"https://github.com/$HEAD_REPO\" @ \"$HEAD_BRANCH\",g" lakefile.lean
79+
80+
lake update batteries
81+
git add lakefile.lean lake-manifest.json
82+
git commit -m "Update Batteries branch for testing https://github.com/leanprover-community/batteries/pull/$PR_NUMBER"
83+
else
84+
echo "Branch already exists, merging $BASE and bumping Batteries."
85+
git switch batteries-pr-testing-$PR_NUMBER
86+
git merge "$BASE" --strategy-option ours --no-commit --allow-unrelated-histories
87+
lake update batteries
88+
git add lake-manifest.json
89+
git commit --allow-empty -m "Trigger CI for https://github.com/leanprover-community/batteries/pull/$PR_NUMBER"
90+
fi
91+
92+
- name: Push changes
93+
if: steps.workflow-info.outputs.pullRequestNumber != ''
94+
env:
95+
PR_NUMBER: ${{ steps.workflow-info.outputs.pullRequestNumber }}
96+
run: |
97+
git push origin batteries-pr-testing-$PR_NUMBER

.gitpod.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ image:
44
vscode:
55
extensions:
66
- leanprover.lean4
7+
8+
tasks:
9+
- init: |
10+
elan self update
11+
lake build

Batteries.lean

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Batteries.Classes.BEq
21
import Batteries.Classes.Cast
32
import Batteries.Classes.Order
43
import Batteries.Classes.RatCast
@@ -17,28 +16,26 @@ import Batteries.Data.Array
1716
import Batteries.Data.AssocList
1817
import Batteries.Data.BinaryHeap
1918
import Batteries.Data.BinomialHeap
20-
import Batteries.Data.BitVec
21-
import Batteries.Data.Bool
2219
import Batteries.Data.ByteArray
20+
import Batteries.Data.ByteSubarray
2321
import Batteries.Data.Char
2422
import Batteries.Data.DList
2523
import Batteries.Data.Fin
24+
import Batteries.Data.FloatArray
2625
import Batteries.Data.HashMap
27-
import Batteries.Data.Int
2826
import Batteries.Data.LazyList
2927
import Batteries.Data.List
3028
import Batteries.Data.MLList
3129
import Batteries.Data.Nat
32-
import Batteries.Data.Option
3330
import Batteries.Data.PairingHeap
3431
import Batteries.Data.RBMap
3532
import Batteries.Data.Range
3633
import Batteries.Data.Rat
3734
import Batteries.Data.String
3835
import Batteries.Data.Sum
39-
import Batteries.Data.Thunk
4036
import Batteries.Data.UInt
4137
import Batteries.Data.UnionFind
38+
import Batteries.Data.Vector
4239
import Batteries.Lean.AttributeExtra
4340
import Batteries.Lean.Delaborator
4441
import Batteries.Lean.Except
@@ -59,18 +56,15 @@ import Batteries.Lean.Meta.SavedState
5956
import Batteries.Lean.Meta.Simp
6057
import Batteries.Lean.Meta.UnusedNames
6158
import Batteries.Lean.MonadBacktrack
62-
import Batteries.Lean.Name
6359
import Batteries.Lean.NameMap
6460
import Batteries.Lean.NameMapAttribute
6561
import Batteries.Lean.PersistentHashMap
6662
import Batteries.Lean.PersistentHashSet
6763
import Batteries.Lean.Position
68-
import Batteries.Lean.SMap
6964
import Batteries.Lean.Syntax
7065
import Batteries.Lean.System.IO
7166
import Batteries.Lean.TagAttribute
7267
import Batteries.Lean.Util.EnvSearch
73-
import Batteries.Lean.Util.Path
7468
import Batteries.Linter
7569
import Batteries.Linter.UnnecessarySeqFocus
7670
import Batteries.Linter.UnreachableTactic
@@ -84,6 +78,7 @@ import Batteries.Tactic.Congr
8478
import Batteries.Tactic.Exact
8579
import Batteries.Tactic.Init
8680
import Batteries.Tactic.Instances
81+
import Batteries.Tactic.Lemma
8782
import Batteries.Tactic.Lint
8883
import Batteries.Tactic.Lint.Basic
8984
import Batteries.Tactic.Lint.Frontend
@@ -102,7 +97,6 @@ import Batteries.Tactic.Unreachable
10297
import Batteries.Tactic.Where
10398
import Batteries.Test.Internal.DummyLabelAttr
10499
import Batteries.Util.Cache
105-
import Batteries.Util.CheckTactic
106100
import Batteries.Util.ExtendedBinder
107101
import Batteries.Util.LibraryNote
108102
import Batteries.Util.Pickle

Batteries/Classes/BEq.lean

Lines changed: 0 additions & 18 deletions
This file was deleted.

Batteries/Classes/Order.lean

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ theorem cmp_congr_left (xy : cmp x y = .eq) : cmp x z = cmp y z :=
102102
theorem cmp_congr_left' (xy : cmp x y = .eq) : cmp x = cmp y :=
103103
funext fun _ => cmp_congr_left xy
104104

105-
theorem cmp_congr_right [TransCmp cmp] (yz : cmp y z = .eq) : cmp x y = cmp x z := by
105+
theorem cmp_congr_right (yz : cmp y z = .eq) : cmp x y = cmp x z := by
106106
rw [← Ordering.swap_inj, symm, symm, cmp_congr_left yz]
107107

108108
end TransCmp
@@ -278,11 +278,8 @@ instance [Ord β] [OrientedOrd β] (f : α → β) : OrientedCmp (compareOn f) w
278278
instance [Ord β] [TransOrd β] (f : α → β) : TransCmp (compareOn f) where
279279
le_trans := TransCmp.le_trans (α := β)
280280

281-
-- FIXME: remove after lean4#3882 is merged
282281
theorem _root_.lexOrd_def [Ord α] [Ord β] :
283-
(lexOrd : Ord (α × β)).compare = compareLex (compareOn (·.1)) (compareOn (·.2)) := by
284-
funext a b
285-
simp [lexOrd, compareLex, compareOn]
282+
(lexOrd : Ord (α × β)).compare = compareLex (compareOn (·.1)) (compareOn (·.2)) := rfl
286283

287284
section «non-canonical instances»
288285
-- Note: the following instances seem to cause lean to fail, see:

Batteries/CodeAction/Attr.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright (c) 2023 Mario Carneiro. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Mario Carneiro
55
-/
6-
import Lean.Server.CodeActions
6+
import Lean.Server.CodeActions.Basic
77

88
/-!
99
# Initial setup for code action attributes
@@ -14,7 +14,7 @@ import Lean.Server.CodeActions
1414
* Attribute `@[tactic_code_action]` collects code actions which will be called
1515
on each occurrence of a tactic.
1616
-/
17-
namespace Std.CodeAction
17+
namespace Batteries.CodeAction
1818

1919
open Lean Elab Server Lsp RequestM Snapshots
2020

0 commit comments

Comments
 (0)