File size: 5,744 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
import OAI.Computability.PerfectCompleteness.Construction.SourceChildKernelLemmas
import OAI.Computability.PerfectCompleteness.Construction.SourceQuestionPositionSplit

namespace OAI

section

namespace PerfectCompleteness.SourceQuestionKernelJoint

open scoped Classical
open RecursiveSpaces SourceQuestionPositionSplit
open UniqueGamesTheorem.Foundations.Games

noncomputable section

private theorem kernelJoint_pushforward_first {S T R : Type*}
    [Fintype S] [Fintype T] [Fintype R]
    (μ : FiniteDistribution S) (kernel : S → FiniteDistribution R) (e : S ≃ T) :
    (CleanConditioning.kernelJoint μ kernel).pushforward
        (Equiv.prodCongr e (Equiv.refl R)) =
      CleanConditioning.kernelJoint (μ.pushforward e) (fun s => kernel (e.symm s)) := by
  simp only [FiniteDistribution.pushforward_equiv]
  apply FiniteDistribution.eq_of_weight_eq
  intro point
  rfl

variable {branch : Nat → Nat} {n t v m : Nat}

abbrev ChoiceTuple :=
  Fin (branch n) → ChildPositions (branch := branch) (n := n) (t := t)

def sourceEquiv (designated : Fin (branch n) → Slots branch n) :
    SourceChildKernel.Sources (m := m) (t := t) designated ≃
      Questions (branch := branch) (n := n) (t := t) (m := m) ×
        ChoiceTuple (branch := branch) (n := n) (t := t) :=
  (SourceQuestionPositionSplit.split designated).trans
    (Equiv.prodCongr (Equiv.refl _) SourceQuestionPositionSplit.byChild)

def sources (designated : Fin (branch n) → Slots branch n)
    (q : Questions (branch := branch) (n := n) (t := t) (m := m))
    (choices : ChoiceTuple (branch := branch) (n := n) (t := t)) :
    SourceChildKernel.Sources (m := m) (t := t) designated :=
  (sourceEquiv designated).symm (q, choices)

@[simp] theorem sources_eq_join (designated : Fin (branch n) → Slots branch n)
    (q : Questions (branch := branch) (n := n) (t := t) (m := m))
    (choices : ChoiceTuple (branch := branch) (n := n) (t := t)) :
    sources designated q choices =
      SourceQuestionPositionSplit.join designated q
        (SourceQuestionPositionSplit.byChild.symm choices) := rfl

theorem sourceLaw_sourceEquiv [NeZero m]
    (designated : Fin (branch n) → Slots branch n) :
    (SourceChildQuestionLaw.sourceLaw m t designated).pushforward (sourceEquiv designated) =
      (PreliminarySampler.questionsLaw (branch := branch) (n := n + 1) (t := t) (m := m)).product
        (FiniteProduct.law (fun _ : Fin (branch n) =>
          FiniteDistribution.uniform (ChildPositions (branch := branch) (n := n) (t := t)))) := by
  calc
    _ = ((SourceChildQuestionLaw.sourceLaw m t designated).pushforward
        (SourceQuestionPositionSplit.split designated)).pushforward
          (Equiv.prodCongr (Equiv.refl _) SourceQuestionPositionSplit.byChild) := by
      rw [FiniteDistribution.pushforward_comp]
      rfl
    _ = _ := by
      rw [SourceQuestionPositionSplit.sourceLaw_split]
      change ((PreliminarySampler.questionsLaw
          (branch := branch) (n := n + 1) (t := t) (m := m)).product
          (FiniteDistribution.uniform (Positions (branch := branch) (n := n) (t := t)))).pushforward
        (fun x => (id x.1, SourceQuestionPositionSplit.byChild x.2)) = _
      rw [FiniteDistribution.product_pushforward, FiniteDistribution.pushforward_id,
        SourceQuestionPositionSplit.positions_byChild]

variable {C : Type*} [Fintype C]
  (rows : Nat → Nat) (clauses : Fin m → SourceClause.NormalizedClause v)
  (designated : Fin (branch n) → Slots branch n)

def groupEquiv :
    SourceChildKernel.Sample (C := C) (t := t) rows clauses designated ≃
      (Questions (branch := branch) (n := n) (t := t) (m := m) ×
        ChoiceTuple (branch := branch) (n := n) (t := t)) ×
          SourceChildKernelJoint.RawTuple (C := C) (t := t) rows clauses designated :=
  (SourceChildKernelJoint.groupEquiv rows clauses designated).trans
    (Equiv.prodCongr (sourceEquiv designated) (Equiv.refl _))

@[simp] theorem groupEquiv_raw
    (sample : SourceChildKernel.Sample (C := C) (t := t) rows clauses designated)
    (i : Fin (branch n)) :
    (groupEquiv rows clauses designated sample).2 i = (sample i).2.2 := rfl

theorem originalLaw_group [NeZero m]
    (flag : Fin (branch n) → FiniteDistribution Bool) :
    (SourceChildKernel.originalLaw (C := C) (t := t) rows clauses designated flag).pushforward
        (groupEquiv rows clauses designated) =
      CleanConditioning.kernelJoint
        ((PreliminarySampler.questionsLaw
          (branch := branch) (n := n + 1) (t := t) (m := m)).product
            (FiniteProduct.law (fun _ : Fin (branch n) =>
              FiniteDistribution.uniform
                (ChildPositions (branch := branch) (n := n) (t := t)))))
        (fun qp => FiniteProduct.law (fun i =>
          SourceChildKernel.kernel (C := C) (t := t) rows clauses designated flag i
            (sources designated qp.1 qp.2 i))) := by
  calc
    _ = ((SourceChildKernel.originalLaw (C := C) (t := t) rows clauses designated flag).pushforward
        (SourceChildKernelJoint.groupEquiv rows clauses designated)).pushforward
          (Equiv.prodCongr (sourceEquiv designated) (Equiv.refl _)) := by
      rw [FiniteDistribution.pushforward_comp]
      rfl
    _ = (CleanConditioning.kernelJoint (SourceChildQuestionLaw.sourceLaw m t designated)
        (fun source => FiniteProduct.law (fun i =>
          SourceChildKernel.kernel (C := C) (t := t) rows clauses designated flag i
            (source i)))).pushforward
          (Equiv.prodCongr (sourceEquiv designated) (Equiv.refl _)) := by
      rw [SourceChildKernelJoint.originalLaw_group]
      rfl
    _ = _ := by
      rw [kernelJoint_pushforward_first, sourceLaw_sourceEquiv]
      rfl

end
end PerfectCompleteness.SourceQuestionKernelJoint

end

end OAI