Skip to content

Commit 643693b

Browse files
committed
chore(Data/Set/Card): small golf (leanprover-community#34691)
1 parent 4a1339f commit 643693b

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

Mathlib/Data/Set/Card.lean

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,8 @@ theorem encard_prod {s : Set α} {t : Set β} : (s ×ˢ t).encard = s.encard * t
181181
@[simp]
182182
theorem encard_pi_eq_prod_encard [h : Fintype α] {ι : α → Type*} {s : ∀ i : α, Set (ι i)} :
183183
(Set.pi Set.univ s).encard = ∏ i, (s i).encard := by
184-
simp only [encard, ENat.card]
185-
rw [Cardinal.mk_congr (Equiv.Set.univPi s)]
186-
simp [Cardinal.prod_eq_of_fintype]
184+
unfold encard ENat.card
185+
simp [Cardinal.mk_congr (Equiv.Set.univPi s), Cardinal.prod_eq_of_fintype]
187186

188187
section Lattice
189188

@@ -197,21 +196,19 @@ theorem encard_mono {α : Type*} : Monotone (encard : Set α → ℕ∞) :=
197196
fun _ _ ↦ encard_le_encard
198197

199198
theorem encard_diff_add_encard_of_subset (h : s ⊆ t) : (t \ s).encard + s.encard = t.encard := by
200-
rw [← encard_union_eq disjoint_sdiff_left, diff_union_self, union_eq_self_of_subset_right h]
199+
rw [← encard_union_eq disjoint_sdiff_left, diff_union_of_subset h]
201200

202201
theorem encard_diff (h : s ⊆ t) (hs : s.Finite) :
203202
(t \ s).encard = t.encard - s.encard := by
204203
rw [← @Set.encard_diff_add_encard_of_subset _ s t h]
205-
exact AddLECancellable.eq_tsub_of_add_eq
206-
(ENat.addLECancellable_of_ne_top (encard_ne_top_iff.mpr hs)) rfl
204+
exact (ENat.addLECancellable_of_ne_top <| encard_ne_top_iff.mpr hs).eq_tsub_of_add_eq rfl
207205

208206
@[simp] theorem one_le_encard_iff_nonempty : 1 ≤ s.encard ↔ s.Nonempty := by
209207
rw [nonempty_iff_ne_empty, Ne, ← encard_eq_zero, ENat.one_le_iff_ne_zero]
210208

211209
theorem encard_diff_add_encard_inter (s t : Set α) :
212210
(s \ t).encard + (s ∩ t).encard = s.encard := by
213-
rw [← encard_union_eq (disjoint_of_subset_right inter_subset_right disjoint_sdiff_left),
214-
diff_union_inter]
211+
rw [← encard_union_eq disjoint_sdiff_inter, diff_union_inter]
215212

216213
theorem encard_union_add_encard_inter (s t : Set α) :
217214
(s ∪ t).encard + (s ∩ t).encard = s.encard + t.encard := by

0 commit comments

Comments
 (0)