Commit graph

74 commits

Author SHA1 Message Date
Leonardo de Moura
80a0200ab2 chore: move to new frontend
@Kha another significant milestone: all files at `src/Lean/Meta` are
being compiled with the new frontend.
2020-10-20 10:59:02 -07:00
Leonardo de Moura
ef18b0ab49 chore: use [builtinInit] 2020-10-19 14:58:38 -07:00
Leonardo de Moura
ab047cc4d1 chore: remove unnecessary file 2020-10-19 12:12:03 -07:00
Leonardo de Moura
a3429caaf4 chore: move to new frontend 2020-10-18 08:27:58 -07:00
Leonardo de Moura
eabee9ce7e chore: remove optParam at Eval.lean 2020-10-16 11:50:53 -07:00
Leonardo de Moura
9af0a0e18b feat: add withReader method
@Kha `withReader` is a well-behaved version of `adaptReader`. `adaptReader` is
too general, and it often produces counterintuitive elaboration
errors.

Here are two super annoying issues I hit all the time:
1- `adaptReader` + polymorphic code
```
def ex1 : ReaderT Nat IO Unit :=
adaptReader (fun x => x + 1) $
  IO.println "foo" -- 3 Errors here failed to synthesize `Monad ?m` and  `MonadIO ?m`, and don't know how to synthesize `Type → Type`
```

2- `adaptReader` and notation that requires the expected type
```
structure Context :=
(x y : Nat)

def ex2 : ReaderT Context IO Nat :=
adaptReader (fun s => { s with x := 10 }) $ -- Error at the structure instance
  ...
```
In the example above, I have to write `fun (s : Context) => ...` to
fix the problem.

The two problems above happen in the old and new frontends. However,
there is a new problem specific for the new frontend. In the new
frontend, a `do` is only elaborated when the expected type is known.
So, `adaptReader (fun ctx => ...) do ...` seldom works :(

As I said above, the issue is that `adaptReader` is too general. Its
type is
```
  {ρ ρ' : Type u_1} → {m m' : Type u_1 → Type u_2} → [MonadReaderAdapter ρ ρ' m m'] → {α : Type u_1} → (ρ' → ρ) → m α → m' α
```

`withReader` is a simpler version of `adaptReader`
```
withReader : {ρ : Type u_1} → {m : Type u_1 → Type u_2} → [MonadWithReader ρ m] → {α : Type u_1} → (ρ → ρ) → m α → m α
```
It doesn't have any of the problems above. Moreover, I managed to replace
every single instance of `adaptReader` with `withReader` at the stdlib
and tests. We don't need the `adaptReader` generality.
2020-10-13 15:00:17 -07:00
Leonardo de Moura
fa6b7b6393 feat: add MonadResolveName type class
`AttrM` can now resolve names.
2020-10-10 11:33:52 -07:00
Leonardo de Moura
a3218dd063 refactor: export Core.mkFreshUserName to Lean namespace 2020-09-30 11:21:46 -07:00
Sebastian Ullrich
2d8c7e4fd0 fix: MetaM.run' 2020-09-29 07:59:22 -07:00
Leonardo de Moura
49c5c5c08a fix: horrible error message due to constApprox := true
The new test `typeMismatch.lean` contains two examples where the error
message was dreadful.
2020-09-29 07:54:48 -07:00
Leonardo de Moura
0174004b1c feat: improver error message generation for termination checking 2020-09-23 18:24:56 -07:00
Leonardo de Moura
661548a2fe refactor: move mkArrow to MetaM 2020-09-22 18:55:02 -07:00
Leonardo de Moura
052e67d1af feat: rewrite tactic 2020-09-18 16:13:14 -07:00
Leonardo de Moura
a28679358e refactor: remove MonadError 2020-09-18 09:58:13 -07:00
Leonardo de Moura
71f91cca23 chore: make sure isClass? return none when argument contains type errors
This is particularly useful for the delaborator when trying to pretty
print code that contains type errors.
2020-09-17 08:24:06 -07:00
Sebastian Ullrich
607227dc7f feat: delaborator: tolerate ill-typed terms (such as IR) 2020-09-17 08:12:28 -07:00
Leonardo de Moura
544d2f4ce5 fix: kind for type metavariable
For example, `mkFreshExprMVar none MetavarKind.synthetic` should
create a fresh synthetic metavariable `?m` with type `?t` where `?t`
is a fresh natural metavariable. If users want a synthetic
metavariable `?t`, then it must create it themselves.
2020-09-16 08:24:15 -07:00
Leonardo de Moura
0abca5475f refactor: move ppExpr to IO
@Kha I am also tracking `currNamespace` and `openDecls`.

BTW, I also tried an experiment where I added `currNamespace` and
`openDecls` to `Meta.Context`, but it looked weird. This information
is only needed in the elaborator and pretty printer.
The `PPContext` object should contain everything you need. You
can put `currNamespace` and `openDecls` in the `Delaborator.Context`.
2020-09-15 18:48:21 -07:00
Leonardo de Moura
e181c1adee refactor: add DefEqM
The idea is to make clear that the field `posponed` is transient
state. It is only used during `isDefEq`.
The refactoring was motivated by a bug I found where the `posponed`
constraints were not being handled correctly. For example,
the `check (e : Expr)` method was returning `true`, but leaving pending
universe constraints at `postponed`.

cc @Kha
2020-09-12 16:42:16 -07:00
Leonardo de Moura
f28def6c5e feat: add Meta.ppExpr 2020-09-10 17:27:14 -07:00
Leonardo de Moura
96ffd206ca feat: add findRecArg 2020-09-08 17:25:35 -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
f30b5bdcba chore: control code size explosion 2020-09-07 07:23:44 -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
12f69a78b7 chore: change meaning of lambdaTelescope
`lambdaTelescope` now only consumes `lambda`s.
`lambdaLetTelescope` implements the old behavior.
2020-09-04 13:35:17 -07:00
Leonardo de Moura
f34fd3e6b4 refactor: move Closure.lean to Meta
We will need to improve the support for let-decls. We will use
the new `trackZeta`.
2020-09-03 11:54:08 -07:00
Leonardo de Moura
ad774ae397 feat: support for tracking which let-decls have been zeta expanded 2020-09-03 11:32:46 -07:00
Leonardo de Moura
238c38fed9 feat: preserve nonDep flag at LocalDecl.ldecl 2020-09-03 09:08:59 -07:00
Leonardo de Moura
f2a6562eed feat: validate 'let rec' types 2020-09-02 17:02:40 -07:00
Leonardo de Moura
e5c35d3a4e feat: add AddMessageDataContext 2020-08-28 18:05:42 -07:00
Leonardo de Moura
99f3296828 refactor: simplify Util/Trace.lean 2020-08-28 17:36:44 -07:00
Leonardo de Moura
39d456cb09 feat: add polymorphic trace and logTrace
This commit also makes sure we always use `withContext` when logging.
2020-08-28 16:49:24 -07:00
Leonardo de Moura
62177069fd fix: induction tactic 2020-08-28 09:18:22 -07:00
Leonardo de Moura
7a6effa54f chore: cleanup 2020-08-27 15:47:58 -07:00
Leonardo de Moura
691e73ca3a fix: collect metavars occurring in delayed assignments 2020-08-27 14:59:54 -07:00
Leonardo de Moura
7db6f420f5 refactor: move mkAuxDefinitionCore 2020-08-26 16:20:09 -07:00
Leonardo de Moura
813a964767 refactor: move polymorphic Meta methods back to Meta namespace 2020-08-25 14:57:58 -07:00
Leonardo de Moura
cf0149a1a7 refactor: use MonadControlT 2020-08-25 13:54:42 -07:00
Leonardo de Moura
49f5e4db20 refactor: cleanup 2020-08-24 17:47:27 -07:00
Leonardo de Moura
eaed6ba6a3 refactor: polymorphic MetaM combinators 2020-08-24 17:03:54 -07:00
Leonardo de Moura
ac565de96c refactor: add MonadMetaM class 2020-08-24 12:17:47 -07:00
Leonardo de Moura
57a6998426 chore: minor 2020-08-24 12:17:47 -07:00
Leonardo de Moura
5b23b5302f refactor: move TransparencyMode to its own file 2020-08-24 12:17:47 -07:00
Leonardo de Moura
143760d443 refactor: polymorphic withIncRecDepth 2020-08-24 12:17:47 -07:00
Leonardo de Moura
4f14fe3b79 refactor: polymorphic withRef 2020-08-24 12:17:47 -07:00
Leonardo de Moura
6fc935f6d1 refactor: add MonadNameGenerator 2020-08-23 19:56:01 -07:00
Leonardo de Moura
50f779e858 refactor: polymorphic setTraceState, getTraceState, etc 2020-08-23 19:10:38 -07:00