Commit graph

11548 commits

Author SHA1 Message Date
Johannes Hölzl
bb4920fcbc feat(library/vm/vm_expr): export instantiate_univ_params 2017-02-17 20:08:18 -08:00
Johannes Hölzl
3db0ebdcf0 feat(library/tactic/match_tactic): return also assignments for universe meta-variables 2017-02-17 20:08:09 -08:00
diakopter
19606fd197 chore(util,kernel,library): clang warnings 2017-02-17 20:01:34 -08:00
Sebastian Ullrich
b9424975b3 refactor(init/meta): replace dynamically-checked quotes where possible 2017-02-17 19:59:57 -08:00
Gabriel Ebner
0c2878e509 fix(frontends/lean/definition_cmds): copy position for equation in meta definitions
Fixes #1377.
2017-02-17 19:57:49 -08:00
Leonardo de Moura
a36e20f0cd feat(tmp/mini_crush): update 2017-02-17 19:56:14 -08:00
Leonardo de Moura
98b2eb893d chore(tests/lean/run): fix tests 2017-02-17 19:55:49 -08:00
Leonardo de Moura
a9122a2c0a chore(library/init/meta): use general when 2017-02-17 19:51:40 -08:00
Leonardo de Moura
632c98aade feat(library/data/list): cleanup proofs 2017-02-17 19:42:57 -08:00
Leonardo de Moura
a4f43d36a6 feat(library/init/meta/smt): add rsimp 2017-02-17 19:40:38 -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
Leonardo de Moura
03d53b82bd feat(library/init/meta/contradiction_tactic): minor improvement 2017-02-17 13:44:42 -08:00
Leonardo de Moura
d3c340a30c feat(library/init/meta): improve induction tactic interface
It uses .rec recursor when it is not specified
2017-02-17 10:58:51 -08:00
Leonardo de Moura
e16c3a0bee feat(library/init/meta/fun_info): add fold_explicit_args 2017-02-17 10:21:06 -08:00
Sebastian Ullrich
d402b2a467 feat(frontends/lean/print_cmd): add to info_manager when not overloaded 2017-02-17 15:41:58 +01:00
Sebastian Ullrich
84f3e2a492 refacotr(init/meta/interactive): clean up parameter gadgets 2017-02-17 15:41:58 +01:00
Sebastian Ullrich
69ed7b940f refactor(init/meta/interactive): query position information dynamically 2017-02-17 15:41:58 +01:00
Sebastian Ullrich
4d41b03168 chore(frontends/lean,library/tactic): remove old tactic_state functions 2017-02-17 15:41:58 +01:00
Sebastian Ullrich
6b611eb030 chore(.travis.yml): fail eagerly 2017-02-17 15:41:58 +01:00
Sebastian Ullrich
e8fa54cc51 refactor(init/meta): move macro creation defs from expr to pexpr 2017-02-17 13:45:57 +01:00
Sebastian Ullrich
9d8c84713c refactor(*): reduce exception context info from expr to pos_info 2017-02-17 13:45:57 +01:00
Sebastian Ullrich
e14eab2db8 chore(test/lean/interactive): do not test for exact source information 2017-02-17 13:45:56 +01: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
Sebastian Ullrich
5ed1ac924c feat(frontends/lean/elaborator): support partially applied eval_expr 2017-02-17 13:03:47 +01:00
Sebastian Ullrich
bdf12a525e fix(library/vm/vm_string): signed->unsigned cast 2017-02-17 13:03:47 +01:00
Sebastian Ullrich
339713091f refactor(frontends/lean): simpler field notation info that also works with implicit parameters 2017-02-17 13:03:47 +01:00
Sebastian Ullrich
260d8789d1 feat(emacs/lean-type): eldoc: always show doc string 2017-02-17 13:03:24 +01:00
Leonardo de Moura
efcebc60f7 feat(library/init/meta/contradiction_tactic): make it more robust 2017-02-16 21:43:34 -08:00
Leonardo de Moura
c4542d5987 chore(tests/lean): fix test 2017-02-16 21:42:51 -08:00
Leonardo de Moura
71950bdf01 fix(frontends/lean/elaborator): expression may not be an application due to error recovery
Issue described at https://groups.google.com/forum/#!topic/lean-user/uSSYhgVKKH0
2017-02-16 21:13:21 -08:00
Leonardo de Moura
aabc15823c feat(tmp/mini_crush): add destruct_best 2017-02-16 20:50:35 -08:00
Leonardo de Moura
54deb6362d feat(library/init/meta): add helper tactics 2017-02-16 20:49:55 -08:00
Leonardo de Moura
769220fa4e fix(library/equations_compiler): structural recursion and partial equations
The equational compiler was failing to generate equational lemmas for
equations such as:

   def f : nat → nat → nat
   | (x+1) (y+1) := f (x+10) y
   | _     _     := 1

It would fail when trying to prove the following equation:

   forall x, f 0 x = 1

using a "refl" proof. This equation does not hold definitionally.
It is not blocked by the internal pattern matching based on the
cases_on recursor, but it is blocked by the outer most brec_on
used to implement structural recursion. The solution is to
"complete" the set of equations. So, the structural_rec
module will replace the equation above with

   def f : nat → nat → nat
   | (x+1) (y+1) := f (x+10) y
   | _     0     := 1
   | _     (y+1) := 1

and then (as before)

   def f : Pi (x y : nat), below y → nat
   | (x+1) (y+1) F := F^.fst^.fst (x+10)
   | _     0     F := 1
   | _     (y+1) F := 1
2017-02-16 14:51:31 -08:00
Leonardo de Moura
3428e9bd59 refactor(library/equations_compiler): add for_each_compatible_constructor 2017-02-16 13:30:15 -08:00
Leonardo de Moura
7886a78967 fix(library/vm/vm): incorrect lean_vm_check 2017-02-16 11:39:23 -08:00
Gabriel Ebner
1437ee9599 fix(kernel/type_checker): disable expression caching in asynchronous proof checking 2017-02-16 07:44:12 -08:00
Leonardo de Moura
ad713c81b4 perf(library/vm/vm_nat): use __builtin_expect to optimize nat operations
@gebner I used the __builtin_expect trick to optimize the vm_nat module.
Most of the time, we are processing small numbers.
In the following example, the runtime went from 7.27 secs to 6.6 secs
on my machine.

def mk (a : nat) : nat → list nat
| 0     := []
| (nat.succ n) := a :: mk n

def Sum : list nat → nat → nat
| []      r := r
| (n::ns) r := Sum ns (r + n)

def loop : nat → nat → nat
| s 0            := s
| s (nat.succ n) := loop (s + (Sum (mk (n % 2) 1000000) 0)) n

vm_eval timeit "time" $ loop 0 30
2017-02-15 23:25:26 -08:00
Leonardo de Moura
bff3e44656 fix(library/vm/vm): compilation error when multi threading is disabled 2017-02-15 22:50:44 -08:00
Leonardo de Moura
c1c1cd417a fix(frontends/lean/builtin_exprs): make sure we use internal names (i.e., names starting with _) when compiling do-blocks
@johoelzl This commit fixes the problem you reported at slack.
2017-02-15 22:45:59 -08:00
Leonardo de Moura
368e2bce80 feat(library/compiler/preprocessor): ignore propositions in the preprocessor
Suppose we have

    def foo : some_proposition :=
    by non_trivial_automation

Moreover, assume non_trivial_automation generates a huge proof.
Since this definition is marked with `def`, it is sent to the VM
compiler. In this kind of scenario, the compiler preprocessor was
spending a long time applying "useless" preprocessing steps.
We say they are useless because in the end everything is erased.

I think we should make sure every definition has some bytecode
associated with it in the VM even if the type of the definition
is a proposition. In this way, we have a simple invariant:

      every definition has a vm_decl associated with it.

So, we workaround the performance problem above by short-circuiting
the preprocessor for propositions.
2017-02-15 22:11:53 -08:00
Leonardo de Moura
8f2a8a3cd3 chore(tests/shell): leftover 2017-02-15 21:40:27 -08:00
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