File size: 4,921 Bytes
4a56cd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.Computability.PerfectCompleteness.Sampling.CutSamplerKeyLocalityLemmas

namespace OAI

section

namespace PerfectCompleteness.LowerCutScalar

open RecursiveSpaces DescendantSpaces RecursiveSampler TerminalCalls

noncomputable section

universe u w

variable {branch : Nat β†’ Nat} {n m : Nat}

abbrev Values (π•œ : Type w) [Field π•œ] (repeats : Nat β†’ Nat)
    (p : Path branch n (m + 1)) (A : Slots branch n β†’ Type u) :=
  TerminalIndex repeats p β†’ space π•œ branch (m + 1) (p.family A)

def reconstruct (π•œ : Type w) [Field π•œ] (repeats : Nat β†’ Nat) :
    {n m : Nat} β†’ (p : Path branch n (m + 1)) β†’ (A : Slots branch n β†’ Type u) β†’
      Values π•œ repeats p A β†’ CutTerminalSplit.ExteriorTape π•œ repeats p A β†’
        space π•œ branch n A
  | _, _, .refl _, _, values, _ => values ()
  | n + 1, _, .step i p, A, values, exterior =>
      RecursiveSampler.combine π•œ A i (repeats (n + 1))
        (fun j => exterior ⟨.inl j, not_isTerminal_ordinary repeats i p j⟩)
        (fun h => reconstruct π•œ repeats p (childFamily A i)
          (fun terminal => values ((h, false), terminal))
          (CutSamplerReplayGrouping.subExterior π•œ repeats i p A (h, false) exterior))
        (fun h => reconstruct π•œ repeats p (childFamily A i)
          (fun terminal => values ((h, true), terminal))
          (CutSamplerReplayGrouping.subExterior π•œ repeats i p A (h, true) exterior))

@[simp] theorem reconstruct_refl (π•œ : Type w) [Field π•œ] (repeats : Nat β†’ Nat)
    (A : Slots branch (m + 1) β†’ Type u)
    (values : Values π•œ repeats (.refl (m + 1)) A)
    (exterior : CutTerminalSplit.ExteriorTape π•œ repeats (.refl (m + 1)) A) :
    reconstruct π•œ repeats (.refl (m + 1)) A values exterior = values () := rfl

theorem reconstruct_step (π•œ : Type w) [Field π•œ] (repeats : Nat β†’ Nat)
    (i : Fin (branch n)) (p : Path branch n (m + 1))
    (A : Slots branch (n + 1) β†’ Type u)
    (values : Values π•œ repeats (.step i p) A)
    (exterior : CutTerminalSplit.ExteriorTape π•œ repeats (.step i p) A) :
    reconstruct π•œ repeats (.step i p) A values exterior =
      RecursiveSampler.combine π•œ A i (repeats (n + 1))
        (fun j => exterior ⟨.inl j, not_isTerminal_ordinary repeats i p j⟩)
        (fun h => reconstruct π•œ repeats p (childFamily A i)
          (fun terminal => values ((h, false), terminal))
          (CutSamplerReplayGrouping.subExterior π•œ repeats i p A (h, false) exterior))
        (fun h => reconstruct π•œ repeats p (childFamily A i)
          (fun terminal => values ((h, true), terminal))
          (CutSamplerReplayGrouping.subExterior π•œ repeats i p A (h, true) exterior)) := rfl

theorem reconstruct_splitTape (π•œ : Type w) [Field π•œ]
    (repeats : Nat β†’ Nat) (p : Path branch n (m + 1)) :
    βˆ€ (A : Slots branch n β†’ Type u)
      (tape : CutSamplerRefinement.Tape π•œ repeats p A),
      reconstruct π•œ repeats p A
          (fun terminal => UniformChildSum.recursiveSum (p.family A)
            ((CutTerminalSplit.splitTape π•œ repeats p A tape).1 terminal))
          (CutTerminalSplit.splitTape π•œ repeats p A tape).2 =
        CutSamplerRefinement.evaluate π•œ repeats p A tape := by
  induction n generalizing m with
  | zero =>
      have h := p.height_le
      omega
  | succ n ih =>
      cases p with
      | refl =>
          intro A tape
          rfl
      | step i p =>
          intro A tape
          rw [reconstruct_step, CutSamplerLocality.evaluate_step]
          apply congrArgβ‚‚ (RecursiveSampler.combine π•œ A i (repeats (n + 1))
            (fun j => tape (.inl j)))
          Β· funext h
            rw [CutSamplerReplayGrouping.subExterior_splitTape]
            simp_rw [CutTerminalZero.splitTape_terminal_step]
            exact ih p (childFamily A i)
              (CutSamplerLocality.subTape π•œ repeats i p A tape h false)
          Β· funext h
            rw [CutSamplerReplayGrouping.subExterior_splitTape]
            simp_rw [CutTerminalZero.splitTape_terminal_step]
            exact ih p (childFamily A i)
              (CutSamplerLocality.subTape π•œ repeats i p A tape h true)

theorem reconstruct_join (π•œ : Type w) [Field π•œ] (repeats : Nat β†’ Nat)
    (p : Path branch n (m + 1)) (A : Slots branch n β†’ Type u)
    (terminal : CutTerminalSplit.TerminalTape π•œ repeats p A)
    (exterior : CutTerminalSplit.ExteriorTape π•œ repeats p A) :
    reconstruct π•œ repeats p A
        (fun call => UniformChildSum.recursiveSum (p.family A) (terminal call)) exterior =
      CutSamplerRefinement.evaluate π•œ repeats p A
        ((CutTerminalSplit.splitTape π•œ repeats p A).symm (terminal, exterior)) := by
  simpa only [Equiv.apply_symm_apply] using
    reconstruct_splitTape π•œ repeats p A
      ((CutTerminalSplit.splitTape π•œ repeats p A).symm (terminal, exterior))

end
end PerfectCompleteness.LowerCutScalar

end

end OAI