File size: 2,705 Bytes
e320e82 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | import OAI.Combinatorics.ExpectationThreshold.SelectorCountingWordsTransport
import Mathlib.Data.Fintype.Powerset
import Mathlib.Data.Fintype.BigOperators
namespace OAI
/-!
# Counting row encodings
A row encoding chooses a subset of the available positions and labels those
positions with a word of a prescribed profile. The word count depends only on
the number of chosen positions, so the total count factors into a binomial
coefficient and the corresponding word count.
-/
namespace TalagrandThreshold
open scoped BigOperators
variable {α H : Type*} [Fintype α] [DecidableEq α] [Fintype H] [DecidableEq H]
/-- The number of subsets of `R` with exactly `t` elements. -/
theorem card_fixedSize_subsets (R : Finset α) (t : ℕ) :
Fintype.card {U : Finset α // U ⊆ R ∧ U.card = t} =
Nat.choose R.card t := by
calc
Fintype.card {U : Finset α // U ⊆ R ∧ U.card = t} =
(R.powersetCard t).card :=
Fintype.card_of_subtype (R.powersetCard t)
(fun _ => Finset.mem_powersetCard)
_ = Nat.choose R.card t := Finset.card_powersetCard t R
/-- A chosen set of positions together with labels of the prescribed profile. -/
def RowEncoding (R : Finset α) (t : ℕ) (n : H → ℕ) : Type _ :=
Σ U : {U : Finset α // U ⊆ R ∧ U.card = t}, ↥(wordFiber ↥U.val n)
noncomputable instance instFintypeRowEncoding (R : Finset α) (t : ℕ) (n : H → ℕ) :
Fintype (RowEncoding R t n) :=
inferInstanceAs (Fintype
(Σ U : {U : Finset α // U ⊆ R ∧ U.card = t}, ↥(wordFiber ↥U.val n)))
/-- Each chosen set admits the same number of words, so the count factors. -/
theorem card_rowEncoding (R : Finset α) (t : ℕ) (n : H → ℕ) :
Fintype.card (RowEncoding R t n) = Nat.choose R.card t * wordCount t n := by
classical
change Fintype.card
(Σ U : {U : Finset α // U ⊆ R ∧ U.card = t}, ↥(wordFiber ↥U.val n)) = _
rw [Fintype.card_sigma]
have hFiber (U : {U : Finset α // U ⊆ R ∧ U.card = t}) :
Fintype.card ↥(wordFiber ↥U.val n) = wordCount t n := by
rw [Fintype.card_coe, wordFiber_finset_card, U.property.2]
calc
(∑ U : {U : Finset α // U ⊆ R ∧ U.card = t},
Fintype.card ↥(wordFiber ↥U.val n)) =
Fintype.card {U : Finset α // U ⊆ R ∧ U.card = t} * wordCount t n := by
simpa only [Finset.card_univ] using
(Finset.sum_const_nat (s := Finset.univ)
(f := fun U : {U : Finset α // U ⊆ R ∧ U.card = t} =>
Fintype.card ↥(wordFiber ↥U.val n))
(m := wordCount t n) (fun U _ => hFiber U))
_ = Nat.choose R.card t * wordCount t n := by
rw [card_fixedSize_subsets]
end TalagrandThreshold
end OAI
|