cfahlgren1's picture
download
raw
7.71 kB
import Mathlib
import OAI.Computability.VertexCover.Repetition.MaskedVariation
namespace OAI
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
namespace UniqueGames.Foundations.Repetition
open scoped BigOperators
noncomputable section
variable {I T X Y : Type*} [Fintype I] [DecidableEq I] [Fintype T]
[Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y]
def mergeAt {R : Type*} (j : I) (a : R) (rest : {i : I // i ≠ j} → R) : I → R :=
fun i => if h : i = j then a else rest ⟨i,h⟩
omit [Fintype I] in
@[simp] theorem mergeAt_self {R : Type*} (j : I) (a : R) (rest : {i : I // i ≠ j} → R) :
mergeAt j a rest j = a := by simp [mergeAt]
omit [Fintype I] in
@[simp] theorem mergeAt_other {R : Type*} (j : I) (a : R)
(rest : {i : I // i ≠ j} → R) (i : {i : I // i ≠ j}) :
mergeAt j a rest i.1 = rest i := by simp [mergeAt, i.property]
def partialRevealWeight (μ : Games.FiniteDistribution (X × Y)) (j : I)
(rest : {i : I // i ≠ j} → X ⊕ Y) (u : I → X × Y) : ℝ :=
μ.weight (u j) * ∏ i : {i : I // i ≠ j}, (revealLaw μ).weight (u i.1,rest i)
theorem product_reveal_at (μ : Games.FiniteDistribution (X × Y)) (j : I)
(r : X ⊕ Y) (rest : {i : I // i ≠ j} → X ⊕ Y) (u : I → X × Y) :
(∏ i, (revealLaw μ).weight (u i,mergeAt j r rest i)) =
(if r = Sum.inl (u j).1 then partialRevealWeight μ j rest u / 2 else 0) +
(if r = Sum.inr (u j).2 then partialRevealWeight μ j rest u / 2 else 0) := by
rw [Fintype.prod_eq_mul_prod_subtype_ne _ j]
simp only [mergeAt_self, mergeAt_other, revealLaw_weight]
by_cases hl : r = Sum.inl (u j).1 <;> by_cases hr : r = Sum.inr (u j).2 <;>
simp [hl, hr, partialRevealWeight, revealLaw_weight] <;> ring
def partialRevealMarginal (μ : Games.FiniteDistribution (X × Y)) (j : I)
(likelihood : T → (I → X × Y) → ℝ) :
(T × ({i : I // i ≠ j} → X ⊕ Y)) × (X × Y) → ℝ := by
classical
exact fun z => ∑ u, if u j = z.2 then
partialRevealWeight μ j z.1.2 u * likelihood z.1.1 u else 0
def fullRevealMarginal (μ : Games.FiniteDistribution (X × Y)) (j : I)
(likelihood : T → (I → X × Y) → ℝ) :
(T × (I → X ⊕ Y)) × (X × Y) → ℝ := by
classical
exact fun z => ∑ u, if u j = z.2 then
(∏ i, (revealLaw μ).weight (u i,z.1.2 i)) * likelihood z.1.1 u else 0
omit [Fintype T] in
theorem fullRevealMarginal_merge (μ : Games.FiniteDistribution (X × Y)) (j : I)
(likelihood : T → (I → X × Y) → ℝ) (t : T)
(rest : {i : I // i ≠ j} → X ⊕ Y) (r : X ⊕ Y) (q : X × Y) :
fullRevealMarginal μ j likelihood ((t,mergeAt j r rest),q) =
maskedJoint (partialRevealMarginal μ j likelihood) (((t,rest),r),q) := by
classical
unfold fullRevealMarginal
simp_rw [product_reveal_at]
have hpoint (u : I → X × Y) :
(if u j = q then
((if r = Sum.inl (u j).1 then partialRevealWeight μ j rest u / 2 else 0) +
(if r = Sum.inr (u j).2 then partialRevealWeight μ j rest u / 2 else 0)) *
likelihood t u else 0) =
(if r = Sum.inl q.1 then
(if u j = q then partialRevealWeight μ j rest u * likelihood t u else 0) / 2 else 0) +
(if r = Sum.inr q.2 then
(if u j = q then partialRevealWeight μ j rest u * likelihood t u else 0) / 2 else 0) := by
by_cases hu : u j = q
· rw [hu]
by_cases hl : r = Sum.inl q.1 <;> by_cases hr : r = Sum.inr q.2 <;>
simp [hl, hr] <;> ring
· simp [hu]
simp_rw [hpoint]
simp [maskedJoint, partialRevealMarginal, Finset.sum_add_distrib, Finset.sum_ite_irrel, div_eq_mul_inv, Finset.sum_mul]
def fullRevealModel (μ : Games.FiniteDistribution (X × Y)) (j : I)
(likelihood : T → (I → X × Y) → ℝ) :
(T × (I → X ⊕ Y)) × (X × Y) → ℝ := fun z =>
Information.firstMarginal (fullRevealMarginal μ j likelihood) z.1 *
(revealProfile μ (z.1.2 j)).weight z.2
omit [Fintype T] in
theorem fullRevealModel_merge (μ : Games.FiniteDistribution (X × Y)) (j : I)
(likelihood : T → (I → X × Y) → ℝ) (t : T)
(rest : {i : I // i ≠ j} → X ⊕ Y) (r : X ⊕ Y) (q : X × Y) :
fullRevealModel μ j likelihood ((t,mergeAt j r rest),q) =
maskedModel μ (partialRevealMarginal μ j likelihood) (((t,rest),r),q) := by
simp only [fullRevealModel, Information.firstMarginal, fullRevealMarginal_merge,
mergeAt_self, maskedModel]
def revealSplitEquiv (j : I) :
((T × (I → X ⊕ Y)) × (X × Y)) ≃
(((T × ({i : I // i ≠ j} → X ⊕ Y)) × (X ⊕ Y)) × (X × Y)) where
toFun z := (((z.1.1, fun i => z.1.2 i.1), z.1.2 j), z.2)
invFun z := ((z.1.1.1, mergeAt j z.1.2 z.1.1.2), z.2)
left_inv z := by
apply Prod.ext
· apply Prod.ext
· rfl
· funext i
by_cases h : i = j <;> simp [mergeAt, h]
· rfl
right_inv z := by
apply Prod.ext
· apply Prod.ext
· apply Prod.ext
· rfl
· funext i
exact mergeAt_other j z.1.2 z.1.1.2 i
· exact mergeAt_self j z.1.2 z.1.1.2
· rfl
theorem totalVariation_comp_equiv {A B : Type*} [Fintype A] [Fintype B]
(e : A ≃ B) (p q : B → ℝ) :
Information.totalVariation (fun a => p (e a)) (fun a => q (e a)) =
Information.totalVariation p q := by
unfold Information.totalVariation
congr 1
exact e.sum_comp (fun b => |p b - q b|)
theorem fullReveal_totalVariation (μ : Games.FiniteDistribution (X × Y)) (j : I)
(likelihood : T → (I → X × Y) → ℝ) :
Information.totalVariation (fullRevealMarginal μ j likelihood) (fullRevealModel μ j likelihood) =
Information.totalVariation (maskedJoint (partialRevealMarginal μ j likelihood))
(maskedModel μ (partialRevealMarginal μ j likelihood)) := by
calc
_ = Information.totalVariation
(fun z => fullRevealMarginal μ j likelihood ((revealSplitEquiv (T := T) j).symm z))
(fun z => fullRevealModel μ j likelihood ((revealSplitEquiv (T := T) j).symm z)) :=
(totalVariation_comp_equiv (revealSplitEquiv (T := T) j).symm _ _).symm
_ = _ := by
congr 1 <;> funext z
· exact fullRevealMarginal_merge μ j likelihood z.1.1.1 z.1.1.2 z.1.2 z.2
· exact fullRevealModel_merge μ j likelihood z.1.1.1 z.1.1.2 z.1.2 z.2
theorem leftReveal_full_error (μ : Games.FiniteDistribution (X × Y)) (j : I)
(likelihood : T → (I → X × Y) → ℝ) :
Information.totalVariation (partialRevealMarginal μ j likelihood)
(leftRevealModel μ (partialRevealMarginal μ j likelihood)) ≤
2 * Information.totalVariation (fullRevealMarginal μ j likelihood)
(fullRevealModel μ j likelihood) := by
rw [fullReveal_totalVariation]
exact leftRevealModel_totalVariation_le μ _
theorem rightReveal_full_error (μ : Games.FiniteDistribution (X × Y)) (j : I)
(likelihood : T → (I → X × Y) → ℝ) :
Information.totalVariation (partialRevealMarginal μ j likelihood)
(rightRevealModel μ (partialRevealMarginal μ j likelihood)) ≤
2 * Information.totalVariation (fullRevealMarginal μ j likelihood)
(fullRevealModel μ j likelihood) := by
rw [fullReveal_totalVariation]
exact rightRevealModel_totalVariation_le μ _
end
end UniqueGames.Foundations.Repetition
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end OAI

Xet Storage Details

Size:
7.71 kB
·
Xet hash:
da9e5f28da646a3d96749591d3821a5d2677b0a166f5789c90e67e5a2637618a

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