File size: 5,359 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
import OAI.Computability.PerfectCompleteness.Construction.SourceQuestionReconstruction
import OAI.Computability.PerfectCompleteness.Foundations.CutSlotAssembly

namespace OAI

section

namespace PerfectCompleteness.CleanEndpointSlots

noncomputable section

open scoped Classical
open RecursiveSpaces DescendantSpaces TreeSourceSpaces
open SourceQuestionReconstruction

variable {branch : Nat → Nat} {n h t v m : Nat} [NeZero m]
  (clauses : Fin m → SourceClause.NormalizedClause v)
  (designated : Fin (branch h) → Slots branch h)
  (clean : Fin (branch h) → Prop)
  (visible : Visible (E := SourceTuple m t) designated clean)

def leftInside (own : {i : Fin (branch h) // clean i} → Fin t → Fin m) :
    Slots branch (h + 1) → Fin t → MixedSupport.Slot :=
  fun s k => SourceKeys.slot clauses
    (reconstructLeft designated clean visible own s.1 s.2 k)

def rightInside (projected : Fin (branch h) → Bool)
    (own : {i : Fin (branch h) // clean i} → Fin t → Fin v) :
    Slots branch (h + 1) → Fin t → MixedSupport.Slot :=
  fun s k => SourceKeys.slot clauses
    (reconstructRight designated clean clauses projected visible own s.1 s.2 k)

omit [NeZero m] in
theorem leftInside_nonclean
    (own other : {i : Fin (branch h) // clean i} → Fin t → Fin m)
    (i : Fin (branch h)) (hi : ¬ clean i) (s : Slots branch h) :
    leftInside clauses designated clean visible own (i, s) =
      leftInside clauses designated clean visible other (i, s) := by
  funext k
  have hn : ¬ (clean i ∧ s = designated i) := fun h => hi h.1
  simp only [leftInside, reconstructLeft, reconstruct, dite_eq_right hn]

omit [NeZero m] in
theorem rightInside_nonclean (projected : Fin (branch h) → Bool)
    (own other : {i : Fin (branch h) // clean i} → Fin t → Fin v)
    (i : Fin (branch h)) (hi : ¬ clean i) (s : Slots branch h) :
    rightInside clauses designated clean visible projected own (i, s) =
      rightInside clauses designated clean visible projected other (i, s) := by
  funext k
  have hn : ¬ (clean i ∧ s = designated i) := fun h => hi h.1
  simp only [rightInside, reconstructRight, reconstruct, dite_eq_right hn]

def leftReference : Slots branch (h + 1) → Fin t → MixedSupport.Slot :=
  leftInside clauses designated clean visible (fun _ _ => 0)

def rightReference (projected : Fin (branch h) → Bool) :
    Slots branch (h + 1) → Fin t → MixedSupport.Slot :=
  rightInside clauses designated clean visible projected
    (fun _ _ => (clauses 0).variable 0)

variable (rows repeats : Nat → Nat) (p : Path branch n (h + 1))
  (outside : Slots branch n → Fin t → MixedSupport.Slot)

def leftSlots (own : {i : Fin (branch h) // clean i} → Fin t → Fin m) :=
  CutSlotAssembly.fill p outside (leftInside clauses designated clean visible own)

def rightSlots (projected : Fin (branch h) → Bool)
    (own : {i : Fin (branch h) // clean i} → Fin t → Fin v) :=
  CutSlotAssembly.fill p outside (rightInside clauses designated clean visible projected own)

omit [NeZero m] in
theorem leftSlots_kept_eq
    (own other : {i : Fin (branch h) // clean i} → Fin t → Fin m)
    (s : Slots branch n) (hs : CutSamplerKeyLocality.keptLeaf p clean s) :
    leftSlots clauses designated clean visible p outside own s =
      leftSlots clauses designated clean visible p outside other s :=
  CutSlotAssembly.fill_kept_eq p outside _ _ clean
    (leftInside_nonclean clauses designated clean visible own other) s hs

omit [NeZero m] in
theorem rightSlots_kept_eq (projected : Fin (branch h) → Bool)
    (own other : {i : Fin (branch h) // clean i} → Fin t → Fin v)
    (s : Slots branch n) (hs : CutSamplerKeyLocality.keptLeaf p clean s) :
    rightSlots clauses designated clean visible p outside projected own s =
      rightSlots clauses designated clean visible p outside projected other s :=
  CutSlotAssembly.fill_kept_eq p outside _ _ clean
    (rightInside_nonclean clauses designated clean visible projected own other) s hs

def leftReplay
    (record : WholeCutReplay.Tape rows repeats p
      (CutSlotAssembly.fill p outside (leftReference clauses designated clean visible)) clean)
    (own : {i : Fin (branch h) // clean i} → Fin t → Fin m) :
    WholeCutReplay.Tape rows repeats p
      (leftSlots clauses designated clean visible p outside own) clean :=
  CutSlotAssembly.transport rows repeats p outside
    (leftReference clauses designated clean visible)
    (leftInside clauses designated clean visible own) clean
    (leftInside_nonclean clauses designated clean visible (fun _ _ => 0) own) record

def rightReplay (projected : Fin (branch h) → Bool)
    (record : WholeCutReplay.Tape rows repeats p
      (CutSlotAssembly.fill p outside
        (rightReference clauses designated clean visible projected)) clean)
    (own : {i : Fin (branch h) // clean i} → Fin t → Fin v) :
    WholeCutReplay.Tape rows repeats p
      (rightSlots clauses designated clean visible p outside projected own) clean :=
  CutSlotAssembly.transport rows repeats p outside
    (rightReference clauses designated clean visible projected)
    (rightInside clauses designated clean visible projected own) clean
    (rightInside_nonclean clauses designated clean visible projected
      (fun _ _ => (clauses 0).variable 0) own) record

end
end PerfectCompleteness.CleanEndpointSlots

end

end OAI