-- Mathlib/RingTheory/Algebraic/Basic.lean
theorem algHom_bijective [NoZeroSMulDivisors K L] [Algebra.IsAlgebraic K L] (f : L →ₐ[K] L) :
    Function.Bijective f

Proof state:
K : Type u_1
L : Type u_2
inst✝⁴ : CommRing K
inst✝³ : Field L
inst✝² : Algebra K L
inst✝¹ : NoZeroSMulDivisors K L
inst✝ : Algebra.IsAlgebraic K L
f : L →ₐ[K] L
⊢ Function.Bijective ⇑f

Tactic:
refine ⟨f.injective, fun b ↦ ?_⟩

Result:
K : Type u_1
L : Type u_2
inst✝⁴ : CommRing K
inst✝³ : Field L
inst✝² : Algebra K L
inst✝¹ : NoZeroSMulDivisors K L
inst✝ : Algebra.IsAlgebraic K L
f : L →ₐ[K] L
b : L
⊢ ∃ a, f a = b

Proof state:
case intro.intro.intro
K : Type u_1
L : Type u_2
inst✝⁴ : CommRing K
inst✝³ : Field L
inst✝² : Algebra K L
inst✝¹ : NoZeroSMulDivisors K L
inst✝ : Algebra.IsAlgebraic K L
f : L →ₐ[K] L
b : L
p : K[X]
hp : p ≠ 0
he : (aeval b) p = 0
f' : ↑(p.rootSet L) → ↑(p.rootSet L) := Set.MapsTo.restrict (⇑f) (p.rootSet L) (p.rootSet L) ⋯
this : Function.Surjective f'
a : ↑(p.rootSet L)
ha : f' a = ⟨b, ⋯⟩
⊢ ∃ a, f a = b

Tactic:
exact ⟨a, Subtype.ext_iff.1 ha⟩

Result:
no goals

Proof state:
case intro.intro
K : Type u_1
L : Type u_2
inst✝⁴ : CommRing K
inst✝³ : Field L
inst✝² : Algebra K L
inst✝¹ : NoZeroSMulDivisors K L
inst✝ : Algebra.IsAlgebraic K L
f : L →ₐ[K] L
b : L
p : K[X]
hp : p ≠ 0
he : (aeval b) p = 0
f' : ↑(p.rootSet L) → ↑(p.rootSet L) := Set.MapsTo.restrict (⇑f) (p.rootSet L) (p.rootSet L) ⋯
this : Function.Surjective f'
⊢ ∃ a, f a = b

Tactic:
obtain ⟨a, ha⟩ := this ⟨b, mem_rootSet.2 ⟨hp, he⟩⟩

Result:
case intro.intro.intro
K : Type u_1
L : Type u_2
inst✝⁴ : CommRing K
inst✝³ : Field L
inst✝² : Algebra K L
inst✝¹ : NoZeroSMulDivisors K L
inst✝ : Algebra.IsAlgebraic K L
f : L →ₐ[K] L
b : L
p : K[X]
hp : p ≠ 0
he : (aeval b) p = 0
f' : ↑(p.rootSet L) → ↑(p.rootSet L) := Set.MapsTo.restrict (⇑f) (p.rootSet L) (p.rootSet L) ⋯
this : Function.Surjective f'
a : ↑(p.rootSet L)
ha : f' a = ⟨b, ⋯⟩
⊢ ∃ a, f a = b

Proof state:
case intro.intro
K : Type u_1
L : Type u_2
inst✝⁴ : CommRing K
inst✝³ : Field L
inst✝² : Algebra K L
inst✝¹ : NoZeroSMulDivisors K L
inst✝ : Algebra.IsAlgebraic K L
f : L →ₐ[K] L
b : L
p : K[X]
hp : p ≠ 0
he : (aeval b) p = 0
f' : ↑(p.rootSet L) → ↑(p.rootSet L) := Set.MapsTo.restrict (⇑f) (p.rootSet L) (p.rootSet L) ⋯
⊢ ∃ a, f a = b

Tactic:
have : f'.Surjective := Finite.injective_iff_surjective.1
  fun _ _ h ↦ Subtype.eq <| f.injective <| Subtype.ext_iff.1 h

Result:
case intro.intro
K : Type u_1
L : Type u_2
inst✝⁴ : CommRing K
inst✝³ : Field L
inst✝² : Algebra K L
inst✝¹ : NoZeroSMulDivisors K L
inst✝ : Algebra.IsAlgebraic K L
f : L →ₐ[K] L
b : L
p : K[X]
hp : p ≠ 0
he : (aeval b) p = 0
f' : ↑(p.rootSet L) → ↑(p.rootSet L) := Set.MapsTo.restrict (⇑f) (p.rootSet L) (p.rootSet L) ⋯
this : Function.Surjective f'
⊢ ∃ a, f a = b

Proof state:
case intro.intro
K : Type u_1
L : Type u_2
inst✝⁴ : CommRing K
inst✝³ : Field L
inst✝² : Algebra K L
inst✝¹ : NoZeroSMulDivisors K L
inst✝ : Algebra.IsAlgebraic K L
f : L →ₐ[K] L
b : L
p : K[X]
hp : p ≠ 0
he : (aeval b) p = 0
⊢ ∃ a, f a = b

Tactic:
let f' : p.rootSet L → p.rootSet L := (rootSet_maps_to' (fun x ↦ x) f).restrict f _ _

Result:
case intro.intro
K : Type u_1
L : Type u_2
inst✝⁴ : CommRing K
inst✝³ : Field L
inst✝² : Algebra K L
inst✝¹ : NoZeroSMulDivisors K L
inst✝ : Algebra.IsAlgebraic K L
f : L →ₐ[K] L
b : L
p : K[X]
hp : p ≠ 0
he : (aeval b) p = 0
f' : ↑(p.rootSet L) → ↑(p.rootSet L) := Set.MapsTo.restrict (⇑f) (p.rootSet L) (p.rootSet L) ⋯
⊢ ∃ a, f a = b

Proof state:
K : Type u_1
L : Type u_2
inst✝⁴ : CommRing K
inst✝³ : Field L
inst✝² : Algebra K L
inst✝¹ : NoZeroSMulDivisors K L
inst✝ : Algebra.IsAlgebraic K L
f : L →ₐ[K] L
b : L
⊢ ∃ a, f a = b

Tactic:
obtain ⟨p, hp, he⟩ := Algebra.IsAlgebraic.isAlgebraic (R := K) b

Result:
case intro.intro
K : Type u_1
L : Type u_2
inst✝⁴ : CommRing K
inst✝³ : Field L
inst✝² : Algebra K L
inst✝¹ : NoZeroSMulDivisors K L
inst✝ : Algebra.IsAlgebraic K L
f : L →ₐ[K] L
b : L
p : K[X]
hp : p ≠ 0
he : (aeval b) p = 0
⊢ ∃ a, f a = b