Download data/lean/OAI/Combinatorics/EditApproximation/Geometry/BandNumericalBits.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 4.33 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditApproximation/Geometry/BandNumericalBits.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/EditApproximation/Geometry/BandNumericalBits.lean
-
curl -L -o BandNumericalBits.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditApproximation/Geometry/BandNumericalBits.lean
4.33 kB
| import OAI.Combinatorics.EditApproximation.Numerics.GradientStorageBits | |
| import OAI.Combinatorics.EditApproximation.Geometry.BandOptimizerWork | |
| import OAI.Combinatorics.EditApproximation.Numerics.OptimizerWorkspace | |
| namespace OAI | |
| /-! The probability vectors actually stored for band actions have polynomial | |
| encodings in the input child masses. No accuracy event is needed. -/ | |
| namespace EditApproximation | |
| open Finset | |
| def bandVertexEncodingBudget (M V B : β) : β := | |
| B + (Nat.size (M * V) + 2 * (M * B + 1) + 1) + 3 | |
| theorem actionVector_encoding_le {M : β} {Ο : Type*} [DecidableEq Ο] | |
| (mass : Fin M β β) (action : Fin M β Ο) (coordinate : Fin M Γ Ο) | |
| (V B : β) (habs : β i, |mass i| β€ V) | |
| (hbits : β i, rationalEncodingBits (mass i) β€ B) : | |
| rationalEncodingBits (actionVector mass action coordinate) β€ bandVertexEncodingBudget M V B := by | |
| have hsum := rational_finite_sum_encoding_le (univ : Finset (Fin M)) mass V B | |
| (fun i _ => habs i) (fun i _ => (by | |
| unfold rationalEncodingBits at hbits | |
| have h := hbits i | |
| omega)) | |
| simp only [Finset.card_univ, Fintype.card_fin] at hsum | |
| unfold actionVector | |
| split_ifs | |
| Β· have hdiv := rationalEncodingBits_div (mass coordinate.1) (β i, mass i) | |
| have hmass := hbits coordinate.1 | |
| unfold bandVertexEncodingBudget | |
| omega | |
| Β· norm_num [rationalEncodingBits, bandVertexEncodingBudget] | |
| theorem actionVector_zero_one {M : β} {Ο : Type*} [DecidableEq Ο] | |
| (mass : Fin M β β) (action : Fin M β Ο) (coordinate : Fin M Γ Ο) | |
| (hpos : β i, 0 < mass i) : | |
| 0 β€ actionVector mass action coordinate β§ actionVector mass action coordinate β€ 1 := by | |
| have hsum : 0 < β i, mass i := | |
| (hpos coordinate.1).trans_le (Finset.single_le_sum (fun i _ => (hpos i).le) (mem_univ _)) | |
| unfold actionVector | |
| split_ifs | |
| Β· exact β¨(div_pos (hpos _) hsum).le, | |
| (div_le_oneβ hsum).2 (single_le_sum (fun i _ => (hpos i).le) (mem_univ _))β© | |
| Β· norm_num | |
| def storedBandVertices {M : β} {Ο : Type*} [DecidableEq Ο] | |
| (band : List (Fin M β Ο)) (mass : Fin M β β) : | |
| List (Vector β (listedBandCoordinates band).length) := | |
| band.map fun action => restrictOptimizerVector (listedBandCoordinateVector band) (actionVector mass action) | |
| theorem storedBandVertices_nonempty {M : β} {Ο : Type*} [DecidableEq Ο] | |
| (band : List (Fin M β Ο)) (mass : Fin M β β) (hband : band β []) : | |
| storedBandVertices band mass β [] := by | |
| intro hempty | |
| exact hband (List.map_eq_nil_iff.mp hempty) | |
| theorem storedBandVertices_input_bounds {M : β} {Ο : Type*} [DecidableEq Ο] | |
| (band : List (Fin M β Ο)) (mass : Fin M β β) (V B : β) | |
| (hpos : β i, 0 < mass i) (habs : β i, |mass i| β€ V) | |
| (hbits : β i, rationalEncodingBits (mass i) β€ B) | |
| (vertex : Vector β (listedBandCoordinates band).length) | |
| (hvertex : vertex β storedBandVertices band mass) | |
| (i : Fin (listedBandCoordinates band).length) : | |
| (0 β€ vertex.get i β§ vertex.get i β€ 1) β§ | |
| Nat.size (vertex.get i).den β€ bandVertexEncodingBudget M V B := by | |
| obtain β¨action, _, rflβ© := List.mem_map.mp hvertex | |
| rw [restrictOptimizerVector_get] | |
| constructor | |
| Β· exact actionVector_zero_one mass action _ hpos | |
| Β· have h := actionVector_encoding_le mass action | |
| ((listedBandCoordinateVector band).get i) V B habs hbits | |
| unfold rationalEncodingBits at h | |
| omega | |
| theorem storedBandOptimizer_history_bits {M : β} {Ο : Type*} [DecidableEq Ο] | |
| (band : List (Fin M β Ο)) (hband : band β []) (mass : Fin M β β) | |
| (linear : Fin M Γ Ο β β) (G K V B : β) | |
| (hpos : β i, 0 < mass i) (habs : β i, |mass i| β€ V) | |
| (hbits : β i, rationalEncodingBits (mass i) β€ B) : | |
| rationalVectorListStorageBits (optimizerStoredHistory (storedBandVertices band mass) | |
| (restrictOptimizerVector (listedBandCoordinateVector band) linear) G K) β€ | |
| (K + 1) * ((listedBandCoordinates band).length * | |
| (2 * ((K + 1) * (2 * Nat.size (K + 1) + 2 + bandVertexEncodingBudget M V B) + 1) + 1)) := by | |
| exact optimizerStoredHistory_storage_le _ _ G K _ (storedBandVertices_nonempty band mass hband) | |
| (fun vertex hvertex i => storedBandVertices_input_bounds band mass V B hpos habs hbits vertex hvertex i) | |
| end EditApproximation | |
| end OAI | |