2014-09-10 22:20:45 +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
|
|
|
|
#include "kernel/expr.h"
|
|
|
|
#include "library/io_state.h"
|
2014-12-19 23:23:22 +00:00
|
|
|
#include "library/unifier.h"
|
2014-09-10 22:20:45 +00:00
|
|
|
|
|
|
|
namespace lean {
|
2014-12-20 03:43:31 +00:00
|
|
|
class local_context;
|
2014-12-20 05:57:55 +00:00
|
|
|
class type_checker;
|
2014-12-20 03:43:31 +00:00
|
|
|
|
2014-09-10 22:20:45 +00:00
|
|
|
/** \brief Create a metavariable, and attach choice constraint for generating
|
2014-12-20 03:43:31 +00:00
|
|
|
solutions using class-instances.
|
2014-09-10 22:20:45 +00:00
|
|
|
|
|
|
|
\param ctx Local context where placeholder is located
|
|
|
|
\param prefix Prefix for metavariables that will be created by this procedure
|
2014-10-30 19:45:41 +00:00
|
|
|
\param suffix If provided, then it is added to the main metavariable created by this procedure.
|
2014-09-10 22:20:45 +00:00
|
|
|
\param use_local_instances If instances in the local context should be used
|
|
|
|
in the class-instance resolution
|
|
|
|
\param is_strict True if constraint should fail if not solution is found,
|
|
|
|
False if empty solution should be returned if there is no solution
|
|
|
|
\param type Expected type for the placeholder (if known)
|
|
|
|
\param tag To be associated with new metavariables and expressions (for error localization).
|
|
|
|
*/
|
2014-12-20 03:43:31 +00:00
|
|
|
pair<expr, constraint> mk_class_instance_elaborator(
|
2014-09-25 17:11:41 +00:00
|
|
|
environment const & env, io_state const & ios, local_context const & ctx,
|
2015-05-08 21:36:38 +00:00
|
|
|
name const & prefix, optional<name> const & suffix, bool use_local_instances,
|
2014-11-09 19:24:19 +00:00
|
|
|
bool is_strict, optional<expr> const & type, tag g, unifier_config const & cfg,
|
|
|
|
pos_info_provider const * pip);
|
2014-10-30 21:20:34 +00:00
|
|
|
|
2014-12-20 04:09:09 +00:00
|
|
|
/** \brief Create/synthesize a term of the class instance \c type. */
|
|
|
|
optional<expr> mk_class_instance(environment const & env, io_state const & ios, local_context const & ctx,
|
2015-05-08 21:36:38 +00:00
|
|
|
name const & prefix, expr const & type, bool use_local_instances = true,
|
2014-12-20 04:09:09 +00:00
|
|
|
unifier_config const & cfg = unifier_config());
|
|
|
|
|
|
|
|
optional<expr> mk_class_instance(environment const & env, io_state const & ios, list<expr> const & ctx,
|
2015-05-08 21:36:38 +00:00
|
|
|
name const & prefix, expr const & type, bool use_local_instances = true,
|
2014-12-20 04:09:09 +00:00
|
|
|
unifier_config const & cfg = unifier_config());
|
|
|
|
|
2015-06-08 23:54:55 +00:00
|
|
|
/** \brief Try to synthesize an inhabitant for (is_hset type) using class instance resolution */
|
2014-12-20 05:57:55 +00:00
|
|
|
optional<expr> mk_hset_instance(type_checker & tc, io_state const & ios, list<expr> const & ctx, expr const & type);
|
|
|
|
|
2015-06-08 23:54:55 +00:00
|
|
|
/** \brief Try to synthesize an inhabitant for (subsingleton type in the standard library, and hprop in the HoTT library)
|
2015-06-06 04:13:05 +00:00
|
|
|
using class instance resolution */
|
|
|
|
optional<expr> mk_subsingleton_instance(type_checker & tc, io_state const & ios, list<expr> const & ctx, expr const & type);
|
|
|
|
|
2014-12-20 03:43:31 +00:00
|
|
|
void initialize_class_instance_elaborator();
|
|
|
|
void finalize_class_instance_elaborator();
|
2014-09-10 22:20:45 +00:00
|
|
|
}
|