Skip to content

Commit

Permalink
feat(data/finset): add card_insert_of_mem (leanprover-community#3137)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbuzzard authored and cipher1024 committed Mar 15, 2022
1 parent eadc44c commit 1111d7b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/data/finset.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,9 @@ by cases s; simp only [multiset.card_eq_one, finset.card, ← val_inj, singleton
by simpa only [card_cons, card, insert_val] using
congr_arg multiset.card (ndinsert_of_not_mem h)

theorem card_insert_of_mem [decidable_eq α] {a : α} {s : finset α}
(h : a ∈ s) : card (insert a s) = card s := by rw insert_eq_of_mem h

theorem card_insert_le [decidable_eq α] (a : α) (s : finset α) : card (insert a s) ≤ card s + 1 :=
by by_cases a ∈ s; [{rw [insert_eq_of_mem h], apply nat.le_add_right},
rw [card_insert_of_not_mem h]]
Expand Down

0 comments on commit 1111d7b

Please sign in to comment.