Zulip Chat Archive

Stream: general

Topic: congr with subsingleton


Reid Barton (Jun 15 2018 at 21:20):

Is this a bug in congr?

example {α : Type} [subsingleton α] (x y : α) : x = y := by congr -- fails
example {α : Type} [subsingleton α] (x y : α) (f : α  nat) : f x = f y := by congr -- ok

Kenny Lau (Jun 15 2018 at 21:21):

what is supposed to the state after the first by congr?

Reid Barton (Jun 15 2018 at 21:21):

"no goals"

Kenny Lau (Jun 15 2018 at 21:21):

oh

Reid Barton (Jun 15 2018 at 21:21):

Actually, I made the second example slightly poor.

Reid Barton (Jun 15 2018 at 21:21):

Edited now.

Mario Carneiro (Jun 15 2018 at 21:21):

Not in the sense that I'm not surprised by the result

Mario Carneiro (Jun 15 2018 at 21:22):

congr only gets its subsingleton optimization when it actually applies a function

Mario Carneiro (Jun 15 2018 at 21:22):

because it simplifies the congruence lemma for f

Mario Carneiro (Jun 15 2018 at 21:22):

so if congr_core applies 0 times the optimization never gets a chance

Reid Barton (Jun 15 2018 at 21:23):

I see

Reid Barton (Jun 15 2018 at 21:23):

I have a more complicated example where congr fails even when there is a function being applied, but I need to minimize it first.

Reid Barton (Jun 15 2018 at 21:24):

Is simp supposed to understand subsingletons then? What exactly does it do with them? It can't handle either of these goals

Mario Carneiro (Jun 15 2018 at 21:25):

simp uses congr to enter a term, so it gets subsingleton handling indirectly that way

Mario Carneiro (Jun 15 2018 at 21:25):

but it won't rewrite x to y if that's what you mean

Mario Carneiro (Jun 15 2018 at 21:26):

mostly it's helpful for carrying along dependent arguments

Reid Barton (Jun 15 2018 at 21:26):

Oh, so by "it [congr] simplifies the congruence lemma" you don't mean using simp?

Mario Carneiro (Jun 15 2018 at 21:26):

No, I mean that the congruence lemma that is generated lacks an equality subgoal for any subsingleton arguments

Reid Barton (Jun 15 2018 at 21:27):

is this stuff in C++, in mk_specialized_congr_lemma?

Mario Carneiro (Jun 15 2018 at 21:27):

yes

Mario Carneiro (Jun 15 2018 at 21:27):

but you can see the resulting lemma by using the mk_congr_lemma function

Reid Barton (Jun 15 2018 at 21:43):

OK, the reason congr didn't work in my actual code is because I only have a subsingleton instance for a particular value of one of the type arguments, and the generated congruence lemma was too general and didn't specify the value of that type.

Reid Barton (Jun 15 2018 at 21:48):

(Namely, I have a subsingleton instance for a ⟶ b only when a is the initial object of a category)


Last updated: Dec 20 2023 at 11:08 UTC