File size: 7,379 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | import OAI.Combinatorics.EditApproximation.Binary.BitQuerySpace
import OAI.Combinatorics.EditApproximation.Queries.QueryInitialSupportSpace
import OAI.Combinatorics.EditApproximation.Queries.QueryHistorySpace
import OAI.Combinatorics.EditApproximation.Queries.QueryGroupSourceSpace
import OAI.Combinatorics.EditApproximation.Queries.QueryOnlineRangeSpace
import OAI.Combinatorics.EditApproximation.Queries.QueryBandGather
import OAI.Combinatorics.EditApproximation.Queries.QueryLocalBuffers
import OAI.Combinatorics.EditApproximation.Queries.QueryWarmupBuffers
import OAI.Combinatorics.EditApproximation.Definitions
namespace OAI
namespace EditApproximation
namespace BinaryFraction
theorem queryParentReadAllocation_le_work {n : β} (keys : List (TargetInterval n))
(words : List BinaryFraction) (r : TargetInterval n) :
queryParentReadAllocation keys words r β€ (queryParentReadWithWork keys words r).2 :=
gatheredLookupAllocation_le_work _ _ _ _ _ (fun k _ => queryIntervalEqualAllocation_le_work r k)
theorem queryBandInputsAllocation_le_work {nx ny : β} (M : β) (parent : TargetInterval nx)
(N P F exponent : β) (hP : 0 < P) (a : BinaryFraction)
(initial : TargetInterval ny β BinaryFraction Γ β) (allocation : TargetInterval ny β β)
(q : TargetInterval ny) (ha : β r, allocation r β€ (initial r).2) :
queryBandInputsAllocation M parent N P F exponent hP a initial allocation q β€
(queryBandInputsWithWork M parent N P F exponent hP a initial q).2 := by
have hr := queryEarlierRepresentativesAllocation_le_work N P F exponent hP a initial allocation q ha
have hw := queryWideInputsAllocation_le_work M parent P
(queryEarlierRepresentativesWithWork N P F exponent hP a initial q).1
unfold queryBandInputsAllocation queryBandInputsWithWork
dsimp only
omega
theorem queryWarmupInputsAllocation_le_work {nx ny : β} (M : β) (parent : TargetInterval nx)
(N P F : β) (a : BinaryFraction)
(initial : TargetInterval ny β BinaryFraction Γ β) (allocation : TargetInterval ny β β)
(q : TargetInterval ny) (ha : β r, allocation r β€ (initial r).2) :
queryWarmupInputsAllocation M parent N P F a initial allocation q β€
(queryWarmupInputsWithWork M parent N P F a initial q).2 := by
have hr := localRepresentativeReadAllocation_le_work N P F a initial allocation q ha
have hw := queryWideInputsAllocation_le_work M parent P (localRepresentativeReadWithWork N P F a initial q).1
unfold queryWarmupInputsAllocation queryWarmupInputsWithWork
dsimp only
omega
end BinaryFraction
open BitQuery
def queryInitialGatherHeap {ΞΉ Ξ² : Type*} {n : β} (N P F exponent : β) (hP : 0 < P)
(a : BinaryFraction) (q : TargetInterval n)
(reader : TargetInterval n β BitQuery ΞΉ BinaryFraction) (hr : β key, Heap (reader key))
(next : List (TargetInterval n) β List BinaryFraction β BitQuery ΞΉ Ξ²)
(hn : β keys words, Heap (next keys words)) :
Heap (queryInitialGather N P F exponent hP a q reader next) :=
(hr q).bind _ fun value =>
(Heap.computeOf (BinaryFraction.queryInitialSupportWithWork N P F exponent hP a value q)
(BinaryFraction.queryInitialSupportAllocation N P F exponent hP a value q)
(BinaryFraction.queryInitialSupportAllocation_le_work N P F exponent hP a value q)).bind _ fun keys =>
Heap.collect reader hr keys (next keys) (hn keys)
def queryBandGatherHeap {ΞΉ Ξ² : Type*} {nx ny : β} (M : β) (parent : TargetInterval nx)
(N P F exponent : β) (hP : 0 < P) (a : BinaryFraction)
(initial : TargetInterval ny β BinaryFraction Γ β) (allocation : TargetInterval ny β β)
(ha : β r, allocation r β€ (initial r).2) (q : TargetInterval ny)
(massReader initialReader : (Fin M Γ TargetInterval ny) β BitQuery ΞΉ BinaryFraction)
(hm : β key, Heap (massReader key)) (hi : β key, Heap (initialReader key))
(next : List (Fin M Γ TargetInterval ny) β List BinaryFraction β List BinaryFraction β BitQuery ΞΉ Ξ²)
(hn : β keys mass words, Heap (next keys mass words)) :
Heap (queryBandGather M parent N P F exponent hP a initial q massReader initialReader next) :=
(Heap.computeOf (BinaryFraction.queryBandInputsWithWork M parent N P F exponent hP a initial q)
(BinaryFraction.queryBandInputsAllocation M parent N P F exponent hP a initial allocation q)
(BinaryFraction.queryBandInputsAllocation_le_work M parent N P F exponent hP a initial allocation q ha)).bind _ fun keys =>
Heap.collect massReader hm keys _ fun mass => Heap.collect initialReader hi keys _ (hn keys mass)
def queryGroupSourceGatherHeap {ΞΉ Ξ² : Type*} {n : β} (M N F Q exponent eM eF : β)
(hM : M = 2 ^ eM) (hF : F = 2 ^ eF) (a : BinaryFraction)
(initial : TargetInterval n β BinaryFraction Γ β) (allocation : TargetInterval n β β)
(ha : β r, allocation r β€ (initial r).2) (q : TargetInterval n)
(reader : GroupScalarKey M F Q β BitQuery ΞΉ BinaryFraction) (hr : β key, Heap (reader key))
(next : List (GroupScalarKey M F Q) β List BinaryFraction β BitQuery ΞΉ Ξ²)
(hn : β keys words, Heap (next keys words)) :
Heap (queryGroupSourceGather M N F Q exponent eM eF hM hF a initial q reader next) :=
Heap.chargeOf (allocation q) (ha q)
((Heap.computeOf (BinaryFraction.queryGroupSourceKeysWithWork M N F Q exponent eM eF hM hF a (initial q).1 q)
(BinaryFraction.queryGroupSourceKeysAllocation M N F Q exponent eM eF hM hF a (initial q).1 q)
(BinaryFraction.queryGroupSourceKeysAllocation_le_work M N F Q exponent eM eF hM hF a (initial q).1 q)).bind _ fun keys =>
Heap.collect reader hr keys (next keys) (hn keys))
def queryOnlineSourceGatherHeap {ΞΉ Ξ² : Type*} {nx ny M : β} (parent : TargetInterval nx)
(N P F exponent H : β) (hP : 0 < P) (tau a : BinaryFraction)
(initial : TargetInterval ny β BinaryFraction Γ β) (initialAllocation : TargetInterval ny β β)
(child : Fin M β TargetInterval ny β BinaryFraction Γ β)
(childAllocation : Fin M β TargetInterval ny β β)
(hi : β r, initialAllocation r β€ (initial r).2)
(hc : β i r, childAllocation i r β€ (child i r).2) (q : TargetInterval ny)
(reader : (β Γ TargetInterval ny) β β β BitQuery ΞΉ BinaryFraction)
(hr : β key range, Heap (reader key range))
(next : List (β Γ TargetInterval ny) β List BinaryFraction β BitQuery ΞΉ Ξ²)
(hn : β keys words, Heap (next keys words)) :
Heap (queryOnlineSourceGather parent N P F exponent H hP tau a initial child q reader next) :=
Heap.chargeOf (initialAllocation q) (hi q)
((Heap.computeOf (BinaryFraction.queryOnlineKeysWithWork N P F hP a (initial q).1 q)
(BinaryFraction.queryOnlineKeysAllocation N P F hP a (initial q).1 q)
(BinaryFraction.queryOnlineKeysAllocation_le_work N P F hP a (initial q).1 q)).bind _ fun keys =>
Heap.collect _ (fun key =>
(Heap.computeOf (BinaryFraction.queryOnlineRangeWithWork parent P exponent H tau child key)
(BinaryFraction.queryOnlineRangeAllocation parent P exponent H tau child childAllocation key)
(BinaryFraction.queryOnlineRangeAllocation_le_work parent P exponent H tau child childAllocation key hc)).bind _ (hr key))
keys (next keys) (hn keys))
end EditApproximation
end OAI
|