Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: asynchronous kernel checking #6368

Draft
wants to merge 42 commits into
base: kernel-env-base
Choose a base branch
from

Conversation

Kha
Copy link
Member

@Kha Kha commented Dec 11, 2024

This PR implements executing kernel checking in parallel to elaboration, which is a prerequisite for parallelizing elaboration itself.

Stacked on #6214

@Kha Kha added the changelog-language Language features, tactics, and metaprograms label Dec 11, 2024
@Kha Kha force-pushed the async-tc branch 6 times, most recently from 06a6e24 to b44a2ff Compare December 13, 2024 09:36
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Dec 13, 2024
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Dec 13, 2024

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase b862e2d25163584322bcca54e5e56d671da1f258 --onto 48be424eaa2ae06972e9cfec4d355906b532204d. (2024-12-13 09:54:31)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase b862e2d25163584322bcca54e5e56d671da1f258 --onto fe45ddd6105078a0a3bd855e5d94673e794f6b88. (2024-12-28 17:23:57)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase b862e2d25163584322bcca54e5e56d671da1f258 --onto 24a8561ec4e302f4e0cba07632fddacd6f6e0323. (2024-12-30 11:43:03)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 48eb3084a0e0e15d6c22287d1c17072cbe9f1541 --onto dd6445515ddc71826c76b8020fe9e030579b432b. (2025-01-09 17:13:04)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase c7939cfb03c78820b069ba9c931900d44b11f58e --onto d2c4471cfa4611977bf4927b5cd849df1a4272b7. (2025-01-13 10:12:15)

@Kha Kha changed the base branch from master to kernel-env-base December 28, 2024 16:59
@Kha
Copy link
Member Author

Kha commented Dec 28, 2024

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 9b36754.
The entire run failed.
Found no significant differences.

@Kha
Copy link
Member Author

Kha commented Dec 30, 2024

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit ed17ab3.
There were significant changes against commit 4600bb1:

  Benchmark                  Metric                    Change
  ========================================================================
- big_do                     branches                    4.0%    (329.8 σ)
- big_do                     instructions                1.1%     (63.6 σ)
- big_do                     maxrss                      5.8%    (124.1 σ)
+ big_omega.lean             branch-misses             -64.9%   (-143.9 σ)
+ big_omega.lean             branches                  -70.2%  (-4059.2 σ)
+ big_omega.lean             instructions              -71.1%  (-3756.4 σ)
+ big_omega.lean             maxrss                    -54.7%   (-105.7 σ)
+ big_omega.lean             task-clock                -74.6%   (-347.4 σ)
+ big_omega.lean             wall-clock                -74.8%   (-327.5 σ)
+ big_omega.lean MT          branch-misses             -69.1%   (-546.0 σ)
+ big_omega.lean MT          branches                  -72.4%  (-9861.4 σ)
+ big_omega.lean MT          instructions              -72.9% (-13535.0 σ)
+ big_omega.lean MT          maxrss                    -66.4%    (-47.5 σ)
+ big_omega.lean MT          task-clock                -80.9%   (-135.4 σ)
+ big_omega.lean MT          wall-clock                -80.9%   (-135.2 σ)
+ binarytrees                instructions               -8.4%  (-3211.4 σ)
+ binarytrees.st             instructions               -8.4%  (-5177.1 σ)
- bv_decide_mul              branches                    1.5%    (382.5 σ)
+ bv_decide_mul              instructions               -1.2%   (-215.5 σ)
- bv_decide_mul              maxrss                      1.6%     (42.3 σ)
+ bv_decide_realworld        branches                   -1.5%   (-178.8 σ)
+ bv_decide_realworld        instructions               -3.9%   (-529.8 σ)
- bv_decide_realworld        maxrss                      4.1%     (15.4 σ)
+ bv_decide_realworld        task-clock                 -1.8%    (-11.5 σ)
+ bv_decide_realworld        wall-clock                 -2.1%    (-15.1 σ)
+ const_fold                 instructions               -3.5%    (-82.7 σ)
+ deriv                      instructions               -1.9%    (-45.7 σ)
+ ilean roundtrip            instructions               -3.3%   (-500.2 σ)
- import Lean                branches                  340.3%   (6011.9 σ)
- import Lean                instructions              238.0%   (3468.3 σ)
- import Lean                maxrss                      2.9%     (30.2 σ)
- import Lean                task-clock                 84.4%     (17.1 σ)
- import Lean                wall-clock                 84.1%     (17.1 σ)
- language server startup    branches                   50.5%     (88.1 σ)
- language server startup    instructions               38.5%     (61.2 σ)
- language server startup    wall-clock                 19.1%     (14.3 σ)
- liasolver                  instructions                3.5%   (1661.0 σ)
+ liasolver                  maxrss                     -1.4%    (-37.9 σ)
- libleanshared.so           binary size                 3.9%
+ nat_repr                   instructions               -5.0%  (-1756.3 σ)
+ parser                     instructions               -4.4%  (-1586.4 σ)
+ parser                     maxrss                     -1.4%    (-37.9 σ)
+ qsort                      instructions               -4.0%  (-1866.2 σ)
+ qsort                      maxrss                     -1.4%    (-16.6 σ)
- rbmap                      instructions                1.5%    (184.0 σ)
+ rbmap_1                    instructions               -1.8%   (-102.6 σ)
+ rbmap_fbip                 instructions              -10.3%   (-708.9 σ)
+ rbmap_library              instructions               -1.9%   (-171.1 σ)
- reduceMatch                instructions               17.1%    (675.1 σ)
- reduceMatch                maxrss                     19.8%    (820.9 σ)
- reduceMatch                task-clock                 12.8%     (14.3 σ)
- reduceMatch                wall-clock                 12.4%     (12.6 σ)
- simp_arith1                branch-misses               3.6%     (12.7 σ)
- simp_arith1                branches                  129.5%   (4425.6 σ)
- simp_arith1                instructions               84.0%   (2749.9 σ)
- simp_arith1                maxrss                      3.6%     (64.0 σ)
- simp_arith1                task-clock                 43.7%     (66.8 σ)
- simp_arith1                wall-clock                 43.3%     (55.9 σ)
- stdlib                     attribute application     199.1%     (90.3 σ)
- stdlib                     dsimp                      13.6%     (20.7 σ)
- stdlib                     fix level params           10.8%     (21.2 σ)
- stdlib                     instructions               13.0%   (4005.3 σ)
- stdlib                     maxrss                     39.4%    (163.9 σ)
- stdlib                     process pre-definitions   162.7%    (292.1 σ)
- stdlib                     share common exprs         12.5%    (131.1 σ)
- stdlib                     tactic execution           25.2%    (338.6 σ)
- stdlib                     task-clock                 16.7%   (1478.4 σ)
- stdlib                     type checking              38.8%     (56.0 σ)
- stdlib                     wall-clock                 14.9%     (77.2 σ)
- stdlib size                bytes .olean                2.7%
- stdlib size                lines                       2.3%
- stdlib size                lines C                     1.4%
- stdlib size                max dynamic symbols         1.4%
- tests/bench/ interpreted   instructions                3.1%    (515.5 σ)
- tests/bench/ interpreted   maxrss                      3.6%     (11.5 σ)
- tests/bench/ interpreted   task-clock                 32.8%     (35.8 σ)
- tests/bench/ interpreted   wall-clock                 12.2%     (21.4 σ)
- tests/compiler             sum binary sizes            4.7%
+ unionfind                  instructions               -8.2%  (-2666.8 σ)
+ unionfind                  task-clock                -11.6%    (-20.6 σ)
+ unionfind                  wall-clock                -11.6%    (-20.6 σ)
- workspaceSymbols           instructions                1.7%   (2541.3 σ)
- workspaceSymbols           maxrss                      3.5%     (73.0 σ)

@Kha
Copy link
Member Author

Kha commented Jan 4, 2025

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit ed17ab3.
There were significant changes against commit 4600bb1:

  Benchmark                  Metric                    Change
  ========================================================================
- big_do                     branches                    3.5%    (293.7 σ)
- big_do                     instructions                2.7%    (159.7 σ)
- big_do                     maxrss                      5.6%    (119.1 σ)
+ big_omega.lean             branch-misses             -65.2%   (-145.9 σ)
+ big_omega.lean             branches                  -70.4%  (-4095.9 σ)
+ big_omega.lean             instructions              -70.7%  (-3688.5 σ)
+ big_omega.lean             maxrss                    -54.7%   (-105.8 σ)
+ big_omega.lean             task-clock                -73.7%   (-331.5 σ)
+ big_omega.lean             wall-clock                -73.9%   (-312.6 σ)
+ big_omega.lean MT          branch-misses             -69.8%   (-564.6 σ)
+ big_omega.lean MT          branches                  -72.5%  (-9938.0 σ)
+ big_omega.lean MT          instructions              -72.8% (-13467.7 σ)
+ big_omega.lean MT          maxrss                    -66.4%    (-47.4 σ)
+ big_omega.lean MT          task-clock                -80.1%   (-129.2 σ)
+ big_omega.lean MT          wall-clock                -80.2%   (-129.0 σ)
+ binarytrees                task-clock                 -5.3%    (-15.3 σ)
- bv_decide_mul              branches                    1.2%    (317.9 σ)
- bv_decide_mul              maxrss                      1.4%     (38.1 σ)
+ bv_decide_realworld        branches                   -1.5%   (-178.5 σ)
+ bv_decide_realworld        instructions               -2.6%   (-350.6 σ)
- bv_decide_realworld        maxrss                      4.1%     (15.6 σ)
- import Lean                branch-misses               8.4%    (125.8 σ)
- import Lean                branches                  349.4%   (6047.4 σ)
- import Lean                instructions              236.1%   (3460.0 σ)
- import Lean                maxrss                      2.9%     (30.4 σ)
- import Lean                task-clock                 74.1%     (15.9 σ)
- import Lean                wall-clock                 74.0%     (15.9 σ)
- language server startup    branches                   50.2%     (87.7 σ)
- language server startup    instructions               37.2%     (59.7 σ)
- language server startup    wall-clock                 18.6%     (14.0 σ)
- libleanshared.so           binary size                 1.9%
- parser                     instructions                1.0%    (347.7 σ)
- reduceMatch                instructions               17.6%    (691.7 σ)
- reduceMatch                maxrss                     19.8%    (821.3 σ)
- reduceMatch                task-clock                 16.1%     (17.4 σ)
- reduceMatch                wall-clock                 15.7%     (15.5 σ)
- simp_arith1                branch-misses               8.3%     (28.3 σ)
- simp_arith1                branches                  129.8%   (4430.4 σ)
- simp_arith1                instructions               83.1%   (2733.9 σ)
- simp_arith1                maxrss                      3.5%     (62.6 σ)
- simp_arith1                task-clock                 40.1%     (62.9 σ)
- simp_arith1                wall-clock                 39.8%     (52.7 σ)
- stdlib                     attribute application     204.4%     (91.1 σ)
- stdlib                     dsimp                      13.9%     (21.0 σ)
- stdlib                     fix level params           10.3%     (20.4 σ)
- stdlib                     instructions               13.8%   (4219.1 σ)
- stdlib                     maxrss                     39.4%    (163.8 σ)
- stdlib                     process pre-definitions   164.7%    (293.5 σ)
- stdlib                     share common exprs         12.7%    (132.2 σ)
- stdlib                     tactic execution           26.8%    (355.2 σ)
- stdlib                     task-clock                 17.6%   (1544.3 σ)
- stdlib                     type checking              39.0%     (56.2 σ)
- stdlib                     wall-clock                 15.7%     (80.6 σ)
- stdlib size                bytes .olean                2.7%
- stdlib size                lines                       2.3%
- stdlib size                lines C                     1.4%
- stdlib size                max dynamic symbols         1.4%
- tests/bench/ interpreted   instructions                5.5%    (893.1 σ)
- tests/bench/ interpreted   maxrss                      3.5%     (11.2 σ)
- tests/bench/ interpreted   task-clock                 36.9%     (39.0 σ)
- tests/bench/ interpreted   wall-clock                 15.6%     (26.5 σ)
- tests/compiler             sum binary sizes            2.8%
- workspaceSymbols           instructions                5.3%   (7607.4 σ)
- workspaceSymbols           maxrss                      3.5%     (72.3 σ)

Kha and others added 12 commits January 8, 2025 12:56
This PR actually prevents Lake from accidentally picking up other
toolchains installed on the machine.

Fixes regression introduced in leanprover#6176
This PR ensures tactics are evaluated incrementally in the body of
`classical`.
This PR fixes and improves the propagator for forall-expressions in the
`grind` tactic.

---------

Co-authored-by: Kim Morrison <[email protected]>
…anprover#6581)

This PR adds the following configuration options to `Grind.Config`:
`splitIte`, `splitMatch`, and `splitIndPred`.
This PR adds support for creating local E-matching theorems for
universal propositions known to be true. It allows `grind` to
automatically solve examples such as:

```lean
example (b : List α) (p : α → Prop) (h₁ : ∀ a ∈ b, p a) (h₂ : ∃ a ∈ b, ¬p a) : False := by
  grind
```
…#6584)

This PR adds helper theorems to implement offset constraints in grind.
This PR fixes a bug in the `grind` canonicalizer.
This PR continues aligning `List/Array/Vector` lemmas, finishing up
lemmas about `map`.
This PR continues aligning `List/Array` lemmas, finishing `filter` and
`filterMap`.
This PR improves the `grind` canonicalizer diagnostics.

---------

Co-authored-by: Kim Morrison <[email protected]>
This PR adds less-than and less-than-or-equal-to relations to `UInt32`,
consistent with the other `UIntN` types.
This PR implements `Std.Net.Addr` which contains structures around IP
and socket addresses.

While we could implement our own parser instead of going through the
`addr_in`/`addr_in6` route we will need to implement these conversions
to make proper system calls anyway. Hence this is likely the approach
with the least amount of non trivial code overall. The only thing I am
uncertain about is whether `ofString` should return `Option` or
`Except`, unfortunately `libuv` doesn't hand out error messages on IP
parsing.
alexkeizer and others added 22 commits January 10, 2025 02:31
This PR adds a `toFin` and `msb` lemma for unsigned bitvector division.
We *don't* have `toInt_udiv`, since the only truly general statement we
can make does no better than unfolding the definition, and it's not
uncontroversially clear how to unfold `toInt` (see
`toInt_eq_msb_cond`/`toInt_eq_toNat_cond`/`toInt_eq_toNat_bmod` for a
few options currently provided). Instead, we do have `toInt_udiv_of_msb`
that's able to provide a more meaningful rewrite given an extra
side-condition (that `x.msb = false`).

This PR also upstreams a minor `Nat` theorem (`Nat.div_le_div_left`)
needed for the above from Mathlib.

---------

Co-authored-by: Kim Morrison <[email protected]>
… types (leanprover#6587)

This PR adds decidable instances for the `LE` and `LT` instances for the
`Offset` types defined in `Std.Time`.
…nprover#6347)

This PR adds `BitVec.toNat_rotateLeft` and `BitVec.toNat_rotateLeft`.

---------

Co-authored-by: Kim Morrison <[email protected]>
This PR adds a `toFin` and `msb` lemma for unsigned bitvector modulus.
Similar to leanprover#6402, we don't provide a general `toInt_umod` lemmas, but
instead choose to provide more specialized rewrites, with extra
side-conditions.

---------

Co-authored-by: Kim Morrison <[email protected]>
…prover#6599)

The FFI description didn't mention Int or signed integers.

This PR adds `Int` and signed integers to the FFI document.
Users have requested toolchain tags on `lean4-cli`, so let's add it to
the release checklist to make sure these get added regularly.

Previously, `lean4-cli` has used more complicated tags, but going
forward we're going to just use the simple `v4.16.0` style tags, with no
repository-specific versioning.

---------

Co-authored-by: Markus Himmel <[email protected]>
This PR fixes a bug in the pattern selection in the `grind`.
This PR adds support for case-splitting on `<->` (and `@Eq Prop`) in the
`grind` tactic.
This PR fixes a bug in the `simp_arith` tactic. See new test.
This PR improves the case-split heuristic used in grind, prioritizing
case-splits with fewer cases.
This PR fixes a bug in the `grind` core module responsible for merging
equivalence classes and propagating constraints.
This PR fixes one of the sanity check tests used in `grind`.
This PR adds lemmas about `Array.append`, improving alignment with the
`List` API.
This PR improves the case split heuristic used in the `grind` tactic,
ensuring it now avoids unnecessary case-splits on `Iff`.
This PR improves the usability of the `[grind =]` attribute by
automatically handling
forbidden pattern symbols. For example, consider the following theorem
tagged with this attribute:
```
getLast?_eq_some_iff {xs : List α} {a : α} : xs.getLast? = some a ↔ ∃ ys, xs = ys ++ [a]
```
Here, the selected pattern is `xs.getLast? = some a`, but `Eq` is a
forbidden pattern symbol.
Instead of producing an error, this function converts the pattern into a
multi-pattern,
allowing the attribute to be used conveniently.
This PR allows the dot ident notation to resolve to the current
definition, or to any of the other definitions in the same mutual block.
Existing code that uses dot ident notation may need to have `nonrec`
added if the ident has the same name as the definition.

Closes leanprover#6601
)

This PR implements support for offset constraints in the `grind` tactic.
Several features are still missing, such as constraint propagation and
support for offset equalities, but `grind` can already solve examples
like the following:

```lean
example (a b c : Nat) : a ≤ b → b + 2 ≤ c → a + 1 ≤ c := by
  grind
example (a b c : Nat) : a ≤ b → b ≤ c → a ≤ c := by
  grind
example (a b c : Nat) : a + 1 ≤ b → b + 1 ≤ c → a + 2 ≤ c := by
  grind
example (a b c : Nat) : a + 1 ≤ b → b + 1 ≤ c → a + 1 ≤ c := by
  grind
example (a b c : Nat) : a + 1 ≤ b → b ≤ c + 2 → a ≤ c + 1 := by
  grind
example (a b c : Nat) : a + 2 ≤ b → b ≤ c + 2 → a ≤ c := by
  grind
```

---------

Co-authored-by: Kim Morrison <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-language Language features, tactics, and metaprograms toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.