Commit graph

33 commits

Author SHA1 Message Date
Leonardo de Moura
835b3a10cc chore(library/init): consistent names 2018-11-14 13:08:57 -08:00
Leonardo de Moura
c3d700ece1 feat(library/compiler/csimp): nat.succ x ==> x + 1 2018-10-29 13:53:59 -07:00
Leonardo de Moura
3ee863da68 feat(library/compiler/erase_irrelevant): eliminate cases_on for builtin types 2018-10-23 14:58:38 -07:00
Sebastian Ullrich
fea637288d fix(library/init/data/nat/basic,library/vm/vm_nat): regression in old compiler: primitive for nat equality was ignored
Improves parser performance by 26%
2018-09-14 16:33:04 -07:00
Leonardo de Moura
4de9b8c177 chore(library/vm): rename constants 2018-05-20 12:30:15 -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
ac13f8b0f9 feat(library/system/io): add random number generator support in the io monad
@aqjune @nunoplopes: See new tests at tests/lean/run/random.lean

We have two actions in `io`. By default, `io` uses the C++
random number generator, but we can force it to use a `std_gen` with
the action `set_rand_gen`.

def rand (lo : nat := std_range.1) (hi : nat := std_range.2) : io nat
def set_rand_gen : std_gen → io unit
2018-02-15 16:12:08 -08:00
Leonardo de Moura
394e0d5f0a refactor(library/init): remove has_cmp and is_ordering type classes
Now, `cmp` is just a fixed helper function.
In the future, we will be able to use (more efficient) specialized
versions during code generation by defining simp rules.
2017-11-14 08:33:24 -08:00
Leonardo de Moura
97d875eb9a perf(library/vm): add native int.cmp and nat.cmp 2017-11-09 14:18:28 -08:00
Leonardo de Moura
9399ce8346 feat(library/vm/vm_string): provide native implementation of type string in the VM
closes #1175

The types `string_imp` and `string.iterator_imp` were supposed to be
marked private, but we cannot do it because we need to provide
`string_imp.mk`, `string_imp.cases_on`, `string.iterator_imp.mk` and
`string.iterator_imp.cases_on` in the VM since we use a different
internal representation. Note that marking them as private does not
work since users can still access `string_imp.cases_on` using
meta-programming.
So, we need better support for private declarations.

Missing feature, char literals do not support non ASCII values.
That is, in the current implementation, we cannot write 'α'.
This will be implemented in the future.

The VM native implementation does not behave correctly for huge
strings (i.e., strings with more than 4G characters).
The problem is that the current implementation relies on
```
size_t force_to_size_t(vm_obj const & o, size_t def)
```
We may also have overflow problems in the string.iterator implementation
code. This is not a big deal right now, since I doubt we will try
to process string with more than 2^32 characters.

@Kha the `core_lib` and tests seem to be working correctly, but
we need more tests.
2017-10-23 10:55:26 -07:00
Mario Carneiro
ced436a707 fix(library/vm/vm_nat): fix VM definition of nat.shiftr
fixes #1723
2017-07-11 20:53:15 +01:00
Mario Carneiro
e705d89490 feat(init/data/int): bitwise ops for integers 2017-06-27 18:55:52 -07:00
Mario Carneiro
ebf15e34cb feat(library/vm/vm_nat): implementation of new bitwise ops 2017-06-27 18:55:52 -07:00
Leonardo de Moura
dc1a1c8540 refactor(library): has_to_string ==> has_repr
See issue #1664

This is just the first step to implement proposal described at issue #1664.
2017-06-18 18:29:19 -07:00
Leonardo de Moura
d489955600 fix(library/vm/vm_nat): bitwise operators 2017-05-30 13:09:17 -07:00
Mario Carneiro
9d676776b5 feat(library/vm/vm_nat): implementations of bitwise ops 2017-05-30 12:47:44 -07:00
Leonardo de Moura
ad713c81b4 perf(library/vm/vm_nat): use __builtin_expect to optimize nat operations
@gebner I used the __builtin_expect trick to optimize the vm_nat module.
Most of the time, we are processing small numbers.
In the following example, the runtime went from 7.27 secs to 6.6 secs
on my machine.

def mk (a : nat) : nat → list nat
| 0     := []
| (nat.succ n) := a :: mk n

def Sum : list nat → nat → nat
| []      r := r
| (n::ns) r := Sum ns (r + n)

def loop : nat → nat → nat
| s 0            := s
| s (nat.succ n) := loop (s + (Sum (mk (n % 2) 1000000) 0)) n

vm_eval timeit "time" $ loop 0 30
2017-02-15 23:25:26 -08:00
Leonardo de Moura
ba3303163d fix(library/vm/vm_nat): nat.has_decidable_eq has been renamed 2016-11-15 14:41:04 -08:00
Leonardo de Moura
b28e724709 feat(library/vm): expose 'environment' C++ object 2016-06-07 17:01:17 -07:00
Leonardo de Moura
fb6c9f2879 feat(library/vm/vm_expr): add more functions to 'expr' API 2016-06-06 11:26:19 -07:00
Leonardo de Moura
fe4fafd95d chore(library/vm): remove unnecessary includes 2016-06-03 13:07:06 -07:00
Leonardo de Moura
924f3629ee feat(library/vm): expose name of the C++ functions that implement builtins 2016-06-02 12:48:43 -07:00
Leonardo de Moura
a6a7daff59 refactor(library/vm): avoid constants.txt when creating bindings 2016-06-02 11:45:56 -07:00
Leonardo de Moura
8bccfc23da feat(library/vm): add example of C function invoking Lean closure 2016-05-31 18:45:14 -07:00
Leonardo de Moura
b31a7bd3e7 feat(library/vm): use cfunction style for nat and IO primitives 2016-05-31 17:22:27 -07:00
Leonardo de Moura
cc4b70e5e5 feat(library/vm/vm_nat): add native support for nat.to_string 2016-05-26 10:55:22 -07:00
Leonardo de Moura
af1908be94 feat(frontends/lean/decl_cmds): do not generate warning for definitions that are implemented in the VM 2016-05-13 18:17:20 -07:00
Leonardo de Moura
2bd400964c feat(library/vm/vm): store arguments in reverse order on the stack
It simplifies the code for handling closures.
2016-05-13 10:54:29 -07:00
Leonardo de Moura
a533cc56ec fix(library/vm/vm_nat): typo 2016-05-12 19:34:06 -07:00
Leonardo de Moura
9fbf3f2921 feat(library/vm): encode small numerals using scnstr instead of num operation 2016-05-12 16:43:21 -07:00
Leonardo de Moura
de327c0c20 feat(library/vm/vm_nat): add builtin support for nat lt 2016-05-12 16:36:37 -07:00
Leonardo de Moura
1393238c9d fix(library/vm/vm_nat): fix constant name 2016-05-12 15:29:14 -07:00
Leonardo de Moura
399b83122c refactor(library): move vm to a separate directory 2016-05-12 14:45:06 -07:00