File size: 5,512 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.Binary.BinaryBufferInputBounds
import OAI.Combinatorics.EditApproximation.Queries.QueryLocalBuffers
import OAI.Combinatorics.EditApproximation.Queries.QueryHistoryInputs

namespace OAI

/-! Numeric input records for the actual adaptive buffers. Earlier values
are bounded by the separately gathered child-initial table, including at
keys absent from the buffers, where the executable lookup returns zero. -/

namespace EditApproximation.BinaryFraction

theorem queryGatheredRefinementHistory_range {nx ny M : β„•} (parent : TargetInterval nx)
    (N P F exponent t Rp : β„•) (hP : 0 < P) (a : BinaryFraction)
    (parentInitial : TargetInterval ny β†’ BinaryFraction Γ— β„•)
    (hp : βˆ€ r, (parentInitial r).2 ≀ Rp) (q : TargetInterval ny)
    (historical : Fin M Γ— β„• Γ— TargetInterval ny β†’ BinaryFraction)
    (initial : Fin M Γ— TargetInterval ny β†’ BinaryFraction)
    (hnonneg : βˆ€ input, 0 ≀ (historical input).value)
    (hinitial : βˆ€ input, 0 ≀ (initial input).value)
    (hbound : βˆ€ input, (historical input).value ≀ (initial (input.1, input.2.2)).value)
    (s : β„•) (input : Fin M Γ— TargetInterval ny) :
    let earlier := (queryEarlierInputsWithWork M parent N P F exponent t hP a parentInitial q).1
    let band := (queryBandInputsWithWork M parent N P F exponent hP a parentInitial q).1
    0 ≀ (queryHistoryReadWithWork earlier (earlier.map historical) s input).1.value ∧
      (queryHistoryReadWithWork earlier (earlier.map historical) s input).1.value ≀
        (queryChildReadWithWork band (band.map initial) input.1 input.2).1.value := by
  have h := gatheredRefinementHistory_range parent N P F exponent t a.value
    (fun r => (parentInitial r).1.value) q queryHistoryEqualWithWork coordinateEqualWithWork
    queryHistoryEqualWithWork_value coordinateEqualWithWork_value historical initial
    hnonneg hinitial hbound (input.1, s, input.2)
  simpa only [queryHistoryReadWithWork, queryChildReadWithWork,
    queryEarlierInputsWithWork_value M parent N P F exponent t hP a parentInitial q Rp hp,
    queryBandInputsWithWork_value M parent N P F exponent hP a parentInitial q Rp hp] using h

theorem queryBufferedRefinementInputBounds {nx ny M : β„•} (parent : TargetInterval nx)
    (N P F exponent H Q eM eF B E S t Rp : β„•) (hP : 0 < P)
    (tau a eta kappa delta : BinaryFraction)
    (parentInitial : TargetInterval ny β†’ BinaryFraction Γ— β„•)
    (hp : βˆ€ r, (parentInitial r).2 ≀ Rp) (q : TargetInterval ny)
    (massWords currentWords : List BinaryFraction) (currentKeys : List (Fin M Γ— TargetInterval ny))
    (historical : Fin M Γ— β„• Γ— TargetInterval ny β†’ BinaryFraction)
    (initial : Fin M Γ— TargetInterval ny β†’ BinaryFraction)
    (integer : β„• β†’ TargetInterval ny β†’ β„•)
    (hn : PreparedKernelNumericBounds (nx := nx) (M := M) N P F exponent H Q eM eF B E S (t - 1)
      tau a eta kappa delta integer)
    (hpw : βˆ€ r, (parentInitial r).1.width ≀ B) (hpn : βˆ€ r, 0 ≀ (parentInitial r).1.value)
    (hmw : βˆ€ w ∈ massWords, w.width ≀ B) (hcw : βˆ€ w ∈ currentWords, w.width ≀ B)
    (hiw : βˆ€ input, (initial input).width ≀ B) (hhw : βˆ€ input, (historical input).width ≀ B)
    (hin : βˆ€ input, 0 ≀ (initial input).value) (hhn : βˆ€ input, 0 ≀ (historical input).value)
    (hbound : βˆ€ input, (historical input).value ≀ (initial (input.1, input.2.2)).value) :
    let earlier := (queryEarlierInputsWithWork M parent N P F exponent t hP a parentInitial q).1
    let band := (queryBandInputsWithWork M parent N P F exponent hP a parentInitial q).1
    PreparedKernelInputBounds (nx := nx) N P F exponent H Q eM eF B E S (t - 1)
      tau a eta kappa delta (fun r => (parentInitial r).1)
      (fun i r => (queryChildReadWithWork band massWords i r).1)
      (fun i r => (queryChildReadWithWork band (band.map initial) i r).1)
      (fun input => (queryHistoryReadWithWork earlier (earlier.map historical) (t - 1) input).1)
      (fun input => (queryChildReadWithWork currentKeys currentWords input.1 input.2).1)
      (fun s input => (queryHistoryReadWithWork earlier (earlier.map historical) s input).1) integer := by
  let earlier := (queryEarlierInputsWithWork M parent N P F exponent t hP a parentInitial q).1
  let band := (queryBandInputsWithWork M parent N P F exponent hP a parentInitial q).1
  have hB : 2 ≀ B := by have := hn.largeBits; omega
  have hew : βˆ€ w ∈ earlier.map historical, w.width ≀ B := by
    intro w hw
    obtain ⟨key, _, rfl⟩ := List.mem_map.mp hw
    exact hhw key
  have hiw' : βˆ€ w ∈ band.map initial, w.width ≀ B := by
    intro w hw
    obtain ⟨key, _, rfl⟩ := List.mem_map.mp hw
    exact hiw key
  apply hn.with_independent_cached_values
  Β· exact hpw
  Β· intro i r
    exact gatheredWordLookupWithWork_width _ band massWords (i, r) B hB hmw
  Β· intro i r
    exact gatheredWordLookupWithWork_width _ band (band.map initial) (i, r) B hB hiw'
  Β· intro input
    exact queryHistoryReadWithWork_width earlier (earlier.map historical) (t - 1) input B hB hew
  Β· intro input
    exact gatheredWordLookupWithWork_width _ currentKeys currentWords input B hB hcw
  Β· intro s _ i r
    exact queryHistoryReadWithWork_width earlier (earlier.map historical) s (i, r) B hB hew
  Β· exact hpn
  Β· intro s _ i r
    exact queryGatheredRefinementHistory_range parent N P F exponent t Rp hP a parentInitial hp q
      historical initial hhn hin hbound s (i, r)

end EditApproximation.BinaryFraction

end OAI