Commit graph

5554 commits

Author SHA1 Message Date
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
ba4fdce508 feat: expand helper macros 2020-09-10 14:25:07 -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
b136c519e2 fix: scope and improve error message 2020-09-09 16:44:43 -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
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
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
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
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
ecda364985 feat: add Expr.forEach 2020-09-08 13:03:53 -07:00
Leonardo de Moura
9151fef49d feat: abstract proofs occurring in binders 2020-09-08 12:29:35 -07:00
Leonardo de Moura
0a853b2c44 feat: abstract nested proofs in definitions 2020-09-08 11:59:26 -07:00
Leonardo de Moura
ebe2cf272e feat: add MonadCacheT 2020-09-08 10:48:47 -07:00
Leonardo de Moura
ef87b33cdc test: add another missing hole test 2020-09-07 17:18:20 -07:00
Leonardo de Moura
fc0be5e391 feat: improve error message position when definition type is metavar 2020-09-07 17:16:44 -07:00
Leonardo de Moura
18a9cb9b43 feat: improve error message position for binders with implicit types 2020-09-07 17:02:43 -07:00
Leonardo de Moura
722608d0c6 chore: fix test 2020-09-07 16:35:28 -07:00
Leonardo de Moura
b6079e12b8 feat: expand macros infix, infixl, infixr, prefix, and postfix 2020-09-07 16:35:25 -07:00
Leonardo de Moura
fded18d114 chore: mkElim ==> mkMatcher 2020-09-07 14:33:39 -07:00
Leonardo de Moura
91363bae19 feat: improve resolveLVal 2020-09-07 12:25:43 -07:00
Leonardo de Moura
7809fe0b01 fix: def+match macro 2020-09-07 11:34:53 -07:00
Leonardo de Moura
a12bc273bb refactor: src/Lean/Meta/EqnCompiler ==> src/Lean/Meta/Match 2020-09-07 11:09:48 -07:00
Leonardo de Moura
ddf12c91c2 fix: do not consider auxiliary declarations as local instances 2020-09-07 08:08:35 -07:00
Leonardo de Moura
79130bc3f9 feat: add addAndCompilePartial 2020-09-07 07:56:11 -07:00
Leonardo de Moura
81582e4482 feat: break PreDefinitions into strongly connected components 2020-09-06 14:22:06 -07:00
Leonardo de Moura
56e6b9b398 feat: add Tarjan's SCC 2020-09-06 14:19:59 -07:00
Leonardo de Moura
565d617bab chore: fix test 2020-09-06 08:57:33 -07:00
Leonardo de Moura
6704468f07 feat: add coeId instance
Add an example showing why it is useful.

TODO: reconsider whether we should use the approximation described in
the new test or not.
2020-09-06 08:27:26 -07:00
Leonardo de Moura
d8855c2673 feat: elaborate all definitions using elabMutualDef 2020-09-06 07:23:47 -07:00
Leonardo de Moura
102d2ae57d fix: avoid unnecessary reduction
```lean
forallBoundedTelescope `(Nat -> IO Nat) 1 fun xs type => ...
```
should assign `IO Nat` to `type` instead of `IO.RealWorld -> ...`
2020-09-06 06:57:52 -07:00
Leonardo de Moura
3ae3c51a8c feat: add Array.partition 2020-09-05 08:48:15 -07:00
Leonardo de Moura
250dc3e3a9 fix: adjust expanders and elaborators to new matchAlts node 2020-09-04 18:59:28 -07:00
Leonardo de Moura
70c42456b9 feat: expand intro+matchAlts macro 2020-09-04 18:22:56 -07:00
Leonardo de Moura
ef64e1c25a feat: fun+match macro
Example:
```
fun
  | 0 => true
  | _ => false
```
2020-09-04 16:23:01 -07:00
Leonardo de Moura
3dbd2b728b feat: add Array.getMax? 2020-09-04 10:40:34 -07:00