l3lab/ntp-mathlib huggingface dataset:
/-- An irreducible polynomial of prime degree with two non-real roots has full Galois group. -/
theorem galActionHom_bijective_of_prime_degree {p : ℚ[X]} (p_irr : Irreducible p)
    (p_deg : p.natDegree.Prime)
    (p_roots : Fintype.card (p.rootSet ℂ) = Fintype.card (p.rootSet ℝ) + 2) :
    Function.Bijective (galActionHom p ℂ) := by
  classical
  have h1 : Fintype.card (p.rootSet ℂ) = p.natDegree := by
    simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe]
    rw [Multiset.toFinset_card_of_nodup, ← natDegree_eq_card_roots]
    · exact IsAlgClosed.splits_codomain p
    · exact nodup_roots ((separable_map (algebraMap ℚ ℂ)).mpr p_irr.separable)
  have h2 : Fintype.card p.Gal = Fintype.card (galActionHom p ℂ).range :=
    Fintype.card_congr (MonoidHom.ofInjective (galActionHom_injective p ℂ)).toEquiv
  let conj := restrict p ℂ (Complex.conjAe.restrictScalars ℚ)
  

Proof state:
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots : Fintype.card ↑(rootSet p ℂ) = Fintype.card ↑(rootSet p ℝ) + 2
h1 : Fintype.card ↑(rootSet p ℂ) = natDegree p
h2 : Fintype.card (Gal p) = Fintype.card ↥(MonoidHom.range (galActionHom p ℂ))
conj : Gal p := (restrict p ℂ) (AlgEquiv.restrictScalars ℚ Complex.conjAe)
⊢ Function.Bijective ⇑(galActionHom p ℂ)

Next tactic:
refine'
    ⟨galActionHom_injective p ℂ, fun x =>
      (congr_arg (Membership.mem x) (show (galActionHom p ℂ).range = ⊤ from _)).mpr
        (Subgroup.mem_top x)⟩
/-- An irreducible polynomial of prime degree with two non-real roots has full Galois group. -/
theorem galActionHom_bijective_of_prime_degree {p : ℚ[X]} (p_irr : Irreducible p)
    (p_deg : p.natDegree.Prime)
    (p_roots : Fintype.card (p.rootSet ℂ) = Fintype.card (p.rootSet ℝ) + 2) :
    Function.Bijective (galActionHom p ℂ) := by
  classical
  have h1 : Fintype.card (p.rootSet ℂ) = p.natDegree := by
    simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe]
    rw [Multiset.toFinset_card_of_nodup, ← natDegree_eq_card_roots]
    · exact IsAlgClosed.splits_codomain p
    · exact nodup_roots ((separable_map (algebraMap ℚ ℂ)).mpr p_irr.separable)
  have h2 : Fintype.card p.Gal = Fintype.card (galActionHom p ℂ).range :=
    Fintype.card_congr (MonoidHom.ofInjective (galActionHom_injective p ℂ)).toEquiv
  let conj := restrict p ℂ (Complex.conjAe.restrictScalars ℚ)
  refine'
    ⟨galActionHom_injective p ℂ, fun x =>
      (congr_arg (Membership.mem x) (show (galActionHom p ℂ).range = ⊤ from _)).mpr
        (Subgroup.mem_top x)⟩
  

Proof state:
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots : Fintype.card ↑(rootSet p ℂ) = Fintype.card ↑(rootSet p ℝ) + 2
h1 : Fintype.card ↑(rootSet p ℂ) = natDegree p
h2 : Fintype.card (Gal p) = Fintype.card ↥(MonoidHom.range (galActionHom p ℂ))
conj : Gal p := (restrict p ℂ) (AlgEquiv.restrictScalars ℚ Complex.conjAe)
x : Equiv.Perm ↑(rootSet p ℂ)
⊢ MonoidHom.range (galActionHom p ℂ) = ⊤

Next tactic:
apply Equiv.Perm.subgroup_eq_top_of_swap_mem
/-- An irreducible polynomial of prime degree with two non-real roots has full Galois group. -/
theorem galActionHom_bijective_of_prime_degree {p : ℚ[X]} (p_irr : Irreducible p)
    (p_deg : p.natDegree.Prime)
    (p_roots : Fintype.card (p.rootSet ℂ) = Fintype.card (p.rootSet ℝ) + 2) :
    Function.Bijective (galActionHom p ℂ) := by
  classical
  have h1 : Fintype.card (p.rootSet ℂ) = p.natDegree := by
    simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe]
    rw [Multiset.toFinset_card_of_nodup, ← natDegree_eq_card_roots]
    · exact IsAlgClosed.splits_codomain p
    · exact nodup_roots ((separable_map (algebraMap ℚ ℂ)).mpr p_irr.separable)
  have h2 : Fintype.card p.Gal = Fintype.card (galActionHom p ℂ).range :=
    Fintype.card_congr (MonoidHom.ofInjective (galActionHom_injective p ℂ)).toEquiv
  let conj := restrict p ℂ (Complex.conjAe.restrictScalars ℚ)
  refine'
    ⟨galActionHom_injective p ℂ, fun x =>
      (congr_arg (Membership.mem x) (show (galActionHom p ℂ).range = ⊤ from _)).mpr
        (Subgroup.mem_top x)⟩
  apply Equiv.Perm.subgroup_eq_top_of_swap_mem
  · 

Proof state:
case h0
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots : Fintype.card ↑(rootSet p ℂ) = Fintype.card ↑(rootSet p ℝ) + 2
h1 : Fintype.card ↑(rootSet p ℂ) = natDegree p
h2 : Fintype.card (Gal p) = Fintype.card ↥(MonoidHom.range (galActionHom p ℂ))
conj : Gal p := (restrict p ℂ) (AlgEquiv.restrictScalars ℚ Complex.conjAe)
x : Equiv.Perm ↑(rootSet p ℂ)
⊢ Nat.Prime (Fintype.card ↑(rootSet p ℂ))

Next tactic:
rwa [h1]
/-- An irreducible polynomial of prime degree with two non-real roots has full Galois group. -/
theorem galActionHom_bijective_of_prime_degree {p : ℚ[X]} (p_irr : Irreducible p)
    (p_deg : p.natDegree.Prime)
    (p_roots : Fintype.card (p.rootSet ℂ) = Fintype.card (p.rootSet ℝ) + 2) :
    Function.Bijective (galActionHom p ℂ) := by
  classical
  have h1 : Fintype.card (p.rootSet ℂ) = p.natDegree := by
    simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe]
    rw [Multiset.toFinset_card_of_nodup, ← natDegree_eq_card_roots]
    · exact IsAlgClosed.splits_codomain p
    · exact nodup_roots ((separable_map (algebraMap ℚ ℂ)).mpr p_irr.separable)
  have h2 : Fintype.card p.Gal = Fintype.card (galActionHom p ℂ).range :=
    Fintype.card_congr (MonoidHom.ofInjective (galActionHom_injective p ℂ)).toEquiv
  let conj := restrict p ℂ (Complex.conjAe.restrictScalars ℚ)
  refine'
    ⟨galActionHom_injective p ℂ, fun x =>
      (congr_arg (Membership.mem x) (show (galActionHom p ℂ).range = ⊤ from _)).mpr
        (Subgroup.mem_top x)⟩
  apply Equiv.Perm.subgroup_eq_top_of_swap_mem
  · rwa [h1]
  · 

Proof state:
case h1
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots : Fintype.card ↑(rootSet p ℂ) = Fintype.card ↑(rootSet p ℝ) + 2
h1 : Fintype.card ↑(rootSet p ℂ) = natDegree p
h2 : Fintype.card (Gal p) = Fintype.card ↥(MonoidHom.range (galActionHom p ℂ))
conj : Gal p := (restrict p ℂ) (AlgEquiv.restrictScalars ℚ Complex.conjAe)
x : Equiv.Perm ↑(rootSet p ℂ)
⊢ Fintype.card ↑(rootSet p ℂ) ∣ Fintype.card ↥(MonoidHom.range (galActionHom p ℂ))

Next tactic:
rw [h1]
/-- An irreducible polynomial of prime degree with two non-real roots has full Galois group. -/
theorem galActionHom_bijective_of_prime_degree {p : ℚ[X]} (p_irr : Irreducible p)
    (p_deg : p.natDegree.Prime)
    (p_roots : Fintype.card (p.rootSet ℂ) = Fintype.card (p.rootSet ℝ) + 2) :
    Function.Bijective (galActionHom p ℂ) := by
  classical
  have h1 : Fintype.card (p.rootSet ℂ) = p.natDegree := by
    simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe]
    rw [Multiset.toFinset_card_of_nodup, ← natDegree_eq_card_roots]
    · exact IsAlgClosed.splits_codomain p
    · exact nodup_roots ((separable_map (algebraMap ℚ ℂ)).mpr p_irr.separable)
  have h2 : Fintype.card p.Gal = Fintype.card (galActionHom p ℂ).range :=
    Fintype.card_congr (MonoidHom.ofInjective (galActionHom_injective p ℂ)).toEquiv
  let conj := restrict p ℂ (Complex.conjAe.restrictScalars ℚ)
  refine'
    ⟨galActionHom_injective p ℂ, fun x =>
      (congr_arg (Membership.mem x) (show (galActionHom p ℂ).range = ⊤ from _)).mpr
        (Subgroup.mem_top x)⟩
  apply Equiv.Perm.subgroup_eq_top_of_swap_mem
  · rwa [h1]
  · rw [h1]
    

Proof state:
case h1
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots : Fintype.card ↑(rootSet p ℂ) = Fintype.card ↑(rootSet p ℝ) + 2
h1 : Fintype.card ↑(rootSet p ℂ) = natDegree p
h2 : Fintype.card (Gal p) = Fintype.card ↥(MonoidHom.range (galActionHom p ℂ))
conj : Gal p := (restrict p ℂ) (AlgEquiv.restrictScalars ℚ Complex.conjAe)
x : Equiv.Perm ↑(rootSet p ℂ)
⊢ natDegree p ∣ Fintype.card ↥(MonoidHom.range (galActionHom p ℂ))

Next tactic:
convert prime_degree_dvd_card p_irr p_deg using 1
/-- An irreducible polynomial of prime degree with two non-real roots has full Galois group. -/
theorem galActionHom_bijective_of_prime_degree {p : ℚ[X]} (p_irr : Irreducible p)
    (p_deg : p.natDegree.Prime)
    (p_roots : Fintype.card (p.rootSet ℂ) = Fintype.card (p.rootSet ℝ) + 2) :
    Function.Bijective (galActionHom p ℂ) := by
  classical
  have h1 : Fintype.card (p.rootSet ℂ) = p.natDegree := by
    simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe]
    rw [Multiset.toFinset_card_of_nodup, ← natDegree_eq_card_roots]
    · exact IsAlgClosed.splits_codomain p
    · exact nodup_roots ((separable_map (algebraMap ℚ ℂ)).mpr p_irr.separable)
  have h2 : Fintype.card p.Gal = Fintype.card (galActionHom p ℂ).range :=
    Fintype.card_congr (MonoidHom.ofInjective (galActionHom_injective p ℂ)).toEquiv
  let conj := restrict p ℂ (Complex.conjAe.restrictScalars ℚ)
  refine'
    ⟨galActionHom_injective p ℂ, fun x =>
      (congr_arg (Membership.mem x) (show (galActionHom p ℂ).range = ⊤ from _)).mpr
        (Subgroup.mem_top x)⟩
  apply Equiv.Perm.subgroup_eq_top_of_swap_mem
  · rwa [h1]
  · rw [h1]
    convert prime_degree_dvd_card p_irr p_deg using 1
    

Proof state:
case h.e'_4
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots : Fintype.card ↑(rootSet p ℂ) = Fintype.card ↑(rootSet p ℝ) + 2
h1 : Fintype.card ↑(rootSet p ℂ) = natDegree p
h2 : Fintype.card (Gal p) = Fintype.card ↥(MonoidHom.range (galActionHom p ℂ))
conj : Gal p := (restrict p ℂ) (AlgEquiv.restrictScalars ℚ Complex.conjAe)
x : Equiv.Perm ↑(rootSet p ℂ)
⊢ Fintype.card ↥(MonoidHom.range (galActionHom p ℂ)) = Fintype.card (Gal p)

Next tactic:
convert h2.symm
/-- An irreducible polynomial of prime degree with two non-real roots has full Galois group. -/
theorem galActionHom_bijective_of_prime_degree {p : ℚ[X]} (p_irr : Irreducible p)
    (p_deg : p.natDegree.Prime)
    (p_roots : Fintype.card (p.rootSet ℂ) = Fintype.card (p.rootSet ℝ) + 2) :
    Function.Bijective (galActionHom p ℂ) := by
  classical
  have h1 : Fintype.card (p.rootSet ℂ) = p.natDegree := by
    simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe]
    rw [Multiset.toFinset_card_of_nodup, ← natDegree_eq_card_roots]
    · exact IsAlgClosed.splits_codomain p
    · exact nodup_roots ((separable_map (algebraMap ℚ ℂ)).mpr p_irr.separable)
  have h2 : Fintype.card p.Gal = Fintype.card (galActionHom p ℂ).range :=
    Fintype.card_congr (MonoidHom.ofInjective (galActionHom_injective p ℂ)).toEquiv
  let conj := restrict p ℂ (Complex.conjAe.restrictScalars ℚ)
  refine'
    ⟨galActionHom_injective p ℂ, fun x =>
      (congr_arg (Membership.mem x) (show (galActionHom p ℂ).range = ⊤ from _)).mpr
        (Subgroup.mem_top x)⟩
  apply Equiv.Perm.subgroup_eq_top_of_swap_mem
  · rwa [h1]
  · rw [h1]
    convert prime_degree_dvd_card p_irr p_deg using 1
    convert h2.symm
  · 

Proof state:
case h2
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots : Fintype.card ↑(rootSet p ℂ) = Fintype.card ↑(rootSet p ℝ) + 2
h1 : Fintype.card ↑(rootSet p ℂ) = natDegree p
h2 : Fintype.card (Gal p) = Fintype.card ↥(MonoidHom.range (galActionHom p ℂ))
conj : Gal p := (restrict p ℂ) (AlgEquiv.restrictScalars ℚ Complex.conjAe)
x : Equiv.Perm ↑(rootSet p ℂ)
⊢ ?τ ∈ MonoidHom.range (galActionHom p ℂ)

Next tactic:
exact ⟨conj, rfl⟩
/-- An irreducible polynomial of prime degree with two non-real roots has full Galois group. -/
theorem galActionHom_bijective_of_prime_degree {p : ℚ[X]} (p_irr : Irreducible p)
    (p_deg : p.natDegree.Prime)
    (p_roots : Fintype.card (p.rootSet ℂ) = Fintype.card (p.rootSet ℝ) + 2) :
    Function.Bijective (galActionHom p ℂ) := by
  classical
  have h1 : Fintype.card (p.rootSet ℂ) = p.natDegree := by
    simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe]
    rw [Multiset.toFinset_card_of_nodup, ← natDegree_eq_card_roots]
    · exact IsAlgClosed.splits_codomain p
    · exact nodup_roots ((separable_map (algebraMap ℚ ℂ)).mpr p_irr.separable)
  have h2 : Fintype.card p.Gal = Fintype.card (galActionHom p ℂ).range :=
    Fintype.card_congr (MonoidHom.ofInjective (galActionHom_injective p ℂ)).toEquiv
  let conj := restrict p ℂ (Complex.conjAe.restrictScalars ℚ)
  refine'
    ⟨galActionHom_injective p ℂ, fun x =>
      (congr_arg (Membership.mem x) (show (galActionHom p ℂ).range = ⊤ from _)).mpr
        (Subgroup.mem_top x)⟩
  apply Equiv.Perm.subgroup_eq_top_of_swap_mem
  · rwa [h1]
  · rw [h1]
    convert prime_degree_dvd_card p_irr p_deg using 1
    convert h2.symm
  · exact ⟨conj, rfl⟩
  · 

Proof state:
case h3
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots : Fintype.card ↑(rootSet p ℂ) = Fintype.card ↑(rootSet p ℝ) + 2
h1 : Fintype.card ↑(rootSet p ℂ) = natDegree p
h2 : Fintype.card (Gal p) = Fintype.card ↥(MonoidHom.range (galActionHom p ℂ))
conj : Gal p := (restrict p ℂ) (AlgEquiv.restrictScalars ℚ Complex.conjAe)
x : Equiv.Perm ↑(rootSet p ℂ)
⊢ Equiv.Perm.IsSwap ((galActionHom p ℂ) conj)

Next tactic:
rw [← Equiv.Perm.card_support_eq_two]
/-- An irreducible polynomial of prime degree with two non-real roots has full Galois group. -/
theorem galActionHom_bijective_of_prime_degree {p : ℚ[X]} (p_irr : Irreducible p)
    (p_deg : p.natDegree.Prime)
    (p_roots : Fintype.card (p.rootSet ℂ) = Fintype.card (p.rootSet ℝ) + 2) :
    Function.Bijective (galActionHom p ℂ) := by
  classical
  have h1 : Fintype.card (p.rootSet ℂ) = p.natDegree := by
    simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe]
    rw [Multiset.toFinset_card_of_nodup, ← natDegree_eq_card_roots]
    · exact IsAlgClosed.splits_codomain p
    · exact nodup_roots ((separable_map (algebraMap ℚ ℂ)).mpr p_irr.separable)
  have h2 : Fintype.card p.Gal = Fintype.card (galActionHom p ℂ).range :=
    Fintype.card_congr (MonoidHom.ofInjective (galActionHom_injective p ℂ)).toEquiv
  let conj := restrict p ℂ (Complex.conjAe.restrictScalars ℚ)
  refine'
    ⟨galActionHom_injective p ℂ, fun x =>
      (congr_arg (Membership.mem x) (show (galActionHom p ℂ).range = ⊤ from _)).mpr
        (Subgroup.mem_top x)⟩
  apply Equiv.Perm.subgroup_eq_top_of_swap_mem
  · rwa [h1]
  · rw [h1]
    convert prime_degree_dvd_card p_irr p_deg using 1
    convert h2.symm
  · exact ⟨conj, rfl⟩
  · rw [← Equiv.Perm.card_support_eq_two]
    

Proof state:
case h3
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots : Fintype.card ↑(rootSet p ℂ) = Fintype.card ↑(rootSet p ℝ) + 2
h1 : Fintype.card ↑(rootSet p ℂ) = natDegree p
h2 : Fintype.card (Gal p) = Fintype.card ↥(MonoidHom.range (galActionHom p ℂ))
conj : Gal p := (restrict p ℂ) (AlgEquiv.restrictScalars ℚ Complex.conjAe)
x : Equiv.Perm ↑(rootSet p ℂ)
⊢ Finset.card (Equiv.Perm.support ((galActionHom p ℂ) conj)) = 2

Next tactic:
apply Nat.add_left_cancel
/-- An irreducible polynomial of prime degree with two non-real roots has full Galois group. -/
theorem galActionHom_bijective_of_prime_degree {p : ℚ[X]} (p_irr : Irreducible p)
    (p_deg : p.natDegree.Prime)
    (p_roots : Fintype.card (p.rootSet ℂ) = Fintype.card (p.rootSet ℝ) + 2) :
    Function.Bijective (galActionHom p ℂ) := by
  classical
  have h1 : Fintype.card (p.rootSet ℂ) = p.natDegree := by
    simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe]
    rw [Multiset.toFinset_card_of_nodup, ← natDegree_eq_card_roots]
    · exact IsAlgClosed.splits_codomain p
    · exact nodup_roots ((separable_map (algebraMap ℚ ℂ)).mpr p_irr.separable)
  have h2 : Fintype.card p.Gal = Fintype.card (galActionHom p ℂ).range :=
    Fintype.card_congr (MonoidHom.ofInjective (galActionHom_injective p ℂ)).toEquiv
  let conj := restrict p ℂ (Complex.conjAe.restrictScalars ℚ)
  refine'
    ⟨galActionHom_injective p ℂ, fun x =>
      (congr_arg (Membership.mem x) (show (galActionHom p ℂ).range = ⊤ from _)).mpr
        (Subgroup.mem_top x)⟩
  apply Equiv.Perm.subgroup_eq_top_of_swap_mem
  · rwa [h1]
  · rw [h1]
    convert prime_degree_dvd_card p_irr p_deg using 1
    convert h2.symm
  · exact ⟨conj, rfl⟩
  · rw [← Equiv.Perm.card_support_eq_two]
    apply Nat.add_left_cancel
    

Proof state:
case h3.a
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots : Fintype.card ↑(rootSet p ℂ) = Fintype.card ↑(rootSet p ℝ) + 2
h1 : Fintype.card ↑(rootSet p ℂ) = natDegree p
h2 : Fintype.card (Gal p) = Fintype.card ↥(MonoidHom.range (galActionHom p ℂ))
conj : Gal p := (restrict p ℂ) (AlgEquiv.restrictScalars ℚ Complex.conjAe)
x : Equiv.Perm ↑(rootSet p ℂ)
⊢ ?h3.n + Finset.card (Equiv.Perm.support ((galActionHom p ℂ) conj)) = ?h3.n + 2
case h3.n
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots : Fintype.card ↑(rootSet p ℂ) = Fintype.card ↑(rootSet p ℝ) + 2
h1 : Fintype.card ↑(rootSet p ℂ) = natDegree p
h2 : Fintype.card (Gal p) = Fintype.card ↥(MonoidHom.range (galActionHom p ℂ))
conj : Gal p := (restrict p ℂ) (AlgEquiv.restrictScalars ℚ Complex.conjAe)
x : Equiv.Perm ↑(rootSet p ℂ)
⊢ ℕ

Next tactic:
rw [← p_roots, ← Set.toFinset_card (rootSet p ℝ), ← Set.toFinset_card (rootSet p ℂ)]
/-- An irreducible polynomial of prime degree with two non-real roots has full Galois group. -/
theorem galActionHom_bijective_of_prime_degree {p : ℚ[X]} (p_irr : Irreducible p)
    (p_deg : p.natDegree.Prime)
    (p_roots : Fintype.card (p.rootSet ℂ) = Fintype.card (p.rootSet ℝ) + 2) :
    Function.Bijective (galActionHom p ℂ) := by
  classical
  have h1 : Fintype.card (p.rootSet ℂ) = p.natDegree := by
    simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe]
    rw [Multiset.toFinset_card_of_nodup, ← natDegree_eq_card_roots]
    · exact IsAlgClosed.splits_codomain p
    · exact nodup_roots ((separable_map (algebraMap ℚ ℂ)).mpr p_irr.separable)
  have h2 : Fintype.card p.Gal = Fintype.card (galActionHom p ℂ).range :=
    Fintype.card_congr (MonoidHom.ofInjective (galActionHom_injective p ℂ)).toEquiv
  let conj := restrict p ℂ (Complex.conjAe.restrictScalars ℚ)
  refine'
    ⟨galActionHom_injective p ℂ, fun x =>
      (congr_arg (Membership.mem x) (show (galActionHom p ℂ).range = ⊤ from _)).mpr
        (Subgroup.mem_top x)⟩
  apply Equiv.Perm.subgroup_eq_top_of_swap_mem
  · rwa [h1]
  · rw [h1]
    convert prime_degree_dvd_card p_irr p_deg using 1
    convert h2.symm
  · exact ⟨conj, rfl⟩
  · rw [← Equiv.Perm.card_support_eq_two]
    apply Nat.add_left_cancel
    rw [← p_roots, ← Set.toFinset_card (rootSet p ℝ), ← Set.toFinset_card (rootSet p ℂ)]
    

Proof state:
case h3.a
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots : Fintype.card ↑(rootSet p ℂ) = Fintype.card ↑(rootSet p ℝ) + 2
h1 : Fintype.card ↑(rootSet p ℂ) = natDegree p
h2 : Fintype.card (Gal p) = Fintype.card ↥(MonoidHom.range (galActionHom p ℂ))
conj : Gal p := (restrict p ℂ) (AlgEquiv.restrictScalars ℚ Complex.conjAe)
x : Equiv.Perm ↑(rootSet p ℂ)
⊢ Finset.card (Set.toFinset (rootSet p ℝ)) + Finset.card (Equiv.Perm.support ((galActionHom p ℂ) conj)) =
    Finset.card (Set.toFinset (rootSet p ℂ))

Next tactic:
exact (card_complex_roots_eq_card_real_add_card_not_gal_inv p).symm
/-- An irreducible polynomial of prime degree with 1-3 non-real roots has full Galois group. -/
theorem galActionHom_bijective_of_prime_degree' {p : ℚ[X]} (p_irr : Irreducible p)
    (p_deg : p.natDegree.Prime)
    (p_roots1 : Fintype.card (p.rootSet ℝ) + 1 ≤ Fintype.card (p.rootSet ℂ))
    (p_roots2 : Fintype.card (p.rootSet ℂ) ≤ Fintype.card (p.rootSet ℝ) + 3) :
    Function.Bijective (galActionHom p ℂ) := by
  

Proof state:
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots1 : Fintype.card ↑(rootSet p ℝ) + 1 ≤ Fintype.card ↑(rootSet p ℂ)
p_roots2 : Fintype.card ↑(rootSet p ℂ) ≤ Fintype.card ↑(rootSet p ℝ) + 3
⊢ Function.Bijective ⇑(galActionHom p ℂ)

Next tactic:
apply galActionHom_bijective_of_prime_degree p_irr p_deg
/-- An irreducible polynomial of prime degree with 1-3 non-real roots has full Galois group. -/
theorem galActionHom_bijective_of_prime_degree' {p : ℚ[X]} (p_irr : Irreducible p)
    (p_deg : p.natDegree.Prime)
    (p_roots1 : Fintype.card (p.rootSet ℝ) + 1 ≤ Fintype.card (p.rootSet ℂ))
    (p_roots2 : Fintype.card (p.rootSet ℂ) ≤ Fintype.card (p.rootSet ℝ) + 3) :
    Function.Bijective (galActionHom p ℂ) := by
  apply galActionHom_bijective_of_prime_degree p_irr p_deg
  

Proof state:
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots1 : Fintype.card ↑(rootSet p ℝ) + 1 ≤ Fintype.card ↑(rootSet p ℂ)
p_roots2 : Fintype.card ↑(rootSet p ℂ) ≤ Fintype.card ↑(rootSet p ℝ) + 3
⊢ Fintype.card ↑(rootSet p ℂ) = Fintype.card ↑(rootSet p ℝ) + 2

Next tactic:
let n := (galActionHom p ℂ (restrict p ℂ (Complex.conjAe.restrictScalars ℚ))).support.card
/-- An irreducible polynomial of prime degree with 1-3 non-real roots has full Galois group. -/
theorem galActionHom_bijective_of_prime_degree' {p : ℚ[X]} (p_irr : Irreducible p)
    (p_deg : p.natDegree.Prime)
    (p_roots1 : Fintype.card (p.rootSet ℝ) + 1 ≤ Fintype.card (p.rootSet ℂ))
    (p_roots2 : Fintype.card (p.rootSet ℂ) ≤ Fintype.card (p.rootSet ℝ) + 3) :
    Function.Bijective (galActionHom p ℂ) := by
  apply galActionHom_bijective_of_prime_degree p_irr p_deg
  let n := (galActionHom p ℂ (restrict p ℂ (Complex.conjAe.restrictScalars ℚ))).support.card
  

Proof state:
F : Type u_1
inst✝² : Field F
p✝ q : F[X]
E : Type u_2
inst✝¹ : Field E
inst✝ : Algebra F E
p : ℚ[X]
p_irr : Irreducible p
p_deg : Nat.Prime (natDegree p)
p_roots1 : Fintype.card ↑(rootSet p ℝ) + 1 ≤ Fintype.card ↑(rootSet p ℂ)
p_roots2 : Fintype.card ↑(rootSet p ℂ) ≤ Fintype.card ↑(rootSet p ℝ) + 3
n : ℕ :=
  Finset.card (Equiv.Perm.support ((galActionHom p ℂ) ((restrict p ℂ) (AlgEquiv.restrictScalars ℚ Complex.conjAe))))
⊢ Fintype.card ↑(rootSet p ℂ) = Fintype.card ↑(rootSet p ℝ) + 2

Next tactic:
have hn : 2 ∣ n :=
    Equiv.Perm.two_dvd_card_support
      (by
         rw [← MonoidHom.map_pow, ← MonoidHom.map_pow,
          show AlgEquiv.restrictScalars ℚ Complex.conjAe ^ 2 = 1 from
            AlgEquiv.ext Complex.conj_conj,
          MonoidHom.map_one, MonoidHom.map_one])