Commit graph

11507 commits

Author SHA1 Message Date
Leonardo de Moura
7ebf16ca26 fix(library/equations_compiler): performance issues at structural_rec module and equational lemma generator
There were two performance bottlenecks in the recursive equation
compiler. Both bottlenecks were due to conversion checking.

1- We allow patterns such as (x+1) in the left-hand-side of a
   recursive equation. This is kind of pattern has to be reduced
   since it is not a constructor. Moreover, when we are trying to
   compile using structural recursion, we need to find an element
   that is structurally smaller in recursive applications.
   Again, we need to use reduction since the pattern may be (x+2),
   and in the recursive application we have (x+1). Now, consider
   the following equation

         f (x+1) (y+1) := f complex_term y

   It will first check whether complex_term is structurally smaller
   than (x+1), and the compiler will timeout trying to reduce
   complex_term.

   This commit adds the following workaround. The structural
   recursion module from now on will only unfold reducible constants
   and constants marked as patterns. This is not a complete
   solution. It will timeout in the following equation:

         f (x+1) (y+1) := f (x+1000000000000) y

   For this one, we need to add a whnf "fuel" option to type_context

2- Equational lemma generation was producing lemmas that are too
   expensive to check. Suppose we the following two definitions

       | f x 0     := 1
       | f x (y+1) := f complex_term y

    and

       | g 0     y    := 1
       | g (x+1) y    := g x complex_term

    Before this commit, we would generate the following proofs for
    the second equation of each definition:

         eq.refl (f complex_term y)
         eq.refl (g x complex_term)

    This proof triggers the following definitionally equality test:

             f x     (y+1)  =?= f complex_term y
             g (x+1) y      =?= g x complex_term

    Since, we have f/g on both sides, the type checker will try
    first to unify the arguments, and may timeout trying to solve

               x  =?= complex_term
               y  =?= complex_term

    since it may take a long time to reduce `complex_term`.

    We workaround this problem by creating a slightly different
    proof.

          eq.refl (unfold_of(f x (y+1)))
          eq.refl (unfold_of(g (x+1) y))

    where unfold_of(t) is the result of applying one delta reduction
    step.
2017-02-15 21:31:28 -08:00
Leonardo de Moura
d4d5ac115c feat(library/type_context): add whnf_transparency_pred 2017-02-15 20:38:29 -08:00
Leonardo de Moura
245b4be315 fix(library/vm/vm): compilation warning 2017-02-15 20:32:22 -08:00
Leonardo de Moura
707cf45a26 refactor(library/type_context): rename whnf_pred => whnf_head_pred 2017-02-15 20:20:27 -08:00
Leonardo de Moura
604cbf827a chore(kernel/type_checker): remove dead code 2017-02-15 18:05:55 -08:00
Leonardo de Moura
3b28cef858 fix(shell/lean): default heartbeat should be unbounded in batch mode 2017-02-15 16:46:44 -08:00
Leonardo de Moura
e0d57aa8a3 chore(library/tactic): add missing lean_vm_check's 2017-02-15 15:40:35 -08:00
Leonardo de Moura
c5287237ee fix(library/vm): race condition in the profiler initialization code 2017-02-15 15:35:41 -08:00
Gabriel Ebner
cbebedb53b feat(library/vm/vm): improve vm check error message 2017-02-15 13:39:10 -08:00
Gabriel Ebner
93d00534e0 fix(library/vm): enable bounds checks 2017-02-15 13:39:00 -08:00
Gabriel Ebner
1d301b7813 feat(init/meta/smt/congruence_closure): add has_to_tactic_format instance 2017-02-15 13:38:30 -08:00
Gabriel Ebner
092f7890a8 chore(shell/server): disable cpplint 2017-02-15 13:33:02 -08:00
Gabriel Ebner
f4b276ca4b fix(shell/server): sleep command: do not respond with "unknown command" 2017-02-15 13:33:02 -08:00
Gabriel Ebner
f72816e0f2 feat(shell/server): cancel all tasks on server exit 2017-02-15 13:33:02 -08: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
11d5773560 refactor(library/init/meta): remove whnf_core 2017-02-14 18:39:57 -08:00
Leonardo de Moura
06a7d6d311 refactor(library/init/meta): remove exact_core 2017-02-14 17:43:42 -08:00
Leonardo de Moura
1ab2bb7714 feat(frontends/lean/elaborator): eta-expand function applications until we consume all optional and auto parameters 2017-02-14 17:38:08 -08: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
304b5b6a20 fix(library/tactic/generalize_tactic): we must check whether the abstracted type is type correct or not 2017-02-14 13:41:49 -08:00
Leonardo de Moura
1b412b6cc0 feat(library/init/meta): new cases that reverts also composite terms
The previous `cases` tactic would only use the revert/intro idiom
for `cases h` when `h` is a hypothesis
2017-02-14 13:30:36 -08:00
Leonardo de Moura
3ced85d399 feat(library/init/meta/tactic): add kdepends_on tactic 2017-02-14 10:33:28 -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
8a34680916 fix(frontends/lean/elaborator): name resolution at tactic execution times with overloaded notation and aliased symbols
See https://groups.google.com/forum/#!topic/lean-user/Jja_lh28v3g
2017-02-13 21:06:49 -08:00
Leonardo de Moura
e551b4ff09 fix(src/util/timer): uninit var 2017-02-13 18:15:01 -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
4d765fa25b fix(library/vm): profiler was not including builtin functions 2017-02-13 16:12:25 -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
702347784a chore(library/norm_num): remove more code duplication 2017-02-12 20:57:46 -08:00
Leonardo de Moura
86e671798a refactor(library/norm_num): delete num_of_expr dead code, move arithmetic evaluator to arith_instance 2017-02-12 20:47:01 -08:00
Leonardo de Moura
1888908483 refactor(library/norm_num): cleanup code, avoid duplication, optimize 2017-02-12 20:13:59 -08:00
Leonardo de Moura
32d3cf610c refactor(library/arith_instance): add mk_num 2017-02-12 19:44:02 -08:00
Leonardo de Moura
1a698d9065 refactor(library/arith_instance_manager): rename to arith_instance, avoid copy&paste, and add support for norm_num 2017-02-12 19:11:58 -08:00
Rob Lewis
6560b8ae19 feat(norm_num): remove redundant instance caching 2017-02-12 17:15:08 -08:00
Rob Lewis
d6ec20304f fix(norm_num): handle embedded nat subtraction 2017-02-12 17:15:08 -08:00
Rob Lewis
9fd8101b36 fix(norm_num): style 2017-02-12 17:15:08 -08:00
Rob Lewis
46a46c9ee0 feat(norm_num): handle nat subtraction as a special case 2017-02-12 17:15:08 -08:00
Leonardo de Moura
ae0577d26e chore(tests/lean): fix tests 2017-02-12 16:50:42 -08:00
Leonardo de Moura
002ffc81bb fix(tests/shared/univ): memory access violation 2017-02-12 16:29:13 -08:00
Leonardo de Moura
1306e56381 feat(library/vm): check heartbeat in function calls 2017-02-12 12:29:32 -08:00
Leonardo de Moura
80ac700e36 refactor(library/init): provide more general try_for, and implement tactic.try_for using it 2017-02-12 12:15:19 -08:00
Leonardo de Moura
e517316405 chore(tests/lean/try_for_heap): missing test output 2017-02-12 11:58:13 -08:00
Leonardo de Moura
7112f6d685 feat(library/tactic): add try_for tactic 2017-02-11 20:35:42 -08:00
Leonardo de Moura
73b1e927ff chore(tests/lean): fix tests 2017-02-11 18:37:15 -08:00
Leonardo de Moura
41d3d42dee feat(library/init/meta): add helper tactics 2017-02-11 18:30:38 -08:00
Leonardo de Moura
5ca18b8d2e feat(library/init/meta): add helper functions 2017-02-11 16:52:06 -08:00
Leonardo de Moura
2f5159e7eb feat(library/init/meta): add simple tactics for testing where a declaration was defined 2017-02-11 10:57:06 -08:00
Gabriel Ebner
2d31007625 fix(emacs): update flycheck messages for tasks 2017-02-11 10:50:11 -08:00
Leonardo de Moura
4fdd512636 fix(tests/shared/univ): bus error on OSX 2017-02-11 09:27:46 -08:00