File size: 2,514 Bytes
e63eb7f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.Combinatorics.EditApproximation.Queries.QueryChargedFamilySpace
import OAI.Combinatorics.EditApproximation.Binary.BinaryNormalizationSpace
import OAI.Combinatorics.EditApproximation.Queries.QueryFamilyMemo

namespace OAI

namespace EditApproximation
open BitQuery

section Family
variable {M J R passes copies T S : ℕ} [NeZero M] [NeZero R]
  (source target : List ℕ) (N P F exponent H Q eM eF : ℕ)
  (hP : 0 < P) (hM : M = 2 ^ eM) (hF : F = 2 ^ eF)
  (A a : ℕ → BinaryFraction) (tau eta kappa delta : BinaryFraction) (multiplier : ℕ → ℕ)
  (occurrence : BinaryMemo PositionCounts) (symbolBits positionBits : ℕ)
  (coarse : PhysicalEntry M J target.length → BinaryFraction × ℕ)
  (allocation : PhysicalEntry M J target.length → ℕ)
  (hc : ∀ entry, allocation entry ≤ 3 * (coarse entry).2)
  (draw : PhysicalFamilyScalarDraw (M := M) (J := J) (R := R)
    target N P F exponent H Q passes copies)

def queryFamilyMemoRawHeap
    (key : QueryFamilyMemoKey (M := M) (J := J) (R := R) (passes := passes)
      (copies := copies) (T := T) (S := S) target N P F exponent H Q) :
    Heap (queryFamilyMemoRaw source target N P F exponent H Q eM eF hP hM hF
      A a tau eta kappa delta multiplier occurrence symbolBits positionBits coarse draw key) := by
  cases key with
  | inl scalar =>
    exact Heap.computeOf (queryFamilySourceWordWithWork target N P F exponent H Q draw scalar)
      (Nat.size (draw scalar).val + 2) (by simp only [queryFamilySourceWordWithWork]; omega)
  | inr request =>
    exact (queryChargedFamilyGlobalHeap source target N P F exponent H Q eM eF hP hM hF
      A a tau eta kappa delta multiplier occurrence symbolBits positionBits coarse allocation hc request).mapKeysWithWork
        _ (fun _ => 1) (fun _ => le_rfl)

def queryFamilyMemoNormalizedHeap (base : List Bool) (hbase : 0 < bitWordValue base)
    (key : QueryFamilyMemoKey (M := M) (J := J) (R := R) (passes := passes)
      (copies := copies) (T := T) (S := S) target N P F exponent H Q) :
    Heap (queryFamilyMemoNormalized source target N P F exponent H Q eM eF hP hM hF
      A a tau eta kappa delta multiplier occurrence symbolBits positionBits coarse draw base hbase key) :=
  (queryFamilyMemoRawHeap source target N P F exponent H Q eM eF hP hM hF
    A a tau eta kappa delta multiplier occurrence symbolBits positionBits coarse allocation hc draw key).normalize
      base hbase (queryFamilyMemoRemaining target N P F exponent H Q key)

end Family
end EditApproximation

end OAI