Skip to content

Commit 07938b8

Browse files
committed
chore(Data/Set/Card): make s.ncard the simpNF of Fintype.card s
1 parent 54f98fd commit 07938b8

12 files changed

Lines changed: 23 additions & 28 deletions

File tree

Mathlib/Combinatorics/SimpleGraph/Connectivity/EdgeConnectivity.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ lemma IsEdgeReachable.le_degree [Fintype (G.neighborSet u)] (h : G.IsEdgeReachab
9696
(huv : u ≠ v) : k ≤ G.degree u := by
9797
classical
9898
by_contra! hh
99-
obtain ⟨w, _⟩ :=
100-
@h (G.incidenceSet u) (by simpa [← Set.coe_fintypeCard, ENat.coe_lt_coe]) |>.exists_isPath
99+
rw [← card_incidenceSet_eq_degree, ← ENat.coe_lt_coe, Set.coe_fintypeCard] at hh
100+
obtain ⟨w, _⟩ := h hh |>.exists_isPath
101101
simpa using w.adj_snd <| by grind [Walk.nil_iff_length_eq, Walk.eq_of_length_eq_zero]
102102

103103
lemma IsEdgeConnected.le_degree [Fintype (G.neighborSet u)] [Nontrivial V]

Mathlib/Combinatorics/SimpleGraph/Copy.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ alias ⟨IsContained.exists_iso_subgraph, IsContained.of_exists_iso_subgraph⟩
313313

314314
theorem Copy.degree_le (f : Copy G H) (v : V) [Fintype <| G.neighborSet v]
315315
[Fintype <| H.neighborSet (f v)] : G.degree v ≤ H.degree (f v) := by
316-
simpa using Fintype.card_le_of_injective _ (f.mapNeighborSet v).injective
316+
simpa [card_neighborSet_eq_degree] using
317+
Fintype.card_le_of_injective _ (f.mapNeighborSet v).injective
317318

318319
theorem Copy.max_degree_le [Fintype V] [Fintype W] [DecidableRel G.Adj] [DecidableRel H.Adj]
319320
(f : Copy G H) : G.maxDegree ≤ H.maxDegree := by

Mathlib/Combinatorics/SimpleGraph/Finite.lean

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,11 @@ lemma edgeFinset_nonempty : G.edgeFinset.Nonempty ↔ G ≠ ⊥ := by
121121
theorem edgeFinset_card : #G.edgeFinset = Fintype.card G.edgeSet :=
122122
Set.toFinset_card _
123123

124-
@[simp]
125124
theorem card_edgeSet : Fintype.card G.edgeSet = #G.edgeFinset :=
126125
.symm <| Set.toFinset_card _
127126

128127
theorem edgeSet_univ_card : #(univ : Finset G.edgeSet) = #G.edgeFinset := by
129-
simp
128+
simp [card_edgeSet]
130129

131130
variable [Fintype V]
132131

@@ -203,7 +202,6 @@ def degree : ℕ := #(G.neighborFinset v)
203202
@[simp]
204203
theorem card_neighborFinset_eq_degree : #(G.neighborFinset v) = G.degree v := rfl
205204

206-
@[simp]
207205
theorem card_neighborSet_eq_degree : Fintype.card (G.neighborSet v) = G.degree v :=
208206
(Set.toFinset_card _).symm
209207

@@ -255,7 +253,8 @@ theorem degree_compl [Fintype (Gᶜ.neighborSet v)] [Fintype V] :
255253
Gᶜ.degree v = Fintype.card V - 1 - G.degree v := by
256254
classical
257255
rw [← card_neighborSet_union_compl_neighborSet G v, Set.toFinset_union]
258-
simp [card_union_of_disjoint (Set.disjoint_toFinset.mpr (compl_neighborSet_disjoint G v))]
256+
simp [card_union_of_disjoint (Set.disjoint_toFinset.mpr (compl_neighborSet_disjoint G v)),
257+
card_neighborSet_eq_degree]
259258

260259
instance incidenceSetFintype [DecidableEq V] : Fintype (G.incidenceSet v) :=
261260
Fintype.ofEquiv (G.neighborSet v) (G.incidenceSetEquivNeighborSet v).symm
@@ -264,11 +263,9 @@ instance incidenceSetFintype [DecidableEq V] : Fintype (G.incidenceSet v) :=
264263
def incidenceFinset [DecidableEq V] : Finset (Sym2 V) :=
265264
(G.incidenceSet v).toFinset
266265

267-
@[simp]
268266
theorem card_incidenceSet_eq_degree [DecidableEq V] :
269267
Fintype.card (G.incidenceSet v) = G.degree v := by
270-
rw [Fintype.card_congr (G.incidenceSetEquivNeighborSet v)]
271-
simp
268+
rw [Fintype.card_congr (G.incidenceSetEquivNeighborSet v), card_neighborSet_eq_degree]
272269

273270
@[simp, norm_cast]
274271
theorem coe_incidenceFinset [DecidableEq V] :

Mathlib/Combinatorics/SimpleGraph/IncMatrix.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ variable [NonAssocSemiring R] [DecidableEq α] [DecidableRel G.Adj] {a : α} {e
106106

107107
theorem sum_incMatrix_apply [Fintype (Sym2 α)] [Fintype (neighborSet G a)] :
108108
∑ e, G.incMatrix R a e = G.degree a := by
109-
simp [incMatrix_apply', sum_boole, Set.filter_mem_univ_eq_toFinset]
109+
simp [incMatrix_apply', sum_boole, Set.filter_mem_univ_eq_toFinset, card_incidenceSet_eq_degree]
110110

111111
theorem incMatrix_mul_transpose_diag [Fintype (Sym2 α)] [Fintype (neighborSet G a)] :
112112
(G.incMatrix R * (G.incMatrix R)ᵀ) a a = G.degree a := by

Mathlib/Combinatorics/SimpleGraph/Matching.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,8 @@ lemma odd_matches_node_outside [Finite V] {u : Set V}
311311
apply Nat.not_even_iff_odd.2 c.prop
312312
haveI : Fintype ↑(Subgraph.induce M (Subtype.val '' supp c.val)).verts := Fintype.ofFinite _
313313
classical
314-
haveI : Fintype (c.val.supp) := Fintype.ofFinite _
315-
simpa [Subgraph.induce_verts, Subgraph.verts_top, Nat.card_eq_fintype_card, Set.toFinset_card,
316-
Finset.card_image_of_injective, ← Nat.card_coe_set_eq] using hMmatch.even_card
314+
haveI := Fintype.ofFinite c.val.supp
315+
simpa [Finset.card_image_of_injective] using hMmatch.even_card
317316

318317
end Finite
319318
end ConnectedComponent

Mathlib/Combinatorics/SimpleGraph/Subgraph.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,6 @@ lemma adj_iff_of_neighborSet_equiv {v : V} {H : Subgraph G}
868868

869869
end Subgraph
870870

871-
@[simp]
872871
theorem card_neighborSet_toSubgraph (G H : SimpleGraph V) (h : H ≤ G)
873872
(v : V) [Fintype ↑((toSubgraph H h).neighborSet v)] [Fintype ↑(H.neighborSet v)] :
874873
Fintype.card ↑((toSubgraph H h).neighborSet v) = H.degree v := by
@@ -880,7 +879,7 @@ theorem card_neighborSet_toSubgraph (G H : SimpleGraph V) (h : H ≤ G)
880879
lemma degree_toSubgraph (G H : SimpleGraph V) (h : H ≤ G) {v : V}
881880
[Fintype ↑((toSubgraph H h).neighborSet v)] [Fintype ↑(H.neighborSet v)] :
882881
(toSubgraph H h).degree v = H.degree v := by
883-
simp [Subgraph.degree]
882+
simp [Subgraph.degree, card_neighborSet_toSubgraph]
884883

885884
section MkProperties
886885

Mathlib/Data/Fintype/Card.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ theorem Fintype.card_lex (α : Type*) [Fintype α] : Fintype.card (Lex α) = Fin
198198

199199
-- Note: The extra hypothesis `h` is there so that the rewrite lemma applies,
200200
-- no matter what instance of `Fintype (Set.univ : Set α)` is used.
201-
@[simp]
202201
theorem Fintype.card_setUniv [Fintype α] {h : Fintype (Set.univ : Set α)} :
203202
Fintype.card (Set.univ : Set α) = Fintype.card α := by
204203
apply Fintype.card_of_finset'

Mathlib/Data/Set/Card.lean

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ theorem toENat_cardinalMk_subtype (P : α → Prop) :
8686
(Cardinal.mk {x // P x}).toENat = {x | P x}.encard :=
8787
rfl
8888

89-
@[simp] theorem coe_fintypeCard (s : Set α) [Fintype s] : Fintype.card s = s.encard := by
89+
variable (s) in
90+
theorem coe_fintypeCard [Fintype s] : Fintype.card s = s.encard := by
9091
simp [encard_eq_coe_toFinset_card]
9192

9293
@[simp, norm_cast] theorem encard_coe_eq_coe_finsetCard (s : Finset α) :
@@ -590,6 +591,7 @@ theorem Finite.cast_ncard_eq (hs : s.Finite) : s.ncard = s.encard := by
590591
rwa [ncard, ENat.coe_toNat_eq_self, ne_eq, encard_eq_top_iff, Set.Infinite, not_not]
591592

592593
variable (s) in
594+
@[simp]
593595
theorem coe_ncard_eq_encard [Finite s] : s.ncard = s.encard :=
594596
s.toFinite.cast_ncard_eq
595597

@@ -607,6 +609,7 @@ theorem ncard_eq_toFinset_card' (s : Set α) [Fintype s] :
607609
simp [← _root_.Nat.card_coe_set_eq, Nat.card_eq_fintype_card]
608610

609611
variable (s) in
612+
@[simp]
610613
theorem fintypeCard_eq_ncard [Fintype s] : Fintype.card s = s.ncard := by
611614
rw [ncard_eq_toFinset_card', toFinset_card]
612615

Mathlib/Data/Set/Finite/Basic.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,6 @@ theorem card_fintypeInsertOfNotMem {a : α} (s : Set α) [Fintype s] (h : a ∉
759759
@Fintype.card _ (fintypeInsertOfNotMem s h) = Fintype.card s + 1 := by
760760
simp [Fintype.card_ofFinset]
761761

762-
@[simp]
763762
theorem card_insert {a : α} (s : Set α) [Fintype s] (h : a ∉ s)
764763
{d : Fintype (insert a s : Set α)} : @Fintype.card _ d = Fintype.card s + 1 := by
765764
rw [← card_fintypeInsertOfNotMem s h]; congr!

Mathlib/GroupTheory/ClassEquation.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ theorem Group.sum_card_conj_classes_eq_card [Finite G] :
4242
∑ᶠ x : ConjClasses G, x.carrier.ncard = Nat.card G := by
4343
classical
4444
cases nonempty_fintype G
45-
rw [Nat.card_eq_fintype_card, ← sum_conjClasses_card_eq_card, finsum_eq_sum_of_fintype]
46-
simp [Set.ncard_eq_toFinset_card']
45+
simp [← sum_conjClasses_card_eq_card, finsum_eq_sum_of_fintype]
4746

4847
/-- The **class equation** for finite groups. The cardinality of a group is equal to the size
4948
of its center plus the sum of the size of all its nontrivial conjugacy classes. -/

0 commit comments

Comments
 (0)