l3lab/ntp-mathlib huggingface dataset:
/-- The separable degree equals the degree of any separable contraction, i.e., it is unique. -/
theorem IsSeparableContraction.degree_eq [hF : ExpChar F q] (g : F[X])
    (hg : IsSeparableContraction q f g) : g.natDegree = hf.degree := by
  cases hF
  · rcases hg with ⟨_, m, hm⟩
    rw [one_pow, expand_one] at hm
    rw [hf.eq_degree, hm]
  · rcases hg with ⟨hg, m, hm⟩
    let g' := Classical.choose hf
    

Proof state:
case prime.intro.intro
F : Type u_1
inst✝ : Field F
q : ℕ
f : F[X]
hf : HasSeparableContraction q f
g : F[X]
hprime✝ : Nat.Prime q
hchar✝ : CharP F q
hg : Separable g
m : ℕ
hm : (expand F (q ^ m)) g = f
g' : F[X] := choose hf
⊢ natDegree g = HasSeparableContraction.degree hf

Next tactic:
obtain ⟨hg', m', hm'⟩ := Classical.choose_spec hf
/-- The separable degree equals the degree of any separable contraction, i.e., it is unique. -/
theorem IsSeparableContraction.degree_eq [hF : ExpChar F q] (g : F[X])
    (hg : IsSeparableContraction q f g) : g.natDegree = hf.degree := by
  cases hF
  · rcases hg with ⟨_, m, hm⟩
    rw [one_pow, expand_one] at hm
    rw [hf.eq_degree, hm]
  · rcases hg with ⟨hg, m, hm⟩
    let g' := Classical.choose hf
    obtain ⟨hg', m', hm'⟩ := Classical.choose_spec hf
    

Proof state:
case prime.intro.intro.intro.intro
F : Type u_1
inst✝ : Field F
q : ℕ
f : F[X]
hf : HasSeparableContraction q f
g : F[X]
hprime✝ : Nat.Prime q
hchar✝ : CharP F q
hg : Separable g
m : ℕ
hm : (expand F (q ^ m)) g = f
g' : F[X] := choose hf
hg' : Separable (choose hf)
m' : ℕ
hm' : (expand F (q ^ m')) (choose hf) = f
⊢ natDegree g = HasSeparableContraction.degree hf

Next tactic:
haveI : Fact q.Prime := ⟨by assumption⟩
/-- The separable degree equals the degree of any separable contraction, i.e., it is unique. -/
theorem IsSeparableContraction.degree_eq [hF : ExpChar F q] (g : F[X])
    (hg : IsSeparableContraction q f g) : g.natDegree = hf.degree := by
  cases hF
  · rcases hg with ⟨_, m, hm⟩
    rw [one_pow, expand_one] at hm
    rw [hf.eq_degree, hm]
  · rcases hg with ⟨hg, m, hm⟩
    let g' := Classical.choose hf
    obtain ⟨hg', m', hm'⟩ := Classical.choose_spec hf
    haveI : Fact q.Prime := ⟨by 

Proof state:
F : Type u_1
inst✝ : Field F
q : ℕ
f : F[X]
hf : HasSeparableContraction q f
g : F[X]
hprime✝ : Nat.Prime q
hchar✝ : CharP F q
hg : Separable g
m : ℕ
hm : (expand F (q ^ m)) g = f
g' : F[X] := choose hf
hg' : Separable (choose hf)
m' : ℕ
hm' : (expand F (q ^ m')) (choose hf) = f
⊢ Nat.Prime q

Next tactic:
assumption
/-- The separable degree equals the degree of any separable contraction, i.e., it is unique. -/
theorem IsSeparableContraction.degree_eq [hF : ExpChar F q] (g : F[X])
    (hg : IsSeparableContraction q f g) : g.natDegree = hf.degree := by
  cases hF
  · rcases hg with ⟨_, m, hm⟩
    rw [one_pow, expand_one] at hm
    rw [hf.eq_degree, hm]
  · rcases hg with ⟨hg, m, hm⟩
    let g' := Classical.choose hf
    obtain ⟨hg', m', hm'⟩ := Classical.choose_spec hf
    haveI : Fact q.Prime := ⟨by assumption⟩
    

Proof state:
case prime.intro.intro.intro.intro
F : Type u_1
inst✝ : Field F
q : ℕ
f : F[X]
hf : HasSeparableContraction q f
g : F[X]
hprime✝ : Nat.Prime q
hchar✝ : CharP F q
hg : Separable g
m : ℕ
hm : (expand F (q ^ m)) g = f
g' : F[X] := choose hf
hg' : Separable (choose hf)
m' : ℕ
hm' : (expand F (q ^ m')) (choose hf) = f
this : Fact (Nat.Prime q)
⊢ natDegree g = HasSeparableContraction.degree hf

Next tactic:
refine contraction_degree_eq_or_insep q g g' m m' ?_ hg hg'
/-- The separable degree equals the degree of any separable contraction, i.e., it is unique. -/
theorem IsSeparableContraction.degree_eq [hF : ExpChar F q] (g : F[X])
    (hg : IsSeparableContraction q f g) : g.natDegree = hf.degree := by
  cases hF
  · rcases hg with ⟨_, m, hm⟩
    rw [one_pow, expand_one] at hm
    rw [hf.eq_degree, hm]
  · rcases hg with ⟨hg, m, hm⟩
    let g' := Classical.choose hf
    obtain ⟨hg', m', hm'⟩ := Classical.choose_spec hf
    haveI : Fact q.Prime := ⟨by assumption⟩
    refine contraction_degree_eq_or_insep q g g' m m' ?_ hg hg'
    

Proof state:
case prime.intro.intro.intro.intro
F : Type u_1
inst✝ : Field F
q : ℕ
f : F[X]
hf : HasSeparableContraction q f
g : F[X]
hprime✝ : Nat.Prime q
hchar✝ : CharP F q
hg : Separable g
m : ℕ
hm : (expand F (q ^ m)) g = f
g' : F[X] := choose hf
hg' : Separable (choose hf)
m' : ℕ
hm' : (expand F (q ^ m')) (choose hf) = f
this : Fact (Nat.Prime q)
⊢ (expand F (q ^ m)) g = (expand F (q ^ m')) g'

Next tactic:
rw [hm, hm']
protected theorem ContinuousLinearMap.hasStrictFDerivAt {x : E} : HasStrictFDerivAt e e x :=
  (isLittleO_zero _ _).congr_left fun x => by 

Proof state:
𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type u_4
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type u_5
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x✝¹ : E
s t : Set E
L L₁ L₂ : Filter E
x✝ : E
x : E × E
⊢ 0 = e x.1 - e x.2 - e (x.1 - x.2)

Next tactic:
simp only [e.map_sub, sub_self]
protected theorem ContinuousLinearMap.hasFDerivAtFilter : HasFDerivAtFilter e e x L :=
  .of_isLittleO <| (isLittleO_zero _ _).congr_left fun x => by 

Proof state:
𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type u_4
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type u_5
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x✝ : E
s t : Set E
L L₁ L₂ : Filter E
x : E
⊢ 0 = e x - e x✝ - e (x - x✝)

Next tactic:
simp only [e.map_sub, sub_self]
protected theorem ContinuousLinearMap.fderivWithin (hxs : UniqueDiffWithinAt 𝕜 s x) :
    fderivWithin 𝕜 e s x = e := by
  

Proof state:
𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type u_4
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type u_5
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
hxs : UniqueDiffWithinAt 𝕜 s x
⊢ fderivWithin 𝕜 (⇑e) s x = e

Next tactic:
rw [DifferentiableAt.fderivWithin e.differentiableAt hxs]
protected theorem ContinuousLinearMap.fderivWithin (hxs : UniqueDiffWithinAt 𝕜 s x) :
    fderivWithin 𝕜 e s x = e := by
  rw [DifferentiableAt.fderivWithin e.differentiableAt hxs]
  

Proof state:
𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type u_4
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type u_5
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
hxs : UniqueDiffWithinAt 𝕜 s x
⊢ fderiv 𝕜 (⇑e) x = e

Next tactic:
exact e.fderiv
theorem IsBoundedLinearMap.fderivWithin (h : IsBoundedLinearMap 𝕜 f)
    (hxs : UniqueDiffWithinAt 𝕜 s x) : fderivWithin 𝕜 f s x = h.toContinuousLinearMap := by
  

Proof state:
𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type u_4
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type u_5
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
h : IsBoundedLinearMap 𝕜 f
hxs : UniqueDiffWithinAt 𝕜 s x
⊢ _root_.fderivWithin 𝕜 f s x = toContinuousLinearMap h

Next tactic:
rw [DifferentiableAt.fderivWithin h.differentiableAt hxs]
theorem IsBoundedLinearMap.fderivWithin (h : IsBoundedLinearMap 𝕜 f)
    (hxs : UniqueDiffWithinAt 𝕜 s x) : fderivWithin 𝕜 f s x = h.toContinuousLinearMap := by
  rw [DifferentiableAt.fderivWithin h.differentiableAt hxs]
  

Proof state:
𝕜 : Type u_1
inst✝⁸ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁵ : NormedAddCommGroup F
inst✝⁴ : NormedSpace 𝕜 F
G : Type u_4
inst✝³ : NormedAddCommGroup G
inst✝² : NormedSpace 𝕜 G
G' : Type u_5
inst✝¹ : NormedAddCommGroup G'
inst✝ : NormedSpace 𝕜 G'
f f₀ f₁ g : E → F
f' f₀' f₁' g' e : E →L[𝕜] F
x : E
s t : Set E
L L₁ L₂ : Filter E
h : IsBoundedLinearMap 𝕜 f
hxs : UniqueDiffWithinAt 𝕜 s x
⊢ _root_.fderiv 𝕜 f x = toContinuousLinearMap h

Next tactic:
exact h.fderiv
theorem exists_list_of_mem_closure {a : R} (h : a ∈ closure s) :
    ∃ L : List (List R), (∀ l ∈ L, ∀ x ∈ l, x ∈ s ∨ x = (-1 : R)) ∧ (L.map List.prod).sum = a :=
  AddGroup.InClosure.recOn h
    fun {x} hx ↦ match x, Monoid.exists_list_of_mem_closure hx with
    | _, ⟨L, h1, rfl⟩ => ⟨[L], List.forall_mem_singleton.2 fun r hr ↦ Or.inl (h1 r hr), zero_add _⟩
    ⟨[], List.forall_mem_nil _, rfl⟩
    fun {b} _ ih ↦ match b, ih with
    | _, ⟨L1, h1, rfl⟩ =>
      ⟨L1.map (List.cons (-1)),
        fun L2 h2 ↦ match L2, List.mem_map.1 h2 with
        | _, ⟨L3, h3, rfl⟩ => List.forall_mem_cons.2 ⟨Or.inr rfl, h1 L3 h3⟩, by
        

Proof state:
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
a : R
h : a ∈ closure s
b : R
ih : ∃ L, (∀ l ∈ L, ∀ x ∈ l, x ∈ s ∨ x = -1) ∧ List.sum (List.map List.prod L) = b
L1 : List (List R)
h1 : ∀ l ∈ L1, ∀ x ∈ l, x ∈ s ∨ x = -1
x✝ : AddGroup.InClosure (Monoid.Closure s) (List.sum (List.map List.prod L1))
⊢ List.sum (List.map List.prod (List.map (List.cons (-1)) L1)) = -List.sum (List.map List.prod L1)

Next tactic:
simp only [List.map_map, (· ∘ ·), List.prod_cons, neg_one_mul]
theorem exists_list_of_mem_closure {a : R} (h : a ∈ closure s) :
    ∃ L : List (List R), (∀ l ∈ L, ∀ x ∈ l, x ∈ s ∨ x = (-1 : R)) ∧ (L.map List.prod).sum = a :=
  AddGroup.InClosure.recOn h
    fun {x} hx ↦ match x, Monoid.exists_list_of_mem_closure hx with
    | _, ⟨L, h1, rfl⟩ => ⟨[L], List.forall_mem_singleton.2 fun r hr ↦ Or.inl (h1 r hr), zero_add _⟩
    ⟨[], List.forall_mem_nil _, rfl⟩
    fun {b} _ ih ↦ match b, ih with
    | _, ⟨L1, h1, rfl⟩ =>
      ⟨L1.map (List.cons (-1)),
        fun L2 h2 ↦ match L2, List.mem_map.1 h2 with
        | _, ⟨L3, h3, rfl⟩ => List.forall_mem_cons.2 ⟨Or.inr rfl, h1 L3 h3⟩, by
        simp only [List.map_map, (· ∘ ·), List.prod_cons, neg_one_mul]
        

Proof state:
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
a : R
h : a ∈ closure s
b : R
ih : ∃ L, (∀ l ∈ L, ∀ x ∈ l, x ∈ s ∨ x = -1) ∧ List.sum (List.map List.prod L) = b
L1 : List (List R)
h1 : ∀ l ∈ L1, ∀ x ∈ l, x ∈ s ∨ x = -1
x✝ : AddGroup.InClosure (Monoid.Closure s) (List.sum (List.map List.prod L1))
⊢ List.sum (List.map (fun x => -List.prod x) L1) = -List.sum (List.map List.prod L1)

Next tactic:
refine' List.recOn L1 neg_zero.symm fun hd tl ih ↦ _
theorem exists_list_of_mem_closure {a : R} (h : a ∈ closure s) :
    ∃ L : List (List R), (∀ l ∈ L, ∀ x ∈ l, x ∈ s ∨ x = (-1 : R)) ∧ (L.map List.prod).sum = a :=
  AddGroup.InClosure.recOn h
    fun {x} hx ↦ match x, Monoid.exists_list_of_mem_closure hx with
    | _, ⟨L, h1, rfl⟩ => ⟨[L], List.forall_mem_singleton.2 fun r hr ↦ Or.inl (h1 r hr), zero_add _⟩
    ⟨[], List.forall_mem_nil _, rfl⟩
    fun {b} _ ih ↦ match b, ih with
    | _, ⟨L1, h1, rfl⟩ =>
      ⟨L1.map (List.cons (-1)),
        fun L2 h2 ↦ match L2, List.mem_map.1 h2 with
        | _, ⟨L3, h3, rfl⟩ => List.forall_mem_cons.2 ⟨Or.inr rfl, h1 L3 h3⟩, by
        simp only [List.map_map, (· ∘ ·), List.prod_cons, neg_one_mul]
        refine' List.recOn L1 neg_zero.symm fun hd tl ih ↦ _
        

Proof state:
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
a : R
h : a ∈ closure s
b : R
ih✝ : ∃ L, (∀ l ∈ L, ∀ x ∈ l, x ∈ s ∨ x = -1) ∧ List.sum (List.map List.prod L) = b
L1 : List (List R)
h1 : ∀ l ∈ L1, ∀ x ∈ l, x ∈ s ∨ x = -1
x✝ : AddGroup.InClosure (Monoid.Closure s) (List.sum (List.map List.prod L1))
hd : List R
tl : List (List R)
ih : List.sum (List.map (fun x => -List.prod x) tl) = -List.sum (List.map List.prod tl)
⊢ List.sum (List.map (fun x => -List.prod x) (hd :: tl)) = -List.sum (List.map List.prod (hd :: tl))

Next tactic:
rw [List.map_cons, List.sum_cons, ih, List.map_cons, List.sum_cons, neg_add]
theorem exists_list_of_mem_closure {a : R} (h : a ∈ closure s) :
    ∃ L : List (List R), (∀ l ∈ L, ∀ x ∈ l, x ∈ s ∨ x = (-1 : R)) ∧ (L.map List.prod).sum = a :=
  AddGroup.InClosure.recOn h
    fun {x} hx ↦ match x, Monoid.exists_list_of_mem_closure hx with
    | _, ⟨L, h1, rfl⟩ => ⟨[L], List.forall_mem_singleton.2 fun r hr ↦ Or.inl (h1 r hr), zero_add _⟩
    ⟨[], List.forall_mem_nil _, rfl⟩
    fun {b} _ ih ↦ match b, ih with
    | _, ⟨L1, h1, rfl⟩ =>
      ⟨L1.map (List.cons (-1)),
        fun L2 h2 ↦ match L2, List.mem_map.1 h2 with
        | _, ⟨L3, h3, rfl⟩ => List.forall_mem_cons.2 ⟨Or.inr rfl, h1 L3 h3⟩, by
        simp only [List.map_map, (· ∘ ·), List.prod_cons, neg_one_mul]
        refine' List.recOn L1 neg_zero.symm fun hd tl ih ↦ _
        rw [List.map_cons, List.sum_cons, ih, List.map_cons, List.sum_cons, neg_add]⟩
    fun {r1 r2} _ _ ih1 ih2 ↦ match r1, r2, ih1, ih2 with
    | _, _, ⟨L1, h1, rfl⟩, ⟨L2, h2, rfl⟩ =>
      ⟨L1 ++ L2, List.forall_mem_append.2 ⟨h1, h2⟩, by 

Proof state:
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
a : R
h : a ∈ closure s
r1 r2 : R
ih1 : ∃ L, (∀ l ∈ L, ∀ x ∈ l, x ∈ s ∨ x = -1) ∧ List.sum (List.map List.prod L) = r1
ih2 : ∃ L, (∀ l ∈ L, ∀ x ∈ l, x ∈ s ∨ x = -1) ∧ List.sum (List.map List.prod L) = r2
L1 : List (List R)
h1 : ∀ l ∈ L1, ∀ x ∈ l, x ∈ s ∨ x = -1
L2 : List (List R)
h2 : ∀ l ∈ L2, ∀ x ∈ l, x ∈ s ∨ x = -1
x✝¹ : AddGroup.InClosure (Monoid.Closure s) (List.sum (List.map List.prod L1))
x✝ : AddGroup.InClosure (Monoid.Closure s) (List.sum (List.map List.prod L2))
⊢ List.sum (List.map List.prod (L1 ++ L2)) = List.sum (List.map List.prod L1) + List.sum (List.map List.prod L2)

Next tactic:
rw [List.map_append, List.sum_append]
@[elab_as_elim]
protected theorem InClosure.recOn {C : R → Prop} {x : R} (hx : x ∈ closure s) (h1 : C 1)
    (hneg1 : C (-1)) (hs : ∀ z ∈ s, ∀ n, C n → C (z * n)) (ha : ∀ {x y}, C x → C y → C (x + y)) :
    C x := by
  

Proof state:
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
C : R → Prop
x : R
hx : x ∈ closure s
h1 : C 1
hneg1 : C (-1)
hs : ∀ z ∈ s, ∀ (n : R), C n → C (z * n)
ha : ∀ {x y : R}, C x → C y → C (x + y)
⊢ C x

Next tactic:
have h0 : C 0 := add_neg_self (1 : R) ▸ ha h1 hneg1
@[elab_as_elim]
protected theorem InClosure.recOn {C : R → Prop} {x : R} (hx : x ∈ closure s) (h1 : C 1)
    (hneg1 : C (-1)) (hs : ∀ z ∈ s, ∀ n, C n → C (z * n)) (ha : ∀ {x y}, C x → C y → C (x + y)) :
    C x := by
  have h0 : C 0 := add_neg_self (1 : R) ▸ ha h1 hneg1
  

Proof state:
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
C : R → Prop
x : R
hx : x ∈ closure s
h1 : C 1
hneg1 : C (-1)
hs : ∀ z ∈ s, ∀ (n : R), C n → C (z * n)
ha : ∀ {x y : R}, C x → C y → C (x + y)
h0 : C 0
⊢ C x

Next tactic:
rcases exists_list_of_mem_closure hx with ⟨L, HL, rfl⟩
@[elab_as_elim]
protected theorem InClosure.recOn {C : R → Prop} {x : R} (hx : x ∈ closure s) (h1 : C 1)
    (hneg1 : C (-1)) (hs : ∀ z ∈ s, ∀ n, C n → C (z * n)) (ha : ∀ {x y}, C x → C y → C (x + y)) :
    C x := by
  have h0 : C 0 := add_neg_self (1 : R) ▸ ha h1 hneg1
  rcases exists_list_of_mem_closure hx with ⟨L, HL, rfl⟩
  

Proof state:
case intro.intro
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
C : R → Prop
h1 : C 1
hneg1 : C (-1)
hs : ∀ z ∈ s, ∀ (n : R), C n → C (z * n)
ha : ∀ {x y : R}, C x → C y → C (x + y)
h0 : C 0
L : List (List R)
HL : ∀ l ∈ L, ∀ x ∈ l, x ∈ s ∨ x = -1
hx : List.sum (List.map List.prod L) ∈ closure s
⊢ C (List.sum (List.map List.prod L))

Next tactic:
clear hx
@[elab_as_elim]
protected theorem InClosure.recOn {C : R → Prop} {x : R} (hx : x ∈ closure s) (h1 : C 1)
    (hneg1 : C (-1)) (hs : ∀ z ∈ s, ∀ n, C n → C (z * n)) (ha : ∀ {x y}, C x → C y → C (x + y)) :
    C x := by
  have h0 : C 0 := add_neg_self (1 : R) ▸ ha h1 hneg1
  rcases exists_list_of_mem_closure hx with ⟨L, HL, rfl⟩
  clear hx
  

Proof state:
case intro.intro
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
C : R → Prop
h1 : C 1
hneg1 : C (-1)
hs : ∀ z ∈ s, ∀ (n : R), C n → C (z * n)
ha : ∀ {x y : R}, C x → C y → C (x + y)
h0 : C 0
L : List (List R)
HL : ∀ l ∈ L, ∀ x ∈ l, x ∈ s ∨ x = -1
⊢ C (List.sum (List.map List.prod L))

Next tactic:
induction' L with hd tl ih
@[elab_as_elim]
protected theorem InClosure.recOn {C : R → Prop} {x : R} (hx : x ∈ closure s) (h1 : C 1)
    (hneg1 : C (-1)) (hs : ∀ z ∈ s, ∀ n, C n → C (z * n)) (ha : ∀ {x y}, C x → C y → C (x + y)) :
    C x := by
  have h0 : C 0 := add_neg_self (1 : R) ▸ ha h1 hneg1
  rcases exists_list_of_mem_closure hx with ⟨L, HL, rfl⟩
  clear hx
  induction' L with hd tl ih
  · 

Proof state:
case intro.intro.nil
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
C : R → Prop
h1 : C 1
hneg1 : C (-1)
hs : ∀ z ∈ s, ∀ (n : R), C n → C (z * n)
ha : ∀ {x y : R}, C x → C y → C (x + y)
h0 : C 0
HL : ∀ l ∈ [], ∀ x ∈ l, x ∈ s ∨ x = -1
⊢ C (List.sum (List.map List.prod []))

Next tactic:
exact h0
@[elab_as_elim]
protected theorem InClosure.recOn {C : R → Prop} {x : R} (hx : x ∈ closure s) (h1 : C 1)
    (hneg1 : C (-1)) (hs : ∀ z ∈ s, ∀ n, C n → C (z * n)) (ha : ∀ {x y}, C x → C y → C (x + y)) :
    C x := by
  have h0 : C 0 := add_neg_self (1 : R) ▸ ha h1 hneg1
  rcases exists_list_of_mem_closure hx with ⟨L, HL, rfl⟩
  clear hx
  induction' L with hd tl ih
  · exact h0
  

Proof state:
case intro.intro.cons
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
C : R → Prop
h1 : C 1
hneg1 : C (-1)
hs : ∀ z ∈ s, ∀ (n : R), C n → C (z * n)
ha : ∀ {x y : R}, C x → C y → C (x + y)
h0 : C 0
hd : List R
tl : List (List R)
ih : (∀ l ∈ tl, ∀ x ∈ l, x ∈ s ∨ x = -1) → C (List.sum (List.map List.prod tl))
HL : ∀ l ∈ hd :: tl, ∀ x ∈ l, x ∈ s ∨ x = -1
⊢ C (List.sum (List.map List.prod (hd :: tl)))

Next tactic:
rw [List.forall_mem_cons] at HL
@[elab_as_elim]
protected theorem InClosure.recOn {C : R → Prop} {x : R} (hx : x ∈ closure s) (h1 : C 1)
    (hneg1 : C (-1)) (hs : ∀ z ∈ s, ∀ n, C n → C (z * n)) (ha : ∀ {x y}, C x → C y → C (x + y)) :
    C x := by
  have h0 : C 0 := add_neg_self (1 : R) ▸ ha h1 hneg1
  rcases exists_list_of_mem_closure hx with ⟨L, HL, rfl⟩
  clear hx
  induction' L with hd tl ih
  · exact h0
  rw [List.forall_mem_cons] at HL
  

Proof state:
case intro.intro.cons
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
C : R → Prop
h1 : C 1
hneg1 : C (-1)
hs : ∀ z ∈ s, ∀ (n : R), C n → C (z * n)
ha : ∀ {x y : R}, C x → C y → C (x + y)
h0 : C 0
hd : List R
tl : List (List R)
ih : (∀ l ∈ tl, ∀ x ∈ l, x ∈ s ∨ x = -1) → C (List.sum (List.map List.prod tl))
HL : (∀ x ∈ hd, x ∈ s ∨ x = -1) ∧ ∀ x ∈ tl, ∀ x_1 ∈ x, x_1 ∈ s ∨ x_1 = -1
⊢ C (List.sum (List.map List.prod (hd :: tl)))

Next tactic:
suffices C (List.prod hd) by
    rw [List.map_cons, List.sum_cons]
    exact ha this (ih HL.2)
@[elab_as_elim]
protected theorem InClosure.recOn {C : R → Prop} {x : R} (hx : x ∈ closure s) (h1 : C 1)
    (hneg1 : C (-1)) (hs : ∀ z ∈ s, ∀ n, C n → C (z * n)) (ha : ∀ {x y}, C x → C y → C (x + y)) :
    C x := by
  have h0 : C 0 := add_neg_self (1 : R) ▸ ha h1 hneg1
  rcases exists_list_of_mem_closure hx with ⟨L, HL, rfl⟩
  clear hx
  induction' L with hd tl ih
  · exact h0
  rw [List.forall_mem_cons] at HL
  suffices C (List.prod hd) by
    

Proof state:
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
C : R → Prop
h1 : C 1
hneg1 : C (-1)
hs : ∀ z ∈ s, ∀ (n : R), C n → C (z * n)
ha : ∀ {x y : R}, C x → C y → C (x + y)
h0 : C 0
hd : List R
tl : List (List R)
ih : (∀ l ∈ tl, ∀ x ∈ l, x ∈ s ∨ x = -1) → C (List.sum (List.map List.prod tl))
HL : (∀ x ∈ hd, x ∈ s ∨ x = -1) ∧ ∀ x ∈ tl, ∀ x_1 ∈ x, x_1 ∈ s ∨ x_1 = -1
this : C (List.prod hd)
⊢ C (List.sum (List.map List.prod (hd :: tl)))

Next tactic:
rw [List.map_cons, List.sum_cons]
@[elab_as_elim]
protected theorem InClosure.recOn {C : R → Prop} {x : R} (hx : x ∈ closure s) (h1 : C 1)
    (hneg1 : C (-1)) (hs : ∀ z ∈ s, ∀ n, C n → C (z * n)) (ha : ∀ {x y}, C x → C y → C (x + y)) :
    C x := by
  have h0 : C 0 := add_neg_self (1 : R) ▸ ha h1 hneg1
  rcases exists_list_of_mem_closure hx with ⟨L, HL, rfl⟩
  clear hx
  induction' L with hd tl ih
  · exact h0
  rw [List.forall_mem_cons] at HL
  suffices C (List.prod hd) by
    rw [List.map_cons, List.sum_cons]
    

Proof state:
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
C : R → Prop
h1 : C 1
hneg1 : C (-1)
hs : ∀ z ∈ s, ∀ (n : R), C n → C (z * n)
ha : ∀ {x y : R}, C x → C y → C (x + y)
h0 : C 0
hd : List R
tl : List (List R)
ih : (∀ l ∈ tl, ∀ x ∈ l, x ∈ s ∨ x = -1) → C (List.sum (List.map List.prod tl))
HL : (∀ x ∈ hd, x ∈ s ∨ x = -1) ∧ ∀ x ∈ tl, ∀ x_1 ∈ x, x_1 ∈ s ∨ x_1 = -1
this : C (List.prod hd)
⊢ C (List.prod hd + List.sum (List.map List.prod tl))

Next tactic:
exact ha this (ih HL.2)
@[elab_as_elim]
protected theorem InClosure.recOn {C : R → Prop} {x : R} (hx : x ∈ closure s) (h1 : C 1)
    (hneg1 : C (-1)) (hs : ∀ z ∈ s, ∀ n, C n → C (z * n)) (ha : ∀ {x y}, C x → C y → C (x + y)) :
    C x := by
  have h0 : C 0 := add_neg_self (1 : R) ▸ ha h1 hneg1
  rcases exists_list_of_mem_closure hx with ⟨L, HL, rfl⟩
  clear hx
  induction' L with hd tl ih
  · exact h0
  rw [List.forall_mem_cons] at HL
  suffices C (List.prod hd) by
    rw [List.map_cons, List.sum_cons]
    exact ha this (ih HL.2)
  

Proof state:
case intro.intro.cons
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
C : R → Prop
h1 : C 1
hneg1 : C (-1)
hs : ∀ z ∈ s, ∀ (n : R), C n → C (z * n)
ha : ∀ {x y : R}, C x → C y → C (x + y)
h0 : C 0
hd : List R
tl : List (List R)
ih : (∀ l ∈ tl, ∀ x ∈ l, x ∈ s ∨ x = -1) → C (List.sum (List.map List.prod tl))
HL : (∀ x ∈ hd, x ∈ s ∨ x = -1) ∧ ∀ x ∈ tl, ∀ x_1 ∈ x, x_1 ∈ s ∨ x_1 = -1
⊢ C (List.prod hd)

Next tactic:
replace HL := HL.1
@[elab_as_elim]
protected theorem InClosure.recOn {C : R → Prop} {x : R} (hx : x ∈ closure s) (h1 : C 1)
    (hneg1 : C (-1)) (hs : ∀ z ∈ s, ∀ n, C n → C (z * n)) (ha : ∀ {x y}, C x → C y → C (x + y)) :
    C x := by
  have h0 : C 0 := add_neg_self (1 : R) ▸ ha h1 hneg1
  rcases exists_list_of_mem_closure hx with ⟨L, HL, rfl⟩
  clear hx
  induction' L with hd tl ih
  · exact h0
  rw [List.forall_mem_cons] at HL
  suffices C (List.prod hd) by
    rw [List.map_cons, List.sum_cons]
    exact ha this (ih HL.2)
  replace HL := HL.1
  

Proof state:
case intro.intro.cons
R : Type u
inst✝¹ : Ring R
cR : Type u
inst✝ : CommRing cR
s : Set R
C : R → Prop
h1 : C 1
hneg1 : C (-1)
hs : ∀ z ∈ s, ∀ (n : R), C n → C (z * n)
ha : ∀ {x y : R}, C x → C y → C (x + y)
h0 : C 0
hd : List R
tl : List (List R)
ih : (∀ l ∈ tl, ∀ x ∈ l, x ∈ s ∨ x = -1) → C (List.sum (List.map List.prod tl))
HL : ∀ x ∈ hd, x ∈ s ∨ x = -1
⊢ C (List.prod hd)

Next tactic:
clear ih tl