Zulip Chat Archive
Stream: mathlib4
Topic: issues at !4#1991 Data.Finsupp.AList
Arien Malec (Feb 01 2023 at 19:42):
Could I ask someone to look at !4#1991?
There are a few remaining issues that all appear to be defeq issues:
lookupFinsupp
hassimp_rw
that do nothing despite type apparently matching-
In
lookupFinsupp_apply
andlookupFinsupp_support
I replacedby convert rfl
with asimp
that leaves the goal state
Option.getD (lookup a l) 0 = Option.getD (lookup a l) 0
but doesn't close -
singleton_lookupFinsupp
is timing out atisDefEq
Johan Commelin (Feb 01 2023 at 19:49):
@Arien Malec re 1: does it help if you pass more arguments to the lemmas in the simp_rw
?
re 2: does rfl
close the goal after simp
? If not, what does congr
do?
Arien Malec (Feb 01 2023 at 19:50):
rfl
does not close, butcongr
does....
Arien Malec (Feb 01 2023 at 19:51):
scratch that -- congr
closes in one place, but not the other...
Johan Commelin (Feb 01 2023 at 19:51):
but does it make progress?
Arien Malec (Feb 01 2023 at 19:54):
Sort of?
I get to
(fun x => decide ¬x.snd = 0) = fun x => decide ¬x.snd = 0
which rfl
doesn't close, and (fun a b => Classical.decEq α a b) = fun a b => inst✝¹ a b
inst✝¹
is DecidableEq α
Arien Malec (Feb 01 2023 at 19:58):
On the first simp_rw
issue, I moved mem_toFinset
to @mem_toFinset _ _
and got a close...
Arien Malec (Feb 01 2023 at 19:58):
which seems...odd
Johan Commelin (Feb 01 2023 at 20:00):
After congr
, try apply Subsingleton.elim
Johan Commelin (Feb 01 2023 at 20:01):
Unfortunately congr
doesn't do that on its own. In Lean 3 it did.
Arien Malec (Feb 01 2023 at 20:02):
huh, that closes one subgoal, but leaves (fun x => decide ¬x.snd = 0) = fun x => decide ¬x.snd = 0
unclosed
Johan Commelin (Feb 01 2023 at 20:03):
funext
and another congr
?
Arien Malec (Feb 01 2023 at 20:06):
Now just the timeout....
Johan Commelin (Feb 01 2023 at 20:07):
There should be a congr!
that does those funext
s and apply Subsingleton.elim
s for us.
Johan Commelin (Feb 01 2023 at 20:07):
Can you paste a bit of context for that timeout?
Arien Malec (Feb 01 2023 at 20:12):
@[simp]
theorem singleton_lookupFinsupp (a : α) (m : M) :
(singleton a m).lookupFinsupp = Finsupp.single a m := by classical simp [← AList.insert_empty]
Arien Malec (Feb 01 2023 at 20:13):
let me see if I can minimize the full context.
Arien Malec (Feb 01 2023 at 20:14):
Hmm, now I get a whnf
timeout rather than an isDefEq
timeout...
Johan Commelin (Feb 01 2023 at 20:14):
Can you push? I'll try to load the PR here.
Arien Malec (Feb 01 2023 at 20:15):
it's all up to date...
Johan Commelin (Feb 01 2023 at 20:17):
ok, I'll take a look
Arien Malec (Feb 01 2023 at 20:23):
Here's the full context:
import Mathlib.Data.Finsupp.Basic
import Mathlib.Data.List.AList
variable {α M : Type _} [Zero M]
noncomputable def AList.lookupFinsupp (l : AList fun x : α => M) : α →₀ M
where
support := by
haveI := Classical.decEq α <;> haveI := Classical.decEq M <;>
exact (l.1.filter fun x => Sigma.snd x ≠ 0).keys.toFinset
toFun a :=
haveI := Classical.decEq α
(l.lookup a).getD 0
mem_support_toFun a := by
classical
simp_rw [@List.mem_toFinset _ _, List.mem_keys, List.mem_filter, ← mem_lookup_iff]
cases lookup a l <;> simp
@[simp]
theorem singleton_lookupFinsupp (a : α) (m : M) :
(AList.singleton a m).lookupFinsupp = Finsupp.single a m := by classical simp [← AList.insert_empty]
Johan Commelin (Feb 01 2023 at 20:26):
@Arien Malec I pushed a fix. Here's what I did:
- replace the proof by
_
. This showed that the statement didn't give errors, so the problem was with the proof. - aha, so probably
simp
is looping, or so. - put the tactics on their own line
- what does
simp?
do? -- nothing - does
simp only [← AList.insert_empty]
make progress? -- Yes! - what does
simp?
do now? -- It closes the goal - clean up
Arien Malec (Feb 01 2023 at 20:31):
Nice heuristics!
Last updated: Dec 20 2023 at 11:08 UTC