Commit graph

43 commits

Author SHA1 Message Date
Sebastian Ullrich
d214df63f1 fix(library/equations_compiler/compiler): eta-expand recursive occurrences earlier 2018-12-18 15:30:38 +01:00
Leonardo de Moura
6b8008a222 feat(library/compiler): new compiler entry point (skeleton) 2018-10-05 17:30:27 -07:00
Leonardo de Moura
4f53e505b0 fix(library/compiler): we need to unfold auxiliary nested _match applications eagerly 2018-09-18 14:17:37 -07:00
Leonardo de Moura
3ebf1db2dc feat(library/compiler): treat f._meta_rec applications as f applications 2018-09-17 09:48:14 -07:00
Leonardo de Moura
2abe11ce63 chore(library): _meta_aux ==> _meta_rec 2018-09-17 09:08:12 -07:00
Leonardo de Moura
3ec73b7156 fix(library/equations_compiler/compiler): avoid pull_nested_rec_fn by unfolding auxiliary declarations
The idea is to mimic the behavior of meta definitions.
This is a temporary fix. The new equation compiler will have to provide
a better solution for this problem.
2018-09-12 18:17:50 -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
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
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
bdea7d420d chore(*): type_context ==> type_context_old 2018-03-05 12:38:24 -08:00
Leonardo de Moura
8a93d2770e feat(library/equations_compiler): add new cache support to equation compiler 2018-02-21 15:04:20 -08:00
Leonardo de Moura
815327fc93 fix(library/equations_compiler): bug at pull_nested_rec
closes #1917
2018-01-30 13:49:47 -08:00
Leonardo de Moura
91079faf97 fix(library/equations_compiler/compiler): problem introduced by recent changes
The problem was reported by @digama at slack.
2017-11-03 10:46:40 -07:00
Leonardo de Moura
6ddfd14a32 fix(library/equations_compiler/compiler): make sure non exhaustiveness couterexamples are reported only once 2017-11-01 14:33:34 -07:00
Leonardo de Moura
14301a7f9f feat(library/equations_compiler/compiler): generate meta auxiliary definitions for regular (recursive) definitions
Motivations:

- Clear execution cost semantics for recursive functions.

- Auxiliary meta definition may assist recursive definition unfolding in the type_context object.

Next step: use meta auxiliary definition at code generation.
2017-11-01 11:58:45 -07:00
Gabriel Ebner
246d71f3ff feat(library/equations_compiler): error recovery 2017-07-16 05:17:38 -07:00
Gabriel Ebner
5e94ecc841 chore(library/equations_compiler): style 2017-07-06 22:04:58 -07:00
Gabriel Ebner
50821c9fac feat(library/equations_compiler): unpack counter-examples in wf recursion 2017-07-06 22:04:58 -07:00
Leonardo de Moura
4bdb2da1b6 fix(library/equations_compiler): improve pull_nested_rec_fn, and make sure it communicates local propositions to the well founded recursion module
The bin_tree and num_consts examples can now be encoded more naturally.
2017-05-26 10:45:39 -07:00
Leonardo de Moura
1c87319b58 feat(library/equations_compiler): add wf_rec skeleton 2017-05-17 12:47:52 -07:00
Leonardo de Moura
dea8a856dc chore(library/equations_compiler/compiler): generate error when using well founded recursion in meta definitions 2017-05-17 12:24:47 -07:00
Leonardo de Moura
900c56be05 feat(frontends/lean,library/equations_compiler): abstract proofs in equations and regular definitions 2017-03-25 14:22:52 -07:00
Leonardo de Moura
53667dd602 fix(library): change API and make sure we don't crash when searching for a non existing local decl
Fixes #1363

After error recovery has been implemented in the elaborator, a few
assumptions made in the type context are not valid anymore since we may
be recovering from errors, and the local and metavariable contexts may
be invalid.

I used the approach used in the class environment.

- find* methods return optional<...>
- get* methods throw exception for unknown elements

Remarks:

I preserved code patterns such as

     optional<local_decl> d = lctx.find_local_decl(...)
     lean_assert(d)

and did not convert them into

     local_decl d = lctx.get_local_decl(...)

Reason: the intention is clear that the local must be defined there.
If it is not we should analyze the problem and decide whether we should
throw an exception or not.

However, I converted code patterns such as

    local_decl d = *lctx.find_local_decl(...)

into

    local_decl d = lctx.get_local_decl(...)

Disclaimer: this change fixes issue #1363, but it may obfuscate other bugs.
2017-02-07 09:38:19 -08:00
Leonardo de Moura
cce6e4d58c fix(library/equations_compiler/compiler): fix #1315 2017-01-16 20:01:25 -08:00
Leonardo de Moura
9a967001be chore(library/equations_compiler/compiler): use exception until well_founded recursion support is implemented 2016-09-19 14:41:25 -07:00
Leonardo de Moura
5df705ebe8 fix(library/equations_compiler/compiler): nested match-exprs in meta_definitions 2016-09-18 17:20:52 -07:00
Leonardo de Moura
6657876566 feat(library/equations_compiler): add support for meta_definitions 2016-09-18 10:52:38 -07:00
Leonardo de Moura
e6dd5242fc feat(library/equations_compiler): add option eqn_compiler.zeta 2016-09-10 14:00:16 -07:00
Leonardo de Moura
4df0c1fe93 feat(library/equations_compiler/compiler): do not use let-expresssions at pull_nested_rec_fn 2016-09-09 18:20:36 -07:00
Leonardo de Moura
c25ac7f54f feat(library/equations_compiler): pull nested recursive calls 2016-09-09 17:56:56 -07:00
Leonardo de Moura
96fa8856bc feat(library/equations_compiler): add mk_nonrec 2016-09-08 14:09:05 -07:00
Leonardo de Moura
230db1bc92 feat(library/equations_compiler/structural_rec): generate brec_on-based function
We still need to generate lemmas and induction principle.
2016-08-29 15:58:13 -07:00
Leonardo de Moura
f0f9880ece refactor(library/equations_compiler/elim_match,library/tactic/cases_tactic):
new design for elim_match

I still need to fix lemma generation, and refactor induction/subst tactics
2016-08-28 13:15:10 -07:00
Leonardo de Moura
cf15218eea chore(library/equations_compiler/compiler): add new trace option 2016-08-25 10:45:08 -07:00
Leonardo de Moura
a93eada058 feat(library/type_context): improved (and simplified) cache management for type_context 2016-08-23 17:56:58 -07:00
Leonardo de Moura
27e06c80ba feat(library/equations_compiler/elim_match): generate auxiliary definition and lemmas for match 2016-08-22 17:59:54 -07:00
Leonardo de Moura
06b02e4912 chore(library/equations_compiler): test elim_match on nonrec equations 2016-08-18 21:00:57 -07:00
Leonardo de Moura
475b75f661 feat(library/equations_compiler/elim_match): refactor 'program' structure 2016-08-18 14:17:49 -07:00
Leonardo de Moura
05013fb61d feat(library/equations_compiler): add elim_match skeleton 2016-08-17 21:38:23 -07:00
Leonardo de Moura
7669e18c77 feat(library/equations_compiler): add unbounded_rec 2016-08-16 12:54:54 -07:00
Leonardo de Moura
8b67480cee feat(library/equations_compiler): add step for handling structural recursion 2016-08-15 18:00:25 -07:00
Leonardo de Moura
9a63936339 refactor(library/equations_compiler): move pack_domain to new module 2016-08-15 08:22:23 -07:00
Leonardo de Moura
7059609f57 feat(library/equations_compiler): equations_compiler stub, add helper equations_editor, add preprocessing
The first preprocessing step packs nary functions into unary using sigma types
2016-08-14 17:02:36 -07:00