2014-07-02 02:05:22 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#pragma once
|
2014-07-02 03:43:53 +00:00
|
|
|
#include "kernel/pos_info_provider.h"
|
2014-07-02 02:05:22 +00:00
|
|
|
#include "library/tactic/tactic.h"
|
|
|
|
|
|
|
|
namespace lean {
|
2014-07-03 15:33:29 +00:00
|
|
|
/**
|
|
|
|
\brief Return true iff the environment \c env contains the following declarations
|
|
|
|
in the namespace 'tactic'
|
2014-09-04 23:36:06 +00:00
|
|
|
tactic.builtin : tactic
|
2014-07-03 15:33:29 +00:00
|
|
|
and_then : tactic -> tactic -> tactic
|
|
|
|
or_else : tactic -> tactic -> tactic
|
|
|
|
repeat : tactic -> tactic
|
|
|
|
*/
|
|
|
|
bool has_tactic_decls(environment const & env);
|
|
|
|
|
|
|
|
/**
|
|
|
|
\brief Creates a tactic by 'executing' \c e. Definitions are unfolded, whnf procedure is invoked,
|
2014-09-04 23:36:06 +00:00
|
|
|
and definitions marked as 'tactic.builtin' are handled by the code registered using
|
2014-07-03 15:33:29 +00:00
|
|
|
\c register_expr_to_tactic.
|
|
|
|
*/
|
|
|
|
tactic expr_to_tactic(environment const & env, expr const & e, pos_info_provider const *p);
|
|
|
|
|
|
|
|
/**
|
|
|
|
\brief Create an expression `by t`, where \c t is an expression of type `tactic`.
|
|
|
|
This kind of expression only affects the elaborator, the kernel will reject
|
|
|
|
any declaration that contains it.
|
|
|
|
|
|
|
|
\post get_by_arg(mk_by(t)) == t
|
|
|
|
\post is_by(mk_by(t))
|
|
|
|
*/
|
|
|
|
expr mk_by(expr const & t);
|
|
|
|
/** \brief Return true iff \c t is an expression created using \c mk_by */
|
|
|
|
bool is_by(expr const & t);
|
|
|
|
/** \see mk_by */
|
|
|
|
expr const & get_by_arg(expr const & t);
|
|
|
|
|
|
|
|
expr const & get_tactic_type();
|
|
|
|
expr const & get_exact_tac_fn();
|
|
|
|
expr const & get_and_then_tac_fn();
|
|
|
|
expr const & get_or_else_tac_fn();
|
|
|
|
expr const & get_repeat_tac_fn();
|
2014-08-12 23:49:21 +00:00
|
|
|
expr const & get_determ_tac_fn();
|
2014-07-03 15:33:29 +00:00
|
|
|
|
|
|
|
/** \brief Exception used to report a problem when an expression is being converted into a tactic. */
|
2014-07-02 21:09:01 +00:00
|
|
|
class expr_to_tactic_exception : public tactic_exception {
|
2014-07-03 15:06:28 +00:00
|
|
|
public:
|
|
|
|
expr_to_tactic_exception(expr const & e, char const * msg):tactic_exception(e, msg) {}
|
|
|
|
expr_to_tactic_exception(expr const & e, sstream const & strm):tactic_exception(e, strm) {}
|
2014-07-02 17:35:43 +00:00
|
|
|
};
|
|
|
|
|
2014-07-02 17:52:45 +00:00
|
|
|
typedef std::function<tactic(type_checker & tc, expr const & e, pos_info_provider const *)> expr_to_tactic_fn;
|
2014-07-03 15:33:29 +00:00
|
|
|
|
|
|
|
/** \brief Register a new "procedural attachment" for expr_to_tactic. */
|
2014-09-22 22:26:41 +00:00
|
|
|
void register_tac(name const & n, expr_to_tactic_fn const & fn);
|
|
|
|
void register_simple_tac(name const & n, std::function<tactic()> const & f);
|
|
|
|
void register_bin_tac(name const & n, std::function<tactic(tactic const &, tactic const &)> const & f);
|
|
|
|
void register_unary_tac(name const & n, std::function<tactic(tactic const &)> const & f);
|
|
|
|
void register_unary_num_tac(name const & n, std::function<tactic(tactic const &, unsigned)> const & f);
|
2014-07-03 15:33:29 +00:00
|
|
|
|
2014-09-22 22:26:41 +00:00
|
|
|
void initialize_expr_to_tactic();
|
|
|
|
void finalize_expr_to_tactic();
|
2014-07-02 02:05:22 +00:00
|
|
|
}
|