Commit graph

2973 commits

Author SHA1 Message Date
Sebastian Ullrich
d037ab1d4b refactor(frontends/lean/structure_cmd): remove awkward pointer index computation 2017-11-17 16:31:30 -08:00
Sebastian Ullrich
aa8791a9ee fix(frontends/lean/structure_cmd): support dependent parents in new structure cmd 2017-11-17 16:31:30 -08:00
Leonardo de Moura
d88a6f663e fix(frontends/lean/elaborator): implicit arguments after auto_param arguments
Function applications `(f ...)` were not being elaborated correctly when
`f` has implicit parameters occurring after auto_params.
The new test exposes the problem.

This bug was found when developing the red black tree module.

This commit also fixes the following bugs:

- Invoke type class resolution again after tactic execution at
  synthesize method. Reason: metavariables occurring in type
  class instances may have been synthesized by tactics.

- mctx.assign optimization at invoke_tactic was incorrect
  when the metavariable was assigned by typing rules.
2017-11-14 17:22:12 -08:00
Leonardo de Moura
fabf7f6380 perf(library/equations_compiler, library/compiler): expand auxiliary _match_idx definitions when generating byte code
We use the auxiliary procedure pull_nested_rec_fn to pull recursive
application in nested match expressions. This is needed because the
nested match expression is compiled before we process the recursive
procedure that contains it. This transformation may produce
performance problems if the recursive application does not depend on
the data being matched. Here is an example from the new test:

```
def tst : tree → nat
| (tree.leaf v) := v
| (tree.node v l r) :=
  match f v with
  | tt := tst l
  | ff := tst r
  end
```

pull_nested_rec_fn will convert it into

```
def tst : tree → nat
| (tree.leaf v)     := v
| (tree.node v l r) := tst._match_1 (f v) (tst l) (tst r)
```

Since our interpreter uses eager evaluation, both `(tst l)` and `(tst r)`
are executed. This commit fixes this issue by expanding `tst._match_1`
during code generation.
2017-11-09 11:14:57 -08:00
Leonardo de Moura
426a9064bf feat(frontends/lean/builtin_cmds): display warning message if has_repr instance could not be synthesized
See issue #1861
2017-11-06 19:26:18 -08:00
Sebastian Ullrich
191065d963 fix(frontends/lean/elaborator): change assertion into type mismatch error
Fixes #1859
2017-11-06 10:51:37 +01: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
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
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
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
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
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
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
51bac2918f chore(library/init/core): declare and using structure
This change was requested by several users.
2017-09-05 15:08:20 -07:00
Sebastian Ullrich
51aabb9b65 feat(frontends/lean/decl_attributes): allow user attributes on inductive types 2017-09-05 23:14:34 +02:00
Sebastian Ullrich
9ed678d80a feat(frontends/lean/elaborator): structure notation: synthesize instance-implicit fields 2017-09-05 23:14:34 +02:00
Sebastian Ullrich
3aa5ebb8bd feat(frontends/lean/elaborator): structure notation: allow explicit ctor param when given expected type 2017-09-05 23:14:34 +02:00
Sebastian Ullrich
da785d96a0 fix(frontends/lean/elaborator): synthesize metavars in e before trying to synthesize reflected e 2017-09-05 23:14:34 +02:00
Sebastian Ullrich
f255513fdc fix(frontends/lean/definition_cmds): apply attributes after declaring equational lemmas
Fixes `@[simp] def ...`
2017-09-01 13:36:53 +02:00
Gabriel Ebner
05178ad950 chore(frontends/lean/decl_cmds,emacs/lean-syntax): typo 2017-08-28 17:04:03 +02:00
Leonardo de Moura
ac0be0ecc6 chore(frontends/lean/elaborator): style 2017-08-22 15:41:12 -07:00
Sebastian Ullrich
9e53147e0a feat(frontends/lean/elaborator): allow field notation for recursive calls 2017-08-22 15:33:37 -07:00
Leonardo de Moura
971ae34521 feat(frontends/lean/elaborator): closes #1760
As described at issue #1760, the new error message is:
```
1760.lean:6:18: error: type mismatch at application
  f x
term
  x
has type
  big_type : Type 1
but is expected to have type
  ?m_1 : Type
```
2017-08-21 16:15:03 -07:00
Leonardo de Moura
049d940167 chore(frontends/lean/elaborator): cleanup 2017-08-18 17:50:29 -07:00
Leonardo de Moura
c149286f44 fix(frontends/lean/elaborator): add instantiate_pattern_mvars 2017-08-18 16:49:45 -07:00
Leonardo de Moura
d4f2bb77b8 feat(frontends/lean): recursive equation preprocessor
To make the equation compiler more convenient to use, we will add a
couple of preprocessing steps.
This commit adds the first one of them. In this step, we use
type inference to refine pattern variables, and we relax the
restrictions on inaccessible annotations.

We will also add a preprocessing step that implements the "complete
transition" step before we execute the elim_match step.
2017-08-18 15:06:11 -07:00
Gabriel Ebner
effd624911 fix(frontends/lean/parser): add check_system call 2017-08-18 08:54:04 +02:00
Leonardo de Moura
9927f331f4 chore(frontends/lean/elaborator): remove dead code 2017-08-17 16:03:32 -07:00
Leonardo de Moura
6315136279 fix(frontends/lean/definition_cmds): fixes #1790 2017-08-16 15:57:55 -07:00
Gabriel Ebner
867bc46d99 feat(library/vm/vm_parser): expose parse_command_like to the vm 2017-08-14 11:41:48 +02:00
Gabriel Ebner
fe5cb0106c fix(frontends/lean/structure_cmd): disable def-eq check of pre-expressions 2017-08-02 14:41:35 +01:00
Gabriel Ebner
c500f9497d feat(frontends/lean/structure_cmd): inherit default values in old_structure_cmd 2017-08-02 14:41:35 +01:00
Gabriel Ebner
becec82311 fix(frontends/lean/structure_cmd): simplify parser 2017-08-02 11:27:13 +01:00
Gabriel Ebner
b6f81e30e5 fix(frontends/lean/structure_cmd): prevent segfault
Fixes #1727.
2017-08-02 11:27:13 +01:00
Gabriel Ebner
403234f29e fix(frontends/lean/interactive): fix empty prefix in autocompletion 2017-08-01 18:42:31 +01:00
Gabriel Ebner
6d0a7a80af fix(frontends/lean/builtin_exprs): prevent segfault 2017-08-01 14:57:37 +01:00