feat(library/tactic): add trace_state_tactic

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-11-24 16:44:02 -08:00
parent 6f05276acd
commit 48d7afb0e8
3 changed files with 16 additions and 1 deletions

View file

@ -74,6 +74,16 @@ tactic trace_tactic(char const * msg) {
return trace_tactic(std::string(msg)); return trace_tactic(std::string(msg));
} }
tactic trace_state_tactic() {
return mk_tactic1([=](environment const &, io_state const & io, proof_state const & s) -> proof_state {
options opts = io.get_options();
format fmt = s.pp(io.get_formatter(), opts);
io.get_diagnostic_channel() << mk_pair(fmt, opts) << "\n";
io.get_diagnostic_channel().get_stream().flush();
return s;
});
}
tactic suppress_trace(tactic const & t) { tactic suppress_trace(tactic const & t) {
return mk_tactic([=](environment const & env, io_state const & io, proof_state const & s) -> proof_state_seq { return mk_tactic([=](environment const & env, io_state const & io, proof_state const & s) -> proof_state_seq {
io_state new_io(io); io_state new_io(io);

View file

@ -148,6 +148,10 @@ tactic trace_tactic(char const * msg);
class sstream; class sstream;
tactic trace_tactic(sstream const & msg); tactic trace_tactic(sstream const & msg);
tactic trace_tactic(std::string const & msg); tactic trace_tactic(std::string const & msg);
/**
\brief Return a tactic that just displays the input state in the diagnostic channel.
*/
tactic trace_state_tactic();
/** /**
\brief Create a tactic that applies \c t, but suppressing diagnostic messages. \brief Create a tactic that applies \c t, but suppressing diagnostic messages.
*/ */

View file

@ -128,10 +128,11 @@ static void tst2() {
ctx = extend(ctx, "H2", q); ctx = extend(ctx, "H2", q);
std::cout << "proof: " << (repeat(conj_tactic()) << assumption_tactic()).solve(env, io, ctx, And(And(p, q), And(p, p))) std::cout << "proof: " << (repeat(conj_tactic()) << assumption_tactic()).solve(env, io, ctx, And(And(p, q), And(p, p)))
<< "\n"; << "\n";
std::cout << "-------------\n";
// Theorem to be proved // Theorem to be proved
expr F = Implies(p, Implies(q, And(And(p, q), And(p, p)))); expr F = Implies(p, Implies(q, And(And(p, q), And(p, p))));
// Tactic // Tactic
tactic T = repeat(conj_tactic() || imp_tactic()) << assumption_tactic(); tactic T = repeat(conj_tactic() || imp_tactic()) << trace_state_tactic() << assumption_tactic();
// Generate proof using tactic // Generate proof using tactic
expr pr = T.solve(env, io, context(), F); expr pr = T.solve(env, io, context(), F);
// Print proof // Print proof