File size: 3,747 Bytes
5d5048e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.Combinatorics.LowSpaceSubsetSum.Representation.RepresentationLayoutExecution
import OAI.Combinatorics.LowSpaceSubsetSum.Representation.RepresentationParameterPreparation

namespace OAI

/-! # Preparing stored layout data and prime widths after the bounded draw -/

noncomputable section
namespace LowSpaceSubsetSum.RepresentationLayoutPreparation

variable {n : ℕ}

structure Data (n : ℕ) where
  permutation : Vector (Fin n) n
  signs : IndexedMask n
  domains : Vector (List (Fin n)) 3
  parameters : MixerParameterExecution.Parameters

def run (D : RepresentationData n) (s : D.zeroSetup.layoutCoupling.Seed) :
    Option (Data n) × ℕ :=
  let layout := RepresentationLayoutExecution.run D.zeroSetup s
  match layout.1 with
  | none => (none, layout.2 + 1)
  | some (v, signs) =>
    let prepared := RepresentationParameterPreparation.run D v
    (some ⟨v, signs, prepared.1.1, prepared.1.2⟩, layout.2 + prepared.2 + 1)

theorem prepared (D : RepresentationData n) (s : D.zeroSetup.layoutCoupling.Seed)
    (data : Data n) (h : (run D s).1 = some data) :
    (data.domains, data.parameters) =
      (RepresentationParameterPreparation.run D data.permutation).1 := by
  unfold run at h
  cases hl : (RepresentationLayoutExecution.run D.zeroSetup s).1 with
  | none => simp only [hl, reduceCtorEq] at h
  | some pair =>
    rcases pair with ⟨v, signs⟩
    simp only [hl, Option.some.injEq] at h
    subst data
    rfl

theorem value (D : RepresentationData n) (s : D.zeroSetup.layoutCoupling.Seed)
    (data : Data n) (h : (run D s).1 = some data) :
    ∃ e, D.zeroSetup.layoutCoupling.bounded s = some (e, data.signs.semantic) ∧
      (∀ i : Fin n, data.permutation[i.val] = e i) ∧
      (∀ j : Fin 3, data.domains[j.val] = (permuteSubset e (D.mixers j)).sort (· ≤ ·)) ∧
      (∀ j : Fin 4, data.parameters.widths[j.val] =
        D.zeroSetup.samplerPrimeWidths (e, data.signs.semantic) j) := by
  unfold run at h
  cases hl : (RepresentationLayoutExecution.run D.zeroSetup s).1 with
  | none => simp only [hl, reduceCtorEq] at h
  | some pair =>
    rcases pair with ⟨v, signs⟩
    simp only [hl, Option.some.injEq] at h
    subst data
    obtain ⟨e, he, hv⟩ := RepresentationLayoutExecution.value D.zeroSetup s v signs hl
    refine ⟨e, he, hv, ?_, ?_⟩
    · intro j
      exact RepresentationMixerPreparation.domains_value D v e hv j
    · intro j
      exact RepresentationParameterPreparation.widths_value D v e hv signs.semantic j

theorem complete (D : RepresentationData n) (s : D.zeroSetup.layoutCoupling.Seed)
    (e : Equiv.Perm (Fin n)) (signs : Finset (Fin n))
    (h : D.zeroSetup.layoutCoupling.bounded s = some (e, signs)) :
    ∃ data, (run D s).1 = some data ∧ data.signs.semantic = signs := by
  obtain ⟨v, mask, hv, hm, _⟩ := RepresentationLayoutExecution.complete D.zeroSetup s e signs h
  refine ⟨⟨v, mask, (RepresentationParameterPreparation.run D v).1.1,
    (RepresentationParameterPreparation.run D v).1.2⟩, ?_, hm⟩
  simp only [run, hv]

theorem work (D : RepresentationData n) (hn : 10000 ≤ n)
    (s : D.zeroSetup.layoutCoupling.Seed) :
    (run D s).2 ≤ n * n ^ 3 + 10 * (n + 1) ^ 2 + 4 * n + 6 +
      inputScale D.input ^ 6 * 2 ^ mixerSize n := by
  have hw := RepresentationLayoutExecution.work D.zeroSetup s
  unfold run
  cases hl : (RepresentationLayoutExecution.run D.zeroSetup s).1 with
  | none => simp only [hl]; omega
  | some pair =>
    rcases pair with ⟨v, signs⟩
    obtain ⟨e, _, hv⟩ := RepresentationLayoutExecution.value D.zeroSetup s v signs hl
    have hp := RepresentationParameterPreparation.work D hn v e hv
    simp only [hl]
    omega

end LowSpaceSubsetSum.RepresentationLayoutPreparation

end

end OAI