math / data /lean /OAI /NumberTheory /Ostmann /Arithmetic /ArithmeticLineIntegration.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
4.68 kB
import Mathlib.Data.Nat.Totient
import OAI.NumberTheory.Ostmann.Characters.PolynomialLineFlags
namespace OAI
/-! # Actual line integrals as bounded functions of the cleared polynomial tests -/
namespace Ostmann
open scoped BigOperators Classical
noncomputable def internalLineScalar (external : Bool) (p : β„•) : ℝ :=
((if external then p else p - 1 : β„•) : ℝ)⁻¹
theorem internalLineScalar_nonneg (external : Bool) (p : β„•) :
0 ≀ internalLineScalar external p := by
unfold internalLineScalar
positivity
theorem internalLineScalar_le_one (external : Bool) (p : β„•) :
internalLineScalar external p ≀ 1 := by
let n : β„• := if external then p else p - 1
change (n : ℝ)⁻¹ ≀ 1
rcases Nat.eq_zero_or_pos n with h | h
Β· simp [h]
Β· exact inv_le_one_of_one_leβ‚€ (by exact_mod_cast h)
noncomputable def internalLineFlagWeight {J : Type*} (external : Bool) (p : β„•)
(flags : Bool βŠ• J β†’ Bool) : ℝ :=
if lineFeasibleFlags external flags then internalLineScalar external p else 0
theorem internalLineFlagWeight_nonneg {J : Type*} (external : Bool) (p : β„•)
(flags : Bool βŠ• J β†’ Bool) : 0 ≀ internalLineFlagWeight external p flags := by
unfold internalLineFlagWeight
split_ifs
Β· exact internalLineScalar_nonneg external p
Β· rfl
theorem internalLineFlagWeight_le_one {J : Type*} (external : Bool) (p : β„•)
(flags : Bool βŠ• J β†’ Bool) : internalLineFlagWeight external p flags ≀ 1 := by
unfold internalLineFlagWeight
split_ifs
Β· exact internalLineScalar_le_one external p
Β· norm_num
/-- The normalized count before the giant variables are integrated out. -/
noncomputable def internalLineProbability {J : Type*} {p : β„•} [Fact p.Prime]
(external : Bool) (a b : J β†’ ZMod p) : ℝ :=
if external then
(Fintype.card {z : ZMod p Γ— (ZMod p)Λ£ // βˆ€ j, a j * z.1 + b j * z.2 = 0} : ℝ) /
Fintype.card (ZMod p Γ— (ZMod p)Λ£)
else
(Fintype.card {z : (ZMod p)Λ£ Γ— (ZMod p)Λ£ // βˆ€ j, a j * z.1 + b j * z.2 = 0} : ℝ) /
Fintype.card ((ZMod p)Λ£ Γ— (ZMod p)Λ£)
theorem internalLineProbability_nonneg {J : Type*} {p : β„•} [Fact p.Prime]
(external : Bool) (a b : J β†’ ZMod p) : 0 ≀ internalLineProbability external a b := by
unfold internalLineProbability
split_ifs <;> positivity
theorem external_lineSystem_integral_eq_flags {Οƒ J : Type*} {p : β„•} [Fact p.Prime]
(L : J β†’ PolynomialGiantLine Οƒ) (i : J) (Ο† : MvPolynomial Οƒ β„€ β†’+* ZMod p)
(hd : βˆ€ j, Ο† (L j).denominator β‰  0)
(hrow : ((L i).normalized Ο†).1 β‰  0 ∨ ((L i).normalized Ο†).2 β‰  0) :
(Fintype.card {z : ZMod p Γ— (ZMod p)Λ£ //
βˆ€ j, ((L j).normalized Ο†).1 * z.1 + ((L j).normalized Ο†).2 * z.2 = 0} : ℝ) /
Fintype.card (ZMod p Γ— (ZMod p)Λ£) =
internalLineFlagWeight true p
(fun s => arithmeticTestFlag (Ο† (lineTestPolynomials L i s) = 0)) := by
rw [external_lineSystem_probability _ _ i hrow]
unfold internalLineFlagWeight
rw [external_polynomialLine_flags_iff L i Ο† hd]
rfl
theorem unit_lineSystem_integral_eq_flags {Οƒ J : Type*} {p : β„•} [Fact p.Prime]
(L : J β†’ PolynomialGiantLine Οƒ) (i : J) (Ο† : MvPolynomial Οƒ β„€ β†’+* ZMod p)
(hd : βˆ€ j, Ο† (L j).denominator β‰  0)
(hrow : ((L i).normalized Ο†).1 β‰  0 ∨ ((L i).normalized Ο†).2 β‰  0) :
(Fintype.card {z : (ZMod p)Λ£ Γ— (ZMod p)Λ£ //
βˆ€ j, ((L j).normalized Ο†).1 * z.1 + ((L j).normalized Ο†).2 * z.2 = 0} : ℝ) /
Fintype.card ((ZMod p)Λ£ Γ— (ZMod p)Λ£) =
internalLineFlagWeight false p
(fun s => arithmeticTestFlag (Ο† (lineTestPolynomials L i s) = 0)) := by
rw [unit_lineSystem_probability _ _ i hrow]
unfold internalLineFlagWeight
rw [unit_polynomialLine_flags_iff L i Ο† hd]
have hc : Fintype.card (ZMod p)Λ£ = p - 1 := by
rw [ZMod.card_units_eq_totient, Nat.totient_prime (Fact.out : p.Prime)]
simp only [internalLineScalar, Bool.false_eq_true, ite_false, hc]
theorem internalLineProbability_eq_flags {Οƒ J : Type*} {p : β„•} [Fact p.Prime]
(external : Bool) (L : J β†’ PolynomialGiantLine Οƒ) (i : J)
(Ο† : MvPolynomial Οƒ β„€ β†’+* ZMod p) (hd : βˆ€ j, Ο† (L j).denominator β‰  0)
(hrow : ((L i).normalized Ο†).1 β‰  0 ∨ ((L i).normalized Ο†).2 β‰  0) :
internalLineProbability external (fun j => ((L j).normalized Ο†).1)
(fun j => ((L j).normalized Ο†).2) =
internalLineFlagWeight external p
(fun s => arithmeticTestFlag (Ο† (lineTestPolynomials L i s) = 0)) := by
cases external
Β· exact unit_lineSystem_integral_eq_flags L i Ο† hd hrow
Β· exact external_lineSystem_integral_eq_flags L i Ο† hd hrow
end Ostmann
end OAI