Commit graph

2801 commits

Author SHA1 Message Date
Leonardo de Moura
b37158f4f8 fix: apply 2020-09-16 16:18:30 -07:00
Leonardo de Moura
544d2f4ce5 fix: kind for type metavariable
For example, `mkFreshExprMVar none MetavarKind.synthetic` should
create a fresh synthetic metavariable `?m` with type `?t` where `?t`
is a fresh natural metavariable. If users want a synthetic
metavariable `?t`, then it must create it themselves.
2020-09-16 08:24:15 -07:00
Leonardo de Moura
0abca5475f refactor: move ppExpr to IO
@Kha I am also tracking `currNamespace` and `openDecls`.

BTW, I also tried an experiment where I added `currNamespace` and
`openDecls` to `Meta.Context`, but it looked weird. This information
is only needed in the elaborator and pretty printer.
The `PPContext` object should contain everything you need. You
can put `currNamespace` and `openDecls` in the `Delaborator.Context`.
2020-09-15 18:48:21 -07:00
Leonardo de Moura
4e99b19a96 fix: expandMatchDiscr cannot be a macro
The `matchType` created by the macro is bad for dependent pattern
matching. The `tst8` and `tst9` at `matchTac` failed to be elaborated
when using the macro.
2020-09-15 13:29:28 -07:00
Leonardo de Moura
75814c2d21 chore: fix tests 2020-09-15 11:11:05 -07:00
Leonardo de Moura
fde43e071d feat: improve matchType inference 2020-09-14 19:44:45 -07:00
Leonardo de Moura
cc3b48ce16 fix: check inductive datatype parameters in constructor resulting type 2020-09-14 16:56:13 -07:00
Leonardo de Moura
634f063631 feat: finish commit "using indentation" 2020-09-14 16:40:52 -07:00
Leonardo de Moura
ca90ff8b59 test: have-by in tactic mode
@Kha By adding `have-by` macro (in term mode), we got `have-by` in
tactic mode without writing a single line of code :)
2020-09-14 15:17:25 -07:00
Leonardo de Moura
a6b19cd4af feat: expand show-by and have-by macros 2020-09-14 15:08:28 -07:00
Leonardo de Moura
fc4ab139b5 feat: indented by
@Kha This one is not as useful as the indented `do`. When writing
interactive proofs I like the error message at the `}` showing the
resulting tactic state. We can simulate it using a `skip` in the end of the sequence :)
We remove the `skip` when the proof is done. Note that, the last `;`
is usually not part of the `by`. Example:
```lean
theorem ex (x y z : Nat) : y = z → y = x → x = z :=
fun _ _ =>
  have x = y by apply Eq.symm; assumption; -- <<< the last `;` is part of the `have`
  Eq.trans this (by assumption)
```
2020-09-14 14:20:02 -07:00
Leonardo de Moura
4c6a589e6c feat: indented do blocks
@Kha it is soooooo much nicer :)
2020-09-14 13:44:51 -07:00
Sebastian Ullrich
a93a53b4b5 feat: more IO Task functions 2020-09-14 17:57:33 +02:00
Sebastian Ullrich
77cbaa752c fix: Task: make reference and -j0 semantics eager, simplify 2020-09-14 17:57:33 +02:00
Sebastian Ullrich
5b83ceb1b5 feat: IO.mapTask, IO.bindTask 2020-09-14 17:57:33 +02:00
Sebastian Ullrich
307a833798 feat: implement IO.asTask as primitive using always-run tasks 2020-09-14 17:57:33 +02:00
Sebastian Ullrich
c672bd657f feat: IO.asTask 2020-09-14 17:57:33 +02:00
Leonardo de Moura
c58252ad74 chore: move more tests to new frontend 2020-09-13 16:13:20 -07:00
Leonardo de Moura
2ee1821f13 fix: ensure expectedType at fun body 2020-09-13 13:44:05 -07:00
Leonardo de Moura
d936b9461f fix: always ensure expectedType when processing overloaded symbols and/or notation 2020-09-13 11:59:13 -07:00
Leonardo de Moura
c080d42692 chore: move tests to new frontend 2020-09-13 10:16:15 -07:00
Leonardo de Moura
0967ad7e91 feat: extend/cleanup isLevelDefEqAux
`tests/lean/run/toExpr.lean` could not be processed by the new
frontend without these extensions.
2020-09-12 15:38:48 -07:00
Leonardo de Moura
ab44cd28f1 chore: move more tests to new frontend 2020-09-12 09:04:39 -07:00
Leonardo de Moura
e1e65e83da fix: try to synthesize instance for substructures 2020-09-12 08:58:13 -07:00
Leonardo de Moura
a784005729 chore: move more tests to new frontend 2020-09-12 07:54:12 -07:00
Leonardo de Moura
f242a958fc chore: move more tests to new frontend 2020-09-11 17:36:37 -07:00
Leonardo de Moura
a8de3c5115 fix: isDefEq configuration in the elaborator 2020-09-11 17:36:28 -07:00
Leonardo de Moura
bbc3bec53b chore: move more tests to new frontend 2020-09-11 16:28:57 -07:00
Leonardo de Moura
bf703c9cab fix: bug at inductive datatype resulting universe inference 2020-09-11 16:07:22 -07:00
Leonardo de Moura
b02cda0408 chore: move more tests to new frontend 2020-09-11 15:31:14 -07:00
Leonardo de Moura
2c2a357f28 chore: remove disabled test 2020-09-11 15:05:00 -07:00
Leonardo de Moura
151012cb39 feat: remove emptyc elaboration hack
@Kha I removed the hack. We know get a nice error message.
2020-09-11 14:41:44 -07:00
Leonardo de Moura
ff9b562e66 chore: move test 2020-09-11 14:40:21 -07:00
Leonardo de Moura
cc6104b369 fix: bug in the old frontend
It had to be fixed because we have code that needs to be compiled with
the old frontend, and the hacks we used to workaround this issue are
incompatible with the new frontend.
2020-09-11 14:12:03 -07:00
Leonardo de Moura
7950413526 feat: improve choice nodes + postpone 2020-09-11 12:45:38 -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
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
54e006dc53 chore: move test to new frontend 2020-09-11 07:47:19 -07:00
Leonardo de Moura
6cf652606a chore: use new frontend 2020-09-10 19:34:05 -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
6b7088e71a fix: too restrictive condition 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
20bc004c70 feat: improve subst tactic 2020-09-09 16:20:15 -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
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