Commit graph

216 commits

Author SHA1 Message Date
Leonardo de Moura
0c1fda999e chore: cleanup 2020-10-17 09:00:05 -07:00
Leonardo de Moura
96d4c3d49b chore: move to new frontend 2020-10-17 08:54:40 -07:00
Leonardo de Moura
6c9f000885 chore: move to new frontend 2020-10-17 08:33:58 -07:00
Leonardo de Moura
2cc620a464 chore: move to new frontend 2020-10-17 08:31:20 -07:00
Leonardo de Moura
072906eb70 chore: move to new frontend 2020-10-17 08:18:33 -07:00
Leonardo de Moura
16646e2a93 chore: move to new frontend 2020-10-17 08:14:04 -07:00
Leonardo de Moura
728ff419c7 chore: move to new frontend 2020-10-17 08:10:20 -07:00
Leonardo de Moura
152f275aac chore: move to new frontend 2020-10-17 08:02:30 -07:00
Leonardo de Moura
f0bc72c2c1 chore: move to new frontend 2020-10-17 07:59:45 -07:00
Leonardo de Moura
4925bf22d4 chore: move to new frontend 2020-10-17 07:40:34 -07:00
Leonardo de Moura
0472f38dc8 chore: move to new frontend 2020-10-17 07:38:44 -07:00
Leonardo de Moura
9433124048 chore: move to new frontend 2020-10-17 07:35:58 -07:00
Leonardo de Moura
5ab15d4e60 chore: move to new frontend 2020-10-17 07:25:50 -07:00
Leonardo de Moura
ced9d88cc6 chore: move to new frontend 2020-10-17 07:24:10 -07:00
Leonardo de Moura
c75d0350ec chore: move to new frontend 2020-10-17 07:19:59 -07:00
Leonardo de Moura
eabee9ce7e chore: remove optParam at Eval.lean 2020-10-16 11:50:53 -07:00
Leonardo de Moura
6a7e997534 chore: improve error message 2020-10-15 10:44:16 -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
82e11c401d fix: #eval was not capturing dbgTrace! output in pure code
In the following example, the output produced by `dbgTrace!` was not
being captured. It could break the lean server. At least, it broke the lean4-mode.
```lean
def f (x : Nat) : Nat :=
dbgTrace! ">>> " ++ toString x;
x + 1

eval f 10
```

cc @Kha
2020-10-05 10:22:04 -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
27be7e6812 fix: leaking isDefEqStuckExceptionId 2020-09-25 18:48:23 -07:00
Leonardo de Moura
66d35cdd76 fix: the generated matcher must be able to eliminate into different universe levels 2020-09-24 19:34:14 -07:00
Leonardo de Moura
98f7e9b3e4 chore: naming convention 2020-09-24 19:22:24 -07:00
Leonardo de Moura
7edc52682b fix: processNonVariable 2020-09-24 17:16:50 -07:00
Leonardo de Moura
6a51ec8427 fix: missing case (kernel projection) at isExprDefEqAuxImpl 2020-09-23 18:24:56 -07:00
Leonardo de Moura
a5ee729554 chore: cleanup ExprDefEq a bit 2020-09-23 18:24:56 -07:00
Leonardo de Moura
6ac2f50d94 fix: Expr.proj case at whnfCoreImp 2020-09-23 18:24:56 -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
bd01093388 feat: add Meta.forEachExpr 2020-09-23 18:24:56 -07:00
Leonardo de Moura
8135d37ddb feat: add MatcherApp.addArg
Helper method for adding a new (dependent) argument to a (dependent) matcher.
2020-09-22 18:56:02 -07:00
Leonardo de Moura
3586337c56 perf: handle easy case efficiently 2020-09-22 18:55:13 -07:00
Leonardo de Moura
661548a2fe refactor: move mkArrow to MetaM 2020-09-22 18:55:02 -07:00
Leonardo de Moura
1256fc3cbc refactor: move MatcherInfo methods to Meta namespace 2020-09-22 16:59:21 -07:00
Leonardo de Moura
a397b3d2ae feat: add matchMatcherApp? 2020-09-22 16:54:54 -07:00
Leonardo de Moura
bbc1f4d461 fix: throwAppTypeMismatch should be polymorphic
We use it from `TermElabM` and `MetaM`, and they have different
`TermElabM` implementations.
2020-09-22 09:35:59 -07:00
Leonardo de Moura
b0564a32b9 feat: add AttrM
We are going to use `AttrM` to implement solution 2 described at https://github.com/leanprover/lean4/issues/175
2020-09-21 16:44:20 -07:00
Leonardo de Moura
052e67d1af feat: rewrite tactic 2020-09-18 16:13:14 -07:00
Leonardo de Moura
f7bd174bb8 chore: improve error message 2020-09-18 15:23:28 -07:00
Leonardo de Moura
43bc429abf fix: typo 2020-09-18 15:18:20 -07:00
Leonardo de Moura
5a24cb5ef7 feat: add hygienicIntro option
@Kha `hygienicIntro` is true by default. `hygienicIntro == false` is
the Lean3 behavior. If we find `hygienicIntro` too inconvenient in
practice, we set the default to false.
2020-09-18 13:02:38 -07:00
Leonardo de Moura
12aabcb731 feat: add introNP and intro1P
Versions of `introN` and `intro1` that preserve the binder name.
They are used to implement the idiom: "revert", do something, re-"intro"-tuce
Before this commit `introNP mvarId n` was `intro1 mvarId n [] false`.
2020-09-18 12:35:25 -07:00
Leonardo de Moura
a28679358e refactor: remove MonadError 2020-09-18 09:58:13 -07:00
Leonardo de Moura
0d295560c3 feat: add replaceLocalDecl
It preserves the location of the local declaration.
@Kha This tactic is going to be used to fix another hygiene related bug in
Lean3 :)
Here is small repro for the problem.
```
example (m n k : ℕ) (h : 0 + n = m) (h : k = m) : ...  :=
begin
  -- Here `h : k = m` is accessible.
  rw [nat.zero_add] at *
  -- `h : k = m` is not accessible anymore, and it is a name for
  -- the simplified `h : n = m` which was inaccessible before.
end
```
2020-09-17 19:27:48 -07:00
Leonardo de Moura
36bfe7b266 feat: add assertAfter tactic 2020-09-17 19:25:53 -07:00
Leonardo de Moura
59bf4defc6 fix: default value 2020-09-17 15:58:29 -07:00
Leonardo de Moura
3dbe2076b9 refactor: Target&LocalDecl => Replace 2020-09-17 13:59:22 -07:00
Leonardo de Moura
4ea8db2722 chore: cleanup 2020-09-17 13:50:40 -07:00