Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit ec36fc0

Browse files
committed
fix(data/set/finite): add decidable assumptions (#6264)
Yury's rule of thumb https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there.20code.20for.20X.3F/topic/classicalize/near/224871122 says that we should have decidable instances here, because the statements of the lemmas need them (rather than the proofs). I'm making this PR to see if anything breaks.
1 parent 680e8ed commit ec36fc0

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/data/set/finite.lean

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -586,33 +586,34 @@ lemma finite.card_to_finset {s : set α} [fintype s] (h : s.finite) :
586586
by { rw [← finset.card_attach, finset.attach_eq_univ, ← fintype.card], congr' 2, funext,
587587
rw set.finite.mem_to_finset }
588588

589-
section
590-
591-
local attribute [instance, priority 1] classical.prop_decidable
589+
section decidable_eq
592590

593-
lemma to_finset_compl {α : Type*} [fintype α] (s : set α) :
594-
sᶜ.to_finset = (s.to_finset)ᶜ :=
591+
lemma to_finset_compl {α : Type*} [fintype α] [decidable_eq α]
592+
(s : set α) [fintype (sᶜ : set α)] [fintype s] : sᶜ.to_finset = (s.to_finset)ᶜ :=
595593
by ext; simp
596594

597-
lemma to_finset_inter {α : Type*} [fintype α] (s t : set α) :
598-
(s ∩ t).to_finset = s.to_finset ∩ t.to_finset :=
595+
lemma to_finset_inter {α : Type*} [decidable_eq α] (s t : set α) [fintype (s ∩ t : set α)]
596+
[fintype s] [fintype t] : (s ∩ t).to_finset = s.to_finset ∩ t.to_finset :=
599597
by ext; simp
600598

601-
lemma to_finset_union {α : Type*} [fintype α] (s t : set α) :
602-
(s ∪ t).to_finset = s.to_finset ∪ t.to_finset :=
599+
lemma to_finset_union {α : Type*} [decidable_eq α] (s t : set α) [fintype (s ∪ t : set α)]
600+
[fintype s] [fintype t] : (s ∪ t).to_finset = s.to_finset ∪ t.to_finset :=
603601
by ext; simp
604602

605-
lemma to_finset_ne_eq_erase {α : Type*} [fintype α] (a : α) :
606-
{x : α | x ≠ a}.to_finset = finset.univ.erase a :=
603+
lemma to_finset_ne_eq_erase {α : Type*} [decidable_eq α] [fintype α] (a : α)
604+
[fintype {x : α | x ≠ a}] : {x : α | x ≠ a}.to_finset = finset.univ.erase a :=
607605
by ext; simp
608606

609-
lemma card_ne_eq [fintype α] (a : α) :
607+
lemma card_ne_eq [fintype α] (a : α) [fintype {x : α | x ≠ a}] :
610608
fintype.card {x : α | x ≠ a} = fintype.card α - 1 :=
611-
by rw [←to_finset_card, to_finset_ne_eq_erase, finset.card_erase_of_mem (finset.mem_univ _),
612-
finset.card_univ, nat.pred_eq_sub_one]
613-
609+
begin
610+
haveI := classical.dec_eq α,
611+
rw [←to_finset_card, to_finset_ne_eq_erase, finset.card_erase_of_mem (finset.mem_univ _),
612+
finset.card_univ, nat.pred_eq_sub_one],
614613
end
615614

615+
end decidable_eq
616+
616617
section
617618

618619
variables [semilattice_sup α] [nonempty α] {s : set α}

0 commit comments

Comments
 (0)