2013-08-17 01:34:11 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
2014-05-17 19:30:03 +00:00
|
|
|
#include <utility>
|
2013-09-13 03:04:10 +00:00
|
|
|
#include "util/sexpr/options.h"
|
2013-08-17 01:34:11 +00:00
|
|
|
|
|
|
|
namespace lean {
|
2014-07-10 17:32:00 +00:00
|
|
|
class expr;
|
|
|
|
class environment;
|
|
|
|
|
2014-06-27 18:11:12 +00:00
|
|
|
/** \brief Return true iff \c t contains a constant named \c n or a local constant with named (pp or not) \c n */
|
|
|
|
bool is_used_name(expr const & t, name const & n);
|
2014-05-17 19:30:03 +00:00
|
|
|
/**
|
|
|
|
\brief Return the body of the binding \c b, where variable #0 is replaced by a local constant with a "fresh" name.
|
|
|
|
The name is considered fresh if it is not used by a constant or local constant occuring in the body of \c b.
|
|
|
|
The fresh constant is also returned (second return value).
|
|
|
|
|
|
|
|
\remark If preserve_type is false, then the local constant will not use binding_domain.
|
|
|
|
*/
|
2014-08-19 23:28:58 +00:00
|
|
|
pair<expr, expr> binding_body_fresh(expr const & b, bool preserve_type = false);
|
2014-05-17 19:30:03 +00:00
|
|
|
|
|
|
|
/** \brief Return the body of the let-expression \c l, where variable #0 is replaced by a local constant with a "fresh" name. */
|
2014-08-19 23:28:58 +00:00
|
|
|
pair<expr, expr> let_body_fresh(expr const & l, bool preserve_type = false);
|
2014-05-17 19:30:03 +00:00
|
|
|
|
2013-08-17 18:29:43 +00:00
|
|
|
class formatter {
|
2014-07-27 16:41:25 +00:00
|
|
|
std::function<format(expr const &, options const &)> m_fn;
|
2014-07-10 17:32:00 +00:00
|
|
|
options m_options;
|
2013-12-08 23:39:26 +00:00
|
|
|
public:
|
2014-07-27 16:41:25 +00:00
|
|
|
formatter(options const & o, std::function<format(expr const &, options const &)> const & fn):m_fn(fn), m_options(o) {}
|
|
|
|
format operator()(expr const & e) const { return m_fn(e, m_options); }
|
2014-07-10 17:32:00 +00:00
|
|
|
options const & get_options() const { return m_options; }
|
2014-07-27 16:41:25 +00:00
|
|
|
formatter update_options(options const & o) const { return formatter(o, m_fn); }
|
2013-08-17 18:29:43 +00:00
|
|
|
};
|
2013-12-08 23:39:26 +00:00
|
|
|
|
2014-07-10 17:32:00 +00:00
|
|
|
typedef std::function<formatter(environment const &, options const &)> formatter_factory;
|
2014-02-18 00:10:11 +00:00
|
|
|
|
|
|
|
std::ostream & operator<<(std::ostream & out, expr const & e);
|
2014-07-10 17:32:00 +00:00
|
|
|
/** \brief Create a simple formatter object based on operator */
|
|
|
|
formatter_factory mk_simple_formatter_factory();
|
2014-02-19 06:55:00 +00:00
|
|
|
|
2014-07-10 17:32:00 +00:00
|
|
|
typedef std::function<format(formatter const &)> pp_fn;
|
2013-08-17 01:34:11 +00:00
|
|
|
}
|