number_theory.legendre_symbol.quadratic_char.basicMathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Michael Stoll
 -/
 import Data.Fintype.Parity
-import NumberTheory.LegendreSymbol.ZmodChar
+import NumberTheory.LegendreSymbol.ZModChar
 import FieldTheory.Finite.Basic
 
 #align_import number_theory.legendre_symbol.quadratic_char.basic from "leanprover-community/mathlib"@"e160cefedc932ce41c7049bf0c4b0f061d06216e"
@@ -322,7 +322,7 @@ theorem quadraticChar_card_sqrts (hF : ringChar F ≠ 2) (a : F) :
       rw [h₁, List.toFinset_cons, List.toFinset_cons, List.toFinset_nil]
       exact Finset.card_pair (Ne.symm (mt (Ring.eq_self_iff_eq_zero_of_char_ne_two hF).mp h₀))
     · rw [quadratic_char_neg_one_iff_not_is_square.mpr h]
-      simp only [Int.coe_nat_eq_zero, Finset.card_eq_zero, Set.toFinset_card, Fintype.card_ofFinset,
+      simp only [Int.natCast_eq_zero, Finset.card_eq_zero, Set.toFinset_card, Fintype.card_ofFinset,
         Set.mem_setOf_eq, add_left_neg]
       ext x
       simp only [iff_false_iff, Finset.mem_filter, Finset.mem_univ, true_and_iff,
Diff
@@ -286,7 +286,7 @@ when the domain has odd characteristic. -/
 theorem quadraticChar_isNontrivial (hF : ringChar F ≠ 2) : (quadraticChar F).IsNontrivial :=
   by
   rcases quadraticChar_exists_neg_one hF with ⟨a, ha⟩
-  have hu : IsUnit a := by by_contra hf; rw [map_nonunit _ hf] at ha ; norm_num at ha 
+  have hu : IsUnit a := by by_contra hf; rw [map_nonunit _ hf] at ha; norm_num at ha
   refine' ⟨hu.unit, (_ : quadraticChar F a ≠ 1)⟩
   rw [ha]
   norm_num
@@ -307,12 +307,12 @@ theorem quadraticChar_card_sqrts (hF : ringChar F ≠ 2) (a : F) :
     by_cases h : IsSquare a
     · rw [(quadraticChar_one_iff_isSquare h₀).mpr h]
       rcases h with ⟨b, h⟩
-      rw [h, mul_self_eq_zero] at h₀ 
+      rw [h, mul_self_eq_zero] at h₀
       have h₁ : s = [b, -b].toFinset := by
         ext x
         simp only [Finset.mem_filter, Finset.mem_univ, true_and_iff, List.toFinset_cons,
           List.toFinset_nil, insert_emptyc_eq, Finset.mem_insert, Finset.mem_singleton]
-        rw [← pow_two] at h 
+        rw [← pow_two] at h
         simp only [hs, Set.mem_toFinset, Set.mem_setOf_eq, h]
         constructor
         · exact eq_or_eq_neg_of_sq_eq_sq _ _
@@ -327,7 +327,7 @@ theorem quadraticChar_card_sqrts (hF : ringChar F ≠ 2) (a : F) :
       ext x
       simp only [iff_false_iff, Finset.mem_filter, Finset.mem_univ, true_and_iff,
         Finset.not_mem_empty]
-      rw [isSquare_iff_exists_sq] at h 
+      rw [isSquare_iff_exists_sq] at h
       exact fun h' => h ⟨_, h'.symm⟩
 #align quadratic_char_card_sqrts quadraticChar_card_sqrts
 -/
Diff
@@ -375,9 +375,21 @@ theorem quadraticChar_neg_one [DecidableEq F] (hF : ringChar F ≠ 2) :
 /-- `-1` is a square in `F` iff `#F` is not congruent to `3` mod `4`. -/
 theorem FiniteField.isSquare_neg_one_iff : IsSquare (-1 : F) ↔ Fintype.card F % 4 ≠ 3 := by
   classical
+  -- suggested by the linter (instead of `[decidable_eq F]`)
+  by_cases hF : ringChar F = 2
+  · simp only [FiniteField.isSquare_of_char_two hF, Ne.def, true_iff_iff]
+    exact fun hf =>
+      one_ne_zero <|
+        (Nat.odd_of_mod_four_eq_three hf).symm.trans <| FiniteField.even_card_of_char_two hF
+  · have h₁ := FiniteField.odd_card_of_char_ne_two hF
+    rw [← quadraticChar_one_iff_isSquare (neg_ne_zero.mpr (one_ne_zero' F)),
+      quadraticChar_neg_one hF, χ₄_nat_eq_if_mod_four, h₁]
+    simp only [Nat.one_ne_zero, if_false, ite_eq_left_iff, Ne.def, (by decide : (-1 : ℤ) ≠ 1),
+      imp_false, Classical.not_not]
+    exact
+      ⟨fun h => ne_of_eq_of_ne h (by decide : 1 ≠ 3), Or.resolve_right (nat.odd_mod_four_iff.mp h₁)⟩
 #align finite_field.is_square_neg_one_iff FiniteField.isSquare_neg_one_iff
 -/
 
--- suggested by the linter (instead of `[decidable_eq F]`)
 end SpecialValues
 
Diff
@@ -375,21 +375,9 @@ theorem quadraticChar_neg_one [DecidableEq F] (hF : ringChar F ≠ 2) :
 /-- `-1` is a square in `F` iff `#F` is not congruent to `3` mod `4`. -/
 theorem FiniteField.isSquare_neg_one_iff : IsSquare (-1 : F) ↔ Fintype.card F % 4 ≠ 3 := by
   classical
-  -- suggested by the linter (instead of `[decidable_eq F]`)
-  by_cases hF : ringChar F = 2
-  · simp only [FiniteField.isSquare_of_char_two hF, Ne.def, true_iff_iff]
-    exact fun hf =>
-      one_ne_zero <|
-        (Nat.odd_of_mod_four_eq_three hf).symm.trans <| FiniteField.even_card_of_char_two hF
-  · have h₁ := FiniteField.odd_card_of_char_ne_two hF
-    rw [← quadraticChar_one_iff_isSquare (neg_ne_zero.mpr (one_ne_zero' F)),
-      quadraticChar_neg_one hF, χ₄_nat_eq_if_mod_four, h₁]
-    simp only [Nat.one_ne_zero, if_false, ite_eq_left_iff, Ne.def, (by decide : (-1 : ℤ) ≠ 1),
-      imp_false, Classical.not_not]
-    exact
-      ⟨fun h => ne_of_eq_of_ne h (by decide : 1 ≠ 3), Or.resolve_right (nat.odd_mod_four_iff.mp h₁)⟩
 #align finite_field.is_square_neg_one_iff FiniteField.isSquare_neg_one_iff
 -/
 
+-- suggested by the linter (instead of `[decidable_eq F]`)
 end SpecialValues
 
Diff
@@ -320,7 +320,7 @@ theorem quadraticChar_card_sqrts (hF : ringChar F ≠ 2) (a : F) :
           simp only [neg_sq]
       norm_cast
       rw [h₁, List.toFinset_cons, List.toFinset_cons, List.toFinset_nil]
-      exact Finset.card_doubleton (Ne.symm (mt (Ring.eq_self_iff_eq_zero_of_char_ne_two hF).mp h₀))
+      exact Finset.card_pair (Ne.symm (mt (Ring.eq_self_iff_eq_zero_of_char_ne_two hF).mp h₀))
     · rw [quadratic_char_neg_one_iff_not_is_square.mpr h]
       simp only [Int.coe_nat_eq_zero, Finset.card_eq_zero, Set.toFinset_card, Fintype.card_ofFinset,
         Set.mem_setOf_eq, add_left_neg]
Diff
@@ -3,9 +3,9 @@ Copyright (c) 2022 Michael Stoll. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Michael Stoll
 -/
-import Mathbin.Data.Fintype.Parity
-import Mathbin.NumberTheory.LegendreSymbol.ZmodChar
-import Mathbin.FieldTheory.Finite.Basic
+import Data.Fintype.Parity
+import NumberTheory.LegendreSymbol.ZmodChar
+import FieldTheory.Finite.Basic
 
 #align_import number_theory.legendre_symbol.quadratic_char.basic from "leanprover-community/mathlib"@"e160cefedc932ce41c7049bf0c4b0f061d06216e"
 
Diff
@@ -2,16 +2,13 @@
 Copyright (c) 2022 Michael Stoll. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Michael Stoll
-
-! This file was ported from Lean 3 source module number_theory.legendre_symbol.quadratic_char.basic
-! leanprover-community/mathlib commit e160cefedc932ce41c7049bf0c4b0f061d06216e
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Data.Fintype.Parity
 import Mathbin.NumberTheory.LegendreSymbol.ZmodChar
 import Mathbin.FieldTheory.Finite.Basic
 
+#align_import number_theory.legendre_symbol.quadratic_char.basic from "leanprover-community/mathlib"@"e160cefedc932ce41c7049bf0c4b0f061d06216e"
+
 /-!
 # Quadratic characters of finite fields
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Michael Stoll
 
 ! This file was ported from Lean 3 source module number_theory.legendre_symbol.quadratic_char.basic
-! leanprover-community/mathlib commit 5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9
+! leanprover-community/mathlib commit e160cefedc932ce41c7049bf0c4b0f061d06216e
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -15,6 +15,9 @@ import Mathbin.FieldTheory.Finite.Basic
 /-!
 # Quadratic characters of finite fields
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 This file defines the quadratic character on a finite field `F` and proves
 some basic statements about it.
 
Diff
@@ -33,6 +33,7 @@ We define the quadratic character of a finite field `F` with values in ℤ.
 
 section Define
 
+#print quadraticCharFun /-
 /-- Define the quadratic character with values in ℤ on a monoid with zero `α`.
 It takes the value zero at zero; for non-zero argument `a : α`, it is `1`
 if `a` is a square, otherwise it is `-1`.
@@ -47,6 +48,7 @@ def quadraticCharFun (α : Type _) [MonoidWithZero α] [DecidableEq α]
     [DecidablePred (IsSquare : α → Prop)] (a : α) : ℤ :=
   if a = 0 then 0 else if IsSquare a then 1 else -1
 #align quadratic_char_fun quadraticCharFun
+-/
 
 end Define
 
@@ -65,6 +67,7 @@ open MulChar
 
 variable {F : Type _} [Field F] [Fintype F] [DecidableEq F]
 
+#print quadraticCharFun_eq_zero_iff /-
 /-- Some basic API lemmas -/
 theorem quadraticCharFun_eq_zero_iff {a : F} : quadraticCharFun F a = 0 ↔ a = 0 :=
   by
@@ -74,17 +77,23 @@ theorem quadraticCharFun_eq_zero_iff {a : F} : quadraticCharFun F a = 0 ↔ a =
   · simp only [ha, if_false, iff_false_iff]
     split_ifs <;> simp only [neg_eq_zero, one_ne_zero, not_false_iff]
 #align quadratic_char_fun_eq_zero_iff quadraticCharFun_eq_zero_iff
+-/
 
+#print quadraticCharFun_zero /-
 @[simp]
 theorem quadraticCharFun_zero : quadraticCharFun F 0 = 0 := by
   simp only [quadraticCharFun, eq_self_iff_true, if_true, id.def]
 #align quadratic_char_fun_zero quadraticCharFun_zero
+-/
 
+#print quadraticCharFun_one /-
 @[simp]
 theorem quadraticCharFun_one : quadraticCharFun F 1 = 1 := by
   simp only [quadraticCharFun, one_ne_zero, isSquare_one, if_true, if_false, id.def]
 #align quadratic_char_fun_one quadraticCharFun_one
+-/
 
+#print quadraticCharFun_eq_one_of_char_two /-
 /-- If `ring_char F = 2`, then `quadratic_char_fun F` takes the value `1` on nonzero elements. -/
 theorem quadraticCharFun_eq_one_of_char_two (hF : ringChar F = 2) {a : F} (ha : a ≠ 0) :
     quadraticCharFun F a = 1 :=
@@ -92,7 +101,9 @@ theorem quadraticCharFun_eq_one_of_char_two (hF : ringChar F = 2) {a : F} (ha :
   simp only [quadraticCharFun, ha, if_false, ite_eq_left_iff]
   exact fun h => False.ndrec _ (h (FiniteField.isSquare_of_char_two hF a))
 #align quadratic_char_fun_eq_one_of_char_two quadraticCharFun_eq_one_of_char_two
+-/
 
+#print quadraticCharFun_eq_pow_of_char_ne_two /-
 /-- If `ring_char F` is odd, then `quadratic_char_fun F a` can be computed in
 terms of `a ^ (fintype.card F / 2)`. -/
 theorem quadraticCharFun_eq_pow_of_char_ne_two (hF : ringChar F ≠ 2) {a : F} (ha : a ≠ 0) :
@@ -101,7 +112,9 @@ theorem quadraticCharFun_eq_pow_of_char_ne_two (hF : ringChar F ≠ 2) {a : F} (
   simp only [quadraticCharFun, ha, if_false]
   simp_rw [FiniteField.isSquare_iff hF ha]
 #align quadratic_char_fun_eq_pow_of_char_ne_two quadraticCharFun_eq_pow_of_char_ne_two
+-/
 
+#print quadraticCharFun_mul /-
 /-- The quadratic character is multiplicative. -/
 theorem quadraticCharFun_mul (a b : F) :
     quadraticCharFun F (a * b) = quadraticCharFun F a * quadraticCharFun F b :=
@@ -128,9 +141,11 @@ theorem quadraticCharFun_mul (a b : F) :
       cases' FiniteField.pow_dichotomy hF ha with ha' ha' <;>
         simp only [ha', h, neg_neg, eq_self_iff_true, if_true, if_false]
 #align quadratic_char_fun_mul quadraticCharFun_mul
+-/
 
 variable (F)
 
+#print quadraticChar /-
 /-- The quadratic character as a multiplicative character. -/
 @[simps]
 def quadraticChar : MulChar F ℤ where
@@ -139,43 +154,57 @@ def quadraticChar : MulChar F ℤ where
   map_mul' := quadraticCharFun_mul
   map_nonunit' a ha := by rw [of_not_not (mt Ne.isUnit ha)]; exact quadraticCharFun_zero
 #align quadratic_char quadraticChar
+-/
 
 variable {F}
 
+#print quadraticChar_eq_zero_iff /-
 /-- The value of the quadratic character on `a` is zero iff `a = 0`. -/
 theorem quadraticChar_eq_zero_iff {a : F} : quadraticChar F a = 0 ↔ a = 0 :=
   quadraticCharFun_eq_zero_iff
 #align quadratic_char_eq_zero_iff quadraticChar_eq_zero_iff
+-/
 
+#print quadraticChar_zero /-
 @[simp]
 theorem quadraticChar_zero : quadraticChar F 0 = 0 := by
   simp only [quadraticChar_apply, quadraticCharFun_zero]
 #align quadratic_char_zero quadraticChar_zero
+-/
 
+#print quadraticChar_one_iff_isSquare /-
 /-- For nonzero `a : F`, `quadratic_char F a = 1 ↔ is_square a`. -/
 theorem quadraticChar_one_iff_isSquare {a : F} (ha : a ≠ 0) : quadraticChar F a = 1 ↔ IsSquare a :=
   by
   simp only [quadraticChar_apply, quadraticCharFun, ha, (by decide : (-1 : ℤ) ≠ 1), if_false,
     ite_eq_left_iff, imp_false, Classical.not_not]
 #align quadratic_char_one_iff_is_square quadraticChar_one_iff_isSquare
+-/
 
+#print quadraticChar_sq_one' /-
 /-- The quadratic character takes the value `1` on nonzero squares. -/
 theorem quadraticChar_sq_one' {a : F} (ha : a ≠ 0) : quadraticChar F (a ^ 2) = 1 := by
   simp only [quadraticCharFun, ha, pow_eq_zero_iff, Nat.succ_pos', IsSquare_sq, if_true, if_false,
     quadraticChar_apply]
 #align quadratic_char_sq_one' quadraticChar_sq_one'
+-/
 
+#print quadraticChar_sq_one /-
 /-- The square of the quadratic character on nonzero arguments is `1`. -/
 theorem quadraticChar_sq_one {a : F} (ha : a ≠ 0) : quadraticChar F a ^ 2 = 1 := by
   rwa [pow_two, ← map_mul, ← pow_two, quadraticChar_sq_one']
 #align quadratic_char_sq_one quadraticChar_sq_one
+-/
 
+#print quadraticChar_dichotomy /-
 /-- The quadratic character is `1` or `-1` on nonzero arguments. -/
 theorem quadraticChar_dichotomy {a : F} (ha : a ≠ 0) :
     quadraticChar F a = 1 ∨ quadraticChar F a = -1 :=
   sq_eq_one_iff.1 <| quadraticChar_sq_one ha
 #align quadratic_char_dichotomy quadraticChar_dichotomy
+-/
 
+#print quadraticChar_eq_neg_one_iff_not_one /-
 /-- The quadratic character is `1` or `-1` on nonzero arguments. -/
 theorem quadraticChar_eq_neg_one_iff_not_one {a : F} (ha : a ≠ 0) :
     quadraticChar F a = -1 ↔ ¬quadraticChar F a = 1 :=
@@ -184,7 +213,9 @@ theorem quadraticChar_eq_neg_one_iff_not_one {a : F} (ha : a ≠ 0) :
   rw [h]
   norm_num
 #align quadratic_char_eq_neg_one_iff_not_one quadraticChar_eq_neg_one_iff_not_one
+-/
 
+#print quadraticChar_neg_one_iff_not_isSquare /-
 /-- For `a : F`, `quadratic_char F a = -1 ↔ ¬ is_square a`. -/
 theorem quadraticChar_neg_one_iff_not_isSquare {a : F} : quadraticChar F a = -1 ↔ ¬IsSquare a :=
   by
@@ -192,25 +223,33 @@ theorem quadraticChar_neg_one_iff_not_isSquare {a : F} : quadraticChar F a = -1
   · simp only [ha, isSquare_zero, MulChar.map_zero, zero_eq_neg, one_ne_zero, not_true]
   · rw [quadraticChar_eq_neg_one_iff_not_one ha, quadraticChar_one_iff_isSquare ha]
 #align quadratic_char_neg_one_iff_not_is_square quadraticChar_neg_one_iff_not_isSquare
+-/
 
+#print quadraticChar_exists_neg_one /-
 /-- If `F` has odd characteristic, then `quadratic_char F` takes the value `-1`. -/
 theorem quadraticChar_exists_neg_one (hF : ringChar F ≠ 2) : ∃ a, quadraticChar F a = -1 :=
   (FiniteField.exists_nonsquare hF).imp fun b h₁ => quadraticChar_neg_one_iff_not_isSquare.mpr h₁
 #align quadratic_char_exists_neg_one quadraticChar_exists_neg_one
+-/
 
+#print quadraticChar_eq_one_of_char_two /-
 /-- If `ring_char F = 2`, then `quadratic_char F` takes the value `1` on nonzero elements. -/
 theorem quadraticChar_eq_one_of_char_two (hF : ringChar F = 2) {a : F} (ha : a ≠ 0) :
     quadraticChar F a = 1 :=
   quadraticCharFun_eq_one_of_char_two hF ha
 #align quadratic_char_eq_one_of_char_two quadraticChar_eq_one_of_char_two
+-/
 
+#print quadraticChar_eq_pow_of_char_ne_two /-
 /-- If `ring_char F` is odd, then `quadratic_char F a` can be computed in
 terms of `a ^ (fintype.card F / 2)`. -/
 theorem quadraticChar_eq_pow_of_char_ne_two (hF : ringChar F ≠ 2) {a : F} (ha : a ≠ 0) :
     quadraticChar F a = if a ^ (Fintype.card F / 2) = 1 then 1 else -1 :=
   quadraticCharFun_eq_pow_of_char_ne_two hF ha
 #align quadratic_char_eq_pow_of_char_ne_two quadraticChar_eq_pow_of_char_ne_two
+-/
 
+#print quadraticChar_eq_pow_of_char_ne_two' /-
 theorem quadraticChar_eq_pow_of_char_ne_two' (hF : ringChar F ≠ 2) (a : F) :
     (quadraticChar F a : F) = a ^ (Fintype.card F / 2) :=
   by
@@ -224,9 +263,11 @@ theorem quadraticChar_eq_pow_of_char_ne_two' (hF : ringChar F ≠ 2) (a : F) :
       simp only [ha'', Int.cast_ite, Int.cast_one, Int.cast_neg, ite_eq_right_iff]
       exact Eq.symm
 #align quadratic_char_eq_pow_of_char_ne_two' quadraticChar_eq_pow_of_char_ne_two'
+-/
 
 variable (F)
 
+#print quadraticChar_isQuadratic /-
 /-- The quadratic character is quadratic as a multiplicative character. -/
 theorem quadraticChar_isQuadratic : (quadraticChar F).IsQuadratic :=
   by
@@ -235,9 +276,11 @@ theorem quadraticChar_isQuadratic : (quadraticChar F).IsQuadratic :=
   · left; rw [ha]; exact quadraticChar_zero
   · right; exact quadraticChar_dichotomy ha
 #align quadratic_char_is_quadratic quadraticChar_isQuadratic
+-/
 
 variable {F}
 
+#print quadraticChar_isNontrivial /-
 /-- The quadratic character is nontrivial as a multiplicative character
 when the domain has odd characteristic. -/
 theorem quadraticChar_isNontrivial (hF : ringChar F ≠ 2) : (quadraticChar F).IsNontrivial :=
@@ -248,7 +291,9 @@ theorem quadraticChar_isNontrivial (hF : ringChar F ≠ 2) : (quadraticChar F).I
   rw [ha]
   norm_num
 #align quadratic_char_is_nontrivial quadraticChar_isNontrivial
+-/
 
+#print quadraticChar_card_sqrts /-
 /-- The number of solutions to `x^2 = a` is determined by the quadratic character. -/
 theorem quadraticChar_card_sqrts (hF : ringChar F ≠ 2) (a : F) :
     ↑{x : F | x ^ 2 = a}.toFinset.card = quadraticChar F a + 1 :=
@@ -285,13 +330,16 @@ theorem quadraticChar_card_sqrts (hF : ringChar F ≠ 2) (a : F) :
       rw [isSquare_iff_exists_sq] at h 
       exact fun h' => h ⟨_, h'.symm⟩
 #align quadratic_char_card_sqrts quadraticChar_card_sqrts
+-/
 
 open scoped BigOperators
 
+#print quadraticChar_sum_zero /-
 /-- The sum over the values of the quadratic character is zero when the characteristic is odd. -/
 theorem quadraticChar_sum_zero (hF : ringChar F ≠ 2) : ∑ a : F, quadraticChar F a = 0 :=
   IsNontrivial.sum_eq_zero (quadraticChar_isNontrivial hF)
 #align quadratic_char_sum_zero quadraticChar_sum_zero
+-/
 
 end quadraticChar
 
@@ -308,6 +356,7 @@ open ZMod MulChar
 
 variable {F : Type _} [Field F] [Fintype F]
 
+#print quadraticChar_neg_one /-
 /-- The value of the quadratic character at `-1` -/
 theorem quadraticChar_neg_one [DecidableEq F] (hF : ringChar F ≠ 2) :
     quadraticChar F (-1) = χ₄ (Fintype.card F) :=
@@ -320,7 +369,9 @@ theorem quadraticChar_neg_one [DecidableEq F] (hF : ringChar F ≠ 2) :
   · simp only [Odd.neg_one_pow h₂, ite_eq_right_iff]
     exact fun hf => False.ndrec (1 = -1) (Ring.neg_one_ne_one_of_char_ne_two hF hf)
 #align quadratic_char_neg_one quadraticChar_neg_one
+-/
 
+#print FiniteField.isSquare_neg_one_iff /-
 /-- `-1` is a square in `F` iff `#F` is not congruent to `3` mod `4`. -/
 theorem FiniteField.isSquare_neg_one_iff : IsSquare (-1 : F) ↔ Fintype.card F % 4 ≠ 3 := by
   classical
@@ -338,6 +389,7 @@ theorem FiniteField.isSquare_neg_one_iff : IsSquare (-1 : F) ↔ Fintype.card F
     exact
       ⟨fun h => ne_of_eq_of_ne h (by decide : 1 ≠ 3), Or.resolve_right (nat.odd_mod_four_iff.mp h₁)⟩
 #align finite_field.is_square_neg_one_iff FiniteField.isSquare_neg_one_iff
+-/
 
 end SpecialValues
 
Diff
@@ -3,15 +3,14 @@ Copyright (c) 2022 Michael Stoll. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Michael Stoll
 
-! This file was ported from Lean 3 source module number_theory.legendre_symbol.quadratic_char
-! leanprover-community/mathlib commit d11893b411025250c8e61ff2f12ccbd7ee35ab15
+! This file was ported from Lean 3 source module number_theory.legendre_symbol.quadratic_char.basic
+! leanprover-community/mathlib commit 5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
 import Mathbin.Data.Fintype.Parity
 import Mathbin.NumberTheory.LegendreSymbol.ZmodChar
 import Mathbin.FieldTheory.Finite.Basic
-import Mathbin.NumberTheory.LegendreSymbol.GaussSum
 
 /-!
 # Quadratic characters of finite fields
@@ -340,126 +339,5 @@ theorem FiniteField.isSquare_neg_one_iff : IsSquare (-1 : F) ↔ Fintype.card F
       ⟨fun h => ne_of_eq_of_ne h (by decide : 1 ≠ 3), Or.resolve_right (nat.odd_mod_four_iff.mp h₁)⟩
 #align finite_field.is_square_neg_one_iff FiniteField.isSquare_neg_one_iff
 
-/-- The value of the quadratic character at `2` -/
-theorem quadraticChar_two [DecidableEq F] (hF : ringChar F ≠ 2) :
-    quadraticChar F 2 = χ₈ (Fintype.card F) :=
-  IsQuadratic.eq_of_eq_coe (quadraticChar_isQuadratic F) isQuadratic_χ₈ hF
-    ((quadraticChar_eq_pow_of_char_ne_two' hF 2).trans (FiniteField.two_pow_card hF))
-#align quadratic_char_two quadraticChar_two
-
-/-- `2` is a square in `F` iff `#F` is not congruent to `3` or `5` mod `8`. -/
-theorem FiniteField.isSquare_two_iff :
-    IsSquare (2 : F) ↔ Fintype.card F % 8 ≠ 3 ∧ Fintype.card F % 8 ≠ 5 := by
-  classical
-  by_cases hF : ringChar F = 2
-  focus
-    have h := FiniteField.even_card_of_char_two hF
-    simp only [FiniteField.isSquare_of_char_two hF, true_iff_iff]
-  rotate_left
-  focus
-    have h := FiniteField.odd_card_of_char_ne_two hF
-    rw [← quadraticChar_one_iff_isSquare (Ring.two_ne_zero hF), quadraticChar_two hF,
-      χ₈_nat_eq_if_mod_eight]
-    simp only [h, Nat.one_ne_zero, if_false, ite_eq_left_iff, Ne.def, (by decide : (-1 : ℤ) ≠ 1),
-      imp_false, Classical.not_not]
-  all_goals
-    rw [← Nat.mod_mod_of_dvd _ (by norm_num : 2 ∣ 8)] at h 
-    have h₁ := Nat.mod_lt (Fintype.card F) (by decide : 0 < 8)
-    revert h₁ h
-    generalize Fintype.card F % 8 = n
-    decide!
-#align finite_field.is_square_two_iff FiniteField.isSquare_two_iff
-
-/-- The value of the quadratic character at `-2` -/
-theorem quadraticChar_neg_two [DecidableEq F] (hF : ringChar F ≠ 2) :
-    quadraticChar F (-2) = χ₈' (Fintype.card F) := by
-  rw [(by norm_num : (-2 : F) = -1 * 2), map_mul, χ₈'_eq_χ₄_mul_χ₈, quadraticChar_neg_one hF,
-    quadraticChar_two hF, @cast_nat_cast _ (ZMod 4) _ _ _ (by norm_num : 4 ∣ 8)]
-#align quadratic_char_neg_two quadraticChar_neg_two
-
-/-- `-2` is a square in `F` iff `#F` is not congruent to `5` or `7` mod `8`. -/
-theorem FiniteField.isSquare_neg_two_iff :
-    IsSquare (-2 : F) ↔ Fintype.card F % 8 ≠ 5 ∧ Fintype.card F % 8 ≠ 7 := by
-  classical
-  by_cases hF : ringChar F = 2
-  focus
-    have h := FiniteField.even_card_of_char_two hF
-    simp only [FiniteField.isSquare_of_char_two hF, true_iff_iff]
-  rotate_left
-  focus
-    have h := FiniteField.odd_card_of_char_ne_two hF
-    rw [← quadraticChar_one_iff_isSquare (neg_ne_zero.mpr (Ring.two_ne_zero hF)),
-      quadraticChar_neg_two hF, χ₈'_nat_eq_if_mod_eight]
-    simp only [h, Nat.one_ne_zero, if_false, ite_eq_left_iff, Ne.def, (by decide : (-1 : ℤ) ≠ 1),
-      imp_false, Classical.not_not]
-  all_goals
-    rw [← Nat.mod_mod_of_dvd _ (by norm_num : 2 ∣ 8)] at h 
-    have h₁ := Nat.mod_lt (Fintype.card F) (by decide : 0 < 8)
-    revert h₁ h
-    generalize Fintype.card F % 8 = n
-    decide!
-#align finite_field.is_square_neg_two_iff FiniteField.isSquare_neg_two_iff
-
-/-- The relation between the values of the quadratic character of one field `F` at the
-cardinality of another field `F'` and of the quadratic character of `F'` at the cardinality
-of `F`. -/
-theorem quadraticChar_card_card [DecidableEq F] (hF : ringChar F ≠ 2) {F' : Type _} [Field F']
-    [Fintype F'] [DecidableEq F'] (hF' : ringChar F' ≠ 2) (h : ringChar F' ≠ ringChar F) :
-    quadraticChar F (Fintype.card F') = quadraticChar F' (quadraticChar F (-1) * Fintype.card F) :=
-  by
-  let χ := (quadraticChar F).ringHomComp (algebraMap ℤ F')
-  have hχ₁ : χ.is_nontrivial :=
-    by
-    obtain ⟨a, ha⟩ := quadraticChar_exists_neg_one hF
-    have hu : IsUnit a := by
-      contrapose ha
-      exact ne_of_eq_of_ne (map_nonunit (quadraticChar F) ha) (mt zero_eq_neg.mp one_ne_zero)
-    use hu.unit
-    simp only [IsUnit.unit_spec, ring_hom_comp_apply, eq_intCast, Ne.def, ha]
-    rw [Int.cast_neg, Int.cast_one]
-    exact Ring.neg_one_ne_one_of_char_ne_two hF'
-  have hχ₂ : χ.is_quadratic := is_quadratic.comp (quadraticChar_isQuadratic F) _
-  have h := Char.card_pow_card hχ₁ hχ₂ h hF'
-  rw [← quadraticChar_eq_pow_of_char_ne_two' hF'] at h 
-  exact
-    (is_quadratic.eq_of_eq_coe (quadraticChar_isQuadratic F') (quadraticChar_isQuadratic F) hF'
-        h).symm
-#align quadratic_char_card_card quadraticChar_card_card
-
-/-- The value of the quadratic character at an odd prime `p` different from `ring_char F`. -/
-theorem quadraticChar_odd_prime [DecidableEq F] (hF : ringChar F ≠ 2) {p : ℕ} [Fact p.Prime]
-    (hp₁ : p ≠ 2) (hp₂ : ringChar F ≠ p) :
-    quadraticChar F p = quadraticChar (ZMod p) (χ₄ (Fintype.card F) * Fintype.card F) :=
-  by
-  rw [← quadraticChar_neg_one hF]
-  have h :=
-    quadraticChar_card_card hF (ne_of_eq_of_ne (ring_char_zmod_n p) hp₁)
-      (ne_of_eq_of_ne (ring_char_zmod_n p) hp₂.symm)
-  rwa [card p] at h 
-#align quadratic_char_odd_prime quadraticChar_odd_prime
-
-/-- An odd prime `p` is a square in `F` iff the quadratic character of `zmod p` does not
-take the value `-1` on `χ₄(#F) * #F`. -/
-theorem FiniteField.isSquare_odd_prime_iff (hF : ringChar F ≠ 2) {p : ℕ} [Fact p.Prime]
-    (hp : p ≠ 2) :
-    IsSquare (p : F) ↔ quadraticChar (ZMod p) (χ₄ (Fintype.card F) * Fintype.card F) ≠ -1 := by
-  classical
-  by_cases hFp : ringChar F = p
-  · rw [show (p : F) = 0 by rw [← hFp]; exact ringChar.Nat.cast_ringChar]
-    simp only [isSquare_zero, Ne.def, true_iff_iff, map_mul]
-    obtain ⟨n, _, hc⟩ := FiniteField.card F (ringChar F)
-    have hchar : ringChar F = ringChar (ZMod p) := by rw [hFp]; exact (ring_char_zmod_n p).symm
-    conv =>
-      congr
-      lhs
-      congr
-      skip
-      rw [hc, Nat.cast_pow, map_pow, hchar, map_ring_char]
-    simp only [zero_pow n.pos, MulZeroClass.mul_zero, zero_eq_neg, one_ne_zero, not_false_iff]
-  · rw [← Iff.not_left (@quadraticChar_neg_one_iff_not_isSquare F _ _ _ _),
-      quadraticChar_odd_prime hF hp]
-    exact hFp
-#align finite_field.is_square_odd_prime_iff FiniteField.isSquare_odd_prime_iff
-
 end SpecialValues
 

Changes in mathlib4

mathlib3
mathlib4
chore: avoid id.def (adaptation for nightly-2024-03-27) (#11829)

Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com>

Diff
@@ -73,12 +73,12 @@ theorem quadraticCharFun_eq_zero_iff {a : F} : quadraticCharFun F a = 0 ↔ a =
 
 @[simp]
 theorem quadraticCharFun_zero : quadraticCharFun F 0 = 0 := by
-  simp only [quadraticCharFun, eq_self_iff_true, if_true, id.def]
+  simp only [quadraticCharFun, eq_self_iff_true, if_true, id]
 #align quadratic_char_fun_zero quadraticCharFun_zero
 
 @[simp]
 theorem quadraticCharFun_one : quadraticCharFun F 1 = 1 := by
-  simp only [quadraticCharFun, one_ne_zero, isSquare_one, if_true, if_false, id.def]
+  simp only [quadraticCharFun, one_ne_zero, isSquare_one, if_true, if_false, id]
 #align quadratic_char_fun_one quadraticCharFun_one
 
 /-- If `ringChar F = 2`, then `quadraticCharFun F` takes the value `1` on nonzero elements. -/
chore(Data/Int): Rename coe_nat to natCast (#11637)

Reduce the diff of #11499

Renames

All in the Int namespace:

  • ofNat_eq_castofNat_eq_natCast
  • cast_eq_cast_iff_NatnatCast_inj
  • natCast_eq_ofNatofNat_eq_natCast
  • coe_nat_subnatCast_sub
  • coe_nat_nonnegnatCast_nonneg
  • sign_coe_add_onesign_natCast_add_one
  • nat_succ_eq_int_succnatCast_succ
  • succ_neg_nat_succsucc_neg_natCast_succ
  • coe_pred_of_posnatCast_pred_of_pos
  • coe_nat_divnatCast_div
  • coe_nat_edivnatCast_ediv
  • sign_coe_nat_of_nonzerosign_natCast_of_ne_zero
  • toNat_coe_nattoNat_natCast
  • toNat_coe_nat_add_onetoNat_natCast_add_one
  • coe_nat_dvdnatCast_dvd_natCast
  • coe_nat_dvd_leftnatCast_dvd
  • coe_nat_dvd_rightdvd_natCast
  • le_coe_nat_suble_natCast_sub
  • succ_coe_nat_possucc_natCast_pos
  • coe_nat_modEq_iffnatCast_modEq_iff
  • coe_natAbsnatCast_natAbs
  • coe_nat_eq_zeronatCast_eq_zero
  • coe_nat_ne_zeronatCast_ne_zero
  • coe_nat_ne_zero_iff_posnatCast_ne_zero_iff_pos
  • abs_coe_natabs_natCast
  • coe_nat_nonpos_iffnatCast_nonpos_iff

Also rename Nat.coe_nat_dvd to Nat.cast_dvd_cast

Diff
@@ -266,7 +266,7 @@ theorem quadraticChar_card_sqrts (hF : ringChar F ≠ 2) (a : F) :
       rw [h₁, List.toFinset_cons, List.toFinset_cons, List.toFinset_nil]
       exact Finset.card_pair (Ne.symm (mt (Ring.eq_self_iff_eq_zero_of_char_ne_two hF).mp h₀))
     · rw [quadraticChar_neg_one_iff_not_isSquare.mpr h]
-      simp only [Int.coe_nat_eq_zero, Finset.card_eq_zero, Set.toFinset_card, Fintype.card_ofFinset,
+      simp only [Int.natCast_eq_zero, Finset.card_eq_zero, Set.toFinset_card, Fintype.card_ofFinset,
         Set.mem_setOf_eq, add_left_neg]
       ext x
       -- Porting note(https://github.com/leanprover-community/mathlib4/issues/5026):
chore: avoid Ne.def (adaptation for nightly-2024-03-27) (#11813)
Diff
@@ -314,14 +314,14 @@ theorem quadraticChar_neg_one [DecidableEq F] (hF : ringChar F ≠ 2) :
 theorem FiniteField.isSquare_neg_one_iff : IsSquare (-1 : F) ↔ Fintype.card F % 4 ≠ 3 := by
   classical -- suggested by the linter (instead of `[DecidableEq F]`)
   by_cases hF : ringChar F = 2
-  · simp only [FiniteField.isSquare_of_char_two hF, Ne.def, true_iff_iff]
+  · simp only [FiniteField.isSquare_of_char_two hF, Ne, true_iff_iff]
     exact fun hf =>
       one_ne_zero <|
         (Nat.odd_of_mod_four_eq_three hf).symm.trans <| FiniteField.even_card_of_char_two hF
   · have h₁ := FiniteField.odd_card_of_char_ne_two hF
     rw [← quadraticChar_one_iff_isSquare (neg_ne_zero.mpr (one_ne_zero' F)),
       quadraticChar_neg_one hF, χ₄_nat_eq_if_mod_four, h₁]
-    simp only [Nat.one_ne_zero, if_false, ite_eq_left_iff, Ne.def, (by decide : (-1 : ℤ) ≠ 1),
+    simp only [Nat.one_ne_zero, if_false, ite_eq_left_iff, Ne, (by decide : (-1 : ℤ) ≠ 1),
       imp_false, Classical.not_not]
     exact
       ⟨fun h => ne_of_eq_of_ne h (by decide : 1 ≠ 3), Or.resolve_right (Nat.odd_mod_four_iff.mp h₁)⟩
chore: more backporting of simp changes from #10995 (#11001)

Co-authored-by: Patrick Massot <patrickmassot@free.fr> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -257,7 +257,7 @@ theorem quadraticChar_card_sqrts (hF : ringChar F ≠ 2) (a : F) :
         simp only [Finset.mem_filter, Finset.mem_univ, true_and_iff, List.toFinset_cons,
           List.toFinset_nil, insert_emptyc_eq, Finset.mem_insert, Finset.mem_singleton]
         rw [← pow_two] at h
-        simp only [h, Set.toFinset_setOf, Finset.mem_univ, Finset.mem_filter, true_and]
+        simp only [s, h, Set.toFinset_setOf, Finset.mem_univ, Finset.mem_filter, true_and]
         constructor
         · exact eq_or_eq_neg_of_sq_eq_sq _ _
         · rintro (h₂ | h₂) <;> rw [h₂]
chore: classify simp can do this porting notes (#10619)

Classify by adding issue number (#10618) to porting notes claiming anything semantically equivalent to simp can prove this or simp can simplify this.

Diff
@@ -140,7 +140,7 @@ theorem quadraticChar_eq_zero_iff {a : F} : quadraticChar F a = 0 ↔ a = 0 :=
   quadraticCharFun_eq_zero_iff
 #align quadratic_char_eq_zero_iff quadraticChar_eq_zero_iff
 
--- @[simp] -- Porting note: simp can prove this
+-- @[simp] -- Porting note (#10618): simp can prove this
 theorem quadraticChar_zero : quadraticChar F 0 = 0 := by
   simp only [quadraticChar_apply, quadraticCharFun_zero]
 #align quadratic_char_zero quadraticChar_zero
feat: The support of f ^ n (#9617)

This involves moving lemmas from Algebra.GroupPower.Ring to Algebra.GroupWithZero.Basic and changing some 0 < n assumptions to n ≠ 0.

From LeanAPAP

Diff
@@ -154,7 +154,7 @@ theorem quadraticChar_one_iff_isSquare {a : F} (ha : a ≠ 0) :
 
 /-- The quadratic character takes the value `1` on nonzero squares. -/
 theorem quadraticChar_sq_one' {a : F} (ha : a ≠ 0) : quadraticChar F (a ^ 2) = 1 := by
-  simp only [quadraticCharFun, ha, pow_eq_zero_iff, Nat.succ_pos', IsSquare_sq, if_true, if_false,
+  simp only [quadraticCharFun, ha, sq_eq_zero_iff, IsSquare_sq, if_true, if_false,
     quadraticChar_apply]
 #align quadratic_char_sq_one' quadraticChar_sq_one'
 
@@ -209,7 +209,7 @@ theorem quadraticChar_eq_pow_of_char_ne_two' (hF : ringChar F ≠ 2) (a : F) :
     (quadraticChar F a : F) = a ^ (Fintype.card F / 2) := by
   by_cases ha : a = 0
   · have : 0 < Fintype.card F / 2 := Nat.div_pos Fintype.one_lt_card two_pos
-    simp only [ha, zero_pow this, quadraticChar_apply, quadraticCharFun_zero, Int.cast_zero]
+    simp only [ha, zero_pow this.ne', quadraticChar_apply, quadraticCharFun_zero, Int.cast_zero]
   · rw [quadraticChar_eq_pow_of_char_ne_two hF ha]
     by_cases ha' : a ^ (Fintype.card F / 2) = 1
     · simp only [ha', eq_self_iff_true, if_true, Int.cast_one]
@@ -245,7 +245,7 @@ theorem quadraticChar_card_sqrts (hF : ringChar F ≠ 2) (a : F) :
     ↑{x : F | x ^ 2 = a}.toFinset.card = quadraticChar F a + 1 := by
   -- we consider the cases `a = 0`, `a` is a nonzero square and `a` is a nonsquare in turn
   by_cases h₀ : a = 0
-  · simp only [h₀, pow_eq_zero_iff, Nat.succ_pos', Int.ofNat_succ, Int.ofNat_zero, MulChar.map_zero,
+  · simp only [h₀, sq_eq_zero_iff, Int.ofNat_succ, Int.ofNat_zero, MulChar.map_zero,
       Set.setOf_eq_eq_singleton, Set.toFinset_card, Set.card_singleton]
   · set s := {x : F | x ^ 2 = a}.toFinset
     by_cases h : IsSquare a
chore: rename Finset.card_doubleton to Finset.card_pair (#9379)
Diff
@@ -264,7 +264,7 @@ theorem quadraticChar_card_sqrts (hF : ringChar F ≠ 2) (a : F) :
           simp only [neg_sq]
       norm_cast
       rw [h₁, List.toFinset_cons, List.toFinset_cons, List.toFinset_nil]
-      exact Finset.card_doubleton (Ne.symm (mt (Ring.eq_self_iff_eq_zero_of_char_ne_two hF).mp h₀))
+      exact Finset.card_pair (Ne.symm (mt (Ring.eq_self_iff_eq_zero_of_char_ne_two hF).mp h₀))
     · rw [quadraticChar_neg_one_iff_not_isSquare.mpr h]
       simp only [Int.coe_nat_eq_zero, Finset.card_eq_zero, Set.toFinset_card, Fintype.card_ofFinset,
         Set.mem_setOf_eq, add_left_neg]
chore: bump to v4.3.0-rc2 (#8366)

PR contents

This is the supremum of

along with some minor fixes from failures on nightly-testing as Mathlib master is merged into it.

Note that some PRs for changes that are already compatible with the current toolchain and will be necessary have already been split out: #8380.

I am hopeful that in future we will be able to progressively merge adaptation PRs into a bump/v4.X.0 branch, so we never end up with a "big merge" like this. However one of these adaptation PRs (#8056) predates my new scheme for combined CI, and it wasn't possible to keep that PR viable in the meantime.

Lean PRs involved in this bump

In particular this includes adjustments for the Lean PRs

leanprover/lean4#2778

We can get rid of all the

local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue [lean4#2220](https://github.com/leanprover/lean4/pull/2220)

macros across Mathlib (and in any projects that want to write natural number powers of reals).

leanprover/lean4#2722

Changes the default behaviour of simp to (config := {decide := false}). This makes simp (and consequentially norm_num) less powerful, but also more consistent, and less likely to blow up in long failures. This requires a variety of changes: changing some previously by simp or norm_num to decide or rfl, or adding (config := {decide := true}).

leanprover/lean4#2783

This changed the behaviour of simp so that simp [f] will only unfold "fully applied" occurrences of f. The old behaviour can be recovered with simp (config := { unfoldPartialApp := true }). We may in future add a syntax for this, e.g. simp [!f]; please provide feedback! In the meantime, we have made the following changes:

  • switching to using explicit lemmas that have the intended level of application
  • (config := { unfoldPartialApp := true }) in some places, to recover the old behaviour
  • Using @[eqns] to manually adjust the equation lemmas for a particular definition, recovering the old behaviour just for that definition. See #8371, where we do this for Function.comp and Function.flip.

This change in Lean may require further changes down the line (e.g. adding the !f syntax, and/or upstreaming the special treatment for Function.comp and Function.flip, and/or removing this special treatment). Please keep an open and skeptical mind about these changes!

Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Mauricio Collares <mauricio@collares.org>

Diff
@@ -85,7 +85,7 @@ theorem quadraticCharFun_one : quadraticCharFun F 1 = 1 := by
 theorem quadraticCharFun_eq_one_of_char_two (hF : ringChar F = 2) {a : F} (ha : a ≠ 0) :
     quadraticCharFun F a = 1 := by
   simp only [quadraticCharFun, ha, if_false, ite_eq_left_iff]
-  exact fun h => h (FiniteField.isSquare_of_char_two hF a)
+  exact fun h => (h (FiniteField.isSquare_of_char_two hF a)).elim
 #align quadratic_char_fun_eq_one_of_char_two quadraticCharFun_eq_one_of_char_two
 
 /-- If `ringChar F` is odd, then `quadraticCharFun F a` can be computed in
chore: drop MulZeroClass. in mul_zero/zero_mul (#6682)

Search&replace MulZeroClass.mul_zero -> mul_zero, MulZeroClass.zero_mul -> zero_mul.

These were introduced by Mathport, as the full name of mul_zero is actually MulZeroClass.mul_zero (it's exported with the short name).

Diff
@@ -100,10 +100,10 @@ theorem quadraticCharFun_eq_pow_of_char_ne_two (hF : ringChar F ≠ 2) {a : F} (
 theorem quadraticCharFun_mul (a b : F) :
     quadraticCharFun F (a * b) = quadraticCharFun F a * quadraticCharFun F b := by
   by_cases ha : a = 0
-  · rw [ha, MulZeroClass.zero_mul, quadraticCharFun_zero, MulZeroClass.zero_mul]
+  · rw [ha, zero_mul, quadraticCharFun_zero, zero_mul]
   -- now `a ≠ 0`
   by_cases hb : b = 0
-  · rw [hb, MulZeroClass.mul_zero, quadraticCharFun_zero, MulZeroClass.mul_zero]
+  · rw [hb, mul_zero, quadraticCharFun_zero, mul_zero]
   -- now `a ≠ 0` and `b ≠ 0`
   have hab := mul_ne_zero ha hb
   by_cases hF : ringChar F = 2
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -40,7 +40,7 @@ e.g., when `α` is a finite field. See `quadraticCharFun_mul`.
 We will later define `quadraticChar` to be a multiplicative character
 of type `MulChar F ℤ`, when the domain is a finite field `F`.
 -/
-def quadraticCharFun (α : Type _) [MonoidWithZero α] [DecidableEq α]
+def quadraticCharFun (α : Type*) [MonoidWithZero α] [DecidableEq α]
     [DecidablePred (IsSquare : α → Prop)] (a : α) : ℤ :=
   if a = 0 then 0 else if IsSquare a then 1 else -1
 #align quadratic_char_fun quadraticCharFun
@@ -60,7 +60,7 @@ section quadraticChar
 
 open MulChar
 
-variable {F : Type _} [Field F] [Fintype F] [DecidableEq F]
+variable {F : Type*} [Field F] [Fintype F] [DecidableEq F]
 
 /-- Some basic API lemmas -/
 theorem quadraticCharFun_eq_zero_iff {a : F} : quadraticCharFun F a = 0 ↔ a = 0 := by
@@ -297,7 +297,7 @@ section SpecialValues
 
 open ZMod MulChar
 
-variable {F : Type _} [Field F] [Fintype F]
+variable {F : Type*} [Field F] [Fintype F]
 
 /-- The value of the quadratic character at `-1` -/
 theorem quadraticChar_neg_one [DecidableEq F] (hF : ringChar F ≠ 2) :
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,16 +2,13 @@
 Copyright (c) 2022 Michael Stoll. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Michael Stoll
-
-! This file was ported from Lean 3 source module number_theory.legendre_symbol.quadratic_char.basic
-! leanprover-community/mathlib commit 5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Data.Fintype.Parity
 import Mathlib.NumberTheory.LegendreSymbol.ZModChar
 import Mathlib.FieldTheory.Finite.Basic
 
+#align_import number_theory.legendre_symbol.quadratic_char.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9"
+
 /-!
 # Quadratic characters of finite fields
 
chore: remove occurrences of semicolon after space (#5713)

This is the second half of the changes originally in #5699, removing all occurrences of ; after a space and implementing a linter rule to enforce it.

In most cases this 2-character substring has a space after it, so the following command was run first:

find . -type f -name "*.lean" -exec sed -i -E 's/ ; /; /g' {} \;

The remaining cases were few enough in number that they were done manually.

Diff
@@ -237,7 +237,7 @@ variable {F}
 when the domain has odd characteristic. -/
 theorem quadraticChar_isNontrivial (hF : ringChar F ≠ 2) : (quadraticChar F).IsNontrivial := by
   rcases quadraticChar_exists_neg_one hF with ⟨a, ha⟩
-  have hu : IsUnit a := by by_contra hf; rw [MulChar.map_nonunit _ hf] at ha ; norm_num at ha
+  have hu : IsUnit a := by by_contra hf; rw [MulChar.map_nonunit _ hf] at ha; norm_num at ha
   refine' ⟨hu.unit, (_ : quadraticChar F a ≠ 1)⟩
   rw [ha]
   norm_num
feat: port NumberTheory.LegendreSymbol.GaussSum (#5419)

This PR incorporates also the changes to NumberTheory.LegendreSymbol.MulCharacter discussed here

Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>

Diff
@@ -310,8 +310,7 @@ theorem quadraticChar_neg_one [DecidableEq F] (hF : ringChar F ≠ 2) :
   set n := Fintype.card F / 2
   cases' Nat.even_or_odd n with h₂ h₂
   · simp only [Even.neg_one_pow h₂, eq_self_iff_true, if_true]
-  · simp only [Odd.neg_one_pow h₂, ite_eq_right_iff]
-    exact fun hf => Ring.neg_one_ne_one_of_char_ne_two hF hf
+  · simp only [Odd.neg_one_pow h₂, Ring.neg_one_ne_one_of_char_ne_two hF, ite_false]
 #align quadratic_char_neg_one quadraticChar_neg_one
 
 /-- `-1` is a square in `F` iff `#F` is not congruent to `3` mod `4`. -/
feat: port NumberTheory.LegendreSymbol.QuadraticChar.Basic (#5175)

Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>

Dependencies 10 + 664

665 files ported (98.5%)
276546 lines ported (98.8%)
Show graph

The unported dependencies are