You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.
Hmm... There are a couple things going on here. I'm also replying to #2005
First of all, this is very un-idiomatic Lean. Much better would be to do
deffact : ℕ → ℕ
| 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:
deffact (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
Numerals in Lean can be pretty complex, internally. To see the actual expression a numeral is, use set_option pp.numerals false.
Prerequisites
or feature requests.
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
The text was updated successfully, but these errors were encountered: