File size: 3,000 Bytes
e63eb7f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.Combinatorics.EditApproximation.Queries.QueryFamilyScalarReads
import OAI.Combinatorics.EditApproximation.Queries.QueryPhysicalSourceCosts

namespace OAI

namespace EditApproximation

section Family
variable {α : Type*} {M J R : ℕ} (target : List α)
  (N P F exponent H Q passes copies pass copy : ℕ)

theorem queryFamilyTagWithWork_cost (B : ℕ)
    (hp : Nat.size pass ≤ B) (hc : Nat.size copy ≤ B)
    (hps : Nat.size (passes + 1) ≤ B) (hcs : Nat.size (copies + 1) ≤ B)
    (scalar : PhysicalScalarKey M J N target.length exponent F Q R (localOnlineMassBound M P H)) :
    (queryFamilyTagWithWork target N P F exponent H Q passes copies pass copy scalar).2 ≤
      120 * (B + 1) ^ 2 + 5 * J + 55 := by
  have h1 := queryFinOfNatWithWork_cost (passes + 1) pass B (Nat.succ_pos _) hps hp
  have h2 := queryFinOfNatWithWork_cost (copies + 1) copy B (Nat.succ_pos _) hcs hc
  have h3 := physicalFamilyCodeWithWork_cost target N P F exponent H Q passes copies
    ((queryFinOfNatWithWork (passes + 1) pass (Nat.succ_pos _)).1,
      (queryFinOfNatWithWork (copies + 1) copy (Nat.succ_pos _)).1, scalar)
  change (queryFinOfNatWithWork (passes + 1) pass (Nat.succ_pos _)).2 +
    (queryFinOfNatWithWork (copies + 1) copy (Nat.succ_pos _)).2 + _ + 1 ≤ _
  omega

variable
  (oracle : PhysicalFamilyScalarKey (M := M) (J := J) (R := R)
    target N P F exponent H Q passes copies → BinaryFraction)
  (readWork : PhysicalFamilyScalarKey (M := M) (J := J) (R := R)
    target N P F exponent H Q passes copies → ℕ)
  (K W : ℕ)
  (hK : ∀ scalar : PhysicalScalarKey M J N target.length exponent F Q R (localOnlineMassBound M P H),
    (queryFamilyTagWithWork target N P F exponent H Q passes copies pass copy scalar).2 ≤ K)
  (hW : ∀ key, readWork key ≤ W)

include hK hW in
theorem queryFamilyGroupRead_work (node : PhysicalInternalNode M J) (time : Fin R)
    (key : GroupScalarKey M F Q) :
    (queryFamilyGroupRead target N P F exponent H Q passes copies pass copy node time key).work
      oracle readWork ≤ (queryScalePresentWithWork N key.1.1).2 +
        (queryCellValidWithWork target.length exponent key.1.2).2 + 5 * J + 43 + (K + W) := by
  unfold queryFamilyGroupRead
  rw [BitQuery.mapKeysWithWork_work]
  apply queryPhysicalScalarGroupRead_work
  intro scalar
  exact Nat.add_le_add (hK scalar) (hW _)

include hK hW in
theorem queryFamilyOnlineRead_work (node : PhysicalInternalNode M J) (time : Fin R)
    (key : ℕ × TargetInterval target.length) (range : ℕ) :
    (queryFamilyOnlineRead target N P F exponent H Q passes copies pass copy node time key range).work
      oracle readWork ≤ (queryScalePresentWithWork N key.1).2 +
        (queryRangeValidWithWork (localOnlineMassBound M P H) range).2 + 5 * J + 43 + (K + W) := by
  unfold queryFamilyOnlineRead
  rw [BitQuery.mapKeysWithWork_work]
  apply queryPhysicalScalarOnlineRead_work
  intro scalar
  exact Nat.add_le_add (hK scalar) (hW _)

end Family
end EditApproximation

end OAI