@@ -688,7 +688,7 @@ private lemma correlated_agreement_implies_contradictory_hamm_dist
688688 constructor
689689 · exact lt_of_lt_of_le
690690 (indicated_polynomial_comp_x_k_natDegree h_s'_non_empty)
691- (by aesop )
691+ (FoldingContext.pow_2_k_mul_le_pow_2_d_of ( by simp_all) )
692692 · simp only [hammingDist, ne_eq, hammingDistBound, Fintype.card_fin]
693693 rw [←Finset.compl_filter, Finset.card_compl, Fintype.card_fin]
694694 apply Nat.sub_le_sub_left
@@ -746,57 +746,28 @@ private lemma dist_from_code_bound_of_correlated_agreement
746746 simp only [Set.mem_setOf_eq, Nat.cast_le]
747747 aesop (add safe [evalOnPoints_mem_code_of_natDegree_lt])
748748
749- private lemma folded_rate_div_eq_helper {d : ℕ}
750- (hkn : k ≤ n) (hkd : 2 ^ k ∣ d) :
751- (↑(d / 2 ^ k) : ℚ≥0 ) / 2 ^ (n - k) = (↑d : ℚ≥0 ) / 2 ^ n := by
752- obtain ⟨m, rfl⟩ := hkd
753- simp +zetaDelta only [ne_eq, Nat.pow_eq_zero, OfNat.ofNat_ne_zero, false_and, not_false_eq_true,
754- mul_div_cancel_left₀, Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] at *
755- rw [←Nat.add_sub_cancel' hkn,
756- pow_add,
757- mul_div_mul_left _ _ (by positivity)]
758- norm_num
759-
760749omit [DecidableEq F] in
761750/-- The rate of the folded RS-code is the same. -/
762- lemma folded_rate_eq {d : ℕ} (hkn : k ≤ n) (hkd : 2 ^ k ∣ d) :
751+ lemma folded_rate_eq {d : ℕ} [FoldingContext k d n] :
763752 LinearCode.rate
764- (ReedSolomon.code (domain.subdomain k : Fin (2 ^ (n - k)) ↪ F) (d / ( 2 ^ k))) =
765- LinearCode.rate (ReedSolomon.code (domain : Fin (2 ^ n) ↪ F) d ) := by
753+ (ReedSolomon.code (domain.subdomain k : Fin (2 ^ (n - k)) ↪ F) (2 ^ (d - k))) =
754+ LinearCode.rate (ReedSolomon.code (domain : Fin (2 ^ n) ↪ F) ( 2 ^ d) ) := by
766755 simp only [rateOfLinearCode_eq_min_div, Fintype.card_fin, min_def, Nat.cast_ite, Nat.cast_pow,
767756 Nat.cast_ofNat]
768- by_cases hif : d ≤ 2 ^ n
769- · simp only [hif, ↓reduceIte]
770- have hif : d / 2 ^ k ≤ 2 ^ (n - k) := by
771- rw [Nat.div_le_iff_le_mul (by simp)]
772- exact le_trans hif <| by
773- rw [←pow_add, Nat.sub_add_cancel hkn]
774- grind
775- aesop (add safe forward [folded_rate_div_eq_helper])
776- · simp only [hif, ↓reduceIte, ne_eq, pow_eq_zero_iff', OfNat.ofNat_ne_zero, false_and,
777- not_false_eq_true, div_self]
778- have hif := Nat.div_le_div_right (c := 2 ^ k) (Nat.le_of_lt (not_le.mp hif))
779- rw [show 2 ^ n / 2 ^ k = 2 ^ (n - k) by
780- aesop (add safe
781- [(by rw [Nat.div_eq_iff]),
782- (by rw [←pow_add]),
783- (by grind)])
784- ] at hif
785- rcases (Nat.lt_or_eq_of_le hif) with hif | hif
786- · aesop (add safe (by omega))
787- · aesop
788- (add safe forward [div_eq_one_iff_eq])
789- (add safe [(by norm_cast)])
757+ have hif : 2 ^ (d - k) ≤ 2 ^ (n - k) := by simp
758+ simp [hif]
759+ field_simp
760+ rw [←pow_add, ←pow_add]
761+ grind
790762
791763omit [DecidableEq F] in
792764/-- The square root of the rate of the folded RS-code is the same. -/
793- lemma folded_sqrtRate_eq {d : ℕ} (hkn : k ≤ n) (hkd : 2 ^ k ∣ d) :
765+ lemma folded_sqrtRate_eq {d : ℕ} [FoldingContext k d n] :
794766 ReedSolomon.sqrtRate
795- (d / ( 2 ^ k))
767+ (2 ^ (d - k))
796768 (domain.subdomain k : Fin (2 ^ (n - k)) ↪ F) =
797- ReedSolomon.sqrtRate d (domain : Fin (2 ^ n) ↪ F) := by
798- aesop (add simp [ReedSolomon.sqrtRate, folded_rate_eq])
799-
769+ ReedSolomon.sqrtRate (2 ^ d) (domain : Fin (2 ^ n) ↪ F) := by
770+ simp [ReedSolomon.sqrtRate, folded_rate_eq]
800771
801772set_option linter.unusedVariables false in -- linter complains about `δ_gt_0`
802773 -- which is a result of it missing
@@ -819,33 +790,26 @@ the corresponding Reed–Solomon code except with probability controlled by
819790theorem folding_preserves_distance
820791 [Fintype F]
821792 {domain : SmoothCosetFftDomain n F} {f : Word F (Fin (2 ^ n))} {d k : ℕ}
793+ [FoldingContext k d n]
822794 {δ : ℝ≥0 }
823- (k_div_d : 2 ^ k ∣ d)
824- (hd0 : 0 < d)
825- (h_d_n : d ≤ 2 ^ n)
826795 (δ_gt_0 : 0 < δ) -- this one is not used but should be.
827- (δ_lt : δ < min (δᵣ(f, ReedSolomon.code (domain : Fin (2 ^ n) ↪ F) d ))
828- (1 - (ReedSolomon.sqrtRate d (domain : Fin (2 ^ n) ↪ F)))) :
796+ (δ_lt : δ < min (δᵣ(f, ReedSolomon.code (domain : Fin (2 ^ n) ↪ F) ( 2 ^ d) ))
797+ (1 - (ReedSolomon.sqrtRate ( 2 ^ d) (domain : Fin (2 ^ n) ↪ F)))) :
829798 Pr_{ let r ←$ᵖ F}[δᵣ(foldWord domain f k r,
830799 ReedSolomon.code (domain.subdomain k : Fin (2 ^ (n - k)) ↪ F)
831- (d / ( 2 ^ k))) ≤ δ] ≤
832- ((2 ^ k) - 1 ) * ProximityGap.errorBound δ (d / ( 2 ^ k))
800+ (2 ^ (d - k))) ≤ δ] ≤
801+ ((2 ^ k) - 1 ) * ProximityGap.errorBound δ (2 ^ (d - k))
833802 (domain.subdomain k : Fin (2 ^ (n - k)) ↪ F) := by
834- have h_k_d : 2 ^ k ≤ d := by exact Nat.le_of_dvd (by omega) k_div_d
835- have h_k_le_n : k ≤ n := by
836- rw [←Nat.pow_le_pow_iff_right (a := 2 ) (by simp)]
837- omega
838803 have bound_tighter :
839- (↑δ) ≤ 1 - ReedSolomon.sqrtRate (d / ( 2 ^ k))
804+ (↑δ) ≤ 1 - ReedSolomon.sqrtRate (2 ^ (d - k))
840805 (domain.subdomain k : Fin (2 ^ (n - k)) ↪ F) :=
841806 le_of_lt <| by
842807 aesop
843808 (add safe [(by rw [folded_sqrtRate_eq])])
844- (add safe [(by grind)])
845809 (add safe (by norm_cast at *))
846810 have correlated_agreement :=
847811 @correlatedAgreement_affine_curves (Fin (2 ^ (n - k))) _ _ F _ _ _
848- (2 ^ k - 1 ) (d / (2 ^ k ))
812+ (2 ^ k - 1 ) ((2 ^ (d - k) ))
849813 (domain := domain.subdomain k) (δ := δ)
850814 (hδ := bound_tighter)
851815 unfold foldWord δ_ε_correlatedAgreementCurves at *
@@ -856,9 +820,9 @@ theorem folding_preserves_distance
856820 comp_apply, PMF.pure_apply, eq_iff_iff, true_iff,
857821 mul_ite, mul_one, mul_zero, tsum_fintype] at contra correlated_agreement
858822 let cast (x : Fin (2 ^ k - 1 + 1 )) : Fin (2 ^ k) :=
859- Fin.cast (by rw [Nat.sub_add_cancel (by omega )]) x
823+ Fin.cast (by rw [Nat.sub_add_cancel (by grind )]) x
860824 let cast' (x : Fin (2 ^ k)) : Fin (2 ^ k - 1 + 1 ) :=
861- Fin.cast (by rw [Nat.sub_add_cancel (by omega )]) x
825+ Fin.cast (by rw [Nat.sub_add_cancel (by grind )]) x
862826 have bijective_cast : Bijective cast := by
863827 rw [bijective_iff_has_inverse]
864828 exists cast'
@@ -895,7 +859,7 @@ theorem folding_preserves_distance
895859 rw [forall_and] at h'
896860 rcases h' with ⟨h_rs, h'⟩
897861 have h_rs := fun x ↦ (mem_code_iff_exists_polynomial_of_ne_zero
898- (ne := ⟨by rw [Nat.div_ne_zero_iff]; omega ⟩)).mp (h_rs x)
862+ (ne := ⟨by simp ⟩)).mp (h_rs x)
899863 let u : Fin (2 ^ k - 1 + 1 ) → Polynomial F :=
900864 fun i => Classical.choose (h_rs i)
901865 have contradiction := dist_from_code_bound_of_correlated_agreement (domain := domain) (f := f)
@@ -917,12 +881,10 @@ theorem folding_preserves_distance
917881 aesop (add norm evalOnPoints)
918882 )
919883 (d := d)
920- h_k_d
921- h_d_n
922884 (fun i ↦
923885 And.left <| Classical.choose_spec (h_rs (cast' i)))
924886 rw [Finset.card_image_of_injective _ (by simp)] at contradiction
925- have contradiction : (Δ₀(f, code (domain : Fin (2 ^ n) ↪ F) d ) : ENNReal)
887+ have contradiction : (Δ₀(f, code (domain : Fin (2 ^ n) ↪ F) ( 2 ^ d) ) : ENNReal)
926888 ≤ (↑(2 ^ n) : ℚ≥0 ) * δ :=
927889 le_trans (ENat.toENNReal_le.mpr contradiction) <| by
928890 apply le_trans
@@ -933,9 +895,9 @@ theorem folding_preserves_distance
933895 (h := swap (le_trans (b := 2 ^ n * 1 )) (by simp) <| by
934896 rw [mul_comm,
935897 ←mul_assoc,
936- ←pow_add,
937- Nat.sub_add_cancel h_k_le_n,
938- ENNReal.mul_le_mul_iff_right (by simp) (by simp)]
898+ ←pow_add]
899+ simp only [FoldingContext.k_le_n, Nat.sub_add_cancel]
900+ rw [ ENNReal.mul_le_mul_iff_right (by simp) (by simp)]
939901 simp
940902 )]
941903 apply le_trans (b := 2 ^ k * ↑↑(#S))
@@ -946,8 +908,8 @@ theorem folding_preserves_distance
946908 · norm_cast
947909 · rw [mul_comm,
948910 ←mul_assoc,
949- ←pow_add,
950- Nat.sub_add_cancel h_k_le_n ]
911+ ←pow_add]
912+ simp only [FoldingContext.k_le_n, Nat.sub_add_cancel]
951913 conv_lhs =>
952914 lhs
953915 rw [←mul_one (2 ^ n)]
@@ -958,7 +920,7 @@ theorem folding_preserves_distance
958920 exact le_trans (le_of_lt δ_lt.2 ) (by simp)
959921 })]
960922 norm_cast
961- have contradiction : δᵣ(f, code (domain : Fin (2 ^ n) ↪ F) d ) ≤ (δ : NNReal) := by
923+ have contradiction : δᵣ(f, code (domain : Fin (2 ^ n) ↪ F) ( 2 ^ d) ) ≤ (δ : NNReal) := by
962924 rw [relDistFromCode_le_iff_distFromCode_toENNReal_le]
963925 exact le_trans contradiction <| by
964926 simp only [Fintype.card_fin, Nat.cast_pow, Nat.cast_ofNat]
0 commit comments