math / data /lean /OAI /Combinatorics /LowSpaceSubsetSum /Compression /CompressionScheduleCells.lean
Download data/lean/OAI/Combinatorics/LowSpaceSubsetSum/Compression/CompressionScheduleCells.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 2.88 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/LowSpaceSubsetSum/Compression/CompressionScheduleCells.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/LowSpaceSubsetSum/Compression/CompressionScheduleCells.lean
-
curl -L -o CompressionScheduleCells.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/LowSpaceSubsetSum/Compression/CompressionScheduleCells.lean
2.88 kB
| import OAI.Combinatorics.LowSpaceSubsetSum.Compression.CompressionPreparedCells | |
| import OAI.Combinatorics.LowSpaceSubsetSum.Storage.ResidueLoopCells | |
| import OAI.Combinatorics.LowSpaceSubsetSum.Compression.BudgetedCompressionSchedule | |
| namespace OAI | |
| /-! # Reusing one compression workspace throughout the residue loop -/ | |
| namespace LowSpaceSubsetSum.CompressionScheduleCells | |
| open PreparedCompressionPass (Arrays) | |
| variable {n : β} | |
| def bucket (I : Instance n) (C B : β) (A : Arrays) (P : β) (hP : 0 < P) | |
| (z budget : β) := | |
| if z < P then | |
| CompressionPreparedCells.run I C B A P I.target z (by exact_mod_cast hP) budget | |
| else ((some (false,budget),0),8) | |
| theorem bucket_value (I : Instance n) (C B : β) (A : Arrays) (P : β) (hP : 0 < P) | |
| (z budget : β) : (bucket I C B A P hP z budget).1 = | |
| BudgetedCompressionSchedule.bucket I C B A P hP z budget := by | |
| unfold bucket BudgetedCompressionSchedule.bucket | |
| split | |
| Β· exact CompressionPreparedCells.value I C B A P I.target z _ budget | |
| Β· rfl | |
| def run (I : Instance n) (C B : β) (A : Arrays) (P : β) (hP : 0 < P) (budget : β) := | |
| let out := ResidueLoopCells.run (bucket I C B A P hP) 0 P budget | |
| (out.1,out.2+4*PreparedCompressionPass.size A+32) | |
| theorem value (I : Instance n) (C B : β) (A : Arrays) (P : β) (hP : 0 < P) (budget : β) : | |
| (run I C B A P hP budget).1 = BudgetedCompressionSchedule.run I C B A P hP budget := by | |
| rw [run,ResidueLoopCells.value] | |
| have he : (fun z b => (bucket I C B A P hP z b).1) = | |
| BudgetedCompressionSchedule.bucket I C B A P hP := by | |
| funext z b | |
| exact bucket_value I C B A P hP z b | |
| rw [he] | |
| rfl | |
| theorem cells (I : Instance n) (hn : 10000 β€ n) (C B : β) (A : Arrays) | |
| (P : β) (hP : 0 < P) (budget : β) (hB : B β€ C) | |
| (hL : β i, (A.first i).size β€ C) (hR : β i, (A.second i).size β€ C) (hC : C β€ 2^n) : | |
| (run I C B A P hP budget).2 β€ inputScale I^9*(C+1) := by | |
| let u := inputScale I | |
| have hu : 10000 β€ u := by unfold u inputScale; omega | |
| have hlarge : 100 β€ u^8 := by | |
| have hp : u β€ u^8 := by | |
| simpa only [pow_one] using Nat.pow_le_pow_right (show 1 β€ u by omega) (by decide : 1 β€ 8) | |
| omega | |
| have hb (z b : β) : (bucket I C B A P hP z b).2 β€ u^8*(C+1) := by | |
| unfold bucket | |
| split | |
| Β· exact CompressionPreparedCells.cells I hn C B A P I.target z _ b hB hL hR hC | |
| Β· dsimp only; nlinarith only [hlarge] | |
| have h := ResidueLoopCells.cells (bucket I C B A P hP) (u^8*(C+1)) hb 0 P budget | |
| have hs := CompressionPreparedCells.arrays_size A C hL hR | |
| have hm : 2*u^8*(C+1) β€ u^9*(C+1) := by | |
| apply Nat.mul_le_mul_right | |
| calc | |
| _ β€ u*u^8 := Nat.mul_le_mul_right _ (by omega) | |
| _ = _ := (pow_succ' _ _).symm | |
| change _+4*PreparedCompressionPass.size A+32 β€ _ | |
| nlinarith only [h,hs,hlarge,hm] | |
| end LowSpaceSubsetSum.CompressionScheduleCells | |
| end OAI | |