Zulip Chat Archive

Stream: general

Topic: Showing s.card is bounded


Daniel Garcia (May 14 2024 at 19:28):

Hey all, I am wondering how to proceed in the following proof to show that the cardinality of a finite set is bounded. Thanks in advance for the help!

import Mathlib.Tactic
open Finset
example (s : Finset ) (h :  x  s, x < 100) : s.card < 101 := by sorry

Damiano Testa (May 14 2024 at 19:40):

example (s : Finset ) (h :  x  s, x < 100) : s.card < 101 := by
  apply Nat.lt_succ.mpr
  have : 100 = Finset.card (Finset.range 100) := rfl
  rw [this]
  apply Finset.card_mono
  exact fun x hx => mem_range.mpr (h x hx)

Daniel Garcia (May 14 2024 at 19:52):

Thank you so much! That worked! :)

Damiano Testa said:

example (s : Finset ) (h :  x  s, x < 100) : s.card < 101 := by
  apply Nat.lt_succ.mpr
  have : 100 = Finset.card (Finset.range 100) := rfl
  rw [this]
  apply Finset.card_mono
  exact fun x hx => mem_range.mpr (h x hx)

Kyle Miller (May 14 2024 at 22:05):

Here's another way to write it, but it's the same idea.

example (s : Finset ) (h :  x  s, x < 100) : s.card < 101 := by
  have : s  Finset.range 100 := by
    intro x hx
    simpa using h x hx
  rw [Nat.lt_succ]
  exact Finset.card_mono this

Damiano Testa (May 14 2024 at 22:11):

You can also go the opposite way and hide all possibility of understanding:

example (s : Finset ) (h :  x  s, x < 100) : s.card < 101 :=
  (card_mono fun _ _ => mem_range.mpr (h _ _›)).trans_lt <| Nat.lt_succ.mpr le_rfl

Last updated: May 02 2025 at 03:31 UTC