Commit graph

248 commits

Author SHA1 Message Date
Leonardo de Moura
244b72befd feat: simpArrow 2021-01-01 17:15:15 -08:00
Leonardo de Moura
7b5f283507 chore: remove Expr.localE constructor
It was used by the old frontend
2020-11-01 09:37:48 -08:00
Sebastian Ullrich
7718795178 fix: mark Lean objects in C++ globals reachable from the new frontend as persistent
sed -Ei 's/(g_\w+)\s*= new (name|expr|format|level|string_ref)\W.*;/\0\n    mark_persistent(\1->raw());/' src/kernel/**/*.cpp src/util/**/*.cpp src/library/**/*.cpp
2020-10-11 17:43:28 +02:00
Leonardo de Moura
7c76a19885 chore: fix includes 2020-05-22 14:17:25 -07:00
Leonardo de Moura
8bdca35282 chore: use #include <lean/runtime/...> for runtime .h files 2020-05-18 11:30:07 -07:00
Leonardo de Moura
bccaaa7af0 fix: bug at lit_type binding
cc @kha
2020-01-06 15:44:38 -08:00
Leonardo de Moura
fdfff29bb1 feat: expose liftLooseBVars and lowerLooseBVars 2019-12-21 08:57:11 -08:00
Leonardo de Moura
8192828b9c fix: lean_expr_update_* functions 2019-12-11 10:15:21 -08:00
Leonardo de Moura
a3ccbe66cf refactor: Expr fully implemented in Lean
No hidden fields.
2019-11-16 12:10:49 -08:00
Leonardo de Moura
3ae5c2f2e4 chore: remove old comment 2019-11-15 14:11:50 -08:00
Leonardo de Moura
85092412c7 refactor: remove Expr.FVar hack
@Kha @dselsam:
This hack was preventing us from making `Expr` a "real" Lean type.
This was bad for a few reasons:
- It was hard to extend/modify `Expr` in Lean since we would also have
to modify the C++ code that creates the `Expr` objects with the hidden
fields.
- `Expr.lam` and `Expr.forallE` were not following the Lean layout
standard where we sort fields by size. @Kha: recall we used that to
avoid a UB. The issue with `Expr.lam` and `Expr.forallE` is that they
have a "visible" field (`BinderInfo`), which is smaller than
hidden fields such as hash code.
- `Expr.fvar` had only one field at `Expr.lean,` but four behind the
scenes.

I added a new constructor `Local` that is only accessible from C++.
It is only used in legacy code we inherited from Lean2.
We will eventually delete it.

This refactoring was quite painful since many parts of the codebase
were mixing the new `Expr.fvar` with the old `Expr.local`.
I doubt I would be able to do it without the new staging framework
@Kha built.

BTW, some of the patches are horrible. I didn't care much since we
are going to deleted the super ugly files. That being said,
you should expect new weird bevaior due to `Expr.fvar` vs `Expr.local`.

Next step: use the new `ExprCachedData` to make all `Expr` hidden visibles
accessible from Lean.

checkpoint
2019-11-15 14:04:26 -08:00
Leonardo de Moura
aea02eb1f8 chore: fix MVar refactoring issues 2019-11-15 10:04:42 -08:00
Leonardo de Moura
d9f3b4bf63 refactor: remove Expr.mvar hidden field 2019-11-15 10:04:42 -08:00
Leonardo de Moura
1e065d495b feat: expose hasLooseBVar 2019-11-09 12:29:50 -08:00
Leonardo de Moura
966882b85c feat: add Expr.updateMData 2019-10-25 10:57:17 -07:00
Leonardo de Moura
025e9d32ef feat: update functions for universe levels, use C version of Level.hasParam and Level.hasMVar 2019-10-24 19:04:01 -07:00
Leonardo de Moura
ba286dee8e chore: update stage0 2019-10-24 17:44:41 -07:00
Leonardo de Moura
cb210b0adc feat: expose Expr.hasExprMVar and Expr.hasLevelMVar 2019-10-24 17:32:47 -07:00
Leonardo de Moura
563da4522d chore: udpate stage0 2019-10-24 15:12:09 -07:00
Leonardo de Moura
d1c9a440d8 feat: add missing Expr.update* functions 2019-10-24 15:10:03 -07:00
Leonardo de Moura
93c6ab8eee feat: add Expr.updateApp test of concept 2019-10-23 15:19:34 -07:00
Leonardo de Moura
cc18c0ef91 feat(library/init/lean/expr): add Expr.hasFVar and Expr.hasMVar
cc @dselsam
2019-10-02 10:07:26 -07:00
Leonardo de Moura
68a93a358c fix(kernel/expr): initialization problem 2019-08-13 15:04:02 -07:00
Leonardo de Moura
34024256ab chore(library/init/lean/expr): simplify Expr.mvar constructor 2019-08-04 13:24:27 -07:00
Leonardo de Moura
1ef23950a4 chore(library/init/lean/expr): expose temporary legacy constructor 2019-08-04 08:03:09 -07:00
Leonardo de Moura
41d8cd9eb9 chore(kernel/expr): remove depth and weight fields
These fields were rarely used, but they were used in the hash code
calculation. So, we may see a negative performance impact.
There is also a positive performance impact since `Expr` consumes less
memory, and it is faster to allocate them.
2019-08-03 11:05:01 -07:00
Sebastian Ullrich
d45cc4cb7b fix(kernel): manually align unboxed fields 2019-07-26 12:39:35 -07:00
Leonardo de Moura
ac27bd092b chore(*): small fixes 2019-03-21 15:06:44 -07:00
Leonardo de Moura
811a480d77 feat(kernel/expr): low level API for expr 2019-02-13 14:59:18 -08:00
Leonardo de Moura
3444a295e7 feat(library/compiler,runtime): builtin support for lean.name 2019-02-05 12:57:46 -08:00
Leonardo de Moura
c3569dc72d feat(kernel): store structure name in proj-expressions 2018-10-02 09:23:11 -07:00
Leonardo de Moura
f0e24e73f4 feat(kernel/expr): missing constructor 2018-09-16 14:30:43 -07:00
Leonardo de Moura
4863ca071a chore(runtime): make sure we use the same naming convention for getters and setters 2018-09-09 10:07:00 -07:00
Leonardo de Moura
3e5f59d6df chore(kernel): remove expr.quote constructor
In Lean4, we will reify expressions.
2018-09-07 22:08:08 -07:00
Leonardo de Moura
96ff6b1718 feat(util/object_ref): add helper functions 2018-08-27 16:28:37 -07:00
Leonardo de Moura
f809758dd3 refactor(kernel/expr): remove extra field 2018-06-22 14:35:32 -07:00
Leonardo de Moura
e9f843ddf6 refactor(kernel/expr): remove mlocal_* functions
The constructors `mvar` and `fvar` have different memory layouts.
2018-06-22 14:25:31 -07:00
Leonardo de Moura
1371c636e5 refactor(kernel/expr): remove pp_name from metavariables 2018-06-22 13:12:42 -07:00
Leonardo de Moura
d0a54aceb6 refactor(kernel): remove unnecessary expr_kind printer 2018-06-22 12:35:38 -07:00
Leonardo de Moura
bc57c66ae3 refactor(kernel/level): naming consistency 2018-06-22 10:29:56 -07:00
Leonardo de Moura
01ea596aea refactor(kernel/expr): implement expr using runtime/object 2018-06-21 16:05:33 -07:00
Leonardo de Moura
c1de8e7ca7 chore(kernel/expr): make sure we can compile with g++ 4.9 2018-06-21 09:00:58 -07:00
Leonardo de Moura
96a9c7db78 feat(kernel/expr): add helper functions for computing scalar data offsets 2018-06-20 16:03:03 -07:00
Leonardo de Moura
bc82208591 chore(kernel/expr): move literal 2018-06-20 15:39:19 -07:00
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
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
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