math / data /lean /OAI /Combinatorics /EditApproximation /Queries /QueryBandGather.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
3.69 kB
import OAI.Combinatorics.EditApproximation.Queries.QueryInitialGather
import OAI.Combinatorics.EditApproximation.Queries.QueryRepresentatives
import OAI.Combinatorics.EditApproximation.Definitions
namespace OAI
/-! The band-data stage constructs its keys by counted Boolean routines,
then gathers mass and initial words in the reference order. -/
namespace EditApproximation
theorem queryBandGather_refines {ΞΉ Ξ² : Type*} {nx ny : β„•} {relation : Ξ² β†’ β„š β†’ Prop}
(M : β„•) (parent : TargetInterval nx) (N P F exponent : β„•) (hP : 0 < P)
(a : BinaryFraction) (initial : TargetInterval ny β†’ BinaryFraction Γ— β„•) (q : TargetInterval ny)
(R : β„•) (hR : βˆ€ r, (initial r).2 ≀ R)
(massReader initialReader : (Fin M Γ— TargetInterval ny) β†’ BitQuery ΞΉ BinaryFraction)
(expectedMass expectedInitial : (Fin M Γ— TargetInterval ny) β†’ FiniteQuery ΞΉ)
(next : List (Fin M Γ— TargetInterval ny) β†’ List BinaryFraction β†’ List BinaryFraction β†’
BitQuery ΞΉ Ξ²)
(expectedNext : List (Fin M Γ— TargetInterval ny) β†’ List β„š β†’ List β„š β†’ FiniteQuery ΞΉ)
(hm : βˆ€ key, BitQuery.Refines (fun word value => word.value = value)
(massReader key) (expectedMass key))
(hi : βˆ€ key, BitQuery.Refines (fun word value => word.value = value)
(initialReader key) (expectedInitial key))
(hn : βˆ€ mass words,
let keys := refinementBandInputList (M := M) parent N P F exponent a.value
(fun r => (initial r).1.value) q
BitQuery.Refines relation (next keys mass words)
(expectedNext keys (mass.map BinaryFraction.value) (words.map BinaryFraction.value))) :
BitQuery.Refines relation
(queryBandGather M parent N P F exponent hP a initial q massReader initialReader next)
(let keys := refinementBandInputList (M := M) parent N P F exponent a.value
(fun r => (initial r).1.value) q
FiniteQuery.collect expectedMass keys fun mass =>
FiniteQuery.collect expectedInitial keys (expectedNext keys mass)) := by
change BitQuery.Refines relation (.charge _ _) _
apply BitQuery.Refines.charge
change BitQuery.Refines relation (BitQuery.collect massReader _ _) _
rw [BinaryFraction.queryBandInputsWithWork_value M parent N P F exponent hP a initial q R hR]
apply BitQuery.Refines.collect massReader expectedMass hm
intro mass
exact BitQuery.Refines.collect initialReader expectedInitial hi _ _ _ (hn mass)
theorem queryBandGather_work {ΞΉ Ξ² : Type*} {nx ny : β„•} (M : β„•) (parent : TargetInterval nx)
(N P F exponent : β„•) (hP : 0 < P) (a : BinaryFraction)
(initial : TargetInterval ny β†’ BinaryFraction Γ— β„•) (q : TargetInterval ny)
(massReader initialReader : (Fin M Γ— TargetInterval ny) β†’ BitQuery ΞΉ BinaryFraction)
(next : List (Fin M Γ— TargetInterval ny) β†’ List BinaryFraction β†’ List BinaryFraction β†’
BitQuery ΞΉ Ξ²) (oracle : ΞΉ β†’ BinaryFraction) (readWork : ΞΉ β†’ β„•) :
let keys := BinaryFraction.queryBandInputsWithWork M parent N P F exponent hP a initial q
(queryBandGather M parent N P F exponent hP a initial q massReader initialReader next).work
oracle readWork = keys.2 +
(keys.1.map fun key => (massReader key).work oracle readWork + 3).sum +
(keys.1.map fun key => (initialReader key).work oracle readWork + 3).sum +
(next keys.1 (keys.1.map fun key => (massReader key).value oracle)
(keys.1.map fun key => (initialReader key).value oracle)).work oracle readWork := by
simp only [queryBandGather, BitQuery.work_bind, BitQuery.compute,
BitQuery.work, BitQuery.value, BitQuery.work_collect, Nat.add_zero, Nat.add_assoc]
end EditApproximation
end OAI