Commit graph

15208 commits

Author SHA1 Message Date
Sebastian Ullrich
feedb539cd chore: import orphaned files in Lean 2020-11-24 19:16:27 +01:00
Sebastian Ullrich
50abe8352b feat: allow specifying file name with --stdin 2020-11-24 19:16:27 +01:00
Leonardo de Moura
f456e006dc chore: test instance ... where 2020-11-23 18:24:23 -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
645c1034a0 chore: reduce compilation time 2020-11-23 16:18:55 -08:00
Leonardo de Moura
be812081f4 chore: using "unbound implicit locals" 2020-11-23 13:09: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
3f27d7318e chore: prepare to add where clause to declarations 2020-11-23 10:41:12 -08:00
Leonardo de Moura
b4012fdd71 chore: remove old comment that is not true anymore 2020-11-23 08:44:50 -08:00
Leonardo de Moura
cb9574b086 chore: test unboundImplicitLocals and cleanup 2020-11-22 10:33:28 -08:00
Leonardo de Moura
da3e3211a0 feat: refine propagateExpectedType 2020-11-22 10:16:41 -08:00
Leonardo de Moura
29303f17f3 chore: test unboundImplicitLocals 2020-11-22 09:48:15 -08:00
Leonardo de Moura
8ed3b8c55f fix: tryPureCoe? 2020-11-22 08:24:56 -08:00
Leonardo de Moura
e8ae23b7a6 chore: minor 2020-11-21 20:53:19 -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
c7a31ed52e chore: remove duplicate instances 2020-11-21 11:05:52 -08:00
Leonardo de Moura
050bdd2e88 feat: readable auto generated instance names 2020-11-21 11:05:28 -08:00
Leonardo de Moura
3ff494832d chore: cleanup 2020-11-21 08:59:21 -08:00
Leonardo de Moura
b672e37bcc chore: annotate OfNat and ToString default instances 2020-11-21 08:34:45 -08:00
Leonardo de Moura
76025c9d18 feat: add attribute [defaultInstance] 2020-11-21 08:24:28 -08:00
Leonardo de Moura
6830291fd5 chore: remove dead code at Class.lean used by old frontend 2020-11-20 16:51:44 -08:00
Leonardo de Moura
104ade010f chore: weird line break 2020-11-20 16:22:01 -08:00
Leonardo de Moura
e6215f7282 chore: remove some unnecessary commas 2020-11-20 15:47:27 -08:00
Leonardo de Moura
c9cbe35916 fix: adjust code to optional , at structure instances
@Kha I implemented the optional `,` at structure instances.
You have suggested it a few weeks/months ago. F# also implements this
feature. I got back to it while write documentation for Lean.
It looks quite nice when we are packing many functions into a structure.

BTW, F# also has optional separators for list literals :)
This is a much simpler change for us since `[...]` is defined using
the `syntax/macro_rules` commands, but I didn't find optional ','
would very useful since our list literals are usually in a single
line.
2020-11-20 15:43:35 -08:00
Leonardo de Moura
fcbd72f2af feat: optional , at structure instances 2020-11-20 15:24:34 -08:00
Leonardo de Moura
27e26998d2 chore: prepare to change structInst syntax 2020-11-20 13:57:52 -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
5adfd37dfd feat: add auxiliary KVMap for storing extra information at Exception.internal 2020-11-20 09:49:00 -08:00
Leonardo de Moura
3323f7da60 feat: add instance Inhabited (Sort u) 2020-11-19 13:55:00 -08:00
Leonardo de Moura
90298ba476 feat: add helper instance 2020-11-19 11:32:54 -08:00
Leonardo de Moura
8a59fe5b52 feat: add ASCII version for · 2020-11-19 09:17:08 -08:00
Leonardo de Moura
6551caf062 feat: define $ notation at Notation.lean 2020-11-19 09:10:19 -08:00
Leonardo de Moura
d7d53bf3a8 chore: remove builtin $
We will define it at `Notation.lean`
2020-11-19 09:04:41 -08:00
Leonardo de Moura
304c80d610 feat: use <| 2020-11-19 09:03:38 -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
f67c93191f feat: use |>. 2020-11-19 08:38:47 -08:00
Leonardo de Moura
a58a7d6536 feat: expand |>. notation 2020-11-19 08:28:12 -08:00
Leonardo de Moura
91b3e3e318 feat: add pipe proj notation
We will delete `dollarProj`
2020-11-19 08:14:29 -08:00
Leonardo de Moura
87d97c24a7 chore: code convention 2020-11-19 08:13:11 -08:00
Leonardo de Moura
954d850e6d feat: add F# pipe notation 2020-11-19 08:12:53 -08:00
Leonardo de Moura
5cc110dd77 feat: add Array.appendCore for quotations
We need it before we can define the more efficient `Array.append`
2020-11-19 08:07:53 -08:00
Leonardo de Moura
c305c2691f chore: use := 2020-11-19 07:22:31 -08:00
Leonardo de Moura
0fcf6217ec feat: optional := before constructors in the inductive command
@Kha In the documentation, I will always use `:=`. The idea is to
avoid the issue: why does `structure` have a `:=` but `inductive`
doesn't.
2020-11-19 06:43:14 -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
bebca44773 feat: add println! macro for rewriting examples 2020-11-18 18:47:22 -08:00
Leonardo de Moura
e991f1993f feat: add Delta.lean 2020-11-18 18:47:22 -08:00
Leonardo de Moura
45cd9fe725 feat: add Core.transform 2020-11-18 18:47:22 -08:00