Commit graph

62 commits

Author SHA1 Message Date
Leonardo de Moura
19051d9a0d chore(library/init/lean/localcontext): export as C functions 2019-08-16 19:49:17 -07:00
Leonardo de Moura
d707026cd8 feat(library/local_context): ensure local_context is just a wrapper for LocalContext
This is a temporary hack. After we eliminate the old elaborator,
we will delete the C++ class `local_context`.
In Lean4, we will not have two different kinds of local context:
`local_ctx` and `local_context`.
2019-08-07 13:11:08 -07:00
Leonardo de Moura
ae97cfdd68 feat(kernel/local_ctx): use LocalContext 2019-08-07 11:50:20 -07:00
Leonardo de Moura
b27f215b9a chore(library/local_context): simplify pp 2019-08-06 10:27:10 -07:00
Leonardo de Moura
f6b9a0fe9c chore(util/sexpr/format): preparing to switch to Lean implementation 2019-06-07 09:46:34 -07:00
Leonardo de Moura
43ceb6bfbe refactor(kernel/local_ctx): simplify local_ctx
Remark: we still need to revise the classes: `type_context` and `local_context`.
2018-10-24 10:02:38 -07:00
Leonardo de Moura
69070f43eb chore(library/local_context): remove user_name indexing
The datastructures at `local_context` used to manage used user_names
introduce a lot of overhead. They do guarantee that `get_unused_name` is
`O(log(n))`, but they slowdown much more common operations such as:
local declaration creation/deletion. We create/delete local declarations
much more often than we use `get_unused_name`.

The corelib build time is now 34.18 secs on my desktop. It was 39.5 secs.
2018-10-17 09:24:40 -07:00
Leonardo de Moura
03a99986bb feat(kernel): implement local_decl using runtime 2018-09-08 16:25:43 -07:00
Leonardo de Moura
85465885f3 chore(library/type_context): remove "frozen local instances"
We will re-implement the type class resolution algorithm, and the new
implementation will not rely on a persistent cache. We will improve
performance by:
1) Using better indexing data-structures.
2) Using a local cache during the search.
2018-09-07 13:17:37 -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
fd5bfc7dfe refactor(kernel): simplify binder_info
Now, it is an enumeration type like its Lean counterpart.
2018-06-20 15:31:40 -07:00
Leonardo de Moura
0a5e7ff1a9 feat(kernel): add local_ctx
We will have only one kind of local constant (aka free variable) in
Lean4. Thus, we need a local context object to implement the kernel
type checker.
2018-06-06 15:24:10 -07:00
Leonardo de Moura
ff3a3177c3 chore(library/local_context): get_pp_name => get_user_name 2018-06-04 16:08:28 -07:00
Leonardo de Moura
39ef7aeee2 chore(util): remove memory_pool
memory_pool object introduces memory contention and unnecessary
complexity. Moreover, it actually reduces performance when we compile
Lean using JEMALLOC.

Here are the numbers for corelib

jemalloc with memory_pool:    13.83 secs
jemalloc without memory_pool: 13.60 secs
2018-04-12 16:43:10 -07:00
Leonardo de Moura
a962efdcd1 fix(library/tactic/cases_tactic): fixes #1836 2018-02-26 15:32:03 -08:00
Leonardo de Moura
7762dc381a feat(library/type_context): use context_cache interface 2018-02-21 15:04:20 -08:00
Leonardo de Moura
058520d6e4 feat(frontends/lean/pp,library/local_context): use sanitize_name_generator_name
Remark: we should remove `sanitize_if_fresh` as soon as we delete `::lean::mk_fresh_name`
2018-02-21 15:04:19 -08:00
Leonardo de Moura
6060b75e62 fix(library/local_context): propagate m_instance_fingerprint 2018-02-01 17:46:31 -08:00
Leonardo de Moura
559211d284 perf(library/local_context): fix performance bottleneck at local_const
This is one of the performance problems at issue #1646.
The method `local_context::erase_user_name(local_decl const & d)` was
inefficient when there are many locals with the same user facing name.
For size 7 in the example described at issue #1646, the average size of the
declaration list was 400. Here are the runtimes for size 7

Before: 19.021 secs
After:  16.433 secs

There are more performance issues.
2017-06-06 10:01:08 -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
Daniel Selsam
1f6306d068 perf(library/inductive_compiler): simplification with sizeof lemmas 2017-03-01 21:13:20 -08: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
Leonardo de Moura
da945e34de perf(library/equations_compiler/util, library/local_context): preserve instance fingerprint and avoid flushing the cache 2017-01-07 00:17:09 -08:00
Leonardo de Moura
d546671849 chore(library/local_context): style 2017-01-03 15:00:46 -08:00
Leonardo de Moura
34073c6f32 feat(library/tactic/smt/smt_state): improve smt_goal formatting 2017-01-03 13:50:25 -08:00
Gabriel Ebner
4dac796337 feat(library/local_context): make get_unused_name O(log(n)) 2016-09-19 16:38:03 -07:00
Leonardo de Moura
e6dd5242fc feat(library/equations_compiler): add option eqn_compiler.zeta 2016-09-10 14:00:16 -07:00
Leonardo de Moura
532efde665 chore(library/local_context): fix warning 2016-09-09 18:01:39 -07:00
Leonardo de Moura
6c13241d59 feat(library/local_context): add low-level methods for declaring local_decls 2016-09-09 17:43:07 -07:00
Leonardo de Moura
78f81034c6 feat(library): add helper methods 2016-08-29 08:31:33 -07:00
Leonardo de Moura
98aefca014 fix(library/local_context): depends_on should take into account assigned metavariables 2016-08-25 13:49:54 -07:00
Leonardo de Moura
5c0a69657d feat(frontends/lean/pp,library/local_context): nicer pp for fresh names 2016-08-05 19:06:26 -07:00
Leonardo de Moura
bae10d7530 feat(library/type_context): restrict context of metavariables during unification if approximate() is true 2016-08-02 16:31:12 -07:00
Leonardo de Moura
c46403265b feat(library/local_context): add instance_mvars method for local_context object 2016-07-31 02:36:51 -07:00
Leonardo de Moura
cc429b1ab7 refactor(library/local_context,library/type_context): remove frozen mode, cleanup instance cache 2016-07-27 16:07:48 -07:00
Leonardo de Moura
c4953cac43 feat(frontends/lean/elaborator): only use eliminator elaboration is function is fully applied 2016-07-25 17:24:57 -07:00
Leonardo de Moura
394995dff0 fix(library/local_context): missing 'const' 2016-07-12 13:41:42 -04:00
Leonardo de Moura
07388479e6 feat(library/local_context): helper functions 2016-07-05 09:08:11 -07:00
Daniel Selsam
e1bc0a68e6 refactor(simplifier): port skeleton to new tactic framework
Conflicts:
	library/init/meta/tactic.lean
	src/library/tactic/tactic_state.cpp
2016-06-24 15:20:40 -07:00
Leonardo de Moura
fd08a9badf refactor(library/local_context): store pp_name in local_ref's
This commit also removes the now obsolete API get_local_pp_name from abstract_type_context
2016-06-21 10:50:38 -07:00
Leonardo de Moura
125a80ad69 feat(library/tactic): add 'clear' tactic 2016-06-11 20:23:24 -07:00
Leonardo de Moura
6829c81f18 feat(library/tactic): add 'rename' tactic 2016-06-11 19:18:25 -07:00
Leonardo de Moura
c5d56be4ee fix(library/local_context): typo 2016-06-10 18:29:41 -07:00
Leonardo de Moura
181e48e3f3 feat(library/tactic/tactic_state): add tactic_state.to_format 2016-06-09 10:47:17 -07:00
Leonardo de Moura
bd18516ddd fix(library/local_context): typo 2016-05-01 19:01:30 -07:00
Leonardo de Moura
ee27480210 feat(library/type_context): initialize type class resolution 2016-03-27 13:41:07 -07:00
Leonardo de Moura
8038ca5f0c refactor(metavar_context): metavar_decl contains a local_context instead of local_decls
Motivations:
- A goal is essentially a metavar_decl
- We need the local_context to implement restrict_metavars_context method
2016-03-15 12:52:30 -07:00
Leonardo de Moura
a823b0e6ec feat(library/type_context): pop_local for type_context 2016-03-09 10:22:48 -08:00
Leonardo de Moura
fcf3e2e065 fix(library/local_context): typo 2016-03-05 16:57:15 -08:00