File size: 5,508 Bytes
2f887db | 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 | import OAI.Computability.PerfectCompleteness.Algebra.UniformLinearImage
import OAI.Computability.PerfectCompleteness.Foundations.HierarchicalArrays
import OAI.Computability.PerfectCompleteness.Foundations.ProjectedCardinality
import OAI.Computability.UniqueGames.Foundations.SamplingLemmas
namespace OAI
section
namespace PerfectCompleteness.CleanTreeFactors
open scoped BigOperators
open UniqueGamesTheorem.Foundations.Games
open RecursiveSpaces TreeSourceSpaces PointwiseSpaces HierarchicalArrays
open ProjectedCardinality FiniteProduct CleanConditioning
noncomputable section
variable {branch : Nat → Nat} {n t : Nat}
abbrev Index (branch : Nat → Nat) (n calls : Nat) (rows : Nat → Nat) :=
Fin calls ⊕ (Σ node : Nodes branch n, Fin (rows (Nodes.height node)))
def height (calls : Nat) (rows : Nat → Nat) : Index branch n calls rows → Nat
| .inl _ => n
| .inr p => Nodes.height p.1
def square (calls : Nat) (rows : Nat → Nat) : Index branch n calls rows → Bool
| .inl _ => true
| .inr _ => false
def factorIds (calls : Nat) (rows : Nat → Nat)
(ids : Slots branch n → Fin t → Nat) :
(j : Index branch n calls rows) → Slots branch (height calls rows j) → Fin t → Nat
| .inl _, s, k => ids s k
| .inr p, s, k => ids ((Nodes.path p.1).slotEmbedding s) k
abbrev Factors (calls : Nat) (rows : Nat → Nat)
(ids : Slots branch n → Fin t → Nat) (j : Index branch n calls rows) :=
Factor (square calls rows j) (factorIds calls rows ids j)
abbrev Raw (calls : Nat) (rows : Nat → Nat)
(ids : Slots branch n → Fin t → Nat) :=
(Fin calls → squareSpace (H (projectedSlots ids))) × Arrays (projectedSlots ids) rows
instance rawFintype (calls : Nat) (rows : Nat → Nat)
(ids : Slots branch n → Fin t → Nat) : Fintype (Raw calls rows ids) :=
Fintype.ofFinite _
def zeroRaw (calls : Nat) (rows : Nat → Nat)
(ids : Slots branch n → Fin t → Nat) : Raw calls rows ids :=
(fun _ => 0, fun _ _ => 0)
instance rawNonempty (calls : Nat) (rows : Nat → Nat)
(ids : Slots branch n → Fin t → Nat) : Nonempty (Raw calls rows ids) :=
⟨zeroRaw calls rows ids⟩
def rawEquiv (calls : Nat) (rows : Nat → Nat)
(ids : Slots branch n → Fin t → Nat) :
((j : Index branch n calls rows) → Factors calls rows ids j) ≃ Raw calls rows ids where
toFun x := (fun q => x (.inl q), fun node row => x (.inr ⟨node, row⟩))
invFun x j := match j with
| .inl q => x.1 q
| .inr p => x.2 p.1 p.2
left_inv x := by
funext j
cases j <;> rfl
right_inv x := by
cases x
rfl
theorem rawEquiv_zero (calls : Nat) (rows : Nat → Nat)
(ids : Slots branch n → Fin t → Nat) :
rawEquiv calls rows ids
(fun j => factorZero (square calls rows j) (factorIds calls rows ids j)) =
zeroRaw calls rows ids := rfl
def rawLaw (calls : Nat) (rows : Nat → Nat)
(ids : Slots branch n → Fin t → Nat) : FiniteDistribution (Raw calls rows ids) :=
(law (fun j : Index branch n calls rows =>
FiniteDistribution.uniform (Factors calls rows ids j))).pushforward (rawEquiv calls rows ids)
theorem rawLaw_uniform (calls : Nat) (rows : Nat → Nat)
(ids : Slots branch n → Fin t → Nat) :
rawLaw calls rows ids = FiniteDistribution.uniform (Raw calls rows ids) := by
unfold rawLaw
rw [UniformLinearImage.law_uniform, FiniteDistribution.pushforward_equiv]
apply FiniteDistribution.eq_of_weight_eq
intro x
change 1 / (Fintype.card ((j : Index branch n calls rows) → Factors calls rows ids j) : ℝ) =
1 / (Fintype.card (Raw calls rows ids) : ℝ)
rw [Fintype.card_congr (rawEquiv calls rows ids)]
def allZero (calls : Nat) (rows : Nat → Nat)
(ids : Slots branch n → Fin t → Nat) (x : Raw calls rows ids) : Bool := by
classical
exact decide ((∀ q, x.1 q = 0) ∧ ∀ node row, x.2 node row = 0)
theorem allZero_rawEquiv (calls : Nat) (rows : Nat → Nat)
(ids : Slots branch n → Fin t → Nat)
(x : (j : Index branch n calls rows) → Factors calls rows ids j) :
allZero calls rows ids (rawEquiv calls rows ids x) =
allEvent (fun j y => decide (y = factorZero
(square calls rows j) (factorIds calls rows ids j))) x := by
classical
apply Bool.eq_iff_iff.mpr
simp only [allZero, allEvent, decide_eq_true_eq]
constructor
· rintro ⟨hc, ha⟩ j
cases j with
| inl q => exact hc q
| inr p => exact ha p.1 p.2
· intro h
exact ⟨fun q => h (.inl q), fun node row => h (.inr ⟨node, row⟩)⟩
theorem probability_allZero (calls : Nat) (rows : Nat → Nat)
(ids : Slots branch n → Fin t → Nat) :
(rawLaw calls rows ids).probability (allZero calls rows ids) =
∏ j : Index branch n calls rows,
1 / (shapeCardinality branch t (height calls rows) (square calls rows) j : ℝ) := by
rw [rawLaw, FiniteDistribution.probability_pushforward]
simp_rw [allZero_rawEquiv]
rw [probability_law_all]
apply Finset.prod_congr rfl
intro j _
rw [UniformLatent.probability_uniform_singleton]
rw [factor_card_eq (square calls rows j) (factorIds calls rows ids j) (fun _ _ => 0)]
rfl
theorem probability_allZero_pos (calls : Nat) (rows : Nat → Nat)
(ids : Slots branch n → Fin t → Nat) :
0 < (rawLaw calls rows ids).probability (allZero calls rows ids) := by
rw [probability_allZero]
exact shape_zero_probability_pos branch t (height calls rows) (square calls rows)
end
end PerfectCompleteness.CleanTreeFactors
end
end OAI
|