Commit graph

6472 commits

Author SHA1 Message Date
Leonardo de Moura
d03f5fe318 feat: add trivial extensible (macro) tactic 2021-03-24 09:50:56 -07:00
Leonardo de Moura
1b7f7e9d39 chore: remove unnecessary annotations 2021-03-23 20:42:59 -07:00
Leonardo de Moura
5742b078af feat: "discriminant refinement" for match-expressions 2021-03-23 20:40:07 -07:00
Leonardo de Moura
5ac7b1232a chore: add workarounds
@Kha It seems the recent parser modifications created some unexpected
problems. I didn't investigate them. I am "lost" in the elaborator and
dependent pattern matching land.

1) We can't write anymore
```
f [1, 2, 3] |>.run' 0 = Except.ok ()
```
We have to use parentheses and the error message is weird :(
```
(f [1, 2, 3] |>.run' 0) = Except.ok ()
```

2) I had to add comments to `macro.lean`, I didn't find a workaround
for one of the rules. BTW, I had to add a bunch of `:term` for fixing
the other rules, and the error messages were counterintuitive.
2021-03-23 18:35:27 -07:00
Leonardo de Moura
1b963862c6 test: add test for former weird error message 2021-03-23 18:16:06 -07:00
Leonardo de Moura
99cd4fa720 feat: refine auto bound implicit locals 2021-03-23 17:33:15 -07:00
Leonardo de Moura
ec409a9bfc fix: fixes #366 2021-03-23 16:02:45 -07:00
Sebastian Ullrich
62ae39e62b fix: pp.all should not turn off pp.binder_types 2021-03-23 19:45:41 +01:00
Leonardo de Moura
81e6181488 test: add another test 2021-03-22 21:21:14 -07:00
Leonardo de Moura
650c6df380 feat: try other variables after failure 2021-03-22 21:02:26 -07:00
Sebastian Ullrich
cd4cd581be feat: make infix non-associative 2021-03-22 16:33:37 +01:00
Sebastian Ullrich
bbf6c717fc feat: introduce arg precedence 2021-03-22 16:33:37 +01:00
Leonardo de Moura
3749213e08 fix: missing whnf at Unify.unify 2021-03-21 22:38:46 -07:00
Leonardo de Moura
2fd0b8c663 feat: contradiction catches empty inductive types 2021-03-21 21:48:43 -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
9a5f239513 refactor: remove Monad Option and Alternative Option
We should use `OptionM` instead.
`Option` still implements `Functor` and `OrElse`.

cc @Kha
2021-03-20 18:25:25 -07:00
Sebastian Ullrich
83ecff44c6 test: make infoTree an output test 2021-03-20 08:28:18 -07:00
Sebastian Ullrich
c0af90022e feat: term info at #print 2021-03-20 08:28:18 -07:00
Sebastian Ullrich
62891a1b0c feat: trace.Elab.info 2021-03-20 08:28:18 -07:00
Leonardo de Moura
86a204d8a1 feat: add simp_all tactic
cc @Kha
2021-03-19 22:34:35 -07:00
Leonardo de Moura
d70740fef2 fix: location notation and simp 2021-03-19 19:54:22 -07:00
Leonardo de Moura
03e3a1cc6b chore: remove hack
It produces weird error messages in some examples, and it will be
obsolete after the new precedence feature.
2021-03-19 11:09:18 -07:00
Sebastian Ullrich
54405c4543 fix: automatically wrap many/sepBy items in null nodes where necessary 2021-03-19 15:15:55 +01:00
Leonardo de Moura
f73615c3d2 fix: nontermination 2021-03-18 14:23:03 -07:00
Leonardo de Moura
1af02dcaca feat: allow users to mark definitions with [simp]
cc @JasonGross @Kha
2021-03-17 19:11:55 -07:00
Leonardo de Moura
205b42a397 feat: proper syntax for configuring simp 2021-03-17 16:37:04 -07:00
Leonardo de Moura
5eda786f6e feat: use False.elim when simplifying local declarations that rewrite to False 2021-03-17 15:30:54 -07:00
Sebastian Ullrich
f4c3d068ae feat: uniform "unsolved case" positions with fullRange
/cc @leodemoura
2021-03-17 12:45:15 +01:00
Sebastian Ullrich
0d86ebe5eb chore: remove volatile cases from test 2021-03-17 12:32:25 +01:00
pcpthm
419a6190e8 fix: bitwise shift overflow of UInt types
It is an undefined behavior in C when the right operand of a shift operation exceeds the bit-width of the left operand.
We define the shift operation to be `x << (y % B)` where `B` is the bit-width of the left operand.
2021-03-17 10:08:02 +01:00
Leonardo de Moura
dd4fb3b71b chore: improve error message
see #346
2021-03-16 20:42:38 -07:00
Leonardo de Moura
08f87752ee fix: closes #346 2021-03-16 18:55:46 -07:00
Leonardo de Moura
60a1b828ad fix: fixes #348 2021-03-16 17:50:40 -07:00
Leonardo de Moura
1fd8089d19 fix: register new metavariables created when applying default instance
closes #353
2021-03-16 17:31:51 -07:00
Leonardo de Moura
c37d961fc3 chore: make sure both alternatives use throwError 2021-03-16 17:20:00 -07:00
Leonardo de Moura
7dc6721fea fix: missing pushScope and popScope 2021-03-16 16:42:45 -07:00
Leonardo de Moura
89797c4485 chore: improve congrDefault
We don't need `congrMatch` anymore.
2021-03-16 15:59:11 -07:00
Leonardo de Moura
8227d3afcd feat: support for simplifying match discriminants 2021-03-16 15:51:36 -07:00
Leonardo de Moura
ea91317f1a fix: avoid nontermination due to respecialization 2021-03-15 19:12:57 -07:00
Leonardo de Moura
cc0712fc82 feat: add support for offset terms at DiscrTree 2021-03-14 08:23:44 -07:00
Sebastian Ullrich
75a97fad94 feat: nicer token parse errors 2021-03-14 08:23:32 -07:00
Sebastian Ullrich
9f21d6fd64 fix: preserve token parse errors 2021-03-14 08:23:32 -07:00
Leonardo de Moura
e04e9ff87e feat: extend anonymous ctor notation 2021-03-13 17:11:37 -08:00
Sebastian Ullrich
d35fc280d2 refactor: further refactor Lean.Elab.Syntax 2021-03-13 14:47:59 +01:00
Sebastian Ullrich
00a0db4231 fix: unexpanders should inherit scopedness 2021-03-13 13:20:12 +01:00
Leonardo de Moura
5c24906c60 fix: Delaborator for constants
@Kha Could you please take a look at the fix?
This is an example posted by @JasonGross on Zulip.
2021-03-12 19:51:27 -08:00
Leonardo de Moura
fb40b5e80d chore: fix test 2021-03-12 18:07:58 -08:00
Leonardo de Moura
50fd39db89 fix: bug at allGoals 2021-03-12 17:48:33 -08:00
Leonardo de Moura
7627458aac chore: fix tests
We are not using the `!` suffix anymore for keywords.
2021-03-12 15:10:50 -08:00
Leonardo de Moura
df994fd16f fix: add checkColGe to matchAlt
@Kha this is a fix for the example that @gebner posted on Zulip.
There are other possible workarounds, but I think this one is
"intuitive".

Here is the problem description and workaround.
We currently use the `withPosition` combinator at `matchAlts`. The
original motivation was nested `match`-expressions without
parenthesis.
We also have the `checkColGt` in the application parser.

Thus, `frob 5` is not parsed as an application. That is, the term
parser after the `then` keyword stops at `frob`.
Then, we get the weird "expected 'else'" error message at `5` :)

In this commit, I add a `checkColGe` check at the beginning of each
alternative right-hand-side.

The effect on the stdlib was minimal. It basically affected old code
that used the Lean 3 workaround for partial functions
```
partial def f : N -> N | i =>
  ...
```
In Lean 4, we can use the more natural
```
partial def f (i : N) : N :=
...
```
or
```
partial def f : N -> N := fun i =>
...
```

It also affected code such as
```
instance : Repr String.Iterator where
  reprPrec | ⟨s, pos⟩, prec =>
    Repr.addAppParen ("String.Iterator.mk " ++ reprArg s ++ " " ++ reprArg pos) prec
```
This is a workaround for a missing feature. We really wanted to write
```
instance : Repr String.Iterator where
  reprPrec ⟨s, pos⟩ prec :=
    Repr.addAppParen ("String.Iterator.mk " ++ reprArg s ++ " " ++ reprArg pos) prec
```
2021-03-12 11:06:07 -08:00