File size: 5,353 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
import OAI.Combinatorics.EditApproximation.Refinement.ComputedGlobalSourceCost
import OAI.Combinatorics.EditApproximation.Geometry.ChargedRandomCost
import OAI.Combinatorics.EditApproximation.Geometry.ChargedTerminalCost

namespace OAI

namespace EditApproximation

section Cost

variable {Οƒ Ξ± : Type*} [DecidableEq Ξ±] {M J R : β„•} [NeZero M] [NeZero R]
  (source target : List Ξ±) (N P H T S passes copies : β„•)
  (factor : β„• β†’ β„š) (multiplier : β„• β†’ β„•) (tau eta kappa delta : β„š)
  (group : β„• β†’ β„• β†’ PhysicalInternalNode M J β†’ Fin R β†’
    CellGroupDraws M (inputSmallLog N) (inputSmallLog N ^ 80))
  (integer : β„• β†’ β„• β†’ PhysicalInternalNode M J β†’ Fin R β†’ β„• β†’ TargetInterval target.length β†’ β„•)
  (initial : PhysicalEntry M J target.length β†’ β„•)
  (readGroup : β„• β†’ β„• β†’ PhysicalInternalNode M J β†’ Fin R β†’
    GroupScalarKey M (inputSmallLog N) (inputSmallLog N ^ 80) β†’ FiniteQuery Οƒ)
  (readInteger : β„• β†’ β„• β†’ PhysicalInternalNode M J β†’ Fin R β†’
    (β„• Γ— TargetInterval target.length) β†’ β„• β†’ FiniteQuery Οƒ)
  (sourceAnswer : Οƒ β†’ β„š) (weight : Οƒ β†’ β„•) (bound : β„•)
  (hN : 0 < N) (hell : 200 ≀ inputSmallLog N) (hM : M = (integerParameters N).M)
  (hA : βˆ€ pass, factor pass ≀ ((integerParameters N).initialFactor : β„š))
  (hgroup : βˆ€ pass copy node time key, (readGroup pass copy node time key).cost sourceAnswer weight ≀ bound)
  (honline : βˆ€ pass copy node time key range,
    (readInteger pass copy node time key range).cost sourceAnswer weight ≀ bound)

local notation "tableValue" => localRequestValue source target N P (inputSmallLog N)
  (40 * smallLogExponent N) H (inputSmallLog N ^ 80) T S copies factor multiplier
    tau eta kappa delta group integer initial

include hN hell hM hA hgroup honline in
 theorem computed_chargedRandomGlobalQuery_source_cost
    (request : ChargedPhysicalRequest M J target.length passes copies T S) :
    (chargedRandomGlobalQuery source target N P (inputSmallLog N) (40 * smallLogExponent N)
      H (inputSmallLog N ^ 80) T S passes copies factor multiplier tau eta kappa delta
      readGroup readInteger initial request).cost
      (Sum.elim sourceAnswer (fun child => chargedRequestValue source target N P (inputSmallLog N)
        (40 * smallLogExponent N) H (inputSmallLog N ^ 80) T S passes copies factor multiplier
          tau eta kappa delta group integer initial child.val))
      (Sum.elim weight (fun _ => 0)) ≀ inputHeight N ^ 91 * bound := by
  cases request with
  | inl entry => exact Nat.zero_le _
  | inr parent =>
    by_cases hi : parent.val.index ≀ T
    Β· unfold chargedRandomGlobalQuery
      dsimp only
      rw [ite_eq_left hi, FiniteQuery.mapKeys_cost]
      simp only [Function.comp_def, Sum.elim_inr]
      rw [FiniteQuery.cost_zero]
      exact Nat.zero_le _
    Β· by_cases hb : parent.val.node.1.val < J
      Β· by_cases hs : (physicalSourceInterval source.length parent.val.node).hi -
            (physicalSourceInterval source.length parent.val.node).lo ≀ 1
        Β· unfold chargedRandomGlobalQuery
          dsimp only
          rw [ite_eq_right hi, ite_eq_left hb, ite_eq_left hs, FiniteQuery.mapKeys_cost]
          simp only [Function.comp_def, Sum.elim_inr]
          rw [FiniteQuery.cost_zero]
          exact Nat.zero_le _
        Β· have hanswer : chargedRequestValue source target N P (inputSmallLog N)
              (40 * smallLogExponent N) H (inputSmallLog N ^ 80) T S passes copies factor multiplier
              tau eta kappa delta group integer initial =
              Sum.elim (fun entry => (initial entry : β„š)) (fun r => tableValue r.val) := by
            funext key
            cases key <;> rfl
          have hz : (fun _ : ChargedPhysicalRequest M J target.length passes copies T S => 0) =
              chargedTableWeight 0 (fun _ => 0) := by
            funext key
            cases key <;> rfl
          rw [hanswer]
          have hcost := chargedRandomGlobalQuery_refinement_cost source target N P (inputSmallLog N)
            (40 * smallLogExponent N) H (inputSmallLog N ^ 80) T S passes copies factor multiplier
            tau eta kappa delta readGroup readInteger initial sourceAnswer tableValue weight 0 (fun _ => 0)
            parent (by omega) hb hs
          simp only [← hz] at hcost
          rw [hcost]
          rw [← physicalRandomGlobalQuery_refinement_cost source target N P (inputSmallLog N)
            (40 * smallLogExponent N) H (inputSmallLog N ^ 80) T S copies factor multiplier
            tau eta kappa delta readGroup readInteger initial sourceAnswer tableValue weight (fun _ => 0)
            parent.val (by omega) hb hs]
          apply computed_physicalRandomGlobalQuery_source_cost source target N P H T S copies
            hN hell hM factor multiplier tau eta kappa delta hA readGroup readInteger initial
            sourceAnswer tableValue weight bound hgroup honline
          intro pass copy node q
          rw [localRequestValue_initial]
          exact stageInitial_nonneg_all_seeds _ _ _ _ _ _ _ _
      Β· unfold chargedRandomGlobalQuery
        dsimp only
        rw [ite_eq_right hi, ite_eq_right hb, FiniteQuery.mapKeys_cost]
        simp only [Function.comp_def, Sum.elim_inr]
        rw [FiniteQuery.cost_zero]
        exact Nat.zero_le _

end Cost

end EditApproximation

end OAI