Commit graph

46 commits

Author SHA1 Message Date
Leonardo de Moura
d334bb1fa7 chore(*): remove more stuff 2018-08-23 15:56:31 -07:00
Leonardo de Moura
5f65b3a6f1 chore(library/tactic): remove unused bindings 2018-08-23 15:04:23 -07:00
Leonardo de Moura
ed5d884d8f chore(library/tactic): remove app_builder_tactics 2018-08-23 14:22:00 -07:00
Leonardo de Moura
e9f843ddf6 refactor(kernel/expr): remove mlocal_* functions
The constructors `mvar` and `fvar` have different memory layouts.
2018-06-22 14:25:31 -07:00
Leonardo de Moura
a7d08d2f3d feat(kernel/inductive/inductive): dependent elimination for inductive predicates
In Lean4, we will not generate non dependent recursors for inductive
predicates. The main goal is to make the shape of the automatically
generated recursors more uniform. The non uniform representation is
leftover from Lean2. In Lean2, we wanted to support different kernels
with different features. For example: we could create proof relevant
kernels, no impredicative universe, etc.
Recall that, in a kernel with an impredicative Prop and no proof
irrelevance, inductive predicates without dependent elimination are
weaker that inductive predicates with dependent elimination.
When proof irrelevance is enabled, we can generate the dependent
recursor from the non dependent one. Actually, the module drec.cpp
generates the dependent recursor.
Now, we only support one kind of kernel, and it doesn't make sense
anymore to generate non dependent recursors for inductive predicates.
This would only produce an unnecessary asymmetry on the inductive
datatype module.

Remark: we had to create non dependent recursors to help the elaborator.
This can be avoid if we improve the elaborator. I will do that in the
new elaborator implemented in Lean.

Remark: equation lemmas are broken for definitions that pattern match on
nested inductive datatypes. The problem is the super messy
`prove_eq_rec_invertible_aux` function. This function will not be needed
after I finish the new inductive datatype support in the kernel.

cc @kha
2018-06-12 13:03:26 -07:00
Leonardo de Moura
e90585737f refactor(*): use C++11 std::current_exception and std::rethrow_exception
With these new C++11 APIs, we can delete the `clone` and `rethrow`
methods from our exception classes.
2018-06-07 16:28:54 -07:00
Leonardo de Moura
6333043adf refactor(kernel): abstract_local(s) ==> abstract 2018-06-07 16:28:54 -07:00
Leonardo de Moura
bdea7d420d chore(*): type_context ==> type_context_old 2018-03-05 12:38:24 -08:00
Leonardo de Moura
421f2c2ae2 fix(library/tactic/subst_tactic): subst was creating type incorrect motive when using dependent elimination
This commit fix a bug reported at comment
https://github.com/leanprover/lean/issues/1827#issuecomment-368258713

Remark: the original problem reported at issue #1827 has nothing to do
with this bug.
2018-02-26 14:02:10 -08:00
Leonardo de Moura
5607884787 feat(library/tactic): use new cache
Remark: so far, caching, in the tactic framework, only makes a difference for the `simp` tactic.
This is not surprising since the simplifier tries to apply rewriting
lemmas over and over again.
2018-02-21 15:04:20 -08:00
Leonardo de Moura
5bad6d5372 feat(library/init/meta/tactic): subst supports heterogeneous equalities that are actually homogeneous 2018-01-12 14:32:49 -08:00
Leonardo de Moura
fb2186334a fix(library/init/meta/relation_tactics,library/tactic/subst_tactic): fixes #1772 2017-08-21 14:51:30 -07:00
Leonardo de Moura
9afb53fad5 feat(kernel/expr): allow metavariables to have user-facing names
We need this feature for:
1) Defining nonlinear search patterns. Example: (?m <= ?m + 1)
2) Preprocessing recursive equations and support the pattern
refinement approach used in Agda. Example: in Agda, they accept
```
def append {A : Type} : Π (m n : nat), Vec A m -> Vec A n -> Vec A (m + n)
| m n nil            ys := ys
| m n (cons m' x xs) ys := cons x (append m' n xs ys)
```
These equations have to be refined. For example, `m` has to be
replaced with `0` (in the first equation), and `succ m'` in the
second. To implement this kind of refinement, we need to convert
the pattern variables (local constants) into metavariables during
elaboration. Then, the unassigned metavariables become local constants
again. This preprocessing step will fix some of the issues on #1594.
To completely fix #1594, we will need yet another preprocessing step
which will implement "complete transition" used in the equation
compiler before we start elim_match.cpp
2017-07-16 07:16:41 -07:00
Leonardo de Moura
b42ae2cf54 fix(library/type_context): fixes #1500 2017-03-31 19:19:44 -07:00
Leonardo de Moura
3322adde1b fix(library/tactic/subst_tactic): fixes #1467 2017-03-17 19:54:35 -07:00
Leonardo de Moura
740d42ea45 fix(library/tactic): we should preserve names when using the revert/do_something/intro idiom 2017-03-11 12:20:39 -08:00
Sebastian Ullrich
4d41b03168 chore(frontends/lean,library/tactic): remove old tactic_state functions 2017-02-17 15:41:58 +01:00
Leonardo de Moura
53667dd602 fix(library): change API and make sure we don't crash when searching for a non existing local decl
Fixes #1363

After error recovery has been implemented in the elaborator, a few
assumptions made in the type context are not valid anymore since we may
be recovering from errors, and the local and metavariable contexts may
be invalid.

I used the approach used in the class environment.

- find* methods return optional<...>
- get* methods throw exception for unknown elements

Remarks:

I preserved code patterns such as

     optional<local_decl> d = lctx.find_local_decl(...)
     lean_assert(d)

and did not convert them into

     local_decl d = lctx.get_local_decl(...)

Reason: the intention is clear that the local must be defined there.
If it is not we should analyze the problem and decide whether we should
throw an exception or not.

However, I converted code patterns such as

    local_decl d = *lctx.find_local_decl(...)

into

    local_decl d = lctx.get_local_decl(...)

Disclaimer: this change fixes issue #1363, but it may obfuscate other bugs.
2017-02-07 09:38:19 -08:00
Gabriel Ebner
5fdc737dfc feat(library/tactic): store name of current declaration in tactic_state 2017-01-28 08:27:19 +01:00
Leonardo de Moura
94f16d1e44 refactor(library/tactic): move defeq_canonizer::state to tactic_state
It was being stored in the environment before. This was very hackish,
and it was producing a series of unnecessary environment updates, and
thread local caches invalidations.

The new test tests/lean/run/heap.lean is 5x-6x faster after this commit.
2017-01-07 10:17:51 -08:00
Leonardo de Moura
5f87ec3356 feat(library/tactic): allow user to write their own pretty printer for tactic states 2016-12-30 18:58:50 -08:00
Leonardo de Moura
78f81034c6 feat(library): add helper methods 2016-08-29 08:31:33 -07:00
Leonardo de Moura
b317d4bc58 refactor(library/tactic): add hsubstitution module 2016-08-29 08:19:05 -07:00
Leonardo de Moura
206bf613d5 feat(library/tactic/subst_tactic): use substitutions instead of name_map<name> in the subst_tactic (low level) API 2016-08-28 13:29:44 -07:00
Leonardo de Moura
c032505023 chore(library/tactic/subst_tactic): missing '\n' in trace msg 2016-08-25 13:45:04 -07:00
Leonardo de Moura
8e63769413 chore(library/tactic/subst_tactic): remove 'static' to avoid warning in release mode 2016-08-22 09:23:18 -07:00
Leonardo de Moura
1ea3bc1683 fix(library/tactic/cases_tactic): lowlevel interface that gives access to renamed/introduced hypotheses 2016-08-21 15:55:56 -07:00
Leonardo de Moura
f7b9702438 fix(library/tactic/subst_tactic): typo 2016-08-21 15:55:56 -07:00
Leonardo de Moura
0f224ff437 fix(library/tactic/subst_tactic): incorrect depends_on 2016-08-16 11:19:06 -07:00
Leonardo de Moura
2ac7b5afca fix(library/tactic/subst_tactic): typo 2016-07-15 13:52:55 -04:00
Leonardo de Moura
de0ae18dd1 feat(library/tactic/subst_tactic): add low-level subst tactic for internal use 2016-07-14 18:00:29 -04:00
Leonardo de Moura
59f2b9e8c2 refactor(library/type_context): "metavar_context & m_mctx" ==> "metavar_context m_mctx" 2016-06-25 13:08:03 -07:00
Leonardo de Moura
7390e8afda refactor(library/app_builder): simplify app_builder API 2016-06-22 16:57:49 -07:00
Leonardo de Moura
38810ad4c1 refactor(library/tactic/subst_tactic): subst take a local instead of a name 2016-06-22 15:13:49 -07:00
Leonardo de Moura
359b566088 feat(library/tactic/subst_tactic): add tracing for subst tactic 2016-06-21 16:31:53 -07:00
Leonardo de Moura
397ea25e24 fix(library/tactic/subst_tactic): use intermediate state for errors 2016-06-20 10:22:36 -07:00
Leonardo de Moura
73b21b9e48 fix(library): assertion violations 2016-06-17 13:16:17 -07:00
Leonardo de Moura
cb9b5650b7 feat(library/tactic): add 'subst' tactic 2016-06-14 21:01:57 -07:00
Leonardo de Moura
aeee79da2b chore(library): library/tactic => library/old_tactic 2016-06-06 16:38:27 -07:00
Leonardo de Moura
d8079aa16a refactor(library): create copy of the kernel type_checker in library
Motivation: it will allow us to simplify the kernel type_checker and
make sure it implements the same API provided by type_context
2016-03-18 14:34:10 -07:00
Leonardo de Moura
c9e9fee76a refactor(*): remove name_generator and use simpler mk_fresh_name 2016-02-11 18:05:57 -08:00
Leonardo de Moura
69be4c720c fix(library/tactic/subst_tactic): bug in 'subst' tactic 2015-06-12 12:11:44 -07:00
Leonardo de Moura
d0d3f9bb41 refactor(kernel,library,frontends/lean): add helper functions, and cleanup collect_locals 2015-06-05 17:29:36 -07:00
Leonardo de Moura
68688ecdf6 fix(library/tactic/subst_tactic): in the standard mode, use dependent elimination in the subst tactic (when needed)
Before this commit, the subst tactic was producing an type incorrect
result when dependent elimination was needed (see new test for an example).
2015-06-03 17:36:04 -07:00
Leonardo de Moura
d0987eb3ac feat(library/tactic): add 'subtvars' tactic 2015-05-25 16:36:44 -07:00
Leonardo de Moura
a3f23d5233 feat(library/tactic): add improved 'subst' tactic 2015-05-25 15:03:59 -07:00