File size: 4,346 Bytes
97c3405
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.Combinatorics.ContingencyTables.Counting.CompanionInitializedRestartProgram
import OAI.Combinatorics.ContingencyTables.Counting.CompanionRestartDataLaw
import OAI.Combinatorics.ContingencyTables.Counting.CompanionRestartScheduleSemantics

namespace OAI

/-! # Literal inputs and disjoint slices of initialized restarts -/
namespace ContingencyTables.CompanionInitializedRestartProgram
open MatchingFPRAS CommonBasesFPRAS FairBits DensePrograms
open CompanionFactorialApplication CompanionComputedInitial CompanionComputedProposal
open CompanionArithmeticProposal CompanionEvaluatedWeightProgram CompanionMultiplierMatrixProgram
open CompanionOracleDensity GridBoundary
open scoped BigOperators Classical
noncomputable section
variable {m n : ℕ}

def data (A : Instance (Fin m) (Fin n)) (C K H T N R L j : ℕ)
    (epsilon : TreeFraction.Fraction) (z : View A → ℕ)
    (v : Grid (I := Fin (RootedCatalogGrid.freeCount A)) K)
    (w : ℕ → LabelIndex A → LabelIndex A → TreeFraction.Fraction)
    (estimates : Fin j → TreeFraction.Fraction) (bits : List Bool) : Input :=
  ((CompanionRestartInitializer.data A C K H T N R L epsilon z v,
    List.ofFn (fun i : Fin j => (matrixCode (w (i.val+1)),estimates i))),bits)

lemma stages_data (A : Instance (Fin m) (Fin n)) (C K H T N R L j : ℕ)
    (epsilon : TreeFraction.Fraction) (z : View A → ℕ)
    (v : Grid (I := Fin (RootedCatalogGrid.freeCount A)) K)
    (w : ℕ → LabelIndex A → LabelIndex A → TreeFraction.Fraction)
    (estimates : Fin j → TreeFraction.Fraction) (bits : List Bool) :
    stages (data A C K H T N R L j epsilon z v w estimates bits)=
      CompanionRestartProgram.stagesData A C K j
        ([Fintype.card (Labels A),A.W,H,T,N,R,L],epsilon) z v (List.replicate bits.length false) w := by
  unfold stages indices data
  rw [List.length_ofFn,DirectedBFSCode.range_eq_map]
  simp only [List.map_map,Function.comp_def]
  rw [←List.ofFn_eq_map]
  apply congrArg List.ofFn
  funext i
  unfold stageAt reserve
  simp only [List.getD_eq_getElem?_getD,List.getElem?_ofFn,i.isLt,dite_true,Option.getD_some,
    List.map_const']
  rfl

lemma initialWidth_data (A : Instance (Fin m) (Fin n)) (C K H T N R L j : ℕ)
    (epsilon : TreeFraction.Fraction) (z : View A → ℕ)
    (v : Grid (I := Fin (RootedCatalogGrid.freeCount A)) K)
    (w : ℕ → LabelIndex A → LabelIndex A → TreeFraction.Fraction)
    (estimates : Fin j → TreeFraction.Fraction) (bits : List Bool) :
    initialWidth (data A C K H T N R L j epsilon z v w estimates bits)=
      wordLength A (CompanionInitialDraw.precision A (CountingPhaseSchedule.initialPrecision H)) :=
  CompanionRestartInitializer.width_data A C K H T N R L epsilon z v

 /-- Exact physical splitting: the initializer sees the first block,
 the restart loop sees the remaining block, and all markers are fixed. -/
theorem output_split (A : Instance (Fin m) (Fin n)) (C K H T N R L j s : ℕ)
    (epsilon : TreeFraction.Fraction) (z : View A → ℕ)
    (v : Grid (I := Fin (RootedCatalogGrid.freeCount A)) K)
    (w : ℕ → LabelIndex A → LabelIndex A → TreeFraction.Fraction)
    (estimates : Fin j → TreeFraction.Fraction)
    (bits : Fin (wordLength A (CompanionInitialDraw.precision A (CountingPhaseSchedule.initialPrecision H))+s) → Bool) :
    output (data A C K H T N R L j epsilon z v w estimates (List.ofFn bits))=
      CompanionRestartProgram.output
        ((CompanionRestartProgram.stagesData A C K j
          ([Fintype.card (Labels A),A.W,H,T,N,R,L],epsilon) z v
          (List.replicate (wordLength A (CompanionInitialDraw.precision A (CountingPhaseSchedule.initialPrecision H))+s) false) w,
          CompanionRestartInitializer.output
            (CompanionRestartInitializer.data A C K H T N R L epsilon z v,
              List.ofFn (splitWordEquiv
                (wordLength A (CompanionInitialDraw.precision A (CountingPhaseSchedule.initialPrecision H))) s bits).1)),
          List.ofFn (splitWordEquiv
            (wordLength A (CompanionInitialDraw.precision A (CountingPhaseSchedule.initialPrecision H))) s bits).2) := by
  unfold output prepare initialCode initialInput
  rw [stages_data,initialWidth_data,List.length_ofFn]
  dsimp only [data]
  rw [ofFn_split_take,ofFn_split_drop]

end
end ContingencyTables.CompanionInitializedRestartProgram

end OAI