diff --git a/src/frontends/lean/elaborator.cpp b/src/frontends/lean/elaborator.cpp index 447b6ae31f..fdb2bd2d4c 100644 --- a/src/frontends/lean/elaborator.cpp +++ b/src/frontends/lean/elaborator.cpp @@ -1506,6 +1506,19 @@ void elaborator::display_tactic_exception(tactic_exception const & ex, proof_sta out << ps.pp(env(), ios()) << "\n"; } +void elaborator::display_unsolved_subgoals(expr const & mvar, proof_state const & ps, expr const & pos) { + unsigned ngoals = length(ps.get_goals()); + sstream s; + s << ngoals << " unsolved subgoal"; + if (ngoals > 1) s << "s"; + display_unsolved_proof_state(mvar, ps, s.str().c_str(), pos); +} + +void elaborator::display_unsolved_subgoals(expr const & mvar, proof_state const & ps) { + display_unsolved_subgoals(mvar, ps, mvar); +} + + /** \brief Try to instantiate meta-variable \c mvar (modulo its state ps) using the given tactic. If it succeeds, then update subst with the solution. Return true iff the metavariable \c mvar has been assigned. @@ -1530,7 +1543,7 @@ bool elaborator::try_using(substitution & subst, expr const & mvar, proof_state } else if (!empty(r->first.get_goals())) { // tactic contains unsolved subgoals if (show_failure) - display_unsolved_proof_state(mvar, r->first, "unsolved subgoals"); + display_unsolved_subgoals(mvar, r->first); return false; } else { subst = r->first.get_subst(); @@ -1612,7 +1625,7 @@ bool elaborator::try_using_begin_end(substitution & subst, expr const & mvar, pr } if (!empty(ps.get_goals())) { - display_unsolved_proof_state(mvar, ps, "unsolved subgoals", pre_tac); + display_unsolved_subgoals(mvar, ps, pre_tac); return false; } else { subst = ps.get_subst(); diff --git a/src/frontends/lean/elaborator.h b/src/frontends/lean/elaborator.h index 4c9653d07b..abb0ac2c5d 100644 --- a/src/frontends/lean/elaborator.h +++ b/src/frontends/lean/elaborator.h @@ -144,6 +144,8 @@ class elaborator : public coercion_info_manager { unify_result_seq solve(constraint_seq const & cs); void display_unsolved_proof_state(expr const & mvar, proof_state const & ps, char const * msg, expr const & pos); void display_unsolved_proof_state(expr const & mvar, proof_state const & ps, char const * msg); + void display_unsolved_subgoals(expr const & mvar, proof_state const & ps, expr const & pos); + void display_unsolved_subgoals(expr const & mvar, proof_state const & ps); void display_tactic_exception(tactic_exception const & ex, proof_state const & ps, expr const & pre_tac); optional get_pre_tactic_for(expr const & mvar); optional pre_tactic_to_tactic(expr const & pre_tac); diff --git a/tests/lean/487.hlean.expected.out b/tests/lean/487.hlean.expected.out index 7b81eb084b..bc54dc13fb 100644 --- a/tests/lean/487.hlean.expected.out +++ b/tests/lean/487.hlean.expected.out @@ -1,11 +1,11 @@ -487.hlean:18:56: error: unsolved subgoals +487.hlean:18:56: error: 1 unsolved subgoal A : Type, B : Type, f : A → B, g : B → A, ε : Π (b : B), f (g b) = b, b b' : B -⊢ (ε b) ⁻¹ ⬝ refl (f (g b)) ⬝ ε b = refl b +⊢ (ε b)⁻¹ ⬝ refl (f (g b)) ⬝ ε b = refl b 487.hlean:19:0: error: failed to add declaration 'foo' to environment, value has metavariables remark: set 'formatter.hide_full_terms' to false to see the complete term λ (A : Type) (B : Type) (f : …) (g : …) (ε : …) (b b' : B), diff --git a/tests/lean/goals1.lean.expected.out b/tests/lean/goals1.lean.expected.out index 1d1c656218..f7b6f75714 100644 --- a/tests/lean/goals1.lean.expected.out +++ b/tests/lean/goals1.lean.expected.out @@ -1,4 +1,4 @@ -goals1.lean:9:0: error: unsolved subgoals +goals1.lean:9:0: error: 1 unsolved subgoal A : Type, a b c : A, Hab : eq a b, diff --git a/tests/lean/inv_del.lean.expected.out b/tests/lean/inv_del.lean.expected.out index fe8d7736b5..7faaf4b95e 100644 --- a/tests/lean/inv_del.lean.expected.out +++ b/tests/lean/inv_del.lean.expected.out @@ -1,4 +1,4 @@ -inv_del.lean:15:2: error: unsolved subgoals +inv_del.lean:15:2: error: 1 unsolved subgoal A : Type, P : vec A 1 → Type, H : Π (a : A), P (vone a),