cfahlgren1/math / lean /OAI /NumberTheory /Ostmann /Quadratic /KernelResidueCount.lean
cfahlgren1's picture
download
raw
2.11 kB
12
theorem unit_square_residue_card_le (q : ℕ) [NeZero q] (a : (ZMod q)ˣ) :
    ((Finset.univ : Finset (ZMod q)).filter
      (fun x => IsUnit x ∧ x ^ 2 = (a : ZMod q))).card ≤
        2 ^ (q.primeFactors.card + 1) := by
proof · 14 lines
  let F := {x : ZMod q // IsUnit x ∧ x ^ 2 = (a : ZMod q)}
  let f : F → {x : (ZMod q)ˣ // x ^ 2 = a} := fun x =>
    ⟨x.property.1.unit, by
      apply Units.ext
      simpa only [Units.val_pow_eq_pow_val, IsUnit.unit_spec] using x.property.2⟩
  have hinj : Function.Injective f := by
    intro x y h
    apply Subtype.ext
    have hv := congrArg (fun z : {x : (ZMod q)ˣ // x ^ 2 = a} => (z.val : ZMod q)) h
    simpa only [f, IsUnit.unit_spec] using hv
  have hc := Fintype.card_le_of_injective f hinj
  have hb := unit_square_fiber_card_le q a
  rw [Nat.card_eq_fintype_card] at hb
  exact (show _ ≤ Fintype.card F from by simp [F, Fintype.card_subtype]).trans (hc.trans hb)
31
theorem kernel_root_residues_card_le (S : Finset ℤ) (root : ℤ → ℕ)
    (m : ℕ) [NeZero m] (h u : ℤ) (hred : h.natAbs.Coprime m)
    (hroot : ∀ x ∈ S, u * (root x : ℤ) ^ 2 = (m : ℤ) * x - h) :
    ((kernelRootPopulation S root).image (fun t : ℕ => (t : ZMod m))).card ≤
      2 ^ (m.primeFactors.card + 1) := by
proof · 10 lines
  by_cases hS : S.Nonempty
  · obtain ⟨a, ha⟩ := kernel_square_residues S root m h u hred hS hroot
    apply (Finset.card_le_card (t := (Finset.univ : Finset (ZMod m)).filter
      (fun r => IsUnit r ∧ r ^ 2 = (a : ZMod m))) ?_).trans (unit_square_residue_card_le m a)
    intro r hr
    obtain ⟨t, ht, rfl⟩ := Finset.mem_image.mp hr
    obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp ht
    exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,
      (ZMod.isUnit_iff_coprime _ _).mpr (ha x hx).1, (ha x hx).2⟩
  · simp [Finset.not_nonempty_iff_eq_empty.mp hS, kernelRootPopulation]

Xet Storage Details

Size:
2.11 kB
·
Xet hash:
b3a7aa46dff4b7edaf3611d5dfc473286fcae742d186e8758a8e861f095249b6

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.