l3lab/ntp-mathlib huggingface dataset:
/-- The linear map `M ⊔ ⟨y⟩ ⟶ Q` by `x + r • y ↦ f x + φ r` is an extension of `f`-/
def extensionOfMaxAdjoin (h : Module.Baer R Q) (y : N) : ExtensionOf i f where
  domain := supExtensionOfMaxSingleton i f y -- (extensionOfMax i f).domain ⊔ Submodule.span R {y}
  le := le_trans (extensionOfMax i f).le le_sup_left
  toFun :=
    { toFun := ExtensionOfMaxAdjoin.extensionToFun i f h
      map_add' := fun a b => by
        have eq1 :
          ↑a + ↑b =
            ↑(ExtensionOfMaxAdjoin.fst i a + ExtensionOfMaxAdjoin.fst i b) +
              (ExtensionOfMaxAdjoin.snd i a + ExtensionOfMaxAdjoin.snd i b) • y := by
          rw [ExtensionOfMaxAdjoin.eqn, ExtensionOfMaxAdjoin.eqn, add_smul, Submodule.coe_add]
          ac_rfl
        rw [ExtensionOfMaxAdjoin.extensionToFun_wd (y := y) i f h (a + b) _ _ eq1,
          LinearPMap.map_add, map_add]
        unfold ExtensionOfMaxAdjoin.extensionToFun
        abel
      map_smul' := fun r a => by
        dsimp
        have eq1 :
          r • (a : N) =
            ↑(r • ExtensionOfMaxAdjoin.fst i a) + (r • ExtensionOfMaxAdjoin.snd i a) • y := by
          rw [ExtensionOfMaxAdjoin.eqn, smul_add, smul_eq_mul, mul_smul]
          rfl
        rw [ExtensionOfMaxAdjoin.extensionToFun_wd i f h (r • a :) _ _ eq1, LinearMap.map_smul,
          LinearPMap.map_smul, ← smul_add]
        

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
h : Baer R Q
y : N
r : R
a : ↥(supExtensionOfMaxSingleton i f y)
eq1 : r • ↑a = ↑(r • ExtensionOfMaxAdjoin.fst i a) + (r • ExtensionOfMaxAdjoin.snd i a) • y
⊢ r •
      (↑(extensionOfMax i f).toLinearPMap (ExtensionOfMaxAdjoin.fst i a) +
        (ExtensionOfMaxAdjoin.extendIdealTo i f h y) (ExtensionOfMaxAdjoin.snd i a)) =
    r • ExtensionOfMaxAdjoin.extensionToFun i f h a

Next tactic:
congr
/-- The linear map `M ⊔ ⟨y⟩ ⟶ Q` by `x + r • y ↦ f x + φ r` is an extension of `f`-/
def extensionOfMaxAdjoin (h : Module.Baer R Q) (y : N) : ExtensionOf i f where
  domain := supExtensionOfMaxSingleton i f y -- (extensionOfMax i f).domain ⊔ Submodule.span R {y}
  le := le_trans (extensionOfMax i f).le le_sup_left
  toFun :=
    { toFun := ExtensionOfMaxAdjoin.extensionToFun i f h
      map_add' := fun a b => by
        have eq1 :
          ↑a + ↑b =
            ↑(ExtensionOfMaxAdjoin.fst i a + ExtensionOfMaxAdjoin.fst i b) +
              (ExtensionOfMaxAdjoin.snd i a + ExtensionOfMaxAdjoin.snd i b) • y := by
          rw [ExtensionOfMaxAdjoin.eqn, ExtensionOfMaxAdjoin.eqn, add_smul, Submodule.coe_add]
          ac_rfl
        rw [ExtensionOfMaxAdjoin.extensionToFun_wd (y := y) i f h (a + b) _ _ eq1,
          LinearPMap.map_add, map_add]
        unfold ExtensionOfMaxAdjoin.extensionToFun
        abel
      map_smul' := fun r a => by
        dsimp
        have eq1 :
          r • (a : N) =
            ↑(r • ExtensionOfMaxAdjoin.fst i a) + (r • ExtensionOfMaxAdjoin.snd i a) • y := by
          rw [ExtensionOfMaxAdjoin.eqn, smul_add, smul_eq_mul, mul_smul]
          rfl
        rw [ExtensionOfMaxAdjoin.extensionToFun_wd i f h (r • a :) _ _ eq1, LinearMap.map_smul,
          LinearPMap.map_smul, ← smul_add]
        congr }
  is_extension m := by
    dsimp
    

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
h : Baer R Q
y : N
m : M
⊢ f m =
    ExtensionOfMaxAdjoin.extensionToFun i f h { val := i m, property := (_ : i m ∈ supExtensionOfMaxSingleton i f y) }

Next tactic:
rw [(extensionOfMax i f).is_extension,
      ExtensionOfMaxAdjoin.extensionToFun_wd i f h _ ⟨i m, _⟩ 0 _, map_zero, add_zero]
/-- The linear map `M ⊔ ⟨y⟩ ⟶ Q` by `x + r • y ↦ f x + φ r` is an extension of `f`-/
def extensionOfMaxAdjoin (h : Module.Baer R Q) (y : N) : ExtensionOf i f where
  domain := supExtensionOfMaxSingleton i f y -- (extensionOfMax i f).domain ⊔ Submodule.span R {y}
  le := le_trans (extensionOfMax i f).le le_sup_left
  toFun :=
    { toFun := ExtensionOfMaxAdjoin.extensionToFun i f h
      map_add' := fun a b => by
        have eq1 :
          ↑a + ↑b =
            ↑(ExtensionOfMaxAdjoin.fst i a + ExtensionOfMaxAdjoin.fst i b) +
              (ExtensionOfMaxAdjoin.snd i a + ExtensionOfMaxAdjoin.snd i b) • y := by
          rw [ExtensionOfMaxAdjoin.eqn, ExtensionOfMaxAdjoin.eqn, add_smul, Submodule.coe_add]
          ac_rfl
        rw [ExtensionOfMaxAdjoin.extensionToFun_wd (y := y) i f h (a + b) _ _ eq1,
          LinearPMap.map_add, map_add]
        unfold ExtensionOfMaxAdjoin.extensionToFun
        abel
      map_smul' := fun r a => by
        dsimp
        have eq1 :
          r • (a : N) =
            ↑(r • ExtensionOfMaxAdjoin.fst i a) + (r • ExtensionOfMaxAdjoin.snd i a) • y := by
          rw [ExtensionOfMaxAdjoin.eqn, smul_add, smul_eq_mul, mul_smul]
          rfl
        rw [ExtensionOfMaxAdjoin.extensionToFun_wd i f h (r • a :) _ _ eq1, LinearMap.map_smul,
          LinearPMap.map_smul, ← smul_add]
        congr }
  is_extension m := by
    dsimp
    rw [(extensionOfMax i f).is_extension,
      ExtensionOfMaxAdjoin.extensionToFun_wd i f h _ ⟨i m, _⟩ 0 _, map_zero, add_zero]
    

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
h : Baer R Q
y : N
m : M
⊢ ↑{ val := i m, property := (_ : i m ∈ supExtensionOfMaxSingleton i f y) } =
    ↑{ val := i m, property := (_ : i m ∈ (extensionOfMax i f).toLinearPMap.domain) } + 0 • y

Next tactic:
simp
theorem extensionOfMax_le (h : Module.Baer R Q) {y : N} :
    extensionOfMax i f ≤ extensionOfMaxAdjoin i f h y :=
  ⟨le_sup_left, fun x x' EQ => by
    

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
h : Baer R Q
y : N
x : ↥(extensionOfMax i f).toLinearPMap.domain
x' : ↥(extensionOfMaxAdjoin i f h y).toLinearPMap.domain
EQ : ↑x = ↑x'
⊢ ↑(extensionOfMax i f).toLinearPMap x = ↑(extensionOfMaxAdjoin i f h y).toLinearPMap x'

Next tactic:
symm
theorem extensionOfMax_le (h : Module.Baer R Q) {y : N} :
    extensionOfMax i f ≤ extensionOfMaxAdjoin i f h y :=
  ⟨le_sup_left, fun x x' EQ => by
    symm
    

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
h : Baer R Q
y : N
x : ↥(extensionOfMax i f).toLinearPMap.domain
x' : ↥(extensionOfMaxAdjoin i f h y).toLinearPMap.domain
EQ : ↑x = ↑x'
⊢ ↑(extensionOfMaxAdjoin i f h y).toLinearPMap x' = ↑(extensionOfMax i f).toLinearPMap x

Next tactic:
change ExtensionOfMaxAdjoin.extensionToFun i f h _ = _
theorem extensionOfMax_le (h : Module.Baer R Q) {y : N} :
    extensionOfMax i f ≤ extensionOfMaxAdjoin i f h y :=
  ⟨le_sup_left, fun x x' EQ => by
    symm
    change ExtensionOfMaxAdjoin.extensionToFun i f h _ = _
    

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
h : Baer R Q
y : N
x : ↥(extensionOfMax i f).toLinearPMap.domain
x' : ↥(extensionOfMaxAdjoin i f h y).toLinearPMap.domain
EQ : ↑x = ↑x'
⊢ ExtensionOfMaxAdjoin.extensionToFun i f h x' = ↑(extensionOfMax i f).toLinearPMap x

Next tactic:
rw [ExtensionOfMaxAdjoin.extensionToFun_wd i f h x' x 0 (by simp [EQ]), map_zero,
      add_zero]
theorem extensionOfMax_le (h : Module.Baer R Q) {y : N} :
    extensionOfMax i f ≤ extensionOfMaxAdjoin i f h y :=
  ⟨le_sup_left, fun x x' EQ => by
    symm
    change ExtensionOfMaxAdjoin.extensionToFun i f h _ = _
    rw [ExtensionOfMaxAdjoin.extensionToFun_wd i f h x' x 0 (by 

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
h : Baer R Q
y : N
x : ↥(extensionOfMax i f).toLinearPMap.domain
x' : ↥(extensionOfMaxAdjoin i f h y).toLinearPMap.domain
EQ : ↑x = ↑x'
⊢ ↑x' = ↑x + 0 • y

Next tactic:
simp [EQ]
theorem extensionOfMax_to_submodule_eq_top (h : Module.Baer R Q) :
    (extensionOfMax i f).domain = ⊤ := by
  

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
h : Baer R Q
⊢ (extensionOfMax i f).toLinearPMap.domain = ⊤

Next tactic:
refine' Submodule.eq_top_iff'.mpr fun y => _
theorem extensionOfMax_to_submodule_eq_top (h : Module.Baer R Q) :
    (extensionOfMax i f).domain = ⊤ := by
  refine' Submodule.eq_top_iff'.mpr fun y => _
  

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
h : Baer R Q
y : N
⊢ y ∈ (extensionOfMax i f).toLinearPMap.domain

Next tactic:
dsimp
theorem extensionOfMax_to_submodule_eq_top (h : Module.Baer R Q) :
    (extensionOfMax i f).domain = ⊤ := by
  refine' Submodule.eq_top_iff'.mpr fun y => _
  dsimp
  

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
h : Baer R Q
y : N
⊢ y ∈ (extensionOfMax i f).toLinearPMap.domain

Next tactic:
rw [← extensionOfMax_is_max i f _ (extensionOfMax_le i f h), extensionOfMaxAdjoin,
    Submodule.mem_sup]
theorem extensionOfMax_to_submodule_eq_top (h : Module.Baer R Q) :
    (extensionOfMax i f).domain = ⊤ := by
  refine' Submodule.eq_top_iff'.mpr fun y => _
  dsimp
  rw [← extensionOfMax_is_max i f _ (extensionOfMax_le i f h), extensionOfMaxAdjoin,
    Submodule.mem_sup]
  

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
h : Baer R Q
y : N
⊢ ∃ y_1 ∈ (extensionOfMax i f).toLinearPMap.domain, ∃ z ∈ Submodule.span R {?y}, y_1 + z = y
case y
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
h : Baer R Q
y : N
⊢ N
case y
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
h : Baer R Q
y : N
⊢ N

Next tactic:
exact ⟨0, Submodule.zero_mem _, y, Submodule.mem_span_singleton_self _, zero_add _⟩
/-- **Baer's criterion** for injective module : a Baer module is an injective module, i.e. if every
linear map from an ideal can be extended, then the module is injective.-/
protected theorem injective (h : Module.Baer R Q) : Module.Injective R Q :=
  { out := fun X Y ins1 ins2 ins3 ins4 i hi f =>
      haveI : Fact (Function.Injective i) := ⟨hi⟩
      ⟨{  toFun := fun y =>
            (extensionOfMax i f).toLinearPMap
              ⟨y, (extensionOfMax_to_submodule_eq_top i f h).symm ▸ trivial⟩
          map_add' := fun x y => by
            

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i✝ : M →ₗ[R] N
f✝ : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i✝)
h : Baer R Q
X Y : TypeMax
ins1 : AddCommGroup X
ins2 : AddCommGroup Y
ins3 : Module R X
ins4 : Module R Y
i : X →ₗ[R] Y
hi : Function.Injective ⇑i
f : X →ₗ[R] Q
this : Fact (Function.Injective ⇑i)
x y : Y
⊢ (fun y =>
        ↑(extensionOfMax i f).toLinearPMap { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) })
      (x + y) =
    (fun y =>
          ↑(extensionOfMax i f).toLinearPMap
            { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) })
        x +
      (fun y =>
          ↑(extensionOfMax i f).toLinearPMap
            { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) })
        y

Next tactic:
rw [← LinearPMap.map_add]
/-- **Baer's criterion** for injective module : a Baer module is an injective module, i.e. if every
linear map from an ideal can be extended, then the module is injective.-/
protected theorem injective (h : Module.Baer R Q) : Module.Injective R Q :=
  { out := fun X Y ins1 ins2 ins3 ins4 i hi f =>
      haveI : Fact (Function.Injective i) := ⟨hi⟩
      ⟨{  toFun := fun y =>
            (extensionOfMax i f).toLinearPMap
              ⟨y, (extensionOfMax_to_submodule_eq_top i f h).symm ▸ trivial⟩
          map_add' := fun x y => by
            rw [← LinearPMap.map_add]
            

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i✝ : M →ₗ[R] N
f✝ : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i✝)
h : Baer R Q
X Y : TypeMax
ins1 : AddCommGroup X
ins2 : AddCommGroup Y
ins3 : Module R X
ins4 : Module R Y
i : X →ₗ[R] Y
hi : Function.Injective ⇑i
f : X →ₗ[R] Q
this : Fact (Function.Injective ⇑i)
x y : Y
⊢ (fun y =>
        ↑(extensionOfMax i f).toLinearPMap { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) })
      (x + y) =
    ↑(extensionOfMax i f).toLinearPMap
      ({ val := x, property := (_ : x ∈ (extensionOfMax i f).toLinearPMap.domain) } +
        { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) })

Next tactic:
congr
/-- **Baer's criterion** for injective module : a Baer module is an injective module, i.e. if every
linear map from an ideal can be extended, then the module is injective.-/
protected theorem injective (h : Module.Baer R Q) : Module.Injective R Q :=
  { out := fun X Y ins1 ins2 ins3 ins4 i hi f =>
      haveI : Fact (Function.Injective i) := ⟨hi⟩
      ⟨{  toFun := fun y =>
            (extensionOfMax i f).toLinearPMap
              ⟨y, (extensionOfMax_to_submodule_eq_top i f h).symm ▸ trivial⟩
          map_add' := fun x y => by
            rw [← LinearPMap.map_add]
            congr
          map_smul' := fun r x => by
            

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i✝ : M →ₗ[R] N
f✝ : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i✝)
h : Baer R Q
X Y : TypeMax
ins1 : AddCommGroup X
ins2 : AddCommGroup Y
ins3 : Module R X
ins4 : Module R Y
i : X →ₗ[R] Y
hi : Function.Injective ⇑i
f : X →ₗ[R] Q
this : Fact (Function.Injective ⇑i)
r : R
x : Y
⊢ AddHom.toFun
      {
        toFun := fun y =>
          ↑(extensionOfMax i f).toLinearPMap
            { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) },
        map_add' :=
          (_ :
            ∀ (x y : Y),
              (fun y =>
                    ↑(extensionOfMax i f).toLinearPMap
                      { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) })
                  (x + y) =
                (fun y =>
                      ↑(extensionOfMax i f).toLinearPMap
                        { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) })
                    x +
                  (fun y =>
                      ↑(extensionOfMax i f).toLinearPMap
                        { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) })
                    y) }
      (r • x) =
    (RingHom.id R) r •
      AddHom.toFun
        {
          toFun := fun y =>
            ↑(extensionOfMax i f).toLinearPMap
              { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) },
          map_add' :=
            (_ :
              ∀ (x y : Y),
                (fun y =>
                      ↑(extensionOfMax i f).toLinearPMap
                        { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) })
                    (x + y) =
                  (fun y =>
                        ↑(extensionOfMax i f).toLinearPMap
                          { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) })
                      x +
                    (fun y =>
                        ↑(extensionOfMax i f).toLinearPMap
                          { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) })
                      y) }
        x

Next tactic:
rw [← LinearPMap.map_smul]
/-- **Baer's criterion** for injective module : a Baer module is an injective module, i.e. if every
linear map from an ideal can be extended, then the module is injective.-/
protected theorem injective (h : Module.Baer R Q) : Module.Injective R Q :=
  { out := fun X Y ins1 ins2 ins3 ins4 i hi f =>
      haveI : Fact (Function.Injective i) := ⟨hi⟩
      ⟨{  toFun := fun y =>
            (extensionOfMax i f).toLinearPMap
              ⟨y, (extensionOfMax_to_submodule_eq_top i f h).symm ▸ trivial⟩
          map_add' := fun x y => by
            rw [← LinearPMap.map_add]
            congr
          map_smul' := fun r x => by
            rw [← LinearPMap.map_smul]
            -- Porting note: used to be congr
            

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i✝ : M →ₗ[R] N
f✝ : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i✝)
h : Baer R Q
X Y : TypeMax
ins1 : AddCommGroup X
ins2 : AddCommGroup Y
ins3 : Module R X
ins4 : Module R Y
i : X →ₗ[R] Y
hi : Function.Injective ⇑i
f : X →ₗ[R] Q
this : Fact (Function.Injective ⇑i)
r : R
x : Y
⊢ AddHom.toFun
      {
        toFun := fun y =>
          ↑(extensionOfMax i f).toLinearPMap
            { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) },
        map_add' :=
          (_ :
            ∀ (x y : Y),
              (fun y =>
                    ↑(extensionOfMax i f).toLinearPMap
                      { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) })
                  (x + y) =
                (fun y =>
                      ↑(extensionOfMax i f).toLinearPMap
                        { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) })
                    x +
                  (fun y =>
                      ↑(extensionOfMax i f).toLinearPMap
                        { val := y, property := (_ : y ∈ (extensionOfMax i f).toLinearPMap.domain) })
                    y) }
      (r • x) =
    ↑(extensionOfMax i f).toLinearPMap
      ((RingHom.id R) r • { val := x, property := (_ : x ∈ (extensionOfMax i f).toLinearPMap.domain) })

Next tactic:
dsimp
protected theorem of_injective (inj : Module.Injective R Q) : Module.Baer R Q := fun I g ↦
  let ⟨g', hg'⟩ := inj.1 (ULift.{max u v} I) (ULift.{max u v} R)
    (ULift.moduleEquiv.symm.toLinearMap ∘ₗ I.subtype ∘ₗ ULift.moduleEquiv.toLinearMap)
    (fun a b h ↦ by 

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
inj : Injective R Q
I : Ideal R
g : ↥I →ₗ[R] Q
a b : ULift.{max u v, u} ↥I
h :
  (↑(LinearEquiv.symm ULift.moduleEquiv) ∘ₗ Submodule.subtype I ∘ₗ ↑ULift.moduleEquiv) a =
    (↑(LinearEquiv.symm ULift.moduleEquiv) ∘ₗ Submodule.subtype I ∘ₗ ↑ULift.moduleEquiv) b
⊢ a = b

Next tactic:
aesop
protected theorem of_injective (inj : Module.Injective R Q) : Module.Baer R Q := fun I g ↦
  let ⟨g', hg'⟩ := inj.1 (ULift.{max u v} I) (ULift.{max u v} R)
    (ULift.moduleEquiv.symm.toLinearMap ∘ₗ I.subtype ∘ₗ ULift.moduleEquiv.toLinearMap)
    (fun a b h ↦ by aesop) (g ∘ₗ ULift.moduleEquiv.toLinearMap)
  ⟨g' ∘ₗ ULift.moduleEquiv.symm.toLinearMap, by 

Proof state:
R : Type u
inst✝⁷ : Ring R
Q : TypeMax
inst✝⁶ : AddCommGroup Q
inst✝⁵ : Module R Q
M N : Type (max u v)
inst✝⁴ : AddCommGroup M
inst✝³ : AddCommGroup N
inst✝² : Module R M
inst✝¹ : Module R N
i : M →ₗ[R] N
f : M →ₗ[R] Q
inst✝ : Fact (Function.Injective ⇑i)
inj : Injective R Q
I : Ideal R
g : ↥I →ₗ[R] Q
g' : ULift.{max u v, u} R →ₗ[R] Q
hg' :
  ∀ (x : ULift.{max u v, u} ↥I),
    g' ((↑(LinearEquiv.symm ULift.moduleEquiv) ∘ₗ Submodule.subtype I ∘ₗ ↑ULift.moduleEquiv) x) =
      (g ∘ₗ ↑ULift.moduleEquiv) x
⊢ ∀ (x : R) (mem : x ∈ I), (g' ∘ₗ ↑(LinearEquiv.symm ULift.moduleEquiv)) x = g { val := x, property := mem }

Next tactic:
aesop
theorem eq_star_of_eq_star [InvolutiveStar R] {r s : R} (h : r = star s) : s = star r := by
  

Proof state:
R : Type u
inst✝ : InvolutiveStar R
r s : R
h : r = star s
⊢ s = star r

Next tactic:
simp [h]
theorem star_star_mul (x y : R) : star (star x * y) = star y * x := by 

Proof state:
R : Type u
inst✝¹ : Mul R
inst✝ : StarMul R
x y : R
⊢ star (star x * y) = star y * x

Next tactic:
rw [star_mul, star_star]
theorem star_mul_star (x y : R) : star (x * star y) = y * star x := by 

Proof state:
R : Type u
inst✝¹ : Mul R
inst✝ : StarMul R
x y : R
⊢ star (x * star y) = y * star x

Next tactic:
rw [star_mul, star_star]
@[simp]
theorem semiconjBy_star_star_star {x y z : R} :
    SemiconjBy (star x) (star z) (star y) ↔ SemiconjBy x y z := by
  

Proof state:
R : Type u
inst✝¹ : Mul R
inst✝ : StarMul R
x y z : R
⊢ SemiconjBy (star x) (star z) (star y) ↔ SemiconjBy x y z

Next tactic:
simp_rw [SemiconjBy, ← star_mul, star_inj, eq_comm]
theorem commute_star_comm {x y : R} : Commute (star x) y ↔ Commute x (star y) := by
  

Proof state:
R : Type u
inst✝¹ : Mul R
inst✝ : StarMul R
x y : R
⊢ Commute (star x) y ↔ Commute x (star y)

Next tactic:
rw [← commute_star_star, star_star]
/-- `star` as a `MulEquiv` from `R` to `Rᵐᵒᵖ` -/
@[simps apply]
def starMulEquiv [Mul R] [StarMul R] : R ≃* Rᵐᵒᵖ :=
  { (InvolutiveStar.star_involutive.toPerm star).trans opEquiv with
    toFun := fun x => MulOpposite.op (star x)
    map_mul' := fun x y => by 

Proof state:
R : Type u
inst✝¹ : Mul R
inst✝ : StarMul R
src✝ : R ≃ Rᵐᵒᵖ := (Function.Involutive.toPerm star (_ : Function.Involutive star)).trans opEquiv
x y : R
⊢ Equiv.toFun
      { toFun := fun x => op (star x), invFun := src✝.invFun,
        left_inv := (_ : Function.LeftInverse src✝.invFun src✝.toFun),
        right_inv := (_ : Function.RightInverse src✝.invFun src✝.toFun) }
      (x * y) =
    Equiv.toFun
        { toFun := fun x => op (star x), invFun := src✝.invFun,
          left_inv := (_ : Function.LeftInverse src✝.invFun src✝.toFun),
          right_inv := (_ : Function.RightInverse src✝.invFun src✝.toFun) }
        x *
      Equiv.toFun
        { toFun := fun x => op (star x), invFun := src✝.invFun,
          left_inv := (_ : Function.LeftInverse src✝.invFun src✝.toFun),
          right_inv := (_ : Function.RightInverse src✝.invFun src✝.toFun) }
        y

Next tactic:
simp only [star_mul, op_mul]