l3lab/ntp-mathlib huggingface dataset:
/-- If the indicators of measurable sets `Aᵢ` tend pointwise almost everywhere to the indicator
of a measurable set `A` and we eventually have `Aᵢ ⊆ B` for some set `B` of finite measure, then
the measures of `Aᵢ` tend to the measure of `A`. -/
lemma tendsto_measure_of_ae_tendsto_indicator {μ : Measure α} (A_mble : MeasurableSet A)
    (As_mble : ∀ i, MeasurableSet (As i)) {B : Set α} (B_mble : MeasurableSet B)
    (B_finmeas : μ B ≠ ∞) (As_le_B : ∀ᶠ i in L, As i ⊆ B)
    (h_lim : ∀ᵐ x ∂μ, ∀ᶠ i in L, x ∈ As i ↔ x ∈ A) :
    Tendsto (fun i ↦ μ (As i)) L (𝓝 (μ A)) := by
  simp_rw [← MeasureTheory.lintegral_indicator_one A_mble,
           ← MeasureTheory.lintegral_indicator_one (As_mble _)]
  

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m m0 : MeasurableSpace α✝
α : Type u_5
inst✝¹ : MeasurableSpace α
A : Set α
ι : Type u_6
L : Filter ι
inst✝ : IsCountablyGenerated L
As : ι → Set α
μ : Measure α
A_mble : MeasurableSet A
As_mble : ∀ (i : ι), MeasurableSet (As i)
B : Set α
B_mble : MeasurableSet B
B_finmeas : ↑↑μ B ≠ ⊤
As_le_B : ∀ᶠ (i : ι) in L, As i ⊆ B
h_lim : ∀ᵐ (x : α) ∂μ, ∀ᶠ (i : ι) in L, x ∈ As i ↔ x ∈ A
⊢ Tendsto (fun i => ∫⁻ (a : α), indicator (As i) 1 a ∂μ) L (𝓝 (∫⁻ (a : α), indicator A 1 a ∂μ))

Next tactic:
refine tendsto_lintegral_filter_of_dominated_convergence (B.indicator (1 : α → ℝ≥0∞))
          (eventually_of_forall ?_) ?_ ?_ ?_
/-- If the indicators of measurable sets `Aᵢ` tend pointwise almost everywhere to the indicator
of a measurable set `A` and we eventually have `Aᵢ ⊆ B` for some set `B` of finite measure, then
the measures of `Aᵢ` tend to the measure of `A`. -/
lemma tendsto_measure_of_ae_tendsto_indicator {μ : Measure α} (A_mble : MeasurableSet A)
    (As_mble : ∀ i, MeasurableSet (As i)) {B : Set α} (B_mble : MeasurableSet B)
    (B_finmeas : μ B ≠ ∞) (As_le_B : ∀ᶠ i in L, As i ⊆ B)
    (h_lim : ∀ᵐ x ∂μ, ∀ᶠ i in L, x ∈ As i ↔ x ∈ A) :
    Tendsto (fun i ↦ μ (As i)) L (𝓝 (μ A)) := by
  simp_rw [← MeasureTheory.lintegral_indicator_one A_mble,
           ← MeasureTheory.lintegral_indicator_one (As_mble _)]
  refine tendsto_lintegral_filter_of_dominated_convergence (B.indicator (1 : α → ℝ≥0∞))
          (eventually_of_forall ?_) ?_ ?_ ?_
  · 

Proof state:
case refine_1
α✝ : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m m0 : MeasurableSpace α✝
α : Type u_5
inst✝¹ : MeasurableSpace α
A : Set α
ι : Type u_6
L : Filter ι
inst✝ : IsCountablyGenerated L
As : ι → Set α
μ : Measure α
A_mble : MeasurableSet A
As_mble : ∀ (i : ι), MeasurableSet (As i)
B : Set α
B_mble : MeasurableSet B
B_finmeas : ↑↑μ B ≠ ⊤
As_le_B : ∀ᶠ (i : ι) in L, As i ⊆ B
h_lim : ∀ᵐ (x : α) ∂μ, ∀ᶠ (i : ι) in L, x ∈ As i ↔ x ∈ A
⊢ ∀ (x : ι), Measurable fun a => indicator (As x) 1 a

Next tactic:
exact fun i ↦ Measurable.indicator measurable_const (As_mble i)
/-- If the indicators of measurable sets `Aᵢ` tend pointwise almost everywhere to the indicator
of a measurable set `A` and we eventually have `Aᵢ ⊆ B` for some set `B` of finite measure, then
the measures of `Aᵢ` tend to the measure of `A`. -/
lemma tendsto_measure_of_ae_tendsto_indicator {μ : Measure α} (A_mble : MeasurableSet A)
    (As_mble : ∀ i, MeasurableSet (As i)) {B : Set α} (B_mble : MeasurableSet B)
    (B_finmeas : μ B ≠ ∞) (As_le_B : ∀ᶠ i in L, As i ⊆ B)
    (h_lim : ∀ᵐ x ∂μ, ∀ᶠ i in L, x ∈ As i ↔ x ∈ A) :
    Tendsto (fun i ↦ μ (As i)) L (𝓝 (μ A)) := by
  simp_rw [← MeasureTheory.lintegral_indicator_one A_mble,
           ← MeasureTheory.lintegral_indicator_one (As_mble _)]
  refine tendsto_lintegral_filter_of_dominated_convergence (B.indicator (1 : α → ℝ≥0∞))
          (eventually_of_forall ?_) ?_ ?_ ?_
  · exact fun i ↦ Measurable.indicator measurable_const (As_mble i)
  · 

Proof state:
case refine_2
α✝ : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m m0 : MeasurableSpace α✝
α : Type u_5
inst✝¹ : MeasurableSpace α
A : Set α
ι : Type u_6
L : Filter ι
inst✝ : IsCountablyGenerated L
As : ι → Set α
μ : Measure α
A_mble : MeasurableSet A
As_mble : ∀ (i : ι), MeasurableSet (As i)
B : Set α
B_mble : MeasurableSet B
B_finmeas : ↑↑μ B ≠ ⊤
As_le_B : ∀ᶠ (i : ι) in L, As i ⊆ B
h_lim : ∀ᵐ (x : α) ∂μ, ∀ᶠ (i : ι) in L, x ∈ As i ↔ x ∈ A
⊢ ∀ᶠ (n : ι) in L, ∀ᵐ (a : α) ∂μ, indicator (As n) 1 a ≤ indicator B 1 a

Next tactic:
filter_upwards [As_le_B] with i hi
/-- If the indicators of measurable sets `Aᵢ` tend pointwise almost everywhere to the indicator
of a measurable set `A` and we eventually have `Aᵢ ⊆ B` for some set `B` of finite measure, then
the measures of `Aᵢ` tend to the measure of `A`. -/
lemma tendsto_measure_of_ae_tendsto_indicator {μ : Measure α} (A_mble : MeasurableSet A)
    (As_mble : ∀ i, MeasurableSet (As i)) {B : Set α} (B_mble : MeasurableSet B)
    (B_finmeas : μ B ≠ ∞) (As_le_B : ∀ᶠ i in L, As i ⊆ B)
    (h_lim : ∀ᵐ x ∂μ, ∀ᶠ i in L, x ∈ As i ↔ x ∈ A) :
    Tendsto (fun i ↦ μ (As i)) L (𝓝 (μ A)) := by
  simp_rw [← MeasureTheory.lintegral_indicator_one A_mble,
           ← MeasureTheory.lintegral_indicator_one (As_mble _)]
  refine tendsto_lintegral_filter_of_dominated_convergence (B.indicator (1 : α → ℝ≥0∞))
          (eventually_of_forall ?_) ?_ ?_ ?_
  · exact fun i ↦ Measurable.indicator measurable_const (As_mble i)
  · filter_upwards [As_le_B] with i hi
    

Proof state:
case h
α✝ : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m m0 : MeasurableSpace α✝
α : Type u_5
inst✝¹ : MeasurableSpace α
A : Set α
ι : Type u_6
L : Filter ι
inst✝ : IsCountablyGenerated L
As : ι → Set α
μ : Measure α
A_mble : MeasurableSet A
As_mble : ∀ (i : ι), MeasurableSet (As i)
B : Set α
B_mble : MeasurableSet B
B_finmeas : ↑↑μ B ≠ ⊤
As_le_B : ∀ᶠ (i : ι) in L, As i ⊆ B
h_lim : ∀ᵐ (x : α) ∂μ, ∀ᶠ (i : ι) in L, x ∈ As i ↔ x ∈ A
i : ι
hi : As i ⊆ B
⊢ ∀ᵐ (a : α) ∂μ, indicator (As i) 1 a ≤ indicator B 1 a

Next tactic:
exact eventually_of_forall (fun x ↦ indicator_le_indicator_of_subset hi (by simp) x)
/-- If the indicators of measurable sets `Aᵢ` tend pointwise almost everywhere to the indicator
of a measurable set `A` and we eventually have `Aᵢ ⊆ B` for some set `B` of finite measure, then
the measures of `Aᵢ` tend to the measure of `A`. -/
lemma tendsto_measure_of_ae_tendsto_indicator {μ : Measure α} (A_mble : MeasurableSet A)
    (As_mble : ∀ i, MeasurableSet (As i)) {B : Set α} (B_mble : MeasurableSet B)
    (B_finmeas : μ B ≠ ∞) (As_le_B : ∀ᶠ i in L, As i ⊆ B)
    (h_lim : ∀ᵐ x ∂μ, ∀ᶠ i in L, x ∈ As i ↔ x ∈ A) :
    Tendsto (fun i ↦ μ (As i)) L (𝓝 (μ A)) := by
  simp_rw [← MeasureTheory.lintegral_indicator_one A_mble,
           ← MeasureTheory.lintegral_indicator_one (As_mble _)]
  refine tendsto_lintegral_filter_of_dominated_convergence (B.indicator (1 : α → ℝ≥0∞))
          (eventually_of_forall ?_) ?_ ?_ ?_
  · exact fun i ↦ Measurable.indicator measurable_const (As_mble i)
  · filter_upwards [As_le_B] with i hi
    exact eventually_of_forall (fun x ↦ indicator_le_indicator_of_subset hi (by 

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m m0 : MeasurableSpace α✝
α : Type u_5
inst✝¹ : MeasurableSpace α
A : Set α
ι : Type u_6
L : Filter ι
inst✝ : IsCountablyGenerated L
As : ι → Set α
μ : Measure α
A_mble : MeasurableSet A
As_mble : ∀ (i : ι), MeasurableSet (As i)
B : Set α
B_mble : MeasurableSet B
B_finmeas : ↑↑μ B ≠ ⊤
As_le_B : ∀ᶠ (i : ι) in L, As i ⊆ B
h_lim : ∀ᵐ (x : α) ∂μ, ∀ᶠ (i : ι) in L, x ∈ As i ↔ x ∈ A
i : ι
hi : As i ⊆ B
x : α
⊢ ∀ (a : α), 0 ≤ OfNat.ofNat 1 a

Next tactic:
simp
/-- If the indicators of measurable sets `Aᵢ` tend pointwise almost everywhere to the indicator
of a measurable set `A` and we eventually have `Aᵢ ⊆ B` for some set `B` of finite measure, then
the measures of `Aᵢ` tend to the measure of `A`. -/
lemma tendsto_measure_of_ae_tendsto_indicator {μ : Measure α} (A_mble : MeasurableSet A)
    (As_mble : ∀ i, MeasurableSet (As i)) {B : Set α} (B_mble : MeasurableSet B)
    (B_finmeas : μ B ≠ ∞) (As_le_B : ∀ᶠ i in L, As i ⊆ B)
    (h_lim : ∀ᵐ x ∂μ, ∀ᶠ i in L, x ∈ As i ↔ x ∈ A) :
    Tendsto (fun i ↦ μ (As i)) L (𝓝 (μ A)) := by
  simp_rw [← MeasureTheory.lintegral_indicator_one A_mble,
           ← MeasureTheory.lintegral_indicator_one (As_mble _)]
  refine tendsto_lintegral_filter_of_dominated_convergence (B.indicator (1 : α → ℝ≥0∞))
          (eventually_of_forall ?_) ?_ ?_ ?_
  · exact fun i ↦ Measurable.indicator measurable_const (As_mble i)
  · filter_upwards [As_le_B] with i hi
    exact eventually_of_forall (fun x ↦ indicator_le_indicator_of_subset hi (by simp) x)
  · 

Proof state:
case refine_3
α✝ : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m m0 : MeasurableSpace α✝
α : Type u_5
inst✝¹ : MeasurableSpace α
A : Set α
ι : Type u_6
L : Filter ι
inst✝ : IsCountablyGenerated L
As : ι → Set α
μ : Measure α
A_mble : MeasurableSet A
As_mble : ∀ (i : ι), MeasurableSet (As i)
B : Set α
B_mble : MeasurableSet B
B_finmeas : ↑↑μ B ≠ ⊤
As_le_B : ∀ᶠ (i : ι) in L, As i ⊆ B
h_lim : ∀ᵐ (x : α) ∂μ, ∀ᶠ (i : ι) in L, x ∈ As i ↔ x ∈ A
⊢ ∫⁻ (a : α), indicator B 1 a ∂μ ≠ ⊤

Next tactic:
rwa [← lintegral_indicator_one B_mble] at B_finmeas
/-- If the indicators of measurable sets `Aᵢ` tend pointwise almost everywhere to the indicator
of a measurable set `A` and we eventually have `Aᵢ ⊆ B` for some set `B` of finite measure, then
the measures of `Aᵢ` tend to the measure of `A`. -/
lemma tendsto_measure_of_ae_tendsto_indicator {μ : Measure α} (A_mble : MeasurableSet A)
    (As_mble : ∀ i, MeasurableSet (As i)) {B : Set α} (B_mble : MeasurableSet B)
    (B_finmeas : μ B ≠ ∞) (As_le_B : ∀ᶠ i in L, As i ⊆ B)
    (h_lim : ∀ᵐ x ∂μ, ∀ᶠ i in L, x ∈ As i ↔ x ∈ A) :
    Tendsto (fun i ↦ μ (As i)) L (𝓝 (μ A)) := by
  simp_rw [← MeasureTheory.lintegral_indicator_one A_mble,
           ← MeasureTheory.lintegral_indicator_one (As_mble _)]
  refine tendsto_lintegral_filter_of_dominated_convergence (B.indicator (1 : α → ℝ≥0∞))
          (eventually_of_forall ?_) ?_ ?_ ?_
  · exact fun i ↦ Measurable.indicator measurable_const (As_mble i)
  · filter_upwards [As_le_B] with i hi
    exact eventually_of_forall (fun x ↦ indicator_le_indicator_of_subset hi (by simp) x)
  · rwa [← lintegral_indicator_one B_mble] at B_finmeas
  · 

Proof state:
case refine_4
α✝ : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m m0 : MeasurableSpace α✝
α : Type u_5
inst✝¹ : MeasurableSpace α
A : Set α
ι : Type u_6
L : Filter ι
inst✝ : IsCountablyGenerated L
As : ι → Set α
μ : Measure α
A_mble : MeasurableSet A
As_mble : ∀ (i : ι), MeasurableSet (As i)
B : Set α
B_mble : MeasurableSet B
B_finmeas : ↑↑μ B ≠ ⊤
As_le_B : ∀ᶠ (i : ι) in L, As i ⊆ B
h_lim : ∀ᵐ (x : α) ∂μ, ∀ᶠ (i : ι) in L, x ∈ As i ↔ x ∈ A
⊢ ∀ᵐ (a : α) ∂μ, Tendsto (fun n => indicator (As n) 1 a) L (𝓝 (indicator A 1 a))

Next tactic:
simpa only [show (OfNat.ofNat 1 : α → ℝ≥0∞) = (fun _ ↦ 1) by rfl,
                tendsto_indicator_const_apply_iff_eventually] using h_lim
/-- If the indicators of measurable sets `Aᵢ` tend pointwise almost everywhere to the indicator
of a measurable set `A` and we eventually have `Aᵢ ⊆ B` for some set `B` of finite measure, then
the measures of `Aᵢ` tend to the measure of `A`. -/
lemma tendsto_measure_of_ae_tendsto_indicator {μ : Measure α} (A_mble : MeasurableSet A)
    (As_mble : ∀ i, MeasurableSet (As i)) {B : Set α} (B_mble : MeasurableSet B)
    (B_finmeas : μ B ≠ ∞) (As_le_B : ∀ᶠ i in L, As i ⊆ B)
    (h_lim : ∀ᵐ x ∂μ, ∀ᶠ i in L, x ∈ As i ↔ x ∈ A) :
    Tendsto (fun i ↦ μ (As i)) L (𝓝 (μ A)) := by
  simp_rw [← MeasureTheory.lintegral_indicator_one A_mble,
           ← MeasureTheory.lintegral_indicator_one (As_mble _)]
  refine tendsto_lintegral_filter_of_dominated_convergence (B.indicator (1 : α → ℝ≥0∞))
          (eventually_of_forall ?_) ?_ ?_ ?_
  · exact fun i ↦ Measurable.indicator measurable_const (As_mble i)
  · filter_upwards [As_le_B] with i hi
    exact eventually_of_forall (fun x ↦ indicator_le_indicator_of_subset hi (by simp) x)
  · rwa [← lintegral_indicator_one B_mble] at B_finmeas
  · simpa only [show (OfNat.ofNat 1 : α → ℝ≥0∞) = (fun _ ↦ 1) by 

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
m m0 : MeasurableSpace α✝
α : Type u_5
inst✝¹ : MeasurableSpace α
A : Set α
ι : Type u_6
L : Filter ι
inst✝ : IsCountablyGenerated L
As : ι → Set α
μ : Measure α
A_mble : MeasurableSet A
As_mble : ∀ (i : ι), MeasurableSet (As i)
B : Set α
B_mble : MeasurableSet B
B_finmeas : ↑↑μ B ≠ ⊤
As_le_B : ∀ᶠ (i : ι) in L, As i ⊆ B
h_lim : ∀ᵐ (x : α) ∂μ, ∀ᶠ (i : ι) in L, x ∈ As i ↔ x ∈ A
⊢ OfNat.ofNat 1 = fun x => 1

Next tactic:
rfl
@[simp]
theorem frobenius_comp_frobeniusEquiv_symm :
    (frobenius R p).comp (frobeniusEquiv R p).symm = RingHom.id R := by
  

Proof state:
R : Type u_1
p : ℕ
inst✝³ : CommSemiring R
inst✝² : Fact (Nat.Prime p)
inst✝¹ : CharP R p
inst✝ : PerfectRing R p
⊢ RingHom.comp (frobenius R p) ↑(RingEquiv.symm (frobeniusEquiv R p)) = RingHom.id R

Next tactic:
ext
@[simp]
theorem frobenius_comp_frobeniusEquiv_symm :
    (frobenius R p).comp (frobeniusEquiv R p).symm = RingHom.id R := by
  ext; 

Proof state:
case a
R : Type u_1
p : ℕ
inst✝³ : CommSemiring R
inst✝² : Fact (Nat.Prime p)
inst✝¹ : CharP R p
inst✝ : PerfectRing R p
x✝ : R
⊢ (RingHom.comp (frobenius R p) ↑(RingEquiv.symm (frobeniusEquiv R p))) x✝ = (RingHom.id R) x✝

Next tactic:
simp
@[simp]
theorem frobeniusEquiv_symm_comp_frobenius :
    ((frobeniusEquiv R p).symm : R →+* R).comp (frobenius R p) = RingHom.id R := by
  

Proof state:
R : Type u_1
p : ℕ
inst✝³ : CommSemiring R
inst✝² : Fact (Nat.Prime p)
inst✝¹ : CharP R p
inst✝ : PerfectRing R p
⊢ RingHom.comp (↑(RingEquiv.symm (frobeniusEquiv R p))) (frobenius R p) = RingHom.id R

Next tactic:
ext
@[simp]
theorem frobeniusEquiv_symm_comp_frobenius :
    ((frobeniusEquiv R p).symm : R →+* R).comp (frobenius R p) = RingHom.id R := by
  ext; 

Proof state:
case a
R : Type u_1
p : ℕ
inst✝³ : CommSemiring R
inst✝² : Fact (Nat.Prime p)
inst✝¹ : CharP R p
inst✝ : PerfectRing R p
x✝ : R
⊢ (RingHom.comp (↑(RingEquiv.symm (frobeniusEquiv R p))) (frobenius R p)) x✝ = (RingHom.id R) x✝

Next tactic:
simp
lemma polynomial_expand_eq (f : R[X]) :
    expand R p f = (f.map (frobeniusEquiv R p).symm) ^ p := by
  

Proof state:
R : Type u_1
p : ℕ
inst✝³ : CommSemiring R
inst✝² : Fact (Nat.Prime p)
inst✝¹ : CharP R p
inst✝ : PerfectRing R p
f : R[X]
⊢ (expand R p) f = map (↑(RingEquiv.symm (frobeniusEquiv R p))) f ^ p

Next tactic:
rw [← (f.map (S := R) (frobeniusEquiv R p).symm).expand_char p, map_expand, map_map,
    frobenius_comp_frobeniusEquiv_symm, map_id]
@[simp]
theorem not_irreducible_expand (f : R[X]) : ¬ Irreducible (expand R p f) := by
  

Proof state:
R : Type u_1
p : ℕ
inst✝³ : CommSemiring R
inst✝² : Fact (Nat.Prime p)
inst✝¹ : CharP R p
inst✝ : PerfectRing R p
f : R[X]
⊢ ¬Irreducible ((expand R p) f)

Next tactic:
have hp : Fact p.Prime := inferInstance
@[simp]
theorem not_irreducible_expand (f : R[X]) : ¬ Irreducible (expand R p f) := by
  have hp : Fact p.Prime := inferInstance
  

Proof state:
R : Type u_1
p : ℕ
inst✝³ : CommSemiring R
inst✝² : Fact (Nat.Prime p)
inst✝¹ : CharP R p
inst✝ : PerfectRing R p
f : R[X]
hp : Fact (Nat.Prime p)
⊢ ¬Irreducible ((expand R p) f)

Next tactic:
rw [polynomial_expand_eq]
@[simp]
theorem not_irreducible_expand (f : R[X]) : ¬ Irreducible (expand R p f) := by
  have hp : Fact p.Prime := inferInstance
  rw [polynomial_expand_eq]
  

Proof state:
R : Type u_1
p : ℕ
inst✝³ : CommSemiring R
inst✝² : Fact (Nat.Prime p)
inst✝¹ : CharP R p
inst✝ : PerfectRing R p
f : R[X]
hp : Fact (Nat.Prime p)
⊢ ¬Irreducible (map (↑(RingEquiv.symm (frobeniusEquiv R p))) f ^ p)

Next tactic:
exact not_irreducible_pow hp.out.ne_one
instance (S : Type*) [CommSemiring S] [CharP S p] [PerfectRing S p] :
    PerfectRing (R × S) p := by
  

Proof state:
R : Type u_1
p : ℕ
inst✝⁶ : CommSemiring R
inst✝⁵ : Fact (Nat.Prime p)
inst✝⁴ : CharP R p
inst✝³ : PerfectRing R p
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : CharP S p
inst✝ : PerfectRing S p
⊢ PerfectRing (R × S) p

Next tactic:
constructor
instance (S : Type*) [CommSemiring S] [CharP S p] [PerfectRing S p] :
    PerfectRing (R × S) p := by
  constructor
  

Proof state:
case bijective_frobenius
R : Type u_1
p : ℕ
inst✝⁶ : CommSemiring R
inst✝⁵ : Fact (Nat.Prime p)
inst✝⁴ : CharP R p
inst✝³ : PerfectRing R p
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : CharP S p
inst✝ : PerfectRing S p
⊢ Bijective ⇑(frobenius (R × S) p)

Next tactic:
have : frobenius (R × S) p = Prod.map (frobenius R p) (frobenius S p) := by
    ext <;> simp [frobenius_def]
instance (S : Type*) [CommSemiring S] [CharP S p] [PerfectRing S p] :
    PerfectRing (R × S) p := by
  constructor
  have : frobenius (R × S) p = Prod.map (frobenius R p) (frobenius S p) := by
    

Proof state:
R : Type u_1
p : ℕ
inst✝⁶ : CommSemiring R
inst✝⁵ : Fact (Nat.Prime p)
inst✝⁴ : CharP R p
inst✝³ : PerfectRing R p
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : CharP S p
inst✝ : PerfectRing S p
⊢ ⇑(frobenius (R × S) p) = Prod.map ⇑(frobenius R p) ⇑(frobenius S p)

Next tactic:
ext
instance (S : Type*) [CommSemiring S] [CharP S p] [PerfectRing S p] :
    PerfectRing (R × S) p := by
  constructor
  have : frobenius (R × S) p = Prod.map (frobenius R p) (frobenius S p) := by
    ext <;> 

Proof state:
case h.a
R : Type u_1
p : ℕ
inst✝⁶ : CommSemiring R
inst✝⁵ : Fact (Nat.Prime p)
inst✝⁴ : CharP R p
inst✝³ : PerfectRing R p
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : CharP S p
inst✝ : PerfectRing S p
x✝ : R × S
⊢ ((frobenius (R × S) p) x✝).1 = (Prod.map (⇑(frobenius R p)) (⇑(frobenius S p)) x✝).1

Next tactic:
simp [frobenius_def]
instance (S : Type*) [CommSemiring S] [CharP S p] [PerfectRing S p] :
    PerfectRing (R × S) p := by
  constructor
  have : frobenius (R × S) p = Prod.map (frobenius R p) (frobenius S p) := by
    ext <;> 

Proof state:
case h.a
R : Type u_1
p : ℕ
inst✝⁶ : CommSemiring R
inst✝⁵ : Fact (Nat.Prime p)
inst✝⁴ : CharP R p
inst✝³ : PerfectRing R p
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : CharP S p
inst✝ : PerfectRing S p
x✝ : R × S
⊢ ((frobenius (R × S) p) x✝).2 = (Prod.map (⇑(frobenius R p)) (⇑(frobenius S p)) x✝).2

Next tactic:
simp [frobenius_def]
instance (S : Type*) [CommSemiring S] [CharP S p] [PerfectRing S p] :
    PerfectRing (R × S) p := by
  constructor
  have : frobenius (R × S) p = Prod.map (frobenius R p) (frobenius S p) := by
    ext <;> simp [frobenius_def]
  

Proof state:
case bijective_frobenius
R : Type u_1
p : ℕ
inst✝⁶ : CommSemiring R
inst✝⁵ : Fact (Nat.Prime p)
inst✝⁴ : CharP R p
inst✝³ : PerfectRing R p
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : CharP S p
inst✝ : PerfectRing S p
this : ⇑(frobenius (R × S) p) = Prod.map ⇑(frobenius R p) ⇑(frobenius S p)
⊢ Bijective ⇑(frobenius (R × S) p)

Next tactic:
rw [this]
instance (S : Type*) [CommSemiring S] [CharP S p] [PerfectRing S p] :
    PerfectRing (R × S) p := by
  constructor
  have : frobenius (R × S) p = Prod.map (frobenius R p) (frobenius S p) := by
    ext <;> simp [frobenius_def]
  rw [this]
  

Proof state:
case bijective_frobenius
R : Type u_1
p : ℕ
inst✝⁶ : CommSemiring R
inst✝⁵ : Fact (Nat.Prime p)
inst✝⁴ : CharP R p
inst✝³ : PerfectRing R p
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : CharP S p
inst✝ : PerfectRing S p
this : ⇑(frobenius (R × S) p) = Prod.map ⇑(frobenius R p) ⇑(frobenius S p)
⊢ Bijective (Prod.map ⇑(frobenius R p) ⇑(frobenius S p))

Next tactic:
exact Bijective.Prod_map (bijective_frobenius R p) (bijective_frobenius S p)
lemma PerfectRing.toPerfectField (K : Type*) (p : ℕ)
    [Field K] [hp : Fact p.Prime] [CharP K p] [PerfectRing K p] : PerfectField K := by
  

Proof state:
K : Type u_1
p : ℕ
inst✝² : Field K
hp : Fact (Nat.Prime p)
inst✝¹ : CharP K p
inst✝ : PerfectRing K p
⊢ PerfectField K

Next tactic:
refine' PerfectField.mk $ fun hf ↦ _
lemma PerfectRing.toPerfectField (K : Type*) (p : ℕ)
    [Field K] [hp : Fact p.Prime] [CharP K p] [PerfectRing K p] : PerfectField K := by
  refine' PerfectField.mk $ fun hf ↦ _
  

Proof state:
K : Type u_1
p : ℕ
inst✝² : Field K
hp : Fact (Nat.Prime p)
inst✝¹ : CharP K p
inst✝ : PerfectRing K p
f✝ : K[X]
hf : Irreducible f✝
⊢ Separable f✝

Next tactic:
rcases separable_or p hf with h | ⟨-, g, -, rfl⟩
lemma PerfectRing.toPerfectField (K : Type*) (p : ℕ)
    [Field K] [hp : Fact p.Prime] [CharP K p] [PerfectRing K p] : PerfectField K := by
  refine' PerfectField.mk $ fun hf ↦ _
  rcases separable_or p hf with h | ⟨-, g, -, rfl⟩
  · 

Proof state:
case inl
K : Type u_1
p : ℕ
inst✝² : Field K
hp : Fact (Nat.Prime p)
inst✝¹ : CharP K p
inst✝ : PerfectRing K p
f✝ : K[X]
hf : Irreducible f✝
h : Separable f✝
⊢ Separable f✝

Next tactic:
assumption
lemma PerfectRing.toPerfectField (K : Type*) (p : ℕ)
    [Field K] [hp : Fact p.Prime] [CharP K p] [PerfectRing K p] : PerfectField K := by
  refine' PerfectField.mk $ fun hf ↦ _
  rcases separable_or p hf with h | ⟨-, g, -, rfl⟩
  · assumption
  · 

Proof state:
case inr.intro.intro.intro
K : Type u_1
p : ℕ
inst✝² : Field K
hp : Fact (Nat.Prime p)
inst✝¹ : CharP K p
inst✝ : PerfectRing K p
g : K[X]
hf : Irreducible ((expand K p) g)
⊢ Separable ((expand K p) g)

Next tactic:
exfalso
lemma PerfectRing.toPerfectField (K : Type*) (p : ℕ)
    [Field K] [hp : Fact p.Prime] [CharP K p] [PerfectRing K p] : PerfectField K := by
  refine' PerfectField.mk $ fun hf ↦ _
  rcases separable_or p hf with h | ⟨-, g, -, rfl⟩
  · assumption
  · exfalso; 

Proof state:
case inr.intro.intro.intro.h
K : Type u_1
p : ℕ
inst✝² : Field K
hp : Fact (Nat.Prime p)
inst✝¹ : CharP K p
inst✝ : PerfectRing K p
g : K[X]
hf : Irreducible ((expand K p) g)
⊢ False

Next tactic:
revert hf
lemma PerfectRing.toPerfectField (K : Type*) (p : ℕ)
    [Field K] [hp : Fact p.Prime] [CharP K p] [PerfectRing K p] : PerfectField K := by
  refine' PerfectField.mk $ fun hf ↦ _
  rcases separable_or p hf with h | ⟨-, g, -, rfl⟩
  · assumption
  · exfalso; revert hf; 

Proof state:
case inr.intro.intro.intro.h
K : Type u_1
p : ℕ
inst✝² : Field K
hp : Fact (Nat.Prime p)
inst✝¹ : CharP K p
inst✝ : PerfectRing K p
g : K[X]
⊢ Irreducible ((expand K p) g) → False

Next tactic:
simp
instance ofFinite [Finite K] : PerfectField K := by
  

Proof state:
K : Type u_1
inst✝¹ : Field K
inst✝ : Finite K
⊢ PerfectField K

Next tactic:
obtain ⟨p, _instP⟩ := CharP.exists K
instance ofFinite [Finite K] : PerfectField K := by
  obtain ⟨p, _instP⟩ := CharP.exists K
  

Proof state:
case intro
K : Type u_1
inst✝¹ : Field K
inst✝ : Finite K
p : ℕ
_instP : CharP K p
⊢ PerfectField K

Next tactic:
have : Fact p.Prime := ⟨CharP.char_is_prime K p⟩
instance ofFinite [Finite K] : PerfectField K := by
  obtain ⟨p, _instP⟩ := CharP.exists K
  have : Fact p.Prime := ⟨CharP.char_is_prime K p⟩
  

Proof state:
case intro
K : Type u_1
inst✝¹ : Field K
inst✝ : Finite K
p : ℕ
_instP : CharP K p
this : Fact (Nat.Prime p)
⊢ PerfectField K

Next tactic:
exact PerfectRing.toPerfectField K p
/-- A perfect field of characteristic `p` (prime) is a perfect ring. -/
instance toPerfectRing (p : ℕ) [hp : Fact p.Prime] [CharP K p] : PerfectRing K p := by
  

Proof state:
K : Type u_1
inst✝² : Field K
inst✝¹ : PerfectField K
p : ℕ
hp : Fact (Nat.Prime p)
inst✝ : CharP K p
⊢ PerfectRing K p

Next tactic:
refine' PerfectRing.ofSurjective _ _ $ fun y ↦ _
/-- A perfect field of characteristic `p` (prime) is a perfect ring. -/
instance toPerfectRing (p : ℕ) [hp : Fact p.Prime] [CharP K p] : PerfectRing K p := by
  refine' PerfectRing.ofSurjective _ _ $ fun y ↦ _
  

Proof state:
K : Type u_1
inst✝² : Field K
inst✝¹ : PerfectField K
p : ℕ
hp : Fact (Nat.Prime p)
inst✝ : CharP K p
y : K
⊢ ∃ a, (frobenius K p) a = y

Next tactic:
let f : K[X] := X ^ p - C y
/-- A perfect field of characteristic `p` (prime) is a perfect ring. -/
instance toPerfectRing (p : ℕ) [hp : Fact p.Prime] [CharP K p] : PerfectRing K p := by
  refine' PerfectRing.ofSurjective _ _ $ fun y ↦ _
  let f : K[X] := X ^ p - C y
  

Proof state:
K : Type u_1
inst✝² : Field K
inst✝¹ : PerfectField K
p : ℕ
hp : Fact (Nat.Prime p)
inst✝ : CharP K p
y : K
f : K[X] := X ^ p - C y
⊢ ∃ a, (frobenius K p) a = y

Next tactic:
let L := f.SplittingField
/-- A perfect field of characteristic `p` (prime) is a perfect ring. -/
instance toPerfectRing (p : ℕ) [hp : Fact p.Prime] [CharP K p] : PerfectRing K p := by
  refine' PerfectRing.ofSurjective _ _ $ fun y ↦ _
  let f : K[X] := X ^ p - C y
  let L := f.SplittingField
  

Proof state:
K : Type u_1
inst✝² : Field K
inst✝¹ : PerfectField K
p : ℕ
hp : Fact (Nat.Prime p)
inst✝ : CharP K p
y : K
f : K[X] := X ^ p - C y
L : Type u_1 := SplittingField f
⊢ ∃ a, (frobenius K p) a = y

Next tactic:
let ι := algebraMap K L