math / data /lean /OAI /Combinatorics /EditApproximation /Queries /QueryGatherSpace.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
7.38 kB
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