Commit graph

379 commits

Author SHA1 Message Date
Joachim Breitner
ccb8568756
feat: linear-size DecidableEq instance (#10152)
This PR introduces an alternative construction for `DecidableEq`
instances that avoids the quadratic overhead of the default
construction.

The usual construction uses a `match` statement that looks at each pair
of constructors, and thus is necessarily quadratic in size. For
inductive data type with dozens of constructors or more, this quickly
becomes slow to process.

The new construction first compares the constructor tags (using the
`.ctorIdx` introduced in #9951), and handles the case of a differing
constructor tag quickly. If the constructor tags match, it uses the
per-constructor-eliminators (#9952) to create a linear-size instance. It
does so by creating a custom “matcher” for a parallel match on the data
types and the `h : x1.ctorIdx = x2.ctorIdx` assumption; this behaves
(and delaborates) like a normal `match` statement, but is implemented in
a bespoke way. This same-constructor-matcher will be useful for
implementing other instances as well.

The new construction produces less efficient code at the moment, so we
use it only for inductive types with 10 or more constructors by default.
The option `deriving.decEq.linear_construction_threshold` can be used to
adjust the threshold; set it to 0 to always use the new construction.
2025-09-03 06:31:49 +00:00
Kyle Miller
7fa1a8b114
chore: eliminate uses of intros x y z (#9983)
This PR eliminates uses of `intros x y z` (with arguments) and updates
the `intros` docstring to suggest that `intro x y z` should be used
instead. The `intros` tactic is historical, and can be traced all the
way back to Lean 2, when `intro` could only introduce a single
hypothesis. Since 2020, the `intro` tactic has superceded it. The
`intros` tactic (without arguments) is currently still useful.
2025-08-19 06:09:13 +00:00
Paul Reichert
6e538c35dd
refactor: migrate all usages of old slice notation (#9000)
This PR replaces all usages of `[:]` slice notation in `src` with the
new `[...]` notation in production code, tests and comments. The
underlying implementation of the `Subarray` functions stays the same.

Notation cheat sheet:

* `*...*` is the doubly-unbounded range.
* `*...a` or `*...<a` contains all elements that are less than `a`.
* `*...=a` contains all elements that are less than or equal to `a`.
* `a...*` contains all elements that are greater than or equal to `a`.
* `a...b` or `a...<b` contains all elements that are greater than or
equal to `a` and less than `b`.
* `a...=b` contains all elements that are greater than or equal to `a`
and less than or equal to `b`.
* `a<...*` contains all elements that are greater than `a`.
* `a<...b` or `a<...<b` contains all elements that are greater than `a`
and less than `b`.
* `a<...=b` contains all elements that are greater than `a` and less
than or equal to `b`.

Benchmarks have shown that importing the iterator-backed parts of the
polymorphic slice library in `Init` impacts build performance. This PR
avoids this problem by separating those parts of the library that do not
rely on iterators from those those that do. Whereever the new slice
notation is used, only the iterator-independent files are imported.
2025-06-27 18:52:07 +00:00
Rob23oba
7cca594a4a
chore: adjust BEq classes (#7855)
This PR moves `ReflBEq` to `Init.Core` and changes `LawfulBEq` to extend
`ReflBEq`.

**BREAKING CHANGES:**
- The `refl` field of `ReflBEq` has been renamed to `rfl` to match
`LawfulBEq`
- `LawfulBEq` extends `ReflBEq`, so in particular `LawfulBEq.rfl` is no
longer valid
2025-04-16 13:24:23 +00:00
Sebastian Ullrich
f7e207a824
chore: remove save tactic (#7047)
This PR removes the `save` and `checkpoint` tactics that have been
superseded by incremental elaboration
2025-02-12 09:19:30 +00:00
Kim Morrison
5b1c6b558a
feat: align take/drop/extract across List/Array/Vector (#6860)
This PR makes `take`/`drop`/`extract` available for each of
`List`/`Array`/`Vector`. The simp normal forms differ, however: in
`List`, we simplify `extract` to `take+drop`, while in `Array` and
`Vector` we simplify `take` and `drop` to `extract`. We also provide
`Array/Vector.shrink`, which simplifies to `take`, but is implemented by
repeatedly popping. Verification lemmas for `Array/Vector.extract` to
follow in a subsequent PR.
2025-01-30 01:24:25 +00:00
Kim Morrison
71122696a1
feat: rename Array.shrink to take, and relate to List.take (#5796) 2024-10-21 23:35:32 +00:00
euprunin
4b47a10bef
chore: fix spelling mistakes in tests (#5439)
Co-authored-by: euprunin <euprunin@users.noreply.github.com>
2024-09-24 03:22:53 +00:00
Joe Hendrix
01104cc81e
chore: bool and prop lemmas for Mathlib compatibility and improved confluence (#3508)
This adds a number of lemmas for simplification of `Bool` and `Prop`
terms. It pulls lemmas from Mathlib and adds additional lemmas where
confluence or consistency suggested they are needed.

It has been tested against Mathlib using some automated test
infrastructure.

That testing module is not yet included in this PR, but will be included
as part of this.

Note. There are currently some comments saying the origin of the simp
rule. These will be removed prior to merging, but are added to clarify
where the rule came from during review.

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-03-04 23:56:30 +00:00
Joachim Breitner
b2d668c340
perf: Use flat ByteArrays in Trie (#2529) 2023-09-20 13:22:37 +02:00
Sebastian Ullrich
451ccec154 fix: save when used as last tactic 2023-06-07 14:29:45 -07:00
Leonardo de Moura
1ec535d523 test: alternative encoding experiment for decEq and noConfusion 2022-11-23 18:46:10 -08:00
Mario Carneiro
dd5948d641 chore: snake-case attributes (part 1) 2022-10-19 09:28:08 -07:00
Leonardo de Moura
18ccc01cf1 feat: add inferType for LCNF 2022-08-09 17:33:24 -07:00
Leonardo de Moura
9e00cbd6d8 feat: add LCNFTypes.lean 2022-08-09 15:47:58 -07:00
Leonardo de Moura
fbb858a32c chore: missing case 2022-08-08 23:40:44 -07:00
Leonardo de Moura
1952633a75 chore: compiler simple type experiment 2022-08-08 20:18:46 -07:00
Leonardo de Moura
a82abee1b2 feat: sum of monomials normal form by reflection 2022-04-22 18:51:48 -07:00
Leonardo de Moura
d8ad343885 test: add Expr.eq_of_toPoly_eq 2022-04-20 23:04:29 -07:00
Leonardo de Moura
6bdeb6c9cb test: add support for sub as som.lean 2022-04-20 22:59:55 -07:00
Leonardo de Moura
6e09dfae1e test: simplify sum of monomials 2022-04-20 22:31:52 -07:00
Leonardo de Moura
14bfe57ba8 test: sum of monomials by reflection 2022-04-20 19:19:50 -07:00
Leonardo de Moura
e69e469a37 chore: update test 2022-04-18 11:56:46 -07:00
Leonardo de Moura
e6aee1e463 feat: make sure cases and induction alternatives are processed using the order provided by the user
Motivation: improve the effectiveness of the `save` and `checkpoint` tactics.
2022-04-18 11:45:36 -07:00
Leonardo de Moura
5599cefe2e feat: add sleep tactic for debugging purposes 2022-04-18 09:53:45 -07:00
Leonardo de Moura
607a590238 test: pge example 2022-04-17 15:17:28 -07:00
Leonardo de Moura
2f8d2e8a12 feat: add procedure for solving subgoals generated by mkSplitterProof 2021-08-24 20:23:13 -07:00
Leonardo de Moura
49520aa2ee feat: generate conditional equation theorems for match expressions 2021-08-19 19:33:31 -07:00
Leonardo de Moura
3c519887d1 chore: generate error message when MatchEqs fail
TODO: we currently do not generate equation theorems
for `match` expressions using array literals.
2021-08-19 17:04:52 -07:00
Leonardo de Moura
a6529a795b feat: add casesOnStuckLHS 2021-08-19 11:22:13 -07:00
Leonardo de Moura
45d3b85d5a refactor: cleanup MatchEqs and simplify SplitIf 2021-08-18 18:34:34 -07:00
Leonardo de Moura
83eaa47e0a chore: move MatchEqs 2021-08-17 21:32:32 -07:00
Daniel Selsam
89364b802b feat: top-down heuristic delaboration 2021-08-03 09:13:18 +02:00
Wojciech Nawrocki
7374b9ba45 chore: update webserver demo 2021-07-15 21:57:55 +02:00
Leonardo de Moura
fb9c1913d7 feat: prototype for equality theorem generator for auxiliary match functions 2021-05-31 18:52:22 -07:00
Daniel Fabian
93bb94bfea test: update playground for Hashable
due to new code generation, adjust the playground code
2021-03-30 13:36:52 -07:00
Daniel Fabian
fee3390dd1 feat: add Hashable deriving
add support for the `Hashable` deriving by combining structural
hashes over fields
2021-03-30 13:36:52 -07:00
Leonardo de Moura
48b855bfe5 chore: fix tests 2021-03-10 18:45:22 -08:00
Leonardo de Moura
0068732751 test: benchmarks for simp 2021-03-09 15:09:51 -08:00
Leonardo de Moura
4c82f5c688 test: perf experiments 2021-03-09 13:42:47 -08:00
Leonardo de Moura
b26c7087fe chore: increase test size 2021-03-04 17:27:24 -08:00
Leonardo de Moura
2b78de650a test: experiment 2021-03-04 14:48:49 -08:00
Leonardo de Moura
5626b537c7 chore: move nondet to Std/Control/Nondet.lean 2021-03-02 07:57:25 -08:00
Leonardo de Moura
533731d61e chore: fix nondet 2021-03-02 07:38:44 -08:00
Leonardo de Moura
d71aab5dc4 fix: allow bigger ctor objects
`IR/Checker.lean` is now also checking the maximum number of fields
and scalar size
2021-01-29 18:23:38 -08:00
Leonardo de Moura
a0ed2d1738 chore: update tests 2021-01-27 15:17:51 -08:00
Sebastian Ullrich
8a02dfec4f feat: subsume variables under variable
/cc @leodemoura
2021-01-22 14:36:05 +01:00
Leonardo de Moura
7ae861f6bd test: simplify 2021-01-21 18:32:23 -08:00
Leonardo de Moura
d6eb5a9ff2 feat: generate sizeOf equality lemmas for constructors
TODO: support for nested inductive types.
2021-01-21 17:44:15 -08:00
Leonardo de Moura
0bce549d92 test: remove code that is being generated automatically 2021-01-21 10:35:22 -08:00