Theorem: AddMonoidAlgebra.freeAlgebra_lift_of_surjective_of_closure
File: Mathlib/RingTheory/FiniteType.lean

tactic: intro f
state_before: R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
⊢ Surjective ⇑((FreeAlgebra.lift R) fun s => of' R M ↑s)
state_after: R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
f : R[M]
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = f

tactic: induction' f using induction_on with m f g ihf ihg r f ih
state_before: R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
f : R[M]
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = f
state_after: case hM
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m : M
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd m)

case hadd
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
f g : R[M]
ihf : ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = f
ihg : ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = g
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = f + g

case hsmul
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
r : R
f : R[M]
ih : ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = f
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = r • f

tactic: have : m ∈ closure S := hS.symm ▸ mem_top _
state_before: case hM
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m : M
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd m)
state_after: case hM
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m : M
this : m ∈ closure S
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd m)

tactic: refine AddSubmonoid.closure_induction this (fun m hm => ?_) ?_ ?_
state_before: case hM
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m : M
this : m ∈ closure S
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd m)
state_after: case hM.refine_1
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m✝ : M
this : m✝ ∈ closure S
m : M
hm : m ∈ S
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd m)

case hM.refine_2
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m : M
this : m ∈ closure S
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd 0)

case hM.refine_3
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m : M
this : m ∈ closure S
⊢ ∀ (x y : M),
    (∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd x)) →
      (∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd y)) →
        ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd (x + y))

tactic: exact ⟨FreeAlgebra.ι R ⟨m, hm⟩, FreeAlgebra.lift_ι_apply _ _⟩
state_before: case hM.refine_1
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m✝ : M
this : m✝ ∈ closure S
m : M
hm : m ∈ S
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd m)
state_after: no goals

tactic: exact ⟨1, AlgHom.map_one _⟩
state_before: case hM.refine_2
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m : M
this : m ∈ closure S
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd 0)
state_after: no goals

tactic: rintro m₁ m₂ ⟨P₁, hP₁⟩ ⟨P₂, hP₂⟩
state_before: case hM.refine_3
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m : M
this : m ∈ closure S
⊢ ∀ (x y : M),
    (∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd x)) →
      (∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd y)) →
        ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd (x + y))
state_after: case hM.refine_3.intro.intro
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m : M
this : m ∈ closure S
m₁ m₂ : M
P₁ : FreeAlgebra R ↑S
hP₁ : ((FreeAlgebra.lift R) fun s => of' R M ↑s) P₁ = (of R M) (Multiplicative.ofAdd m₁)
P₂ : FreeAlgebra R ↑S
hP₂ : ((FreeAlgebra.lift R) fun s => of' R M ↑s) P₂ = (of R M) (Multiplicative.ofAdd m₂)
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd (m₁ + m₂))

tactic: exact
  ⟨P₁ * P₂, by
    rw [AlgHom.map_mul, hP₁, hP₂, of_apply, of_apply, of_apply, single_mul_single,
      one_mul]; rfl⟩
state_before: case hM.refine_3.intro.intro
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m : M
this : m ∈ closure S
m₁ m₂ : M
P₁ : FreeAlgebra R ↑S
hP₁ : ((FreeAlgebra.lift R) fun s => of' R M ↑s) P₁ = (of R M) (Multiplicative.ofAdd m₁)
P₂ : FreeAlgebra R ↑S
hP₂ : ((FreeAlgebra.lift R) fun s => of' R M ↑s) P₂ = (of R M) (Multiplicative.ofAdd m₂)
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = (of R M) (Multiplicative.ofAdd (m₁ + m₂))
state_after: no goals

tactic: rw [AlgHom.map_mul, hP₁, hP₂, of_apply, of_apply, of_apply, single_mul_single,
  one_mul]
state_before: R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m : M
this : m ∈ closure S
m₁ m₂ : M
P₁ : FreeAlgebra R ↑S
hP₁ : ((FreeAlgebra.lift R) fun s => of' R M ↑s) P₁ = (of R M) (Multiplicative.ofAdd m₁)
P₂ : FreeAlgebra R ↑S
hP₂ : ((FreeAlgebra.lift R) fun s => of' R M ↑s) P₂ = (of R M) (Multiplicative.ofAdd m₂)
⊢ ((FreeAlgebra.lift R) fun s => of' R M ↑s) (P₁ * P₂) = (of R M) (Multiplicative.ofAdd (m₁ + m₂))
state_after: R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m : M
this : m ∈ closure S
m₁ m₂ : M
P₁ : FreeAlgebra R ↑S
hP₁ : ((FreeAlgebra.lift R) fun s => of' R M ↑s) P₁ = (of R M) (Multiplicative.ofAdd m₁)
P₂ : FreeAlgebra R ↑S
hP₂ : ((FreeAlgebra.lift R) fun s => of' R M ↑s) P₂ = (of R M) (Multiplicative.ofAdd m₂)
⊢ single (Multiplicative.toAdd (Multiplicative.ofAdd m₁) + Multiplicative.toAdd (Multiplicative.ofAdd m₂)) 1 =
    single (Multiplicative.toAdd (Multiplicative.ofAdd (m₁ + m₂))) 1

tactic: rfl
state_before: R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
m : M
this : m ∈ closure S
m₁ m₂ : M
P₁ : FreeAlgebra R ↑S
hP₁ : ((FreeAlgebra.lift R) fun s => of' R M ↑s) P₁ = (of R M) (Multiplicative.ofAdd m₁)
P₂ : FreeAlgebra R ↑S
hP₂ : ((FreeAlgebra.lift R) fun s => of' R M ↑s) P₂ = (of R M) (Multiplicative.ofAdd m₂)
⊢ single (Multiplicative.toAdd (Multiplicative.ofAdd m₁) + Multiplicative.toAdd (Multiplicative.ofAdd m₂)) 1 =
    single (Multiplicative.toAdd (Multiplicative.ofAdd (m₁ + m₂))) 1
state_after: no goals

tactic: rcases ihf with ⟨P, rfl⟩
state_before: case hadd
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
f g : R[M]
ihf : ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = f
ihg : ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = g
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = f + g
state_after: case hadd.intro
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
g : R[M]
ihg : ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = g
P : FreeAlgebra R ↑S
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = ((FreeAlgebra.lift R) fun s => of' R M ↑s) P + g

tactic: rcases ihg with ⟨Q, rfl⟩
state_before: case hadd.intro
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
g : R[M]
ihg : ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = g
P : FreeAlgebra R ↑S
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = ((FreeAlgebra.lift R) fun s => of' R M ↑s) P + g
state_after: case hadd.intro.intro
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
P Q : FreeAlgebra R ↑S
⊢ ∃ a,
    ((FreeAlgebra.lift R) fun s => of' R M ↑s) a =
      ((FreeAlgebra.lift R) fun s => of' R M ↑s) P + ((FreeAlgebra.lift R) fun s => of' R M ↑s) Q

tactic: exact ⟨P + Q, AlgHom.map_add _ _ _⟩
state_before: case hadd.intro.intro
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
P Q : FreeAlgebra R ↑S
⊢ ∃ a,
    ((FreeAlgebra.lift R) fun s => of' R M ↑s) a =
      ((FreeAlgebra.lift R) fun s => of' R M ↑s) P + ((FreeAlgebra.lift R) fun s => of' R M ↑s) Q
state_after: no goals

tactic: rcases ih with ⟨P, rfl⟩
state_before: case hsmul
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
r : R
f : R[M]
ih : ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = f
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = r • f
state_after: case hsmul.intro
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
r : R
P : FreeAlgebra R ↑S
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = r • ((FreeAlgebra.lift R) fun s => of' R M ↑s) P

tactic: exact ⟨r • P, AlgHom.map_smul _ _ _⟩
state_before: case hsmul.intro
R : Type u_1
M : Type u_2
inst✝¹ : AddMonoid M
inst✝ : CommSemiring R
S : Set M
hS : closure S = ⊤
r : R
P : FreeAlgebra R ↑S
⊢ ∃ a, ((FreeAlgebra.lift R) fun s => of' R M ↑s) a = r • ((FreeAlgebra.lift R) fun s => of' R M ↑s) P
state_after: no goals