2013-08-25 01:02:38 +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
|
|
|
|
*/
|
2013-09-13 10:35:29 +00:00
|
|
|
#include <limits>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
2013-09-13 03:04:10 +00:00
|
|
|
#include "util/flet.h"
|
2013-09-13 01:25:38 +00:00
|
|
|
#include "util/name_set.h"
|
2013-09-13 03:04:10 +00:00
|
|
|
#include "kernel/normalizer.h"
|
|
|
|
#include "kernel/context.h"
|
|
|
|
#include "kernel/builtin.h"
|
|
|
|
#include "kernel/free_vars.h"
|
|
|
|
#include "kernel/for_each.h"
|
|
|
|
#include "kernel/replace.h"
|
2013-09-13 01:25:38 +00:00
|
|
|
#include "kernel/instantiate.h"
|
|
|
|
#include "kernel/metavar.h"
|
2013-10-01 01:16:13 +00:00
|
|
|
#include "kernel/printer.h"
|
2013-09-13 01:25:38 +00:00
|
|
|
#include "library/placeholder.h"
|
|
|
|
#include "library/reduce.h"
|
2013-09-13 03:04:10 +00:00
|
|
|
#include "library/update_expr.h"
|
|
|
|
#include "library/expr_pair.h"
|
2013-09-13 03:09:35 +00:00
|
|
|
#include "frontends/lean/frontend.h"
|
|
|
|
#include "frontends/lean/elaborator.h"
|
|
|
|
#include "frontends/lean/elaborator_exception.h"
|
2013-08-25 01:02:38 +00:00
|
|
|
|
|
|
|
namespace lean {
|
2013-09-24 18:01:30 +00:00
|
|
|
static name g_choice_name = name::mk_internal_unique_name();
|
2013-09-01 17:24:10 +00:00
|
|
|
static expr g_choice = mk_constant(g_choice_name);
|
2013-08-31 23:46:41 +00:00
|
|
|
static format g_assignment_fmt = format(":=");
|
2013-09-06 01:57:29 +00:00
|
|
|
static format g_unification_u_fmt = format("\u2248");
|
|
|
|
static format g_unification_fmt = format("=?=");
|
2013-08-25 17:34:19 +00:00
|
|
|
|
2013-09-01 17:24:10 +00:00
|
|
|
expr mk_choice(unsigned num_fs, expr const * fs) {
|
|
|
|
lean_assert(num_fs >= 2);
|
|
|
|
return mk_eq(g_choice, mk_app(num_fs, fs));
|
2013-08-25 17:34:19 +00:00
|
|
|
}
|
|
|
|
|
2013-09-01 17:24:10 +00:00
|
|
|
bool is_choice(expr const & e) {
|
|
|
|
return is_eq(e) && eq_lhs(e) == g_choice;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned get_num_choices(expr const & e) {
|
|
|
|
lean_assert(is_choice(e));
|
|
|
|
return num_args(eq_rhs(e));
|
|
|
|
}
|
|
|
|
|
|
|
|
expr const & get_choice(expr const & e, unsigned i) {
|
|
|
|
lean_assert(is_choice(e));
|
|
|
|
return arg(eq_rhs(e), i);
|
2013-08-25 17:34:19 +00:00
|
|
|
}
|
2013-08-25 01:02:38 +00:00
|
|
|
|
2013-09-27 01:24:45 +00:00
|
|
|
elaborator::elaborator(frontend const & ) {}
|
2013-08-30 03:12:43 +00:00
|
|
|
elaborator::~elaborator() {}
|
2013-09-27 01:24:45 +00:00
|
|
|
expr elaborator::operator()(expr const & e) { return e; }
|
|
|
|
expr elaborator::operator()(expr const & e, expr const & /* expected_type */) { return e; }
|
|
|
|
expr const & elaborator::get_original(expr const & e) const { return e; }
|
|
|
|
void elaborator::set_interrupt(bool ) {}
|
|
|
|
void elaborator::clear() {}
|
2013-10-02 00:41:03 +00:00
|
|
|
environment const & elaborator::get_environment() const {
|
|
|
|
static thread_local environment g_env;
|
|
|
|
return g_env;
|
|
|
|
}
|
2013-09-27 01:24:45 +00:00
|
|
|
void elaborator::display(std::ostream & ) const {}
|
|
|
|
format elaborator::pp(formatter &, options const &) const { return format(); }
|
|
|
|
void elaborator::print(imp * ptr) { lean_assert(ptr); }
|
|
|
|
bool elaborator::has_constraints() const { return false; }
|
2013-08-25 01:02:38 +00:00
|
|
|
}
|