Commit graph

12634 commits

Author SHA1 Message Date
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
Gabriel Ebner
16fb5ade58 fix(library/string): correctly escape non-printable characters
This also fixes a compiler warning on ARM, where `0 <= c` is always
true.
2017-06-23 20:39:41 +02:00
Gabriel Ebner
7342741263 fix(CMakeLists): do not use -fsigned-char 2017-06-23 18:21:30 +02:00
Gabriel Ebner
4a6513e5f5 refactor(util/serializer,library/module): use basic_ostream::write for the olean code 2017-06-23 15:13:40 +02:00
Gabriel Ebner
31162df650 fix(frontends/lean/structure_instance): compiler warning 2017-06-23 08:31:04 +02:00
Leonardo de Moura
e63c79c81e feat(frontends/lean): enable hash_consing during tactic execution
This commit is trying to address a memory consumption problem in
@dselsam project.
2017-06-22 17:24:27 -07:00
Leonardo de Moura
9cb94847cb fix(library/equations_compiler): propagate m_ignore_if_unused flag 2017-06-22 17:01:31 -07:00
Leonardo de Moura
58f0561f41 fix(library/equations_compiler/equations): is_equation 2017-06-22 17:01:08 -07:00
Leonardo de Moura
e905e83e9e chore(library, frontends/lean): use override 2017-06-22 16:15:21 -07:00
Leonardo de Moura
096b437c11 fix(library/equations_compiler, frontends/lean): missing operator== for macro_definition_cell subclasses 2017-06-22 16:13:29 -07:00
Gabriel Ebner
30a9217a78 feat(library/type_context): unfold lemmas in major premise of acc.rec 2017-06-22 08:33:11 -07:00
Sebastian Ullrich
4d5d2abcba fix(init/meta): fix build 2017-06-22 08:24:36 -07:00
Mario Carneiro
47c3c0ba84 fix(tests/*): fix tests 2017-06-22 08:24:19 -07:00
Mario Carneiro
09af93186a fix(frontends/lean/elaborator): @applications don't make thunks 2017-06-22 08:24:11 -07:00
Leonardo de Moura
d666742219 doc(changes): update 2017-06-22 08:07:25 -07:00
Sebastian Ullrich
0a48809469 refactor(frontends/lean/tactic_notation): rename note/define tactics to have/let 2017-06-22 08:03:23 -07:00
Mario Carneiro
495093f6c0 fix(tests/run): fix tests 2017-06-22 08:03:23 -07:00
Mario Carneiro
9f31096892 refactor(init/meta/interactive): rename pose -> define 2017-06-22 08:03:23 -07:00
Mario Carneiro
b775a01fba refactor(init/meta/interactive): merge assert -> note 2017-06-22 08:03:23 -07:00
Leonardo de Moura
671b6240c1 fix(library/init/meta): make sure rw still produces useful error messages 2017-06-21 20:58:59 -07:00
Leonardo de Moura
14d768ffa2 feat(library/init/meta/interactive): add simp_all tactic
@Armael I added the simp_all tactic. See new test for an example.
2017-06-21 20:43:56 -07:00
Leonardo de Moura
058d073cba feat(library/init/meta/interactive): allow user to write rw [f] to rewrite using the equational lemmas for f
The tactic succeeds if the expression can be rewritten using one of the
equational lemmas associated with `f`.

See discussion at #1680
2017-06-21 18:56:18 -07:00
Leonardo de Moura
35b99aafb2 feat(library/init/category/combinators): add list.mfirst 2017-06-21 18:53:22 -07:00
Leonardo de Moura
51a28828d6 chore(tests/lean/interactive/info_tactic): fix test 2017-06-21 17:03:24 -07:00
Leonardo de Moura
3195a800f4 feat(library/tactic/simp_lemmas): use proof for refl lemmas at simp_lemma_rewrite too
I forgot to do it at 9fcb3ae4b5
2017-06-21 16:53:35 -07:00
Leonardo de Moura
b9dee04fdb feat(library/tactic/simplify): add single_pass simplifier option (default is false) 2017-06-21 16:41:54 -07:00
Leonardo de Moura
9fcb3ae4b5 feat(library/tactic/simplify): store proof for refl lemmas and use them in simp
Before this commit, simp would not silently apply refl-lemmas, and use
reflexivity. This strategy produces compact proofs but may generate
performance problems. For example, the new test timeouts without this
commit.

I believe a similar performance problem is affecting the Certigrad
project developed by @dselsam.
2017-06-21 16:21:11 -07:00
Leonardo de Moura
fd17a19a23 chore(library/tactic/simplify): remove dead option 2017-06-21 15:32:08 -07:00
Scott Morrison
629d5ebbe8 feat(init/meta/simp_tactic) tactics that revert hypotheses should allow elet expressions
Conflicts:

	library/init/meta/simp_tactic.lean
2017-06-21 13:58:46 -07:00
Scott Morrison
6aba80d389 feat(library/init/meta/simp_tactic,library/init/meta/interactive) interactive tactics for unfold_projection 2017-06-21 13:51:52 -07:00
Sebastian Ullrich
565e583915 chore(doc/changes): fix link 2017-06-21 13:23:02 -07:00
Sebastian Ullrich
676e8eee6c chore(doc/changes): update changelog 2017-06-21 13:22:47 -07:00
Gabriel Ebner
814a5edaf1 fix(library/module_mgr): check for errors when writing olean files 2017-06-21 11:25:25 +02:00
Gabriel Ebner
a0a70a678a fix(library/module): check for end-of-file in deserialization 2017-06-21 11:25:25 +02:00
Gabriel Ebner
942f7bf8b5 fix(library/module): unify hash computation 2017-06-21 10:50:54 +02:00
Mario Carneiro
e6f3c5cc22 fix(tests/lean/interactive/mk_input): strip \r from input files (win) 2017-06-21 08:53:11 +02:00
Leonardo de Moura
eef4d95410 feat(frontends/lean/inductive_cmds): closes #1655 2017-06-20 16:25:18 -07:00
Leonardo de Moura
e089fe6ee7 fix(library/expr_lt): make sure find_local_decl is not tested in the Meta case, and add /* fall-thru */
See comments at commit b25291c5c9
2017-06-20 13:47:30 -07:00
Leonardo de Moura
5a07b3b27c test(tests/lean/run/1688): add test for PR #1688 2017-06-20 12:36:31 -07:00
Mario Carneiro
636e65a216 fix(init/meta/interactive): elab terms of change-with using same type 2017-06-20 12:34:29 -07:00
Leonardo de Moura
b25291c5c9 fix(library/tactic/simplify): fixes #1685 2017-06-20 12:27:46 -07:00
Leonardo de Moura
ce3387b246 fix(library/tactic/change_tactic): fixes #1686 2017-06-20 12:05:21 -07:00
Leonardo de Moura
3c306d0a7b fix(library/equations_compiler/elim_match): forward dependency checking
See comment at #1594

This commit is not fixing the issue, but a problem described in one of
the comments.
2017-06-20 11:29:23 -07:00
Leonardo de Moura
c7e68e57cf fix(frontends/lean/structure_cmd): fixes #1681
@kha I'm not sure if this is the right fix. I just avoided the loop that adds
`mk_expr_placeholder` if the function is not a projection.
I didn't spend time investigating why we need `mk_proj_app`.
I know the library doesn't compile if we don't use it, and just use
```
    return mk_app(copy_tag(ref, mk_constant(S_name + fname)), e);
```
:)
2017-06-19 16:22:38 -07:00
Leonardo de Moura
cfa34dc83e chore(library): remove workarounds for issue #1682 2017-06-19 16:09:12 -07:00
Leonardo de Moura
ddb6b38d88 fix(frontends/lean/elaborator): fixes #1682
@kha Could you please double check whether this is right fix?
2017-06-19 16:04:24 -07:00
Leonardo de Moura
0f64b6088c chore(frontends/lean): remove then have ... notation
This notation was a leftover from Lean 0.1.
2017-06-19 14:20:52 -07:00
Gabriel Ebner
16c6e0ffaf fix(util/object_serializer): do not compare chars 2017-06-19 20:48:24 +02:00
Gabriel Ebner
b826bdfe43 fix(CMakeLists): force char to be signed 2017-06-19 20:47:57 +02:00
Gabriel Ebner
25a3b13fc7 fix(.travis.yml): move -t0 test to a release configuration 2017-06-19 20:35:11 +02:00