Commit graph

27 commits

Author SHA1 Message Date
Leonardo de Moura
40b3129e7b refactor(kernel): improve names
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-16 11:28:05 -07:00
Leonardo de Moura
4842ae4fc7 refactor(kernel): store macro arguments in the macro_expr
Before this commit, we "stored" macro arguments using applications.
This representation had some issues. Suppose we use [m a] to denote a macro
application. In the old representation, ([m a] b) and [m a b] would have
the same representation. Another problem is that some procedures (e.g., type inference)
would not have a clean implementation.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-25 15:02:56 -07:00
Leonardo de Moura
508bccb0c5 fix(kernel/max_sharing): add example exposing bug in max_sharing_fn, and fix it
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-24 15:55:48 -07:00
Leonardo de Moura
188da7e4c6 feat(kernel/max_sharing): add method already_processed
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-22 18:30:07 -07:00
Leonardo de Moura
9fda7e2529 fix(kernel): incorrect optimization in max_sharing_fn class
The resultant expression may failed to be fully shared.
Add an example that demonstrates the problem.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-22 15:38:22 -07:00
Leonardo de Moura
bc8379256a refactor(kernel): remove pairs from kernel
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-17 10:52:07 -07:00
Leonardo de Moura
eb046c11fb refactor(kernel): the type in let-exprs is not optional anymore, if the user does not provide it, we use a metavariable
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:55 -07:00
Leonardo de Moura
f986963a95 refactor(kernel): serializer and deserializer
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:55 -07: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
8eec289ce1 feat(kernel): add dependent pairs
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-03 16:52:49 -08:00
Leonardo de Moura
95b6e61738 feat(kernel/max_sharing): check for imminent stack overflows and interruptions in the expression sharing maximizer
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-21 14:33:49 -08:00
Leonardo de Moura
a43020b31b refactor(kernel): remove heterogeneous equality
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-16 17:39:12 -08:00
Leonardo de Moura
411f14415d feat(builtin): automatically generate Lean/C++ interface for builtin theories
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-09 18:09:53 -08:00
Leonardo de Moura
92c7145d7f feat(kernel/expr): maximize sharing before serializing
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-02 20:03:42 -08:00
Leonardo de Moura
d6d221b992 Move auxiliary files away from kernel
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-15 19:02:28 -07:00
Leonardo de Moura
3f789ce2b7 Add let and heterogeneous equality. Add bool_type and bool_value.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-04 09:37:52 -07:00
Leonardo de Moura
0a679074f0 Add support for semantic attachments. Remove expr_numeral
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-03 16:12:15 -07:00
Leonardo de Moura
10def5cabe Remove duplicate code
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-29 21:34:16 -07:00
Leonardo de Moura
08b750c825 Remove Prop from kernel
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-29 19:49:34 -07:00
Leonardo de Moura
1f7011353b Add (temporary) buffer class
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-24 14:57:51 -07:00
Leonardo de Moura
0fb93ad6ef Expose max_sharing_fn object
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-24 14:56:32 -07:00
Leonardo de Moura
4b61639f4d Use consistent naming for functional objects
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-24 14:56:32 -07:00
Leonardo de Moura
ed6d6483fe Rename abst_expr -> abst_body
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-24 14:56:32 -07:00
Leonardo de Moura
54a02b4fc7 Simplify expr accessor names
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-24 14:56:31 -07:00
Leonardo de Moura
6a2c9ef076 Rename/Reorg some kernel files
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-24 14:56:31 -07:00
Leonardo de Moura
f00d8c4683 Fix bug in max_sharing
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-23 09:18:18 -07:00
Leonardo de Moura
79d00f4d78 Rename max_sharing files
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-23 09:01:54 -07:00
Renamed from src/kernel/expr_max_shared.cpp (Browse further)