Commit graph

71 commits

Author SHA1 Message Date
Leonardo de Moura
7f852d1dad doc: getSubgoalsAux 2019-12-04 06:14:05 -08:00
Leonardo de Moura
1ad97e8e9e refactor: simplify code 2019-12-04 05:54:21 -08:00
Leonardo de Moura
a0a7f11faf refactor: remove unnecessary tryResolveCore from tryAnswer 2019-12-04 05:36:53 -08:00
Leonardo de Moura
1e16b31190 doc: Meta/SynthInstance.lean 2019-12-03 20:09:06 -08:00
Leonardo de Moura
1aa398415c fix: accidental variable shadowing 2019-12-03 14:38:59 -08:00
Leonardo de Moura
43fc18eb41 fix: incorrect local context being used to create new metavariables 2019-12-03 13:31:24 -08:00
Leonardo de Moura
a7aca58bf7 fix: missing instantiateMVars 2019-12-03 13:01:44 -08:00
Leonardo de Moura
618b22e9a1 fix: typo 2019-12-03 12:53:37 -08:00
Leonardo de Moura
98f9ec8b07 refactor: avoid code explosion generated by telescope functions 2019-12-03 12:28:54 -08:00
Leonardo de Moura
2e0b22d49d fix: MetavarContext propagation 2019-12-03 11:34:04 -08:00
Leonardo de Moura
2254da0367 test: add simple test 2019-12-03 10:42:43 -08:00
Leonardo de Moura
5adce9fa20 fix: use eta reduction at DiscrTree
@kha @dselsam

Suppose we are trying to retrieve the global instances for
`(Monad (StateM Nat))`.
During retrieval, we reducde `StateM Nat` into `fun x => StateT Nat Id x`
However, the `DiscrTree` contains an entry for `Monad (StateT * *)`.
Thus, we fail to retrieve any instance.
I fixed the particular issue by using eta reduction.
Not sure we will encounter other definitional-equality related problems .
2019-12-03 10:30:53 -08:00
Leonardo de Moura
3c515dcd21 feat: missing methods 2019-12-03 09:09:45 -08:00
Leonardo de Moura
833c587fa3 feat: add generate, newSubgoal, tryResolve, and simpler table
TODO: `resume`
2019-12-02 19:00:43 -08:00
Leonardo de Moura
3eabda1c4d feat: add withMCtx 2019-12-02 12:48:34 -08:00
Leonardo de Moura
028531ba9b chore: M => SynthM 2019-12-02 11:41:44 -08:00
Leonardo de Moura
798001af75 refactor: do not save/restore cache at withNewMCtxDepth 2019-12-02 11:17:20 -08:00
Leonardo de Moura
770649ce1d refactor: do not save/restore cache at "telescope" methods
@kha @dselsam FYI

The original motivation for saving/restoring the cache was not
correctness, but cache size management. When we go inside a binder
using the telescope methods, we extend the local context with new fresh
free variables, execute the action `k` using the new extended local
context, and then restore it. Any cached result containing these
fresh variables is dead after executing `k`. So, `savingCache` here
could be viewed as a "checkpoint". However, it also removes any
cached entry that does not contain the new fresh variables.
I found this inconvenient in practice, and it is the wrong choice
in a few cases. Example: we have a `forall` expr (aka arrow), and use a
telescope to go inside, and then invoke TC. If the telescope uses
`savingCache`, we lose the cached TC instance witness. This is
wasteful since the witness often doesn't even depend on the new fresh
free variables created by the telescope.
Thus, this commit removes the `savingCache` occurrences from
the "telescope" methods. Users may still manually use it if
they think it is appropriate. That is, they can write
```lean
savingCache $ forallTelescope e $ fun xs body => <code>
```
if they really want to discard any new cache entry created while
executing `<code>`.
2019-12-02 11:11:49 -08:00
Leonardo de Moura
00a5860ce6 feat: add withMVarContext
cc @dselsam @kha
2019-12-02 10:50:00 -08:00
Leonardo de Moura
76d146b879 refactor: simplify SynthInstance.M 2019-12-02 10:36:57 -08:00
Leonardo de Moura
14de4e6965 feat: add trySynthInstance 2019-12-01 18:52:31 -08:00
Leonardo de Moura
f85ac7b5dc feat: add isLevelDefEqStuck exception 2019-12-01 18:42:33 -08:00
Leonardo de Moura
7e34cb4474 feat: add SynthInstance.lean
It is the first step to integrate the new type class procedure intro
`MetaM`. It implements the main entry point where we preprocess the
instance, check cache, invoke main function, process replacements, and
cache result.
2019-12-01 18:32:48 -08:00
Leonardo de Moura
5682c6e33b feat: add hasAssignableMVar 2019-12-01 18:32:48 -08:00
Leonardo de Moura
a55841aa68 chore: simplify synthInstance cache
Make sure it handle the common cases efficiently.
2019-12-01 18:32:48 -08:00
Leonardo de Moura
99840f6212 chore: move abbreviation 2019-12-01 18:32:48 -08:00
Leonardo de Moura
2867cd627b feat: add tryOpt 2019-12-01 18:32:48 -08:00
Leonardo de Moura
00b991baf6 feat: add openAbstractMVarsResult 2019-12-01 18:32:48 -08:00
Leonardo de Moura
27bf6c8229 chore: refine synthInstance cache 2019-12-01 18:32:48 -08:00
Leonardo de Moura
11d829eccd feat: add lambdaMetaTelescope
We need it because `abstractMVars` use lambdas
2019-12-01 18:32:48 -08:00
Leonardo de Moura
e73b5e3c88 chore: SynthInstanceAnswer ==> SynthInstance.Answer 2019-12-01 18:32:48 -08:00
Leonardo de Moura
3bc5e144a2 feat: add synthInstance cache 2019-12-01 18:32:48 -08:00
Leonardo de Moura
e82ca1456e chore: user lambda instead of forall to store result
Reason: ensure the resulting expression is type correct.
2019-12-01 18:32:48 -08:00
Leonardo de Moura
f701683388 chore: add abbreviations MVarId and FVarId 2019-11-28 08:18:06 -08:00
Leonardo de Moura
f8fb195719 feat: cache local instances at metavariable declarations 2019-11-28 05:57:46 -08:00
Leonardo de Moura
2733a5bebd chore: remove unnecessary method 2019-11-28 05:40:03 -08:00
Leonardo de Moura
deacb03802 feat: add isReadOnlyExprMVar 2019-11-28 05:34:12 -08:00
Leonardo de Moura
be9dab41ad fix: abstractMVars 2019-11-27 10:53:25 -08:00
Leonardo de Moura
b1f9b7cd4d feat: add AbstractMVars 2019-11-27 09:45:40 -08:00
Leonardo de Moura
005d03fc3d feat: remove ignoreImplict workaround 2019-11-27 06:54:55 -08:00
Leonardo de Moura
e99f8a9d22 chore: naming convention
suffix `?` should only be used for functions/methods returning `Bool`.
2019-11-27 05:50:31 -08:00
Leonardo de Moura
42fcf6e6e8 feat: add parameter ignoreImplicit 2019-11-26 17:56:07 -08:00
Leonardo de Moura
9a160a197a fix: addGlobalInstance 2019-11-26 17:19:03 -08:00
Leonardo de Moura
81278c1509 feat: add instanceExtension
Use discrimination trees indexing type class instances.
2019-11-26 17:01:36 -08:00
Leonardo de Moura
55ab0f29e9 feat: break insert into two steps
Only the first step `Expr -> Array Key` requires the `MetaM` monad.
Motivation: we can save `(Array Key, Expr)` into .olean files, and
import modules without using `MetaM`.
2019-11-26 17:01:36 -08:00
Leonardo de Moura
f9376fe04b feat: add withNewMCtxDepth 2019-11-26 17:01:36 -08:00
Leonardo de Moura
1f815ac521 feat: add forallMetaTelescope 2019-11-26 17:01:36 -08:00
Leonardo de Moura
4162eb1e08 fix: typo 2019-11-25 15:53:08 -08:00
Leonardo de Moura
856fb0c000 feat: use isProofQuick to implement isDefEqProofIrrel 2019-11-25 08:42:23 -08:00
Leonardo de Moura
292603f8bb chore: remove ParamInfo.proof field
It is an approximation because of dependent types.
Moreover, the new `isProofQuick` should make `isProof` much cheaper.
2019-11-25 08:42:23 -08:00