Commit graph

3310 commits

Author SHA1 Message Date
Leonardo de Moura
73b1e927ff chore(tests/lean): fix tests 2017-02-11 18:37:15 -08:00
Leonardo de Moura
9210e45da0 feat(frontends/lean): add notation for ';' and '<|>' in the tactic interactive mode 2017-02-10 22:53:30 -08:00
Leonardo de Moura
8bd5a51db4 test(tests/lean/run/quote_base): add example from Bas' paper 2017-02-10 18:34:53 -08:00
Johannes Hölzl
9902a0d4d1 feat(src/library/tactic): apply_core returns list of all generated metavariables 2017-02-10 16:07:33 -08:00
Johannes Hölzl
bb136d63ab feat(src/library/tactic): tactic.cases_core returns for each new goal the used constructor, a list of introduced hypotheses, and substitutions for dependent hypotheses 2017-02-10 16:07:33 -08:00
Johannes Hölzl
d7af5515d2 feat(src/library/tactic): tactic.induction_core returns for each new goal the list of introduced hypotheses and substitutions for dependent hypotheses
Also add to_obj(buffer<vm_obj>) to construct a vm-list of vm objects.
2017-02-10 16:07:33 -08:00
Leonardo de Moura
c35108cf0d fix(library/tactic): fixes #1369
- `eval_expr` instantiate assigned metavariables occuring in the input
  expression.
- Rename pp.instantiate_goal_mvars to pp.instantiate_mvars
- `format_expr` also instantiates assigned metavariables before pretty printing
  when pp.instantiate_mvars is set to true.
2017-02-10 15:58:27 -08:00
Leonardo de Moura
7a58da1181 fix(library/tactic/user_attribute): nasty interaction between eval_expr and attribute_manager
eval_expr creates auxiliary definitions in the VM. These auxiliary
definitions are gone after the VM finishes.

We store vm_obj's in the attribute_manager.

Before this commit, Lean was crashing in the following scenario:

1- A new caching_user_attribute is defined, and the user data structure
contains closures.

2- The closures are created using eval_expr.

3- When reusing the cached values, the system crashes when trying
to apply a closure created using eval_expr. The closure points to
an auxiliary definition that has already been deleted.

The new test exposes the problem. This is not a hypothetical scenario,
the new test is based on the Lean - Mathematica integration being
developed by @rlewis1988.

The fix consists in making sure we do not cache anything if
the VM environment has been updated by eval_expr.

I believe this is acceptable behavior. eval_expr is a very low level
tactic, and I don't see a good motivation for invoking it when
constructing the cache.

BTW, the test can be relaxed if the vm_attr does not contain closures.
However, it doesn't seem to pay off.

Another potential fix would be to propagate the definitions created
by eval_expr to the main environment. However, I think this is not
acceptable.
We will be flooding the main environment with useless temporary definitions
created by `eval_expr`.

This commit also stores the environment at caching time, and make
sure the cache is only reused if the current environment is a descendant
of the the one at caching time. This is fixing a different potential
bug.
2017-02-10 15:24:01 -08:00
Leonardo de Moura
6334ff24eb fix(frontends/lean/tactic_notation): erase position information quoted terms occurring inside `[...]
See new test for understanding the problem.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2017-02-09 19:06:56 -08:00
Leonardo de Moura
c0e6314f14 fix(library/init/meta,library/tactic/elaborate): bad error position when to_expr is used outside of interactive mode 2017-02-09 18:44:50 -08:00
Leonardo de Moura
add5266df7 fix(frontends/lean, library/tactic): error position in auto quoted terms
This commit also gets rid of the redundant "elaborator failed" error
message.
2017-02-09 18:03:04 -08:00
Leonardo de Moura
898894ffaa feat(frontends/lean/parser): syntax sugar for auto_param gadget 2017-02-09 16:06:55 -08:00
Leonardo de Moura
c8bbb34e2a feat(frontends/lean): add auto_param gadget 2017-02-09 15:49:10 -08:00
Leonardo de Moura
5e397795cf fix(library/init/meta): focus tactic
This commit also add the interactive tactic 'focus'
2017-02-09 10:02:19 -08:00
Leonardo de Moura
e4b3dee526 feat(library/simplify): use custom matcher in the simplifier, and remove hack from type_context
@joehendrix This commit is implementing the matcher that postpones
implicit arguments. The lemma get_data_mk_byte can be proved without
using any hacks in the type_context unifier.

I also added the trace class: simplify.implicit_failure
If we use the command

   set_option trace.simplify.implicit_failure true

Then, the simplifier will generate a diagnostic message every time it
succeeds in the explicit part, but fails in the implicit one.

Please feel free to suggest a better name to his option.

BTW, we can now easily extend the matcher with additional features.
I'm wondering if we will eventually want to write some of these
extensions in Lean.
2017-02-08 22:24:13 -08:00
Leonardo de Moura
f5e0fc4876 fix(frontends/lean/elaborator): '{}' inside quotations 2017-02-08 17:50:17 -08:00
Leonardo de Moura
32e6442d0a feat(frontends/lean): no global universes in the frontend 2017-02-08 17:23:04 -08:00
Leonardo de Moura
c5dc8e651a chore(library/init/meta): cleanup 2017-02-08 15:33:25 -08:00
Leonardo de Moura
7df64e6e7b feat(library/data): add lazy_list 2017-02-08 12:01:46 -08:00
Leonardo de Moura
2c0a5a5120 fix(library/compiler/erase_irrelevant): remove broken io monad optimization
It doesn't work when combined with inlining and common-subexpression-elimination
2017-02-07 21:24:31 -08:00
Leonardo de Moura
a8c91aa6fc fix(library/compiler/preprocess): expand eq.cases_on
The code generator was failing to erase eq.cases_on.
2017-02-07 21:19:01 -08:00
Leonardo de Moura
54f7bf9391 fix(frontends/lean, library/tactic): remove redundant error messages, and fix position of error messages
Summary:

We minimize the number of "'sorry' used warning messages".  We also
re-target the error to the main declaration. Example: foo._main ==> foo
We do not report for auxiliary declarations such as "_example" and
"foo.equations._eqn_1"

Get rid of the redundant error message "error : failed" for tactics.
We added "silent failures" in the tactic framework.

We do not store line/col information for tactics nested in notation
declarations.  Before this commit, we would have tactics such
as (tactic.save_info line col) nested inside of notation declarations.
2017-02-07 20:25:28 -08:00
Leonardo de Moura
a28d6a94fd feat(library/init/meta): add any_goals tactic 2017-02-06 16:23:29 -08:00
Gabriel Ebner
572c9a0de0 chore(tests/lean): fix tests after error-recovery 2017-02-06 15:15:47 +01:00
Gabriel Ebner
7946b15511 feat(frontends/lean/elaborator): recover from most errors using sorry 2017-02-06 15:15:44 +01:00
Gabriel Ebner
98f41d9b15 feat(interactive/test_single): colorized diff 2017-02-06 15:08:45 +01:00
Leonardo de Moura
55aa2023f4 feat(frontends/lean): add support for monad_fail type class in 'do' blocks 2017-02-05 20:09:08 -08:00
Leonardo de Moura
8b662d19ac feat(library/init/category/monad_fail): add monad_fail type class 2017-02-05 18:46:29 -08:00
Leonardo de Moura
797b26f402 fix(frontends/lean/tactic_notation): trace messages in nested blocks were not being displayed in the correct place 2017-02-05 18:20:10 -08:00
Leonardo de Moura
30a1876fc8 feat(library/init/meta): add add_aux_decl and abstract tactics 2017-02-05 16:00:47 -08:00
Leonardo de Moura
323db5a530 feat(frontends/lean/pp): pretty print structure instances and field projections 2017-02-05 14:01:53 -08:00
Gabriel Ebner
6910f3f2b9 feat(frontends/lean/print_cmd): show sorry macro as axiom 2017-02-05 14:01:08 +01:00
Gabriel Ebner
95068e4e79 feat(library/sorry): make sorry a macro 2017-02-05 14:01:03 +01:00
Gabriel Ebner
252931a470 feat(tests/lean/test_single): show unified diffs with color 2017-02-05 13:44:21 +01:00
Leonardo de Moura
84188c5aa1 feat(frontends/lean/elaborator): add pattern validator in the elaborator
@johoelzl We now produce a better message for your example:

   inductive R : ℕ → Prop
   | pos : ∀p n, R (p + n)

   lemma R_id : ∀n, R n → R n
   | (.p + .n) (R.pos p n) := R.pos p n

The new error is:

file.lean:5:2: error: invalid function application in pattern, it cannot be reduced to a constructor (possible solution, mark term as inaccessible using '.( )')
  .p + .n
2017-02-04 19:00:20 -08:00
Leonardo de Moura
9869ed1026 feat(library/equations_compiler/util): make sure "inaccessible annotations" do not leak into the type of automatically generated equational lemmas 2017-02-04 17:19:42 -08:00
Leonardo de Moura
dbb36f5412 feat(library/type_context): improve offset trick in the unifier 2017-02-04 17:15:05 -08:00
Leonardo de Moura
6d9c9b3f9a feat(library/type_context): avoid auxiliary definitions introduced by the equation compiler from being used in the type class resolution procedure
This can only happen in meta definitions, but the user may be confused
by this behavior.
2017-02-04 15:56:54 -08:00
Leonardo de Moura
e4a27a2328 chore(tests/lean/interactive): fix test output 2017-02-04 15:53:01 -08:00
Leonardo de Moura
45eb64add0 chore(tests/lean/run/listex3): we don't need the unit trick anymore 2017-02-04 13:55:51 -08:00
Leonardo de Moura
9e42f7ea30 test(tests/lean/run): add test for meta recursive definition wo recursive equation 2017-02-04 13:53:12 -08:00
Leonardo de Moura
aff5a2dd37 fix(library/init/meta): bug introduced 9bee8ce36d 2017-02-03 17:01:46 -08:00
Leonardo de Moura
2640d3085b fix(library/init/meta/interactive): name resolution problems in parametric sections 2017-02-03 14:04:59 -08:00
Leonardo de Moura
ab94e71e37 feat(library/type_context): do not fail on universe constraints of the form ?u =?= max ?u v
We solve them by creating a fresh metavariable ?w

         ?u := max ?w v

Remark: this is a precise solution.
2017-02-02 22:30:30 -08:00
Leonardo de Moura
b2968f450c fix(frontends/lean/elaborator): use expected type when elaborating application for the form (c^.fn a)
For example, the following definition did not work before this commit:

  protected meta def map {α β} (f : α → β) : lazy_tactic α → lazy_tactic β
  | t s := (t s)^.for (λ ⟨a, new_s⟩, (f a, new_s))
2017-02-02 19:56:50 -08:00
Leonardo de Moura
9bee8ce36d fix(frontends/lean/elaborator): thunk gadget should not be considered in patterns
The new test demonstrates the problem.
2017-02-02 17:28:03 -08:00
Johannes Hölzl
3be8deb2d2 fix(library/tactic/generalize_tactic): instantiate mvars before calling kabstract 2017-02-01 18:48:10 -08:00
Leonardo de Moura
a9821f6437 fix(library/type_context): bug in revert method
We should not assume that the arguments at to_revert are sorted by idx.
This commit fixes the bug reported at:
https://groups.google.com/forum/#!topic/lean-user/x4Zwpou3le0
2017-02-01 10:51:24 -08:00
Leonardo de Moura
6e7929252f feat(frontends/lean, library/init): add 'thunk' gadget
We can now write
   trace "hello" t
instead of
   trace "hello" (fun _, t)
2017-01-31 18:41:59 -08:00
Leonardo de Moura
7cc31835e4 refactor(library/init/meta/fun_info): cleanup fun_info API 2017-01-31 18:01:54 -08:00