File size: 6,988 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 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 120 121 122 123 124 125 126 127 128 129 130 131 132 | import OAI.Combinatorics.EditApproximation.Queries.QueryFamilyActive
import OAI.Combinatorics.EditApproximation.Queries.QueryFamilyRefinementCost
import OAI.Combinatorics.EditApproximation.Queries.QueryPhysicalProgramWidth
import OAI.Combinatorics.EditApproximation.Queries.QuerySemanticRestriction
namespace OAI
namespace EditApproximation
section Transport
variable {M J n : ℕ} (T : ℕ) (request : PhysicalTableRequest M J n)
(hindex : T < request.index)
include hindex in
theorem queryRefinementRequest_eq :
PhysicalTableRequest.refinement request.pass request.copy request.node T (request.index - T)
request.state = request := by
have hi : T + (request.index - T) = request.index := by omega
unfold PhysicalTableRequest.refinement
rw [hi]
def queryActiveChildMap {σ : Type*} (S : ℕ) :
Sum σ {child : PhysicalTableRequest M J n // child.combinedRank T S <
(PhysicalTableRequest.refinement request.pass request.copy request.node T (request.index - T)
request.state).combinedRank T S} →
Sum σ {child : PhysicalTableRequest M J n // child.combinedRank T S < request.combinedRank T S} :=
Sum.map id (fun child => ⟨child.val, by simpa only [queryRefinementRequest_eq T request hindex] using child.property⟩)
def queryActiveOracle {σ : Type*} (S : ℕ)
(oracle : Sum σ {child : PhysicalTableRequest M J n // child.combinedRank T S < request.combinedRank T S} →
BinaryFraction) := fun key => oracle (queryActiveChildMap T request hindex S key)
def queryActiveReadWork {σ : Type*} (S : ℕ)
(readWork : Sum σ {child : PhysicalTableRequest M J n // child.combinedRank T S < request.combinedRank T S} →
ℕ) := fun key => 1 + readWork (queryActiveChildMap T request hindex S key)
end Transport
section Active
variable {α : Type*} {M J R : ℕ} [NeZero M] [NeZero R]
(source target : List α) (N P F exponent H Q eM eF B E Scale : ℕ)
(hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF)
(tau a eta kappa delta : BinaryFraction) (T S passes copies : ℕ)
(request : PhysicalTableRequest M J target.length)
(hindex : T < request.index) (hbelow : request.node.1.val < J)
(oracle : Sum (PhysicalFamilyScalarKey (M := M) (J := J) (R := R)
target N P F exponent H Q passes copies)
{child : PhysicalTableRequest M J target.length // child.combinedRank T S < request.combinedRank T S} → BinaryFraction)
(readWork : Sum (PhysicalFamilyScalarKey (M := M) (J := J) (R := R)
target N P F exponent H Q passes copies)
{child : PhysicalTableRequest M J target.length // child.combinedRank T S < request.combinedRank T S} → ℕ)
local notation "tableOracle" => (fun key => queryActiveOracle T request hindex S oracle (Sum.inr key))
open BinaryFraction
theorem queryFamilyActive_work_bound (V C : ℕ)
(hn : PreparedKernelNumericBounds (nx := source.length) (ny := target.length) (M := M)
N P F exponent H Q eM eF B E Scale (request.index - T - 1) tau a eta kappa delta (fun _ _ => 0))
(htime : Nat.size (request.index - T) ≤ B) (hPd : ∃ j : ℕ, P = 2 ^ j)
(hV : 2 ≤ V) (hVB : V ≤ B) (hMean : warmupAverageWordBudget T V ≤ B)
(hc : ∀ key, key.val.pass = request.pass → key.val.copy = request.copy → readWork (Sum.inr key) ≤ C)
(hs : ∀ key, readWork (Sum.inl key) ≤ C)
(hv : ∀ key, (oracle (Sum.inr key)).width ≤ V)
(hsv : ∀ key, (oracle (Sum.inl key)).width ≤ B)
(hnonneg : ∀ key, 0 ≤ (oracle (Sum.inr key)).value)
(hprior : ∀ input : Fin M × ℕ × TargetInterval target.length,
((queryPhysicalEarlierRead copies request.pass request.copy T S (request.index - T)
request.node hbelow request.state input).value tableOracle).value ≤
((queryPhysicalWarmupRead copies request.pass request.copy T S (request.index - T)
(Nat.sub_pos_of_lt hindex) request.node request.state
(physicalChild request.node hbelow input.1) (by change request.node.1.val ≤ request.node.1.val + 1; omega)
0 (Nat.zero_le T) input.2.2).value tableOracle).value)
(hp : Nat.size request.pass ≤ B) (hcopy : Nat.size request.copy ≤ B)
(hps : Nat.size (passes + 1) ≤ B) (hcs : Nat.size (copies + 1) ≤ B)
(hbound : Nat.size (localOnlineMassBound M P H) ≤ B) :
(queryFamilyActive (R := R) source target N P F exponent H Q eM eF hP hM hF
tau a eta kappa delta T S passes copies request hindex hbelow).work oracle readWork ≤
queryLocalProgramBitBudget M N P F exponent eM eF B Scale (request.index - T)
(queryPhysicalDataBudget T J B V (C + 1) (queryFamilySourceReadBudget J B (C + 1 + 1))) := by
rw [queryFamilyActive, BitQuery.mapKeysWithWork_work]
change (queryFamilyRefinement (R := R) source target N P F exponent H Q eM eF hP hM hF
tau a eta kappa delta passes copies request.pass request.copy T S (request.index - T)
(Nat.sub_pos_of_lt hindex) request.node hbelow (Fin.ofNat R (request.index - T - 1)) request.state).work
(queryActiveOracle T request hindex S oracle) (queryActiveReadWork T request hindex S readWork) ≤ _
apply queryFamilyRefinement_work_bound source target N P F exponent H Q eM eF B E Scale hP hM hF
tau a eta kappa delta passes copies request.pass request.copy T S (request.index - T)
(Nat.sub_pos_of_lt hindex) request.node hbelow (Fin.ofNat R (request.index - T - 1)) request.state
_ _ V (C + 1) hn htime hPd hV hVB hMean
· intro key hpass hcopy'
have h := hc ⟨key.val, by simpa only [queryRefinementRequest_eq T request hindex] using key.property⟩ hpass hcopy'
change 1 + readWork (Sum.inr ⟨key.val, _⟩) ≤ C + 1
omega
· intro key
change 1 + readWork (Sum.inl key) ≤ C + 1
have := hs key
omega
· intro key
exact hv _
· exact hsv
· intro key
exact hnonneg _
· exact hprior
· exact hp
· exact hcopy
· exact hps
· exact hcs
· exact hbound
theorem queryFamilyActive_width
(hn : PreparedKernelNumericBounds (nx := source.length) (ny := target.length) (M := M)
N P F exponent H Q eM eF B E Scale (request.index - T - 1) tau a eta kappa delta (fun _ _ => 0))
(htime : Nat.size (request.index - T) ≤ B)
(hv : ∀ key, (oracle (Sum.inr key)).width ≤ B)
(hnonneg : ∀ key, 0 ≤ (oracle (Sum.inr key)).value) :
((queryFamilyActive (R := R) source target N P F exponent H Q eM eF hP hM hF
tau a eta kappa delta T S passes copies request hindex hbelow).value oracle).width ≤
preparedKernelWordBudget M B := by
rw [queryFamilyActive, BitQuery.mapKeysWithWork_value]
apply queryFamilyRefinement_width source target N P F exponent H Q eM eF B E Scale hP hM hF
tau a eta kappa delta passes copies request.pass request.copy T S (request.index - T)
(Nat.sub_pos_of_lt hindex) request.node hbelow (Fin.ofNat R (request.index - T - 1)) request.state
_ hn htime
· intro key
exact hv _
· intro key
exact hnonneg _
end Active
end EditApproximation
end OAI
|