File size: 2,656 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
50
51
52
53
54
55
56
import OAI.Combinatorics.EditApproximation.Refinement.ComputedFamilySampling
import OAI.Combinatorics.EditApproximation.Probability.ExactSampling

namespace OAI

namespace EditApproximation

/-- The stream keeps the current word and one optional accepted value;
failed words are overwritten and the failure count belongs only to the
probability-space description, not to the machine state. -/
def rejectionStateCells (N bits : ℕ) (state : Option (Fin N)) (word : Fin (2 ^ bits)) : ℕ :=
  (state.map fun value => value.val.bits.length).getD 0 + word.val.bits.length + 4

theorem rejectionStateCells_bound (N bits : ℕ) (hN : N ≤ 2 ^ bits)
    (state : Option (Fin N)) (word : Fin (2 ^ bits)) :
    rejectionStateCells N bits state word ≤ 2 * bits + 4 := by
  have hw : word.val.bits.length ≤ bits := by
    rw [Nat.size_eq_bits_len]
    exact Nat.size_le.mpr word.isLt
  have hs : (state.map fun value => value.val.bits.length).getD 0 ≤ bits := by
    cases state with
    | none => exact Nat.zero_le _
    | some value =>
      change value.val.bits.length ≤ bits
      rw [Nat.size_eq_bits_len]
      exact Nat.size_le.mpr (value.isLt.trans_le hN)
  unfold rejectionStateCells
  omega

/-- This bound holds after every transition, regardless of how many
failed trials preceded it. -/
theorem rejectionTransition_cells (N bits : ℕ) (hN : N ≤ 2 ^ bits)
    (state : Option (Fin N)) (word nextWord : Fin (2 ^ bits)) :
    rejectionStateCells N bits (rejectionTransition N (2 ^ bits) state word) nextWord ≤ 2 * bits + 4 :=
  rejectionStateCells_bound N bits hN _ _

theorem computedFamilySampler_cells (source target : List ℕ) (N R : ℕ)
    (hMass : Nat.size (localOnlineMassBound (integerParameters N).M (integerParameters N).P
      (inputHeight N)) ≤ inputHeight N)
    (key : ComputedFamilyScalarKey source target N R)
    (state : Option (Fin (physicalFamilyRange target N (integerParameters N).P (inputSmallLog N)
      (40 * smallLogExponent N) (inputHeight N) (inputSmallLog N ^ 80)
      (computedSeedPassCount N) (inputHeight N ^ 2) key)))
    (word : Fin (2 ^ rejectionBitCount (physicalFamilyRange target N (integerParameters N).P (inputSmallLog N)
      (40 * smallLogExponent N) (inputHeight N) (inputSmallLog N ^ 80)
      (computedSeedPassCount N) (inputHeight N ^ 2) key))) :
    rejectionStateCells _ _ state word ≤ 2 * inputHeight N + 4 := by
  have h := rejectionStateCells_bound _ _ (Nat.le_pow_clog (by decide : 1 < (2 : ℕ)) _) state word
  have hb := computedFamilyRange_bits_le source target N R hMass key
  dsimp only [rejectionBitCount] at hb
  exact h.trans (by omega)

end EditApproximation

end OAI