diff --git a/src/frontends/lean/builtin_cmds.cpp b/src/frontends/lean/builtin_cmds.cpp index 7fe1897c3..0133d66c0 100644 --- a/src/frontends/lean/builtin_cmds.cpp +++ b/src/frontends/lean/builtin_cmds.cpp @@ -5,6 +5,7 @@ Released under Apache 2.0 license as described in the file LICENSE. Author: Leonardo de Moura */ #include +#include #include "util/sstream.h" #include "util/sexpr/option_declarations.h" #include "kernel/type_checker.h" @@ -181,6 +182,27 @@ environment end_scoped_cmd(parser & p) { /** \brief Auxiliary function for check/eval */ static std::tuple parse_local_expr(parser & p) { expr e = p.parse_expr(); + environment const & env = p.env(); + if (is_constant(e) && !const_levels(e)) { + // manually elaborate simple constant using nicer names for meta-variables + if (auto decl = env.find(const_name(e))) { + levels ls = param_names_to_levels(decl->get_univ_params()); + e = mk_constant(const_name(e), ls); + expr type = instantiate_type_univ_params(*decl, ls); + while (true) { + if (!is_pi(type)) + break; + if (is_explicit(binding_info(type))) + break; + std::string q("?"); + q += binding_name(type).to_string(); + expr m = mk_local(name(q.c_str()), binding_domain(type)); + type = instantiate(binding_body(type), m); + e = mk_app(e, m); + } + return std::make_tuple(e, decl->get_univ_params()); + } + } list ctx = p.locals_to_context(); level_param_names new_ls; std::tie(e, new_ls) = p.elaborate_relaxed(e, ctx); diff --git a/tests/lean/check.lean b/tests/lean/check.lean new file mode 100644 index 000000000..3a4e6f7c9 --- /dev/null +++ b/tests/lean/check.lean @@ -0,0 +1,6 @@ +import logic + +check and.intro +check or.elim +check eq +check eq.rec diff --git a/tests/lean/check.lean.expected.out b/tests/lean/check.lean.expected.out new file mode 100644 index 000000000..34ad91a3f --- /dev/null +++ b/tests/lean/check.lean.expected.out @@ -0,0 +1,4 @@ +and.intro : ?a → ?b → ?a ∧ ?b +or.elim : ?a ∨ ?b → (?a → ?c) → (?b → ?c) → ?c +eq : ?A → ?A → Prop +eq.rec : ?C ?a → (Π {a : ?A}, ?a = a → ?C a) diff --git a/tests/lean/interactive/in2.input.expected.out b/tests/lean/interactive/in2.input.expected.out index 9d4e747c9..1028d6545 100644 --- a/tests/lean/interactive/in2.input.expected.out +++ b/tests/lean/interactive/in2.input.expected.out @@ -9,5 +9,5 @@ Type.{1} : Type.{2} -- BEGINWAIT -- ENDWAIT -- BEGINEVAL -tst.foo.{l_1 l_2} : ?M_1 → ?M_2 → ?M_1 +tst.foo.{l_1 l_2} : ?A → ?B → ?A -- ENDEVAL