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
The behavior seems to depend on whether other lemmas are present or not in the simp set.
Steps to Reproduce
The following code shows the problem.
defSet := Nat → Propnamespace Set
defsingleton (a : Nat) : Set := fun b ↦ b = a
defcompl (s : Set) : Set := fun x ↦ ¬ s x
@[simp]theoremcompl_iff (s : Set) (x : Nat) : s.compl x ↔ ¬ s x := Iff.rfl
@[simp]theoremsingleton_iff {a b : Nat} : singleton b a ↔ a = b := Iff.rfl
open Classical
noncomputabledefindicator (s : Set) (x : Nat) : Nat := if s x then1else0@[simp]-- remove `simp` attribute --> works (and the trace changes)theoremindicator_of {s : Set} {a : Nat} (h : s a) : indicator s a = 1 := if_pos h
@[simp]theoremindicator_of_not {s : Set} {a : Nat} (h : ¬ s a) : indicator s a = 0 := if_neg h
set_option trace.Meta.Tactic.simp.rewrite true
theoremtest : indicator (compl <| singleton 0) 0 = 0 := by
simp? -- leaves out `singleton_iff` even though it is necessary
Removing the simp attribute from indicator_of makes the problem go away.
With set_option trace.Meta.Tactic.simp.discharge true (in addition to ...rewrite true), the trace in the "bad" case is
Note: in the "bad" case, singleton_iff is used in the first attempt via indicator_of that ultimately fails, and is not listed again in the second (succeeding) attempt. However, it is necessary to use it there (as the "good" trace shows).
Speculation: simp caches the result obtained from singleton_iff in the first attempt and reuses that in the second one, but does not take note of it for inclusion in the lemma list.
Disclaimer: I have no actual idea how simp works internally.
Expected behavior: simp? should suggest a simp only [...] call whose list of lemmas (and simprocs) contains all lemmas etc. that simp used.
Actual behavior:
In the specific case, one necessary lemma is missing from the suggested list.
Versions
"4.7.0-rc2" on Linux
Impact
This behavior (when it occurs) is annoying, since it necessitates a manual correction, and it is not always immediately obvious which lemma(s) is/are missing.
When `discharge?` failed, the `usedSimps` was being restored, but the
cache wasn't. This bug was exposed by issue #3710.
This PR makes the following changes:
- We restore the `cache` at `discharge?`. We use `SMap` to ensure the
operation is efficient.
- We don't need the field `dischargeDepth` anymore at `Simp.Result`.
- `UsedSimps` should use `PHashMap` since it is not used linearly.
closes#3710
When `discharge?` failed, the `usedSimps` was being restored, but the
cache wasn't. This bug was exposed by issue #3710.
This PR makes the following changes:
- We restore the `cache` at `discharge?`. We use `SMap` to ensure the
operation is efficient.
- We don't need the field `dischargeDepth` anymore at `Simp.Result`.
- `UsedSimps` should use `PHashMap` since it is not used linearly.
closes#3710
---------
Co-authored-by: Mario Carneiro <[email protected]>
Prerequisites
Description
In some (probably rather specific) cases, the
Try this:
suggestion provided bysimp?
misses a relevantsimp
-lemma.Context
See this Zulip thread.
The behavior seems to depend on whether other lemmas are present or not in the
simp
set.Steps to Reproduce
The following code shows the problem.
Removing the
simp
attribute fromindicator_of
makes the problem go away.With
set_option trace.Meta.Tactic.simp.discharge true
(in addition to...rewrite true
), the trace in the "bad" case iswhereas in the "good" case, it is
Note: in the "bad" case, singleton_iff is used in the first attempt via indicator_of that ultimately fails, and is not listed again in the second (succeeding) attempt. However, it is necessary to use it there (as the "good" trace shows).
Speculation: simp caches the result obtained from singleton_iff in the first attempt and reuses that in the second one, but does not take note of it for inclusion in the lemma list.
Disclaimer: I have no actual idea how
simp
works internally.Expected behavior:
simp?
should suggest asimp only [...]
call whose list of lemmas (and simprocs) contains all lemmas etc. thatsimp
used.Actual behavior:
In the specific case, one necessary lemma is missing from the suggested list.
Versions
"4.7.0-rc2" on Linux
Impact
This behavior (when it occurs) is annoying, since it necessitates a manual correction, and it is not always immediately obvious which lemma(s) is/are missing.
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
The text was updated successfully, but these errors were encountered: