Commit graph

3598 commits

Author SHA1 Message Date
Leonardo de Moura
6c3d90e20e fix(library/type_context): type_context was not checking if to_revert dependencies were frozen 2018-02-23 11:59:18 -08:00
Leonardo de Moura
24e7a5a339 feat(library/tactic): add frozen_local_instances tactic for retrieving list of frozen local instances 2018-02-23 11:39:38 -08:00
Leonardo de Moura
db4fcac40c feat(library): add tactic unfreeze_local_instances 2018-02-23 11:12:05 -08:00
Leonardo de Moura
46ed0ad677 refactor(library/congr_lemma): remove mk_rel_iff_congr_lemma and mk_rel_eq_congr_lemma 2018-02-21 15:04:20 -08:00
Leonardo de Moura
c176faed32 feat(kernel/inductive): make sure constructor types do not contain local constants nor metavariables 2018-02-21 15:04:19 -08:00
Leonardo de Moura
56dba5b98a fix(frontends/lean/elaborator): fixes #1930
@kha the following idiom is not safe
```
   while (is_pi(t)) {
      t = whnf(binding_body(t));
   }
```
`whnf(e)` assumes that `e` does not have dangling deBruijn variables.
We should use (the more expensive):
```
   while (is_pi(t)) {
      t = whnf(instantiate(binding_body(t), locals.push_local_from_binding(t)));
   }
```
BTW, this problem is not related to the assertion violation at #1930
I just stumbled on it when fixing the violation.
2018-02-19 08:51:26 -08:00
Leonardo de Moura
e023b1001a fix(library/system/random): bug at rand_nat 2018-02-16 11:20:43 -08:00
Leonardo de Moura
96fab5172f perf(library/compiler): apply lambda lifting after erase trivial structures
cc @kha
2018-02-15 16:55:27 -08:00
Leonardo de Moura
1c9648a12d chore(library): remove dead constants 2018-02-15 16:17:43 -08:00
Leonardo de Moura
ac13f8b0f9 feat(library/system/io): add random number generator support in the io monad
@aqjune @nunoplopes: See new tests at tests/lean/run/random.lean

We have two actions in `io`. By default, `io` uses the C++
random number generator, but we can force it to use a `std_gen` with
the action `set_rand_gen`.

def rand (lo : nat := std_range.1) (hi : nat := std_range.2) : io nat
def set_rand_gen : std_gen → io unit
2018-02-15 16:12:08 -08:00
Leonardo de Moura
f786d21b0f feat(library/system): basic support for random numbers
@aqjune @nunoplopes: This commit adds basic support for random numbers.
It defines a random number generator interface, and an basic
implementation based on the Haskell one.
We can add more implementations in the future if neeeded.
The new test program has a few examples.

BTW, this is a pure Lean implementation.
If we need more performance we can provide an implementation
using C++.
2018-02-15 14:36:28 -08:00
Leonardo de Moura
96e02613fc fix(library/compiler/simp_inductive): erase trivial structure bug 2018-02-11 11:43:05 -08:00
Leonardo de Moura
30cfcc0fa6 fix(library/compiler/inliner): missing reduction 2018-02-11 09:28:42 -08:00
Sebastian Ullrich
affe3463ab fix(frontends/lean/elaborator): fix assertion error: accidental mutation of a variable 2018-02-08 14:07:08 +01:00
Sebastian Ullrich
703d12d594 feat(frontends/lean/elaborator): do not execute tactics after error recovery 2018-02-02 08:58:53 -08:00
Sebastian Ullrich
b3262d53b4 feat(frontends/lean/elaborator): structure notation: fall back to inferring superclasses 2018-02-02 08:58:53 -08:00
Sebastian Ullrich
9f25cf665e feat(frontends/lean/elaborator): structure instance notation: allow implicit fields 2018-02-02 08:58:53 -08:00
Sebastian Ullrich
040748419f refactor(frontends/lean/elaborator): refactor and document structure instance notation code 2018-02-02 08:58:53 -08:00
Sebastian Ullrich
6ab13a433d chore(library/type_context): should not have an implicit constructor, copy constructor, or assignment operator 2018-02-02 08:58:53 -08:00
Sebastian Ullrich
dc5e50e7f0 feat(frontends/lean/structure_cmd): hide out_param in projections 2018-02-02 08:58:52 -08:00
Sebastian Ullrich
3f497b8d8e fix(library/constructions/projection): out_params should always be implicit in projections 2018-02-02 08:58:52 -08:00
Sebastian Ullrich
e427068081 fix(frontends/lean/pp): missing parentheses around notation 2018-02-02 08:58:52 -08:00
Sebastian Ullrich
9f60fd5492 feat(frontends/lean/elaborator): ignore more sorry-containing type mismatch messages 2018-02-02 08:58:52 -08:00
Sebastian Ullrich
009cff6f79 feat(frontends/lean/elaborator): prefer taking subobjects from structure notation sources as a whole
This guarantees definitional equality on the field as witnessed by the test
2018-02-02 08:58:52 -08:00
Leonardo de Moura
e6a98ffe9c feat(library/type_context): improve unifier first-order approximation
@kha We can now solve unification constraints of the form

         ?m unit =?= itactic

I'm not very confident this new extension will improve usuability
instead of creating new counter-intuitive behavior.
At least, in the process of implementing it, I fixed two bugs,
and removed a nasty hack that was being used in the unifier.
Thus, even if we disable this feature in the future, some good came out
of it.

Although, the new extension locally increases the number of constraints
that can be solved, it may prevent terms that could be elaborated before
from being elaborated. I am not too concerned at this point because
I could not construct a natural example. I encountered one case, but it
was due to a problem that I fixed in the previous commit.
I reconstruct it here for the record. Suppose we have a constraint

         ?m_1 ?m_2 =?= itactic

Without the fix from the previous commit, `itactic` would unfold too
`id_rhs Type (tactic unit)`, and the constrain would be solved as

         ?m_1 := (id_rhs Type)
         ?m_2 := (tactic unit)

It succeeds locally, but the elaboration fails later when it tries to
synthesize the type class `has_bind (id_rhs Type)`.
The previous fixes the problem by making sure `itactic` is unfolded to
`tactic unit` as expected. `id_rhs` is an auxiliary definition
used to implement smart unfolding. That being said, the user could in
principle define `itactic` as `@id Type (tactic unit)`, and the constraint

         ?m_1 ?m_2 =?= itactic

will be solved as

         ?m_1 := (@id Type)
         ?m_2 := (tactic unit)

which is not the solution we want.
2018-01-30 15:42:17 -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
3fa487c153 fix(frontends/lean/decl_util): as-is annotation was leaking into elaborated terms
@kha This commit fixes the repro you sent me. Could you please check
whether it also fixes the original file?
2018-01-30 12:48:48 -08:00
Leonardo de Moura
28b8020995 fix(library/type_context): bug in the unifier
One of the approximations used was generating type incorrect terms.
2018-01-30 12:48:48 -08:00
Leonardo de Moura
39f1cc0bab test(tests/lean/run): add new tests exposing bug in the unifier
This commit also documents the problem at type_context.cpp, and
describes a potential solution.
2018-01-30 12:48:48 -08:00
Gabriel Ebner
aac833c8d4 test(tests/lean/run): test for mk_inj_eq 2018-01-28 09:10:26 -08:00
Leonardo de Moura
77ae133baa fix(library/type_context): preprocess_class
@kha This commit fixes the bug we discussed on slack.
I had to repair one of the tests. The broken test made me
realize that if we use the unbundled approach to define something like
`is_semiring`

```
class is_semiring (α : Type) (plus : α → α → α) (mul : α → α → α) (zero : out_param α) (one : out_param α) :=
...
```
Then, to retrieve a `is_semiring` instance, we need to know `α`, `plus`
and `mul`. This is problematic because we may be in a context where one
of them cannot be inferred. This would force user to manually provide
the missing (input) parameter. We are not considering the unbundled
approach for complex algebraic structures such as `semiring`, `ring` and
`field`, but I wanted to document this limitation here since we may face
it in other type classes.

I think it is a bad idea to add back `inout_param` and have both:
`inout_param` and `out_param`. The previous `inout_param` created
many instabilities and hard to diagnose failures.
2018-01-24 17:30:04 -08:00
Leonardo de Moura
1e626e382f chore(frontends/smt2): remove SMT2 frontend 2018-01-24 15:21:52 -08:00
Leonardo de Moura
d4e1a4a50a chore(library/system/io): tactic.run_io ==> tactic.unsafe_run_io 2018-01-24 10:32:32 -08:00
Leonardo de Moura
0d83a74b26 fix(library/io,tests/lean): io monad command line arguments, and tests 2018-01-23 15:24:41 -08:00
Leonardo de Moura
0ad5497462 refactor(library/io): make io easier to extend and use 2018-01-23 15:03:31 -08:00
matt rice
1538615e8c feat(util): allow some math alphanum symbol latin letter variations
Add the Script, Double-struck, and Fractur blocks from,
https://unicode.org/charts/PDF/U1D400.pdf
to is_letter_like() so they may be bound to variables.
2018-01-23 11:20:05 -08:00
Sebastian Ullrich
67fc899d0d feat(shell/server): sync: default "content" to file content
This mostly simplifies debugging and testing
2018-01-23 11:14:18 -08:00
Leonardo de Moura
368f17d0b1 feat(library/tactic/simplify): add simp! 2018-01-16 17:29:24 -08:00
Leonardo de Moura
c195d7c2a1 feat(library/tactic/simp_tactic): improve mk_simp_attr
- An new simp attribute may depend on other existing attributes

- Add `[norm]` simp attribute. It is an extension of the default `[simp]` attribute.
  It should be used to add extra rules for normalizing goals.
  These extra rules are used to produce normal forms and/or reduce the
  number of constants used in a goal. Here is an example coming from a
  discussion with @kha. When working with monads, we may want to
  eliminate `<$>` by using the lemma `f <$> x = x >>= pure ∘ f`.
  This lemma is in the `[norm]` simp set, but it is not in `[simp]`
2018-01-16 16:47:30 -08:00
Leonardo de Moura
6635f6c8c1 chore(library/init/coe): document why @[reducible] annotation is needed 2018-01-16 11:31:43 -08:00
Sebastian Ullrich
49e1cf9a79 feat(leanpkg): leanpkg new/init: initialize git repository to correct branch 2018-01-15 09:58:19 +01:00
Sebastian Ullrich
b354feb8b9 fix(leanpkg): mandate path = "src"
Fixes #1880
2018-01-15 09:58:19 +01:00
Leonardo de Moura
cebde17bec feat(library/tactic/simplify): simp reduces c a_1 ... a_n = c b_1 ... b_n into a_1 = b_1 /\ ... /\ a_n = b_n 2018-01-12 18:18:56 -08:00
Leonardo de Moura
9eb22cd548 feat(library/constructions/injective): automatically generate auxiliary lemma *.inj_eq for constructors
We are going to use these lemmas in the simplifier.
2018-01-12 16:41:12 -08:00
Leonardo de Moura
58fce78282 feat(library/init/meta/interactive): add interactive tactic subst_vars 2018-01-12 14:37:11 -08:00
Leonardo de Moura
5bad6d5372 feat(library/init/meta/tactic): subst supports heterogeneous equalities that are actually homogeneous 2018-01-12 14:32:49 -08:00
Leonardo de Moura
1437d7209a feat(library/tactic/simplify): add support for generalized inductive datatypes 2018-01-12 11:51:49 -08:00
Leonardo de Moura
c3d4a9456e feat(library/init/meta/interactive): add sorry interactive tactic (alias for admit). 2018-01-11 16:58:46 -08:00
Leonardo de Moura
c5df94ed17 feat(library/tactic): add support for auto params at simp tactic 2018-01-11 16:47:22 -08:00
Leonardo de Moura
3b0e23e1f0 fix(library/equations_compiler/util): make sure untrusted macros are unfolded when creating auxiliary *._sunfold definitions 2018-01-11 12:45:42 -08:00