Theorem: FiniteField.unit_isSquare_iff
File: Mathlib/FieldTheory/Finite/Basic.lean

tactic: obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := Fˣ)
state_before: K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
a : Fˣ
⊢ IsSquare a ↔ a ^ (Fintype.card F / 2) = 1

tactic: obtain ⟨n, hn⟩ : a ∈ Submonoid.powers g := by rw [mem_powers_iff_mem_zpowers]; apply hg
state_before: case intro
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
a g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
⊢ IsSquare a ↔ a ^ (Fintype.card F / 2) = 1

tactic: have hodd := Nat.two_mul_odd_div_two (FiniteField.odd_card_of_char_ne_two hF)
state_before: case intro.intro
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
a g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hn : (fun x x_1 => x ^ x_1) g n = a
⊢ IsSquare a ↔ a ^ (Fintype.card F / 2) = 1

tactic: constructor
state_before: case intro.intro
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
a g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hn : (fun x x_1 => x ^ x_1) g n = a
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
⊢ IsSquare a ↔ a ^ (Fintype.card F / 2) = 1

tactic: rw [mem_powers_iff_mem_zpowers]
state_before: K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
a g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
⊢ a ∈ Submonoid.powers g

tactic: apply hg
state_before: K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
a g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
⊢ a ∈ Subgroup.zpowers g

tactic: rintro ⟨y, rfl⟩
state_before: case intro.intro.mp
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
a g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hn : (fun x x_1 => x ^ x_1) g n = a
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
⊢ IsSquare a → a ^ (Fintype.card F / 2) = 1

tactic: rw [← pow_two, ← pow_mul, hodd]
state_before: case intro.intro.mp.intro
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
y : Fˣ
hn : (fun x x_1 => x ^ x_1) g n = y * y
⊢ (y * y) ^ (Fintype.card F / 2) = 1

tactic: apply_fun Units.val using Units.ext (α := F)
state_before: case intro.intro.mp.intro
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
y : Fˣ
hn : (fun x x_1 => x ^ x_1) g n = y * y
⊢ y ^ (Fintype.card F - 1) = 1

tactic: push_cast
state_before: case intro.intro.mp.intro
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
y : Fˣ
hn : (fun x x_1 => x ^ x_1) g n = y * y
⊢ ↑(y ^ (Fintype.card F - 1)) = ↑1

tactic: exact FiniteField.pow_card_sub_one_eq_one (y : F) (Units.ne_zero y)
state_before: case intro.intro.mp.intro
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
y : Fˣ
hn : (fun x x_1 => x ^ x_1) g n = y * y
⊢ ↑y ^ (Fintype.card F - 1) = 1

tactic: subst a
state_before: case intro.intro.mpr
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
a g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hn : (fun x x_1 => x ^ x_1) g n = a
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
⊢ a ^ (Fintype.card F / 2) = 1 → IsSquare a

tactic: intro h
state_before: case intro.intro.mpr
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
⊢ (fun x x_1 => x ^ x_1) g n ^ (Fintype.card F / 2) = 1 → IsSquare ((fun x x_1 => x ^ x_1) g n)

tactic: have key : 2 * (Fintype.card F / 2) ∣ n * (Fintype.card F / 2) := by
  rw [← pow_mul] at h
  rw [hodd, ← Fintype.card_units, ← orderOf_eq_card_of_forall_mem_zpowers hg]
  apply orderOf_dvd_of_pow_eq_one h
state_before: case intro.intro.mpr
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
h : (fun x x_1 => x ^ x_1) g n ^ (Fintype.card F / 2) = 1
⊢ IsSquare ((fun x x_1 => x ^ x_1) g n)

tactic: have : 0 < Fintype.card F / 2 := Nat.div_pos Fintype.one_lt_card (by norm_num)
state_before: case intro.intro.mpr
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
h : (fun x x_1 => x ^ x_1) g n ^ (Fintype.card F / 2) = 1
key : 2 * (Fintype.card F / 2) ∣ n * (Fintype.card F / 2)
⊢ IsSquare ((fun x x_1 => x ^ x_1) g n)

tactic: obtain ⟨m, rfl⟩ := Nat.dvd_of_mul_dvd_mul_right this key
state_before: case intro.intro.mpr
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
h : (fun x x_1 => x ^ x_1) g n ^ (Fintype.card F / 2) = 1
key : 2 * (Fintype.card F / 2) ∣ n * (Fintype.card F / 2)
this : 0 < Fintype.card F / 2
⊢ IsSquare ((fun x x_1 => x ^ x_1) g n)

tactic: refine' ⟨g ^ m, _⟩
state_before: case intro.intro.mpr.intro
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
this : 0 < Fintype.card F / 2
m : ℕ
h : (fun x x_1 => x ^ x_1) g (2 * m) ^ (Fintype.card F / 2) = 1
key : 2 * (Fintype.card F / 2) ∣ 2 * m * (Fintype.card F / 2)
⊢ IsSquare ((fun x x_1 => x ^ x_1) g (2 * m))

tactic: dsimp
state_before: case intro.intro.mpr.intro
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
this : 0 < Fintype.card F / 2
m : ℕ
h : (fun x x_1 => x ^ x_1) g (2 * m) ^ (Fintype.card F / 2) = 1
key : 2 * (Fintype.card F / 2) ∣ 2 * m * (Fintype.card F / 2)
⊢ (fun x x_1 => x ^ x_1) g (2 * m) = g ^ m * g ^ m

tactic: rw [mul_comm, pow_mul, pow_two]
state_before: case intro.intro.mpr.intro
K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
this : 0 < Fintype.card F / 2
m : ℕ
h : (fun x x_1 => x ^ x_1) g (2 * m) ^ (Fintype.card F / 2) = 1
key : 2 * (Fintype.card F / 2) ∣ 2 * m * (Fintype.card F / 2)
⊢ g ^ (2 * m) = g ^ m * g ^ m

tactic: rw [← pow_mul] at h
state_before: K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
h : (fun x x_1 => x ^ x_1) g n ^ (Fintype.card F / 2) = 1
⊢ 2 * (Fintype.card F / 2) ∣ n * (Fintype.card F / 2)

tactic: rw [hodd, ← Fintype.card_units, ← orderOf_eq_card_of_forall_mem_zpowers hg]
state_before: K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
h : g ^ (n * (Fintype.card F / 2)) = 1
⊢ 2 * (Fintype.card F / 2) ∣ n * (Fintype.card F / 2)

tactic: apply orderOf_dvd_of_pow_eq_one h
state_before: K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
h : g ^ (n * (Fintype.card F / 2)) = 1
⊢ orderOf g ∣ n * (Fintype.card F / 2)

tactic: norm_num
state_before: K : Type ?u.1100843
R : Type ?u.1100846
F : Type u_1
inst✝¹ : Field F
inst✝ : Fintype F
hF : ringChar F ≠ 2
g : Fˣ
hg : ∀ (x : Fˣ), x ∈ Subgroup.zpowers g
n : ℕ
hodd : 2 * (Fintype.card F / 2) = Fintype.card F - 1
h : (fun x x_1 => x ^ x_1) g n ^ (Fintype.card F / 2) = 1
key : 2 * (Fintype.card F / 2) ∣ n * (Fintype.card F / 2)
⊢ 0 < 2