2014-05-20 16:40:30 +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-10-27 21:49:11 +00:00
|
|
|
#include <functional>
|
|
|
|
#include "kernel/type_checker.h"
|
2014-05-20 16:40:30 +00:00
|
|
|
|
|
|
|
namespace lean {
|
2014-10-27 21:49:11 +00:00
|
|
|
/** \brief Return the \c e normal form with respect to the environment \c env.
|
|
|
|
Any unification constraint generated in the process is discarded.
|
|
|
|
|
|
|
|
\remark Unification constraints are only generated if \c e contains meta-variables.
|
|
|
|
*/
|
2015-03-12 07:31:10 +00:00
|
|
|
expr normalize(environment const & env, expr const & e, bool eta = false);
|
|
|
|
expr normalize(environment const & env, level_param_names const & ls, expr const & e, bool eta = false);
|
2014-10-27 21:49:11 +00:00
|
|
|
/** \brief Similar to <tt>expr normalize(environment const & env, expr const & e)</tt>, but
|
|
|
|
uses the converter associated with \c tc. */
|
2015-03-12 07:31:10 +00:00
|
|
|
expr normalize(type_checker & tc, expr const & e, bool eta = false);
|
2015-05-21 02:09:44 +00:00
|
|
|
expr normalize(type_checker & tc, level_param_names const & ls, expr const & e, bool eta = false, bool eval_nested_prop = true);
|
2014-10-27 21:49:11 +00:00
|
|
|
/** \brief Return the \c e normal form with respect to \c tc, and store generated constraints
|
|
|
|
into \c cs.
|
|
|
|
*/
|
2015-03-12 07:31:10 +00:00
|
|
|
expr normalize(type_checker & tc, expr const & e, constraint_seq & cs, bool eta = false);
|
2014-10-27 21:49:11 +00:00
|
|
|
/** \brief Return the \c e normal form with respect to \c tc, and store generated constraints
|
|
|
|
into \c cs.
|
|
|
|
|
|
|
|
\remark A sub-expression is evaluated only if \c pred returns true.
|
|
|
|
*/
|
2014-10-27 23:49:29 +00:00
|
|
|
expr normalize(type_checker & tc, expr const & e, std::function<bool(expr const&)> const & pred, // NOLINT
|
2015-03-12 07:31:10 +00:00
|
|
|
constraint_seq & cs, bool eta = false);
|
2015-02-06 20:12:52 +00:00
|
|
|
|
2015-04-05 09:47:37 +00:00
|
|
|
/** \brief unfold-c hint instructs the normalizer (and simplifier) that
|
2015-02-06 20:12:52 +00:00
|
|
|
a function application (f a_1 ... a_i ... a_n) should be unfolded
|
|
|
|
when argument a_i is a constructor.
|
|
|
|
|
|
|
|
The constant will be unfolded even if it the whnf procedure did not unfolded it.
|
|
|
|
|
|
|
|
Of course, kernel opaque constants are not unfolded.
|
|
|
|
*/
|
2015-04-05 09:47:37 +00:00
|
|
|
environment add_unfold_c_hint(environment const & env, name const & n, unsigned idx, bool persistent = true);
|
|
|
|
environment erase_unfold_c_hint(environment const & env, name const & n, bool persistent = true);
|
2015-02-06 20:12:52 +00:00
|
|
|
/** \brief Retrieve the hint added with the procedure add_unfold_c_hint. */
|
|
|
|
optional<unsigned> has_unfold_c_hint(environment const & env, name const & d);
|
|
|
|
|
2015-04-05 09:47:37 +00:00
|
|
|
/** \brief unfold-f hint instructs normalizer (and simplifier) that function application
|
|
|
|
(f a_1 ... a_n) should be unfolded when it is fully applied */
|
|
|
|
environment add_unfold_f_hint(environment const & env, name const & n, bool persistent = true);
|
|
|
|
environment erase_unfold_f_hint(environment const & env, name const & n, bool persistent = true);
|
|
|
|
/** \brief Retrieve the hint added with the procedure add_unfold_f_hint. */
|
|
|
|
optional<unsigned> has_unfold_f_hint(environment const & env, name const & d);
|
|
|
|
|
2015-05-04 21:23:04 +00:00
|
|
|
|
|
|
|
/** \brief unfold-m hint instructs normalizer (and simplifier) that function application
|
|
|
|
(f ...) should be unfolded when it is the major premise of a constructor like operator */
|
2015-05-07 18:56:42 +00:00
|
|
|
environment add_constructor_hint(environment const & env, name const & n, bool persistent = true);
|
|
|
|
environment erase_constructor_hint(environment const & env, name const & n, bool persistent = true);
|
|
|
|
/** \brief Retrieve the hint added with the procedure add_constructor_hint. */
|
|
|
|
optional<unsigned> has_constructor_hint(environment const & env, name const & d);
|
2015-05-04 21:23:04 +00:00
|
|
|
|
2015-05-29 22:08:49 +00:00
|
|
|
expr try_eta(expr const & e);
|
2015-06-07 03:30:14 +00:00
|
|
|
expr beta_reduce(expr t);
|
|
|
|
expr beta_eta_reduce(expr t);
|
2015-05-29 22:08:49 +00:00
|
|
|
|
2015-02-06 20:12:52 +00:00
|
|
|
void initialize_normalize();
|
|
|
|
void finalize_normalize();
|
2014-05-20 16:40:30 +00:00
|
|
|
}
|