File size: 4,350 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
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
import OAI.Combinatorics.ExpectationThreshold.Basic
import OAI.Combinatorics.ExpectationThreshold.ProbabilityColors
import OAI.Combinatorics.ExpectationThreshold.SelectorTruncationDefinitions
import Mathlib.Data.Fintype.Pi
import Mathlib.Data.Finset.Lattice.Fold

namespace OAI

/-!
# Actual moves and profiles for the simultaneous selector

We retain all colorings of minimum total movement for at least one original
family member. This avoids an arbitrary tie-breaking order; each retained
coloring still has the member-specific minimality used in reconstruction.
-/

noncomputable section

open scoped BigOperators

namespace TalagrandThreshold.Selector

variable {α : Type*} [Fintype α] [DecidableEq α]

/-- A probability mass for each actual member of the family. -/
structure MassFamily (F : Family α) where
  weight : ↥F → α → ℝ
  nonneg : ∀ H x, 0 ≤ weight H x
  total : ∀ H, ∑ x, weight H x = 1
  supported : ∀ H x, x ∉ H.val → weight H x = 0

/-- Colors have zero-based indices; the actual color level is one larger. -/
def prefixSet {s : ℕ} (z : Coloring α s) (i : Fin s) : Finset α :=
  Finset.univ.filter fun x => (z x).val ≤ i.val

def dscale {s : ℕ} (i : Fin s) : ℝ := ((2 : ℝ) ^ (i.val + 1))⁻¹

/-- `Earlier a z` means that the move from `a` to `z` only lowers colors. -/
def Earlier {s : ℕ} (a z : Coloring α s) : Prop := ∀ x, z x ≤ a x

def changes {s : ℕ} (a z : Coloring α s) : Finset α :=
  Finset.univ.filter fun x => z x < a x

def crossings {s : ℕ} (a z : Coloring α s) (i : Fin s) : ℕ :=
  (prefixSet z i \ prefixSet a i).card

def movement {s : ℕ} (a z : Coloring α s) : ℕ :=
  ∑ x, ((a x).val - (z x).val)

def movedRow {s : ℕ} (a z : Coloring α s) (i : Fin s) : Finset α :=
  Finset.univ.filter fun x => (z x).val = i.val ∧ (z x).val < (a x).val

/-- The full profile retains both final and original colors. -/
abbrev Profile (s : ℕ) := Fin s → Color s → ℕ

def profile {s : ℕ} (a z : Coloring α s) : Profile s :=
  fun i h => (Finset.univ.filter fun x =>
    (z x).val = i.val ∧ a x = h ∧ i.val < h.val).card

def rowCount {s : ℕ} (n : Profile s) (i : Fin s) : ℕ := ∑ h, n i h

def profileSize {s : ℕ} (n : Profile s) : ℕ := ∑ i, rowCount n i

def profileCrossings {s : ℕ} (n : Profile s) (i : Fin s) : ℕ :=
  ∑ j : Fin s, ∑ h : Color s,
    if j.val ≤ i.val ∧ i.val < h.val then n j h else 0

def FeasibleFor {F : Family α} (mu : MassFamily F) {s : ℕ}
    (a z : Coloring α s) (H : ↥F) : Prop :=
  ∀ i : Fin s, ∃ ε : ℝ,
    Admissible (mu.weight H) (prefixSet z i) (crossings a z i : ℝ) (dscale i) ε

def Feasible {F : Family α} (mu : MassFamily F) {s : ℕ}
    (a z : Coloring α s) : Prop :=
  Earlier a z ∧ ∃ H : ↥F, FeasibleFor mu a z H

def BoundedFeasible {F : Family α} (mu : MassFamily F) {s : ℕ}
    (a : Coloring α s) (H₀ : ↥F) (z : Coloring α s) : Prop :=
  Feasible mu a z ∧ changes a z ⊆ H₀.val

def IsMinimalMove {F : Family α} (mu : MassFamily F) {s : ℕ}
    (a : Coloring α s) (H₀ : ↥F) (z : Coloring α s) : Prop :=
  BoundedFeasible mu a H₀ z ∧
    ∀ w, BoundedFeasible mu a H₀ w → movement a z ≤ movement a w

def Selected {F : Family α} (mu : MassFamily F) {s : ℕ}
    (a z : Coloring α s) : Prop := ∃ H₀ : ↥F, IsMinimalMove mu a H₀ z

def selectedMoves {F : Family α} (mu : MassFamily F) {s : ℕ}
    (a : Coloring α s) : Finset (Coloring α s) := by
  classical
  exact Finset.univ.filter (Selected mu a)

/-- An actual bad original coloring, its selected endpoint, and its full profile. -/
def Captured {F : Family α} (mu : MassFamily F) {s : ℕ}
    (a : Coloring α s) : Prop :=
  ∃ H : ↥F, ∀ i : Fin s,
    1 - dscale i ≤ ∑ x ∈ prefixSet a i, mu.weight H x

def Bad {F : Family α} (mu : MassFamily F) {s : ℕ}
    (a : Coloring α s) : Prop := ¬ Captured mu a

def groupOriginals {F : Family α} (mu : MassFamily F) {s : ℕ}
    (z : Coloring α s) (n : Profile s) : Finset (Coloring α s) := by
  classical
  exact Finset.univ.filter fun a => Bad mu a ∧ Selected mu a z ∧ profile a z = n

def meanColor {F : Family α} (mu : MassFamily F) {s : ℕ}
    (H : ↥F) (a : Coloring α s) : ℝ :=
  ∑ x, ((a x).val + 1 : ℝ) * mu.weight H x

end TalagrandThreshold.Selector

end

end OAI