Commit graph

388 commits

Author SHA1 Message Date
Leonardo de Moura
4fc06bfcca feat: add optional (priority := <prio>) to instance command 2020-12-21 10:02:12 -08:00
Leonardo de Moura
498dae8fab chore: add trace messages 2020-12-19 12:26:37 -08:00
Leonardo de Moura
6133e5de43 chore: make sure subst is a "noop" if there is nothing to substitute 2020-12-17 17:30:23 -08:00
Leonardo de Moura
9736ea55f5 chore: cleanup 2020-12-17 17:30:23 -08:00
Leonardo de Moura
c428e4feaa fix: bug at injection 2020-12-17 17:30:23 -08:00
Leonardo de Moura
87b6385bea feat: add deriving DecidableEq 2020-12-17 17:30:23 -08:00
Leonardo de Moura
c7ae8354fd feat: improve type mismatch error messages
Use heuristic to automatically annotate terms with `pp.explicit`.
2020-12-17 07:11:52 -08:00
Leonardo de Moura
7c865e7bd9 feat: sort instances by priority 2020-12-16 10:45:27 -08:00
Leonardo de Moura
0fa262bb93 feat: add priority to InstanceEntry 2020-12-16 10:40:58 -08:00
Leonardo de Moura
ed87480093 refactor: move to attr syntax category 2020-12-15 20:22:04 -08:00
Leonardo de Moura
469c9b7bbf chore: remove TODO 2020-12-14 11:50:22 -08:00
Leonardo de Moura
f345c8c708 feat: add betaReduce 2020-12-13 15:49:22 -08:00
Leonardo de Moura
04a07c15b9 chore: use deriving Inhabited 2020-12-13 11:57:59 -08:00
Leonardo de Moura
3b6d65c3c3 chore: use deriving Inhabited 2020-12-13 10:09:20 -08:00
Leonardo de Moura
25ecc43a84 fix: missing try at isClass? 2020-12-09 15:19:49 -08:00
Leonardo de Moura
63ab55289e chore: remove "liftable methods"
The new frontend "auto lifting" feature makes them obsolete.
2020-12-09 15:06:07 -08:00
Leonardo de Moura
7a4b544b1c feat: improve application type mismatch error message
If the type error is at an implicit argument, we annotate
application with `pp.explicit := true`

Given the type incorrect definition
```
def f {a b c : α} : a = c :=
  Eq.trans (a := a) (b := b = c)
```
We now generate the error
```
error: application type mismatch
  @Eq.trans α a (b = c)
argument
  b = c
has type
  Prop
but is expected to have type
  α
```
@Kha Note that we only enable `pp.explicit := true` for the relevant
application. That is, we set `pp.explicit := false` for each children.

Unfortunately, there is a corner case.
```
set_option pp.explicit true
def f {a b c : α} : a = c :=
  Eq.trans (a := a) (b := b = c)
```
produces the error
```
error: application type mismatch
  @Eq.trans α a (b = c)
argument
  @Eq α b c
has type
  Prop
but is expected to have type
  α
```
The reset `pp.explicit := false` overwrote the user option.
I think the simplest solution is the following
1- The delaborator saves the initial set of Options `Init`
2- When it finds a node annotated with a `pp` options, it only
consider the option if it is not set by `Init`.

What do you think?
2020-12-09 13:58:08 -08:00
Leonardo de Moura
9a422ddc23 fix: Array.back on empty array 2020-12-08 12:21:01 -08:00
Leonardo de Moura
ae5aa51712 chore: add explicit discard 2020-12-08 06:18:18 -08:00
Leonardo de Moura
cbf2b6c0db feat: change synthinstance threshold
Before this commit, the threshold was the amount of "fuel".
Now, it is the maximum number of instances used to solve a TC problem.
We have two thresholds
- `maxInstSize`: default 128
- `maxCoeSize`: default 16. It is similar to `maxInstSize`, but used for automatic coercions.

cc @Kha
2020-12-07 10:45:08 -08:00
Leonardo de Moura
6af3eac142 feat: add MonadStateCacheT based on StateT 2020-12-06 19:07:28 -08:00
Leonardo de Moura
906cb81319 feat: improve inferAppType
See comment at `Expr.instantiateRevRange`
2020-12-06 19:01:23 -08:00
Leonardo de Moura
265b7571b4 chore: change checkCache type 2020-12-06 16:24:51 -08:00
Leonardo de Moura
1aaf7c0778 feat: add SimpleScopedEnvExtension
`ParserExtension` will probably be the only case where we need the
general case.
2020-12-05 16:38:35 -08:00
Leonardo de Moura
f0372f724c chore: remove unused attribute 2020-12-05 16:28:58 -08:00
Leonardo de Moura
533192c369 feat: implement instanceExtension using ScopedEnvExtension 2020-12-05 16:04:37 -08:00
Leonardo de Moura
32d5ef8b78 feat: scoped and local unification hints 2020-12-05 13:49:36 -08:00
Leonardo de Moura
0ab368581a refactor: ScopedEnvExtension
1) `ScopedEnvExtension` module now mananges the push/pop/activate
methods. Motivations:
  - Easier to add attributes
  - One `ScopedEnvExtension` may be shared between multiple
  attributes (e.g., parsers)

2) Add `AttributeKind`
2020-12-04 16:22:43 -08:00
Leonardo de Moura
469de09280 fix: bug at isDefEq
The new test contains a minimal example that triggers the bug.
2020-12-02 13:27:21 -08:00
Leonardo de Moura
9d304df757 feat: heterogeneous Append experiment
@Kha This one required a bunch of manual fixes. The main issue is that
before we added the string interpolation feature, we created
`MessageData`s using `++` and coercions. For example, given
`(e : Expr)`, we would write
```
let msg : MessageData := "type: " ++ e
```
and rely on the coercions `String -> MessageData` and
`Expr -> MessageData`, and the instance `Append MessageData`.
However, heterogeneous operators "block" the expected type propagation downwards.
This kind of code is obsolete now since we can write a more compact
version using string interpolation
```
let msg := m!"type: {e}"
```
2020-12-01 16:32:41 -08:00
Leonardo de Moura
d629c76f9e chore: more heterogeneous operators support 2020-12-01 12:39:45 -08:00
Leonardo de Moura
e213a7ecca feat: add support for heterogeneous operators at Offset.lean 2020-12-01 11:53:44 -08:00
Leonardo de Moura
27292c4f60 chore: prepare to change OfNat type class 2020-12-01 06:59:16 -08:00
Leonardo de Moura
6a3fff5c66 fix: condition 2020-11-30 17:10:25 -08:00
Leonardo de Moura
085c7e59ba feat: apply default instances using priorities 2020-11-30 16:43:12 -08:00
Leonardo de Moura
b437cfd9a3 feat: add [defaultInstance] priorities 2020-11-30 15:57:40 -08:00
Leonardo de Moura
b6f242434d fix: fixes #229 2020-11-30 11:51:13 -08:00
Leonardo de Moura
72215c7144 feat: add TransparencyMode.instances 2020-11-29 18:12:33 -08:00
Leonardo de Moura
390eea3750 feat: use One and Zero classes when expanding numeric literals 2020-11-29 16:23:52 -08:00
Leonardo de Moura
9e860672ad chore: helper trace message 2020-11-29 08:46:34 -08:00
Leonardo de Moura
05fc1e8bbf feat: optional name for unification hints 2020-11-29 08:05:26 -08:00
Leonardo de Moura
2ffd929227 feat: improve unification hints
The constraints don't need to be in the same universe anymore.
The new test demonstrates why this is useful.
2020-11-28 19:03:21 -08:00
Leonardo de Moura
ebba9d119d feat: unification hints 2020-11-27 18:12:49 -08:00
Leonardo de Moura
0869f38de4 chore: update structure, class, inductive 2020-11-27 15:09:30 -08:00
Leonardo de Moura
5981553e11 chore: remove workaround 2020-11-27 13:15:31 -08:00
Leonardo de Moura
c0db9f1e0c chore: adjust stdlib to recent changes 2020-11-27 12:26:07 -08:00
Leonardo de Moura
fcc382df08 fix: improve Offset.lean
It did not support for assigned metavariables.
2020-11-27 08:40:43 -08:00
Leonardo de Moura
eabbb6eca0 feat: improve [defaultInstance]
cc @Kha
2020-11-25 18:33:06 -08:00
Leonardo de Moura
975271e1a3 feat: hide inaccessible names and add pp.inaccessibleNames
@Kha We will probably have to refine the heuristic for hiding the
inaccessible names, but the first version is already useful.
Here is the error message for a `_` before this commit
```
error: don't know how to synthesize placeholder
context:
x✝⁴ : List Nat
x✝³ : Nat
x✝² : x✝⁴ ≠ []
a b x✝¹ : Nat
x✝ : [a, b] ≠ []
⊢ Nat
```
After
```
error: don't know how to synthesize placeholder
a b : Nat
 : [a, b] ≠ []
⊢ Nat
```
2020-11-25 17:22:09 -08:00
Leonardo de Moura
276a8b99dd refactor: move ppGoal to Meta
We need `MetaM` methods such as `isProp` to improve `ppGoal`.
This commit also moves `currNamespace` and `openDecls` to
`Core.Context`. Without this change, `Meta.ppExpr` was not taking
`open` commands into account.
2020-11-25 14:17:13 -08:00