Skip to content

[Merged by Bors] - feat: add theorem cast_subgroup_of_units_card_ne_zero#6500

Closed
BoltonBailey wants to merge 85 commits intomasterfrom
BoltonBailey/subgroup_of_units_card_ne_zero
Closed

[Merged by Bors] - feat: add theorem cast_subgroup_of_units_card_ne_zero#6500
BoltonBailey wants to merge 85 commits intomasterfrom
BoltonBailey/subgroup_of_units_card_ne_zero

Conversation

@BoltonBailey
Copy link
Copy Markdown
Collaborator

@BoltonBailey BoltonBailey commented Aug 10, 2023

Adds a theorem saying the cardinality of a multiplicative subgroup of a field, cast to the field, is nonzero. As well as sum_subgroup_units_zero_of_ne_bot and other theorems about summing over multiplicative subgroups.

Co-authored-by: Pratyush Mishra prat@upenn.edu
Co-authored-by: Buster rcopley@gmail.com


Open in Gitpod

@BoltonBailey BoltonBailey added the WIP Work in progress label Aug 10, 2023
@BoltonBailey BoltonBailey added awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. and removed WIP Work in progress labels Aug 11, 2023
@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Aug 11, 2023
@BoltonBailey BoltonBailey added awaiting-review awaiting-author A reviewer has asked the author a question or requested changes. and removed awaiting-review labels Aug 11, 2023
@BoltonBailey
Copy link
Copy Markdown
Collaborator Author

Note: this is true for infinite fields too, so I should generalize it.

@BoltonBailey BoltonBailey added awaiting-review and removed awaiting-author A reviewer has asked the author a question or requested changes. labels Aug 13, 2023
@BoltonBailey BoltonBailey added awaiting-author A reviewer has asked the author a question or requested changes. and removed awaiting-review labels Aug 21, 2023
BoltonBailey and others added 6 commits September 27, 2023 09:08
Co-authored-by: Eric Rodriguez <37984851+ericrbg@users.noreply.github.com>
Co-authored-by: Eric Rodriguez <37984851+ericrbg@users.noreply.github.com>
Co-authored-by: Eric Rodriguez <37984851+ericrbg@users.noreply.github.com>
@BoltonBailey
Copy link
Copy Markdown
Collaborator Author

I tried to do the golf, but was not getting it. Maybe actually sum_pow_units can be golfed too?

@BoltonBailey
Copy link
Copy Markdown
Collaborator Author

Given that everything apparently turned out to be true in NoZeroDivisor rings, I'd be interested to know if the preexisting lemmas in this file can be generalized along those lines.

@BoltonBailey
Copy link
Copy Markdown
Collaborator Author

This is as far as I got

/-- The sum of `x ^ i` as `x` ranges over a finite field of cardinality `q`
is equal to `0` if `i < q - 1`. -/
theorem sum_pow_lt_card_sub_one (i : ℕ) (h : i < q - 1) : ∑ x : K, x ^ i = 0 := by
  by_cases hi : i = 0
  · simp only [hi, nsmul_one, sum_const, pow_zero, card_univ, cast_card_eq_zero]
  classical
    -- have hiq : ¬q - 1 ∣ i := by contrapose! h; exact Nat.le_of_dvd (Nat.pos_of_ne_zero hi) h
    let φ : Kˣ ↪ K := ⟨fun x ↦ x, Units.ext⟩
    have : univ.map φ = univ \ {0} := by
      ext x
      simp only [true_and_iff, Function.Embedding.coeFn_mk, mem_sdiff, Units.exists_iff_ne_zero,
        mem_univ, mem_map, exists_prop_of_true, mem_singleton]
    calc
      ∑ x : K, x ^ i = ∑ x in univ \ {(0 : K)}, x ^ i := by
        rw [← sum_sdiff ({0} : Finset K).subset_univ, sum_singleton,
          zero_pow (Nat.pos_of_ne_zero hi), add_zero]
      _ = ∑ x : Kˣ, (x ^ i : K) := by simp [← this, univ.sum_map φ]
      _ = 0 := by 
        sorry
        -- convert sum_subgroup_pow_eq_zero (G := ⊤) (k := i) hi _
#align finite_field.sum_pow_lt_card_sub_one FiniteField.sum_pow_lt_card_sub_one

@ericrbg
Copy link
Copy Markdown
Contributor

ericrbg commented Sep 27, 2023

Given that everything apparently turned out to be true in NoZeroDivisor rings, I'd be interested to know if the preexisting lemmas in this file can be generalized along those lines.

I think this can wait for a followup PR, but yes:)

@ericrbg
Copy link
Copy Markdown
Contributor

ericrbg commented Sep 27, 2023

ok also the refactoring can, lmao it took me forever

if you want to see
lemma Subgroup.prod_top {α β : Type*} [Group α] [Fintype α] [Fintype (⊤ : Subgroup α)]
  [CommMonoid β] (f : α → β) : ∏ x : (⊤ : Subgroup α), f x = ∏ x : α, f x :=
  by simp [Finset.prod_set_coe]

lemma Subgroup.sum_top {α β : Type*} [Group α] [Fintype α] [Fintype (⊤ : Subgroup α)]
  [AddCommMonoid β] (f : α → β) : ∑ x : (⊤ : Subgroup α), f x = ∑ x : α, f x :=
  by simp [Finset.sum_set_coe]

-- how to make these a `to_additive` pair?

lemma prod_units_nonunits {α β : Type*} [Monoid α] [CommMonoid β] [Fintype α] [Fintype αˣ]
  [Fintype <| nonunits α] (f : α → β) :
    (∏ x : αˣ, f x) * ∏ x in (nonunits α).toFinset, f x = ∏ x : α, f x := by
  rw [←Finset.prod_set_coe, ←Fintype.prod_sum_elim]
  apply Fintype.prod_bijective (Sum.elim (· : αˣ → α) (· : nonunits α → α))
  swap; aesop
  refine ⟨?_, fun x ↦ ?_⟩
  · rintro (u | nu) (u | nu) h
    · exact congr(Sum.inl $(Units.ext h))
    · refine (nu.2 ?_).elim
      dsimp at h
      rw [←h]
      exact u.isUnit
    · refine (nu.2 ?_).elim
      dsimp at h
      rw [h]
      exact u.isUnit
    · refine congr(Sum.inr $(Subtype.ext h))
  · by_cases h : IsUnit x
    · exact ⟨.inl h.unit, rfl⟩
    · exact ⟨.inr ⟨x, h⟩, rfl⟩

lemma sum_units_nonunits {α β : Type*} [Monoid α] [AddCommMonoid β] [Fintype α] [Fintype αˣ]
  [Fintype <| nonunits α] (f : α → β) :
    (∑ x : αˣ, f x) + ∑ x in (nonunits α).toFinset, f x = ∑ x : α, f x :=
prod_units_nonunits (β := Multiplicative β) f

-- attribute [to_additive] prod_units_nonunits sum_units_nonunits
-- this is the "correct" additivization but not sure how to tell `to_additive` that

@[simp] lemma nonunits_eq_zero {G : Type*} [GroupWithZero G] : nonunits G = {0} :=
  Set.ext <| fun x ↦ by simpa [nonunits] using (isUnit_iff_ne_zero (a := x)).not

/-- The sum of `x ^ i` as `x` ranges over a finite field of cardinality `q`
is equal to `0` if `i < q - 1`. -/
theorem sum_pow_lt_card_sub_one (i : ℕ) (h : i < q - 1) : ∑ x : K, x ^ i = 0 := by
  by_cases hi : i = 0
  · simp only [hi, nsmul_one, sum_const, pow_zero, card_univ, cast_card_eq_zero]
  classical
  rw [←Fintype.card_units, ←Subgroup.card_top] at h
  have key := sum_subgroup_pow_eq_zero (K := K) (G := ⊤) hi (by convert h)
  erw [Subgroup.sum_top ((· : Kˣ → K) ^ i : Kˣ → K)] at key
  rw [←sum_units_nonunits, ← key]
  simp [hi]

#align finite_field.sum_pow_lt_card_sub_one FiniteField.sum_pow_lt_card_sub_one

so I'll do this in a separate PR tidying up the file

Copy link
Copy Markdown
Contributor

@ericrbg ericrbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - there will be tidying done on this file after! I think it will just blow up this PR's size

maintainer merge

@github-actions
Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by ericrbg.

Copy link
Copy Markdown
Member

@riccardobrasca riccardobrasca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments and LGTM, thanks!

bors d+

@bors
Copy link
Copy Markdown

bors bot commented Sep 28, 2023

✌️ BoltonBailey can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@ghost ghost added delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). and removed awaiting-review labels Sep 28, 2023
BoltonBailey and others added 5 commits September 28, 2023 08:03
Co-authored-by: Riccardo Brasca <riccardo.brasca@gmail.com>
Co-authored-by: Riccardo Brasca <riccardo.brasca@gmail.com>
@BoltonBailey
Copy link
Copy Markdown
Collaborator Author

bors r+

bors bot pushed a commit that referenced this pull request Sep 28, 2023
Adds a theorem saying the cardinality of a multiplicative subgroup of a field, cast to the field, is nonzero. As well as `sum_subgroup_units_zero_of_ne_bot` and other theorems about summing over multiplicative subgroups.

Co-authored-by: Pratyush Mishra <prat@upenn.edu>
Co-authored-by:  Buster <rcopley@gmail.com>
@bors
Copy link
Copy Markdown

bors bot commented Sep 28, 2023

Pull request successfully merged into master.

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot changed the title feat: add theorem cast_subgroup_of_units_card_ne_zero [Merged by Bors] - feat: add theorem cast_subgroup_of_units_card_ne_zero Sep 28, 2023
@bors bors bot closed this Sep 28, 2023
@bors bors bot deleted the BoltonBailey/subgroup_of_units_card_ne_zero branch September 28, 2023 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants