Commit graph

72 commits

Author SHA1 Message Date
Leonardo de Moura
fd5bfc7dfe refactor(kernel): simplify binder_info
Now, it is an enumeration type like its Lean counterpart.
2018-06-20 15:31:40 -07:00
Leonardo de Moura
c5714c2fac chore(kernel): remove expr.macro constructor
We are now ready to implement `expr` using `runtime/object`.
2018-06-19 17:54:43 -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
3356c1d08d refactor(library,frontends/lean): move choice to frontends/lean
Remark: `choice` will be a syntax object in Lean4
2018-06-18 13:43:42 -07:00
Leonardo de Moura
0847571ea6 feat(kernel): add mdata constructor 2018-06-18 13:36:22 -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
71fc35af1d chore(library/vm): remove meta rb_map
We should use the non-meta rbmap that is implemented in Lean.
2018-06-14 17:34:43 -07:00
Leonardo de Moura
78192972e9 chore(kernel): expr_kind::Meta ==> expr_kind::MVar 2018-06-14 15:13:45 -07:00
Leonardo de Moura
73e067d361 feat(kernel): add expression literals 2018-06-14 14:55:14 -07:00
Leonardo de Moura
4c370e4558 refactor(kernel/expr): fix binder_info 2018-06-13 12:20:58 -07:00
Leonardo de Moura
335c58f8a7 feat(kernel): add expr_kind::Quote
This is a temporary expr constructor. We need it to be able to eliminate
expr_macro, and then define expr using runtime/object
2018-06-12 17:40:00 -07:00
Leonardo de Moura
a6250840d5 chore(kernel): rename some expr functions 2018-06-09 07:18:24 -07:00
Leonardo de Moura
1612aca0b2 chore(kernel): rename expr kinds 2018-06-09 06:50:14 -07:00
Leonardo de Moura
62788a9ca3 refactor(kernel): fix terminology: "free_var" is actually a loose bound variable
We represent free variables uisng local constants.
We will fix this terminology too.
2018-06-08 13:25:36 -07:00
Leonardo de Moura
ee7bc150f2 chore(library/init/meta/expr): remove elaborated : bool parameter from expr 2018-06-06 09:47:01 -07:00
Leonardo de Moura
3a7229add3 chore(library/init): pexpr is now an opaque constant 2018-06-06 09:36:22 -07:00
Leonardo de Moura
ab481d7e7b chore(library/init/meta): remove unnecessary primitives 2018-06-05 16:13:22 -07:00
Leonardo de Moura
45202eca16 chore(library/init/meta): cleanup 2018-06-05 15:32:59 -07:00
Leonardo de Moura
1332fbabd6 feat(library,frontends): remove sorry macro
Lean4 will not have macros.
2018-05-24 14:00:30 -07:00
Leonardo de Moura
75c63ec921 refactor(*): list<name> ==> obj_list<name> 2018-05-23 15:48:43 -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
160b7e8847 refactor(library/init/meta/expr): local_const will have only one field
In Lean3, we supported two kinds of local constant:
context-less (inherited from Lean2) and context-based (type,
binder-info and pretty printing name are stored in the context).
The context-less was used in the kernel and a few modules we kept when
we moved from Lean2 to Lean3. Even if we keep the hybrind
representation, we should not expose the context-less to users.
2018-05-21 15:36:09 -07:00
Leonardo de Moura
4de9b8c177 chore(library/vm): rename constants 2018-05-20 12:30:15 -07:00
Leonardo de Moura
1e11611388 chore(library): cleanup constants.txt 2018-04-12 16:43:11 -07:00
Leonardo de Moura
db4b00c7d8 chore(util,library): remove small_object_allocator
We use small_object_allocator to allocate vm_obj's.
However small_object_allocator is not thread safe. So, we need to copy
vm_obj's between threads. Moreover, in our experiments, we observed that
JEMALLOC is actually faster than the small_object_allocator.

Here are numbers for the reduced corelib.

small_object_allocator:  15.62 secs
gcc 4.9 allocator:       16.19 secs
jemalloc:                13.83 secs
2018-04-12 16:43:10 -07:00
Leonardo de Moura
9afb53fad5 feat(kernel/expr): allow metavariables to have user-facing names
We need this feature for:
1) Defining nonlinear search patterns. Example: (?m <= ?m + 1)
2) Preprocessing recursive equations and support the pattern
refinement approach used in Agda. Example: in Agda, they accept
```
def append {A : Type} : Π (m n : nat), Vec A m -> Vec A n -> Vec A (m + n)
| m n nil            ys := ys
| m n (cons m' x xs) ys := cons x (append m' n xs ys)
```
These equations have to be refined. For example, `m` has to be
replaced with `0` (in the first equation), and `succ m'` in the
second. To implement this kind of refinement, we need to convert
the pattern variables (local constants) into metavariables during
elaboration. Then, the unassigned metavariables become local constants
again. This preprocessing step will fix some of the issues on #1594.
To completely fix #1594, we will need yet another preprocessing step
which will implement "complete transition" used in the equation
compiler before we start elim_match.cpp
2017-07-16 07:16:41 -07:00
Gabriel Ebner
b0185774a4 fix(library/vm/vm_expr): do not use expr_var as both function and class name 2017-07-04 09:10:35 +02:00
Leonardo de Moura
d73facb8bc feat(library/init/meta/expr): add expr.has_local_in 2017-07-01 20:23:37 -07:00
Leonardo de Moura
b8fa7f5311 fix(library): expr, level, hash_map, rb_map has_repr instances should be has_to_string since they do not produce results that can be parsed by Lean
See #1664
2017-06-18 18:33:27 -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
Sebastian Ullrich
283d8ade1a fix(library/quote): use opaque macro for elaborated expr quotations 2017-06-07 10:00:17 -07:00
Gabriel Ebner
04f9eb0b4f refactor(library/init/meta/expr): pure Lean implementation of reflected 2017-06-01 10:17:51 +02:00
Leonardo de Moura
42eeb445d4 fix(library): make sure `(t) does not evaluate t
See #1631
2017-05-31 22:03:15 -07:00
Leonardo de Moura
e163b5c884 feat(library/init/meta/expr): binder_info.other ==> binder_info.aux_decl 2017-05-23 21:42:52 -07:00
Sebastian Ullrich
84997bf4de refactor(init/meta/expr): unify expr and pexpr 2017-05-17 10:38:12 -07:00
Sebastian Ullrich
808ab73d93 refactor(init): use list for expr.macro args 2017-05-14 19:17:28 -07:00
Sebastian Ullrich
42eb0c680e feat(kernel/inductive,library/inductive_compiler): do not enforce positivity rule on meta inductives 2017-05-14 19:17:28 -07:00
Gabriel Ebner
b3975c8fc1 chore(library/vm/vm_expr): fix compiler warning 2017-05-11 11:04:11 +02:00
Sebastian Ullrich
4b21b13649 refactor(init): replace has_quote class with reflected 2017-05-09 16:02:42 -07:00
Sebastian Ullrich
ead6318ee0 feat(frontends/lean/elaborator): substitute reflected locals into expr quotes 2017-05-09 16:02:41 -07:00
Sebastian Ullrich
2825c5fbcc feat(frontends/lean/elaborator): elaborate ``(e) to type reflected e` if possible and add coercion reflected -> expr 2017-05-09 16:02:41 -07:00
Sebastian Ullrich
0ca6e2c96f refactor(library/{type_context,compiler/preprocess},frontends/lean/elaborator): use opaque, general type class instead of special app elaboration for eval_expr 2017-04-27 16:04:59 -07:00
Sebastian Ullrich
026c5ee509 fix(library/init/meta/expr,library/vm/vm_expr): fix macro args 2017-04-11 17:07:28 -07:00
Leonardo de Moura
31b6dc222d feat(library/init/meta/expr): add expr.is_annotation 2017-03-18 13:40:11 -07:00
Sebastian Ullrich
5d68938a9c feat(frontends/lean): expr literals ```(...) 2017-03-05 08:37:16 -08:00
Johannes Hölzl
bb4920fcbc feat(library/vm/vm_expr): export instantiate_univ_params 2017-02-17 20:08:18 -08:00
Sebastian Ullrich
e8fa54cc51 refactor(init/meta): move macro creation defs from expr to pexpr 2017-02-17 13:45:57 +01:00
Sebastian Ullrich
d15591a2d8 feat(library,frontends/lean): expose parser to Lean and use for parsing tactic parameters 2017-02-17 13:45:56 +01:00
Gabriel Ebner
93d00534e0 fix(library/vm): enable bounds checks 2017-02-15 13:39:00 -08:00
Leonardo de Moura
5ca18b8d2e feat(library/init/meta): add helper functions 2017-02-11 16:52:06 -08:00