diff --git a/src/library/tactic/inversion_tactic.cpp b/src/library/tactic/inversion_tactic.cpp index d42817c4b..24e0e5cef 100644 --- a/src/library/tactic/inversion_tactic.cpp +++ b/src/library/tactic/inversion_tactic.cpp @@ -35,7 +35,7 @@ optional apply_eq_rec_eq(type_checker & tc, io_state const & ios, list args; + get_app_args(e, args); + if (args.size() != 3) + return false; + pair d = tc.is_def_eq(args[1], args[2]); + return d.first && !d.second; +} + void mk_telescopic_eq(type_checker & tc, buffer const & t, buffer const & s, buffer & eqs) { lean_assert(t.size() == s.size()); lean_assert(std::all_of(s.begin(), s.end(), is_local)); diff --git a/src/library/util.h b/src/library/util.h index daf50a846..42fe272be 100644 --- a/src/library/util.h +++ b/src/library/util.h @@ -101,7 +101,10 @@ expr mk_eq(type_checker & tc, expr const & lhs, expr const & rhs); expr mk_refl(type_checker & tc, expr const & a); bool is_eq_rec(expr const & e); bool is_eq(expr const & e); +/** \brief Return true iff \c e is of the form (eq A a a) */ bool is_eq_a_a(expr const & e); +/** \brief Return true iff \c e is of the form (eq A a a') where \c a and \c a' are definitionally equal */ +bool is_eq_a_a(type_checker & tc, expr const & e); /** \brief Create a telescope equality for HoTT library. This procedure assumes eq supports dependent elimination. diff --git a/tests/lean/hott/inv_bug.hlean b/tests/lean/hott/inv_bug.hlean new file mode 100644 index 000000000..3e1ac2b6d --- /dev/null +++ b/tests/lean/hott/inv_bug.hlean @@ -0,0 +1,24 @@ +open nat +open eq.ops + +inductive even : nat → Type := +even_zero : even zero, +even_succ_of_odd : ∀ {a}, odd a → even (succ a) +with odd : nat → Type := +odd_succ_of_even : ∀ {a}, even a → odd (succ a) + +example : even 1 → empty := +begin + intro He1, + cases He1 with (a, Ho0), + cases Ho0 +end + +example : even 3 → empty := +begin + intro He3, + cases He3 with (a, Ho2), + cases Ho2 with (a, He1), + cases He1 with (a, Ho0), + cases Ho0 +end