Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
simp
tactic uses a discrimination tree to select candidate theorems that will be used to rewrite an expression. This indexing data structure minimizes the number of theorems that need to be tried and improves performance. However, indexing modulo reducibility is challenging, and a theorem that could be applied, when taking reduction into account, may be missed. For example, suppose we have asimp
theoremfoo : forall x y, f x (x, y).2 = y
, and we are trying to simplify the expressionf a b <= b
.foo
will not be tried bysimp
because the second argument off a b
is not a projection of a pair. However,f a b
is definitionally equal tof a (a, b).2
since we can reduce(a, b).2
.In Lean 3, we had a much simpler indexing data structure where only the head symbol was taken into account. For the theorem
foo
, the head symbol isf
. Thus, the theorem would be considered bysimp
.This commit adds the option
Simp.Config.index
. Whensimp (config := { index := false })
, only the head symbol is considered when retrieving theorems, as in Lean 3. Moreover, ifset_option diagnostics true
,simp
will check whether every applied theorem would also have been applied ifindex := true
, and report them. This feature can help users diagnose tricky issues in code that has been ported from libraries developed using Lean 3 and then ported to Lean 4. In the following example, it will report thatfoo
is a problematic theorem.In the example above, the following diagnostic message is produced.
With the information above, users can annotate theorems such as
foo
usingno_index
for problematic subterms.Example:
cc @semorrison
cc @PatrickMassot