The doc at https://leanprover-community.github.io/extras/simp.html says about simp
:
all it does is repeatedly replace (or rewrite) subterms of the form A by B, for all applicable facts of the form A = B or A ↔ B. The simplifier mindlessly rewrites until it can rewrite no more.
This raises some questions as to how this works in practice:
- Does
simp
only perform a brute force search or is it smarter? - How does
simp
never end in a cyclic behavior? - Is there some limit in the number of steps it takes to try to obtain the target?
simp
go into an infinite loop. The first is with a simp lemma which expands like 0=0+0. It will reach a maximum recursion depth and fail. The other is with something likefoo = baz
andbaz = foo
. In these cases you get a "maximum number of steps exceeded" or maximum heartbeats error depending on the situation. $\endgroup$rw_search
tactic which attempts to prove two terms are equal with a series of rewrites, although it is for a slightly different use case thansimp
and there is no expectation of reaching a normal form, so backtracking search is required inrw_search
. $\endgroup$