Commit graph

944 commits

Author SHA1 Message Date
Leonardo de Moura
01ea596aea refactor(kernel/expr): implement expr using runtime/object 2018-06-21 16:05:33 -07:00
Leonardo de Moura
a2c2d1d9e7 feat(util/object_ref): add ternary mk_cnstr 2018-06-20 14:25:09 -07:00
Leonardo de Moura
e14255e7ae chore(util/sexpr): remove sexpr serializer
It was dead code.
Moreover, sexpr will not be part of Lean4
2018-06-20 11:27:29 -07:00
Leonardo de Moura
9e7e600ad7 feat(kernel): add expr.proj constructor
TODO: implement infer_proj and reduce_proj
2018-06-19 15:45:49 -07:00
Leonardo de Moura
0847571ea6 feat(kernel): add mdata constructor 2018-06-18 13:36:22 -07:00
Leonardo de Moura
d704bfef17 fix(util/pair_ref): missing file 2018-06-18 08:19:32 -07:00
Leonardo de Moura
9ef934e090 chore(util): style 2018-06-15 16:05:11 -07:00
Leonardo de Moura
f7d73fb304 feat(util/kvmap): add C++ kvmap wrapper 2018-06-15 16:05:11 -07:00
Leonardo de Moura
13c532d0d4 fix(*): truncation bugs
- Lean strings (like std::string) may contain null characters. The
  codebase was ignoring this issue.

- We now have a wrapper `string_ref` for wrapping Lean string objects in
  C++. This wrapper also implements correctly the coercions std::string <-> string_ref.
  Remark: I also found a few places where the code relies on the
  following property which is not true
  Forall s : std::string, std::string(s.c_str()) == s

- `name` object wrapper was assuming that all numerals were small
  `nat` values. This is true in most cases, but the system would
  crash when processing if it is a big number.

- The commit tries to make sure runtime/util/kernel are correct.
  Modules that will be deleted contain many `TODO` comments
  indicating they may crash and/or produce incorrect results
  when strings contain null characters and numerals are big.

cc @kha

@kha: I thought about using `string` instead of `string_ref`.
We consistently use `std::string`. So, it should be fine, but I
was concerned about code readability.

After we bootstrap Lean4, we will be able to delete `lean::list`
template, and rename `lean::list_ref` to `lean::list`.

I am going to add `pair_ref` for wrapping Lean pair objects.
If we use `lean::string` instead of `lean::string_ref`, then
we should also use `lean::pair` instead of `lean::pair_ref`.
But, there is a problem in this case since we have
https://github.com/leanprover/lean4/blob/master/src/util/pair.h#L13
:(
2018-06-15 16:05:11 -07:00
Leonardo de Moura
c8a13a9ada refactor(*): name convention obj_list => list_ref
Remark: we use the `_ref` suffix for Lean object smart pointers
when the name clashes with an existing name.
2018-06-15 16:05:11 -07:00
Leonardo de Moura
fe2d416cde fix(runtime,util,kernel): should not use strcmp to compare Lean string objects
Reason:
- UTF8 encoding
- Lean strings may contain null char. That is, null char is not an end
  of string delimiter like in C. Lean string objects are similar to std::string
2018-06-15 16:05:11 -07:00
Leonardo de Moura
4878abfda4 chore(util/nat): fix style 2018-06-14 14:04:37 -07:00
Leonardo de Moura
017e1d7a5f fix(util/name): strcmp does not implement Lean string equality 2018-06-13 11:43:05 -07:00
Leonardo de Moura
4432629eb0 feat(util/nat): add C++ wrapper for manipulating runtime nat values 2018-06-13 09:29:52 -07:00
Leonardo de Moura
e90585737f refactor(*): use C++11 std::current_exception and std::rethrow_exception
With these new C++11 APIs, we can delete the `clone` and `rethrow`
methods from our exception classes.
2018-06-07 16:28:54 -07:00
Leonardo de Moura
0dd25b0a24 refactor(util,library): move subscripted_name_set to library 2018-06-05 08:06:32 -07:00
Leonardo de Moura
909284dd74 refactor(runtime): normlize object names 2018-06-01 15:34:42 -07:00
Leonardo de Moura
75c63ec921 refactor(*): list<name> ==> obj_list<name> 2018-05-23 15:48:43 -07:00
Leonardo de Moura
a1b9ae0e67 feat(util/obj_list): add map_reuse and cleanup code 2018-05-23 15:05:08 -07:00
Leonardo de Moura
4af1f31877 feat(util, kernel): add obj_list wrapper for Lean list objects, and use it to implement list of universe levels 2018-05-23 14:48:22 -07:00
Leonardo de Moura
ef8bbccf9f chore(util/object_ref): disable automatic coercion from object_ref to object * 2018-05-23 13:12:40 -07:00
Leonardo de Moura
3d46684d2a chore(util/name): minor change 2018-05-23 09:41:44 -07:00
Leonardo de Moura
e2a7d78dd6 chore(util/name): remove dead code 2018-05-22 17:57:33 -07:00
Leonardo de Moura
5b17a30203 feat(runtime): add object serializer
Any type implemented on top of `object` gets the serializer/deserializer for free
2018-05-22 16:34:41 -07:00
Leonardo de Moura
67b59a0a3c fix(util): memory leaks 2018-05-22 11:05:51 -07:00
Leonardo de Moura
df26e10609 fix(util): assertion violations 2018-05-20 13:42:22 -07:00
Leonardo de Moura
ce29de1b49 chore(util): style 2018-05-20 13:26:59 -07:00
Leonardo de Moura
256a1f720c refactor(util/name): implement name using object 2018-05-20 13:22:34 -07:00
Leonardo de Moura
dd6e56f3bf feat(util/object_ref): add smart pointer for object 2018-05-20 11:46:53 -07:00
Sebastian Ullrich
3a2fbe2d2f fix(util/init_module): segfault using clang 2018-05-20 11:01:37 +02:00
Leonardo de Moura
b1d8a17f1b fix(runtime): add init_module 2018-05-14 20:38:21 -07:00
Leonardo de Moura
8ee2f4fea1 feat(*): basic runtime string support 2018-05-14 16:52:55 -07:00
Leonardo de Moura
0556412f8d refactor(*): add runtime folder
@kha The runtime folder includes what is needed to link a
standalone Lean program. It is still contains some unnecessary files.
We will be able to remove them after we release Lean4.
2018-05-14 14:23:56 -07:00
Leonardo de Moura
095d100a38 chore(util/debug): remove logtree dependency 2018-05-14 11:09:07 -07:00
Leonardo de Moura
4fa1022388 fix(gen/apply): emit #pragma once 2018-05-14 11:08:45 -07:00
Leonardo de Moura
914f6907dc chore(util/lean_obj): remove unnecessary includes 2018-05-14 11:08:16 -07:00
Leonardo de Moura
1ab4c9f8bf feat(gen/apply): simplify over-application case and avoid quadratic blowup
The over-application doesn't occur very often in practice.
The new version adds an extra "copy" step, but it avoids the quadratic
blowup in code size.
Xavier Leroy reports that only 5% of all calls are over-applications
in his experiments.
In Lean3, 6.59% of all calls performed to compile corelib are "over",
and we did not implement any fancy optimization.
2018-05-12 15:10:26 -07:00
Leonardo de Moura
d02c36df18 chore(gen/apply): style 2018-05-11 18:01:58 -07:00
Leonardo de Moura
1d69493b83 feat(gen/apply): add generator for apply
It generates the functions at `util/apply.h` that are used by
the Lean runtime.
2018-05-11 17:54:09 -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
3be7540efe chore(library/init): use mfor instead of mmap' 2018-05-09 15:41:53 -07:00
Leonardo de Moura
c75387b5d3 chore(util/lean_obj): style 2018-04-24 15:23:53 -07:00
Leonardo de Moura
055518bacf feat(util/lean_obj): remove lean_string
We don't need anymore since we removed the field `m_length`.
We can use lean_sarray for implementing them.
2018-04-23 08:54:39 -07:00
Leonardo de Moura
49dbcfb1ac fix(util/lean_obj): static assertion is not supported on Clang
g++ 4.9 can check it statically, but clang++ fails (at least on OSX).
2018-04-20 11:28:45 -07:00
Leonardo de Moura
5cac9ee01d feat(util/lean_obj): add static_assert's to make the assumptions used in the object GC explicit 2018-04-20 11:16:58 -07:00
Leonardo de Moura
ccc433876e feat(util/lean_obj): develop lean_obj 2018-04-19 17:53:03 -07:00
Leonardo de Moura
3a93106596 feat(util/lean_obj): new objects for code extraction, virtual machine and implementing Lean itself
We will implement: format, name, options, level, expr, ... using this module.
2018-04-18 15:50:14 -07:00
Leonardo de Moura
4b6583ae9f refactor(util): move mpz/mpq to util
The new lean_obj objects will be defined at util.
Reason: we will define `name`, `options`, `format`, ... on top of lean_obj.
lean_obj depends on mpz.
Remark: lean_obj will replace vm_obj.
2018-04-12 16:43:11 -07:00
Leonardo de Moura
74f10fdf5c chore(numerics): remove numeric_traits
numeric_traits is dead code. It was used to implement a simplex that was
parametric on the number type. This code has been moved to Z3.
So, we don't need it anymore.
2018-04-12 16:43:11 -07:00
Leonardo de Moura
d1cdae9d90 chore(util/sequence): remove dead code 2018-04-12 16:43:10 -07:00