Leonardo de Moura
cb479a75ae
fix(kernel/expr): make sure we cannot create a free variable with index uint_max, reason: get_free_var_range would return an incorrect value
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-17 13:25:21 -07:00
Leonardo de Moura
dc864bf7b9
feat(kernel): store free variable range in composite expressions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-04-17 11:31:48 -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
9b161b825f
refactor(kernel): instantiate_params
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:57 -07:00
Leonardo de Moura
3939b93c2d
refactor(kernel): substitution
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:57 -07:00
Leonardo de Moura
916301bdfb
refactor(kernel): parametric kernel objects
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:57 -07:00
Leonardo de Moura
3c6002e969
refactor(kernel): add mk_rev_app, update_rev_app, implement instantiate_metavars functions, modify instantiate (free vars) API
...
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
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
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
74f74d2f79
refactor(kernel): shallow copy procedure
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:55 -07:00
Leonardo de Moura
d17990ed78
refactor(kernel): add formatter and simplify contexts
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:55 -07:00
Leonardo de Moura
53ee205dc6
fix(kernel): memory corruption bugs
...
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
23988f528c
refactor(kernel/expr): add expr constructors, and expression equality test
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:54 -07:00
Leonardo de Moura
02413d7c44
refactor(kernel/expr): adding suport for universe polymorphism, and simplify metavariable representation
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-03-18 10:27:54 -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
5e5ab1429d
feat(frontends/lean): parse and pretty print sigma types
...
This commit also fixes some bugs in the implementation of Sigma types.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-02-03 18:16:00 -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
6bcd8e3ee5
fix(library/expr_lt): use expression depth instead of size to obtain a monotonic total order on terms
...
It is not incorrect to use size, but it can easily overflow due to sharing.
The following script demonstrates the problem:
local f = Const("f")
local a = Const("a")
function mk_shared(d)
if d == 0 then
return a
else
local c = mk_shared(d-1)
return f(c, c)
end
end
print(mk_shared(33):size())
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-20 17:40:49 -08:00
Leonardo de Moura
5060bdbf14
fix(kernel/expr): compilation warning
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-20 13:12:49 -08:00
Leonardo de Moura
ac9f8f340d
feat(kernel/expr): add efficient get_size() function for expressions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-20 12:28:37 -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
7fb0aa4800
chore(kernel/expr): remove dead code
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 17:24:31 -08:00
Leonardo de Moura
c096eec1d6
chore(kernel/expr): remove dead code
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 17:09:04 -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
1f6e959139
feat(deserializer): protect against corrupted binary files
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-30 18:05:38 -08:00
Leonardo de Moura
de77851a00
refactor(util/object_serializer): add methods write_core and read_core that allows to pack information in the byte used to indicate whether an object is already in the cache or not
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-29 19:59:53 -08:00
Leonardo de Moura
d0fdc3619b
feat(kernel/expr): compress application serialization
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-29 19:11:57 -08:00
Leonardo de Moura
22bebbf242
feat(kernel/object): serializer for kernel objects
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-28 14:39:10 -08:00
Leonardo de Moura
755e8b735f
feat(kernel/expr): serializer for kernel expressions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-28 01:23:21 -08:00
Leonardo de Moura
90dbdaec40
feat(kernel/expr): cache is_arrow result
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-21 13:59:45 -08:00
Leonardo de Moura
8f2fe273ea
refactor(*): isolate std::thread dependency
...
This commit allows us to build Lean without the pthread dependency.
It is also useful if we want to implement multi-threading on top of Boost.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-09 15:20:26 -08:00
Leonardo de Moura
2f88d6710c
feat(kernel/expr): add some_expr and none_expr for building values of type optional<expr>
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-08 10:34:38 -08:00
Leonardo de Moura
25b812f1c9
feat(kernel/expr): no overhead optional<expr> template specialization
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-08 10:17:29 -08:00
Leonardo de Moura
3e1fd06903
refactor(kernel/expr): remove 'null' expression, and operator bool for expression
...
After this commit, a value of type 'expr' cannot be a reference to nullptr.
This commit also fixes several bugs due to the use of 'null' expressions.
TODO: do the same for kernel objects, sexprs, etc.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-07 23:21:10 -08:00
Leonardo de Moura
c1afefb873
feat(library/fo_unify): unify heterogeneous - homogeneous equality
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-05 19:00:31 -08:00
Leonardo de Moura
3a93212d5e
chore(kernel/expr): fix cpplint warning
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-27 12:59:16 -08:00
Leonardo de Moura
956f203a55
refactor(bindings/lua): move Lua bindings to the file associated with them
...
The directory bindings/lua was getting too big and had too many dependencies.
Moreover, it was getting too painful to edit/maintain two different places.
Now, the bindings for module X are in the directory that defines X.
For example, the bindings for util/name.cpp are located at util/name.cpp.
The only exception is the kernel. We do not want to inflate the kernel
with Lua bindings. The bindings for the kernel classes are located
at bindings/kernel_bindings.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-26 19:15:56 -08:00
Leonardo de Moura
7f088b7635
feat(kernel): add (optional) field m_type to expr_const, this field is useful for implementing the tactic framework
...
This field should not be visible in the external API.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-19 11:21:52 -08:00
Leonardo de Moura
57bf4f3e67
feat(kernel/expr): avoid recursion when deleting expressions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-18 18:41:08 -08:00
Leonardo de Moura
691893258d
feat(kernel/expr): add hash code based on allocation time
...
The new hash code has the property that given expr_cell * c1 and expr_cell * c2,
if c1 != c2 then there is a high propbability that c1->hash_alloc() != c2->hash_alloc().
The structural hash code hash() does not have this property because we may have
c1 != c2, but c1 and c2 are structurally equal.
The new hash code is only compatible with pointer equality.
By compatible we mean, if c1 == c2, then c1->hash_alloc() == c2->hash_alloc().
This property is obvious because hash_alloc() does not have side-effects.
The test tests/lua/big.lua exposes the problem fixed by this commit.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-14 02:43:11 -08:00
Leonardo de Moura
31abc00db8
chore(*): add LCOV_EXCL_LINE to lean_unreachable statements
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 09:19:38 -08:00
Leonardo de Moura
aa99ac6618
feat(kernel/value): allow semantic attachments to use coercions when being pretty printed
...
For example, this feature is useful when displaying the integer value 10 with coercions enabled. In this case, we want to display "nat_to_int 10" instead of "10".
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-30 11:42:26 -07:00
Leonardo de Moura
7cf83800c0
refactor(metavar): implement metavar_env, and use unification_constraint and trace objects in the type_checker, light_checker
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
59914a36f3
refactor(metavar): reorganize and simplify metavariables
...
- Use hierarchical names instead of unsigned integers to identify metavariables.
- Associate type with metavariable.
- Replace metavar_env with substitution.
- Rename meta_ctx --> local_ctx
- Rename meta_entry --> local_entry
- Disable old elaborator
- Rename unification_problems to unification_constraints
- Add metavar_generator
- Fix metavar unit tests
- Modify type checker to use metavar_generator
- Fix placeholder module
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
6477708d78
refactor(debug): improve lean_unreachable(), now we can avoid 'fake' return statements
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-09-25 21:27:20 -07:00
Leonardo de Moura
ba0528c298
Implement total order on expressions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-09-24 12:16:32 -07:00
Soonho Kong
ab6ca82e6f
Update to suppress unused-parameter warnings
2013-09-19 22:40:34 -07:00
Leonardo de Moura
99a163f11d
Simplify metavariable context. Now, we have only 'lift' and 'inst' instead of 'subst', 'lift' and 'lower'
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-09-16 19:32:28 -07:00
Leonardo de Moura
63e102055e
Move metavariables to the kernel. This is the first step for implementing the new elaborator.
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-09-15 12:09:01 -07:00
Leonardo de Moura
26097475fd
Use fullpath in #include directives.
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-09-12 20:04:10 -07:00
Leonardo de Moura
2459c4ae7c
Add (optional) type to let declarations
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-09-06 10:06:26 -07:00
Leonardo de Moura
d41160f8a5
Modify environment. Now, when a builtin value is declared, if it has a unicode alternative representation, then we add it as a definition. Now, everything that occurs in the environment has been 'declared'.
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-09-04 08:53:00 -07:00
Leonardo de Moura
887f696f66
Factor duplicate code. Add more comments
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-09-03 23:27:58 -07:00
Leonardo de Moura
18a195029b
Refactor expression equality
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-23 09:42:49 -07:00
Leonardo de Moura
cbff5ea856
Cleanup
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-16 20:40:39 -07:00
Leonardo de Moura
99219f998b
Rename files sets.h and maps.h to expr_sets.h and expr_maps.h
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-15 19:02:28 -07:00
Leonardo de Moura
392b347f53
Add expr_formatter and expr_locator. Add better error messages. Improve simple printer.
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-13 19:16:40 -07:00
Leonardo de Moura
11a9cac5d6
Refactor kernel objects
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-13 15:13:54 -07:00
Leonardo de Moura
2670e94398
Add pretty printer for Lean environment
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-07 19:10:12 -07:00
Leonardo de Moura
84de625ee4
Rename pp functions (that do not use format lib) to print
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-07 12:10:10 -07:00
Leonardo de Moura
722e2b0ed4
Reformat code (make formating more consistent)
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-07 08:17:33 -07:00
Leonardo de Moura
84f4a32c0e
Change name convention for creating Lean expressions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-06 11:27:14 -07:00
Leonardo de Moura
2986f0543e
Simplify how universe variable constraints are represented in the kernel. Allow universe variable to be created without an environment.
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-05 20:06:42 -07:00
Leonardo de Moura
f0ccb2a03e
Rename eqp --> is_eqp. The name is too similar to heterogeneous equality constructor eq.
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-04 09:41:49 -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
b979436c40
Add basic semantic attachments for arithmetic
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-03 19:57:06 -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
2972bdfec3
Rename abst_type to abst_domain
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-03 16:12:12 -07:00
Leonardo de Moura
3ef9d21875
Fix bugs in type checker
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-01 21:40:39 -07:00
Leonardo de Moura
e220d7c525
Add type checker. Fix normalization with non-empty context
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-08-01 21:40:36 -07:00
Soonho Kong
322c2b472d
Add more to expr pretty-print
2013-08-01 18:54:06 -07:00
Soonho Kong
5a89bffe83
Add pp to expr
2013-08-01 15:42:06 -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
6452c69b96
Use level at kernel expressions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-29 19:44:26 -07:00
Leonardo de Moura
f7138b6ecf
Fix normalize
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-25 19:13:45 -07:00
Leonardo de Moura
59592ed36b
Add deep copy for kernel expressions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-24 14:56:32 -07:00
Leonardo de Moura
ceb6537e3a
Fix race condition when updating expression flags: max_shared and closed
...
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
9fd88e6e27
Add small demo
...
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
2c3fc09e3c
Add has_free_vars/closed function
...
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
90f498994a
Add some overloads
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-24 14:56:31 -07:00
Leonardo de Moura
dd74284fdc
Cleanup eq_functor
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-23 09:12:15 -07:00
Leonardo de Moura
5aa25a635f
Add max_shared flag to expr_cell. Improve app constructor.
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-23 08:59:39 -07:00
Leonardo de Moura
2a9d0de57b
Add max_shared: function for computing maximally shared expressions.
2013-07-22 19:31:27 -07:00
Leonardo de Moura
aed8a07c1b
Add sexpr test
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-22 19:02:11 -07:00
Leonardo de Moura
06320c8615
Replace expr == with recursive function. Add goodies for traversing expressions.
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-22 16:40:17 -07:00
Leonardo de Moura
c4cd6c4f84
Add tests for kernel expression
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-22 13:04:27 -07:00
Leonardo de Moura
c32dfe22b6
Add expressions (dependent type theory)
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-07-22 12:46:11 -07:00