File size: 3,883 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 | import OAI.Combinatorics.LowSpaceSubsetSum.Representation.RepresentationReaderCells
import OAI.Combinatorics.LowSpaceSubsetSum.Storage.BudgetedFillCells
namespace OAI
/-! # Concrete bounded-space filling of a representation tie buffer -/
namespace LowSpaceSubsetSum.RepresentationFillCells
variable {n : β}
def run (I : Instance n) (F : IndexedMask n) (P : β€) (mode : FilteredStream.Mode)
(right : Array (LeafRecord n)) {d : β} (charge : β) (K : β€) (B : β)
(s : CountedParentJoin.State I F P mode right d) (budget : β) :=
BudgetedFillCells.run charge (RepresentationReaderCells.read I F P mode right)
(RepresentationKeyCells.pairKey I F P mode) CountedParentJoin.cells ParentLiveState.reader
K B s budget
theorem run_value (I : Instance n) (F : IndexedMask n) (P : β€) (mode : FilteredStream.Mode)
(right : Array (LeafRecord n)) {d : β} (charge : β) (K : β€) (B : β)
(s : CountedParentJoin.State I F P mode right d) (budget : β) :
(run I F P mode right charge K B s budget).1 =
BudgetedFill.execute charge (RepresentationKeys.read I F P mode right)
(RepresentationKeys.pairKey I F P mode) CountedParentJoin.cells K B s #[] 0 budget := by
rw [run, BudgetedFillCells.run_value]
have hr : (fun s : CountedParentJoin.State I F P mode right d =>
(RepresentationReaderCells.read I F P mode right s).1) =
RepresentationKeys.read I F P mode right :=
funext (RepresentationReaderCells.read_value I F P mode right)
have hk : (fun x => (RepresentationKeyCells.pairKey I F P mode x).1) =
RepresentationKeys.pairKey I F P mode :=
funext (RepresentationKeyCells.pairKey_value I F P mode)
rw [hr, hk]
theorem run_cells (I : Instance n) (F : IndexedMask n) (P : β€) (mode : FilteredStream.Mode)
(right : Array (LeafRecord n)) {d : β} (charge : β) (K : β€) (B C : β)
(s : CountedParentJoin.State I F P mode right d) (budget : β)
(hn : 10000 β€ n) (hd : d β€ n) (ht : 2 ^ (d + 1) β€ 4 * (C + 1)) (hB : B β€ C) :
(run I F P mode right charge K B s budget).2 β€ inputScale I ^ 5 * (C + 1) := by
let u := inputScale I
have hu : n + 1 β€ u := by unfold u inputScale; omega
have hc : 12 * n + 32 β€ 44 * u := by omega
have hsc := Nat.mul_le_mul hc ht
have hs : β st : CountedParentJoin.State I F P mode right d,
ParentLiveState.reader st β€ 176 * u * (C + 1) := by
intro st
rw [ParentLiveState.reader_exact]
nlinarith only [hsc]
have hl : β x, (RepresentationKeyCells.pairKey I F P mode x).2 β€ 44 * u := by
intro x
exact (RepresentationKeyCells.pairKey_cells I F P mode x).trans hc
have h := BudgetedFillCells.run_cells charge (RepresentationReaderCells.read I F P mode right)
(RepresentationKeyCells.pairKey I F P mode) CountedParentJoin.cells ParentLiveState.reader K
(u ^ 4 * (C + 1)) (44 * u) (176 * u * (C + 1)) (6 * n + 4)
(fun st => RepresentationReaderCells.read_scale I F P mode right st C hn hd ht)
hl hs CountedParentJoin.cells_le B s budget
have hbuf := Nat.mul_le_mul_left (6 * n + 5) hB
have hsmall : (run I F P mode right charge K B s budget).2 β€
(u ^ 4 + 500 * u) * (C + 1) := by
change (run I F P mode right charge K B s budget).2 β€ _ at h
nlinarith only [h, hbuf, hu]
have hu3 : 500 β€ u ^ 3 := by
calc
500 β€ 8 ^ 3 := by norm_num
_ β€ u ^ 3 := Nat.pow_le_pow_left (by omega) 3
have hm := Nat.mul_le_mul_right u hu3
have hp : 500 * u β€ u ^ 4 := by simpa only [pow_succ, Nat.mul_assoc] using hm
have hfactor : 2 * u ^ 4 β€ u ^ 5 := by
calc
_ β€ u * u ^ 4 := Nat.mul_le_mul_right _ (by omega)
_ = _ := (pow_succ' _ _).symm
change (run I F P mode right charge K B s budget).2 β€ u ^ 5 * (C + 1)
exact hsmall.trans (Nat.mul_le_mul_right (C + 1) (by omega))
end LowSpaceSubsetSum.RepresentationFillCells
end OAI
|