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
b24d1c2d90
feat: add .. syntax for pattern applications
2020-09-09 09:55:29 -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
4cb3d5faa4
chore: remove workaround
2020-09-09 06:44:36 -07:00
Leonardo de Moura
34291e2151
feat: add Name.simpMacroScopes
...
@Kha We currently have a few macros that create binder names
such as `x`. These macros rely on the hygienic framework. This part is
great. Before this commit we were simply erasing the macro
scopes when creating the actual binders at `Expr.lean`.
The result produced expressions that were hard to debug.
For example, consider the following scenario
1- Macro creates a few binder names using ``x <- `(x)``
2- We create a lambda expression `t` with these binder names.
3- Then, we use `lambdaTelescope t fun xs body => ...`
Now, if we trace `xs` and `body`, we get `#[x, x, ... x]` and
we can't distinguish the different `x`s in `body`.
So, it is really hard to debug anything using the traces.
This commit adds `Name.simpMacroScopes` for simplying "macro scoped"
names. Example: given `x._@.Init.Data.List.Basic._hyg.2.5`, it
produces `x.2.5`. I exported this function, and used it in the old
pretty printer.
I have considered modifying `lambdaTelescope` to make sure it creates
unused names. I think this option is bad because it introduces
overhead, and in a few places we want to preserve the binder names.
I have also considered replacing the `let x := x.eraseMacroScopes` at
`Expr.lean` with `let x := x.simpMacroScopes`. I think this option is
bad since we are destroying scoping information and will not be able
to distiguish which variables have macro scopes when processing
tactics.
Anyway, the solution in this commit is good for this week, but we
should discuss a more permanent solution next week.
2020-09-08 18:22:44 -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
96ffd206ca
feat: add findRecArg
2020-09-08 17:25:35 -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
603f2dee73
fix: unnecessary get!
2020-09-08 13:15:57 -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
296981319c
feat: add abstractNestedProofs
2020-09-08 11:48:28 -07:00
Leonardo de Moura
2e335bf802
feat: ensure MonadCacheT does not implement MonadState
2020-09-08 11:33:12 -07:00
Leonardo de Moura
9a69ab568e
feat: add mkAuxName for MonadEnv
2020-09-08 10:56:31 -07:00
Leonardo de Moura
ebe2cf272e
feat: add MonadCacheT
2020-09-08 10:48:47 -07:00
Leonardo de Moura
b52713ef8f
refactor: split PreDefinition.lean into smaller files
2020-09-08 08:23:41 -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
0ec284db24
feat: check for unassigned metavars before recursion elimination
2020-09-07 17:11:10 -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
cf944e32cf
chore: add back support for Lean3 mixfix/reserve syntax
...
We have tests that rely on them :(
2020-09-07 16:40:12 -07:00
Leonardo de Moura
1bc9b5c119
feat: expand ! and ¬ syntax
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
804ebcec16
feat: adjust mixfix syntax
2020-09-07 15:55:02 -07:00
Leonardo de Moura
aed9b16dc8
feat: add MatcherInfo extension
2020-09-07 15:08:21 -07:00
Leonardo de Moura
fded18d114
chore: mkElim ==> mkMatcher
2020-09-07 14:33:39 -07:00
Leonardo de Moura
43b593a888
feat: check for nonsensical declaration modifiers combinations
2020-09-07 12:36:58 -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
87db970cfa
chore: control code size explosion
2020-09-07 08:42:39 -07:00
Leonardo de Moura
936b8d34dd
chore: add auxiliary declaration to stop specialization
2020-09-07 08:30:08 -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
36bc65385d
chore: naming convention
2020-09-07 08:03:41 -07:00
Leonardo de Moura
79130bc3f9
feat: add addAndCompilePartial
2020-09-07 07:56:11 -07:00
Leonardo de Moura
f30b5bdcba
chore: control code size explosion
2020-09-07 07:23:44 -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
35a81e80d6
refactor: move PreDeclaration (now PreDefinition) to its own module
2020-09-06 08:54:38 -07:00
Leonardo de Moura
d0993d07a1
chore: rename Definition.lean => DefView.lean
2020-09-06 08:40:48 -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
dc60739bd6
feat: partition non recursive
2020-09-05 09:22:18 -07:00
Leonardo de Moura
3ae3c51a8c
feat: add Array.partition
2020-09-05 08:48:15 -07:00
Leonardo de Moura
52aef7611a
chore: fix val vs value naming convention
2020-09-05 08:38:37 -07:00
Leonardo de Moura
fbe18ee84c
feat: addAndCompileNonRec
2020-09-05 08:32:56 -07:00
Leonardo de Moura
4e7ca37204
chore: use Lean version
2020-09-05 08:15:53 -07:00