Commit graph

5992 commits

Author SHA1 Message Date
Leonardo de Moura
f37fd97d9f chore: fix test 2020-11-23 18:34:38 -08:00
Leonardo de Moura
5884b9c19a feat: add support for instance ... where
@Kha The fields are not mutually recursive yet, but it is good enough
 for writing examples in the manual.

See new test
2020-11-23 18:07:02 -08:00
Leonardo de Moura
ac85650e0a feat: add optional where clause at declarations
closes #191

@Kha Note that it expands into a "let rec".
There are many other places where an optional `where`-clause is
useful. We can add them later. It is relatively easy to add support in
other places using the new helper functions
`expandWhereDeclsOpt` and `expandMatchAltsWhereDecls`
2020-11-23 12:04:51 -08:00
Leonardo de Moura
f7279ee419 test: add tests for some Lean3 issues 2020-11-23 09:55:39 -08:00
Leonardo de Moura
da3e3211a0 feat: refine propagateExpectedType 2020-11-22 10:16:41 -08:00
Leonardo de Moura
8ed3b8c55f fix: tryPureCoe? 2020-11-22 08:24:56 -08:00
Leonardo de Moura
8598dde6e6 fix: if-then-else elaboration issue
@Kha I hate this kind of hack, but the behavior looked unacceptabled
to me. I added a big comment describing the issue and the hack.
2020-11-21 20:51:28 -08:00
Leonardo de Moura
7496f4377f fix: issues with unbound implicit locals
This commit also add support for them in the `inductive` command.
2020-11-21 16:17:38 -08:00
Leonardo de Moura
f220654a27 feat: default instances 2020-11-21 14:44:40 -08:00
Leonardo de Moura
b672e37bcc chore: annotate OfNat and ToString default instances 2020-11-21 08:34:45 -08:00
Leonardo de Moura
fa6d35adfa chore: fix tests 2020-11-20 17:00:13 -08:00
Leonardo de Moura
fcbd72f2af feat: optional , at structure instances 2020-11-20 15:24:34 -08:00
Leonardo de Moura
72032980ff feat: support for unboundImplicitLocals at variable and variables commands
They are morally part of the header.

cc @Kha
2020-11-20 12:32:32 -08:00
Leonardo de Moura
f3779f1542 feat: add support for unbound implicit locals 2020-11-20 12:22:27 -08:00
Leonardo de Moura
eba78e2d83 test: renaming for intrinsically typed lambda calculus 2020-11-19 19:10:49 -08:00
Leonardo de Moura
909969a7c2 chore: fix test 2020-11-19 09:25:13 -08:00
Leonardo de Moura
b6a1914299 chore: remove $. notation
It has been replaced by `|>.`
2020-11-19 08:47:35 -08:00
Leonardo de Moura
91dca53274 refactor: remove MonadIO
There is no reason for having `MonadIO` anymore. The `MonadLift` type
class is well behaved in the new frontend, the `MonadFinally` solves
the problem at monad stacks such as `ExcepT e IO`.

This commit also changes the type of the IO printing functions.
For example, the type of `IO.println` was
```
def IO.println {m} [MonadIO m] {α} [ToString α] (s : α) : m Unit
```
and now it is just
```
def IO.println {α} [ToString α] (s : α) : IO Unit
```
We rely on the new frontend auto-lifting feature.
That is, if there is an instance `[MonadLiftT IO m]`, then
a term of type `IO a` is automatically coerced to `m a`

We also want a simpler `IO.println` for writing tests.
For example,
```
```
doesn't work because there isn't sufficient information for inferring
the parameter `m` in the previous `IO.println`.
The shortest workaround looked very weird
```
```

I considered adding `IO` as a default value for `m` when we have
`MonadIO m`, as we use `Nat` as the default for `ofNat a`, but it felt
like uncessary complexity.

@Kha The commit seems to work well. The auto-lifting featuring has
been working great for me. There is still room for improvement.
For example, given `MonadLiftT m n`, it doesn't automatically lift
`a -> m b` into `a -> n b`. So, code such as
`foo >>= IO.println`
had to be rewritten as
`foo >>= fun x => IO.println x`
I will add this feature later.
If you have time, please try to play with this feature and figure out
if it is stable enough for making it the default.
That is, if it roboust enough, we can stop using the following idiom
for writing functions that can be lifted automatically.
```
def instantiateLevelMVarsImp (u : Level) : MetaM Level :=
  ...

def instantiateLevelMVars {m} [MonadLiftT MetaM m] (u : Level) : m Level :=
  liftMetaM $ instantiateLevelMVarsImp u
```
I think we only need this idiom when using `MonadControlT` which is
not as common as `MonadLiftT`.
2020-11-18 18:47:22 -08:00
Leonardo de Moura
a056332c03 fix: registerLetRecsToLift 2020-11-18 18:47:22 -08:00
Leonardo de Moura
2c06ba577e chore: fix test 2020-11-17 17:14:06 -08:00
Leonardo de Moura
7e533b4650 refactor: use Lists for Array reference implementation
Motivation: better reduction in the kernel.

cc @Kha
2020-11-17 17:05:53 -08:00
Leonardo de Moura
8751bbe2a8 fix: notation for non reserved symbols 2020-11-17 11:25:04 -08:00
Leonardo de Moura
1d93eefada feat: add ! x notation for notFollowedBy(x) in the syntax command 2020-11-17 10:57:15 -08:00
Leonardo de Moura
da23b96b43 feat: improve error messages for syntax command 2020-11-17 10:33:53 -08:00
Leonardo de Moura
178b3e5b52 chore: remove workaround 2020-11-16 16:25:58 -08:00
Leonardo de Moura
57670b633a feat: improve smart unfolding 2020-11-16 15:44:52 -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
bb06fbaa8a test: smart unfolding 2020-11-15 16:36:22 -08:00
Leonardo de Moura
f5ba036d8f chore: add support for reducing matchers 2020-11-15 15:07:53 -08:00
Leonardo de Moura
0bf703b17c chore: remove misleading comment
It doesn't loop in Lean 4.
2020-11-14 18:07:19 -08:00
Leonardo de Moura
73dec1be45 test: add tests for Lean3 bugs 2020-11-14 18:04:22 -08:00
Leonardo de Moura
db5fe843de chore: add expandInterpolatedStr helper function, rename msg! => m! 2020-11-14 13:52:52 -08:00
Leonardo de Moura
cc7d7422db fix: UInt ctors/fields in generated code 2020-11-14 12:50:32 -08:00
Leonardo de Moura
17fb995348 feat: improve mkLevelMax' 2020-11-14 08:36:23 -08:00
Leonardo de Moura
053e09c5e6 chore: fix test 2020-11-14 08:16:47 -08:00
Leonardo de Moura
99fad9fc4d feat: goodies for writing notation with binders 2020-11-14 07:32:44 -08:00
Sebastian Ullrich
9c6c568caf fix: don't try to pretty-print underapplied matcher
Fixes #219
2020-11-14 13:19:21 +01:00
Sebastian Ullrich
1add44916c chore: remove broken & redundant "new parser Core.lean" benchmark 2020-11-13 21:08:46 +01:00
Leonardo de Moura
b0e8183663 fix: error position for unsolved goals at cases and induction tactics 2020-11-13 07:59:50 -08:00
Leonardo de Moura
d137ecf4e8 feat: improve addLValArg
@Kha the module as classes test is now working.
2020-11-12 18:59:59 -08:00
Leonardo de Moura
61dfe2b1db fix: letDecl
use `simpleBinderWithoutType` at `declSig` and `optDeclSig`
2020-11-12 16:22:57 -08:00
Leonardo de Moura
fc6c8e0348 fix: beta reduce value at processAssignmentFOApprox 2020-11-12 14:46:28 -08:00
Leonardo de Moura
367432defc fix: fixes #217 2020-11-12 14:36:47 -08:00
Leonardo de Moura
cae6aa95dc feat: support simpleBinder at letDecl 2020-11-12 13:25:38 -08:00
Leonardo de Moura
bd76458210 feat: add support for nonReservedSymbol at syntax command 2020-11-12 07:32:18 -08:00
Leonardo de Moura
65dafaf07c fix: stdlib and tests
We also declare a few macros for the syntax command.
2020-11-12 07:12:30 -08:00
Leonardo de Moura
d30e96bc7d chore: fix tests 2020-11-11 19:09:23 -08:00
Leonardo de Moura
ab2ee0390d chore: fix tests 2020-11-11 10:19:14 -08:00
Leonardo de Moura
dbf99a17b6 chore: define notation using infix commands 2020-11-11 08:26:12 -08:00