Commit graph

28 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
32e6442d0a feat(frontends/lean): no global universes in the frontend 2017-02-08 17:23:04 -08:00
Leonardo de Moura
6e7929252f feat(frontends/lean, library/init): add 'thunk' gadget
We can now write
   trace "hello" t
instead of
   trace "hello" (fun _, t)
2017-01-31 18:41:59 -08:00
Leonardo de Moura
d3db3661af refactor(library/init/core): simpler has_sep type class with out_param 2017-01-30 18:54:56 -08:00
Leonardo de Moura
04a8518104 refactor(library/init/core): simpler has_insert type class with out_param 2017-01-30 18:50:21 -08:00
Leonardo de Moura
f176c272b4 refactor(library/init/core): simpler has_mem type class with out_param 2017-01-30 18:43:05 -08:00
Leonardo de Moura
5da8b205b9 feat(library/type_context, frontends/lean/elaborator): type classes with output parameters 2017-01-30 18:32:54 -08:00
Leonardo de Moura
41bf46dbba chore(library/init): adjust Sort vs Type in definitions 2017-01-30 12:50:18 -08:00
Leonardo de Moura
3b38f71f11 fix(library,tests/lean): fix run/interactive tests, and problems in the standard library due to the new interpretation for Type
We had to change subtype to use Sort since the axiom
strong_indefinite_description uses it.

see #1341
2017-01-30 11:54:00 -08:00
Leonardo de Moura
a6f26f0b74 chore(library): poly_unit ==> punit
psum, pprod and punit are used internally.

see #1341
2017-01-30 11:54:00 -08:00
Leonardo de Moura
77a9feaf70 refactor(frontends/lean): PType ==> Sort
see #1341
2017-01-30 11:54:00 -08:00
Leonardo de Moura
bf9f7560f7 feat(frontends/lean): (Type u) can't be a proposition
(Type u)  is the old (Type (u+1))
(PType u) is the old (Type u)
Type*     is the old (Type (_+1))
PType*    is the old Type*

The stdlib can be compiled, but we still have > 70 broken tests

See discussion at #1341
2017-01-30 11:54:00 -08:00
Leonardo de Moura
9107439bce feat(frontends/lean/elaborator): default parameter prototype
See #1340
2017-01-27 16:32:22 -08:00
Leonardo de Moura
0ba60e62d7 feat(kernel/quotient/quotient): make quotient module robust against users that define their own prelude's
Before this commit, an user could define their own prelude and change
the types of quot, quot.mk, quot.lift or quot.ind.
By doing that, they could prove false.

This commit prevents this kind of abuse.
It also modifies the definition of `quot` and avoids the `setoid`
dependency.
The previous `quot` type is now called `quotient`, and it is defined
using the new `quot` type provided by the kernel.

See discussion at #1330
2017-01-24 15:59:38 -08:00
Gabriel Ebner
4d4e47921a fix(library/init/core): mark all rfl-lemmas as lemmas 2017-01-05 18:09:28 -08:00
Leonardo de Moura
b313328cb9 feat(library/equations_compiler): int constants 2016-12-25 10:00:18 -08:00
Leonardo de Moura
fb38b6e016 refactor(library/init): move combinator logic to core 2016-12-02 15:56:52 -08:00
Leonardo de Moura
00f5a807af refactor(library/init): create init.category folder 2016-12-02 15:52:49 -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
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
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
f483c44968 chore(library/init/core): remove obsolete comment 2016-10-03 11:48:37 -07:00
Leonardo de Moura
96538ba899 refactor(library/init): add basic order classes 2016-10-02 07:53:37 -07:00
Leonardo de Moura
3a3c43f381 refactor(library/init): move unification_hint structure to init folder 2016-09-28 09:35:19 -07:00
Leonardo de Moura
6207dd0346 refactor(library/init): simplify has_emptyc type class 2016-09-27 10:03:57 -07:00
Leonardo de Moura
c6609543d0 chore(library/init): minor changes 2016-09-27 07:23:51 -07:00
Leonardo de Moura
d5a28f91cc refactor(library/init): reorganize files and cleanup notation 2016-09-25 13:37:45 -07:00
Renamed from library/init/datatypes.lean (Browse further)