Zulip Chat Archive

Stream: new members

Topic: Failed to synthesize Union


Iocta (Jan 07 2025 at 03:45):

What is this and how to fix?

import Mathlib

variable {α : Type} (a b : Finset α)
#check a  b
failed to synthesize
  Union (Finset α)

#check insert b ({a} : Finset (Finset α))
failed to synthesize
  Insert (Finset α) (Finset (Finset α))

Matt Diamond (Jan 07 2025 at 03:54):

the instances require DecidableEq, so just use the classical tactic beforehand or add an assumption

Matt Diamond (Jan 07 2025 at 03:55):

or open Classical in, etc.

Iocta (Jan 07 2025 at 04:01):

What's the clue that should tip me off that I need classical?

Matt Diamond (Jan 07 2025 at 04:05):

not sure... honestly I just looked up docs#Union in the mathlib docs, opened the Instances list, saw docs#Finset.instUnion, clicked through, and saw the DecidableEq requirement

Matt Diamond (Jan 07 2025 at 04:07):

it would be cool if the instance search had some way of telling the user "I almost found an instance but it was missing this one typeclass requirement"

Matt Diamond (Jan 07 2025 at 04:12):

actually you can do this:

import Mathlib

variable {α : Type}

set_option diagnostics true

#synth Union (Finset α)

and there's some more info there


Last updated: May 02 2025 at 03:31 UTC