Commit graph

3206 commits

Author SHA1 Message Date
Leonardo de Moura
19cf5e916b chore(script/gen_constants_cpp): generates a warning if automatically generated C++ function is not used in the source code 2017-02-21 12:05:41 -08:00
Leonardo de Moura
7e6a10bd1b chore(tests/lean): fix tests, and environment.decl_pos 2017-02-21 11:21:02 -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
04fd50e4e8 chore(*): fix tests and style 2017-02-20 23:53:44 -08:00
Leonardo de Moura
e9a98362d3 feat(library): functional arrays 2017-02-20 22:00:02 -08:00
Leonardo de Moura
f5cbdff893 feat(library/tools/mini_crush/default): provide equational lemmas for "relevant" functions to rsimp; make sure we do not get stuck in ematching loop by using try_for 2017-02-19 20:56:13 -08:00
Leonardo de Moura
f140095d7b feat(library/tools/mini_crush/default): improve mini_crush 2017-02-19 20:26:30 -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
a41aac0e6a feat(library/tools/mini_crush): add tracing messages, and more examples 2017-02-19 17:27:09 -08:00
Leonardo de Moura
0fb5a01f17 feat(library/tools): add mini_crush 2017-02-19 16:21:12 -08:00
Leonardo de Moura
ec6e1e389b chore(tests/lean/run/cpdt): simplify 2017-02-19 13:49:19 -08:00
Leonardo de Moura
50f4a28fc3 feat(library/init/meta/smt/interactive): rsimp for smt_tactic 2017-02-19 13:31:03 -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
Leonardo de Moura
74f7bc0473 feat(frontends/lean): improve notation for converting infix notation into functions 2017-02-17 23:11:22 -08:00
Leonardo de Moura
077176b82f feat(frontends/lean): add Haskell-like for converting infix notation into functions
Examples:

 qsort (<) [20, 5, 10, 3, 2, 14, 1]

 foldl (+) 0 [1, 2, 3]
2017-02-17 22:51:50 -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
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
98b2eb893d chore(tests/lean/run): fix tests 2017-02-17 19:55:49 -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
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
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
339713091f refactor(frontends/lean): simpler field notation info that also works with implicit parameters 2017-02-17 13:03:47 +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
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
7886a78967 fix(library/vm/vm): incorrect lean_vm_check 2017-02-16 11:39:23 -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
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
Gabriel Ebner
1d301b7813 feat(init/meta/smt/congruence_closure): add has_to_tactic_format instance 2017-02-15 13:38:30 -08:00
Leonardo de Moura
11d5773560 refactor(library/init/meta): remove whnf_core 2017-02-14 18:39:57 -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
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
Rob Lewis
d6ec20304f fix(norm_num): handle embedded nat subtraction 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
1306e56381 feat(library/vm): check heartbeat in function calls 2017-02-12 12:29:32 -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
9210e45da0 feat(frontends/lean): add notation for ';' and '<|>' in the tactic interactive mode 2017-02-10 22:53:30 -08:00
Leonardo de Moura
8bd5a51db4 test(tests/lean/run/quote_base): add example from Bas' paper 2017-02-10 18:34:53 -08:00
Johannes Hölzl
9902a0d4d1 feat(src/library/tactic): apply_core returns list of all generated metavariables 2017-02-10 16:07:33 -08:00