Commit graph

63 commits

Author SHA1 Message Date
Leonardo de Moura
cebde17bec feat(library/tactic/simplify): simp reduces c a_1 ... a_n = c b_1 ... b_n into a_1 = b_1 /\ ... /\ a_n = b_n 2018-01-12 18:18:56 -08:00
Leonardo de Moura
1437d7209a feat(library/tactic/simplify): add support for generalized inductive datatypes 2018-01-12 11:51:49 -08:00
Leonardo de Moura
4bd314f7bd feat(library/tactic/simplify): simp reduces c_1 ... = c_2 ... to false 2018-01-12 11:30:45 -08:00
Leonardo de Moura
5a320e260a refactor(library/tactic): code duplication 2018-01-11 14:12:15 -08:00
Leonardo de Moura
22270d37cf feat(library/type_context): m_update => m_update_left/m_update_right 2018-01-03 13:49:42 -08:00
Leonardo de Moura
17172cbbdd fix(library/tactic/simplify): imp_congr was not preserving binder name 2017-11-17 12:45:04 -08:00
Gabriel Ebner
6bd3fe2449 feat(library/tactic/simp_lemmas): support congruence lemmas that are metavariable applications 2017-08-18 08:54:03 +02:00
Gabriel Ebner
0c15724e8e fix(library/tactic/simplify): handle universe polymorphic simplification rules
The issue was that instantiate_mvars(infer(m)) had a metavariable, while
infer(instantiate_mvars(m)) did not.  Changing the call from assign to
is_def_eq also unifies the type, assigning the metavariable inside the
type.
2017-08-03 17:42:07 +01:00
Leonardo de Moura
6b3e28d30b feat(library/init/meta/simp_tactic): add option for reducing [reducible] definitions at dsimp, and to_unfold : list name similar to the one in the simp tactic
This complete addresses the two pending items at 16711fcdba
2017-07-03 13:28:46 -07:00
Leonardo de Moura
16711fcdba feat(library/tactic/dsimplify): new configuration options for dsimp
TODO for `dsimp`:
- Add an option for reducing [reducible] definitions
- Add (to_unfold : list name) similar to the one in the `simp` tactic
2017-07-02 18:26:03 -07:00
Leonardo de Moura
df091f5c34 feat(library/init/meta/interactive): simp and unfold can unfold projection applications
@Armael: we finally can write `simp [proj]` to unfold the `proj`
projection application.

Remark: we still need to add similar support for `dsimp`.
2017-07-02 16:28:04 -07:00
Leonardo de Moura
76eed7cb41 chore(library/init/meta): add to_unfold parameter to simplify, and remove redundant simp* tactics
Remark: the `to_unfold` has not been implemented yet.
2017-07-02 15:26:06 -07:00
Leonardo de Moura
4604d7fd5a feat(library/init/meta): allow users to specify tactic for discharging subgoals in the simp tactic family
@dselsam @Armael: this feature may be useful for you.
The doc/changes.md describes many other new features.
2017-07-01 15:35:33 -07:00
Leonardo de Moura
7c35fae9e3 refactor(library/init/meta/simp_tactic): merge simplify_core and simplify 2017-07-01 14:13:49 -07:00
Leonardo de Moura
b05c4e09ed feat(library/init/meta): add memoize field to simp_config and dsimp_config
We use `memoize := ff` when implementing `conv.interactive.for` and
`conv.interactive.find`.
2017-07-01 10:37:09 -07:00
Leonardo de Moura
5dee3415a4 feat(library/init/meta/simp_tactic): add flag for controlling whether simp-tactics fail when input input expression is not modified 2017-06-29 16:03:20 -07:00
Leonardo de Moura
68afd4194b fix(library/tactic/simplify): fixes #1659
@dselsam The method `try_user_congr` was leaking a temporary
meta-variable into the formula. The problem in the congruence lemma
```
dif_ctx_simp_congr :
  ∀ {α : Sort u_1} {b c : Prop} [dec_b : decidable b] {x : b → α} {u : c → α} {y : ¬b → α} {v : ¬c → α}
  (h_c : b ↔ c),
    (∀ (h : c), x (h_c.mpr h) = u h) →
    (∀ (h : ¬c), y ((not_iff_not_of_iff h_c).mpr h) = v h) → dite b x y = dite c u v
```
when the hypothesis `(∀ (h : c), x (h_c.mpr h) = u h)` is processed,
`h_c` is still unassigned. `h_c` was being assigned in a second
loop (the one that I deleted). Do you see any reason for having this
second pass? I think it is an optimization, we can skip the potentially
expensive
```
   expr hyp = finalize(m_ctx, rel, r_congr_hyp).get_proof();
   expr pf = local_factory.mk_lambda(hyp);
```
if the expression has not been simplified.
Anyway, I removed this code and merged both loops.
I don't think it should impact performance since we barely use custom
congruence lemmas.
2017-06-26 15:25:58 -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
b25291c5c9 fix(library/tactic/simplify): fixes #1685 2017-06-20 12:27:46 -07:00
Leonardo de Moura
7d937dcfcb fix(library/tactic/simplify): instantiate assigned metavariables in the simplifier
This fixes a problem similar to the one described at #1587
2017-05-18 10:52:11 -07:00
Leonardo de Moura
e59fd2927a feat(library): process explicit arguments before implicit
Moreover, we process the implicit arguments using at least the Semireducible
transparency mode. The idea is to make sure to reduce counterintuitive
behavior in rw and simp where the user believes a lemma is applicable
but it does not work because the implicit part fails to unify.

The modification above fixes the simplifier issues found by @kha when proving the
monadic laws.

This commit also improves constraints of the form

          n =?= m

where n and m are big distinct numerals. The type_context fails quickly
for this kind of constraint even using transparency mode Semireducible.
We need this feature otherwise we timeout at

      @eq char a b =?= @eq unsigned ?x ?y

Recall that

       char     := fin char_sz
       unsigned := fin unsigned_sz
2017-04-25 17:16:06 -07:00
Leonardo de Moura
d0dede53f5 chore(library/tactic): make sure "pattern" is the first argument of is_def_eq 2017-04-25 09:59:04 -07:00
Leonardo de Moura
09867fcfe0 fix(library/tactic/simplify): assertion violation 2017-03-27 18:04:57 -07:00
Leonardo de Moura
1cef8af1be feat(library/tactic/simplify): add eta := tt to simp 2017-03-27 17:38:40 -07:00
Leonardo de Moura
eea46610ea fix(library/tactic/simplify): missing projection reduction, add proj := tt to simp 2017-03-27 17:38:40 -07:00
Leonardo de Moura
b09968a37b feat(library/tactic/simplify): add beta := tt to simp 2017-03-27 17:38:31 -07:00
Leonardo de Moura
34f6a92e24 fix(library/tactic/simplify): simp default behavior should eliminate annotations 2017-03-27 15:10:47 -07:00
Leonardo de Moura
8979663164 feat(library/tactic/simplify): relax reducibility constraints when matching implicit arguments
Motivation: if the explicit part matches (what the user sees), then the implicit part must morally match too.
If it doesn't because of reducibility setting, the behavior is usually counterintuitive.
2017-03-08 20:08:54 -08:00
Daniel Selsam
1f6306d068 perf(library/inductive_compiler): simplification with sizeof lemmas 2017-03-01 21:13:20 -08:00
Leonardo de Moura
d1d5428808 feat(library): add check_constants.lean validation, cleanup unused names, minor stdlib fixes 2017-02-21 10:45:31 -08:00
Leonardo de Moura
296d4b0f09 refactor(library/tactic, library/init/meta): simplify_config => simp_config 2017-02-19 13:10:36 -08:00
Leonardo de Moura
0d22410e2e feat(library/tactic): add zeta option, refactor simplify config option, allow users to change simplify_config in interactive mode 2017-02-19 12:11:22 -08: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
e132d106fb feat(library/tactic/simplify): improve simplify trace messages 2017-02-09 11:13:38 -08:00
Leonardo de Moura
8926e98090 fix(library/tactic/simplify): missing constraints
This bug was introduced in the previous commit.
2017-02-08 23:15:07 -08:00
Leonardo de Moura
e4b3dee526 feat(library/simplify): use custom matcher in the simplifier, and remove hack from type_context
@joehendrix This commit is implementing the matcher that postpones
implicit arguments. The lemma get_data_mk_byte can be proved without
using any hacks in the type_context unifier.

I also added the trace class: simplify.implicit_failure
If we use the command

   set_option trace.simplify.implicit_failure true

Then, the simplifier will generate a diagnostic message every time it
succeeds in the explicit part, but fails in the implicit one.

Please feel free to suggest a better name to his option.

BTW, we can now easily extend the matcher with additional features.
I'm wondering if we will eventually want to write some of these
extensions in Lean.
2017-02-08 22:24:13 -08:00
Leonardo de Moura
2684a77093 fix(library/type_context): fix problem with offset constraints, then adjust simplify 2017-02-06 18:21:14 -08:00
Gabriel Ebner
5fdc737dfc feat(library/tactic): store name of current declaration in tactic_state 2017-01-28 08:27:19 +01:00
Leonardo de Moura
28ce1e6d2b fix(library/tactic/simplify): make sure a partially applied lhs can be used to rewrite terms with "more arguments" in simp
See discussion at issue #1331
2017-01-23 19:53:49 -08:00
Leonardo de Moura
2ca2920284 fix(library/tactic/simplify): relax test
We only need to check whether the resulting expression does not contain
temporary metavariables introduced by the simplifier.
It is ok if it contains regular metavariables that were already in the goal.

This fixes the issue reported at
https://groups.google.com/forum/#!topic/lean-user/3qzchWkut0g
2017-01-23 09:59:06 -08:00
Leonardo de Moura
e8839cbcdc feat(library/app_builder): add mk_eq_mpr that removes unnecessary propext 2017-01-20 20:27:41 -08:00
Leonardo de Moura
94f16d1e44 refactor(library/tactic): move defeq_canonizer::state to tactic_state
It was being stored in the environment before. This was very hackish,
and it was producing a series of unnecessary environment updates, and
thread local caches invalidations.

The new test tests/lean/run/heap.lean is 5x-6x faster after this commit.
2017-01-07 10:17:51 -08:00
Leonardo de Moura
d3795b20dd feat(library/defeq_canonizer): remove thread local cache
The goal is to avoid hard to debug behavior because any tactic (e.g., simp/dsimp/cc) using
defeq_canonize was breaking referential transparency.
2016-12-27 12:56:39 -08:00
Leonardo de Moura
516f45428d fix(library/tactic/simplify): missing clear cache operation 2016-12-19 21:32:46 -08:00
Leonardo de Moura
ac1af2dfda feat(library/tactic/simplify): trace prove failures 2016-12-17 11:53:44 -08:00
Leonardo de Moura
b0d27d6d92 feat(library/tactic/simplify): simplify_core calls itself to discharge hypothese 2016-12-16 10:26:44 -08:00
Daniel Selsam
6120f8cc9f fix(src/library/tactic/simplify): relaxed_whnf when checking if fn is dependent 2016-12-08 07:41:42 -08:00
Daniel Selsam
7bfe0aedb0 feat(library/tactic/simplify): better debug.simplify.try_rewrite tracing 2016-11-29 14:46:35 -08:00
Daniel Selsam
f3dc41b631 fix(library/tactic/simplify): only use auto_eq_congr if number of args match 2016-11-04 10:13:02 -07:00