File size: 4,325 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 | 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
|