Zulip Chat Archive

Stream: Is there code for X?

Topic: Cardinality of set of sets of integers with properties.


Michail Karatarakis (Dec 11 2023 at 00:14):

Hi, do we have this?

There are (A+1)n(A+1)^n possible sets of integers (x1,,xn)(x_1, \ldots, x_n) with 0xkA0 \leq x_k \leq A for 1kn.1 \leq k \leq n.

example :
  let X : Set (Fin n  ) := {x |  (k : Fin n), 0  x k  x k  A}
  (Nat.card X) = (A + 1) ^ n := by sorry

Yury G. Kudryashov (Dec 11 2023 at 00:16):

You can build an equivalence with Fin n → Fin (A + 1).

Yaël Dillies (Dec 11 2023 at 06:53):

Just write your set as (Finset.univ : Finset (Fin n)).pi fun _ ↦ Icc (0 : ℤ) A and use docs#Finset.card_pi

Michail Karatarakis (Dec 11 2023 at 11:00):

I see, thanks. So, in general, I am dealing with finite sets with an increasingly number of conditions and I am not very familiar with the Finset API to generalize the stuff I am doing.

example {A B C : } : (Nat.card Y)  (N*A*H + 1)^M := by
let Y := {y : Fin M   |  j : Fin M, -B * H  y  y  C * H  B + C  N * A};
  sorry

Furthermore, assuming I write the set below differently, how do I pull the elements out to prove trivial stuff like ? :

example {A : } :
  let X :=(Finset.univ : Finset (Fin n)).pi fun _  Icc (0 : ) A;
     (Nat.card X) = (A + 1) ^ N 
             (finX : Finite X),
                let hX := Fintype.ofFinite X;
                     x  Set.toFinset X,
                         (k : Fin N), |x k|  A := by sorry

Yaël Dillies (Dec 11 2023 at 11:57):

Your set Y is ((Finset.univ : Finset (Fin M)).pi fun _ ↦ Icc (-B * H) (C * H)).filter fun _ ↦ B * C ≤ N * A (although it seems you have a typo somewhere since the filtering is trivial). For your second question, probably simp or aesop can do it.

Peter Nelson (Dec 11 2023 at 12:46):

I think this kind of thing indicates how difficult the Finset API is to work with for the uninitiated. Terms like attach and filter aren’t particularly intuitive.

Yaël Dillies (Dec 11 2023 at 12:50):

I agree. We need better notation.

Yaël Dillies (Dec 11 2023 at 12:51):

Better notation for s.filter p and univ.filter p would already go a long way.


Last updated: Dec 20 2023 at 11:08 UTC