Open JasonGross opened 5 years ago
Hmm... There are a couple things going on here. I'm also replying to #2005
def fact : ℕ → ℕ
| 0 := 1
| (n+1) := (n+1) * fact n
example : fact 5 = 5 := begin rw [fact], simp [fact], end
What's happening here is that when you define a definition using the equation compiler, Lean will automatically generate the corresponding rewrite rules for each case, and use those when you call `rw`/`simp`.
If you don't use the equation compiler, you are encouraged to write those lemmas yourself for your definition of `fact`, and not rely on unfolding your definition.
* If this solution is not satisfactory to you, it is a bit hard to guess what you actually want. If you want to reduce this actual definition, without generating extra lemmas something like this works, but it is discouraged:
```lean
def fact (n : ℕ) : ℕ :=
nat.rec
1
(λ n' fact_n', (nat.succ n') * fact_n')
n
example : fact 5 = 5 :=
begin
dsimp only [nat.has_one, bit0, bit1, nat.has_add, nat.add, nat.has_zero, fact],
end
set_option pp.numerals false
.Also, I'd like to add that development on Lean 3 have moved to https://github.com/leanprover-community/lean. This is where we put bug fixes and new features.
Prerequisites
Description
If I remove
[nat.rec]
, then instead I get the error:How am I supposed to simplify recursion?
Expected behavior:
simp
reduces things likenat.rec
,int.rec
,list.rec
, etcActual behavior:
simp
does not reduce these thingsReproduces how often: [What percentage of the time does it reproduce?] 100%
Versions