Commit graph

1952 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
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
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
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
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
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
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
ff7e691d66 feat(library/vm): add support for system.platform.nbits in the VM 2018-05-03 15:54:54 -07:00
Leonardo de Moura
acade175b6 feat(library/init/data/array): store dimension in the array
The array dimension is now stored inside the array.
The main motivation is that it reflects the actual runtime implementation.
We need to store the array size to be able to GC it.
So, it feels silly to have the array size stored in each array object,
but we cannot use this information.
For example, in the `hashmap` we implemented the bucket array using
`array`, and we store the `size` of the array.
Same for the Lean3 `buffer` object.
The `buffer` object doesn't even need to exist.
The actual `array` implementation is the `buffer`
2018-05-03 15:43:03 -07:00
Leonardo de Moura
668d198991 feat(library/init/data/usize): add usize 2018-05-03 15:43:00 -07:00
Leonardo de Moura
732d638bb8 chore(library/init/data/array/lemmas): remove array theorems 2018-05-03 15:38:42 -07:00
Leonardo de Moura
9aa459c7e1 feat(library/init/data/nat/basic): add auxiliary power theorems 2018-05-03 11:23:59 -07:00
Leonardo de Moura
c135d0ae61 chore(library/init/data/uint): cleanup 2018-05-03 10:42:50 -07:00
Sebastian Ullrich
bd7109dc02 chore(library/init/core): cleanup matches 2018-05-03 10:35:39 +02:00
Sebastian Ullrich
16190610dc feat(frontends/lean/match_expr): make end after match optional, remove eventually 2018-05-03 10:35:39 +02:00
Leonardo de Moura
82bf618972 feat(library/init/lean/disjoint_set): disjoint sets
We need this datastructure to eliminate phi nodes from the IR.
The phi nodes need to be eliminated when mapping to C++ and/or
interpreting the IR.
2018-05-02 22:24:33 -07:00
Leonardo de Moura
bf71068b14 feat(library/init/lean/ir): parse IR definitions 2018-05-02 16:59:50 -07:00
Leonardo de Moura
0d49ae3f69 feat(library/init/lean/parser): add not_followed_by and not_followed_by_sat
The new parsers are useful to implement the longest match rule.
2018-05-02 15:55:57 -07:00