Commit graph

29 commits

Author SHA1 Message Date
Leonardo de Moura
ec1a490a15 chore(*): annotate candidates for thread local cache reset 2018-02-01 14:59:37 -08:00
Leonardo de Moura
c195d7c2a1 feat(library/tactic/simp_tactic): improve mk_simp_attr
- An new simp attribute may depend on other existing attributes

- Add `[norm]` simp attribute. It is an extension of the default `[simp]` attribute.
  It should be used to add extra rules for normalizing goals.
  These extra rules are used to produce normal forms and/or reduce the
  number of constants used in a goal. Here is an example coming from a
  discussion with @kha. When working with monads, we may want to
  eliminate `<$>` by using the lemma `f <$> x = x >>= pure ∘ f`.
  This lemma is in the `[norm]` simp set, but it is not in `[simp]`
2018-01-16 16:47:30 -08:00
Sebastian Ullrich
b3587e15a3 fix(library/tactic/user_attribute): persist user attribute parameters
Fixes #1871
2017-11-22 19:19:05 +01:00
Sebastian Ullrich
7ff06b2184 chore(init/meta/attribute): rename user_attribute.set_param to user_attribute.set
Setting the parameter value really is a side effect of setting the whole attribute
2017-09-14 18:48:18 +02:00
Sebastian Ullrich
1544c3d390 feat(library/tactic/user_attribute,init/meta/attribute): user_attribute.set_param 2017-09-05 23:14:34 +02:00
Sebastian Ullrich
ea6a4159a9 feat(library/tactic/user_attribute,init/meta/attribute): implement parameterized user attributes 2017-09-05 23:14:34 +02:00
Sebastian Ullrich
3188c4cbcf refactor(library/tactic/user_attribute,init/meta/attribute): merge caching_user_attribute into user_attribute
The inheritance-based approach doesn't scale to a second subclass for parameterized attributes
2017-09-05 23:14:34 +02:00
Sebastian Ullrich
4f66673fc2 feat(init/meta/attribute,library/tactic/attribute): user_attribute apply handlers 2017-08-02 14:32:39 +01:00
Sebastian Ullrich
e9a6c544af refactor(frontends/lean/{elaborator,structure_cmd}): compile structure inheritance to nested fields 2017-04-24 19:35:15 +02:00
Sebastian Ullrich
b2dfae8a67 chore(tests/lean/caching_user_attribute): fix flaky test 2017-03-30 06:04:00 +02:00
Sebastian Ullrich
e3b9190fe2 refactor(library/tactic/user_attribute): use attribute for registering attributes. naturally. 2017-03-15 14:06:34 -07: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
5f9c53f1a0 feat(library/tactic/user_attribute): use Sebastian's trick to avoid unnecessary cache failures 2017-02-14 15:13:53 -08:00
Leonardo de Moura
5d9de2aef7 fix(library/tactic/user_attribute): incorrect tactic_state being returned 2017-02-14 13:58:54 -08:00
Leonardo de Moura
f650a1b873 refactor(library/init/meta): avoid '_core' idiom using default parameters
I kept a few core methods (e.g., exact_core and apply_core). Reason:
if we use default parameters

    meta constant exact (e : expr) (md := semireducible) : tactic unit

then, we will not be able to write

    to_expr p >>= exact

The workaround is

    do t <- to_expr p, exact t

or
    to_expr p >>= (fun x, exact x)

One alternative is to change how we handle default parameters, and
eta-expand applications that involve default parameters.
We may also have an attribute [eta_expand]. Then

    attribute [eta_expand] foo

instructs the elaborator to automatically eta-expand foo-applications.
The attribute would give users more control, and avoid potential
performance problems. Without the attribute, then for every function
application the elaborator has to check the type and decide whether it
must be eta-expanded or not.

@gebner @kha What do you think?
2017-02-14 09:46:55 -08:00
Leonardo de Moura
7a58da1181 fix(library/tactic/user_attribute): nasty interaction between eval_expr and attribute_manager
eval_expr creates auxiliary definitions in the VM. These auxiliary
definitions are gone after the VM finishes.

We store vm_obj's in the attribute_manager.

Before this commit, Lean was crashing in the following scenario:

1- A new caching_user_attribute is defined, and the user data structure
contains closures.

2- The closures are created using eval_expr.

3- When reusing the cached values, the system crashes when trying
to apply a closure created using eval_expr. The closure points to
an auxiliary definition that has already been deleted.

The new test exposes the problem. This is not a hypothetical scenario,
the new test is based on the Lean - Mathematica integration being
developed by @rlewis1988.

The fix consists in making sure we do not cache anything if
the VM environment has been updated by eval_expr.

I believe this is acceptable behavior. eval_expr is a very low level
tactic, and I don't see a good motivation for invoking it when
constructing the cache.

BTW, the test can be relaxed if the vm_attr does not contain closures.
However, it doesn't seem to pay off.

Another potential fix would be to propagate the definitions created
by eval_expr to the main environment. However, I think this is not
acceptable.
We will be flooding the main environment with useless temporary definitions
created by `eval_expr`.

This commit also stores the environment at caching time, and make
sure the cache is only reused if the current environment is a descendant
of the the one at caching time. This is fixing a different potential
bug.
2017-02-10 15:24:01 -08:00
Gabriel Ebner
5fdc737dfc feat(library/tactic): store name of current declaration in tactic_state 2017-01-28 08:27:19 +01:00
Gabriel Ebner
a26e2c9108 feat(library/module): intermediary data structure for environment modifications 2016-12-20 10:15:19 -08:00
Gabriel Ebner
a8df381d20 feat(*): parallel compilation 2016-11-29 11:12:40 -08:00
Leonardo de Moura
7232e3a076 feat(library/vm/vm): invoke debugger (aka vm_monitor) 2016-11-14 14:45:49 -08:00
Leonardo de Moura
2d86d88c92 feat(library/tactic/user_attribute): allow user to specify whether attribute is persistent or not 2016-11-05 11:46:04 -07:00
Leonardo de Moura
4516d1b046 feat(library/init/meta/attribute, library/tactic/user_attribute): make sure caching_user_attribute is in (Type 1) 2016-10-04 02:05:34 -07:00
Leonardo de Moura
bd4c77d414 fix(library/tactic/user_attribute): anonymous attribute names are now allowed 2016-10-04 01:11:33 -07:00
Leonardo de Moura
7c07d269f9 refactor(library/tactic/user_attribute): cache builder must be a tactic 2016-10-03 14:20:37 -07:00
Leonardo de Moura
7ab12ed57f feat(library/init/algebra): improve transport_to_additive (copy attributes) 2016-10-01 12:55:17 -07:00
Leonardo de Moura
af78fd0a3c fix(library/tactic/user_attribute): make sure it compiles when using older versions of g++ 2016-09-12 10:51:25 -07:00
Sebastian Ullrich
5e3e54e208 feat(library/tactic/user_attribute): Support pure function caching for user-defined attributes 2016-09-12 10:38:48 -07:00
Leonardo de Moura
39dc336310 feat(library/tactic/user_attribute): add set_basic_attribute and unset_attribute tactics 2016-09-01 14:17:05 -07:00
Leonardo de Moura
19a6005f7e refactor(library): move user_attribute to tactic folder
It depends on tactic_state.
2016-08-26 09:28:42 -07:00
Renamed from src/library/vm/user_attribute.cpp (Browse further)