Commit graph

70 commits

Author SHA1 Message Date
Leonardo de Moura
c086c58b4a fix(library/init/meta/simp_tactic): simp_intro_aux tactic should not fail when hypothesis cannot be simplified 2017-03-08 21:20:43 -08:00
Sebastian Ullrich
ddfdca2e57 chore(init/meta): replace some uses of to_expr `(...) with ``(...) 2017-03-05 08:37:16 -08:00
Leonardo de Moura
b1848efbc4 chore(library/init/meta): add head prefix to head reduction tactics, and add zeta tactic (that applies zeta reduction to all subterms) 2017-03-02 10:55:38 -08:00
Sebastian Ullrich
69741061b0 refactor(init/meta): drop obsolete X.to_expr functions 2017-02-21 11:06:39 -08:00
Leonardo de Moura
1ca5c78cf8 feat(library/tools/mini_crush): improve mini_crush 2017-02-19 18:33:12 -08:00
Leonardo de Moura
0fb5a01f17 feat(library/tools): add mini_crush 2017-02-19 16:21:12 -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
b52e8d67be feat(library/init/meta): simp&intro tactics 2017-02-19 13:02:27 -08:00
Leonardo de Moura
d20319693d feat(library/init/meta): cleanup interface using default parameters 2017-02-19 12:12:34 -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
b9424975b3 refactor(init/meta): replace dynamically-checked quotes where possible 2017-02-17 19:59:57 -08:00
Leonardo de Moura
c51d9ad4f4 feat(library/init/meta): add simph: a shorter simp_using_hs 2017-02-17 13:45:03 -08:00
Sebastian Ullrich
d15591a2d8 feat(library,frontends/lean): expose parser to Lean and use for parsing tactic parameters 2017-02-17 13:45:56 +01:00
Leonardo de Moura
edd5e97045 feat(frontends/lean/elaborator): coercion from (decidable) Prop to bool
This is a hard coded extra case. It is not an instance of has_coe.
Even if we change has_coe to accomodate this case, it will not be a
satisfactory solution because this coercion depends on the element and
not the type, and the element usually contains metavariables.

We should eventually write a tactic for synthesizing coercions.
2017-02-14 18:41:32 -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
59c8a36f40 chore(library/init/meta/simp_tactic): remove unnecessary generality 2017-02-13 17:19:14 -08:00
Leonardo de Moura
c37634c815 feat(library/init): add helper functions and instances 2017-02-13 14:53:32 -08:00
Leonardo de Moura
41d3d42dee feat(library/init/meta): add helper tactics 2017-02-11 18:30:38 -08:00
Leonardo de Moura
c5dc8e651a chore(library/init/meta): cleanup 2017-02-08 15:33:25 -08:00
Leonardo de Moura
96ccb148b1 feat(library/init/meta/simp_tactic): add top_down simplifier combinator 2017-02-06 20:06:13 -08:00
Leonardo de Moura
ae06844f57 chore(library/init/meta): remove unnecessarily '| failed' annotations
tactic and smt_tactic are instaces of monad_fail
2017-02-05 20:12:42 -08:00
Leonardo de Moura
bb9a0c79f4 feat(frontends/lean/builtin_exprs): better syntax for quoted terms with type ascription 2017-02-01 12:49:38 -08:00
Leonardo de Moura
b1d097e63a feat(library/init/meta): add 'delta' tactic for applying delta reduction
closes #1331
2017-01-26 19:04:07 -08:00
Leonardo de Moura
778d5382f6 refactor(library/init/meta/simp_tactic): use default field values at simplify_config 2017-01-23 10:22:48 -08:00
Leonardo de Moura
4de71cadfa feat(library/init/meta): expose additional app_builder tactics 2017-01-20 20:27:07 -08:00
Leonardo de Moura
dc7e39887b refactor(library/tools/super/simp): reorganize simplify lemmas API 2017-01-11 13:47:49 -08:00
Leonardo de Moura
b1c1d2dfa4 feat(library/init/meta): improve dsimp tactic notation 2017-01-09 17:31:35 -08:00
Leonardo de Moura
13a11b4374 feat(library/init/meta/interactive): add get_eqn_lemmas_for tactic, allow user to provide definition name as an argument to simp 2017-01-06 11:45:09 -08:00
Leonardo de Moura
060a554db1 feat(library/tactic): add norm_num_tactic 2016-12-17 16:48:40 -08:00
Leonardo de Moura
d41c403442 feat(library/init/meta/simp_tactic, library/init/meta/interactive): add simp_using_hs 2016-12-17 12:54:04 -08:00
Leonardo de Moura
8683ea4f60 feat(library/tactic/simp_lemmas): add simp_lemmas.pp 2016-12-17 11:53:02 -08:00
Leonardo de Moura
692701c5ef feat(library/init/meta): use cheap "reflexivity" after simp and rewrite
The idea is to make sure lean doesn't timeout (at reflexivity) when we apply simp or
rewrite in goals such as

    (x y : nat) |- x + y + 10000000000 = x + y + 200000000000000

This commit also addresses an issue raised at #1218
2016-12-08 14:41:26 -08:00
Leonardo de Moura
3b09865684 feat(library/init/meta/simp_tactic): add tactics for validating simp lemmas 2016-11-23 17:43:55 -08:00
Leonardo de Moura
c816b80855 chore(*): don't use upper case letter for type variables, and camelCase for declarations 2016-11-17 14:54:08 -08:00
Leonardo de Moura
6edec4c4e9 feat(library/init/meta/converter): implement conversionals using ext_simplify_core 2016-10-19 17:23:32 -07:00
Leonardo de Moura
205d524409 refactor(library/tactic/simplify): delete old simplifier 2016-10-19 14:03:14 -07:00
Leonardo de Moura
053389b70b feat(library/init/meta/simp_tactic): add new simp primitives 2016-10-19 08:41:25 -07:00
Leonardo de Moura
45997a0ca8 chore(library/init/meta/simp_tactic): update documentation 2016-10-12 17:34:57 -07:00
Leonardo de Moura
ef23c591fc feat(library/init/meta): implement unfold tactics in Lean using new building blocks 2016-10-12 17:25:56 -07:00
Leonardo de Moura
924b4d3bdc refactor(library, library/tactic): move simp_lemmas and eqn_lemmas to tactic folder
They were at src/library because we hoped we would be able to use them
in the type_context unifier. However, the plan did not work for several
reasons. We saved the partial implementation in the branch: https://github.com/leodemoura/lean/tree/type_context_with_refl_lemmas

Here are the problems:

1) We have to be able to rewrite even when the type context is already in tmp-mode.
   This is an issue because the tmp metavariables in the refl lemma clash with the ones created in the type context.

  Solution: implemented lift operation for idx metavariables, and custom
  match. This solution is not perfect since the lifting is extra overhead.

2) The term being "unfolded" may be stuck. Example:

      nat.add n (@one nat ?m)

  will not match the pattern

      nat.add ?x_0 (nat.succ ?x_1)

  because ?m is not assigned yet.
  We can assign it during the matching process because it is a regular metavariable and the matching is performed in
  tmp_mode.

  Possible workaround a) try to instanciate type class instances before we try the refl lemmas.
  This is a potential performance problem because the term can be arbitrarily big.
  The current heuristics we use to speed up the process do not work for the example above.

  Possible workaround b) allow regular metavariables be assigned by type class resolution even
  when we are in tmp-mode.

  We have not tried to implement any of these workarounds.

3) There are many more lazy-delta steps. Before this feature, when we unfold `nat.add a (succ ... (succ b) ...)`,
   we are done with delta-reduction. It is just iota and beta after that.
   However, with refl-lemmas, the term `nat.add a (succ ... (succ b) ...)` produces one lazy-delta step per succ.
   This produces nasty side-effects because of the
   The heuristic (f t =?= f s) ==> (t =?= s).

   Examples such as
       (fib 8) =?= 34
   will take a very long time because of this heuristic.

   Possible workaround: cache failures like we did in Lean2.
   However, failure are only easy to cache if there are no meta-variables.

4) The type context trace gets very confusing since we use is_def_eq for matching lhs while we are computing is_def_eq.
   Possible workaround: disable trace when trying refl_lemmas.

5) We must be able to temporarily disable the feature.
   Example: when proving a refl_lemma for a definition `f`, we may have
   to expand the nested definitions
   (e.g., for match-end blocks)

6) refl/simp lemmas were designed to rewrite elaborated terms.
   Using them during unification may produce a series of unexpected
   behaviors since terms usually contain many regular and universe meta-variables.

7) We need to define a notion of "refl stuck application".
   Right now, a metavar is stuck, a projection is stuck if the structure
   is stuck, a recursor is stuck is the major premise is stuck.
   An application (f ...) is refl-lemma stuck if f has refl-lemmas
   associated with it, AND metavariables occurring in arguments are
   preventing a refl-lemma from being applied.
2016-10-12 14:36:00 -07:00
Leonardo de Moura
4f2db5702f feat(library/tactic/unfold_tactic): allow user to set transparency_mode at dunfold_expr 2016-10-12 14:07:50 -07:00
Leonardo de Moura
46eb7decde feat(library/tactic/unfold_tactic): add unfold_projection tactic 2016-10-12 13:43:32 -07:00
Leonardo de Moura
deb2bb92b2 feat(library/tactic/simp_lemmas_tactics): add dunfold_expr tactic based on equational lemmas 2016-10-12 13:18:10 -07:00
Leonardo de Moura
f66aec2309 feat(library/tactic/simp_lemmas_tactics): add simp_lemmas.drewrite 2016-10-12 09:01:47 -07:00
Leonardo de Moura
1a4ac3a102 fix(library/tactic/dsimplify): bugs and implement dsimp using new dsimplify 2016-10-12 08:33:40 -07:00
Leonardo de Moura
d655310ecf feat(library/init/meta): rename rsimp* back to dsimp* 2016-10-11 16:37:08 -07:00
Leonardo de Moura
231c124be8 feat(library/init/meta): rename dsimp => rsimp, and add primitive tactic that takes an arbitrary simp_lemmas 2016-10-09 10:02:26 -07:00
Leonardo de Moura
a78e8fb11a refactor(library/tactic/simp_lemmas_tactics): consistent naming 2016-10-09 09:37:20 -07:00
Leonardo de Moura
df9a93c44d refactor(library/tactic/simp_lemmas_tactics): rename function 2016-10-09 09:00:15 -07:00
Leonardo de Moura
d747fcb17c refactor(library/tactic/simp_lemmas): new caching mechanism 2016-10-06 20:20:01 -07:00