File size: 3,554 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 | import OAI.Combinatorics.LowSpaceSubsetSum.Representation.RepresentationBackgroundPreparation
namespace OAI
/-! # Exact blocks produced by the background preparation -/
noncomputable section
namespace LowSpaceSubsetSum.RepresentationBackgroundPreparation
open scoped BigOperators
variable {n : ℕ}
theorem size_check (I : Instance n) (v : Vector (Fin n) n) (e : Equiv.Perm (Fin n))
(hv : ∀ i : Fin n, v[i.val] = e i) (guesses : Vector ℕ 3)
(g : RepresentationSetup.Guesses n) (hg : ∀ j : Fin 3, guesses[j.val] = (g j).val)
(hn : 10000 ≤ n)
(hlog : Real.logb 2 ((mixerSize n : ℝ) + 1) + 1 ≤ (n : ℝ) / 1000) :
(∑ i : Fin 8, (RepresentationAllocationExecution.run n guesses).1[i.val]) =
(CanonicalBackground.run v).1.length := by
have hs := representationLeafCounts_sum g hn hlog
have hv' := CanonicalBackground.value I v e hv ∅
calc
_ = ∑ i : Fin 8, representationLeafCounts n g i :=
Finset.sum_congr rfl (fun i _ => RepresentationAllocationExecution.value n guesses g hg i)
_ = representationBackgroundSize n := hs
_ = _ := by
rw [hv', Finset.length_sort, RepresentationSetup.backgroundDomain_card]
theorem complete (I : Instance n) (v : Vector (Fin n) n) (e : Equiv.Perm (Fin n))
(hv : ∀ i : Fin n, v[i.val] = e i) (signs : Finset (Fin n)) (guesses : Vector ℕ 3)
(g : RepresentationSetup.Guesses n) (hg : ∀ j : Fin 3, guesses[j.val] = (g j).val)
(hn : 10000 ≤ n)
(hlog : Real.logb 2 ((mixerSize n : ℝ) + 1) + 1 ≤ (n : ℝ) / 1000) :
∃ rows, (run I v guesses).1 = some rows ∧
∀ (side : Fin 2) (leaf : Fin 4),
rows[4 * side.val + leaf.val].toFinset =
(canonicalRepresentationData I).zeroSetup.rawBackground (e, signs)
((canonicalRepresentationData I).zeroSetup.allocatedBackground (e, signs) g hn hlog)
side leaf := by
let R := (canonicalRepresentationData I).zeroSetup
let V := Finset.univ \ R.mixerUnion (e, signs)
let out := CanonicalBackground.run v
let counts := (RepresentationAllocationExecution.run n guesses).1
have hout : out.1 = V.sort (· ≤ ·) := CanonicalBackground.value I v e hv signs
have hcard : V.card = out.1.length := by rw [hout, Finset.length_sort]
have hc : (∑ i : Fin 8, counts[i.val]) = out.1.length := size_check I v e hv guesses g hg hn hlog
let xs : Vector (Fin n) out.1.length := ⟨out.1.toArray, by simp only [List.size_toArray]⟩
have hxs (k : Fin out.1.length) : xs[k.val] = ((V.orderIsoOfFin hcard) k).val := by
rw [Finset.coe_orderIsoOfFin_apply, Finset.orderEmbOfFin_apply]
change out.1[k.val] = _
simp only [hout]
rfl
let rows := (StoredBackgroundBlocks.run xs counts hc).1
refine ⟨rows, ?_, ?_⟩
· exact run_of_size I v guesses hc
· intro side leaf
let index : Fin 8 := ⟨4 * side.val + leaf.val, by omega⟩
have hrow := StoredBackgroundBlocks.row_source_of_size V hcard xs hxs counts hc index
have hcounts : (fun i : Fin 8 => counts[i.val]) = representationLeafCounts n g := by
funext i
exact RepresentationAllocationExecution.value n guesses g hg i
simp only [hcounts] at hrow
dsimp only [rows, StoredBackgroundBlocks.run]
rw [Vector.getElem_ofFn]
change (StoredBackgroundBlocks.row xs counts hc index).toFinset = _
rw [hrow]
ext x
simp only [V, R, RepresentationSetup.rawBackground, RepresentationSetup.allocatedBackground,
backgroundPairColor_eq_iff]
rfl
end LowSpaceSubsetSum.RepresentationBackgroundPreparation
end
end OAI
|