@@ -16,6 +16,7 @@ import ArkLib.Data.CodingTheory.ProximityGap.BCIKS20.Curves
1616import ArkLib.Data.Domain.CosetFftDomain.Block
1717import ArkLib.Data.Domain.CosetFftDomain.Subdomain
1818import ArkLib.Data.Domain.CosetFftDomain.Log
19+ import ArkLib.Data.Domain.CosetFftDomain.Pullback
1920import ArkLib.Data.Polynomial.Indicator
2021import ArkLib.ToMathlib.Polynomial.EvalExt
2122import ArkLib.ToMathlib.Polynomial.NatDegreeOfSum
@@ -594,11 +595,7 @@ private lemma eval_comp_x_pow_map_eq {f : Polynomial (Polynomial F)} {x : F}
594595
595596private noncomputable def hammingDistComplementBound
596597 {n : ℕ} (k : ℕ) (domain : SmoothCosetFftDomain n F) (s : Finset F) : ℕ :=
597- Finset.card { i ∈
598- Finset.product
599- Finset.univ
600- (Finset.preimage s (domain.subdomain k) (by simp)) |
601- (domain i.1 ) ^ (2 ^ k) = domain.subdomain k i.2 }
598+ Finset.card (Pullback.pullback domain 0 k s)
602599
603600private noncomputable def hammingDistBound
604601 {n : ℕ} (k : ℕ) (domain : SmoothCosetFftDomain n F) (s : Finset F) : ℕ :=
@@ -617,64 +614,13 @@ private lemma contradictory_hamming_dist_formula {s : Finset F}
617614 (h_d : d ≤ 2 ^ n) :
618615 hammingDistBound k domain s =
619616 2 ^ n - 2 ^ k * (Finset.card s) := by
620- unfold hammingDistBound hammingDistComplementBound
621- simp only [Fintype.card_fin, product_eq_sprod]
622- congr
623- rw [show @filter _ _ _ _ =
624- (Finset.preimage s (domain.subdomain k) (by simp)).biUnion
625- (fun i ↦ {j | domain j.1 ^ 2 ^ k = domain.subdomain k i ∧ j.2 = i} ) by aesop,
626- Finset.card_biUnion (fun x hx y hy hxy a ha₁ ha₂ ↦ by
627- by_contra contra
628- obtain ⟨c, hc⟩ : ∃ c, c ∈ a := by
629- aesop
630- (add simp [le_eq_subset])
631- (add safe (by grind))
632- specialize (ha₁ hc)
633- specialize (ha₂ hc)
634- aesop
635- )]
636- conv =>
637- lhs
638- congr
639- rfl
640- ext u
641- rw [show (Finset.card _) = #{j | domain j ^ 2 ^ k =
642- (CosetFftDomain.subdomain domain k) u} by
643- aesop (add safe (by apply Finset.card_bij (fun a _ ↦ a.1 )))
644- ]
645- rw [Finset.sum_bij (t := s)
646- (g := fun x ↦ Finset.card {j | domain j ^ (2 ^ k) = x})
647- (i := fun i _ ↦ domain.subdomain k i)
648- (by aesop)
649- CosetFftDomain.injOn
650- (by {
651- intro b hb
652- obtain ⟨a, ha⟩ : ∃ i, (CosetFftDomain.subdomain domain k) i = b := by
653- rw [←CosetFftDomainClass.mem_def,
654- ←CosetFftDomainClass.mem_toFinset_iff_mem]
655- exact h_s hb
656- exists a
657- aesop
658- })
659- (by simp)]
660- rw [Finset.sum_bij (t := s)
661- (g := fun i ↦ 2 ^ k) (fun i _ ↦ i)
662- (by aesop)
663- (by aesop)
664- (by aesop)
665- (fun a ha ↦ by
666- rw [
667- show ({j | domain j ^ 2 ^ k = a} : Finset _) = blockIdx domain k a by rfl,
668- card_blockIdx,
669- card_block_of_mem_subdomain' (by {
670- rw [←Nat.pow_le_pow_iff_right (a := 2 ) (by simp)]
671- omega
672- }) (by {
673- rw [←CosetFftDomainClass.mem_toFinset_iff_mem]
674- exact h_s ha
675- })]
676- )]
677- aesop (add safe (by grind))
617+ have hkn : k ≤ n := by
618+ rw [←Nat.pow_le_pow_iff_right (a := 2 ) (by omega)]
619+ omega
620+ aesop
621+ (add simp [hammingDistBound, hammingDistComplementBound])
622+ (add safe (by rw [Pullback.card_pullback_eq_mul_card_pullback₂,
623+ Pullback.card_pullback₂_eq]))
678624
679625private lemma correlated_agreement_implies_contradictory_hamm_dist
680626 [Fintype F]
@@ -715,25 +661,21 @@ private lemma correlated_agreement_implies_contradictory_hamm_dist
715661 · simp only [hammingDist, ne_eq, hammingDistBound, Fintype.card_fin]
716662 rw [←Finset.compl_filter, Finset.card_compl, Fintype.card_fin]
717663 apply Nat.sub_le_sub_left
718- apply Finset.card_le_card_of_injOn Prod.fst
719- (f_inj := fun _ _ _ _ h ↦ by
720- aesop
721- (add unsafe [(by apply CosetFftDomain.injective (ω := domain.subdomain k))])
722- )
723- rintro ⟨a₁, a₂⟩ ha
724- simp_all only [product_eq_sprod, coe_filter, mem_product, mem_univ, mem_preimage, true_and,
725- Set.mem_setOf_eq]
726- rcases ha with ⟨h_a_s, h_eq⟩
727- rw [eval_comp_x_pow_map_eq, h_eq]
664+ rw [hammingDistComplementBound, Pullback.card_pullback_eq_card_pullback₁]
665+ apply Finset.card_le_card
666+ intro x hx
667+ have hx := Pullback.mem_s_of_mem_pullback₁ hx
668+ rw [subdomain_0_apply] at hx
669+ simp only [tsub_zero, Nat.sub_zero, mem_filter, mem_univ, true_and] at hx ⊢
670+ rw [eval_comp_x_pow_map_eq]
728671 by_cases h_s'_s : s' = s
729672 · rw [h_s'_s,
730673 ←eval_comm,
731- indicated_polynomial_eq_foldAux (by simp [h_a_s]),
732- ←h_eq,
674+ indicated_polynomial_eq_foldAux (by simp [hx]),
733675 ←foldValue_def,
734676 foldValue_pow_x_k]
735677 · rw [indicated_polynomial_eq_foldAux' (u := u) (by aesop)] <;> try assumption
736- · rw [←foldValue_def, ←h_eq, foldValue_pow_x_k]
678+ · rw [←foldValue_def, foldValue_pow_x_k]
737679 · intro i x hx
738680 have hx := (pick_subset_subset : s' ⊆ s) hx
739681 rw [h_u _ _ hx]
@@ -742,9 +684,8 @@ private lemma correlated_agreement_implies_contradictory_hamm_dist
742684 (h_u_deg i)
743685 (by rw [pick_subset_card_eq_of_ne h_s'_s])
744686
745- set_option linter.unusedFintypeInType false in -- false alert
746687private lemma dist_from_code_bound_of_correlated_agreement
747- [Fintype F]
688+ [Finite F]
748689 {s : Finset F}
749690 (h_s : s ⊆ (domain.subdomain k).toFinset)
750691 {u : Fin (2 ^ k) → Polynomial F}
@@ -756,7 +697,8 @@ private lemma dist_from_code_bound_of_correlated_agreement
756697 (h_u_deg : ∀ i, (u i).natDegree < d / (2 ^ k)) :
757698 Δ₀(f, ReedSolomon.code (domain : Fin (2 ^ n) ↪ F) d)
758699 ≤ 2 ^ n -
759- 2 ^ k * (Finset.card s) := by
700+ 2 ^ k * Finset.card s := by
701+ have := Fintype.ofFinite
760702 simp only [distFromCode, SetLike.mem_coe]
761703 exact sInf_le_of_le
762704 (b := ↑(hammingDistBound k domain s))
0 commit comments