Commit graph

2060 commits

Author SHA1 Message Date
Leonardo de Moura
737e634556 fix(util/list): bug in map template
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-01 08:51:24 -08:00
Leonardo de Moura
568931ccb1 refactor(library/tactic): remove duplicate code, add add_proofs
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-01 07:55:01 -08:00
Leonardo de Moura
f91c4901e8 feat(library/tactic): add absurd_tactic
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-01 07:55:00 -08:00
Leonardo de Moura
bf2adb20e7 feat(library/tactic): add disj_hyp_tactic
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-01 07:55:00 -08:00
Soonho Kong
6a6b69ddf4 test(library/rewriter): add test for depth RW 2013-12-01 01:59:21 -05:00
Soonho Kong
064e3fe20d refactor(library/rewriter): rename lc => ti 2013-12-01 01:59:20 -05:00
Soonho Kong
506cca0ac1 feat(library/rewriter): implement depth RW 2013-12-01 01:59:20 -05:00
Soonho Kong
ae0508128f refactor(library/rewriter): move apply_rewriter_fn into rewriter.h 2013-12-01 00:57:09 -05:00
Soonho Kong
6d5adb0429 chore(.gitignore): update .gitignore 2013-12-01 00:48:44 -05:00
Soonho Kong
d7ba5e3893 doc(library/rewriter): add doxygen annotations for rewrite_* funcs 2013-12-01 00:47:53 -05:00
Leonardo de Moura
1a221d8bbe feat(library/tactic): add focus tactical
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-30 11:28:38 -08:00
Leonardo de Moura
7ff791eb9f feat(util/name_set): add mk_unique (with respect to a name_set)
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-30 11:28:38 -08:00
Leonardo de Moura
6da13cc245 feat(util/list): map_append template
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-30 11:28:38 -08:00
Leonardo de Moura
fe79bbf2b7 feat(util/list): filter template
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-30 11:28:38 -08:00
Soonho Kong
f205dd0763 fix(library/rewriter): unused variable warnings 2013-11-30 07:05:18 -05:00
Leonardo de Moura
83aaf64318 fix(library/tactic): memory leaks
Proof/Cex builders and tactics implemented in Lua had a "strong reference" to script_state. If they are stored in the Lua state, then we get a cyclic reference.
That is, script_state points to these objects, and they point back to script_state.

To avoid this memory leak, this commit defines a weak reference for script_state objects. The Proof/Cex builders and tactics now store a weak reference to the Lua state.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-30 00:44:39 -08:00
Leonardo de Moura
2372567a6e fix(util/luaref): warnings produced by valgrind
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-30 00:34:38 -08:00
Leonardo de Moura
a7027a1d00 feat(library/tactic): polish tactic API, and add new example showing how to implement tactics using Lua
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-30 00:16:39 -08:00
Soonho Kong
aed8b1fc73 fix(tests/library/rewriter): app_rewriter1_tst
There was a bug in the app_rewriter1_tst. If we apply the ADD_COMM RW to
f(0), then the result should be f(0) since there is nothing to do for
ADD_COMM.

    f(0) = f(0)

The proof for this equality should be Refl(Nat, f(0)). But it was

    Refl(Nat -> Nat, f)

which is wrong. Somehow, the previous kernel didn't detect this type
mismatch and recent changes of the kernel found the problem.

I fixed the bug and re-enable the test as it was.
2013-11-30 02:25:30 -05:00
Soonho Kong
f5f7380fbe feat(library/rewriter): add apply_rewriter_fn which will be used in depth RW 2013-11-30 02:25:30 -05:00
Soonho Kong
1d76a6f71d feat(library/rewriter): add rewrite_* functions
rewrite_* functions take the rewriting results of the sub-components and
construct the rewriting result for the main component.

For instance, rewrite_app function takes env, ctx, and the value v s.t.

v = (e_0 e_1 ... e_n)

and the rewriting results for e_i's as a vector(buffer)

(e'_0, pf_0 -- proof of e_0 = e'_0)
(e'_1, pf_1 -- proof of e_1 = e'_1)
...
(e'_n, pf_n -- proof of e_n = e'_n).

Then rewrite_app function construct the new v'

v' = (e'_0 e'_1 ... e'_n)

and the proof of v = v' which is constructed with pf_i's.

These functions are used in the component rewriters such as app_RW and
let_type_RW, as well as more complicated rewriters such as depth
rewriter.
2013-11-30 02:25:29 -05:00
Leonardo de Moura
a9eb2a9307 feat(kernel/builtin): add is_* functions
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-29 11:35:58 -08:00
Leonardo de Moura
18eb9e427f fix(library/tactic): compilation warning
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-29 10:35:14 -08:00
Leonardo de Moura
98897b467d feat(frontends/lean/parser): add support for Lua expression code blocks
In expression code blocks, we do not have to write a "return".
After this commit, the argument of an apply command is a Lua expression instead of a Lua block of code. That is, we can now write

apply (** REPEAT(ORELSE(imp_tactic, conj_tactic, conj_hyp_tactic, assumption_tactic)) **)

instead of

apply (** return REPEAT(ORELSE(imp_tactic, conj_tactic, conj_hyp_tactic, assumption_tactic)) **)

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-29 10:21:24 -08:00
Leonardo de Moura
f9874cd675 feat(library/tactic): add to_tactic_ext, it allows functions that return tactics to be used where a tactic is expected
For example, after this commit, we can write

simple_tac = REPEAT(ORELSE(imp_tactic, conj_tactic)) .. assumption_tactic

instead of

simple_tac = REPEAT(ORELSE(imp_tactic(), conj_tactic())) .. assumption_tactic()

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-29 09:40:21 -08:00
Leonardo de Moura
20a36e98ec feat(library/elaborator): modify how elaborator handles constraints of the form ?M << P and P << ?M, where P is a proposition.
Before this commit, the elaborator would only assign ?M <- P, if P was normalized. This is bad since normalization may "destroy" the structure of P.

For example, consider the constraint
[a : Bool; b : Bool; c : Bool] ⊢ ?M::1 ≺ implies a (implies b (and a b))

Before this, ?M::1 will not be assigned to the "implies-term" because the "implies-term" is not normalized yet.
So, the elaborator would continue to process the constraint, and convert it into:

[a : Bool; b : Bool; c : Bool] ⊢ ?M::1 ≺ if Bool a (if Bool b (if Bool (if Bool a (if Bool b false true) true) false true) true) true

Now, ?M::1 is assigned to the term
     if Bool a (if Bool b (if Bool (if Bool a (if Bool b false true) true) false true) true) true

This is bad, since the original structure was lost.

This commit also contains an example that only works after the commit is applied.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-29 09:15:01 -08:00
Leonardo de Moura
066dacea31 feat(library/tactic): add show_tactic, and optional '.' in the end of tactic command
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-29 01:33:26 -08:00
Leonardo de Moura
b3f87e2e4f feat(library/tactic): make THEN, ORELSE, APPEND, PAR and INTERLEAVE nary combinators
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 22:11:07 -08:00
Leonardo de Moura
7ed78815e0 fix(tests/lua): incorrect assertion
The assertion got violated after a bug was fixed in the to_goal procedure.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 21:53:57 -08:00
Leonardo de Moura
6832b265e9 style(frontends/lean/parse): missing include
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 21:50:55 -08:00
Leonardo de Moura
5dfb3b8b56 feat(frontends/lean/parse): allow script-code blocks to be used in the apply command
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 21:48:30 -08:00
Leonardo de Moura
67def8da21 fix(library/type_inferer): typo
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 21:47:29 -08:00
Leonardo de Moura
dae86c2ffa feat(frontends/lean/parser): add basic tactic support in the frontend
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 21:08:12 -08:00
Leonardo de Moura
73bbf67702 refactor(library/elaborator): simplify synthesizer interface
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 19:00:48 -08:00
Leonardo de Moura
c6b05bcfcb feat(library/tactic): modify assumption_tactic, it should fail if not applicable, and TRY tactical
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 18:23:38 -08:00
Leonardo de Moura
e3f3ec5553 feat(library/tactic): expose conj_tactic, imp_tactic, conj_hyp_tactic in the Lua API
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 18:17:15 -08:00
Leonardo de Moura
d36a91e145 feat(library/tactic): expose COND and WHEN tacticals in Lua, add HOL-like tactical names
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 17:57:24 -08:00
Leonardo de Moura
ff052d41ee chore(*): fix cygwin compilation errors
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 13:49:18 -08:00
Leonardo de Moura
662fb71d59 chore(tests/lua/threads): fix type in file name
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 13:12:54 -08:00
Leonardo de Moura
ce674d2d43 feat(library/tactic): execute Lua tactics using coroutines
This is very important when several Lua tactics are implemented in the
same Lua State object.  In this case, even if we use the par
combinator, a Lua tactic will block the other Lua tactics running in
the same Lua State object.

With this commit, a Lua tactic can use yield to allow other tactics
in the same State object to execute.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 13:09:33 -08:00
Leonardo de Moura
1eeec07713 doc(lua): add options documentation
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 11:02:34 -08:00
Leonardo de Moura
6cb8300076 doc(lua): add S-expression documentation
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 10:33:32 -08:00
Leonardo de Moura
09bc7ddf91 feat(library/tactic): add support for migratic tactic framework object between Lua states
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-28 08:03:05 -08:00
Leonardo de Moura
3dc7a856f0 refactor(library/tactic): use unprotect/protect idiom for callbacks in the tactic API
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-27 18:11:46 -08:00
Leonardo de Moura
b4a8418d38 feat(library/tactic): expose tactics in the Lua API
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-27 17:47:29 -08:00
Leonardo de Moura
55f86f79a8 fix(util/optional): typo
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-27 16:57:29 -08:00
Leonardo de Moura
a2aa90ae66 refactor(util/script_state): replace std::recursive_mutex with std::mutex, and use unlock_guard
The unlock_guard and exec_unprotected will be useful also for implementing the Lua tactic API.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-27 15:40:41 -08:00
Leonardo de Moura
b038636ff5 refactor(util/script_state): remove unsafe unguarded_apply
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-27 15:14:26 -08:00
Leonardo de Moura
75b4a96d0e chore(tests/lua/threads): break lua thread tests into individual tests
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-27 15:06:07 -08:00
Leonardo de Moura
f7e8545e97 refactor(frontends/lua): rename leanlua_state to script_state, and move it to util
This commit also minimizes the dependencies of script_state.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-27 14:57:36 -08:00