Commit graph

10224 commits

Author SHA1 Message Date
Gabriel Ebner
b05b514cc2 refactor(*): structured message objects 2016-10-13 18:49:10 -07:00
Leonardo de Moura
bf7bae6eaf feat(library/init/meta/tactic): add beta/zeta tactics 2016-10-13 18:47:27 -07:00
Daniel Selsam
b4644acba4 fix(meta/mk_dec_eq_instance): handle indices and ginductives 2016-10-13 10:12:37 -07:00
Daniel Selsam
ae730532c8 fix(inductive_compiler): preserve invariant that all basic ir names are <ind_name>.<atomic> 2016-10-13 10:12:08 -07:00
Daniel Selsam
8d94dfd8e8 fix(inductive_cmd): intro rule names must be atomic identifiers 2016-10-13 10:12:08 -07:00
Daniel Selsam
047556528d refactor(inductive_compiler): keep simulated inductive types semireducible 2016-10-13 10:12:08 -07:00
Leonardo de Moura
881aa6d023 perf(library/type_context): small optimization
It makes a big difference in examples such as:

example (p : nat → Prop) (a : nat) (h : false) : p (a + 5000) :=
begin
  unfold add has_add.add nat.add bit0 bit1 one has_one.one,
  contradiction
end
2016-10-12 21:39:10 -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
9320016b97 refactor(library/tactic): merge simp_lemmas and simp_lemmas_tactics 2016-10-12 14:49:54 -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
e6acd52fc2 feat(library/init/list): add list.any and list.all 2016-10-12 13:30:39 -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
4e71013aa4 refactor(library/tactic/dsimplify): expose classes 2016-10-12 07:44:53 -07:00
Leonardo de Moura
e37207e8a9 feat(library/tactic): expose new dsimplify in Lean 2016-10-12 07:25:09 -07:00
Leonardo de Moura
239cd9c543 feat(library/tactic): start new defeq simplifier 2016-10-11 16:37:50 -07:00
Leonardo de Moura
d655310ecf feat(library/init/meta): rename rsimp* back to dsimp* 2016-10-11 16:37:08 -07:00
Sebastian Ullrich
3e3399dbb6 chore(emacs/lean-input): add custom shorthands for French quote symbols 2016-10-11 14:17:30 -07:00
Sebastian Ullrich
b0e6c83ea9 feat(library/tactic): add back notation for by assumption 2016-10-11 14:17:18 -07:00
Leonardo de Moura
85486ad82e refactor(library/init/core): define nat.add using equations
Several tests had to be patched. The new ouput is bad in several cases.
Future commits will fix that.
2016-10-11 14:10:49 -07:00
Leonardo de Moura
f2a610ab52 fix(library/type_context): bug at is_def_eq_args
The method would produce incorrect result for dependent functions whose
arity depends on the arguments provided (e.g., recursors).
2016-10-10 14:07:54 -07:00
Leonardo de Moura
65e040ac38 fix(library/type_context): bug at scope life-cycle 2016-10-10 11:53:42 -07:00
Leonardo de Moura
a737ecfc78 fix(library/eqn_lemmas): typo 2016-10-09 19:27:30 -07:00
Leonardo de Moura
50aca35ce3 fix(frontends/lean/definition_cmds): do not generate code for examples 2016-10-09 19:27:07 -07:00
Leonardo de Moura
ebd912d243 feat(library/eqn_lemmas): add map function name => equational lemmas 2016-10-09 11:48:55 -07:00
Leonardo de Moura
e8497f3b7e fix(frontends/lean/definition_cmds): typo 2016-10-09 11:42:30 -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
Gabriel Ebner
37b998ff1e feat(frontends/lean,library/flycheck): redirect all diagnostic output from commands to flycheck 2016-10-08 22:23:53 -07:00
Daniel Selsam
7cdec2c8f3 chore(frontents/lean/definition_cmds): improve error message 2016-10-08 22:22:23 -07:00
Daniel Selsam
1644e52c47 fix(frontends/lean/decl_cmds): allow noncomputable meta 2016-10-08 22:21:56 -07:00
Leonardo de Moura
476684a284 refactor(library,library/tactic/defeq_simplifier): use simp_lemmas in the defeq_simplifier 2016-10-08 22:15:27 -07:00
Leonardo de Moura
a796bda14e refactor(library/tactic): use new simp_lemmas module in the simplifier 2016-10-08 21:54:34 -07:00
Leonardo de Moura
86b0c53c14 refactor(library/simp_lemmas): new simp_lemmas module that combines rfl_lemmas and simplifier/simp_lemmas 2016-10-08 20:57:08 -07:00
Leonardo de Moura
5e1bb3dbdd refactor(library/rfl_lemmas): avoid tmp_type_context 2016-10-08 10:45:47 -07:00
Leonardo de Moura
84f55bb736 fix(library/inverse): m_inv_arity was not being stored in the .olean file 2016-10-07 17:08:56 -07:00
Leonardo de Moura
d44b5c749b feat(library): add discrimination trees 2016-10-07 17:07:31 -07:00
Leonardo de Moura
eaef8dae20 chore(library/init/core): remove unnecessary annotations 2016-10-07 16:09:14 -07:00
Leonardo de Moura
7336c4dade chore(library/init/core): use equations 2016-10-07 14:58:17 -07:00
Leonardo de Moura
39a1ec9e08 chore(library/init/bool): add xor for Booleans 2016-10-07 14:21:11 -07:00
Leonardo de Moura
7e62a8e4c7 chore(library/init/function): cleanup 2016-10-07 14:09:52 -07:00
Leonardo de Moura
77d899eca6 chore(emacs/lean-mode): disable minor mode 2016-10-07 13:14:30 -07:00
Leonardo de Moura
61d68f4abf feat(library/type_context): solve ?m s =?= ?m t by first-order unification in approximate mode 2016-10-07 12:06:22 -07:00
Leonardo de Moura
224d78e98c feat(library/type_context): improve precision 2016-10-07 12:01:12 -07:00
Leonardo de Moura
cc3150ea79 fix(frontends/lean/definition_cmds): make sure theorem/lemma type does not contain metavariables before we try to elaborate its proof 2016-10-07 11:10:01 -07:00