Commit graph

252 commits

Author SHA1 Message Date
Leonardo de Moura
1b4c9f63ce perf(kernel/environment): improve is_descendant performance, optimize for the common case: the is_descendant tree is huge but has few deep branches
This is an important optimization for module.cpp. The benchmark tests/lua/slow/mod2.lua is a good example where the cost of is_descendant was neutralizing the benefit of the replace method.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-27 22:29:03 -07:00
Leonardo de Moura
f375ed5f7a test(tests/kernel/environment): add more tests for environment objects
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-21 12:42:29 -07:00
Leonardo de Moura
8872d4a531 refactor(kernel): rename definition class to declaration
The name was misleading since not every declaration is a definition.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-20 10:41:38 -07:00
Leonardo de Moura
5ce134e24e chore(kernel): binder => binding where appropriate
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-17 11:37:27 -07:00
Leonardo de Moura
d625c9a26c refactor(kernel): move max_sharing to library
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-17 11:15:08 -07:00
Leonardo de Moura
69e72c278d feat(kernel): add proof irrelevance for classes
We can use this feature to implement proof irrelevance for Identity types.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-16 15:30:32 -07:00
Leonardo de Moura
862c5e354d feat(kernel/expr): attach auxiliary name (for pretty printing) into local constants
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-16 13:08:09 -07:00
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
660b9299ad refactor(kernel): (de)serialization procedures don't need to be in the kernel
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-15 17:23:36 -07:00
Leonardo de Moura
2593f65ce1 feat(kernel): add tag to kernel expressions
Frontends can used tags to associate expressions with line number information.
The update_* procedures automatically propagate tags.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-12 16:33:25 -07:00
Leonardo de Moura
ff9004dae2 refactor(kernel): add level normalizer, is_equivalent predicate, switch to is_equivalent in the type checker, fix bugs in is_lt predicate
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-11 18:05:02 -07:00
Leonardo de Moura
e942aecca6 refactor(kernel/type_checker): remove method is_conv
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-09 20:29:35 -07:00
Leonardo de Moura
7b6d555433 refactor(kernel): remove level constraints from definitions
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-09 20:11:50 -07:00
Leonardo de Moura
23ed003389 refactor(kernel): remove diff_cnstrs module
We don't need them anymore. We will drop universe cumulativity from the kernel.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-09 19:58:25 -07:00
Leonardo de Moura
c843243f64 feat(library/kernel_bindings): add add_decl and type_check functions to Lua API
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-08 18:08:32 -07:00
Leonardo de Moura
850ec69538 feat(kernel): add flag for disabling impredicativity of Prop/Bool in the kernel
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-05 14:09:17 -07:00
Leonardo de Moura
120c24319e fix(tests/kernel/metavar): typo
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-01 12:58:09 -07:00
Leonardo de Moura
027614cebb fix(kernel/metavar): wierd memory leak that only happens when compiling with clang++
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-01 12:55:55 -07:00
Leonardo de Moura
b0e0e82350 refactor(kernel): separate type_checker and converter
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-30 18:42:01 -07:00
Leonardo de Moura
49e626a0e0 refactor(kernel/metavar): switch to functional substitution datastructure
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-29 10:22:36 -07:00
Leonardo de Moura
1681dc2389 test(kernel): add new environment tests
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-28 14:04:05 -07:00
Leonardo de Moura
e769c26800 refactor(kernel): move files that don't need to be in the kernel
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-25 18:30:40 -07:00
Leonardo de Moura
a39a5b4195 refactor(kernel): remove normalizer
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-25 12:02:33 -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
f99444b130 chore(tests): move max_sharing unit tests to tests/kernel
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-22 16:01:30 -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
984ac03ac7 refactor(kernel): replace kernel object with definition, disable affected files
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-17 16:10:47 -07:00
Leonardo de Moura
3712da0b54 refactor(kernel/instantiate): use get_free_var_range to improve instantiate, remove instantiate_with_closed, fix index overflow bug
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-17 13:12:49 -07:00
Leonardo de Moura
1fd5e9682d refactor(kernel/free_vars): use get_free_var_range to improve lift_free_vars and lower_free_vars performance
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-17 12:41:06 -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
3651b4ecd0 refactor(kernel): replace_fn functional object
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:57 -07:00
Leonardo de Moura
eb487e44c1 refactor(kernel): use names instead of unsigned integers to encode level parameters
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:57 -07:00
Leonardo de Moura
aa4a7acccf feat(kernel/level): is_trivial predicate for level constraints
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:57 -07:00
Leonardo de Moura
41782c0894 test(kernel/metavar): add metavar tests
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:56 -07:00
Leonardo de Moura
bf13441bd7 fix(kernel): bugs in justification module, add missing metavar methods, add basic metavar tests
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:56 -07:00
Leonardo de Moura
2a73389ed3 refactor(kernel): justification objects
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:56 -07:00
Leonardo de Moura
501435f6fc feat(kernel): add has_local predicate
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:56 -07:00
Leonardo de Moura
6baa59376c refactor(kernel): normalizer
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:56 -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
737fe6830f test(tests/kernel): adjust expr tests
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:55 -07:00
Leonardo de Moura
73c8bf4436 refactor(tests/kernel): move tests to new kernel
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:55 -07:00
Leonardo de Moura
72e1678ad9 refactor(kernel): cleanup instantiate and abstract procedures, implement update procedures
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:55 -07:00
Leonardo de Moura
76b1ddb967 feat(kernel): add difference constraint solver with backtracking support, and justification generation, this solver will be used to check the satisfiability of universe level constraints
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:54 -07:00
Leonardo de Moura
9f93b5d97e feat(kernel/level): new universe level datastructure for universe level polymorphism
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:54 -07:00
Leonardo de Moura
1739b5c153 fix(kernel/type_checker): caching bug
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-12 10:43:01 -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
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
9fb3ccb4c0 feat(library/simplifier): support for dependent simplification in lambda expressions
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-25 16:54:42 -08:00
Leonardo de Moura
bbf6e6a256 feat(builtin/kernel): create default rule set in the kernel, and adjust unit tests
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-19 11:24:20 -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