Zulip Chat Archive

Stream: mathlib4

Topic: convert ... using ... with ...


Michael Stoll (Nov 11 2023 at 16:27):

The following surprsies me:

import Mathlib.Tactic

open BigOperators

def Nat.primesBelow (n : ) : Finset  := (Finset.range n).filter (fun p  p.Prime)

example (f :   ) (n : ) :
     p in n.primesBelow, f p =  m in Finset.range n, Set.indicator {p :  | p.Prime} f m := by
  convert Set.sum_indicator_subset f Finset.mem_of_mem_filter using 2 -- `with m hm` does not work
  sorry

After convert, the tactic state is

f:   
n x: 
a: x  Finset.range n
 Set.indicator {p | Nat.Prime p} f x = Set.indicator ((Finset.filter (fun p  Nat.Prime p) (Finset.range n))) f x

Trying to name the hidden variables by appending with m hm does not work: there is no error message, but the tactic state is the same as before. This looks like a bug to me.
(Of course, I can (and do) rename them via rename_i, but it should be possible to give them names through the call to convert.)

Kyle Miller (Nov 11 2023 at 17:52):

Yes, there's some sort of bug in with that I've noticed and haven't tracked down yet. Here's a workaround:

convert Set.sum_indicator_subset f Finset.mem_of_mem_filter using 2 with _ _ m hm

Michael Stoll (Nov 11 2023 at 19:17):

The problem with this is that it will break once the bug is fixed...

Kyle Miller (Nov 11 2023 at 19:23):

I'm sorry for the bug (I wrote this feature), but there are at least a couple workarounds and you can decide which you want to use.

At least if you use _'s you can delete them once the bug is fixed. The bug seems to be that the with clause variables get unnecessarily consumed.

Scott Morrison (Nov 11 2023 at 21:29):

The advantage of something breaking once a bug is fixed is that we are not stuck with the workaround forever!


Last updated: Dec 20 2023 at 11:08 UTC