feat(library/tactic/class_instance_synth): add mk_hset_instance procedure
This commit is contained in:
parent
8c63045492
commit
d9d822baa7
2 changed files with 13 additions and 0 deletions
|
@ -22,6 +22,7 @@ Author: Leonardo de Moura
|
|||
#include "library/generic_exception.h"
|
||||
#include "library/util.h"
|
||||
#include "library/tactic/util.h"
|
||||
#include "library/tactic/class_instance_synth.h"
|
||||
|
||||
#ifndef LEAN_DEFAULT_CLASS_UNIQUE_CLASS_INSTANCES
|
||||
#define LEAN_DEFAULT_CLASS_UNIQUE_CLASS_INSTANCES false
|
||||
|
@ -455,4 +456,12 @@ optional<expr> mk_class_instance(environment const & env, io_state const & ios,
|
|||
local_context lctx(ctx);
|
||||
return mk_class_instance(env, ios, lctx, prefix, type, relax_opaque, use_local_instances, cfg);
|
||||
}
|
||||
|
||||
optional<expr> mk_hset_instance(type_checker & tc, io_state const & ios, list<expr> const & ctx, expr const & type) {
|
||||
name is_trunc{"truncation", "is_trunc"};
|
||||
expr trunc_index = mk_app(mk_constant(name{"truncation", "nat_to_trunc_index"}), mk_constant(name{"nat", "zero"}));
|
||||
level lvl = sort_level(tc.ensure_type(type).first);
|
||||
expr is_hset = mk_app(mk_constant(name{"truncation", "is_trunc"}, {lvl}), trunc_index, type);
|
||||
return mk_class_instance(tc.env(), ios, ctx, tc.mk_fresh_name(), is_hset);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ Author: Leonardo de Moura
|
|||
|
||||
namespace lean {
|
||||
class local_context;
|
||||
class type_checker;
|
||||
|
||||
/** \brief Create a metavariable, and attach choice constraint for generating
|
||||
solutions using class-instances.
|
||||
|
@ -42,6 +43,9 @@ optional<expr> mk_class_instance(environment const & env, io_state const & ios,
|
|||
name const & prefix, expr const & type, bool relax_opaque = true, bool use_local_instances = true,
|
||||
unifier_config const & cfg = unifier_config());
|
||||
|
||||
/** \breif Try to synthesize an inhabitant for (is_hset type) using class instance resolution */
|
||||
optional<expr> mk_hset_instance(type_checker & tc, io_state const & ios, list<expr> const & ctx, expr const & type);
|
||||
|
||||
void initialize_class_instance_elaborator();
|
||||
void finalize_class_instance_elaborator();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue