Commit graph

68 commits

Author SHA1 Message Date
Leonardo de Moura
f2a418a7ae chore: smartUnfolding cleanup
We remove dead code, update comments, and add new tests

See #445
2021-09-19 15:29:11 -07:00
Leonardo de Moura
5b0a1c2b2f feat: smart unfolding support for nested match-expressions
See #445
2021-09-19 15:17:56 -07:00
Leonardo de Moura
03f095ccab fix: match + OfNat issue
See https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/simp.20match.20question
2021-08-27 11:48:02 -07:00
Leonardo de Moura
52b52b22ef fix: to do unfold matcher applications that cannot be reduced when smartUnfolding is true
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/How.20to.20WHNF.20without.20exposing.20recursors.3F
2021-08-17 21:32:32 -07:00
Leonardo de Moura
63ad42ba47 refactor: move and generalize reduceProj? 2021-08-10 20:21:04 -07:00
Leonardo de Moura
84b155cfc0 chore: add docstring 2021-08-05 18:12:14 -07:00
Leonardo de Moura
6e1620ca8d refactor: replace IO.Ref with the extern/export hack at MetaM 2021-08-03 11:50:57 -07:00
Leonardo de Moura
bba9353619 fix: make sure isDefEqOffset does not expose kernel nat literals
This issue is similar to a bug where `isDefEqOffset` was exposing
`Nat.add` when processing `HAdd.hAdd`.

Fixes #561
The example at issue #561 is now working, but we may have other places
where raw literals are being accidentally exposed.
2021-08-02 11:27:00 -07:00
Leonardo de Moura
b25bb78e2a feat: improve DiscrTree
Try to improve the performance issue described at #587.

The issue is that Mathlib contains thousands of theorems where the
associated key for the discrimination tree is just
`Key.other`. The indexing is not effective for them. This happens because

1- Lambda expressions are indexed using `Key.other`. The
   discrimination tree mainly focus on the first-order structure.

2- It unfolds reducible constants when inserting and retrieving
   entries. The motivation is that users expect simp theorems to fire
   modulo reducible constants.

Then, we have many theorems such as
```lean
map ?g ∘ map ?f = map (?g ∘ ?f)
```
when we expand the function composition on the left-hand side, we get
```lean
fun (x : List ?α) => map ?g (map ?f x)
```
Which is indexed as `Key.other`.

We should not avoid the `Array`s in the discrimination tree nodes
If the index is working effectively, these arrays are all very small.

In this commit, we try to address the problem by using a different
approach. When processing the root of a pattern, we interrupt
reduction as soon as the we hit something that would be indexed
as `Key.other`. Note that, in Lean 3, the root of a pattern also
receives special treatment.
2021-07-29 16:08:26 -07:00
Leonardo de Moura
8b4cdcfddd chore: fix mutable variable shadowing 2021-05-22 19:24:41 -07:00
Leonardo de Moura
4675817a9e fix: projection of string literals 2021-05-07 14:38:21 -07:00
Leonardo de Moura
5fcd08326f fix: bug at reduceRec 2021-05-07 14:21:37 -07:00
Leonardo de Moura
d9273786c7 chore: remove when and «unless»
They are obsolete.

cc @Kha
2021-03-20 18:52:18 -07:00
Leonardo de Moura
be841a7cad chore: throwError! => throwError, throwErrorAt! => throwErrorAt
@Kha I marked the corresponding methods as `protected`.
I currently can't stand `throw_error`, and I am optimistic about
server highlighting feature you are working on :)
2021-03-11 11:59:45 -08:00
Leonardo de Moura
68143ca8ba chore: trace[...]! ==> trace[...]
@Kha I think this one is a good change, there is no real reason for
using the `!` suffix here.
2021-03-10 18:44:43 -08:00
Leonardo de Moura
08fc25217d chore: cleanup, fix docs 2021-03-07 09:01:54 -08:00
Jan Hrcek
2753822fe7
doc: fix typos 2021-03-07 15:06:02 +01:00
Leonardo de Moura
399af03c7c refactor: move defeq unfolding to reduce, use transform to implement dsimp 2021-02-16 17:41:18 -08:00
Leonardo de Moura
3e65f586cc fix: smart unfolding 2021-02-16 15:39:07 -08:00
Leonardo de Moura
5e0b6a404f chore: naming convention 2021-02-11 15:05:26 -08:00
Leonardo de Moura
83775b08cb fix: whnfCore not expanding delayed assignments 2021-02-05 15:14:12 -08:00
Leonardo de Moura
4dc2a84302 fix: whnfCore
Update function before invoking `reduceMatcher?`
2021-02-05 13:40:39 -08:00
Leonardo de Moura
6c119a1921 chore: use register_builtin_option 2021-01-26 18:24:56 -08:00
Leonardo de Moura
75466a7cf3 chore: cleanup 2021-01-26 16:01:46 -08:00
Leonardo de Moura
0da83dc4ae feat: add unfoldDefinition 2021-01-25 17:18:08 -08:00
Leonardo de Moura
b575087859 fix: unfold class projections when using TransparencyMode.instances 2021-01-25 12:30:26 -08:00
Leonardo de Moura
8bb7cc10ff chore: cleanup 2021-01-25 11:33:48 -08:00
Leonardo de Moura
f53e83b182 feat: add options maxHeartbeats and synthInstance.maxHeartbeats 2021-01-24 17:45:50 -08:00
Leonardo de Moura
51de663e2c fix: crash when using TransparencyMode.instances 2021-01-22 14:17:19 -08:00
Leonardo de Moura
ea0fda39bc chore: Declaration.lean naming convention
`Declaration.lean` was one of the first Lean 4 files, and was still
using an old naming convention.

cc @Kha
2021-01-20 17:07:02 -08:00
Leonardo de Moura
300fcc3321 fix: bug at getStuckMVar? 2021-01-11 06:43:08 -08:00
Leonardo de Moura
b756562d4a feat: simp beta/proj/recursor/matcher 2021-01-01 08:29:21 -08:00
Leonardo de Moura
63ab55289e chore: remove "liftable methods"
The new frontend "auto lifting" feature makes them obsolete.
2020-12-09 15:06:07 -08:00
Leonardo de Moura
72215c7144 feat: add TransparencyMode.instances 2020-11-29 18:12:33 -08:00
Leonardo de Moura
0869f38de4 chore: update structure, class, inductive 2020-11-27 15:09:30 -08:00
Leonardo de Moura
d6f778bec4 refactor: arbitrary without explicit arguments
@Kha I was tired of writing `arbitrary _` :)
There 0 places in the stdlib where the type needs to be provided.
If in the future we need to specify the type we can use
`arbitrary (α := <type>)`
2020-11-25 09:07:38 -08:00
Leonardo de Moura
c305c2691f chore: use := 2020-11-19 07:22:31 -08:00
Leonardo de Moura
c81dbeb53c feat: improve smart unfolding 2020-11-15 17:34:37 -08:00
Leonardo de Moura
f1b88e1304 feat: add option for disabling smart unfolding and fix tests 2020-11-15 17:00:51 -08:00
Leonardo de Moura
f5ba036d8f chore: add support for reducing matchers 2020-11-15 15:07:53 -08:00
Leonardo de Moura
f17e226638 chore: naming convention
Example: `mkNameStr` => `Name.mkStr`

cc @Kha
2020-11-11 10:08:55 -08:00
Leonardo de Moura
2d2d39c78e chore: use mut 2020-11-07 17:32:13 -08:00
Leonardo de Moura
81d6e065e7 chore: adjust files and tests 2020-11-07 17:32:12 -08:00
Leonardo de Moura
7b5f283507 chore: remove Expr.localE constructor
It was used by the old frontend
2020-11-01 09:37:48 -08:00
Leonardo de Moura
13a3215d0d chore: use Subarray combinators 2020-10-28 19:52:59 -07:00
Leonardo de Moura
4ba21ea10c chore: cleanup src/Array/Basic.lean 2020-10-28 19:35:42 -07:00
Leonardo de Moura
5ea49c92bb chore: cleanup 2020-10-27 13:26:21 -07:00
Leonardo de Moura
13c2a8ff51 chore: remove #lang lean4 header 2020-10-25 09:54:07 -07:00
Leonardo de Moura
1495f403a1 chore: use builtin_initialize instead of initialize at src/Lean 2020-10-19 15:17:02 -07:00
Leonardo de Moura
ef18b0ab49 chore: use [builtinInit] 2020-10-19 14:58:38 -07:00