File size: 7,019 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 143 144 145 146 147 148 149 150 151 152 153 154 155 | import OAI.Computability.PerfectCompleteness.Foundations.CutSlotOutside
import OAI.Computability.PerfectCompleteness.Sampling.PreliminarySampler
namespace OAI
section
namespace PerfectCompleteness.SourceQuestionCutSplit
noncomputable section
open scoped Classical
open RecursiveSpaces DescendantSpaces TreeSourceSpaces
open UniqueGamesTheorem.Foundations.Games
variable {branch : Nat → Nat} {root h t m : Nat}
abbrev OutsideLeaf (p : Path branch root h) :=
{leaf : Slots branch root // leaf ∉ Set.range p.slotEmbedding}
abbrev OutsideQuestions (p : Path branch root h) (t m : Nat) :=
OutsideLeaf p → Fin t → Fin m
def restrict (p : Path branch root h)
(q : PreliminarySampler.Questions branch root t m) :
PreliminarySampler.Questions branch h t m :=
fun leaf => q (p.slotEmbedding leaf)
def outside (p : Path branch root h)
(q : PreliminarySampler.Questions branch root t m) : OutsideQuestions p t m :=
fun leaf => q leaf.val
def join (p : Path branch root h)
(inside : PreliminarySampler.Questions branch h t m) (external : OutsideQuestions p t m) :
PreliminarySampler.Questions branch root t m :=
fun leaf => if hleaf : leaf ∈ Set.range p.slotEmbedding then
inside (Classical.choose hleaf) else external ⟨leaf, hleaf⟩
@[simp] theorem join_at_cut (p : Path branch root h)
(inside : PreliminarySampler.Questions branch h t m) (external : OutsideQuestions p t m)
(leaf : Slots branch h) :
join p inside external (p.slotEmbedding leaf) = inside leaf := by
have hleaf : p.slotEmbedding leaf ∈ Set.range p.slotEmbedding := ⟨leaf, rfl⟩
have hchoose : Classical.choose hleaf = leaf :=
p.slotEmbedding_injective (Classical.choose_spec hleaf)
simp only [join, dite_eq_left hleaf, hchoose]
@[simp] theorem join_outside (p : Path branch root h)
(inside : PreliminarySampler.Questions branch h t m) (external : OutsideQuestions p t m)
(leaf : OutsideLeaf p) :
join p inside external leaf.val = external leaf := by
simp only [join, dite_eq_right leaf.property]
theorem join_restrict (p : Path branch root h)
(q : PreliminarySampler.Questions branch root t m) :
join p (restrict p q) (outside p q) = q := by
funext leaf
by_cases hleaf : leaf ∈ Set.range p.slotEmbedding
· simp only [join, dite_eq_left hleaf, restrict, Classical.choose_spec hleaf]
· simp only [join, dite_eq_right hleaf, outside]
def splitEquiv (p : Path branch root h) :
PreliminarySampler.Questions branch root t m ≃
PreliminarySampler.Questions branch h t m × OutsideQuestions p t m where
toFun q := (restrict p q, outside p q)
invFun parts := join p parts.1 parts.2
left_inv q := join_restrict p q
right_inv parts := by
apply Prod.ext
· funext leaf
exact join_at_cut p parts.1 parts.2 leaf
· funext leaf
exact join_outside p parts.1 parts.2 leaf
@[simp] theorem splitEquiv_apply (p : Path branch root h)
(q : PreliminarySampler.Questions branch root t m) :
splitEquiv p q = (restrict p q, outside p q) := rfl
@[simp] theorem splitEquiv_symm_apply (p : Path branch root h)
(inside : PreliminarySampler.Questions branch h t m) (external : OutsideQuestions p t m) :
(splitEquiv p).symm (inside, external) = join p inside external := rfl
theorem split_law [NeZero m] (p : Path branch root h) :
(PreliminarySampler.questionsLaw (branch := branch) (n := root) (t := t) (m := m)).pushforward
(splitEquiv p) =
(PreliminarySampler.questionsLaw (branch := branch) (n := h) (t := t) (m := m)).product
(FiniteDistribution.uniform (OutsideQuestions p t m)) := by
rw [FiniteDistribution.pushforward_equiv]
apply FiniteDistribution.eq_of_weight_eq
intro pair
change 1 / (Fintype.card (PreliminarySampler.Questions branch root t m) : ℝ) =
(1 / (Fintype.card (PreliminarySampler.Questions branch h t m) : ℝ)) *
(1 / (Fintype.card (OutsideQuestions p t m) : ℝ))
rw [Fintype.card_congr (splitEquiv (t := t) (m := m) p), Fintype.card_prod,
Nat.cast_mul, one_div_mul_one_div]
theorem join_eq_fill (p : Path branch root h)
(q : PreliminarySampler.Questions branch root t m)
(inside : PreliminarySampler.Questions branch h t m) :
join p inside (outside p q) = CutSlotAssembly.fill p q inside := by
funext leaf
by_cases hleaf : leaf ∈ Set.range p.slotEmbedding
· obtain ⟨s, rfl⟩ := hleaf
exact (join_at_cut p inside (outside p q) s).trans
(CutSlotAssembly.fill_at_cut p q inside s).symm
· exact (join_outside p inside (outside p q) ⟨leaf, hleaf⟩).trans
(CutSlotAssembly.fill_outside p q inside leaf hleaf).symm
variable {v : Nat} (clauses : Fin m → SourceClause.NormalizedClause v)
theorem sourceSlots_restrict (p : Path branch root h)
(q : PreliminarySampler.Questions branch root t m) :
HierarchicalArrays.sourceSlots clauses (PreliminarySampler.endpoints (restrict p q)) =
fun leaf j => HierarchicalArrays.sourceSlots clauses
(PreliminarySampler.endpoints q) (p.slotEmbedding leaf) j := rfl
theorem sourceSlots_fill (p : Path branch root h)
(q : PreliminarySampler.Questions branch root t m)
(inside : PreliminarySampler.Questions branch h t m) :
HierarchicalArrays.sourceSlots clauses
(PreliminarySampler.endpoints (CutSlotAssembly.fill p q inside)) =
CutSlotAssembly.fill p
(HierarchicalArrays.sourceSlots clauses (PreliminarySampler.endpoints q))
(HierarchicalArrays.sourceSlots clauses (PreliminarySampler.endpoints inside)) := by
funext leaf j
by_cases hleaf : leaf ∈ Set.range p.slotEmbedding
· obtain ⟨s, rfl⟩ := hleaf
exact (congrArg (fun row : Fin t → Fin m => SourceKeys.slot clauses (.clause (row j)))
(CutSlotAssembly.fill_at_cut p q inside s)).trans
(congrFun (CutSlotAssembly.fill_at_cut p
(HierarchicalArrays.sourceSlots clauses (PreliminarySampler.endpoints q))
(HierarchicalArrays.sourceSlots clauses (PreliminarySampler.endpoints inside)) s) j).symm
· exact (congrArg (fun row : Fin t → Fin m => SourceKeys.slot clauses (.clause (row j)))
(CutSlotAssembly.fill_outside p q inside leaf hleaf)).trans
(congrFun (CutSlotAssembly.fill_outside p
(HierarchicalArrays.sourceSlots clauses (PreliminarySampler.endpoints q))
(HierarchicalArrays.sourceSlots clauses (PreliminarySampler.endpoints inside)) leaf hleaf) j).symm
theorem sourceSlots_join (p : Path branch root h)
(q : PreliminarySampler.Questions branch root t m)
(inside : PreliminarySampler.Questions branch h t m) :
HierarchicalArrays.sourceSlots clauses (PreliminarySampler.endpoints (join p inside (outside p q))) =
CutSlotAssembly.fill p
(HierarchicalArrays.sourceSlots clauses (PreliminarySampler.endpoints q))
(HierarchicalArrays.sourceSlots clauses (PreliminarySampler.endpoints inside)) := by
rw [join_eq_fill]
exact sourceSlots_fill clauses p q inside
end
end PerfectCompleteness.SourceQuestionCutSplit
end
end OAI
|