feat(library/tactic/unfold_rec): take '[recursor]' annotations into account at unfold_rec
This commit is contained in:
parent
b0ac78c2cb
commit
7fa5c3e5da
3 changed files with 24 additions and 2 deletions
|
@ -11,6 +11,7 @@ Author: Leonardo de Moura
|
|||
#include "library/util.h"
|
||||
#include "library/replace_visitor.h"
|
||||
#include "library/constants.h"
|
||||
#include "library/user_recursors.h"
|
||||
#include "library/tactic/location.h"
|
||||
|
||||
extern void pp_detail(lean::environment const & env, lean::expr const & e);
|
||||
|
@ -60,9 +61,11 @@ class unfold_rec_fn : public replace_visitor_aux {
|
|||
throw exception("ill-formed expression");
|
||||
}
|
||||
|
||||
static bool is_rec_building_part(name const & n) {
|
||||
bool is_rec_building_part(name const & n) {
|
||||
if (n == get_prod_pr1_name() || n == get_prod_pr2_name())
|
||||
return true;
|
||||
if (is_user_defined_recursor(m_env, n))
|
||||
return true;
|
||||
if (n.is_atomic() || !n.is_string())
|
||||
return false;
|
||||
char const * str = n.get_string();
|
||||
|
@ -343,7 +346,7 @@ public:
|
|||
m_ngen(ngen),
|
||||
m_force_unfold(force_unfold),
|
||||
m_tc(mk_type_checker(m_env, m_ngen.mk_child(), [](name const &) { return false; })),
|
||||
m_norm_decl_tc(mk_type_checker(m_env, m_ngen.mk_child(), [](name const & n) { return !is_rec_building_part(n); })),
|
||||
m_norm_decl_tc(mk_type_checker(m_env, m_ngen.mk_child(), [&](name const & n) { return !is_rec_building_part(n); })),
|
||||
m_to_unfold(to_unfold),
|
||||
m_occs(occs),
|
||||
m_occ_idx(0)
|
||||
|
|
15
tests/lean/unfold_rec3.lean
Normal file
15
tests/lean/unfold_rec3.lean
Normal file
|
@ -0,0 +1,15 @@
|
|||
open nat
|
||||
|
||||
definition nrec [recursor] := @nat.rec
|
||||
|
||||
definition myadd x y :=
|
||||
nrec y (λ n r, succ r) x
|
||||
|
||||
theorem myadd_zero : ∀ n, myadd n 0 = n :=
|
||||
begin
|
||||
intro n, induction n with n ih,
|
||||
reflexivity,
|
||||
esimp [myadd],
|
||||
state,
|
||||
rewrite ih
|
||||
end
|
4
tests/lean/unfold_rec3.lean.expected.out
Normal file
4
tests/lean/unfold_rec3.lean.expected.out
Normal file
|
@ -0,0 +1,4 @@
|
|||
unfold_rec3.lean:13:2: proof state
|
||||
n : ℕ,
|
||||
ih : myadd n 0 = n
|
||||
⊢ succ (myadd n 0) = succ n
|
Loading…
Reference in a new issue