Commit graph

1602 commits

Author SHA1 Message Date
Sebastian Ullrich
bd7bb6f5b5 fix: do formatting 2020-11-25 11:30:24 +01:00
Sebastian Ullrich
b22e035b6f fix: pretty print empty matchers as nomatch
/cc @leodemoura
2020-11-25 11:30:24 +01:00
Sebastian Ullrich
cf9a2ae6af feat: formatter: preserve comments 2020-11-25 11:30:24 +01:00
Sebastian Ullrich
871cd105dc feat: Syntax.updateLeading: also choose "nicer" splits 2020-11-25 11:30:24 +01:00
Sebastian Ullrich
33c1e5ed9e fix: formatter: ignore all but one choice node 2020-11-25 11:30:24 +01:00
Sebastian Ullrich
6126fd6388 chore: improve pretty printer traces, avoid recursion 2020-11-25 11:30:24 +01:00
Leonardo de Moura
1cb7cb3ef6 feat: add exists tactic 2020-11-24 16:17:43 -08:00
Leonardo de Moura
22629b3c66 feat: add headBetaMVarType 2020-11-24 16:17:27 -08:00
Leonardo de Moura
36eb03c601 chore: cleanup Check.lean 2020-11-24 16:13:52 -08:00
Leonardo de Moura
b72a3c69b6 fix: ambiguity at induction/cases
See efc3a320fe
2020-11-24 14:59:12 -08:00
Leonardo de Moura
efc3a320fe chore: prepare to fix ambiguity at induction/cases notation
@Kha I was writing the following example
```
  ...
  induction as
  | nil          => cases h -- `h` is an empty type
  | cons b bs ih => cases h
    | head a bs => exact ⟨[], ⟨bs, rfl⟩⟩
    | tail a b bs h1 => ...
```
The current `syntax` assumes the `| cons b bs ih => ...` alternative
is part of the first `cases h`. Forcing the `|` to occur in a column
>= of the corresponding `cases` is not a nice solution since it would
preven us from writing the second `cases` as I wrote it above.
That is we would have to write
```
  induction as
  | nil          => cases h -- `h` is an empty type
  | cons b bs ih =>
    cases h
    | head a bs => exact ⟨[], ⟨bs, rfl⟩⟩
    | tail a b bs h1 => ...
```
or
```
  induction as
  | nil          => cases h -- `h` is an empty type
  | cons b bs ih => cases h
                    | head a bs => exact ⟨[], ⟨bs, rfl⟩⟩
                    | tail a b bs h1 => ...
```
I think the best solution is to use `with` when we have explicit
alternatives with `|`. The new syntax is similar to `match ... with | ...`
That is, we would write
```
  ...
  induction as with
  | nil          => cases h
  | cons b bs ih => cases h with
    | head a bs => exact ⟨[], ⟨bs, rfl⟩⟩
    | tail a b bs h1 => ...
```
2020-11-24 14:33:19 -08:00
Leonardo de Moura
5585f9823f chore: cleaner structure/class syntax
@Kha I implemented the syntax for structure/class that we discussed this morning.
It is much cleaner. See new tests at `struct2.lean`.
I updated the documentation to use it.
2020-11-24 13:07:43 -08:00
Leonardo de Moura
8f1ad0411d fix: fixes #220 and #223 2020-11-24 10:18:02 -08:00
Leonardo de Moura
5c39cd5120 chore: cleanup 2020-11-24 10:18:02 -08:00
Leonardo de Moura
ecfe590268 refactor: split Match.lean 2020-11-24 10:18:02 -08:00
Sebastian Ullrich
feedb539cd chore: import orphaned files in Lean 2020-11-24 19:16:27 +01: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
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
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
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
8a59fe5b52 feat: add ASCII version for · 2020-11-19 09:17:08 -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
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