Commit graph

20956 commits

Author SHA1 Message Date
Leonardo de Moura
457e48cfe4 chore: add private 2020-09-11 11:23:07 -07:00
Leonardo de Moura
81987e59e7 fix: expected type propagation issue 2020-09-11 11:03:59 -07:00
Leonardo de Moura
1731962ea9 feat: elaborate emptyC notation
@Kha this is a little bit ugly. As in Lean3, the notation `{ }` is
overloaded. It can be `HasEmptyc.emptyc` or the empty structure.
Moreover, if we have an instance `HasEmptyc A` for a structure `A`,
then `{ }` is notation for `HasEmptyc.emptyc`. I am not very happy
about this, but it seems users use this feature. It is even used in
our own Lean4 code base :)

BTW, I will try a different alternative later.
First, move the notation `{ }` as a proper parser for `emptyc`.
Then, make sure the elaborator throws an error when
`{ }` is ambiguous. That is, `{}` can be elaborated as the empty
structure `A` and there is an `HasEmptyc A` instance.
Example:
```
structure A :=
(x : Nat := 0)

instance : HasEmptyc A :=
⟨{ x := 10 }⟩
```

The main issue here is that the support for choice+postpone is
currently broken.
2020-09-11 10:42:39 -07:00
Leonardo de Moura
32eabf2ef1 chore: remove old elaborator that is not needed anymore 2020-09-11 10:28:00 -07:00
Leonardo de Moura
4ddd4c4657 chore: move more tests to new frontend 2020-09-11 10:28:00 -07:00
Leonardo de Moura
290cd5cf0f chore: delete disabled tests 2020-09-11 08:38:12 -07:00
Leonardo de Moura
5db5cf7734 fix: do not lift (<- action) nested in quotations 2020-09-11 08:06:20 -07:00
Leonardo de Moura
fff61bc6a5 chore: update stage0 2020-09-11 07:49:24 -07:00
Leonardo de Moura
54e006dc53 chore: move test to new frontend 2020-09-11 07:47:19 -07:00
Leonardo de Moura
2978d7af32 fix: error message 2020-09-11 07:32:30 -07:00
Leonardo de Moura
6cf652606a chore: use new frontend 2020-09-10 19:34:05 -07:00
Leonardo de Moura
a8df621683 fix: bug at elabEvalUnsafe
It was forgetting the the updates performed by `MetaHasEval`.
Wow, I wasted a lot of time on this bug.
2020-09-10 19:33:52 -07:00
Leonardo de Moura
13d067d619 fix: forallTelescopeReducing => forallTelescope
It impacts `mkInhabitantFor`
2020-09-10 18:06:29 -07:00
Leonardo de Moura
e4a3b434d7 chore: moving tests to new frontend
@Kha The transition has begun :)
I found and fixed a few bugs, but it is going well so far.
2020-09-10 18:00:34 -07:00
Leonardo de Moura
a5c99b7601 fix: bug at getInstances 2020-09-10 17:49:17 -07:00
Leonardo de Moura
f28def6c5e feat: add Meta.ppExpr 2020-09-10 17:27:14 -07:00
Leonardo de Moura
c3d91e4228 chore: new keywords 2020-09-10 15:18:32 -07:00
Leonardo de Moura
f871c7b552 feat: trace! macro in the new frontend 2020-09-10 15:18:20 -07:00
Leonardo de Moura
264ce93bc8 chore: simplify elabEval
`TermElab` is now on top of `IO`
2020-09-10 15:03:45 -07:00
Leonardo de Moura
40777c203b feat: add MonadEnv helper methods 2020-09-10 14:58:22 -07:00
Leonardo de Moura
22bdab67ff feat: expand sorry 2020-09-10 14:58:14 -07:00
Leonardo de Moura
ba4fdce508 feat: expand helper macros 2020-09-10 14:25:07 -07:00
Leonardo de Moura
450b87811b chore: update stage0 2020-09-10 13:33:34 -07:00
Leonardo de Moura
d77dc5efb8 feat: add helper syntax 2020-09-10 13:31:45 -07:00
Leonardo de Moura
61bd10997a feat: add coercions for the new frontend 2020-09-10 13:24:13 -07:00
Leonardo de Moura
6b7088e71a fix: too restrictive condition 2020-09-10 11:20:09 -07:00
Leonardo de Moura
232fe8cadd doc: document parser trick 2020-09-10 11:20:09 -07:00
Leonardo de Moura
20152c1192 chore: change by precedence
@Kha it now uses the same precedence of `fun`.
The main motivation is to allow us to write `@by { ... }` instead of
`@(by { ... })`.

BTW, I am considering disabling implicit lambdas for `by ...` expressions.
It is automatically "intro"ducing the implicit variables without
giving an opportunity for users to pick their names.
2020-09-10 11:17:42 -07:00
Leonardo de Moura
2214d81e84 test: add match with proofs example 2020-09-09 16:59:45 -07:00
Leonardo de Moura
d3de12fa09 test: another dependent pattern matching test 2020-09-09 16:51:46 -07:00
Leonardo de Moura
b136c519e2 fix: scope and improve error message 2020-09-09 16:44:43 -07:00
Leonardo de Moura
02fc447b04 fix: error message 2020-09-09 16:42:41 -07:00
Leonardo de Moura
20bc004c70 feat: improve subst tactic 2020-09-09 16:20:15 -07:00
Leonardo de Moura
83410083a8 fix: do not generate code for noncomputable definitions 2020-09-09 15:28:41 -07:00
Leonardo de Moura
c78d0cf1f8 feat: use | position for reporting dependent-match elimination errors 2020-09-09 14:07:23 -07:00
Leonardo de Moura
854cc3418e feat: improve error message for dependent-match elimination failures
@Kha This is a first attempt to improve the error message for examples
like the one Andrew Kent posted on Zulip.
I created a simpler example using "vectors".
2020-09-09 13:43:06 -07:00
Leonardo de Moura
1215333e0f chore: use simpMacroScopes at ppGoal 2020-09-09 10:40:38 -07:00
Leonardo de Moura
c9f4f858b1 feat: ellipsis in constructor application patterns
Given
```
inductive Foo
| mk₁ (x y z w : Nat)
| mk₂ (x y z w : Nat)
```
We can now write
```
def Foo.z : Foo → Nat
| mk₁ (z := z) .. => z
| mk₂ (z := z) .. => z
```
instead of
```
def Foo.z : Foo → Nat
| mk₁ _ _ z _ => z
| mk₂ _ _ z _ => z
```

cc @Kha
2020-09-09 10:21:06 -07:00
Leonardo de Moura
25c3ba274b chore: update stage0 2020-09-09 09:56:59 -07:00
Leonardo de Moura
b24d1c2d90 feat: add .. syntax for pattern applications 2020-09-09 09:55:29 -07:00
Leonardo de Moura
276e6a55ba feat: improve collectPatternVars
Add support for `@` and named parameters.
Fix how ctor fields are processed.
2020-09-09 09:52:25 -07:00
Leonardo de Moura
4cb3d5faa4 chore: remove workaround 2020-09-09 06:44:36 -07:00
Leonardo de Moura
34291e2151 feat: add Name.simpMacroScopes
@Kha We currently have a few macros that create binder names
such as `x`. These macros rely on the hygienic framework. This part is
great. Before this commit we were simply erasing the macro
scopes when creating the actual binders at `Expr.lean`.
The result produced expressions that were hard to debug.
For example, consider the following scenario

1- Macro creates a few binder names using ``x <- `(x)``
2- We create a lambda expression `t` with these binder names.
3- Then, we use `lambdaTelescope t fun xs body => ...`
   Now, if we trace `xs` and `body`, we get `#[x, x, ... x]` and
   we can't distinguish the different `x`s in `body`.
   So, it is really hard to debug anything using the traces.

This commit adds `Name.simpMacroScopes` for simplying "macro scoped"
names. Example: given `x._@.Init.Data.List.Basic._hyg.2.5`, it
produces `x.2.5`. I exported this function, and used it in the old
pretty printer.

I have considered modifying `lambdaTelescope` to make sure it creates
unused names. I think this option is bad because it introduces
overhead, and in a few places we want to preserve the binder names.

I have also considered replacing the `let x := x.eraseMacroScopes` at
`Expr.lean` with `let x := x.simpMacroScopes`. I think this option is
bad since we are destroying scoping information and will not be able
to distiguish which variables have macro scopes when processing
tactics.

Anyway, the solution in this commit is good for this week, but we
should discuss a more permanent solution next week.
2020-09-08 18:22:44 -07:00
Leonardo de Moura
2e11053eb5 fix: matchAlt macros should not consume implicit arguments
As in Lean3, the following example is a valid definition

```
def head : {α : Type} → List α → Option α
| _, a::as => some a
| _, _     => none
```
2020-09-08 17:31:57 -07:00
Leonardo de Moura
96ffd206ca feat: add findRecArg 2020-09-08 17:25:35 -07:00
Leonardo de Moura
ea2e86afba feat: add Array.allDiff 2020-09-08 16:16:14 -07:00
Leonardo de Moura
77f8fe0e41 fix: mkLetRecClosureFor 2020-09-08 15:14:46 -07:00
Leonardo de Moura
fc1e4cb533 feat: add Array.isPrefixOf 2020-09-08 14:40:43 -07:00
Leonardo de Moura
603f2dee73 fix: unnecessary get! 2020-09-08 13:15:57 -07:00
Leonardo de Moura
ecda364985 feat: add Expr.forEach 2020-09-08 13:03:53 -07:00