math / data /lean /OAI /Combinatorics /ExpectationThreshold /SelectorDefinitions.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
4.35 kB
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