Commit graph

9279 commits

Author SHA1 Message Date
Leonardo de Moura
4f1f15a425 refactor(library/init/meta/match_tactic): cleanup match_tactic interface 2017-12-06 12:52:41 -08:00
Leonardo de Moura
1b34160396 feat(library/tactic/tactic_state): display number of goals 2017-12-06 11:20:09 -08:00
Leonardo de Moura
a056e87350 fix(library/init/meta/injection_tactic): add support for ginductive datatypes 2017-12-06 09:39:20 -08:00
Sebastian Ullrich
14b2c343d0 chore(util/debug): show current task in assertion message 2017-12-05 17:15:55 -08:00
Leonardo de Moura
bc89ebc19c feat(kernel/inductive): improve how induction hypotheses are named
See doc/changes.md
2017-12-05 15:58:09 -08:00
Leonardo de Moura
a2f55e5d7b feat(library/tactic/induction_tactic): new name generator for induction and cases tactics 2017-12-05 14:57:36 -08:00
Leonardo de Moura
458958b9fc feat(kernel/inductive): use ih to name induction hypothesis (instead of ih_1) when there is only one 2017-12-05 13:50:24 -08:00
Leonardo de Moura
54004d4972 fix(library/tactic/cases_tactic): try to clear input hypothesis when performing dependent elimination
The `induction h` tactic tries to clear hypothesis `h` after it is
applied. But, before this commit, `cases h` would only try to clear `h`
when performing non-dependent elimination. This was problematic when
writing tactic scripts for automating proofs.
2017-12-05 11:03:46 -08:00
Leonardo de Moura
51a87212fa chore(frontends/lean/inductive_cmds): remove copy&paste code 2017-12-04 15:56:04 -08:00
Sebastian Ullrich
450ca5834c fix(frontends/lean/parser): fix debug build 2017-11-30 17:47:49 +01:00
Sebastian Ullrich
0ca9eb16c1 fix(library/type_context): preprocess_class: always solve universe mvars in inout 2017-11-29 17:21:02 -08:00
Leonardo de Moura
4fdf452b17 fix(library/type_context): make sure all assigned metavariables are substituted 2017-11-29 17:19:15 -08:00
Leonardo de Moura
04f3684681 fix(library/tactic/cases_tactic): debug build 2017-11-29 15:05:19 -08:00
Sebastian Ullrich
c521a2d3c7 fix(library/type_context): do not cache queries containing tmp mvars 2017-11-29 14:43:33 -08:00
Leonardo de Moura
960832045f fix(library/type_context): failure condition 2017-11-29 14:35:58 -08:00
Leonardo de Moura
a411e6337c chore(library/type_context): typo 2017-11-29 14:35:36 -08:00
Leonardo de Moura
49b5fbe2c2 fix(library/type_context): add missing update
We also improved the comments, and documented alternative designs that
have been considered.
2017-11-28 08:07:11 -08:00
Leonardo de Moura
641a4548b6 fix(library/tactic/cases_tactic): use inj_arrow instead no_confusion when index is a nested and/or mutually recursive datatype
The `no_confusion` construction is only generated for inductive
datatypes supported in the kernel.
Before this commit, given `h : T`, `cases h` could leak the internal encoding
used by the inductive compiler WHEN a nested and/or mutual inductive
datatype is used to index the inductive datatype `T`.
The new test exposes the problem.

The solution implemented in this commit uses inj_arrow lemmas
generated by the inductive compiler. We only use the lemmas
if the target is a proposition. If it is not, we sign an error.
The reason for this limitation is documented in the source code.

cc @jroesch @dselsam

Jared: the information leakage has been fixed. So, students will not be
confused by the internal encoding used in the inductive compiler.
I added the example I posted on slack as a new test.
Note that, the workaround I used has been removed.
2017-11-27 21:56:35 -08:00
Sebastian Ullrich
7c63b2f046 fix(frontends/lean/parser): unicode pattern aliases 2017-11-27 12:43:15 +01:00
Sebastian Ullrich
18cf63e37f fix(frontends/lean/elaborator): avoid assertion error on delayed abstraction in structure notation 2017-11-24 21:27:55 +01:00
Leonardo de Moura
e12275a925 perf(library/equations_compiler/elim_match): use max_sharing 2017-11-22 16:41:42 -08:00
Leonardo de Moura
47994fe14e chore(library): remove id_locked 2017-11-22 16:29:04 -08:00
Leonardo de Moura
64f575a2d5 perf(library/equations_compiler): performance problem for definitions that produce many equational lemmas
The new test and comment at src/library/equations_compiler/util.cpp
explains the issue.
2017-11-22 16:16:11 -08:00
Leonardo de Moura
dd9d8e9552 chore(library/equations_compiler): improve comments 2017-11-22 14:55:40 -08:00
Leonardo de Moura
01bbf27fb0 fix(library/equations_compiler/util): typo 2017-11-22 12:50:23 -08:00
Leonardo de Moura
7c35a25169 fix(frontends/lean): do not generate equation lemma for match expressions occurring in by tac nested in regular definitions 2017-11-22 12:49:32 -08:00
Leonardo de Moura
7d3133a845 fix(frontends/lean/structure_cmd): do not generate equation lemma for _default meta definitions 2017-11-22 12:24:51 -08:00
Sebastian Ullrich
30cfc6cf0b feat(frontends/lean/{parser,elaborator}): structure instance patterns 2017-11-22 12:16:28 -08:00
Sebastian Ullrich
b3587e15a3 fix(library/tactic/user_attribute): persist user attribute parameters
Fixes #1871
2017-11-22 19:19:05 +01:00
Leonardo de Moura
0208755c82 fix(library/vm/vm_string): bug at VM string < 2017-11-21 16:26:36 -08:00
Sebastian Ullrich
06a316ad30 fix(frontends/lean/elaborator): type of '..' placeholders
Fixes #1870
2017-11-19 18:57:18 +01:00
Sebastian Ullrich
0aacccd8c9 feat(frontends/lean): change structure update notation
`{s with ...}` is now `{..., ..s}`, which more clearly expresses that the
result type is not necessarily equal to the type of `s` (in absence of an
expected type and a structure name, we still default to the type of `s`).

Multiple fallback sources can be given: `{..., ..s, ..t}` will fall back to
searching a field in `s`, then in `t`. The last component can also be `..`,
which will replace any missing fields with a placeholder.

The old notation will be removed in the future.
2017-11-17 16:40:47 -08:00
Sebastian Ullrich
e7e05a3ad0 feat(frontends/lean): add aliasing patterns id@pat 2017-11-17 16:35:21 -08:00
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
17172cbbdd fix(library/tactic/simplify): imp_congr was not preserving binder name 2017-11-17 12:45:04 -08:00
Leonardo de Moura
062ebf4344 fix(library/tactic/apply_tactic): when using elimator-like definitions
We found this problem when developing the red-black tree module.
2017-11-16 11:21:17 -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
394e0d5f0a refactor(library/init): remove has_cmp and is_ordering type classes
Now, `cmp` is just a fixed helper function.
In the future, we will be able to use (more efficient) specialized
versions during code generation by defining simp rules.
2017-11-14 08:33:24 -08:00
Leonardo de Moura
a39c0531cf feat(library/init/data): has_lt for string and list 2017-11-13 15:30:41 -08:00
Sebastian Ullrich
c838cdab34 fix(library/process): do not strip signal information from child exit status
This should match the meaning of "$?" in bash:

"3.7.5 Exit Status

The exit status of an executed command is the value returned by the waitpid system call or equivalent function. Exit statuses fall between 0 and 255."

Fixes #1868
2017-11-13 17:15:28 +01:00
Sebastian Ullrich
55276a5c36 chore(emacs): remove obsolete files 2017-11-11 15:17:05 +01:00
Leonardo de Moura
97d875eb9a perf(library/vm): add native int.cmp and nat.cmp 2017-11-09 14:18:28 -08:00
Leonardo de Moura
f2ef24696d perf(library/compiler/cse): make sure we eliminate common sub expressions in match-cases associated with 0-ary constructors
The new test exposes the problem. Before this commit, the common
subexpressions at

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

were not converted into a let-exprs.
2017-11-09 13:32:15 -08:00
Leonardo de Moura
0bbe51615e chore(library/compiler/vm_compiler): add helper function 2017-11-09 13:29:32 -08:00
Leonardo de Moura
76ddda493d refactor(library/compiler/cse): isolate cse processor procedure
We will use it to fix a performance problem in case expressions for
inductive datatypes that have constructors without data.
2017-11-09 12:41:36 -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
2c1f50cc04 fix(library/num): fixes #1862 2017-11-09 09:49:53 -08:00
Leonardo de Moura
b61920e9a3 perf(library/compiler/lambda_lifting): missing opportunity for applying eta-reduction and avoiding unnecessary aux decl 2017-11-08 16:23:11 -08:00
Leonardo de Moura
b40f3af801 feat(library/init/meta): move rb_tree and rb_map to native namespace
cc @kha
2017-11-07 13:41:45 -08:00