/-- If `B / S / R` is a tower of ring extensions where `S` is integral over `R`,
then `S` maps (uniquely) into an integral closure `B / A / R`. -/
noncomputable def lift : S →ₐ[R] A where
  toFun x := mk' A (algebraMap S B x) (IsIntegral.algebraMap (h x))
  map_one' := by simp only [RingHom.map_one, mk'_one]
  map_zero' := by simp only [RingHom.map_zero, mk'_zero]
  map_add' x y := by simp_rw [← mk'_add, RingHom.map_add]
  map_mul' x y := by simp_rw [← mk'_mul, RingHom.map_mul]
  commutes' x := by 

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
inst✝¹¹ : CommRing R
inst✝¹⁰ : CommRing A
inst✝⁹ : CommRing B
inst✝⁸ : Algebra R B
inst✝⁷ : Algebra A B
inst✝⁶ : IsIntegralClosure A R B
S : Type u_4
inst✝⁵ : CommRing S
inst✝⁴ : Algebra R S
inst✝³ : Algebra S B
inst✝² : IsScalarTower R S B
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
h : Algebra.IsIntegral R S
x : R
⊢ OneHom.toFun
      (↑↑{
            toMonoidHom :=
              {
                toOneHom :=
                  { toFun := fun x => mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                    map_one' := (_ : mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) },
                map_mul' :=
                  (_ :
                    ∀ (x y : S),
                      OneHom.toFun
                          { toFun := fun x => mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                            map_one' := (_ : mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) }
                          (x * y) =
                        OneHom.toFun
                            { toFun := fun x => mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                              map_one' := (_ : mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) }
                            x *
                          OneHom.toFun
                            { toFun := fun x => mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                              map_one' := (_ : mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) }
                            y) },
            map_zero' := (_ : mk' A ((algebraMap S B) 0) (_ : IsIntegral R ((algebraMap S B) 0)) = 0),
            map_add' :=
              (_ :
                ∀ (x y : S),
                  OneHom.toFun
                      (↑{
                          toOneHom :=
                            { toFun := fun x => mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                              map_one' :=
                                (_ : mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) },
                          map_mul' :=
                            (_ :
                              ∀ (x y : S),
                                OneHom.toFun
                                    {
                                      toFun := fun x =>
                                        mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                                      map_one' :=
                                        (_ : mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) }
                                    (x * y) =
                                  OneHom.toFun
                                      {
                                        toFun := fun x =>
                                          mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                                        map_one' :=
                                          (_ : mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) }
                                      x *
                                    OneHom.toFun
                                      {
                                        toFun := fun x =>
                                          mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                                        map_one' :=
                                          (_ : mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) }
                                      y) })
                      (x + y) =
                    OneHom.toFun
                        (↑{
                            toOneHom :=
                              { toFun := fun x => mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                                map_one' :=
                                  (_ : mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) },
                            map_mul' :=
                              (_ :
                                ∀ (x y : S),
                                  OneHom.toFun
                                      {
                                        toFun := fun x =>
                                          mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                                        map_one' :=
                                          (_ : mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) }
                                      (x * y) =
                                    OneHom.toFun
                                        {
                                          toFun := fun x =>
                                            mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                                          map_one' :=
                                            (_ :
                                              mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) }
                                        x *
                                      OneHom.toFun
                                        {
                                          toFun := fun x =>
                                            mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                                          map_one' :=
                                            (_ :
                                              mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) }
                                        y) })
                        x +
                      OneHom.toFun
                        (↑{
                            toOneHom :=
                              { toFun := fun x => mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                                map_one' :=
                                  (_ : mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) },
                            map_mul' :=
                              (_ :
                                ∀ (x y : S),
                                  OneHom.toFun
                                      {
                                        toFun := fun x =>
                                          mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                                        map_one' :=
                                          (_ : mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) }
                                      (x * y) =
                                    OneHom.toFun
                                        {
                                          toFun := fun x =>
                                            mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                                          map_one' :=
                                            (_ :
                                              mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) }
                                        x *
                                      OneHom.toFun
                                        {
                                          toFun := fun x =>
                                            mk' A ((algebraMap S B) x) (_ : IsIntegral R ((algebraMap S B) x)),
                                          map_one' :=
                                            (_ :
                                              mk' A ((algebraMap S B) 1) (_ : IsIntegral R ((algebraMap S B) 1)) = 1) }
                                        y) })
                        y) })
      ((algebraMap R S) x) =
    (algebraMap R A) x

Next tactic:
simp_rw [← IsScalarTower.algebraMap_apply, mk'_algebraMap]