File size: 3,555 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 | import OAI.Combinatorics.EditApproximation.Queries.QueryBufferedSharedCost
namespace OAI
namespace EditApproximation.BinaryFraction
theorem queryBufferedGroupReadCost {n M N F Q : β} [NeZero M]
(exponent eM eF B V : β) (hMdef : M = 2 ^ eM) (hFdef : F = 2 ^ eF)
(a value : BinaryFraction) (q : TargetInterval n) (words : List BinaryFraction)
(hB : 7 β€ B) (hN : Nat.size N β€ B) (hF : Nat.size F + 2 β€ B)
(hM : Nat.size M + 2 β€ B) (hQ : Nat.size Q + 2 β€ B) (hes : eM + eF + 7 β€ B)
(he : exponent + 1 β€ B) (hn : Nat.size n β€ B) (ha : a.width β€ B)
(hv : value.width β€ B) (hw : 0 β€ value.value) (hV : 2 β€ V)
(hwords : β v β words, v.width β€ V) :
let keys := (queryGroupSourceKeysWithWork M N F Q exponent eM eF hMdef hFdef a value q).1
β eb β List.range (max 1 N.bits.length),
(refinementScaleGuardWithWork F (2 ^ eb) a value).1 = true β
β cell β (targetCellsWithWork
(canonicalMulWithWork (inversePowerTwo exponent) (nat (2 ^ eb))).1
(bitWordValue (naturalCeilingWithWork value).1) q).1,
β scale sample, (queryGroupDrawReadWithWork keys words (2 ^ eb) cell scale sample).2 β€
queryBufferedGroupReadBudget M F exponent eM eF B V := by
dsimp only
intro eb heb hg cell hc scale sample
have hk := (queryGroupSourceKeysWithWork_bounds M N F Q exponent eM eF B hMdef hFdef a value q
hB hN hF hM hQ hes he hn ha hv hw).1
have hr := queryGroupDrawReadWithWork_scoped_cost exponent eM eF B V hMdef hFdef a value q words
hB hN hF (by omega) (by omega) he hn ha hv hw hV hwords eb heb hg cell hc scale sample
apply hr.trans
unfold queryBufferedGroupReadBudget queryGroupBufferReadBudget
gcongr
theorem queryBufferedOnlineReadCost {n : β} (N P F B V : β) (hP : 0 < P)
(a value : BinaryFraction) (q : TargetInterval n) (words : List BinaryFraction)
(hB : 7 β€ B) (hN : Nat.size N β€ B) (hF : Nat.size F + 2 β€ B) (hFpos : 1 β€ F)
(hPb : Nat.size P β€ B) (hn : Nat.size n β€ B) (ha : a.width β€ B) (hv : value.width β€ B)
(hV : 2 β€ V) (hwords : β v β words, v.width β€ V) :
let keys := (queryOnlineKeysWithWork N P F hP a value q).1
β e β (queryExponentsWithWork N F a value).1,
(queryOnlineIntegerReadWithWork keys words (2 ^ e)
(roundStateWithWork (bitWordValue (seedGridSpacingWithWork (2 ^ e) P).1)
(seedGridSpacingWithWork_pos (2 ^ e) P hP) q).1).2 β€
queryOnlineBufferReadBudget (B + 1) B V := by
dsimp only
intro e he
have hk := (queryOnlineKeysWithWork_bounds N P F B hP a value q hB hN hF hFpos hPb hn ha hv).1
have hr := queryOnlineIntegerReadWithWork_scoped_cost N P F B V hP a value q words
hN hFpos hn hV hwords e he
apply hr.trans
unfold queryOnlineBufferReadBudget
gcongr
theorem queryOnlineIntegerReadWithWork_size {n : β}
(keys : List (β Γ TargetInterval n)) (words : List BinaryFraction) (b : β) (q : TargetInterval n)
(V : β) (hV : 2 β€ V) (hwords : β v β words, v.width β€ V) :
Nat.size (queryOnlineIntegerReadWithWork keys words b q).1 β€ V := by
let word := gatheredWordLookupWithWork queryOnlineKeyEqualWithWork keys words (b, q)
have hw : word.1.width β€ V := gatheredWordLookupWithWork_width _ keys words _ V hV hwords
have hf := (naturalFloorWithWork_bounds word.1).1
change Nat.size (bitWordValue (naturalFloorWithWork word.1).1) β€ V
exact (Nat.size_le.mpr (bitWordValue_lt_pow_length _)).trans (hf.trans hw)
end EditApproximation.BinaryFraction
end OAI
|