cfahlgren1/math / lean /OAI /Combinatorics /IndependentSets /Repetition /SelectedProfileBudget.lean
cfahlgren1's picture
download
raw
12 kB
import Mathlib
import OAI.Combinatorics.IndependentSets.Repetition.SelectedProfiles
namespace OAI
noncomputable section
namespace IndependentSetsGames.Foundations.Repetition
section
open scoped BigOperators
open Games Information
variable {Q₁ Q₂ A₁ A₂ : Type*}
[Fintype Q₁] [Fintype Q₂] [Fintype A₁] [Fintype A₂]
[DecidableEq Q₁] [DecidableEq Q₂] {n : Nat}
omit [DecidableEq Q₁] [DecidableEq Q₂] in
theorem selectedQuestionRadius_le_informationRadius [Nonempty A₁] [Nonempty A₂]
(G : Game Q₁ Q₂ A₁ A₂)
(strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂))
(selected : Finset (Fin n)) :
Real.sqrt ((Fintype.card {i : Fin n // i ∉ selected} : ℝ) *
Real.log (1 / G.selectedSuccess strategy selected)) ≤
selectedInformationRadius G strategy selected := by
have hcard : (1 : ℝ) ≤ Fintype.card (SelectedLabels (A₁ := A₁) (A₂ := A₂) selected) := by
exact_mod_cast (Nat.succ_le_of_lt
(Fintype.card_pos : 0 < Fintype.card (SelectedLabels (A₁ := A₁) (A₂ := A₂) selected)))
have hlog := Real.log_nonneg hcard
have hnonneg : 0 ≤ (Fintype.card {i : Fin n // i ∉ selected} : ℝ) := Nat.cast_nonneg _
unfold selectedInformationRadius
apply Real.sqrt_le_sqrt
nlinarith
theorem selectedQuestionMarginal_error_sum [Nonempty A₁] [Nonempty A₂]
(G : Game Q₁ Q₂ A₁ A₂)
(strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected) :
(∑ j : {i : Fin n // i ∉ selected},
(selectedQuestionMarginal G strategy selected positive j.1).totalVariation G.questions) ≤
selectedInformationRadius G strategy selected :=
(unselectedQuestionMarginal_totalVariation_sum_le_sqrt G strategy selected positive).trans
(selectedQuestionRadius_le_informationRadius G strategy selected)
def selectedEmbeddingError (G : Game Q₁ Q₂ A₁ A₂)
(strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected)
(j : {i : Fin n // i ∉ selected}) : ℝ :=
2 * selectedLeftProfileError G strategy selected positive j +
2 * selectedRightProfileError G strategy selected positive j
theorem selectedEmbeddingError_nonnegative (G : Game Q₁ Q₂ A₁ A₂)
(strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected)
(j : {i : Fin n // i ∉ selected}) :
0 ≤ selectedEmbeddingError G strategy selected positive j := by
exact add_nonneg
(mul_nonneg (by norm_num) (Information.totalVariation_nonneg _ _))
(mul_nonneg (by norm_num) (Information.totalVariation_nonneg _ _))
theorem selectedLeftProfileError_sum [Nonempty A₁] [Nonempty A₂]
(G : Game Q₁ Q₂ A₁ A₂)
(strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected) :
(∑ j : {i : Fin n // i ∉ selected}, selectedLeftProfileError G strategy selected positive j) ≤
3 * selectedInformationRadius G strategy selected := by
have hsum := Finset.sum_le_sum
(fun j (_ : j ∈ (Finset.univ : Finset {i : Fin n // i ∉ selected})) =>
selectedLeftProfileError_le G strategy selected positive j)
simp_rw [selectedCommonLaw_secondMarginal] at hsum
rw [Finset.sum_add_distrib] at hsum
have hleft := selected_leftReveal_error_sum G strategy selected positive
have hquestion := selectedQuestionMarginal_error_sum G strategy selected positive
change (∑ j : {i : Fin n // i ∉ selected},
Information.totalVariation (selectedQuestionMarginal G strategy selected positive j.1).weight
G.questions.weight) ≤ _ at hquestion
linarith
theorem selectedRightProfileError_sum [Nonempty A₁] [Nonempty A₂]
(G : Game Q₁ Q₂ A₁ A₂)
(strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected) :
(∑ j : {i : Fin n // i ∉ selected}, selectedRightProfileError G strategy selected positive j) ≤
3 * selectedInformationRadius G strategy selected := by
have hsum := Finset.sum_le_sum
(fun j (_ : j ∈ (Finset.univ : Finset {i : Fin n // i ∉ selected})) =>
selectedRightProfileError_le G strategy selected positive j)
simp_rw [selectedCommonLaw_secondMarginal] at hsum
rw [Finset.sum_add_distrib] at hsum
have hright := selected_rightReveal_error_sum G strategy selected positive
have hquestion := selectedQuestionMarginal_error_sum G strategy selected positive
change (∑ j : {i : Fin n // i ∉ selected},
Information.totalVariation (selectedQuestionMarginal G strategy selected positive j.1).weight
G.questions.weight) ≤ _ at hquestion
linarith
theorem selectedEmbeddingError_sum_le_fifteen [Nonempty A₁] [Nonempty A₂]
(G : Game Q₁ Q₂ A₁ A₂)
(strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected) :
(∑ j : {i : Fin n // i ∉ selected}, selectedEmbeddingError G strategy selected positive j) ≤
15 * selectedInformationRadius G strategy selected := by
have hl := selectedLeftProfileError_sum G strategy selected positive
have hr := selectedRightProfileError_sum G strategy selected positive
have hn : 0 ≤ selectedInformationRadius G strategy selected := Real.sqrt_nonneg _
simp only [selectedEmbeddingError, Finset.sum_add_distrib, ← Finset.mul_sum]
linarith
end
open Games
variable {Q₁ Q₂ A₁ A₂ : Type*}
[Fintype Q₁] [Fintype Q₂] [Fintype A₁] [Fintype A₂]
[DecidableEq Q₁] [DecidableEq Q₂] {n : Nat}
def selectedLabelAccepts (G : Game Q₁ Q₂ A₁ A₂) (selected : Finset (Fin n))
(fixed : selected → Q₁ × Q₂)
(label : SelectedLabels (A₁ := A₁) (A₂ := A₂) selected) : Bool := by
classical
exact decide (∀ i : selected, G.accepts (fixed i).1 (fixed i).2 (label.1 i) (label.2 i) = true)
def selectedLocalAnswers {Q A : Type*} (strategy : (Fin n → Q) → (Fin n → A))
(selected : Finset (Fin n)) (fixed : selected → Q)
(remaining : {i : Fin n // i ∉ selected} → Q) : selected → A :=
fun i => strategy (mergeCoordinates selected fixed remaining) i.1
def selectedLocalTest {Q A : Type*} (strategy : (Fin n → Q) → (Fin n → A))
(selected : Finset (Fin n)) (fixed : selected → Q) (label : selected → A)
(remaining : {i : Fin n // i ∉ selected} → Q) : ℝ := by
classical
exact if selectedLocalAnswers strategy selected fixed remaining = label then 1 else 0
theorem selectedLocalTest_nonnegative {Q A : Type*} (strategy : (Fin n → Q) → (Fin n → A))
(selected : Finset (Fin n)) (fixed : selected → Q) (label : selected → A)
(remaining : {i : Fin n // i ∉ selected} → Q) :
0 ≤ selectedLocalTest strategy selected fixed label remaining := by
classical
unfold selectedLocalTest
split <;> norm_num
omit [Fintype Q₁] [Fintype Q₂] [DecidableEq Q₁] [DecidableEq Q₂] in
theorem selectedQuestionTuple_left (selected : Finset (Fin n))
(fixed : selected → Q₁ × Q₂) (remaining : {i : Fin n // i ∉ selected} → Q₁ × Q₂) :
(selectedQuestionTuple selected fixed remaining).1 =
mergeCoordinates selected (fun i => (fixed i).1) (fun i => (remaining i).1) := by
funext i
simp only [selectedQuestionTuple, mergeCoordinates]
split <;> rfl
omit [Fintype Q₁] [Fintype Q₂] [DecidableEq Q₁] [DecidableEq Q₂] in
theorem selectedQuestionTuple_right (selected : Finset (Fin n))
(fixed : selected → Q₁ × Q₂) (remaining : {i : Fin n // i ∉ selected} → Q₁ × Q₂) :
(selectedQuestionTuple selected fixed remaining).2 =
mergeCoordinates selected (fun i => (fixed i).2) (fun i => (remaining i).2) := by
funext i
simp only [selectedQuestionTuple, mergeCoordinates]
split <;> rfl
omit [DecidableEq Q₁] [DecidableEq Q₂] in
theorem selectedWins_of_answerLabel (G : Game Q₁ Q₂ A₁ A₂)
(strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂))
(selected : Finset (Fin n)) (fixed : selected → Q₁ × Q₂)
(label : SelectedLabels (A₁ := A₁) (A₂ := A₂) selected)
(remaining : {i : Fin n // i ∉ selected} → Q₁ × Q₂)
(hlabel : selectedAnswerLabel strategy selected (selectedQuestionTuple selected fixed remaining) = label) :
G.selectedWins strategy selected (selectedQuestionTuple selected fixed remaining) =
selectedLabelAccepts G selected fixed label := by
classical
have hleft (i : selected) := congrArg (fun l => l.1 i) hlabel
have hright (i : selected) := congrArg (fun l => l.2 i) hlabel
apply Bool.eq_iff_iff.mpr
simp only [Game.selectedWins, selectedLabelAccepts, decide_eq_true_eq]
constructor
· intro h i
have hi := h i.1 i.property
simpa [Game.coordinateWin, selectedQuestionTuple, mergeCoordinates, i.property,
← hleft i, ← hright i, selectedAnswerLabel] using hi
· intro h i hi
have hv := h ⟨i,hi⟩
simpa [Game.coordinateWin, selectedQuestionTuple, mergeCoordinates, hi,
← hleft ⟨i,hi⟩, ← hright ⟨i,hi⟩, selectedAnswerLabel] using hv
omit [DecidableEq Q₁] [DecidableEq Q₂] in
theorem selectedLikelihood_factorization (G : Game Q₁ Q₂ A₁ A₂)
(strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂))
(selected : Finset (Fin n)) (fixed : selected → Q₁ × Q₂)
(label : SelectedLabels (A₁ := A₁) (A₂ := A₂) selected)
(remaining : {i : Fin n // i ∉ selected} → Q₁ × Q₂) :
selectedLikelihood G strategy selected fixed label remaining =
(if selectedLabelAccepts G selected fixed label then 1 else 0) *
selectedLocalTest strategy.1 selected (fun i => (fixed i).1) label.1 (fun i => (remaining i).1) *
selectedLocalTest strategy.2 selected (fun i => (fixed i).2) label.2 (fun i => (remaining i).2) := by
classical
have he : selectedAnswerLabel strategy selected (selectedQuestionTuple selected fixed remaining) =
(selectedLocalAnswers strategy.1 selected (fun i => (fixed i).1) (fun i => (remaining i).1),
selectedLocalAnswers strategy.2 selected (fun i => (fixed i).2) (fun i => (remaining i).2)) := by
simp only [selectedAnswerLabel,
selectedQuestionTuple_left, selectedQuestionTuple_right]
rfl
by_cases hl : selectedLocalAnswers strategy.1 selected (fun i => (fixed i).1)
(fun i => (remaining i).1) = label.1
· by_cases hr : selectedLocalAnswers strategy.2 selected (fun i => (fixed i).2)
(fun i => (remaining i).2) = label.2
· have hlabel : selectedAnswerLabel strategy selected (selectedQuestionTuple selected fixed remaining) = label := by
rw [he, hl, hr]
simp only [selectedLikelihood, ite_eq_left hlabel,
selectedWins_of_answerLabel G strategy selected fixed label remaining hlabel,
selectedLocalTest, ite_eq_left hl, ite_eq_left hr, mul_one]
· have hn : selectedAnswerLabel strategy selected (selectedQuestionTuple selected fixed remaining) ≠ label := by
intro h
rw [he] at h
exact hr (congrArg Prod.snd h)
simp [selectedLikelihood, hn, selectedLocalTest, hl, hr]
· have hn : selectedAnswerLabel strategy selected (selectedQuestionTuple selected fixed remaining) ≠ label := by
intro h
rw [he] at h
exact hl (congrArg Prod.fst h)
simp [selectedLikelihood, hn, selectedLocalTest, hl]
end IndependentSetsGames.Foundations.Repetition
end
end OAI

Xet Storage Details

Size:
12 kB
·
Xet hash:
181ff7e2bd756f9cf81f4a2362a7e21095a69a83ba569e3374a42cf8c95a3476

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.