@@ -63,255 +63,200 @@ variable {α : Type*}[DecidableEq α] [Nonempty α]
6363 {F : Type *}
6464
6565/--
66- Distance from a point `x` to a set of points `P`.
66+ Distance from a point `x` to a set of points `P`.
6767-/
6868noncomputable def distToSet (Δ : (ι → α) → (ι → α) → ℕ) (x : ι → α) (P : Set (ι → α)) : ℕ :=
6969 sInf {d | ∃ y ∈ P, Δ x y = d}
7070
71+ -- /--
72+ -- Definition 1.1 in [ BCIKS20 ] .
73+ -- -/
74+ noncomputable def generalProximityGap (P : Finset (ι → α)) (C : Set (Finset (ι → α)))
75+ (Δ : (ι → α) → (ι → α) → ℕ) (δ ε : ℝ≥0 ) : Prop :=
76+ ∀ S ∈ C (PMF.uniformOfFinset S).toOuterMeasure {x | distToSet Δ x P ≤ δ} = 1
77+ ∨ (PMF.uniformOfFinset S).toOuterMeasure {x | distToSet Δ x P ≤ δ} ≤ ε
78+
79+ #check @generalProximityGap
7180/--
72- Definition 1.1 in [ BCIKS20 ] .
81+ The error bound `ε` in the pair of proximity and error parameters `(δ,ε)` for Reed-Solomon codes
82+ defined up to the Johnson bound. More precisely, let `ρ` be the rate of the Reed-Solomon code.
83+ Then for `δ ∈ (0, 1 - √ρ)`, we define the relevant error parameter `ε` for the unique decoding
84+ bound, i.e. `δ ∈ [0, (1-√ρ)/2]` and Johnson bound, i.e. `δ ∈ [(1-√ρ)/2 , 1 - √ρ]`.
7385-/
74- noncomputable def generalProximityGap (P : Finset (ι → α)) (C : Finset (Finset (ι → α)))
75- (Δ : (ι → α) → (ι → α) → ℕ) (δ ε : ℝ≥0 ) (S : Finset (ι → α)) (h' : S ∈ C) (h : S.Nonempty)
76- : Prop :=
77- (PMF.uniformOfFinset S h).toOuterMeasure {x | distToSet Δ x P ≤ δ} = 1
78- ∨ (PMF.uniformOfFinset S h).toOuterMeasure {x | distToSet Δ x P ≤ δ} ≤ ε
86+ noncomputable def errorBound [Field F] [Fintype F] [Fintype ι] (δ : ℝ≥0 ) (deg : ℕ)
87+ (domain : ι ↪ F) : ℝ≥0 :=
88+ if UD : δ ≤ 1 - (ReedSolomonCode.sqrtRate deg domain)/2 then Fintype.card ι / Fintype.card F
89+ else if JB : δ ≥ 1 - (ReedSolomonCode.sqrtRate deg domain)/2 ∧ δ ≤ 1 -
90+ (ReedSolomonCode.sqrtRate deg domain)
91+ then
92+ let m := min (1 - (ReedSolomonCode.sqrtRate deg domain) - δ)
93+ (ReedSolomonCode.sqrtRate deg domain/ 20 )
94+ ⟨(deg ^ 2 : ℝ≥0 ) / ((2 * m) ^ 7 * (Fintype.card F : ℝ)), by positivity⟩
95+ else 0
96+
97+
98+ abbrev RScodeSet [Fintype ι] [Nonempty ι] [Field F] [Fintype F] [DecidableEq F]
99+ (domain : ι ↪ F) (deg : ℕ) : Set (ι → F) :=
100+ (ReedSolomon.code domain deg).carrier
101+
102+ lemma RScode_finite [Fintype ι] [Nonempty ι] [Field F] [Fintype F] [DecidableEq F]
103+ (domain : ι ↪ F) (deg : ℕ) : (RScodeSet domain deg).Finite := by
104+ unfold RScodeSet
105+ exact Set.toFinite _
106+
107+ noncomputable instance RScode_fintype [Fintype ι] [Nonempty ι] [Field F] [Fintype F][DecidableEq F]
108+ (domain : ι ↪ F) (deg : ℕ) [Fintype ι]:
109+ Fintype {f : ι → F // f ∈ RScodeSet domain deg} :=
110+ Fintype.ofFinset (RScode_finite domain deg).toFinset (by simp)
111+
112+ noncomputable def RScodeFinset [Fintype ι] [Nonempty ι] [Field F] [Fintype F][DecidableEq F]
113+ (domain : ι ↪ F) (deg : ℕ) : Finset (ι → F) :=
114+ (RScodeSet domain deg).toFinset
115+
116+ #check AffineSubspace
79117
80118/--
81- A collection of affine spaces in an `F`-module is non-empty.
119+ A collection of `F`-affine spaces is non-empty.
82120-/
83121lemma setOfAffineSubspaces_nonempty [Ring F] :
84122 {A | ∃ B : AffineSubspace F (ι → F), A = B}.Nonempty := by simp only [exists_eq', Set.setOf_true,
85123 Set.univ_nonempty]
86124
87125/--
88- A collection of affine spaces over a finite `F`-module is finite.
126+ A collection of affine spaces over a finite `F`-module is finite.
89127-/
90128lemma setOfAffineSubspaces_finite [Ring F] [Fintype F] [Fintype ι] :
91129 {A | ∃ B : AffineSubspace F (ι → F), A = B}.Finite := by
92130 simp only [exists_eq', Set.setOf_true]
93131 exact Set.finite_univ
94132
95- /--
96- The pair of proximity and error parameter `(δ,ε)` for Reed-Solomon codes defined up to the Johnson
97- bound. More precisely, let `ρ` be the rate of the Reed-Solomon code. Then for `δ ∈ (0, 1 - √ρ)`,
98- we define the relevant error parameter `ε` for the unique decoding bound, i.e. `δ ∈ [0, (1-√ρ)/2]`
99- and Johnson bound, i.e. `δ ∈ [(1-√ρ)/2 , 1 - √ρ]`.
100- -/
101- noncomputable def proximityParams [Field F] [Fintype F] [Fintype ι] (δ : ℝ≥0 ) (deg : ℕ)
102- (domain : ι ↪ F) : ℝ≥0 :=
103- if UD : δ ≤ 1 - (ReedSolomonCode.sqrtRate deg domain)/2 then Fintype.card ι / Fintype.card F
104- else if JB : δ ≥ 1 - (ReedSolomonCode.sqrtRate deg domain)/2 ∧ δ ≤ 1 -
105- (ReedSolomonCode.sqrtRate deg domain)
106- then
107- let m := min (1 - (ReedSolomonCode.sqrtRate deg domain) - δ)
108- (ReedSolomonCode.sqrtRate deg domain/ 20 )
109- ⟨(deg ^ 2 : ℝ≥0 ) / ((2 * m) ^ 7 * (Fintype.card F : ℝ)), by positivity⟩
110- else 0
111133
112- -- /--
113- -- Theorem 1.2 (Proximity gap for RS codes)
114- -- -/
115- -- theorem proximityGapsRSCode [Fintype ι] [Nonempty ι] [Field F] [Fintype F]
134+ -- -- /--
135+ -- -- Theorem 1.2 Proximity Gaps for Reed-Solomon codes in [ BCIKS20 ] .
136+ -- -- -/
137+ -- theorem proximity_gap_RSCodes [Fintype ι] [Nonempty ι] [Field F] [Fintype F] [DecidableEq F]
138+ -- (δ : ℝ≥0) (deg : ℕ) (domain : ι ↪ F)
139+ -- (hδ : δ ≤ 1 - (ReedSolomonCode.sqrtRate deg domain)) :
140+ -- generalProximityGap (RScodeFinset domain deg) {A | ∃ B : AffineSubspace F (ι → F), A = B}
141+ -- Code.relHammingDistToCode δ (errorBound δ deg) := by sorry
142+
116143
117144/--
118- Theorem 1.4 (Main Theorem — Correlated agreement over lines) in [ BCIKS20 ] .
145+ Theorem 1.4 (Main Theorem — Correlated agreement over lines) in [ BCIKS20 ] .
119146-/
120147theorem correlatedAgreement_lines [Fintype ι] [Nonempty ι] [Field F] [Fintype F] [DecidableEq F]
121148(u : Fin 2 → ι → F) (δ : ℝ≥0 ) (deg : ℕ) (domain : ι ↪ F)
122149(hδ : δ ≤ 1 - (ReedSolomonCode.sqrtRate deg domain))
123150(hproximity : (PMF.uniformOfFintype F).toOuterMeasure
124151 {z | Code.relHammingDistToCode (u 1 + z • u 2 ) (ReedSolomon.code domain deg) ≤ δ}
125- > proximityParams δ deg domain) :
152+ > errorBound δ deg domain) :
126153 correlatedAgreement (ReedSolomon.code domain deg) δ u := by sorry
127154
128155/--
129- Let `u := {u_1, ..., u_l}` be a collection of vectors with coefficients in a semiring.
130- The parameterised curve of degree `l` generated by `u` is the set of linear combinations of the
131- form `{∑ i ∈ l r ^ i • u_i | r ∈ F}`.
156+ Let `u := {u_1, ..., u_l}` be a collection of vectors with coefficients in a semiring.
157+ The parameterised curve of degree `l` generated by `u` is the set of linear combinations of the
158+ form `{∑ i ∈ l r ^ i • u_i | r ∈ F}`.
132159-/
133160def parametrisedCurve {l : ℕ} [Semiring F]
134161 (u : Fin l → ι → F) : Set (ι → F) := {v | ∃ r : F, v = ∑ i : Fin l, (r ^ (i : ℕ)) • u i}
135162
136163section
137- variable {ι : Type *} [Fintype ι] [DecidableEq ι]
164+ variable {ι : Type *} [Fintype ι]
138165 {F : Type *} [Semiring F] [DecidableEq F]
139166/--
140- A parametrised curve over a finite field is finite.
167+ A parametrised curve over a finite field is finite.
141168-/
142- def parametrisedCurveFinite [Fintype F]
169+ def parametrisedCurveFinite [Fintype F] [DecidableEq ι]
143170 {l : ℕ} (u : Fin l → ι → F) :
144171Finset (ι → F) := {v | ∃ r : F, v = ∑ i : Fin l, (r ^ (i : ℕ)) • u i}
145172
146173
147- instance [Fintype F] [Nonempty F] {l : ℕ} :
174+ instance [Fintype F] [Nonempty F] [DecidableEq ι] {l : ℕ} :
148175 ∀ u : Fin l → ι → F, Nonempty {x // x ∈ parametrisedCurveFinite u } := by
149176 intro u
150177 unfold parametrisedCurveFinite
151178 simp only [mem_filter, mem_univ, true_and, nonempty_subtype]
152- obtain ⟨r⟩ := ‹Nonempty F›
179+ have ⟨r⟩ := ‹Nonempty F›
153180 use ∑ i : Fin l, r ^ (i : ℕ) • u i, r
154181
155182
156183/--
157- Theorem 1.5 (Correlated agreement for low-degree parameterised curves) in in [ BCIKS20 ] .
184+ Theorem 1.5 (Correlated agreement for low-degree parameterised curves) in in [ BCIKS20 ] .
158185-/
159- theorem correlatedAgreement_affine_curves [Nonempty ι][Field F] [Fintype F]
186+ theorem correlatedAgreement_affine_curves [Nonempty ι][DecidableEq ι][ Field F][Fintype F]
160187{l : ℕ} (u : Fin l → ι → F) (δ : ℝ≥0 ) (deg : ℕ) (domain : ι ↪ F)
161188(hδ : δ ≤ 1 - (ReedSolomonCode.sqrtRate deg domain))
162189(hproximity : (PMF.uniformOfFintype (parametrisedCurveFinite u)).toOuterMeasure
163190 {y | Code.relHammingDistToCode y.1 (ReedSolomon.code domain deg) ≤ δ}
164- > l*(proximityParams δ deg domain)):
191+ > l*(errorBound δ deg domain)):
165192 correlatedAgreement (ReedSolomon.code domain deg) δ u := by sorry
166193
167194
168-
169-
170- instance {l : ℕ} [NeZero l] : Nonempty (Fin l) := inferInstance
171-
172- instance {l : ℕ} [NeZero l] : Fintype (Fin l) := inferInstance
173-
174-
175- instance {α : Type} [Fintype α] [Nonempty α] :
176- Nonempty (Finset.univ : Finset α) :=
177- by exact Nonempty.to_subtype (univ_nonempty_iff.mpr (by assumption))
178-
179-
180- def finsetVectorsU {k : ℕ} [Fintype ι] (u : Fin k → ι → F) : Finset (ι → F) :=
195+ def finsetU {k : ℕ} [Fintype ι] (u : Fin k → ι → F) : Finset (ι → F) :=
181196 Finset.univ.image u
182197
183- def setVectorsU {k : ℕ} [Fintype ι] (u : Fin k → ι → F) : Set (ι → F) :=
184- Finset.toSet (finsetVectorsU u)
198+ abbrev setVectorsU {k : ℕ} [Fintype ι] (u : Fin k → ι → F) : Set (ι → F) :=
199+ Finset.toSet (finsetU u)
185200
186- theorem thing₁ {F ι : Type *} [DecidableEq F] {k : ℕ} [NeZero k] [Fintype ι] {u : Fin k → ι → F} :
187- (finsetVectorsU u).Nonempty := by simp [finsetVectorsU ]
201+ instance finsetU_nonempty {F ι : Type *} [DecidableEq F] {k : ℕ} [NeZero k] [Fintype ι]
202+ {u : Fin k → ι → F} : (finsetU u).Nonempty := by simp [finsetU ]
188203
189204instance {F ι : Type*} [DecidableEq F] {k : ℕ} [NeZero k] [Fintype ι] {u : Fin k → ι → F} :
190- Nonempty (finsetVectorsU u) := by
191- have := thing₁ (u := u)
205+ Nonempty (finsetU u) := by
206+ have := finsetU_nonempty (u := u)
192207 simp only [nonempty_subtype]
193208 exact this
194209
195210instance {F ι : Type*} [DecidableEq F] {k : ℕ} [NeZero k] [Fintype ι] {u : Fin k → ι → F} :
196211 Nonempty (setVectorsU u) := by
197- have := thing₁ (u := u)
212+ have := finsetU_nonempty (u := u)
198213 simp only [nonempty_subtype]
199214 exact this
200215
201- theorem thing₁' {F ι : Type *} [DecidableEq F] {k : ℕ} [NeZero k] [Fintype ι] {u : Fin k → ι → F} :
202- (setVectorsU u).Nonempty := by
216+ lemma setVectorsU_nonempty {F ι : Type *} [DecidableEq F] {k : ℕ} [NeZero k] [Fintype ι]
217+ {u : Fin k → ι → F} : (setVectorsU u).Nonempty := by
203218 simp [setVectorsU]
204- exact thing₁
219+ exact finsetU_nonempty
205220
206221
207- #check affineSpan_nonempty
208-
209-
210-
211- theorem thing₂ {F P V : Type *} [AddCommGroup V] [Ring F] [Module F V] {s : Set P}
212- (h : Set.Nonempty s)
213- [AddTorsor V P] : Nonempty ↥(affineSpan F s) := by
214- have := @affineSpan_nonempty F V P _ _ _ _ s
215- unfold Set.Nonempty at this h
216- simp
217- symm at this
218- apply this.1
219- exact h
220-
221- -- def affineSpaceOnU {k : ℕ} [Fintype ι] [Field F] (u : Fin k → ι → F) :
222- -- AffineSubspace F (setVectorsU u) := affineSpan F (setVectorsU u)
223-
224- theorem affineSpanUNonempty {F : Type *} [Field F][DecidableEq F] {k : ℕ} [Fintype ι]
225- (u : Fin k → ι → F) : Nonempty ↥(affineSpan F (setVectorsU u)) := by
226-
227- sorry
228- ---have := @affineSpan_nonempty F (setVectorsU u)
229-
230- theorem thing₄' {F : Type *} [Field F] [Fintype F] [DecidableEq F] {k : ℕ}
231- (u : Fin k → ι → F) : Finite ↥(affineSpan F (setVectorsU u)) := by
232- unfold affineSpan
233- infer_instance
234-
235-
236- -- theorem thing₄ {α P V : Type*} [AddCommGroup V] [Fintype α] [Ring α] [Module α V] [Fintype P]
237- -- {s : Finset P}
238- -- [AddTorsor V P] : Finite ↥(@affineSpan α V P _ _ _ _ s) := by
239- -- unfold affineSpan
240- -- infer_instance
241-
242- noncomputable def thing₃' {F : Type *} [Field F] [Fintype F] [DecidableEq F] {k : ℕ}
222+ noncomputable def affineSpan_Fintype {F : Type *} [Field F] [Fintype F] [DecidableEq F] {k : ℕ}
243223 {u : Fin k → ι → F} : Fintype ↥(affineSpan F (setVectorsU u)) := by
244224 apply Fintype.ofFinite
245225
246- noncomputable def nonempty {F : Type *} [Field F] [Fintype F] [DecidableEq F] {k : ℕ}
247- {u : Fin k → ι → F} : Nonempty ↥(affineSpan F (setVectorsU u)) := sorry
248-
249- -- noncomputable def thing₃ {α P V : Type*} [Fintype α] [AddCommGroup V]
250- -- [Ring α] [Module α V] [Fintype P] {s : Finset P}
251- -- [AddTorsor V P] : Fintype ↥(@affineSpan α V P _ _ _ _ s) := by
252- -- have := @thing₄ α P V _ _ _ _ _ s _
253- -- apply Fintype.ofFinite
226+ lemma affineSpan_nonempty' {F : Type *} [Field F] [Fintype F] [DecidableEq F] {k : ℕ} [NeZero k]
227+ {u : Fin k → ι → F} : Nonempty ↥(affineSpan F (setVectorsU u)) := by
228+ have affineSpan_ne_iff := @affineSpan_nonempty F _ _ _ _ _ _ (setVectorsU u)
229+ unfold Set.Nonempty at affineSpan_ne_iff
230+ symm at affineSpan_ne_iff
231+ simp
232+ apply affineSpan_ne_iff. 1
233+ exact setVectorsU_nonempty
254234
255235theorem correlatedAgreement_affine_spaces [Fintype ι] [Field F] [Fintype F]
256236 [DecidableEq F] [Nonempty F] [Nonempty ι]
257- {k : ℕ} (u : Fin k → ι → F) (δ : ℝ≥0 ) (deg : ℕ) (domain : ι ↪ F)
237+ {k : ℕ} [NeZero k] (u : Fin k → ι → F) (δ : ℝ≥0 ) (deg : ℕ) (domain : ι ↪ F)
258238 (hδ : δ ≤ 1 - (ReedSolomonCode.sqrtRate deg domain))
259- (hproximity : (@PMF.uniformOfFintype (affineSpan F (setVectorsU u)) thing₃' nonempty).toOuterMeasure
260- {y | Code.relHammingDistToCode (ι := ι) (F := F) y (ReedSolomon.code domain deg) ≤ δ}
261- > proximityParams δ deg domain) :
239+ (hproximity :
240+ (@PMF.uniformOfFintype (affineSpan F (setVectorsU u))
241+ affineSpan_Fintype affineSpan_nonempty').toOuterMeasure
242+ {y | Code.relHammingDistToCode (ι := ι) (F := F) y (ReedSolomon.code domain deg) ≤ δ}
243+ > errorBound δ deg domain) :
262244 correlatedAgreement (ReedSolomon.code domain deg) δ u := by sorry
263245
246+ abbrev AffSpanSet [Fintype ι] [Nonempty ι] [Field F] [Fintype F] [DecidableEq F]
247+ {k : ℕ} (u : Fin k → ι → F) : Set (ι → F) :=
248+ (affineSpan F (finsetU u)).carrier
264249
250+ -- /--
251+ -- Theorem 1.2 Proximity Gaps for Reed-Solomon codes in [ BCIKS20 ] .
252+ -- -/
253+ -- theorem proximity_gap_RSCodes' [Fintype ι] [Nonempty ι] [ Field F ] [Fintype F ] [DecidableEq F]
254+ -- (δ : ℝ≥0) {k : ℕ} (deg : ℕ) (domain : ι ↪ F) (u : Fin k → ι → F)
255+ -- (hδ : δ ≤ 1 - (ReedSolomonCode.sqrtRate deg domain)) :
256+ -- generalProximityGap (RScodeFinset domain deg) (AffSpanSet u)
257+ -- Code.relHammingDistToCode δ (errorBound δ deg) := by sorry
265258
266- -- def X (n : ℕ) : Type := {x : ℕ // x < n}
267-
268- -- def eq {n : ℕ} : X n ≃ Fin n := sorry
269-
270- -- #check Fin.add_one_le_of_lt
271-
272- -- instance {n : ℕ} : Preorder (X n) where
273- -- le a b := eq a ≤ eq b
274- -- le_refl := λ _ ↦ Fin.le_refl _
275- -- le_trans := λ _ _ _ ↦ Fin.le_trans
276-
277- -- instance {n : ℕ} : Add (X n) := Equiv.add eq
278-
279- -- instance {n : ℕ} [NeZero n] {i : ℕ} : OfNat (X n) i where
280- -- ofNat := eq.symm (Fin.ofNat n i)
281-
282- -- theorem abc {n : ℕ} {a b : X (n + 1)} (h : a < b) : a + 1 ≤ b := by
283- -- unfold LE.le
284- -- unfold_projs
285- -- simp
286- -- apply Fin.add_one_le_of_lt
287- -- unfold LT.lt at h
288- -- unfold_projs at h
289- -- simp at h
290- -- exact h.2
291-
292-
293-
294-
295-
296-
297- -- theorem correlatedAgreement_affine_spaces [Fintype ι] [Field F] [Fintype F]
298- -- [DecidableEq F] [ AddTorsor F (ι → F) ] [Nonempty F ] [Nonempty ι]
299- -- {k : ℕ} [NeZero k] (u : Fin k → ι → F) (δ : ℝ≥0) (deg : ℕ) (domain : ι ↪ F)
300- -- (hδ : δ ≤ 1 - (ReedSolomonCode.sqrtRate deg domain))
301- -- (hproximity : (PMF.uniformOfFintype (affineSpan F (setVectorsU u))).toOuterMeasure
302- -- {y | Code.relHammingDistToCode y (ReedSolomon.code domain deg) ≤ δ}
303- -- > proximityParams δ deg domain) :
304- -- correlatedAgreement (ReedSolomon.code domain deg) δ u := by sorry
305-
306- -- theorem correlatedAgreement_affine_spaces' [Fintype ι] [Field F] [Fintype F]
307- -- [DecidableEq F] [AddTorsor F (ι → F)]
308- -- {k : ℕ} [NeZero k] (u : Fin k → ι → F) (δ : ℝ≥0) (deg : ℕ) (domain : ι ↪ F)
309- -- (hδ : δ ≤ 1 - (ReedSolomonCode.sqrtRate deg domain))
310- -- (hproximity : PMF.toOuterMeasure
311- -- (@PMF.uniformOfFintype
312- -- (@affineSpan F F (ι → F) _ _ _ _ (thing u))
313- -- (@thing.thing₃ F (ι → F) F _ _ _ _ _ (thing u) _)
314- -- (@thing.thing₂ F (ι → F) F _ _ _ (thing u)
315- -- (@thing.thing₁ F ι _ k _ _ u) _)) > sorry) : False := by sorry
259+ #check AffineSubspace
316260
317261end
262+ end
0 commit comments