Download data/lean/OAI/Combinatorics/EditApproximation/Queries/QueryDataBuffers.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 3.76 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditApproximation/Queries/QueryDataBuffers.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/EditApproximation/Queries/QueryDataBuffers.lean
-
curl -L -o QueryDataBuffers.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditApproximation/Queries/QueryDataBuffers.lean
3.76 kB
| import OAI.Combinatorics.EditApproximation.Queries.QuerySourceBuffers | |
| import OAI.Combinatorics.EditApproximation.Definitions | |
| namespace OAI | |
| /-! Counted local data buffers for the adaptive gathers. Bounds depend on | |
| stored keys and the requested key, not on an unbounded ambient key type. -/ | |
| namespace EditApproximation | |
| namespace BinaryFraction | |
| theorem gatheredWordLookupWithWork_cost_on {ΞΊ : Type*} | |
| (equal : ΞΊ β ΞΊ β Bool Γ β) (C : β) (keys : List ΞΊ) | |
| (values : List BinaryFraction) (query : ΞΊ) | |
| (hC : β key β keys, (equal query key).2 β€ C) : | |
| (gatheredWordLookupWithWork equal keys values query).2 β€ | |
| 1 + keys.length * (C + 1) := by | |
| induction keys generalizing values with | |
| | nil => simp only [gatheredWordLookupWithWork, List.length_nil, Nat.zero_mul, Nat.add_zero, le_rfl] | |
| | cons key keys ih => | |
| have hc := hC key List.mem_cons_self | |
| have ht := ih (values.drop 1) (fun k hk => hC k (List.mem_cons_of_mem _ hk)) | |
| cases values with | |
| | nil => simp only [gatheredWordLookupWithWork]; omega | |
| | cons value values => | |
| simp only [List.drop_succ_cons, List.drop_zero] at ht | |
| simp only [gatheredWordLookupWithWork] | |
| split_ifs <;> simp only [List.length_cons, Nat.add_mul, Nat.one_mul] <;> omega | |
| @[simp] theorem queryChildReadWithWork_value {M n : β} | |
| (keys : List (Fin M Γ TargetInterval n)) (values : List BinaryFraction) | |
| (i : Fin M) (q : TargetInterval n) : | |
| (queryChildReadWithWork keys values i q).1.value = | |
| finiteAnswerTable keys (values.map value) (i, q) := | |
| gatheredWordLookupWithWork_value _ coordinateEqualWithWork_value keys values (i, q) | |
| theorem queryChildReadWithWork_cost {M n : β} (keys : List (Fin M Γ TargetInterval n)) | |
| (values : List BinaryFraction) (i : Fin M) (q : TargetInterval n) | |
| (B : β) (hM : Nat.size M β€ B) (hn : Nat.size n β€ B) : | |
| (queryChildReadWithWork keys values i q).2 β€ 1 + keys.length * (24 * B + 9) := by | |
| exact gatheredWordLookupWithWork_cost coordinateEqualWithWork (24 * B + 8) | |
| (fun a b => coordinateEqualWithWork_cost a b B hM hn) keys values (i, q) | |
| @[simp] theorem queryHistoryReadWithWork_value {M n : β} | |
| (keys : List (Fin M Γ β Γ TargetInterval n)) (values : List BinaryFraction) | |
| (s : β) (input : Fin M Γ TargetInterval n) : | |
| (queryHistoryReadWithWork keys values s input).1.value = | |
| finiteAnswerTable keys (values.map value) (input.1, s, input.2) := | |
| gatheredWordLookupWithWork_value _ queryHistoryEqualWithWork_value keys values (input.1, s, input.2) | |
| theorem queryHistoryReadWithWork_cost {M n : β} | |
| (keys : List (Fin M Γ β Γ TargetInterval n)) (values : List BinaryFraction) | |
| (s : β) (input : Fin M Γ TargetInterval n) (B : β) | |
| (hM : Nat.size M β€ B) (hn : Nat.size n β€ B) (hs : Nat.size s β€ B) | |
| (ht : β key β keys, Nat.size key.2.1 β€ B) : | |
| (queryHistoryReadWithWork keys values s input).2 β€ | |
| 1 + keys.length * (32 * B + 12) := by | |
| apply gatheredWordLookupWithWork_cost_on queryHistoryEqualWithWork (32 * B + 11) | |
| intro key hk | |
| have hc := coordinateEqualWithWork_cost input (key.1, key.2.2) B hM hn | |
| have he := naturalEqualWithWork_cost s key.2.1 B hs (ht key hk) | |
| change (coordinateEqualWithWork input (key.1, key.2.2)).2 + | |
| (naturalEqualWithWork s key.2.1).2 + 1 β€ _ | |
| omega | |
| theorem queryHistoryReadWithWork_width {M n : β} | |
| (keys : List (Fin M Γ β Γ TargetInterval n)) (values : List BinaryFraction) | |
| (s : β) (input : Fin M Γ TargetInterval n) (B : β) | |
| (hB : 2 β€ B) (hv : β v β values, v.width β€ B) : | |
| (queryHistoryReadWithWork keys values s input).1.width β€ B := | |
| gatheredWordLookupWithWork_width _ keys values _ B hB hv | |
| end BinaryFraction | |
| end EditApproximation | |
| end OAI | |