Commit graph

216 commits

Author SHA1 Message Date
Leonardo de Moura
1612aca0b2 chore(kernel): rename expr kinds 2018-06-09 06:50:14 -07:00
Leonardo de Moura
62788a9ca3 refactor(kernel): fix terminology: "free_var" is actually a loose bound variable
We represent free variables uisng local constants.
We will fix this terminology too.
2018-06-08 13:25:36 -07:00
Leonardo de Moura
818170d780 refactor(kernel): remove tag from kernel expressions
We are temporarily storing position information in a global table.
2018-06-08 10:29:22 -07:00
Leonardo de Moura
2a79da1ab6 refactor(kernel): move formatting stuff out of the kernel 2018-06-07 16:28:54 -07:00
Leonardo de Moura
0119926022 fix(kernel/expr): constructor order 2018-06-05 15:56:51 -07:00
Leonardo de Moura
b47aa7997e chore(kernel): remove dead code 2018-06-01 18:07:10 -07:00
Leonardo de Moura
0556412f8d refactor(*): add runtime folder
@kha The runtime folder includes what is needed to link a
standalone Lean program. It is still contains some unnecessary files.
We will be able to remove them after we release Lean4.
2018-05-14 14:23:56 -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
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
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
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
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
544d5c67f4 feat(CMakeLists,kernel): add TRACK_LIVE_EXPRS=ON compilation option 2017-02-28 10:56:14 -08:00
Leonardo de Moura
715f0bdd8c fix(kernel/expr): typo
closes #1350
2017-02-07 10:11:47 -08:00
Leonardo de Moura
9065cf0350 feat(library/tactic/congruence/theory_ac): add internalization, interface with congruence closure module, and trivial/simp/orient transitions
Still missing: superpose, collapse and compose transitions.
2016-12-28 21:35:16 -08:00
Leonardo de Moura
caf92bbcc0 feat(kernel/expr): compress expr_macro representation 2016-12-28 09:01:21 -08:00
Leonardo de Moura
5572d7f3ec perf(kernel,library/module): enable expr caching when deserializing .olean files 2016-12-16 18:33:46 -08:00
Leonardo de Moura
487a1e7f89 refactor(kernel): remove extension_context
We replaced it with abstract_type_context
2016-03-19 15:15:39 -07:00
Leonardo de Moura
e7f1f409c4 refactor(kernel): simplify kernel type_checker
TODO: cleanup, move justification/metavar/constraints to library
2016-03-18 16:28:42 -07:00
Leonardo de Moura
3c878ecd01 feat(kernel): add let-expressions to the kernel
The frontend is still using the old "let-expression macros".
We will use the new let-expressions to implement the new tactic framework.
2016-02-29 16:40:17 -08:00
Leonardo de Moura
2b1d734544 feat(kernel/expr): remove 'contextual' flag from binder_info 2016-02-29 12:41:43 -08: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
f67181baf3 chore(*): remove support for Lua 2016-02-11 17:17:55 -08:00
Leonardo de Moura
930fcddace feat(kernel/expr): add get_app_args_at_most 2016-01-06 17:29:28 -08:00
Leonardo de Moura
ba392f504f feat(kernel/expr,library/blast/blast,frontends/lean/decl_cmds): add workaround for allowing users to use blast inside of recursive equations 2016-01-03 21:53:31 -08:00
Daniel Selsam
413989afd6 feat(library/blast/backward): backward chaining strategy 2015-11-18 17:48:39 -08:00
Leonardo de Moura
92a7c38260 feat(kernel/expr): add mk_app that takes a list of arguments 2015-11-13 14:01:15 -08:00
Leonardo de Moura
57035d3162 feat(kernel/level,library/blast/expr): add universe level hash consing support in the kernel, simplify blast/expr even more 2015-09-30 13:31:42 -07:00
Leonardo de Moura
c5603e456a feat(kernel/expr): replace "opportunistic" caching with precise caching
We also removed compilation option LEAN_CACHE_EXPRS
2015-09-30 12:29:43 -07:00
Leonardo de Moura
9c09b0750b chore(kernel/expr): remove dead code 2015-09-21 15:43:51 -07:00
Leonardo de Moura
25cbc5c154 fix(kernel/expr): remove 'cast_binder_info'
We should put it back when we decide to implement it.
We also fix the bogus comment at src/frontends/lean/parser.cpp.

see issue #667
2015-06-11 18:11:22 -07:00
Leonardo de Moura
f830bf54c2 refactor(*): clarify name_generator ownership 2015-05-21 14:32:36 -07:00
Leonardo de Moura
061e26157e fix(kernel,library): make sure macros check relevant arguments when kernel is performing full type checking 2015-05-08 12:41:23 -07:00
Leonardo de Moura
7516fcad97 feat(kernel/type_checker): add is_stuck method, and improve ensure_pi method, closes #261 2014-10-27 13:16:50 -07:00
Leonardo de Moura
6a31a79265 refactor(frontends/lean/inductive_cmd): move auxiliary method to expr.h 2014-10-18 15:11:26 -07:00
Leonardo de Moura
6d64da2981 perf(kernel/expr_eq_fn): use thread local cache, and avoid memory allocation/deallocation 2014-10-17 16:44:20 -07:00
Leonardo de Moura
fe484b26f3 refactor(kernel/expr): remove dead code 2014-10-16 13:45:36 -07:00
Leonardo de Moura
3b6b23c921 refactor(kernel/expr): remove silly overloads 2014-10-16 13:37:55 -07:00
Leonardo de Moura
c4f02bd16a refactor(kernel/expr): remove dead code 2014-10-16 13:09:26 -07:00
Leonardo de Moura
97a7dae12a refactor(kernel/expr): remove code duplication 2014-10-16 12:48:49 -07:00
Leonardo de Moura
814778abb1 refactor(kernel/expr): tag expressions at "creation" time 2014-10-15 13:12:09 -07:00
Leonardo de Moura
a26618e0f2 feat(frontends/lean): add '[]' notation for marking arguments where class-instance resolution should be applied 2014-10-12 13:06:00 -07:00
Leonardo de Moura
92c424936a refactor(kernel/macro_definition_cell): improve macro get_type API 2014-10-07 16:38:31 -07:00
Leonardo de Moura
a0c37b231f feat(kernel/expr): add hash_bi function that takes binder information into account 2014-09-29 16:44:55 -07:00
Leonardo de Moura
da481c3274 refactor(kernel): explicit initialization/finalization
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-09-24 10:12:28 -07:00
Leonardo de Moura
4a4de27a6c refactor(frontends/lean/elaborator): move local_context to separate file 2014-09-10 11:20:16 -07:00
Leonardo de Moura
3310eb3dfc feat(frontends/lean): remove restriction on implict arguments, add new test that demonstrates the new feature
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-09-07 12:29:32 -07:00
Leonardo de Moura
9588336c15 refactor(kernel/type_checker): remove "global" constraint buffer from type_checker, and use constraint_seq instead
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-08-20 16:46:19 -07:00