Commit graph

2107 commits

Author SHA1 Message Date
Leonardo de Moura
368fcb5ff9 refactor(builtin/kernel): rename refute to by_contradiction
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-12 08:49:19 -08:00
Leonardo de Moura
69bccb6014 feat(builtin): define list, cons, nil and prove basic theorems
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-11 21:32:05 -08:00
Leonardo de Moura
bfe64a7031 fix(library/elaborator): hack for fixing a bug due to pairs/projs, this is temporary fix until we build a new elaborator
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-11 21:30:26 -08:00
Leonardo de Moura
0878b44fc7 feat(frontends/lean): allow user to import several theories using a single import
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-11 17:15:12 -08:00
Leonardo de Moura
fddaa7bc3a doc(examples/lean): add theorem sent by Jeremy Avigad
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-11 14:10:29 -08:00
Leonardo de Moura
1796c2b992 doc(examples/lean): proof of concept
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-11 07:59:49 -08:00
Leonardo de Moura
56ad1c1728 doc(examples/lean/abelian): proof of concept
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-10 18:17:15 -08:00
Leonardo de Moura
65076816fa doc(examples/lean/group): prove basic theorems
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-10 15:49:24 -08:00
Leonardo de Moura
acd04d3c2b doc(examples/lean): setoid and group examples
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-10 14:41:29 -08:00
Leonardo de Moura
11a2b3016f fix(builtin/num): remove hacks for making the elaborator happy
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-10 14:05:51 -08:00
Leonardo de Moura
b7b868de85 fix(library/elaborator): bug reported by Jeremy Avigad
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-10 14:01:22 -08:00
Leonardo de Moura
a2d2e36f04 refactor(frontends/lean): remove notation for creating tuples
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-10 09:03:42 -08:00
Leonardo de Moura
4e08a3233e fix(builtin): build dependency issue
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-10 08:33:07 -08:00
Leonardo de Moura
273f78d1cb feat(builtin/num): prove strong induction and other theorems for num
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-09 21:09:50 -08:00
Leonardo de Moura
b119c11473 feat(builtin/tactic): add simp_no_assump tactic
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-09 20:28:30 -08:00
Leonardo de Moura
4317f67bd2 fix(builtin/tactic): more meaningful error message when skip tactic is used in a full proof
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-09 18:57:33 -08:00
Leonardo de Moura
57982135d9 fix(library/simplifier): bug using congr1 theorem
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-09 16:24:29 -08:00
Leonardo de Moura
c45c1748d8 refactor(builtin/kernel): reorder congr1 arguments
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-09 16:15:44 -08:00
Leonardo de Moura
fd6f8b1945 refactor(builtin/num): simplify proofs using 'by simp'
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-09 15:03:45 -08:00
Leonardo de Moura
2d70e2f4f2 fix(library/tactic/goal): bug in the proof builder
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-09 15:02:36 -08:00
Leonardo de Moura
4c76f6abb9 chore(builtin/num): remove leftover
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-09 11:39:26 -08:00
Leonardo de Moura
8df7c7b02d feat(kernel/type_checker): remove fallback that expands opaque definitions in the type checker
We should not rely on this feature. It can be quite expensive.
We invoke is_convertible in several places, in particular, if we are using overloading. For example, the frontend uses is_convertible to check which overload should be used. Thus, it will make several calls such as

   is_convertible(num, Nat)

If is_convertible starts unfolding opaque definitions, we would keep expanding num.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-09 11:31:24 -08:00
Leonardo de Moura
4c4c8b3e0d feat(builtin/num): prove basic theorems using simplifier
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-09 11:24:53 -08:00
Leonardo de Moura
633ed6bb69 fix(frontends/lean/parser): bug in add_rewrite
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-09 09:46:56 -08:00
Leonardo de Moura
b24c085cb0 feat(frontends/lean): avoid warning message
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-09 09:26:51 -08:00
Leonardo de Moura
d6167eae32 feat(builtin/num): define add and mul
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-08 22:28:15 -08:00
Leonardo de Moura
cc4148a98d feat(builtin/num): primitive recursion theorem
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-08 22:05:57 -08:00
Leonardo de Moura
f28c56b188 feat(builtin/num): add auxiliary definitions and theorems for proving the primitive recursion theorem
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-08 19:36:17 -08:00
Leonardo de Moura
fa4b60963b feat(builtin/num): define lt predicate, and prove basic theorems
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-08 10:57:17 -08:00
Leonardo de Moura
0760b5b53d doc(todo): update todo list 2014-02-08 09:23:56 -08:00
Leonardo de Moura
ded72f94b2 doc(todo): update todo list 2014-02-08 09:23:13 -08:00
Leonardo de Moura
1f3e0f7a38 chore(builtin/num): update object file
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-08 09:16:52 -08:00
Leonardo de Moura
aeaa803f9a feat(builtin): add num type (the base type that will be used to build nat, int, real)
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-08 09:12:53 -08:00
Leonardo de Moura
1c43020fc9 fix(library/tactic/goal): bug creating main proof builder
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-08 09:11:07 -08:00
Leonardo de Moura
24528ff685 fix(library/elaborator): fix glitches in the elaborator that were forcing us to provide parameters explicitly
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-07 18:02:08 -08:00
Leonardo de Moura
1ec01f5757 refactor(builtin): merge pair.lean with kernel.lean, and add basic theorems
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-07 16:04:44 -08:00
Leonardo de Moura
5454e2af32 doc(todo): remove item from todo list
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-07 15:04:10 -08:00
Leonardo de Moura
ad7b13104f feat(*): add support for heterogeneous equality in the parser, elaborator and simplifier, adjusts unit test to reflect changes
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-07 15:03:16 -08:00
Leonardo de Moura
6d7ec9d7b6 refactor(kernel): add heterogeneous equality back to expr
The main motivation is that we will be able to move equalities between universes.

For example, suppose we have
    A : (Type i)
    B : (Type i)
    H : @eq (Type j) A B
where j > i

We didn't find any trick for deducing (@eq (Type i) A B) from H.
Before this commit, heterogeneous equality as a constant with type

   heq : {A B : (Type U)} : A -> B -> Bool

So, from H, we would only be able to deduce

   (@heq (Type j) (Type j) A B)

Not being able to move the equality back to a smaller universe is
problematic in several cases. I list some instances in the end of the commit message.

With this commit, Heterogeneous equality is a special kind of expression.
It is not a constant anymore. From H, we can deduce

   H1 : A == B

That is, we are essentially "erasing" the universes when we move to heterogeneous equality.
Now, since A and B have (Type i), we can deduce (@eq (Type i) A B) from H1. The proof term is

  (to_eq (Type i) A B (to_heq (Type j) A B H))  :  (@eq (Type i) A B)

So, it remains to explain why we need this feature.

For example, suppose we want to state the Pi extensionality axiom.

axiom hpiext {A A' : (Type U)} {B : A → (Type U)} {B' : A' → (Type U)} :
      A = A' → (∀ x x', x == x' → B x == B' x') → (∀ x, B x) == (∀ x, B' x)

This axiom produces an "inflated" equality at (Type U) when we treat heterogeneous
equality as a constant. The conclusion

     (∀ x, B x) == (∀ x, B' x)

is syntax sugar for

   (@heq (Type U) (Type U) (∀ x : A, B x) (∀ x : A', B' x))

Even if A, A', B, B' live in a much smaller universe.

As I described above, it doesn't seem to be a way to move this equality back to a smaller universe.

So, if we wanted to keep the heterogeneous equality as a constant, it seems we would
have to support axiom schemas. That is, hpiext would be parametrized by the universes where
A, A', B and B'. Another possibility would be to have universe polymorphism like Agda.
None of the solutions seem attractive.

So, we decided to have heterogeneous equality as a special kind of expression.
And use the trick above to move equalities back to the right universe.

BTW, the parser is not creating the new heterogeneous equalities yet.
Moreover, kernel.lean still contains a constant name heq2 that is the heterogeneous
equality as a constant.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-07 10:28:10 -08:00
Leonardo de Moura
354d5607af chore(builtin/sum): cleanup
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-06 21:25:57 -08:00
Leonardo de Moura
d4b08fcf96 feat(library/elaborator): be 'lazy' when normalizing terms in the elaborator
Unification constraints of the form

         ctx |- ?m[inst:i v] == T

         and

         ctx |- (?m a1 ... an) == T

are delayed by elaborator because the produce case-splits.
On the other hand, the step that puts terms is head-normal form is eagerly applied.
This is a bad idea for constraints like the two above. The elaborator will put T in head normal form
before executing process_meta_app and process_meta_inst. This is just wasted work, and creates
fully unfolded terms for solvers and provers.

The new test demonstrates the problem. In this test, we mark several terms as non-opaque.
Without this commit, the produced goal is a huge term.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-06 21:08:00 -08:00
Leonardo de Moura
ff955f9830 chore(frontends/lean/parser): update comments
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-06 20:56:31 -08:00
Leonardo de Moura
593f1f2ebd fix(frontends/lean): allow user set constants defined in other namespaces as opaque
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-06 20:56:31 -08:00
Leonardo de Moura
363c4dc5c2 feat(library/elaborator): improve support for dependent pairs in the elaborator
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-06 20:56:31 -08:00
Leonardo de Moura
5efc60d1f1 doc(todo): add another item to todo list 2014-02-06 18:07:06 -08:00
Leonardo de Moura
4b4b5e3345 fix(frontends/lean): import explicit versions when using the command 'using'
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-06 17:33:58 -08:00
Leonardo de Moura
ea06bb2885 feat(frontends/lean/pp): change how lift local entries are pretty printed
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-06 17:26:38 -08:00
Leonardo de Moura
a51139e63b feat(frontends/lean): position information in error messages
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-06 17:26:38 -08:00
Leonardo de Moura
e85b1f1ac0 feat(library/elaborator): expose elaborator configuration options
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-06 17:26:38 -08:00
Leonardo de Moura
45ef10e2c1 doc(todo): update todo list 2014-02-06 17:01:30 -08:00