Commit graph

1260 commits

Author SHA1 Message Date
Leonardo de Moura
a241bd3328 chore(kernel/type_checker): remove dead code 2018-04-12 16:43:11 -07:00
Leonardo de Moura
efb9fb0802 chore(kernel): remove opportunistic hash consing support
It just adds extra complexity and is in conflict for our plans for
Lean4. Moreover, in our experiments it impacts negatively on
performance: master and lean4 branches. The negative impact has been
confirmed by @kha too.
2018-04-12 16:43:10 -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
1dd7165694 chore(util): remove dead code 2018-04-12 16:43:10 -07:00
Leonardo de Moura
4c14668bf0 chore(util/lru_cache): remove dead code 2018-04-12 16:43:10 -07:00
Leonardo de Moura
8dd53cd94f chore(*): rename expr_struct_* to expr_*
We don't need to modifier `_struct` anymore since we don't use the
pointer equality based hashtables anymore.
2018-04-09 12:55:48 -07:00
Leonardo de Moura
faf8e025e7 chore(kernel): remove m_hash_alloc field from expressions
This field was originally added to create hashtables based on pointer
equality. We don't use them anymore, and the caches based on
m_hash_alloc can be implemented using m_hash without any performance
impact. This commit also fixes two places where `expr_set` was used
instead of `expr_struct_set`.

This commit is also important for the Lean4 plans where `expr` will
be implemented in Lean, and fields like `m_hash_alloc` would require us
to track state.
2018-04-09 10:05:56 -07:00
Leonardo de Moura
173eb1c6b7 refactor(util/fresh_name): implement fresh_name using unique thread id
@kha This commit is retracting the experiment using
`mk_fresh_name_generator_child` when creating new tasks.
The names get too long.

I'm still refactoring the code and trying to eliminate all occurrences
of `mk_fresh_name`. I still have a long way to go, but I am merging
this branch into master since it has many other fixes.
2018-02-23 10:35:04 -08:00
Leonardo de Moura
b16f641179 feat(util/name_generator): name generator prefix bookkeeping 2018-02-21 15:04:19 -08:00
Leonardo de Moura
ce028d651d refactor(kernel): abstract_type_context::mk_fresh_name ==> abstract_type_context::next_name 2018-02-21 15:04:19 -08:00
Leonardo de Moura
c176faed32 feat(kernel/inductive): make sure constructor types do not contain local constants nor metavariables 2018-02-21 15:04:19 -08:00
Leonardo de Moura
2e5b66a5f1 refactor(kernel): make sure kernel does not use global ::lean::mk_fresh_name 2018-02-21 15:04:19 -08:00
Leonardo de Moura
60d04987c8 chore(kernel/inductive/inductive): remove dead global variable 2018-02-21 15:04:19 -08:00
Nuno Lopes
ac6a16ddba feat(msvc): further work on MSVC compatibility 2018-02-06 10:11:09 -08:00
Leonardo de Moura
ec1a490a15 chore(*): annotate candidates for thread local cache reset 2018-02-01 14:59:37 -08:00
Leonardo de Moura
f7bc884ae8 chore(kernel/type_checker): fix compilation warning msgs 2017-12-17 08:44:51 -08:00
Gabriel Ebner
860cc95730 fix(library/compiler/rec_fn_macro): do not type-check in non-meta declarations 2017-12-17 15:47:52 +01:00
Leonardo de Moura
ef784ce7b8 fix(library/tactic/simp_lemmas): auto_params when adding simp lemmas 2017-12-09 09:47:39 -08:00
Leonardo de Moura
bc89ebc19c feat(kernel/inductive): improve how induction hypotheses are named
See doc/changes.md
2017-12-05 15:58:09 -08:00
Leonardo de Moura
458958b9fc feat(kernel/inductive): use ih to name induction hypothesis (instead of ih_1) when there is only one 2017-12-05 13:50:24 -08:00
Leonardo de Moura
64f575a2d5 perf(library/equations_compiler): performance problem for definitions that produce many equational lemmas
The new test and comment at src/library/equations_compiler/util.cpp
explains the issue.
2017-11-22 16:16:11 -08:00
Leonardo de Moura
88cd294a09 feat(src/kernel/error_msgs): show aliased variables when printing error messages
closes #1814

@kenmcmil: the error messages will now list aliased variables.
For example, in your file, the new error message is:

```
invalid type ascription, term has type
  triple (ctxpre c' s_1 ∧ ctxpre c'_1 s_1) (bndngapp b s_1) (ctxpost c' s_1 ∧ ctxpost c'_1 s_1)
but is expected to have type
  triple (ctxpre c' s_1 ∧ ctxpre c'_1 s_1) (bndngapp b s_1) (ctxpost c' s_1 ∧ ctxpost c'_1 s_1)
types contain aliased name(s): c'
remark: the tactic `dedup` can be used to rename aliases
state:
...
```
2017-09-05 16:46:44 -07:00
Gabriel Ebner
9920062b69 fix(kernel/expr,library/constructions/projection): preserve instance-implicitness in structure parameters 2017-08-27 16:47:04 +02:00
Leonardo de Moura
971ae34521 feat(frontends/lean/elaborator): closes #1760
As described at issue #1760, the new error message is:
```
1760.lean:6:18: error: type mismatch at application
  f x
term
  x
has type
  big_type : Type 1
but is expected to have type
  ?m_1 : Type
```
2017-08-21 16:15:03 -07:00
Sebastian Ullrich
46c1a1a844 refactor(frontends/lean/elaborator,kernel/error_msgs): remove duplicate code 2017-07-21 01:46:31 -07:00
Sebastian Ullrich
f8cfc4ea1b feat(kernel/error_msgs,frontends/lean/elaborator): add more context to 'type/function expected' errors 2017-07-21 01:46:31 -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
Gabriel Ebner
1d6716d1fb fix(kernel/type_checker): eagerly check for proof irrelevant definitional equality
Fixes #1716.  @leodemoura I did not observe any performance effect on
the standard library.
2017-07-14 21:46:04 +01:00
Sebastian Ullrich
c209cdc8be fix(kernel/inductive/inductive): identify indices modulo whnf 2017-07-06 20:59:58 -07:00
Leonardo de Moura
04dfd55f94 perf(kernel/expr): fix hash consing performance problem
The kernel support opportunistic hash consing.
At commit e63c79c81e we have enabled this feature during
tactic execution, and fixed performance problems in the Certigrad
project (by @dselsam).
However, this change produced unexpected performance problems in
other Lean files (example: @JasonGross example at issue #1646 was 10x
slower after the commit above).
After analyzing the performance logs, I conjecture the hash_consing
may produce a substantial performance overhead if the following property
doesn't hold.

- Let `cache` be the hash_consing cache, then for each `e` in `cache`,
all children of `e` are also in the `cache`.

If the property above is not true, we may have problem whenever
we add an expression `t` containing multiple copies of a big term `T`.
For example, support we insert `f T_1 T_2`, where `T_1` and `T_2` are
structurally equal but are not pointer equal. Then, if we try to insert
`f T_2 T_1`, we will have to compare the huge terms twice, and the
comparison will be proportional to the size of `T_i`.

This commit tries to address this performance problem by enforcing
the property above. This is not a perfect solution since we may keep
trying to create terms using big terms created before hash_consing
has been enabled. After this commit, the example at issue #1646
is only 1.4x slower. It didn't impact the standard library
compilation (memory nor time).

I'm using this commit is a temporary workaround. We should probably
remove the hash_consing support from the kernel, and implement it
in key places. For example, for Certigrad, we can control memory
consumption by using hash_consing only during `simp`,
`instantiate_mvars` and `elaborator` finalization procedure.

@gebner @kha Any ideas/suggestions for this hash_consing issue?
2017-06-23 12:41:35 -07:00
Leonardo de Moura
82db0f874a fix(kernel/type_checker,library/type_context): add support for macros that cannot be expanded
Fixes #1650
2017-06-07 08:25:21 -07:00
Leonardo de Moura
e204a30685 fix(kernel/replace_fn): check if running out of stack space at replace_rec_fn
See #1646
2017-06-04 15:57:11 -07:00
Leonardo de Moura
4bdb2da1b6 fix(library/equations_compiler): improve pull_nested_rec_fn, and make sure it communicates local propositions to the well founded recursion module
The bin_tree and num_consts examples can now be encoded more naturally.
2017-05-26 10:45:39 -07:00
Leonardo de Moura
7ffd7fea3d feat(kernel): store depth of composite terms and use it in the hash code computation
closes #1589
2017-05-25 16:51:02 -07:00
Sebastian Ullrich
491802409a chore(*): remove unused macro_definition_cell::pp method 2017-05-24 09:51:23 +02:00
Leonardo de Moura
eddc5b0869 chore(kernel/environment): rename method 2017-05-15 14:18:16 -07:00
Sebastian Ullrich
42eb0c680e feat(kernel/inductive,library/inductive_compiler): do not enforce positivity rule on meta inductives 2017-05-14 19:17:28 -07:00
Sebastian Ullrich
d968b9a1c8 fix(frontends/lean/structure_cmd): remove evil Pi overload that accidentally abstracted constants in structure decls 2017-04-26 14:22:36 -07:00
Sebastian Ullrich
3f87755a2a fix(frontends/lean/pp): qualify constant shadowed by local 2017-03-31 09:40:49 -07:00
Sebastian Ullrich
b92af074c0 feat(kernel/pos_info_provider): add save_pos_info
Allows the elaborator to contribute new info locations
2017-03-31 09:40:48 -07:00
Sebastian Ullrich
a50398f837 fix(library/tactic/eval,kernel/kernel_exception): hide internal definition name on eval_expr type error 2017-03-27 13:42:08 -07:00
Gabriel Ebner
42288198db fix(kernel/expr): disable caching by default 2017-03-23 08:57:56 +01:00
Gabriel Ebner
595cbb8fe9 refactor(*): task<T>, log_tree, cancellation_token 2017-03-23 08:57:52 +01:00
Leonardo de Moura
d37fd17725 fix(kernel/level): potential compiler specific behavior 2017-03-11 18:30:28 -08:00
Leonardo de Moura
b69e2006f5 chore(kernel/quotient/quotient): update comments
The comments were written before the Type => Sort change
2017-03-07 14:11:51 -08:00
Leonardo de Moura
544d5c67f4 feat(CMakeLists,kernel): add TRACK_LIVE_EXPRS=ON compilation option 2017-02-28 10:56:14 -08:00
Leonardo de Moura
7c57d23b46 feat(kernel): add compilation flags for disabling has_local optimization and abstraction cache 2017-02-21 19:46:31 -08:00
Leonardo de Moura
1c959f6790 feat(kernel): add compilation flag for disabling "free var range" optimization 2017-02-21 19:40:56 -08:00
diakopter
19606fd197 chore(util,kernel,library): clang warnings 2017-02-17 20:01:34 -08:00
Sebastian Ullrich
9d8c84713c refactor(*): reduce exception context info from expr to pos_info 2017-02-17 13:45:57 +01:00