Commit graph

13903 commits

Author SHA1 Message Date
Leonardo de Moura
fc840eab3f feat(library/init/lean/ir): add emit_unop 2018-05-09 18:20:46 -07:00
Leonardo de Moura
c7153f7661 chore(library/init/lean/ir/extract_cpp): cleanup 2018-05-09 18:03:00 -07:00
Leonardo de Moura
9345765815 feat(library/init/lean/ir/extract_cpp): start IR => C++ extractor 2018-05-09 17:47:55 -07:00
Leonardo de Moura
60c8ff2472 feat(util/lean_obj): add some missing primitives 2018-05-09 17:43:40 -07:00
Leonardo de Moura
7d196f58c3 chore(library/init/lean/ir): remove ashr 2018-05-09 17:43:25 -07:00
Leonardo de Moura
5baae4724f feat(library/init/lean/ir): distinguish free and dealloc 2018-05-09 17:43:12 -07:00
Leonardo de Moura
8a6d2125b3 chore(library/init/control/combinators): remove top-level mmap and related combinators
The top-level `mmap` should use the `traversable` typeclass that will be
defined in the future.
2018-05-09 15:49:13 -07:00
Leonardo de Moura
3be7540efe chore(library/init): use mfor instead of mmap' 2018-05-09 15:41:53 -07:00
Leonardo de Moura
63bddd56d6 feat(library/init/data/rbmap,library/init/data/rbtree): add mfold and mfor for rbtree/rbmap 2018-05-09 15:38:57 -07:00
Leonardo de Moura
014735e498 feat(library/init/control/combinators): remove unnecessary universe constraint from list.mmap'
This commit also adds the alias `mfor` for `mmap'`
2018-05-09 15:38:35 -07:00
Leonardo de Moura
6368d0c5f6 chore(library/init/lean/name_mangling): allow custom prefix when mangling names 2018-05-09 15:01:12 -07:00
Leonardo de Moura
83415ea44c feat(library/init/control/except): add instance has_monad_lift (except ε) (except_t ε m) 2018-05-09 12:19:44 -07:00
Leonardo de Moura
d5fd86791d chore(tests/lean/run/ext_eff*): reduce number of iterations
My machine was taking forever to run these tests in debug mode.
2018-05-09 10:52:33 -07:00
Leonardo de Moura
14e19502f0 chore(tests/lean/run/type_class_performance1): remove #exit 2018-05-09 10:24:45 -07:00
Leonardo de Moura
f8cedb33e7 fix(library/type_context): bug introduced at d85c30fde1 2018-05-09 10:18:53 -07:00
Leonardo de Moura
d05e93f763 test(tests/lean/run/name_mangling): add tests for name mangling 2018-05-09 10:10:00 -07:00
Leonardo de Moura
0c0972f317 feat(library/init/lean): name mangling 2018-05-09 09:19:32 -07:00
Leonardo de Moura
3f883bd949 chore(library/init/lean/parser/parser): add monad_fail instance 2018-05-09 09:19:14 -07:00
Leonardo de Moura
874f9caf13 feat(library/init/control/state): modify monad_run instance for state_t
@Kha, I was having to use `(run ...).1` in many places
in my code. So, I changed the instance
```
instance (σ m out) [monad_run out m] : monad_run (λ α, σ → out (α × σ)) (state_t σ m) :=
⟨λ α x, run ∘ (λ σ, x.run σ)⟩
```
to
```
instance (σ : Type u) (m out : Type u → Type v) [functor m] [monad_run out m] : monad_run (λ α, σ → out α) (state_t σ m) :=
⟨λ α x, run ∘ (λ σ, prod.fst <$> (x.run σ))⟩
```
If we want to get the resultant state in an action `act`, we can just
use `run (act >> get) init_state`.
2018-05-08 17:32:54 -07:00
Leonardo de Moura
b0641ba770 feat(frontends/lean/elaborator): add support for definitions such as monad_run.run
cc @Kha
2018-05-08 17:14:52 -07:00
Leonardo de Moura
b77cd740a8 test(tests/lean/run/display_hw_term_hack_deps): add helper function for displaying functions that use wf_term_hack 2018-05-08 16:28:42 -07:00
Leonardo de Moura
ab39ef261d refactor(library/init/lean/ir/ssa_check): use format instead of blockid_error 2018-05-08 15:47:02 -07:00
Leonardo de Moura
60a275a464 chore(library/init/lean/ir/elim_phi): use idiom: define run for every monad 2018-05-08 15:46:30 -07:00
Leonardo de Moura
7f85f0893c refactor(library/init/lean/ir): cleanup 2018-05-08 15:38:43 -07:00
Leonardo de Moura
4f75e49da8 feat(library/init/control/except): add monad_except _ except instance 2018-05-08 15:38:20 -07:00
Leonardo de Moura
00147df082 chore(library/init/lean/ir/ssa_check): use format for error messages 2018-05-08 14:50:58 -07:00
Leonardo de Moura
9373133800 chore(library/init/lean/ir/type_check): cleanup 2018-05-08 14:50:28 -07:00
Sebastian Ullrich
4ed7b57903 test(tests/lean/run/ext_eff): add IO exception handling example 2018-05-08 17:29:12 +02:00
Leonardo de Moura
50f883a946 chore(tests/lean/parser1): fix test 2018-05-07 18:11:41 -07:00
Leonardo de Moura
e40f37b08e feat(library/init/lean/ir): add type checker 2018-05-07 18:07:04 -07:00
Leonardo de Moura
d85c30fde1 perf(library/init/data): mark usize, uint16, uint32 and uint64 as [irreducible]
Without these annotations, Lean will timeout when trying to synthesize
the type class instance `decidable_eq uint32`. The type class resolution
problem will produce the unification problem:
```
decidable (@eq uint32 a b) =?= decidable (@eq usize ?x ?y)
```
which Lean tries to solve by assigning `?x := a`.
During the assignment, the types of `?x` and `a` are unified with "full
force". Thus, we get the constraint
```
usize_sz =?= uint32_sz
```
which will take forever to be solved when peforming the computation in
unary arithmetic.

Remark: this commit also makes sure that `type_context` will not unfold
irreducible definitions when trying to unify/match the types.

The new test `type_class_performance1.lean` exposes the problem fixed
by this commit.
2018-05-07 18:07:04 -07:00
Leonardo de Moura
f7c4134452 refactor(library/init/lean/ir): we can use the cast instruction for boxing/unboxing 2018-05-07 18:07:04 -07:00
Leonardo de Moura
5b89f69e36 chore(library/init/data/dlist): add @[inline] 2018-05-07 18:07:04 -07:00
Leonardo de Moura
79f351d177 fix(library/init/lean/ir): parser and test 2018-05-07 18:07:04 -07:00
Leonardo de Moura
0a9bd8caa8 chore(library/init/lean/ir): improve sizet syntax 2018-05-07 18:07:04 -07:00
Leonardo de Moura
e6b509781f feat(library/init/lean/ir/ir): platform independent object size and offset 2018-05-07 18:07:04 -07:00
Sebastian Ullrich
91e3e2435a test(tests/lean/run/ext_eff): document quadratic run time issue and implement solution from paper
~3x slowdown on right-associated binds
2018-05-07 23:58:17 +02:00
Leonardo de Moura
883f6923e2 chore(library/init/lean/ir/elim_phi): fix typo 2018-05-06 10:15:17 -07:00
Leonardo de Moura
88082cd16d fix(library/init/lean/ir/parser): case 2018-05-06 10:11:58 -07:00
Leonardo de Moura
e2e124626f feat(library/init/lean/ir): add elim_phi function 2018-05-06 10:07:44 -07:00
Leonardo de Moura
89b4bb7210 feat(library/init/data/hashable): add hashable nat instance 2018-05-06 07:53:29 -07:00
Leonardo de Moura
3079d2d007 feat(library/init/lean/name): add hashable instance 2018-05-06 07:49:17 -07:00
Leonardo de Moura
162f817fa3 feat(library/init/data/hashable): add builtin string hash 2018-05-06 07:28:05 -07:00
Leonardo de Moura
e64cb10ded feat(library/init): add hashable type class 2018-05-05 20:48:57 -07:00
Leonardo de Moura
d5fe509c36 chore(*): remove end after each match-expression
`end` is not optional anymore
2018-05-04 11:30:06 -07:00
Leonardo de Moura
752e0a134e chore(library/init/data/nat/basic): cleanup 2018-05-04 11:30:06 -07:00
Sebastian Ullrich
7da6d5c50d test(tests/lean/run/ext_eff): add extensible effects monad example 2018-05-04 19:44:33 +02:00
Leonardo de Moura
11a8a7c4f3 feat(library/init): use usize instead of uint32 in the low level array access primitives 2018-05-04 10:40:14 -07:00
Leonardo de Moura
af4f831a9f feat(library/init/data/hashmap): hash function produces an uint32 instead of nat
Most efficient hash functions use uint32/uint64 and produce values
that do not fit in out small nat representation. Thus, GMP big numbers
would have to be created.
2018-05-03 17:56:10 -07:00
Leonardo de Moura
7aeae54522 chore(tests/lean/trust0/basic): fix test 2018-05-03 15:57:59 -07:00