Zulip Chat Archive

Stream: mathlib4

Topic: Using `conv` with binders on finsum


Eric Wieser (Mar 14 2024 at 11:50):

Is there a mechanism for hooking custom congruence lemmas into conv? How can I tell it to use docs#finsum_congr_Prop in the following?

import Mathlib

open scoped BigOperators

example : ∑ᶠ (i : ) (h : i < 3), i = 3 := by
  conv =>
    enter [1, 1, i]
    -- goal: | ∑ᶠ (_ : i < 3), i
    skip
    -- how do I get my goal to be `| i < 3` via `finsum_congr_Prop`?
  sorry

Eric Wieser (Mar 14 2024 at 11:52):

rw [finsum_congr_Prop _ fun x => rfl] is close, but it leaves me with a metavariable that I want conv to absorb

Kyle Miller (Mar 14 2024 at 11:54):

It's clunky, but you can do

example : ∑ᶠ (i : ) (h : i < 3), i = 3 := by
  conv =>
    enter [1, 1, i]
    apply finsum_congr_Prop
    tactic => intro; rfl
    skip
    -- | i < 3

or

example : ∑ᶠ (i : ) (h : i < 3), i = 3 := by
  conv =>
    enter [1, 1, i]
    apply finsum_congr_Prop _ (fun _ => rfl)
    -- | i < 3

Kyle Miller (Mar 14 2024 at 11:55):

(To a first approximation, congr just does apply with a congruence lemma.)

Kyle Miller (Mar 14 2024 at 11:56):

There's no mechanism for custom congruence lemmas yet though. I think only the congr! tactic (and tactics using congr!) is the only use of them outside of simp.

Eric Wieser (Mar 14 2024 at 12:02):

That second example doesn't work for me, there's a stray ⊢ ℕ → Prop that comes first

Kyle Miller (Mar 14 2024 at 12:10):

Weird, something changed in the last week of mathlib (or Lean? I don't know, I was on nightly-testing I think)

Kyle Miller (Mar 14 2024 at 12:12):

This does the right thing:

    apply finsum_congr_Prop
    tactic => intro; rfl

Kyle Miller (Mar 14 2024 at 12:14):

Anyway, I'd like to see conv have some tactics for applying a @[congr] lemma, maybe that could be congr itself, so enter would gain that power.


Last updated: May 02 2025 at 03:31 UTC