Commit graph

9224 commits

Author SHA1 Message Date
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
cd8c154bcd feat(library/compiler/vm_compiler): clear runtime cost model
The equation compiler uses different strategies for processing
recursive equations. Some of them may produce unclear runtime cost
model. For example, the following fibonacci functions was running in
linear time instead of exponential time because the equation compiler
used the brec_on recursor.

def fib : nat → nat
| 0     := 1
| 1     := 1
| (n+2) := fib (n+1) + fib n

@dselsam and @jroesch have reported examples were the equation compiler
produces a negative performance impact. The new test (`eval` function)
captures the problem reported by @jroesch. In this example, the runtime
should not depend on the "amount of fuel".

This commit addresses this issue.
2017-11-01 14:11:09 -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
Leonardo de Moura
15660c94f1 chore(frontends/lean/definition_cmds): remove workarounds for meta definitions
The new approach used to compile meta (and mutual meta) definitions does
not require these hacks in the frontend anymore.
2017-10-30 15:16:51 -07:00
Leonardo de Moura
482e06427b feat(library/equations_compiler): meta mutual definitions
closes #1622
2017-10-30 15:06:12 -07:00
Leonardo de Moura
7b683427da feat(library/aux_definition): add closure_helper 2017-10-30 15:00:14 -07:00
Leonardo de Moura
7999200676 chore(library/equations_compiler/equations): add aux function 2017-10-30 15:00:13 -07:00
Leonardo de Moura
7caa88b61e refactor(library/vm/vm): remove unnecessary field from vm_decl_cell 2017-10-30 15:00:13 -07:00
Sebastian Ullrich
1a80ea9c8e fix(util/utf8): UTF8 decoding 2017-10-27 09:48:09 -07:00
Sebastian Ullrich
734ee66514 fix(library/string): unicode char literals 2017-10-27 09:48:09 -07:00
Leonardo de Moura
ce4e316e09 fix(library/equations_compiler/util): fixes #1841 2017-10-26 11:25:16 -07:00
Leonardo de Moura
d2497d554f feat(frontends/lean): add support for unicode char literals and escape sequences
TODO: we are not checking if the unicode escape values provide by the
user correspond to valud unicode scalar values. We should check how
other languanges handle this case.
2017-10-23 13:46:57 -07:00
Sebastian Ullrich
032e0701e0 fix(frontends/lean/elaborator): non-recursive local shouldn't shadow projection 2017-10-23 12:12:06 -07:00
Sebastian Ullrich
716c730c38 fix(frontends/lean/structure_cmd): allow extending structures in the current context 2017-10-23 11:12:14 -07:00
Leonardo de Moura
e53f8021ec feat(library/vm/vm_string): add builtin VM implementation for string.cmp 2017-10-23 10:55:26 -07:00
Leonardo de Moura
10184315fb feat(library/vm/vm_string): add builtin VM implementation for string.has_decidable_eq 2017-10-23 10:55:26 -07:00
Leonardo de Moura
a9e884cc1d fix(library/vm/vm_string): bug at string.iterator.remove VM builtin implementation 2017-10-23 10:55:26 -07:00
Leonardo de Moura
f8ce142da7 fix(library/vm/vm_string): bug at string.iterator.insert VM builtin implementation 2017-10-23 10:55:26 -07:00
Leonardo de Moura
e30f2f6604 fix(library/vm/vm): bug at update_vm_constructor 2017-10-23 10:55:26 -07:00
Leonardo de Moura
47a8c2baef fix(library/vm/vm_string): missing VM builtin for string_imp projections 2017-10-23 10:55:26 -07:00
Leonardo de Moura
ffb2464f1f fix(library/vm/vm_string): missing VM builtin for string.iterator_imp projections 2017-10-23 10:55:26 -07:00
Leonardo de Moura
7cba1c6753 fix(library/vm/vm_string): bug at string.fold VM builtin implementation 2017-10-23 10:55:26 -07: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
Leonardo de Moura
28501a0e0e feat(library/init/data/string): string as a list of unicode scalar values, and iterator abstraction
TODO:
- Implement string primitives in the VM.
- Support for unicode char literals.
2017-10-23 10:55:26 -07:00
Leonardo de Moura
bdc8e1ced8 feat(library/init/data/char): char as an unicode scalar value
TODO: this is the first step to have better unicode support.
2017-10-23 10:55:26 -07:00
Sebastian Ullrich
87e1a88d01 feat(init/meta/pexpr): allow creating structure instance pre-terms 2017-10-11 16:13:34 +02:00
Sebastian Ullrich
5efa1b829c chore(src/emacs): move lean-mode to https://github.com/leanprover/lean-mode
Closes #410
2017-10-06 10:46:43 -07:00
Sebastian Ullrich
d54c4e11c2 feat(emacs): highlight flycheck and eldoc output 2017-09-18 13:02:06 -07:00
Leonardo de Moura
f0bf1624fe feat(frontends/lean/brackets): closes #1820 2017-09-15 12:54:21 -07:00
Leonardo de Moura
f36fca875c feag(frontends/lean): explicit delimiters in declaration parameters
Comment from parser.h

This commit makes sure that all declaration parameters must be surrounded with some kind of bracket. (e.g., '()', '{}', '[]').
The goal is to avoid counter-intuitive declarations such as:

              example p : false := trivial
              def main proof : false := trivial

which would be parsed as

              example (p : false) : _ := trivial

              def main (proof : false) : _ := trivial

where `_` in both cases is elaborated into `true`. This issue was raised by @gebner in the slack channel.

Remark: we still want implicit delimiters for lambda/pi expressions. That is, we want to write

               fun x : t, s
           or
               fun x, s

instead of

               fun (x : t), s
2017-09-15 10:07:09 -07:00
Gabriel Ebner
3d711b37c3 chore(*): development version 3.3.1 2017-09-14 18:55:03 +02:00
Gabriel Ebner
fa9c868ed2 chore(*): version 3.3.0 2017-09-14 18:53:38 +02:00
Sebastian Ullrich
7ff06b2184 chore(init/meta/attribute): rename user_attribute.set_param to user_attribute.set
Setting the parameter value really is a side effect of setting the whole attribute
2017-09-14 18:48:18 +02:00
Sebastian Ullrich
8d9c0ac806 fix(frontends/lean/tactic_notation): by tactic: accept non-atomic proof 2017-09-14 18:48:18 +02:00
Sebastian Ullrich
2faad5114a chore(frontends/lean): enforce and document applying attributes last 2017-09-14 18:48:18 +02:00
Gabriel Ebner
341cf71fb9 fix(frontends/lean/structure_cmd): check parent expression after elaboration as well 2017-09-14 09:36:40 +02:00
Leonardo de Moura
6781681ae5 feat(frontends/lean/definition_cmds): when the kernel fails to type check a declaration include the fully elaborated term in the error message 2017-09-13 16:43:54 -07:00
Gabriel Ebner
9118079f7f fix(library/module_mgr): error handling in cyclic imports
Fixes #1807
2017-09-12 17:22:47 +02:00
Sebastian Ullrich
7412512579 fix(frontends/lean/structure_cmd): apply attributes last 2017-09-11 16:56:02 -07:00
Sebastian Ullrich
230bf7e8d9 fix(frontends/lean/decl_cmds): constant/axiom cmds: apply attributes 2017-09-11 16:56:02 -07:00
Leonardo de Moura
d428eca8a7 fix(library/equations_compiler,frontends/lean): private name support and alias generation for auxialiary declarations
fixes #1804

Remark: now, all auxiliary definitions in a private declaration share
the same "private" prefix.
2017-09-11 16:46:56 -07:00
Sebastian Ullrich
d82df26ff0 fix(frontends/lean/elaborator): go back to ignoring implicit args in quote patterns 2017-09-11 09:33:38 -07:00
Sebastian Ullrich
f242d04d55 chore(emacs/lean-dev): lean-diff-test-file produced wrong paths 2017-09-10 09:53:23 +02:00
Sebastian Ullrich
0bf96e5752 fix(frontends/lean/elaborator): revert dubious workaround of mine
Synthesizing an expr placeholder in an elaborated term doesn't make much sense
2017-09-08 13:23:16 +02:00
Leonardo de Moura
1f757ba84e fix(frontends/lean/pp): fixes #1817 2017-09-07 15:23:58 -07:00
Gabriel Ebner
19777cf9eb fix(frontends/lean/definition_cmds): show trace messages in examples 2017-09-06 14:44:44 +02:00
Gabriel Ebner
5f8cf45073 feat(frontends/lean/elaborator): apply to-sort coercion also in arguments 2017-09-06 14:15:30 +02:00
Gabriel Ebner
7b18d5828d feat(frontends/lean/elaborator): trigger coe_to_fun even when expected type has metavariables
We only need to know that the expected type is a Π to perform
to-function coercion.  Related to #1402.

Fixes https://github.com/gebner/hott3/issues/2
2017-09-06 11:20:04 +02:00
Leonardo de Moura
88cd294a09 feat(src/kernel/error_msgs): show aliased variables when printing error messages
closes #1814

@kenmcmil: the error messages will now list aliased variables.
For example, in your file, the new error message is:

```
invalid type ascription, term has type
  triple (ctxpre c' s_1 ∧ ctxpre c'_1 s_1) (bndngapp b s_1) (ctxpost c' s_1 ∧ ctxpost c'_1 s_1)
but is expected to have type
  triple (ctxpre c' s_1 ∧ ctxpre c'_1 s_1) (bndngapp b s_1) (ctxpost c' s_1 ∧ ctxpost c'_1 s_1)
types contain aliased name(s): c'
remark: the tactic `dedup` can be used to rename aliases
state:
...
```
2017-09-05 16:46:44 -07:00