l3lab/ntp-mathlib huggingface dataset:
/-- The explicit left homology data of a short complex of abelian group that is
given by a kernel and a quotient given by the `AddMonoidHom` API. -/
@[simps]
def abLeftHomologyData : S.LeftHomologyData where
  K := AddCommGroupCat.of (AddMonoidHom.ker S.g)
  H := AddCommGroupCat.of ((AddMonoidHom.ker S.g) ⧸ AddMonoidHom.range S.abToCycles)
  i := (AddMonoidHom.ker S.g).subtype
  π := QuotientAddGroup.mk' _
  wi := by
    ext ⟨_, hx⟩
    exact hx
  hi := AddCommGroupCat.kernelIsLimit _
  wπ := by
    ext (x : S.X₁)
    

Proof state:
case w
S : ShortComplex Ab
x : ↑S.X₁
⊢ (Limits.IsLimit.lift (AddCommGroupCat.kernelIsLimit S.g) (Limits.KernelFork.ofι S.f (_ : S.f ≫ S.g = 0)) ≫
        QuotientAddGroup.mk' (AddMonoidHom.range (abToCycles S)))
      x =
    0 x

Next tactic:
erw [QuotientAddGroup.eq_zero_iff]
/-- The explicit left homology data of a short complex of abelian group that is
given by a kernel and a quotient given by the `AddMonoidHom` API. -/
@[simps]
def abLeftHomologyData : S.LeftHomologyData where
  K := AddCommGroupCat.of (AddMonoidHom.ker S.g)
  H := AddCommGroupCat.of ((AddMonoidHom.ker S.g) ⧸ AddMonoidHom.range S.abToCycles)
  i := (AddMonoidHom.ker S.g).subtype
  π := QuotientAddGroup.mk' _
  wi := by
    ext ⟨_, hx⟩
    exact hx
  hi := AddCommGroupCat.kernelIsLimit _
  wπ := by
    ext (x : S.X₁)
    erw [QuotientAddGroup.eq_zero_iff]
    

Proof state:
case w
S : ShortComplex Ab
x : ↑S.X₁
⊢ (Limits.IsLimit.lift (AddCommGroupCat.kernelIsLimit S.g) (Limits.KernelFork.ofι S.f (_ : S.f ≫ S.g = 0))) x ∈
    AddMonoidHom.range (abToCycles S)

Next tactic:
rw [AddMonoidHom.mem_range]
/-- The explicit left homology data of a short complex of abelian group that is
given by a kernel and a quotient given by the `AddMonoidHom` API. -/
@[simps]
def abLeftHomologyData : S.LeftHomologyData where
  K := AddCommGroupCat.of (AddMonoidHom.ker S.g)
  H := AddCommGroupCat.of ((AddMonoidHom.ker S.g) ⧸ AddMonoidHom.range S.abToCycles)
  i := (AddMonoidHom.ker S.g).subtype
  π := QuotientAddGroup.mk' _
  wi := by
    ext ⟨_, hx⟩
    exact hx
  hi := AddCommGroupCat.kernelIsLimit _
  wπ := by
    ext (x : S.X₁)
    erw [QuotientAddGroup.eq_zero_iff]
    rw [AddMonoidHom.mem_range]
    

Proof state:
case w
S : ShortComplex Ab
x : ↑S.X₁
⊢ ∃ x_1,
    (abToCycles S) x_1 =
      (Limits.IsLimit.lift (AddCommGroupCat.kernelIsLimit S.g) (Limits.KernelFork.ofι S.f (_ : S.f ≫ S.g = 0))) x

Next tactic:
apply exists_apply_eq_apply
lemma exact_iff_surjective_abToCycles :
    S.Exact ↔ Function.Surjective S.abToCycles := by
  

Proof state:
S : ShortComplex Ab
⊢ Exact S ↔ Function.Surjective ⇑(abToCycles S)

Next tactic:
rw [S.abLeftHomologyData.exact_iff_epi_f', abLeftHomologyData_f',
    AddCommGroupCat.epi_iff_surjective]
lemma exact_iff_surjective_abToCycles :
    S.Exact ↔ Function.Surjective S.abToCycles := by
  rw [S.abLeftHomologyData.exact_iff_epi_f', abLeftHomologyData_f',
    AddCommGroupCat.epi_iff_surjective]
  

Proof state:
S : ShortComplex Ab
⊢ Function.Surjective ⇑(abToCycles S) ↔ Function.Surjective ⇑(abToCycles S)

Next tactic:
rfl
lemma ab_exact_iff :
    S.Exact ↔ ∀ (x₂ : S.X₂) (_ : S.g x₂ = 0), ∃ (x₁ : S.X₁), S.f x₁ = x₂ := by
  

Proof state:
S : ShortComplex Ab
⊢ Exact S ↔ ∀ (x₂ : ↑S.X₂), S.g x₂ = 0 → ∃ x₁, S.f x₁ = x₂

Next tactic:
rw [exact_iff_surjective_abToCycles]
lemma ab_exact_iff :
    S.Exact ↔ ∀ (x₂ : S.X₂) (_ : S.g x₂ = 0), ∃ (x₁ : S.X₁), S.f x₁ = x₂ := by
  rw [exact_iff_surjective_abToCycles]
  

Proof state:
S : ShortComplex Ab
⊢ Function.Surjective ⇑(abToCycles S) ↔ ∀ (x₂ : ↑S.X₂), S.g x₂ = 0 → ∃ x₁, S.f x₁ = x₂

Next tactic:
constructor
lemma ab_exact_iff :
    S.Exact ↔ ∀ (x₂ : S.X₂) (_ : S.g x₂ = 0), ∃ (x₁ : S.X₁), S.f x₁ = x₂ := by
  rw [exact_iff_surjective_abToCycles]
  constructor
  · 

Proof state:
case mp
S : ShortComplex Ab
⊢ Function.Surjective ⇑(abToCycles S) → ∀ (x₂ : ↑S.X₂), S.g x₂ = 0 → ∃ x₁, S.f x₁ = x₂

Next tactic:
intro h x₂ hx₂
lemma ab_exact_iff :
    S.Exact ↔ ∀ (x₂ : S.X₂) (_ : S.g x₂ = 0), ∃ (x₁ : S.X₁), S.f x₁ = x₂ := by
  rw [exact_iff_surjective_abToCycles]
  constructor
  · intro h x₂ hx₂
    

Proof state:
case mp
S : ShortComplex Ab
h : Function.Surjective ⇑(abToCycles S)
x₂ : ↑S.X₂
hx₂ : S.g x₂ = 0
⊢ ∃ x₁, S.f x₁ = x₂

Next tactic:
obtain ⟨x₁, hx₁⟩ := h ⟨x₂, hx₂⟩
lemma ab_exact_iff :
    S.Exact ↔ ∀ (x₂ : S.X₂) (_ : S.g x₂ = 0), ∃ (x₁ : S.X₁), S.f x₁ = x₂ := by
  rw [exact_iff_surjective_abToCycles]
  constructor
  · intro h x₂ hx₂
    obtain ⟨x₁, hx₁⟩ := h ⟨x₂, hx₂⟩
    

Proof state:
case mp.intro
S : ShortComplex Ab
h : Function.Surjective ⇑(abToCycles S)
x₂ : ↑S.X₂
hx₂ : S.g x₂ = 0
x₁ : ↑S.X₁
hx₁ : (abToCycles S) x₁ = { val := x₂, property := hx₂ }
⊢ ∃ x₁, S.f x₁ = x₂

Next tactic:
exact ⟨x₁, by simpa only [Subtype.ext_iff, abToCycles_apply_coe] using hx₁⟩
lemma ab_exact_iff :
    S.Exact ↔ ∀ (x₂ : S.X₂) (_ : S.g x₂ = 0), ∃ (x₁ : S.X₁), S.f x₁ = x₂ := by
  rw [exact_iff_surjective_abToCycles]
  constructor
  · intro h x₂ hx₂
    obtain ⟨x₁, hx₁⟩ := h ⟨x₂, hx₂⟩
    exact ⟨x₁, by 

Proof state:
S : ShortComplex Ab
h : Function.Surjective ⇑(abToCycles S)
x₂ : ↑S.X₂
hx₂ : S.g x₂ = 0
x₁ : ↑S.X₁
hx₁ : (abToCycles S) x₁ = { val := x₂, property := hx₂ }
⊢ S.f x₁ = x₂

Next tactic:
simpa only [Subtype.ext_iff, abToCycles_apply_coe] using hx₁
lemma ab_exact_iff :
    S.Exact ↔ ∀ (x₂ : S.X₂) (_ : S.g x₂ = 0), ∃ (x₁ : S.X₁), S.f x₁ = x₂ := by
  rw [exact_iff_surjective_abToCycles]
  constructor
  · intro h x₂ hx₂
    obtain ⟨x₁, hx₁⟩ := h ⟨x₂, hx₂⟩
    exact ⟨x₁, by simpa only [Subtype.ext_iff, abToCycles_apply_coe] using hx₁⟩
  · 

Proof state:
case mpr
S : ShortComplex Ab
⊢ (∀ (x₂ : ↑S.X₂), S.g x₂ = 0 → ∃ x₁, S.f x₁ = x₂) → Function.Surjective ⇑(abToCycles S)

Next tactic:
rintro h ⟨x₂, hx₂⟩
lemma ab_exact_iff :
    S.Exact ↔ ∀ (x₂ : S.X₂) (_ : S.g x₂ = 0), ∃ (x₁ : S.X₁), S.f x₁ = x₂ := by
  rw [exact_iff_surjective_abToCycles]
  constructor
  · intro h x₂ hx₂
    obtain ⟨x₁, hx₁⟩ := h ⟨x₂, hx₂⟩
    exact ⟨x₁, by simpa only [Subtype.ext_iff, abToCycles_apply_coe] using hx₁⟩
  · rintro h ⟨x₂, hx₂⟩
    

Proof state:
case mpr.mk
S : ShortComplex Ab
h : ∀ (x₂ : ↑S.X₂), S.g x₂ = 0 → ∃ x₁, S.f x₁ = x₂
x₂ : ↑S.X₂
hx₂ : x₂ ∈ AddMonoidHom.ker S.g
⊢ ∃ a, (abToCycles S) a = { val := x₂, property := hx₂ }

Next tactic:
obtain ⟨x₁, rfl⟩ := h x₂ hx₂
lemma ab_exact_iff :
    S.Exact ↔ ∀ (x₂ : S.X₂) (_ : S.g x₂ = 0), ∃ (x₁ : S.X₁), S.f x₁ = x₂ := by
  rw [exact_iff_surjective_abToCycles]
  constructor
  · intro h x₂ hx₂
    obtain ⟨x₁, hx₁⟩ := h ⟨x₂, hx₂⟩
    exact ⟨x₁, by simpa only [Subtype.ext_iff, abToCycles_apply_coe] using hx₁⟩
  · rintro h ⟨x₂, hx₂⟩
    obtain ⟨x₁, rfl⟩ := h x₂ hx₂
    

Proof state:
case mpr.mk.intro
S : ShortComplex Ab
h : ∀ (x₂ : ↑S.X₂), S.g x₂ = 0 → ∃ x₁, S.f x₁ = x₂
x₁ : ↑S.X₁
hx₂ : S.f x₁ ∈ AddMonoidHom.ker S.g
⊢ ∃ a, (abToCycles S) a = { val := S.f x₁, property := hx₂ }

Next tactic:
exact ⟨x₁, rfl⟩
lemma ab_exact_iff_range_eq_ker : S.Exact ↔ S.f.range = S.g.ker := by
  

Proof state:
S : ShortComplex Ab
⊢ Exact S ↔ AddMonoidHom.range S.f = AddMonoidHom.ker S.g

Next tactic:
rw [ab_exact_iff_ker_le_range]
lemma ab_exact_iff_range_eq_ker : S.Exact ↔ S.f.range = S.g.ker := by
  rw [ab_exact_iff_ker_le_range]
  

Proof state:
S : ShortComplex Ab
⊢ AddMonoidHom.ker S.g ≤ AddMonoidHom.range S.f ↔ AddMonoidHom.range S.f = AddMonoidHom.ker S.g

Next tactic:
constructor
lemma ab_exact_iff_range_eq_ker : S.Exact ↔ S.f.range = S.g.ker := by
  rw [ab_exact_iff_ker_le_range]
  constructor
  · 

Proof state:
case mp
S : ShortComplex Ab
⊢ AddMonoidHom.ker S.g ≤ AddMonoidHom.range S.f → AddMonoidHom.range S.f = AddMonoidHom.ker S.g

Next tactic:
intro h
lemma ab_exact_iff_range_eq_ker : S.Exact ↔ S.f.range = S.g.ker := by
  rw [ab_exact_iff_ker_le_range]
  constructor
  · intro h
    

Proof state:
case mp
S : ShortComplex Ab
h : AddMonoidHom.ker S.g ≤ AddMonoidHom.range S.f
⊢ AddMonoidHom.range S.f = AddMonoidHom.ker S.g

Next tactic:
refine' le_antisymm _ h
lemma ab_exact_iff_range_eq_ker : S.Exact ↔ S.f.range = S.g.ker := by
  rw [ab_exact_iff_ker_le_range]
  constructor
  · intro h
    refine' le_antisymm _ h
    

Proof state:
case mp
S : ShortComplex Ab
h : AddMonoidHom.ker S.g ≤ AddMonoidHom.range S.f
⊢ AddMonoidHom.range S.f ≤ AddMonoidHom.ker S.g

Next tactic:
rintro _ ⟨x₁, rfl⟩
lemma ab_exact_iff_range_eq_ker : S.Exact ↔ S.f.range = S.g.ker := by
  rw [ab_exact_iff_ker_le_range]
  constructor
  · intro h
    refine' le_antisymm _ h
    rintro _ ⟨x₁, rfl⟩
    

Proof state:
case mp.intro
S : ShortComplex Ab
h : AddMonoidHom.ker S.g ≤ AddMonoidHom.range S.f
x₁ : ↑S.X₁
⊢ S.f x₁ ∈ AddMonoidHom.ker S.g

Next tactic:
erw [AddMonoidHom.mem_ker, ← comp_apply, S.zero]
lemma ab_exact_iff_range_eq_ker : S.Exact ↔ S.f.range = S.g.ker := by
  rw [ab_exact_iff_ker_le_range]
  constructor
  · intro h
    refine' le_antisymm _ h
    rintro _ ⟨x₁, rfl⟩
    erw [AddMonoidHom.mem_ker, ← comp_apply, S.zero]
    

Proof state:
case mp.intro
S : ShortComplex Ab
h : AddMonoidHom.ker S.g ≤ AddMonoidHom.range S.f
x₁ : ↑S.X₁
⊢ 0 x₁ = 0

Next tactic:
rfl
lemma ab_exact_iff_range_eq_ker : S.Exact ↔ S.f.range = S.g.ker := by
  rw [ab_exact_iff_ker_le_range]
  constructor
  · intro h
    refine' le_antisymm _ h
    rintro _ ⟨x₁, rfl⟩
    erw [AddMonoidHom.mem_ker, ← comp_apply, S.zero]
    rfl
  · 

Proof state:
case mpr
S : ShortComplex Ab
⊢ AddMonoidHom.range S.f = AddMonoidHom.ker S.g → AddMonoidHom.ker S.g ≤ AddMonoidHom.range S.f

Next tactic:
intro h
lemma ab_exact_iff_range_eq_ker : S.Exact ↔ S.f.range = S.g.ker := by
  rw [ab_exact_iff_ker_le_range]
  constructor
  · intro h
    refine' le_antisymm _ h
    rintro _ ⟨x₁, rfl⟩
    erw [AddMonoidHom.mem_ker, ← comp_apply, S.zero]
    rfl
  · intro h
    

Proof state:
case mpr
S : ShortComplex Ab
h : AddMonoidHom.range S.f = AddMonoidHom.ker S.g
⊢ AddMonoidHom.ker S.g ≤ AddMonoidHom.range S.f

Next tactic:
rw [h]
/-- A subalgebra is algebraic if and only if it is algebraic as an algebra. -/
theorem Subalgebra.isAlgebraic_iff (S : Subalgebra R A) :
    S.IsAlgebraic ↔ @Algebra.IsAlgebraic R S _ _ S.algebra := by
  

Proof state:
R : Type u
A : Type v
inst✝² : CommRing R
inst✝¹ : Ring A
inst✝ : Algebra R A
S : Subalgebra R A
⊢ IsAlgebraic S ↔ Algebra.IsAlgebraic R ↥S

Next tactic:
delta Algebra.IsAlgebraic Subalgebra.IsAlgebraic
/-- A subalgebra is algebraic if and only if it is algebraic as an algebra. -/
theorem Subalgebra.isAlgebraic_iff (S : Subalgebra R A) :
    S.IsAlgebraic ↔ @Algebra.IsAlgebraic R S _ _ S.algebra := by
  delta Algebra.IsAlgebraic Subalgebra.IsAlgebraic
  

Proof state:
R : Type u
A : Type v
inst✝² : CommRing R
inst✝¹ : Ring A
inst✝ : Algebra R A
S : Subalgebra R A
⊢ (∀ x ∈ S, _root_.IsAlgebraic R x) ↔ ∀ (x : ↥S), _root_.IsAlgebraic R x

Next tactic:
rw [Subtype.forall']
/-- A subalgebra is algebraic if and only if it is algebraic as an algebra. -/
theorem Subalgebra.isAlgebraic_iff (S : Subalgebra R A) :
    S.IsAlgebraic ↔ @Algebra.IsAlgebraic R S _ _ S.algebra := by
  delta Algebra.IsAlgebraic Subalgebra.IsAlgebraic
  rw [Subtype.forall']
  

Proof state:
R : Type u
A : Type v
inst✝² : CommRing R
inst✝¹ : Ring A
inst✝ : Algebra R A
S : Subalgebra R A
⊢ (∀ (x : ↥S), _root_.IsAlgebraic R ↑x) ↔ ∀ (x : ↥S), _root_.IsAlgebraic R x

Next tactic:
refine' forall_congr' fun x => exists_congr fun p => and_congr Iff.rfl _
/-- A subalgebra is algebraic if and only if it is algebraic as an algebra. -/
theorem Subalgebra.isAlgebraic_iff (S : Subalgebra R A) :
    S.IsAlgebraic ↔ @Algebra.IsAlgebraic R S _ _ S.algebra := by
  delta Algebra.IsAlgebraic Subalgebra.IsAlgebraic
  rw [Subtype.forall']
  refine' forall_congr' fun x => exists_congr fun p => and_congr Iff.rfl _
  

Proof state:
R : Type u
A : Type v
inst✝² : CommRing R
inst✝¹ : Ring A
inst✝ : Algebra R A
S : Subalgebra R A
x : ↥S
p : R[X]
⊢ (aeval ↑x) p = 0 ↔ (aeval x) p = 0

Next tactic:
have h : Function.Injective S.val := Subtype.val_injective
/-- A subalgebra is algebraic if and only if it is algebraic as an algebra. -/
theorem Subalgebra.isAlgebraic_iff (S : Subalgebra R A) :
    S.IsAlgebraic ↔ @Algebra.IsAlgebraic R S _ _ S.algebra := by
  delta Algebra.IsAlgebraic Subalgebra.IsAlgebraic
  rw [Subtype.forall']
  refine' forall_congr' fun x => exists_congr fun p => and_congr Iff.rfl _
  have h : Function.Injective S.val := Subtype.val_injective
  

Proof state:
R : Type u
A : Type v
inst✝² : CommRing R
inst✝¹ : Ring A
inst✝ : Algebra R A
S : Subalgebra R A
x : ↥S
p : R[X]
h : Function.Injective ⇑(val S)
⊢ (aeval ↑x) p = 0 ↔ (aeval x) p = 0

Next tactic:
conv_rhs => rw [← h.eq_iff, AlgHom.map_zero]
/-- A subalgebra is algebraic if and only if it is algebraic as an algebra. -/
theorem Subalgebra.isAlgebraic_iff (S : Subalgebra R A) :
    S.IsAlgebraic ↔ @Algebra.IsAlgebraic R S _ _ S.algebra := by
  delta Algebra.IsAlgebraic Subalgebra.IsAlgebraic
  rw [Subtype.forall']
  refine' forall_congr' fun x => exists_congr fun p => and_congr Iff.rfl _
  have h : Function.Injective S.val := Subtype.val_injective
  conv_rhs => 

Proof state:
R : Type u
A : Type v
inst✝² : CommRing R
inst✝¹ : Ring A
inst✝ : Algebra R A
S : Subalgebra R A
x : ↥S
p : R[X]
h : Function.Injective ⇑(val S)
| (aeval x) p = 0

Next tactic:
rw [← h.eq_iff, AlgHom.map_zero]
/-- A subalgebra is algebraic if and only if it is algebraic as an algebra. -/
theorem Subalgebra.isAlgebraic_iff (S : Subalgebra R A) :
    S.IsAlgebraic ↔ @Algebra.IsAlgebraic R S _ _ S.algebra := by
  delta Algebra.IsAlgebraic Subalgebra.IsAlgebraic
  rw [Subtype.forall']
  refine' forall_congr' fun x => exists_congr fun p => and_congr Iff.rfl _
  have h : Function.Injective S.val := Subtype.val_injective
  conv_rhs => rw [← h.eq_iff, AlgHom.map_zero]
  

Proof state:
R : Type u
A : Type v
inst✝² : CommRing R
inst✝¹ : Ring A
inst✝ : Algebra R A
S : Subalgebra R A
x : ↥S
p : R[X]
h : Function.Injective ⇑(val S)
⊢ (aeval ↑x) p = 0 ↔ (val S) ((aeval x) p) = 0

Next tactic:
rw [← aeval_algHom_apply, S.val_apply]
/-- An algebra is algebraic if and only if it is algebraic as a subalgebra. -/
theorem Algebra.isAlgebraic_iff : Algebra.IsAlgebraic R A ↔ (⊤ : Subalgebra R A).IsAlgebraic := by
  

Proof state:
R : Type u
A : Type v
inst✝² : CommRing R
inst✝¹ : Ring A
inst✝ : Algebra R A
⊢ IsAlgebraic R A ↔ Subalgebra.IsAlgebraic ⊤

Next tactic:
delta Algebra.IsAlgebraic Subalgebra.IsAlgebraic
/-- An algebra is algebraic if and only if it is algebraic as a subalgebra. -/
theorem Algebra.isAlgebraic_iff : Algebra.IsAlgebraic R A ↔ (⊤ : Subalgebra R A).IsAlgebraic := by
  delta Algebra.IsAlgebraic Subalgebra.IsAlgebraic
  

Proof state:
R : Type u
A : Type v
inst✝² : CommRing R
inst✝¹ : Ring A
inst✝ : Algebra R A
⊢ (∀ (x : A), _root_.IsAlgebraic R x) ↔ ∀ x ∈ ⊤, _root_.IsAlgebraic R x

Next tactic:
simp only [Algebra.mem_top, forall_prop_of_true, iff_self_iff]
theorem isAlgebraic_iff_not_injective {x : A} :
    IsAlgebraic R x ↔ ¬Function.Injective (Polynomial.aeval x : R[X] →ₐ[R] A) := by
  

Proof state:
R : Type u
A : Type v
inst✝² : CommRing R
inst✝¹ : Ring A
inst✝ : Algebra R A
x : A
⊢ IsAlgebraic R x ↔ ¬Function.Injective ⇑(aeval x)

Next tactic:
simp only [IsAlgebraic, injective_iff_map_eq_zero, not_forall, and_comm, exists_prop]
/-- An element of `R` is algebraic, when viewed as an element of the `R`-algebra `A`. -/
theorem isAlgebraic_algebraMap [Nontrivial R] (x : R) : IsAlgebraic R (algebraMap R A x) :=
  ⟨_, X_sub_C_ne_zero x, by 

Proof state:
R : Type u
S : Type u_1
A : Type v
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Ring A
inst✝⁴ : Algebra R A
inst✝³ : Algebra R S
inst✝² : Algebra S A
inst✝¹ : IsScalarTower R S A
inst✝ : Nontrivial R
x : R
⊢ (aeval ((algebraMap R A) x)) (X - C x) = 0

Next tactic:
rw [_root_.map_sub, aeval_X, aeval_C, sub_self]
theorem isAlgebraic_one [Nontrivial R] : IsAlgebraic R (1 : A) := by
  

Proof state:
R : Type u
S : Type u_1
A : Type v
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Ring A
inst✝⁴ : Algebra R A
inst✝³ : Algebra R S
inst✝² : Algebra S A
inst✝¹ : IsScalarTower R S A
inst✝ : Nontrivial R
⊢ IsAlgebraic R 1

Next tactic:
rw [← _root_.map_one (algebraMap R A)]
theorem isAlgebraic_one [Nontrivial R] : IsAlgebraic R (1 : A) := by
  rw [← _root_.map_one (algebraMap R A)]
  

Proof state:
R : Type u
S : Type u_1
A : Type v
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Ring A
inst✝⁴ : Algebra R A
inst✝³ : Algebra R S
inst✝² : Algebra S A
inst✝¹ : IsScalarTower R S A
inst✝ : Nontrivial R
⊢ IsAlgebraic R ((algebraMap R A) 1)

Next tactic:
exact isAlgebraic_algebraMap 1
theorem isAlgebraic_nat [Nontrivial R] (n : ℕ) : IsAlgebraic R (n : A) := by
  

Proof state:
R : Type u
S : Type u_1
A : Type v
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Ring A
inst✝⁴ : Algebra R A
inst✝³ : Algebra R S
inst✝² : Algebra S A
inst✝¹ : IsScalarTower R S A
inst✝ : Nontrivial R
n : ℕ
⊢ IsAlgebraic R ↑n

Next tactic:
rw [← map_natCast (_ : R →+* A) n]
theorem isAlgebraic_nat [Nontrivial R] (n : ℕ) : IsAlgebraic R (n : A) := by
  rw [← map_natCast (_ : R →+* A) n]
  

Proof state:
R : Type u
S : Type u_1
A : Type v
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Ring A
inst✝⁴ : Algebra R A
inst✝³ : Algebra R S
inst✝² : Algebra S A
inst✝¹ : IsScalarTower R S A
inst✝ : Nontrivial R
n : ℕ
⊢ IsAlgebraic R (?m.105672 ↑n)
R : Type u
S : Type u_1
A : Type v
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Ring A
inst✝⁴ : Algebra R A
inst✝³ : Algebra R S
inst✝² : Algebra S A
inst✝¹ : IsScalarTower R S A
inst✝ : Nontrivial R
n : ℕ
⊢ R →+* A

Next tactic:
exact isAlgebraic_algebraMap (Nat.cast n)
theorem isAlgebraic_int [Nontrivial R] (n : ℤ) : IsAlgebraic R (n : A) := by
  

Proof state:
R : Type u
S : Type u_1
A : Type v
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Ring A
inst✝⁴ : Algebra R A
inst✝³ : Algebra R S
inst✝² : Algebra S A
inst✝¹ : IsScalarTower R S A
inst✝ : Nontrivial R
n : ℤ
⊢ IsAlgebraic R ↑n

Next tactic:
rw [← _root_.map_intCast (algebraMap R A)]
theorem isAlgebraic_int [Nontrivial R] (n : ℤ) : IsAlgebraic R (n : A) := by
  rw [← _root_.map_intCast (algebraMap R A)]
  

Proof state:
R : Type u
S : Type u_1
A : Type v
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Ring A
inst✝⁴ : Algebra R A
inst✝³ : Algebra R S
inst✝² : Algebra S A
inst✝¹ : IsScalarTower R S A
inst✝ : Nontrivial R
n : ℤ
⊢ IsAlgebraic R ((algebraMap R A) ↑n)

Next tactic:
exact isAlgebraic_algebraMap (Int.cast n)
theorem isAlgebraic_rat (R : Type u) {A : Type v} [DivisionRing A] [Field R] [Algebra R A] (n : ℚ) :
    IsAlgebraic R (n : A) := by
  

Proof state:
R✝ : Type u
S : Type u_1
A✝ : Type v
inst✝⁹ : CommRing R✝
inst✝⁸ : CommRing S
inst✝⁷ : Ring A✝
inst✝⁶ : Algebra R✝ A✝
inst✝⁵ : Algebra R✝ S
inst✝⁴ : Algebra S A✝
inst✝³ : IsScalarTower R✝ S A✝
R : Type u
A : Type v
inst✝² : DivisionRing A
inst✝¹ : Field R
inst✝ : Algebra R A
n : ℚ
⊢ IsAlgebraic R ↑n

Next tactic:
rw [← map_ratCast (algebraMap R A)]
theorem isAlgebraic_rat (R : Type u) {A : Type v} [DivisionRing A] [Field R] [Algebra R A] (n : ℚ) :
    IsAlgebraic R (n : A) := by
  rw [← map_ratCast (algebraMap R A)]
  

Proof state:
R✝ : Type u
S : Type u_1
A✝ : Type v
inst✝⁹ : CommRing R✝
inst✝⁸ : CommRing S
inst✝⁷ : Ring A✝
inst✝⁶ : Algebra R✝ A✝
inst✝⁵ : Algebra R✝ S
inst✝⁴ : Algebra S A✝
inst✝³ : IsScalarTower R✝ S A✝
R : Type u
A : Type v
inst✝² : DivisionRing A
inst✝¹ : Field R
inst✝ : Algebra R A
n : ℚ
⊢ IsAlgebraic R ((algebraMap R A) ↑n)

Next tactic:
exact isAlgebraic_algebraMap (Rat.cast n)
protected theorem IsAlgebraic.algebraMap {a : S} :
    IsAlgebraic R a → IsAlgebraic R (algebraMap S A a) := fun ⟨f, hf₁, hf₂⟩ =>
  ⟨f, hf₁, by 

Proof state:
R : Type u
S : Type u_1
A : Type v
inst✝⁶ : CommRing R
inst✝⁵ : CommRing S
inst✝⁴ : Ring A
inst✝³ : Algebra R A
inst✝² : Algebra R S
inst✝¹ : Algebra S A
inst✝ : IsScalarTower R S A
a : S
x✝ : IsAlgebraic R a
f : R[X]
hf₁ : f ≠ 0
hf₂ : (aeval a) f = 0
⊢ (aeval ((algebraMap S A) a)) f = 0

Next tactic:
rw [aeval_algebraMap_apply, hf₂, map_zero]
/-- This is slightly more general than `IsAlgebraic.algebraMap` in that it
  allows noncommutative intermediate rings `A`. -/
protected theorem IsAlgebraic.algHom (f : A →ₐ[R] B) {a : A}
    (h : IsAlgebraic R a) : IsAlgebraic R (f a) :=
  let ⟨p, hp, ha⟩ := h
  ⟨p, hp, by 

Proof state:
R : Type u
S : Type u_1
A : Type v
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : Ring A
inst✝⁵ : Algebra R A
inst✝⁴ : Algebra R S
inst✝³ : Algebra S A
inst✝² : IsScalarTower R S A
B : Type u_2
inst✝¹ : Ring B
inst✝ : Algebra R B
f : A →ₐ[R] B
a : A
h : IsAlgebraic R a
p : R[X]
hp : p ≠ 0
ha : (aeval a) p = 0
⊢ (aeval (f a)) p = 0

Next tactic:
rw [aeval_algHom, f.comp_apply, ha, map_zero]
theorem isAlgebraic_algHom_iff (f : A →ₐ[R] B) (hf : Function.Injective f)
    {a : A} : IsAlgebraic R (f a) ↔ IsAlgebraic R a :=
  ⟨fun ⟨p, hp0, hp⟩ ↦ ⟨p, hp0, hf <| by 

Proof state:
R : Type u
S : Type u_1
A : Type v
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : Ring A
inst✝⁵ : Algebra R A
inst✝⁴ : Algebra R S
inst✝³ : Algebra S A
inst✝² : IsScalarTower R S A
B : Type u_2
inst✝¹ : Ring B
inst✝ : Algebra R B
f : A →ₐ[R] B
hf : Function.Injective ⇑f
a : A
x✝ : IsAlgebraic R (f a)
p : R[X]
hp0 : p ≠ 0
hp : (aeval (f a)) p = 0
⊢ f ((aeval a) p) = f 0

Next tactic:
rwa [map_zero, ← f.comp_apply, ← aeval_algHom]
theorem IsAlgebraic.of_pow {r : A} {n : ℕ} (hn : 0 < n) (ht : IsAlgebraic R (r ^ n)) :
    IsAlgebraic R r := by
  

Proof state:
R : Type u
S : Type u_1
A : Type v
inst✝⁶ : CommRing R
inst✝⁵ : CommRing S
inst✝⁴ : Ring A
inst✝³ : Algebra R A
inst✝² : Algebra R S
inst✝¹ : Algebra S A
inst✝ : IsScalarTower R S A
r : A
n : ℕ
hn : 0 < n
ht : IsAlgebraic R (r ^ n)
⊢ IsAlgebraic R r

Next tactic:
obtain ⟨p, p_nonzero, hp⟩ := ht
theorem IsAlgebraic.of_pow {r : A} {n : ℕ} (hn : 0 < n) (ht : IsAlgebraic R (r ^ n)) :
    IsAlgebraic R r := by
  obtain ⟨p, p_nonzero, hp⟩ := ht
  

Proof state:
case intro.intro
R : Type u
S : Type u_1
A : Type v
inst✝⁶ : CommRing R
inst✝⁵ : CommRing S
inst✝⁴ : Ring A
inst✝³ : Algebra R A
inst✝² : Algebra R S
inst✝¹ : Algebra S A
inst✝ : IsScalarTower R S A
r : A
n : ℕ
hn : 0 < n
p : R[X]
p_nonzero : p ≠ 0
hp : (aeval (r ^ n)) p = 0
⊢ IsAlgebraic R r

Next tactic:
refine ⟨Polynomial.expand _ n p, ?_, ?_⟩
theorem IsAlgebraic.of_pow {r : A} {n : ℕ} (hn : 0 < n) (ht : IsAlgebraic R (r ^ n)) :
    IsAlgebraic R r := by
  obtain ⟨p, p_nonzero, hp⟩ := ht
  refine ⟨Polynomial.expand _ n p, ?_, ?_⟩
  · 

Proof state:
case intro.intro.refine_1
R : Type u
S : Type u_1
A : Type v
inst✝⁶ : CommRing R
inst✝⁵ : CommRing S
inst✝⁴ : Ring A
inst✝³ : Algebra R A
inst✝² : Algebra R S
inst✝¹ : Algebra S A
inst✝ : IsScalarTower R S A
r : A
n : ℕ
hn : 0 < n
p : R[X]
p_nonzero : p ≠ 0
hp : (aeval (r ^ n)) p = 0
⊢ (expand R n) p ≠ 0

Next tactic:
rwa [Polynomial.expand_ne_zero hn]
theorem IsAlgebraic.of_pow {r : A} {n : ℕ} (hn : 0 < n) (ht : IsAlgebraic R (r ^ n)) :
    IsAlgebraic R r := by
  obtain ⟨p, p_nonzero, hp⟩ := ht
  refine ⟨Polynomial.expand _ n p, ?_, ?_⟩
  · rwa [Polynomial.expand_ne_zero hn]
  · 

Proof state:
case intro.intro.refine_2
R : Type u
S : Type u_1
A : Type v
inst✝⁶ : CommRing R
inst✝⁵ : CommRing S
inst✝⁴ : Ring A
inst✝³ : Algebra R A
inst✝² : Algebra R S
inst✝¹ : Algebra S A
inst✝ : IsScalarTower R S A
r : A
n : ℕ
hn : 0 < n
p : R[X]
p_nonzero : p ≠ 0
hp : (aeval (r ^ n)) p = 0
⊢ (aeval r) ((expand R n) p) = 0

Next tactic:
rwa [Polynomial.expand_aeval n p r]
lemma IsAlgebraic.invOf {x : S} [Invertible x] (h : IsAlgebraic R x) : IsAlgebraic R (⅟ x) := by
  

Proof state:
R : Type u
S : Type u_1
A : Type v
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Ring A
inst✝⁴ : Algebra R A
inst✝³ : Algebra R S
inst✝² : Algebra S A
inst✝¹ : IsScalarTower R S A
x : S
inst✝ : Invertible x
h : IsAlgebraic R x
⊢ IsAlgebraic R ⅟x

Next tactic:
obtain ⟨p, hp, hp'⟩ := h
lemma IsAlgebraic.invOf {x : S} [Invertible x] (h : IsAlgebraic R x) : IsAlgebraic R (⅟ x) := by
  obtain ⟨p, hp, hp'⟩ := h
  

Proof state:
case intro.intro
R : Type u
S : Type u_1
A : Type v
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Ring A
inst✝⁴ : Algebra R A
inst✝³ : Algebra R S
inst✝² : Algebra S A
inst✝¹ : IsScalarTower R S A
x : S
inst✝ : Invertible x
p : R[X]
hp : p ≠ 0
hp' : (aeval x) p = 0
⊢ IsAlgebraic R ⅟x

Next tactic:
refine ⟨p.reverse, by simpa using hp, ?_⟩