Commit graph

133 commits

Author SHA1 Message Date
Leonardo de Moura
0d97700c60 feat(library/compiler): add support for and.rec in the code generator 2017-04-16 13:31:37 -07:00
Leonardo de Moura
470f2bc547 feat(library/compiler, library/vm): remove additional irrelevant information 2017-04-16 12:46:14 -07:00
Leonardo de Moura
60dd85719c feat(library/system/io): system.io without axioms 2017-03-22 23:36:05 -07:00
Sebastian Ullrich
16558bf082 refactor(library,library): rename pre_monad to has_bind 2017-03-09 20:32:25 -08:00
Sebastian Ullrich
763097dbd2 refactor(library): revise the monadic hierarchy 2017-03-09 20:30:03 -08:00
Leonardo de Moura
b0a33259ee fix(library/compiler/simp_inductive): array^.data should not be treated as a regular projection 2017-03-09 19:11:51 -08:00
Leonardo de Moura
6916a8ceca fix(library/compiler/inliner): inliner was unfolding constants aggressively when trying to reduce projections
@digama0 After this commit, your example will also produce a
non-destructive update.

```lean
structure test :=
(data1 : array nat 3)
(data2 : array nat 3)
(sz: nat)

def test.write (s : test) (i : fin 3) (v : nat) :=
{s with data1 := s^.data1^.write i v, data2 := s^.data2^.write i v}

set_option trace.array.update true
  (fin.of_nat 1) 10 in
  (a^.data1^.read (fin.of_nat 1), a^.data2^.read (fin.of_nat 2)) -- destructive write
```
2017-03-09 18:52:27 -08:00
Leonardo de Moura
4ab0a6d8d2 fix(library): problems with the subtype constructor and field renaming
The problem was not detected by the test suite because of issue #1446
2017-03-08 19:42:12 -08:00
Leonardo de Moura
ceeb77ec8c fix(library/compiler/erase_irrelevant): erase types of irrelevant lambdas
This modification makes sure we do not create unnecessary closures,
and avoid artificial dependencies that may prevent destructive updates.
2017-03-08 14:48:45 -08:00
Leonardo de Moura
943576b8e9 feat(library/compiler/extract_values): restrict extra_values to nat/int/char/string/name 2017-03-07 11:14:32 -08:00
Sebastian Ullrich
5d68938a9c feat(frontends/lean): expr literals ```(...) 2017-03-05 08:37:16 -08:00
Leonardo de Moura
22988bb95d feat(library/compiler): avoid pack/unpack overhead produced by the inductive_compiler in the code generator
TODO: make sure the user is not manually using cases_on for the
auxiliary datatype generated by the inductive_compiler to
destruct nested inductives.
2017-03-04 13:54:44 -08:00
Leonardo de Moura
184d505d51 fix(library/compiler/preprocess): do not unfold noncomputable definitions in the compiler
see #1401
2017-02-26 22:05:16 -08:00
Leonardo de Moura
d9307413b9 feat(library/compiler): skip bytecode optimization for interactive tactics
This is just overhead for begin...end blocks.
Moreover, "live variable analysis" is currently a recursive
procedure, and Lean will run of stack space when processing big begin
end blocks (> 1000 tactics).
2017-02-21 21:23:58 -08:00
Leonardo de Moura
622e9a6035 feat(library/type_context): use m_unfold_pred to decide whether macros should be unfolded or not
see #1394
2017-02-21 18:07:39 -08:00
Leonardo de Moura
e9a98362d3 feat(library): functional arrays 2017-02-20 22:00:02 -08:00
Sebastian Ullrich
9d8c84713c refactor(*): reduce exception context info from expr to pos_info 2017-02-17 13:45:57 +01:00
Sebastian Ullrich
5ed1ac924c feat(frontends/lean/elaborator): support partially applied eval_expr 2017-02-17 13:03:47 +01: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
707cf45a26 refactor(library/type_context): rename whnf_pred => whnf_head_pred 2017-02-15 20:20:27 -08:00
Leonardo de Moura
2c0a5a5120 fix(library/compiler/erase_irrelevant): remove broken io monad optimization
It doesn't work when combined with inlining and common-subexpression-elimination
2017-02-07 21:24:31 -08:00
Leonardo de Moura
a8c91aa6fc fix(library/compiler/preprocess): expand eq.cases_on
The code generator was failing to erase eq.cases_on.
2017-02-07 21:19:01 -08:00
Leonardo de Moura
53667dd602 fix(library): change API and make sure we don't crash when searching for a non existing local decl
Fixes #1363

After error recovery has been implemented in the elaborator, a few
assumptions made in the type context are not valid anymore since we may
be recovering from errors, and the local and metavariable contexts may
be invalid.

I used the approach used in the class environment.

- find* methods return optional<...>
- get* methods throw exception for unknown elements

Remarks:

I preserved code patterns such as

     optional<local_decl> d = lctx.find_local_decl(...)
     lean_assert(d)

and did not convert them into

     local_decl d = lctx.get_local_decl(...)

Reason: the intention is clear that the local must be defined there.
If it is not we should analyze the problem and decide whether we should
throw an exception or not.

However, I converted code patterns such as

    local_decl d = *lctx.find_local_decl(...)

into

    local_decl d = lctx.get_local_decl(...)

Disclaimer: this change fixes issue #1363, but it may obfuscate other bugs.
2017-02-07 09:38:19 -08:00
Gabriel Ebner
95068e4e79 feat(library/sorry): make sorry a macro 2017-02-05 14:01:03 +01:00
Gabriel Ebner
61804eb8e9 chore(util/sexpr): remove mpz and mpq cases 2017-01-31 09:39:31 +01: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
3178f41cce fix(library/compiler/inliner): applications of definitions marked as [inline] are inlined even if they are not fully applied
see #1316
2017-01-17 16:33:19 -08:00
Leonardo de Moura
fc00275636 fix(library/compiler/elim_recursors): it was assuming that recursive arguments occur after non recursive ones 2017-01-16 22:59:17 -08:00
Leonardo de Moura
ad8c241129 perf(library/compiler/eta_expansion): conservative eta_expansion
We only eta_expand where needed (e.g., partial constructor/projection/recursor applications).
2017-01-12 11:18:16 -08:00
Leonardo de Moura
1977b4ff3f fix(library/compiler/vm_compiler): bytecode generation error
This bug was introduced by commit 2bd400964c
when we decided to store arguments in reverse order.
2017-01-12 11:18:16 -08:00
Leonardo de Moura
1f2b8745dc fix(library/compiler): prevent let-expressions from being expanded 2017-01-12 11:18:16 -08:00
Leonardo de Moura
2df280431a fix(library/compiler/comp_irrelevant): fix #1302 2017-01-11 11:10:17 -08:00
Leonardo de Moura
b526e30c55 fix(library/compiler/cse): common subexpressions inside common subexpressions were not being eliminated 2017-01-09 11:11:55 -08:00
Gabriel Ebner
9435762643 fix(compiler/vm_compiler): only compile computable non-builtin definitions 2017-01-04 16:30:22 -08:00
Leonardo de Moura
a516d384ae fix(library/compiler/erase_irrelevant): make sure io monad actions are not erased by dead code elimination optimization 2017-01-02 01:42:36 -08:00
Leonardo de Moura
b313328cb9 feat(library/equations_compiler): int constants 2016-12-25 10:00:18 -08:00
Leonardo de Moura
5f72e37501 chore(library/vm): fix warning 2016-12-20 10:19:20 -08:00
Leonardo de Moura
bd2f9bce05 fix(library/compiler/erase_irrelevant): issue created by elim_unused_lets optimization 2016-12-14 18:51:53 -08:00
Leonardo de Moura
6e3959de2f feat(library/compiler): create declarations for nested values 2016-12-12 10:37:58 -08:00
Leonardo de Moura
502413d5dd chore(library/compiler/elim_unused_lets): style 2016-12-12 08:32:42 -08:00
Leonardo de Moura
028bf36152 feat(library/compiler): eliminate unused let declarations 2016-12-12 08:23:37 -08:00
Leonardo de Moura
abfea1f388 feat(library/compiler/cse): ignore 0-ary macros during common subexpression elimination 2016-12-12 07:40:46 -08:00
Leonardo de Moura
fbc1bb4d89 perf(library/compiler): add common subexpression elimination
It addresses a performance problem reported by Brian (huffman@galois.com).
2016-12-11 14:43:51 -08:00
Leonardo de Moura
6577cc87a3 feat(library): add pre_monad
closes #1235
2016-12-08 12:48:55 -08:00
Jared Roesch
e65d90ac79 feat(*): C++ code generator
in progress move of Lean.native to init
2016-12-05 16:11:41 -08:00
Leonardo de Moura
62d6b88570 fix(library/compiler/preprocess): make sure let-expressions are not expanded in the compiler preprocessor 2016-11-22 10:24:13 -08:00
Leonardo de Moura
e16e9880f7 chore(library/system): enforce Lean naming conventions IO ==> io 2016-11-17 11:27:37 -08:00
Leonardo de Moura
fffe69fdf9 feat(library/vm,library/tactic/vm_monitor): use optionT to define vm monad 2016-11-14 16:13:56 -08:00
Leonardo de Moura
7232e3a076 feat(library/vm/vm): invoke debugger (aka vm_monitor) 2016-11-14 14:45:49 -08:00
Leonardo de Moura
e673fa65ba feat(library/vm/vm): Store position information at vm_decl's 2016-11-11 15:39:32 -08:00