Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
File size: 7,865 Bytes
4365a98 |
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
import data.real.nnreal
import topology.algebra.infinite_sum
import topology.instances.ennreal
import topology.algebra.monoid
open_locale nnreal big_operators
open finset
/-!
# A technical lemma on the way to `lem98`
The purpose of this file is to prove the following lemma:
```
lemma exists_partition (N : β) (hN : 0 < N) (f : β β ββ₯0) (hf : β n, f n β€ 1) (hf' : summable f) :
β (mask : fin N β set β),
(β n, β! i, n β mask i) β§ (β i, β' n, set.indicator (mask i) f n β€ (β' n, f n) / N + 1) :=
```
In disguise, this is `lem98` (`combinatorial_lemma/default.lean`) specialized to `Ξ = β€`.
The proof of the general case makes a reduction to this special case.
## Informal explanation of the statement
The lemma `exists_partition` informally says the following:
Suppose we have a sequence of real numbers `f 0`, `f 1`, β¦, all between `0` and `1`,
and suppose that `c = β (f i)` exists.
Then, for every positive natural number `N`, we can split `f` into `N` subsequences `g 1`, β¦, `g N`,
such that `β (g j i) β€ c/N + 1`.
The informal proof is easy: consider `N` buckets, that are initially empty.
Now view the numbers `f i` as an incoming stream of numbers,
and place each of these in the buckets with the smallest total sum.
The formal proof is a bit trickier: we need to make sure that every number ends up in a bucket,
we need to show that the final subsequences have a converging sum, etcβ¦
We model the subsqeuences by using indicator functions to mask parts of `f`
using `N` subsets of `β` (`mask` in the statement).
In `recursion_data` below, we setup the `N` buckets,
and define the recursion step in `recursion_data_succ`.
The rest of the file consists of assembling the pieces.
-/
namespace combinatorial_lemma
/-- A data structure for recording partial sums of subsequences of a sequence of real numbers,
such that all the partial sums are rougly the same size.
The field `m` records to which partial sum the next entry in the sequence will be added. -/
structure recursion_data (N : β) (hN : 0 < N) (f : β β ββ₯0) (hf : β n, f n β€ 1) (k : β) :=
(m : fin N β Prop)
(hm : β! i, m i)
(partial_sums : fin N β ββ₯0)
(hβ : β i, partial_sums i = β n in range (k + 1), f n)
(hβ : β i, partial_sums i β€ (β n in range (k + 1), f n) / N + 1)
[dec_inst : β i, decidable (m i)]
attribute [instance] recursion_data.dec_inst
/-- The starting point for recursively constructing subsequences of a sequence of real numbers
such that all the subsequences sum to be roughly the same size:
we start by placing the first element of the sequence into the subsequence `0`. -/
def recursion_data_zero (N : β) (hN : 0 < N) (f : β β ββ₯0) (hf : β n, f n β€ 1) :
recursion_data N hN f hf 0 :=
{ m := Ξ» j, j = β¨0, hNβ©,
hm := β¨_, rfl, Ξ» _, idβ©,
partial_sums := Ξ» j, if j = β¨0, hNβ© then f 0 else 0,
hβ := by simp only [sum_ite_eq', if_true, mem_univ, sum_singleton, range_one],
hβ :=
begin
intros i,
split_ifs,
{ simp only [sum_singleton, range_one],
refine (hf 0).trans _,
exact self_le_add_left 1 (f 0 / βN) },
{ exact zero_le' }
end }
instance (N : β) (hN : 0 < N) (f : β β ββ₯0) (hf : β n, f n β€ 1) :
inhabited (recursion_data N hN f hf 0) := β¨recursion_data_zero N hN f hfβ©
/-- Given partial sums of subsequences up to the `k`-th element in a sequence of real numbers,
add the `k+1`st element to the smallest partial sum so far. -/
noncomputable def recursion_data_succ (N : β) (hN : 0 < N) (f : β β ββ₯0) (hf : β n, f n β€ 1) (k : β)
(dat : recursion_data N hN f hf k) :
recursion_data N hN f hf (k + 1) :=
let I := (finset.univ : finset (fin N)).exists_min_image
dat.partial_sums β¨β¨0, hNβ©, finset.mem_univ _β© in
{ m := Ξ» j, j = I.some,
hm := β¨I.some, rfl, Ξ» _, idβ©,
partial_sums := Ξ» i, dat.partial_sums i + (if i = I.some then f (k + 1) else 0),
hβ :=
begin
rw sum_range_succ _ (k + 1),
simp [finset.sum_add_distrib, dat.hβ, add_comm],
end,
hβ :=
begin
intros i,
split_ifs,
{ rw h,
have : dat.partial_sums I.some * N β€ (β n in range (k + 1 + 1), f n),
{ calc dat.partial_sums I.some * N
= β i : fin N, dat.partial_sums I.some : _
... β€ β i, dat.partial_sums i : _ -- follows from I
... = β n in range (k + 1), f n : dat.hβ
... β€ β n in range (k + 1 + 1), f n : _,
{ simp only [finset.sum_const, finset.card_fin, nsmul_eq_mul, mul_comm] },
{ obtain β¨-, HIβ© := I.some_spec,
apply finset.sum_le_sum,
intros j hj, exact HI j hj },
{ rw sum_range_succ _ (k + 1),
simp } },
have : dat.partial_sums I.some β€ (β n in range (k + 1 + 1), f n) / βN,
{ rwa nnreal.le_div_iff_mul_le, exact_mod_cast hN.ne' },
exact add_le_add this (hf (k + 1)) },
{ calc dat.partial_sums i + 0
β€ (β n in range (k + 1), f n) / βN + 1 : by simpa using dat.hβ i
... β€ (β n in range (k + 1 + 1), f n) / βN + 1 : add_le_add _ le_rfl,
simp only [div_eq_mul_inv, fin.sum_univ_eq_sum_range],
refine mul_le_mul' _ le_rfl,
simp only [finset.sum_range_succ],
exact self_le_add_right _ _ }
end }
/-- Recursively construct subsequences of a given sequence of real numbers,
in such a way that the sums of the subsequences are all roughly of the same size. -/
noncomputable def partition (N : β) (hN : 0 < N) (f : β β ββ₯0) (hf : β n, f n β€ 1) :
Ξ i : β, (recursion_data N hN f hf i)
| 0 := recursion_data_zero N hN f hf
| (k + 1) := recursion_data_succ N hN f hf k (partition k)
lemma partition_sums_aux (k : β) (N : β) (hN : 0 < N) (f : β β ββ₯0) (hf : β n, f n β€ 1)
(i : fin N) :
(partition N hN f hf (k + 1)).partial_sums i =
(partition N hN f hf k).partial_sums i +
if (partition N hN f hf (k + 1)).m i then f (k + 1) else 0 :=
by simp [partition, recursion_data_succ]
lemma partition_sums (k : β) (N : β) (hN : 0 < N) (f : β β ββ₯0) (hf : β n, f n β€ 1)
(i : fin N) :
(partition N hN f hf k).partial_sums i =
β n in range (k + 1), set.indicator {k | (partition N hN f hf k).m i} f n :=
begin
induction k with k IH,
{ dsimp [partition], simp, dsimp [partition, recursion_data_zero], congr },
rw [partition_sums_aux, IH, sum_range_succ _ k.succ, set.indicator, add_right_inj],
congr' 1,
end
lemma exists_partition (N : β) (hN : 0 < N) (f : β β ββ₯0) (hf : β n, f n β€ 1) (hf' : summable f) :
β (mask : fin N β set β),
(β n, β! i, n β mask i) β§ (β i, β' n, set.indicator (mask i) f n β€ (β' n, f n) / N + 1) :=
begin
let mask : fin N β β β Prop := Ξ» i, {n | (partition N hN f hf n).m i},
have h_sum : β k i, β n in range k, set.indicator (mask i) f n β€ (β n in range k, f n) / N + 1,
{ rintros β¨kβ© i,
{ simp [mask] },
rw β partition_sums k N hN f hf i,
exact (partition N hN f hf k).hβ i, },
refine β¨mask, _, _β©,
{ intros n, exact (partition N hN f hf n).hm },
{ intros i,
set Sβ : ββ₯0 := β' (n : β), f n,
have hf'' : has_sum f Sβ := hf'.has_sum,
have hf''' : has_sum _ (Sβ / N) := hf''.mul_right (N:ββ₯0)β»ΒΉ,
have : set.indicator (mask i) f β€ f,
{ intros n,
dsimp [set.indicator],
split_ifs, exacts [le_rfl, zero_le'] },
obtain β¨Sβ, -, h_maskβ© := nnreal.exists_le_has_sum_of_le this hf'',
rw h_mask.tsum_eq,
rw nnreal.has_sum_iff_tendsto_nat at hf''' h_mask,
have := filter.tendsto.add_const 1 hf''',
apply le_of_tendsto_of_tendsto' h_mask this,
intros n,
simp only [div_eq_mul_inv, finset.sum_mul] at h_sum β’,
exact h_sum n i }
end
end combinatorial_lemma
#lint-
|