Leonardo de Moura
926ed0a02d
feat(lua): add type_inferer object to Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-16 19:18:15 -08:00
Leonardo de Moura
4ebb3c572a
feat(kernel/environment): make the environment throw an exception when weak-ref has expired
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-16 18:35:17 -08:00
Leonardo de Moura
590b14570f
feat(lua): improve error handling in Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-16 18:21:42 -08:00
Leonardo de Moura
516c5c8fea
feat(lua): add metavar_env objects to Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-16 14:44:33 -08:00
Leonardo de Moura
c8fff45319
feat(lua): add justification objects to Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-16 11:12:58 -08:00
Leonardo de Moura
9398ea5a59
feat(util/shared_mutex): add support for recursive lock at shared_mutex
...
We need support for recursive locks. The main user of this class is
the environment object. This commit adds a test that demonstrates that
the shared_lock of the environment object may be recursively requested.
Before this fix, the Lean was deadlocking in this example.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-15 22:01:11 -08:00
Leonardo de Moura
209a2d10f7
fix(lua): replace std::mutex with std::recursive_mutex, add test that demonstrates the problem that is being fixed
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-15 21:26:16 -08:00
Leonardo de Moura
8525e8534b
feat(lua): expose parse_expr and parse_commands from frontends/lean in the Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-15 16:11:26 -08:00
Leonardo de Moura
d9d9c05e4f
refactor(lua/options): remove unnecessary function
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-15 12:53:27 -08:00
Leonardo de Moura
19533c811b
feat(library/script_evaluator): add abstract class that exposes only the API needed by frontend objects
...
The main motivation is to break the remove the dependency frontends/lean <-- bindings/lua.
This dependency is undesirable because we want to expose the frontends/lean parser and pretty printer objects at bindings/lua.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-15 12:13:09 -08:00
Leonardo de Moura
1cb0262ec5
chore(memcheck): make the suppression entries for LuaJIT more general
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-15 11:34:50 -08:00
Leonardo de Moura
e7552d35e0
chore(memcheck): hide another tcmalloc bug
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-15 11:33:34 -08:00
Leonardo de Moura
a74412963a
chore(build): only execute lua multi-threading tests when on cygwin or linux, and using g++
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-15 09:27:58 -08:00
Leonardo de Moura
782335581b
fix(lua/thread): uninitialized memory
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-15 09:07:18 -08:00
Leonardo de Moura
b5dcb93550
feat(lua): communication channels for threads
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-14 21:10:46 -08:00
Leonardo de Moura
bd1e9c7548
feat(lua): throw an exception if the user tries to create a thread and Lean was compiled without multi-threading support
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-14 19:06:36 -08:00
Leonardo de Moura
3a924a5fb1
perf(lua/name): improve to_name_ext performance
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-14 18:06:09 -08:00
Leonardo de Moura
cd6bd79d63
refactor(lua): cleanup Lua API, improve performance
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-14 17:33:46 -08:00
Leonardo de Moura
6575566f9f
fix(lua): rename lua_ref to lref, lua_ref is a macro in LuaJIT
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-14 15:50:56 -08:00
Leonardo de Moura
09bed4786c
feat(lua): add semantic attachments for builtin arithmetical values to Lua API, improve mk_constant
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-14 15:15:04 -08:00
Leonardo de Moura
05f254f605
refactor(lua): move lua_ref to separate file
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-14 14:41:54 -08:00
Leonardo de Moura
bdea42b2a9
style(lua): ignore bogus warning
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-14 14:13:06 -08:00
Leonardo de Moura
abe93dfec0
fix(lua/splay_tree): for_each method was crashing if the map was updated during for_each
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-14 13:48:23 -08:00
Leonardo de Moura
64cce595a5
feat(lua): add splay_maps to the Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-14 13:35:36 -08:00
Leonardo de Moura
8e56726116
fix(library/expr_lt): fix bug when using hash codes
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-14 13:18:33 -08:00
Leonardo de Moura
b0322787ff
feat(lua): add has_metavar method
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-14 10:28:50 -08:00
Leonardo de Moura
9e445d1917
feat(lua): interrupt and sleep Lua APIs
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-14 10:04:32 -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
ae7ea99b56
fix(lua): copy_values and add tests
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 21:31:27 -08:00
Leonardo de Moura
c759fc93f7
test(lua): object Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 20:59:28 -08:00
Leonardo de Moura
6e0fc0ca9b
chore(build): include dl.so when compiling on Linux
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 18:44:28 -08:00
Leonardo de Moura
6964e374c0
fix(lua): luajit incompatibility
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 18:08:00 -08:00
Leonardo de Moura
cbc4254ff5
feat(lua): add occurs method to expr Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 17:10:09 -08:00
Leonardo de Moura
ad1180c5b4
fix(kernel/occurs): typos
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 17:04:56 -08:00
Leonardo de Moura
351ef867d2
feat(lua): add abstract, instantiate, has_free_vars, lift/lower free_vars to Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 17:02:49 -08:00
Leonardo de Moura
ed3cf8152b
feat(lua): add for_each to expr Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 16:30:59 -08:00
Leonardo de Moura
eacd60de9c
feat(frontends/lean): return the operator associated with constant expressions that are names of builtin values
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 16:08:21 -08:00
Leonardo de Moura
1bf6051866
test(lua): expr LUA API test
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 15:29:31 -08:00
Leonardo de Moura
9a22702383
feat(lua): make objects() and localobjects() methods return iterators in the environment LUA API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 14:26:01 -08:00
Leonardo de Moura
8c52d47692
chore(lua): rename env() to get_env()
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 13:58:51 -08:00
Leonardo de Moura
ba0889265e
refactor(lua): cleanup Lua bindings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 13:55:05 -08:00
Leonardo de Moura
b5f0185729
fix(lua): replace lua_pushfstring with lua_pushstring
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 12:14:55 -08:00
Leonardo de Moura
a80adae1c3
feat(lua): add fields method to sexpr Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 12:10:24 -08:00
Leonardo de Moura
e2efce6b62
style(util/sexpr): name convetion for enumeration types
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 11:50:12 -08:00
Leonardo de Moura
450128e28b
refactor(lua): cleanup Lua bindings, and add accessor/tester to expr Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-13 11:46:09 -08:00
Leonardo de Moura
c4c548dc5d
feat(*): simplify interrupt propagation
...
Instead of having m_interrupted flags in several components. We use a thread_local global variable.
The new approach is much simpler to get right since there is no risk of "forgetting" to propagate
the set_interrupt method to sub-components.
The plan is to support set_interrupt methods and m_interrupted flags only in tactic objects.
We need to support them in tactics and tacticals because we want to implement combinators/tacticals such as (try_for T M) that fails if tactic T does not finish in M ms.
For example, consider the tactic:
try-for (T1 ORELSE T2) 5
It tries the tactic (T1 ORELSE T2) for 5ms.
Thus, if T1 does not finish after 5ms an interrupt request is sent, and T1 is interrupted.
Now, if you do not have a m_interrupted flag marking each tactic, the ORELSE combinator will try T2.
The set_interrupt method for ORELSE tactical should turn on the m_interrupted flag.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-12 21:45:48 -08:00
Leonardo de Moura
b31233e8c2
feat(util/interrupt): restore interrupt module
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-12 21:16:10 -08:00
Leonardo de Moura
126c45626c
chore(memcheck.supp): add suppressions for LuaJIT bugs
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-12 18:52:03 -08:00
Leonardo de Moura
be093ecf90
feat(lua): use formatter available in the state object to convert Lean objects into strings in the Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-12 16:56:30 -08:00
Leonardo de Moura
9a5f86fce6
feat(lua): use (** ... **) instead of {{ ... }} for nested Lua scripts
...
The token }} is a bad delimiter for blocks of Lua script code nested in Lean files.
The problem is that the sequence }} occurs very often in Lua code because Lua uses { and } to build tables/lists/arrays.
Here is an example of Lua code that contains the sequence }}
t = {{1, 2}, {2, 3}, {3, 4}}
In Lean, (* ... *) is used to create comments. Thus, (** ... **) code blocks will not affect
valid Lean files. It also looks reasonably good.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-12 16:05:49 -08:00
Leonardo de Moura
8190d4fed5
feat(lua): allow Lua scripts to update 'global' options
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-12 15:38:00 -08:00
Leonardo de Moura
0a6f622aec
chore(build): remove CheckLuaObjlen, it is easier to check the Lua version
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-12 12:58:22 -08:00
Leonardo de Moura
b986af09ed
feat(lua): add support for copying closures between Lua states
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-12 12:54:34 -08:00
Leonardo de Moura
c46edcf370
feat(lua): expose formatter in the Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-12 11:19:15 -08:00
Leonardo de Moura
2af2a69fc6
feat(lua): expose kernel objects in the Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-12 09:40:29 -08:00
Leonardo de Moura
d257156b88
fix(lua): memory leaks, we should not use luaL_error because it does not unwind C++ stack
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 21:45:13 -08:00
Leonardo de Moura
a30e02d862
fix(lua): redefine Lua 'print' function, and make sure it is thread safe
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 21:15:21 -08:00
Leonardo de Moura
eb9d0f0552
test(lua): add example showing how to access/update an environment object using multiple threads
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 20:53:23 -08:00
Leonardo de Moura
0af8f17834
feat(lua): allow Booleans to be copied between Lua states
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 20:39:46 -08:00
Leonardo de Moura
7cb15cdac5
feat(lua): allow environment object references to be moved between Lua states
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 20:32:36 -08:00
Leonardo de Moura
ac6c18321a
fix(lua): make sure environment objects can be safely accessed/updated from current threads
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 20:29:53 -08:00
Leonardo de Moura
596e4aeb57
feat(util/shared_mutex): add shared_mutex object, this is a temporary replacement for std::shared_mutex that will be available in C++11
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 20:00:21 -08:00
Leonardo de Moura
cc7b5b7e50
fix(lua): disable custom allocation for Lua, it is crashing
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 18:20:52 -08:00
Leonardo de Moura
7d49df3985
style(lua): fix cpplint.py warnings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 17:46:39 -08:00
Leonardo de Moura
69b41eae70
feat(lua): add support for multiple execution threads in the Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 16:25:17 -08:00
Leonardo de Moura
95785c7aaa
feat(lua): add State objects, it allows us to create several Lua State objects in a lua script
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 15:05:50 -08:00
Leonardo de Moura
f158b0b311
fix(util/memory): make sure realloc behaves like free when sz == 0
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 13:42:22 -08:00
Leonardo de Moura
7cc6c35eee
feat(lua/name): add hash method to name objects
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 13:32:56 -08:00
Leonardo de Moura
8dd85ebc15
fix(lua): typos and a bug in the expr Lua bindings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 13:11:06 -08:00
Leonardo de Moura
b227775a07
test(lua): add tests for format object
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-11 12:58:47 -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
dbdb9a41af
style(lua): use C++-style cast
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-10 11:14:04 -08:00
Leonardo de Moura
7683188ab0
chore(emplace_back): use emplace_back when appropriate
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-10 11:14:04 -08:00
Leonardo de Moura
8c140ff86f
feat(lua): allow lua scripts (embedded in Lean files) to access the environment
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-10 11:14:04 -08:00
Leonardo de Moura
3078923ea4
fix(kernel/type_checker): add missing test, and kernel_exception has_no_type_exception
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-10 11:14:04 -08:00
Leonardo de Moura
9d61fcf85b
feat(lua): expose environment objects in the Lua bindings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-10 11:14:04 -08:00
Leonardo de Moura
119e0ba5e6
feat(lua): add to_nonnull_expr
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-10 11:14:04 -08:00
Leonardo de Moura
8dd62e76be
feat(lua): add mk_metavar to Lua API
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-10 11:14:04 -08:00
Soonho Kong
1cf037f11e
chore(cmake): do not delete coverage.info.cleaned which will be used for coveralls.io
2013-11-09 22:19:08 -05:00
Leonardo de Moura
6b71fb346c
fix(lua): add missing files for local_context
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-09 12:47:52 -08:00
Leonardo de Moura
554defe89d
feat(lua): expose local_context objects in the Lua bindings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-09 12:18:46 -08:00
Leonardo de Moura
183080294b
fix(cmake/Modules/CheckLuaNewstate.cc): compilation problem on cygwin
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-09 12:18:20 -08:00
Leonardo de Moura
ad2de3b53c
feat(lua): expose level objects in the Lua bindings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-08 17:08:24 -08:00
Leonardo de Moura
5a97f730af
feat(lua): add Type function
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-08 15:52:58 -08:00
Leonardo de Moura
32605d8266
feat(lua): expose level objects in the Lua bindings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-08 15:38:00 -08:00
Soonho Kong
d4dbc18404
chore(cmake/Modules/FindLua): disable TRY_RUN in cross-compilation.
2013-11-08 18:04:55 -05:00
Leonardo de Moura
bbab454b6c
fix(lua): cpplint.py does not like multiline strings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-08 13:27:20 -08:00
Leonardo de Moura
ec56ba72ea
fix(lua): cygwing compilation problem
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-08 13:27:20 -08:00
Leonardo de Moura
cc17be1ef1
feat(lua): add is_* predicates
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-08 12:40:28 -08:00
Leonardo de Moura
5c35a9ad0a
feat(lua): add Consts function
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-08 12:09:46 -08:00
Leonardo de Moura
b7d8391306
refactor(lua): remove duplicate code, separate lua_exception, add missing #pragma once
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-08 11:59:47 -08:00
Leonardo de Moura
c8b0c10c88
refactor(lua): make Lua a required (non-optional) package
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-08 10:56:29 -08:00
Leonardo de Moura
c5207489fd
fix(memory): realloc must behave like malloc when ptr is nullptr
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-08 10:31:57 -08:00
Leonardo de Moura
a10aa0880f
fix(build): add CheckLuaObjlen.cc test, not every Lua version has the function lua_objlen
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-08 08:26:04 -08:00
Leonardo de Moura
b57ad80d5e
feat(lua): expose basic API for Lean expressions in the Lua bindings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-07 21:54:57 -08:00
Leonardo de Moura
fb09fc9fe6
feat(lua): add set_global_function template, and to_name_ext function
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-07 21:54:57 -08:00
Leonardo de Moura
db8b16641c
chore(build): check if the Lua installed in the system supports lua_newstate
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-07 21:54:57 -08:00
Leonardo de Moura
9000c7c2fa
feat(lua): expose format objects in the Lua bindings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-07 21:54:42 -08:00
Leonardo de Moura
6f432b4094
feat(lua): make Lua use our malloc/realloc, catch error when initializing Lua
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-07 15:52:39 -08:00
Leonardo de Moura
57b9657bf0
feat(lua): add lua_exception for wrapping lua errors, and improve Lua error messages in the Lean frontend
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-07 15:19:26 -08:00
Leonardo de Moura
a9b2be0b9c
feat(frontends/lean): add support for embedded Lua scripts in Lean files
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-07 13:56:04 -08:00
Leonardo de Moura
ff16ffaea3
fix(kernel/environment): warning produced by clang
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-07 11:36:08 -08:00
Leonardo de Moura
8012c4f644
fix(kernel/environment): add weak reference to environment objects
...
We need weak references to environment objects because the environment has a reference to the type_checker and the type_checker has a reference back to the environment. Before, we were breaking the cycle using an "environment const &". This was a dangerous hack because the environment smart pointer passed to the type_checker could be on the stack. The weak_ref is much safer.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-07 11:29:08 -08:00
Leonardo de Moura
9c60eed93c
refactor(kernel/metavar): avoid using unique names for default metavariable prefix
...
The problem is that unique names depend on the order compilation units are initialized. The order of initialization is not specified by the C++ standard. Then, different compilers (or even the same compiler) may produce different initialization orders, and consequently the metavariable prefix is going to be different for different builds. This is not a bug, but it makes unit tests to fail since the output produced by different builds is different for the same input file.
Avoiding unique name feature in the default metavariable prefix avoids this problem.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-07 10:16:25 -08:00
Leonardo de Moura
2141ee12f4
refactor(frontends/lean): use extension objects to store lean default frontend data in the environment
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-07 10:00:12 -08:00
Leonardo de Moura
80e23f98c7
feat(kernel/environment): add environment extension objects, the environment can be extended with frontend specific objects
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-06 19:22:30 -08:00
Soonho Kong
c5fd828a71
chore(cmake): switch the ordering between gmp and mpfr
2013-11-05 19:31:10 -05:00
Leonardo de Moura
e7d508043b
fix(lua/numerics): errors when cross-compiling for Windows
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-05 13:35:34 -08:00
Leonardo de Moura
40fde1a69c
test(lua): invoke Lua binding tests from ctest
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-05 13:17:10 -08:00
Leonardo de Moura
0cc475e581
fix(lua/sexpr): make sexpr bindings robust
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-05 13:03:32 -08:00
Leonardo de Moura
055cc7f957
fix(lua): make testudata compatible with Lua 5.1
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-05 11:35:09 -08:00
Leonardo de Moura
5a01f167df
fix(lua): expose missing functions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-04 21:33:33 -08:00
Leonardo de Moura
0ac8f2d8d9
feat(lua/sexpr): improve sexpr Lua bindings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-04 21:28:17 -08:00
Leonardo de Moura
f13a97397f
feat(lua): expose s-expressions in the Lua bindings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-04 19:58:32 -08:00
Leonardo de Moura
1e12ddc7a9
refactor(lua): add goodies for accessing Lean values on the Lua stack
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-04 19:45:15 -08:00
Leonardo de Moura
47c289a24b
refactor(lua/name): improve name bindings for Lua
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-04 18:48:21 -08:00
Leonardo de Moura
3c475e890d
refactor(lua/options): improve options bindings for Lua
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-04 18:46:58 -08:00
Leonardo de Moura
7b77863507
refactor(lua/name): improve name bindings for Lua
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-04 18:44:20 -08:00
Leonardo de Moura
f488e6bbfc
fix(lua): safe_function_wrapper
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-04 18:12:53 -08:00
Leonardo de Moura
92b2591a6f
style(lua): add missing include
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-04 16:29:47 -08:00
Leonardo de Moura
32d3990fc7
fix(lua): problem when compiling with clang++
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-04 15:05:04 -08:00
Leonardo de Moura
0579970fc5
feat(lua): expose options object in the Lua bindings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-04 14:38:49 -08:00
Leonardo de Moura
543aea65c9
chore(lua): rename init_* functions to open_*
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-04 13:54:51 -08:00
Leonardo de Moura
fd7e85f0bb
feat(lua): add safe_function template that catches Lean and C++ exceptions and convert them into Lua errors
...
I'm using the approach described at:
http://stackoverflow.com/questions/4615890/how-to-handle-c-exceptions-when-calling-functions-from-lua
BTW, in some Lua versions, the C++ exceptions are correctly propagated.
I think we should not rely on features of particular implementations.
For example, LuaJIT does not propagate C++ exceptions.
Whenever an exception is thrown from C++ code invoked from LuaJit, LuaJit interrupts the execution and converts it to an error "C++ exception".
On the other hand, Lua 5.2 PUC-Rio interpreter (for Ubuntu) seem to propagate the C++ exceptions.
The template safe_function solves the issue. It will also produce a Lua error whenever the function being wrapped throws an exception. The error message is based on the "what()" method.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-03 14:42:57 -08:00
Leonardo de Moura
1a734979b4
fix(shell/lua): catch lean exceptions in the leanlua frontend
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-03 13:46:15 -08:00
Leonardo de Moura
6f2183fafe
feat(FindLua.cmake): search also for LuaJit
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-03 13:45:23 -08:00
Leonardo de Moura
9884c056ce
feat(lua): allow Lean to be compiled with Lua 5.1 and LuaJit
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-03 12:40:44 -08:00
Leonardo de Moura
df7dbe17b5
feat(lua/util): remove dependency on luaL_setfuncs
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-03 12:16:23 -08:00
Leonardo de Moura
e2da8c1f4d
feat(lua/numerics): expose mpz and mpq numbers in the Lua bindings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-03 12:05:54 -08:00
Soonho Kong
88ebdbcfb6
fix(shell/lua): move "#include<iostream>"
2013-11-03 13:25:33 -05:00
Soonho Kong
a9d55bf036
fix(lua): use updated FindLua and check version 5.2
2013-11-03 13:24:46 -05:00
Soonho Kong
044813615e
fix: add '#include <tuple>'
2013-11-03 13:00:42 -05:00
Soonho Kong
0d0d0cd533
chore(cmake): add gmp/mpfr include paths to cmakelists.txt
2013-11-03 13:00:42 -05:00
Leonardo de Moura
ccd95a9b66
fix(lua/name): fix memory leak
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-02 20:57:41 -07:00
Leonardo de Moura
dbf2d56c77
feat(lua/name): expose hierarchical names in the Lua bindings
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-02 20:49:42 -07:00
Leonardo de Moura
1b9cf816c4
fix(lua): mark package as optional
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-02 11:43:23 -07:00
Leonardo de Moura
ac08e244a6
feat(lua): add Lua support to build
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-02 11:16:30 -07:00
Leonardo de Moura
bf998d8661
feat(frontends/lean/parser): allow 'typeless' definitions, the type is inferred by the system
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-01 08:51:49 -07:00
Leonardo de Moura
fdea8aba10
feat(frontends/lean/scanner): allow '#' to be used in class B identifiers
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-01 08:42:25 -07:00
Leonardo de Moura
96dcd003c6
fix(frontends/lean/parser): associated position with 'type' placeholder
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-31 16:27:36 -07: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
032f5cd7b3
feat(frontends/lean): make the 'expression template' argument in Subst implicit because higher-order matching can infer it.
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-30 10:45:43 -07:00
Leonardo de Moura
bc92671ae4
fix(frontends/lean/notation): adjust the implicit arguments of TransExt, and add new test
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-29 17:12:50 -07:00
Leonardo de Moura
7fc87faa8f
feat(kernel): heterogeneous transitivity axiom, we need this axiom to be able to generate modular proofs in the rewriting engine module
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-29 17:07:30 -07:00
Leonardo de Moura
a57ca284ec
fix(tests/library/elaborator): replace eq with my_eq because eq is now a builtin symbol
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-29 17:06:32 -07:00
Leonardo de Moura
4dd6cead83
refactor(equality): make homogeneous equality the default equality
...
It was not a good idea to use heterogeneous equality as the default equality in Lean.
It creates the following problems.
- Heterogeneous equality does not propagate constraints in the elaborator.
For example, suppose that l has type (List Int), then the expression
l = nil
will not propagate the type (List Int) to nil.
- It is easy to write false. For example, suppose x has type Real, and the user
writes x = 0. This is equivalent to false, since 0 has type Nat. The elaborator cannot introduce
the coercion since x = 0 is a type correct expression.
Homogeneous equality does not suffer from the problems above.
We keep heterogeneous equality because it is useful for generating proof terms.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-29 16:20:06 -07:00
Leonardo de Moura
d0009d0242
feat(frontends/lean): make the first argument of if-expression implicit, add support for marking implicit arguments on builtin symbols (aka semantic attachments)
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-29 15:53:50 -07:00
Leonardo de Moura
2d88922543
feat(frontends/lean/elaborator): solve easy overloads at preprocessing time
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-29 10:07:15 -07:00
Leonardo de Moura
577ca128a1
fix(library/elaborator): add missing conflict justification
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-29 03:01:17 -07:00
Leonardo de Moura
521fa1ddb8
style(kernel/metavar): add missing includes
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-29 03:00:43 -07:00
Leonardo de Moura
7c8daf8974
fix(kernel/metavar): make sure the justification and substitution are always matching each other
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-29 02:39:52 -07:00
Leonardo de Moura
2c6d4d2225
fix(kernel/normalizer): do not apply substitutions in the normalizer
...
It is incorrect to apply substitutions during normalization.
The problem is that we do not have support for tracking justifications in the normalizer. So, substitutions were being silently applied during normalization. Thus, the correctness of the conflict resolution in the elaboration was being affected.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-29 02:14:48 -07:00
Leonardo de Moura
5f11392fcc
test(numerics/numeric_traits): add missing test
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-28 07:50:33 -07:00
Leonardo de Moura
1d18f60dd5
fix(numerics): add missing numeric_traits<float>::zero()
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-28 07:47:23 -07:00
Leonardo de Moura
b16a64f44b
fix(library/elaborator): missing normalization step for semantic attachments
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-28 07:42:14 -07:00
Leonardo de Moura
4564bfa1d3
feat(library/elaborator): improve simple_ho_match
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-27 11:17:03 -07:00
Leonardo de Moura
dbefc91151
fix(kernel/metavar): add normalize assignment justification
...
We need that when we normalize the assignment in a metavariable environment.
That is, we replace metavariable in a substitution with other assignments.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-27 11:02:34 -07:00
Leonardo de Moura
92f5a31976
feat(kernel/expr): add new mk_app template for creating applications using a collection
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-27 08:53:58 -07:00
Leonardo de Moura
eaccdcb558
refactor(assumption_justification): move to the kernel
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-26 14:21:29 -07:00
Leonardo de Moura
4bed9f85b0
feat(kernel/for_each): add option for disabling cache of atomic expressions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 15:25:17 -07:00
Leonardo de Moura
ce10bfeaf6
perf(kernel/metavar): improve performance of has_assigned_metavar by avoiding for_each+exception
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 15:19:59 -07:00
Leonardo de Moura
57d9d23bd4
feat(kernel/for_each): allow function F to interrupt for_each search
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 14:58:02 -07:00
Leonardo de Moura
2dd44bdf1a
perf(kernel/for_each): delay initialization of visited set
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 14:52:08 -07:00
Leonardo de Moura
e765105ea5
fix(frontends/lean/pp): let expressions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 12:30:39 -07:00
Leonardo de Moura
c3c66b6c90
feat(make): add THREAD_SAFE build option
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 11:50:35 -07:00
Leonardo de Moura
c53d559f7f
perf(library/elaborator): improve process_metavar
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 11:19:17 -07:00
Leonardo de Moura
471bbd4040
refactor(kernel/metavar): combine several splay_trees (at metavar_env) into a single one
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 11:02:19 -07:00
Leonardo de Moura
5e34f410b3
refactor(splay_map): modify splay_find signature
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 10:47:15 -07:00
Leonardo de Moura
5812dfcf44
perf(kernel/justification): remove cache from depends_on
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 10:26:05 -07:00
Leonardo de Moura
2b5c951de3
perf(name): add quick_cmp for hierarchical names
...
It first compare names using hash codes.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 09:58:06 -07:00
Leonardo de Moura
66f4834dbc
perf(kernel/metavar): add quick test that catches many cases
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 09:24:01 -07:00
Leonardo de Moura
f38178311c
perf(kernel/expr_eq): delay hashtable initialization
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 09:21:47 -07:00
Leonardo de Moura
e0ca27bfb3
fix(tests/library/rewriter): warning
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 08:33:53 -07:00
Leonardo de Moura
412bc792c9
fix(style): missing include
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 08:10:28 -07:00
Leonardo de Moura
0c21f45292
fix(kernel/unification_constraint): memory leak
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-25 08:06:21 -07:00
Leonardo de Moura
f0e149d77b
fix(frontends/lean/pp): fix how Type expressions are pretty printed
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 20:02:34 -07:00
Leonardo de Moura
a5c3829d1b
feat(kernel): add unexpected_metavar_occurrence exception
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 19:56:44 -07:00
Leonardo de Moura
83907d7c73
fix(elaborator): max constraints
...
elaborator was not handling max constraints where one of the arguments was a Bool. Example:
ctx |- max(Bool, Type) == ?M
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 19:27:57 -07:00
Leonardo de Moura
65a514ad8a
fix(frontends/lean/parser): option propagation
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 19:04:06 -07:00
Leonardo de Moura
576b4e2169
fix(frontends/lean/pp): missing comma when printing contexts
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 19:00:24 -07:00
Leonardo de Moura
df07a84d11
feat(frontends/lean/parser): display elaborator error messages
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 18:48:53 -07:00
Leonardo de Moura
ca6a6d71e5
fix(kernel/printer): bug when printing let expression
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 18:05:23 -07:00
Leonardo de Moura
e3efe39eeb
fix(elaborator): fix bug in higher-order matching/unification
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 17:53:37 -07:00
Leonardo de Moura
d1a2a4ea7e
feat(frontends/lean/elaborator): add support for coercions in let declarations
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 17:01:06 -07:00
Leonardo de Moura
872b698bc3
feat(elaborator): add option m_assume_injectivity for getting more concise solutions
...
We may miss solutions, but the solutions found are much more readable.
For example, without this option, for elaboration problem
Theorem Example4 (a b c d e : N) (H: (a = b ∧ b = e ∧ b = c) ∨ (a = d ∧ d = c)) : (h a c) = (h c a) :=
DisjCases H
(fun H1 : _,
let AeqC := Trans (Conjunct1 H1) (Conjunct2 (Conjunct2 H1))
in CongrH AeqC (Symm AeqC))
(fun H1 : _,
let AeqC := Trans (Conjunct1 H1) (Conjunct2 H1)
in CongrH AeqC (Symm AeqC))
the elaborator generates
Theorem Example4 (a b c d e : N) (H : a = b ∧ b = e ∧ b = c ∨ a = d ∧ d = c) : (h a c) = (h c a) :=
DisjCases
H
(λ H1 : if
Bool
(if Bool (a = b) (if Bool (if Bool (if Bool (b = e) (if Bool (b = c) ⊥ ⊤) ⊤) ⊥ ⊤) ⊥ ⊤) ⊤)
⊥
⊤,
let AeqC := Trans (Conjunct1 H1) (Conjunct2 (Conjunct2 H1)) in CongrH AeqC (Symm AeqC))
(λ H1 : if Bool (if Bool (a = d) (if Bool (d = c) ⊥ ⊤) ⊤) ⊥ ⊤,
let AeqC := Trans (Conjunct1 H1) (Conjunct2 H1) in CongrH AeqC (Symm AeqC))
The solution is correct, but it is not very readable. The problem is that the elaborator expands the definitions of \/ and /\.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 16:47:50 -07:00
Leonardo de Moura
d2f9c24d3c
fix(tests/lean): adjust tests
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 15:42:17 -07:00
Leonardo de Moura
a7f94b55db
fix(frontends/lean/elaborator): fix bugs and adjust tests
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 15:29:56 -07:00
Leonardo de Moura
bbc265ded4
feat(frontends/lean): hook new elaborator in the default frontend
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 15:14:29 -07:00
Leonardo de Moura
c9f7b8bce2
feat(frontends/lean): add get_coercions method
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 14:38:09 -07:00
Leonardo de Moura
71ccec5b9e
refactor(frontends/lean/elaborator): delete old_elaborator, and create frontend_elaborator class that will be based on library/elaborator/elaborator
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-24 10:45:59 -07:00
Leonardo de Moura
449454efdb
fix(debug): remove typeid information from assertion, the names are mangled and are not very useful
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-23 16:41:51 -07:00
Leonardo de Moura
434c33f225
feat(metavar): automatically apply beta-reduction when instantiating metavariable applications (i.e., expressions of the form (?m a)), when the metavariable is a lambda
...
This feature is useful for problems that require higher-order matching and/or unification.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-23 16:35:50 -07:00
Leonardo de Moura
873e56844a
refactor(beta_reduction): add function apply_beta
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-23 16:03:52 -07:00
Leonardo de Moura
f1e0d6ec29
refactor(beta_reduction): move beta reduction functions to the kernel, delete reduce.cpp file and tests
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-23 15:44:26 -07:00
Leonardo de Moura
c1e451151a
feat(replace_visitor): add an abstract class for applying transformations on expressions
...
I also removed replace_using_ctx since it is subsumed by the new class.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-23 15:01:37 -07:00
Leonardo de Moura
13531b7d3e
refactor(kernel): rename trace to justification
...
Motivations:
- We have been writing several comments of the form "... trace/justification..." and "this trace object justify ...".
- Avoid confusion with util/trace.h
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-23 13:42:17 -07:00
Leonardo de Moura
8e1a75ce1c
feat(elaborator): only process upper bound constraints when the corresponding metavariable does not have lower bound and max constraints
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-23 13:09:13 -07:00
Leonardo de Moura
172567a2fb
feat(elaborator): add support for upper bounds, max constraints, and fix bugs
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-23 12:01:39 -07:00
Leonardo de Moura
17b48010b7
fix(unification_constraint): fix printer for max constraints
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-23 12:00:29 -07:00
Leonardo de Moura
274b11530f
feat(metavar): improve apply_local_context
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-23 11:59:36 -07:00
Leonardo de Moura
b57f492e2d
fix(kernel/printer): improve printer for Type expressions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-23 11:58:49 -07:00
Leonardo de Moura
c635c16637
refactor(ho_unifier): remove ho_unifier, it has been subsumed by the elaborator class
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 17:51:54 -07:00
Leonardo de Moura
019f64671b
fix(elaborator): add basic support for flex-flex pairs, add more tests, fix bug when enumerating different solutions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 17:49:37 -07:00
Leonardo de Moura
80a507cf45
refactor(tests/frontends/lean/implicit_args): remove implicit_args unit tests from frontends/lean, all tests were moved to tests/library/elaborator
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 16:42:07 -07:00
Leonardo de Moura
7ad256131e
feat(elaborator): add support for constraints of the form ?m[inst, ...] == t, fix bugs, add more tests
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 16:39:22 -07:00
Leonardo de Moura
891d22b3de
feat(kernel/context): add method for remove context entries at positions [s, s+n).
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 15:52:24 -07:00
Leonardo de Moura
3fa4eac4ef
fix(replace_using_ctx_fn): typo
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 15:46:11 -07:00
Leonardo de Moura
8142726923
fix(type_inferer): bug when inferring the type of free variables
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 15:41:22 -07:00
Leonardo de Moura
874f67c605
feat(normalizer): remove normalization rule t == t ==> true
...
This normalization rule is not really a computational rule.
It is essentially encoding the reflexivity axiom as computation.
It can also be abaused. For example, with this rule,
the following definition is valid:
Theorem Th : a = a := Refl b
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 14:02:48 -07:00
Leonardo de Moura
5e61496381
test(elaborator): add more tests
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 13:45:20 -07:00
Leonardo de Moura
a5b4908f71
fix(elaborator): process_simple_ho_match and missing cases
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 13:45:04 -07:00
Leonardo de Moura
cb2c73cf37
feat(elaborator): add higher-order matching support to elaborator
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 11:22:00 -07:00
Leonardo de Moura
f4592da87f
feat(elaborator): solve more unification constraints, add more tests
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:37 -07:00
Leonardo de Moura
c3e87f106f
fix(kernel/trace): fix typo in depends_on
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:37 -07:00
Leonardo de Moura
dc51d35dc0
feat(library/type_inferer): add support for metavariables at type_inferer
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:37 -07:00
Leonardo de Moura
7f96c07a01
refactor(library): rename light_checker to type_inferer
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
183f5a1ccf
feat(elaborator): solve unification constraints
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
a1710aeeb9
feat(elaborator): add trace objects for elaborator
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
dc0e7a4472
feat(pos_info_provider): add position information provider for expressions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
8663ac550f
feat(kernel/trace): add function depends_on for trace objects
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
42edc4a72d
test(set): add set of pointers test
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
b1b49e86e7
test(elaborator): add simple test
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
1548ffabb1
feat(elaborator): add new elaborator interface
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
827c65b5e9
feat(kernel): add static_assert for update_metavar
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
61ccaf741c
fix(frontend/lean): minor modification to be able to execute lean frontend while refactoring elaborator
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -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
1f0eab7a14
test(type_checker): add new tests for type_checker trace objects
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
fc288929a2
feat(type_checker): add trace objects to justify constraints created by the type checker
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
5b1b03bafd
refactor(is_convertible): move from normalizer to type_checker class
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
85bfa45e6a
refactor(kernel_exception): delete kernel_exception_formatter, and implement kernel_exception pretty printer as a virtual method
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
d843d432d3
refactor(kernel): move printer and formatter objects to the kernel
...
The printer and formatter objects are not trusted code.
We moved them to the kernel to be able to provide them as an argument to the trace objects.
Another motivation is to eliminate the kernel_exception_formatter hack.
With the formatter in the kernel, we can implement the pretty printer for kernel exceptions as a virtual method.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
ddb90d3038
feat(kernel): add unification_constraint and trace objects to the kernel
...
Trace objects will be used to justify steps performed by engines such as the elaborator. We use them to implement non-chronological backtracking in the elaborator. They are also use to justify to the user why something did not work.
The unification constraints are in the kernel because the type checker may create them when type checking a term containing metavariables.
Remark: a minimalistic kernel does not need to include metavariables, unification constraints, nor trace objects. We include these objects in our kernel to minimize code duplication.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-22 08:15:36 -07:00
Leonardo de Moura
e741cc29ef
test(metavar): encode two of the bad examples as unit tests
...
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
3387c300a0
feat(polynomial): add multivariate polynomials
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-21 18:22:14 -07:00
Leonardo de Moura
93d4466d06
refactor(interval): move interval unit tests to tests/util/interval
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-21 18:17:34 -07:00
Leonardo de Moura
f18d35555e
refactor(interval): organize template source code using the approach described at http://www.codeproject.com/Articles/3515/How-To-Organize-Template-Source-Code
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-21 18:15:27 -07:00
Leonardo de Moura
e208309abd
refactor(numerics): rename power operator to pow, the idea is to follow the C/C++ name convention for the power operator
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-21 17:23:56 -07:00
Leonardo de Moura
f1d9312521
feat(numerics/zpz): add numeric_traits for zpz numerals
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-18 14:41:18 -07:00
Leonardo de Moura
1429cc9df2
feat(numerics): add finite field Z/pZ
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-18 13:27:28 -07:00
Leonardo de Moura
bdade0e638
fix(numerics): problem with gcd tests on OSX
...
Now, we only test gcd(a, b) for a != b && a != 0 && b != 0.
When one of these conditions do not hold, the result is implementation dependent.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-17 10:38:02 -07:00
Leonardo de Moura
cf2c0f8ebb
feat(numerics): add gcd and extended gcd templates (for primitive types)
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-16 18:18:20 -07:00
Leonardo de Moura
39f68ed0d6
feat(numerics): add is_prime function
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-16 17:25:08 -07:00
Leonardo de Moura
1097bbfb22
fix(style): fix warnings produced by cpplint.py, disable sizeof(type) warning
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-16 17:04:39 -07:00
Leonardo de Moura
105f55c68b
feat(numerics): add zero() method to all numeric_traits
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-16 16:55:17 -07:00
Leonardo de Moura
ff04c5a2e2
test(numerics): add test to make sure that zeros of different precision mpfp numbers are the equal.
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-16 16:54:43 -07:00
Leonardo de Moura
467eff4662
add(numerics): add prime number generator/iterator
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-16 16:05:45 -07:00
Leonardo de Moura
0783805671
feat(kernel): add weight to kernel definitions
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-15 14:50:08 -07:00
Leonardo de Moura
5bd6ba37d0
fix(light_checker): fix inconsistent cache bug in light_checker, add tests that expose the problem
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-01 19:25:58 -07:00
Leonardo de Moura
aa5be3262f
fix(type_checker): fix inconsistent cache bug in type_checker, add tests that expose the problem
...
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-01 19:23:55 -07:00