l3lab/ntp-mathlib huggingface dataset:
instance : SemilatticeInf (ExtensionOf i f) :=
  Function.Injective.semilatticeInf ExtensionOf.toLinearPMap
    (fun X Y h =>
      ExtensionOf.ext (by rw [h]) fun x y h' => by
        -- Porting note: induction didn't handle dependent rw like in Lean 3
        have : {x y : N} → (h'' : x = y) → (hx : x ∈ X.toLinearPMap.domain) →
          (hy : y ∈ Y.toLinearPMap.domain) → X.toLinearPMap ⟨x,hx⟩ = Y.toLinearPMap ⟨y,hy⟩ := by
            rw [h]
            intro _ _ h _ _
            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
X Y : ExtensionOf i f
h : X.toLinearPMap = Y.toLinearPMap
x : ↥X.domain
y : ↥Y.domain
h' : ↑x = ↑y
this :
  ∀ {x y : N},
    x = y →
      ∀ (hx : x ∈ X.domain) (hy : y ∈ Y.domain),
        ↑X.toLinearPMap { val := x, property := hx } = ↑Y.toLinearPMap { val := y, property := hy }
⊢ ↑X.toLinearPMap x = ↑Y.toLinearPMap y

Next tactic:
apply this h' _ _
instance : SemilatticeInf (ExtensionOf i f) :=
  Function.Injective.semilatticeInf ExtensionOf.toLinearPMap
    (fun X Y h =>
      ExtensionOf.ext (by rw [h]) fun x y h' => by
        -- Porting note: induction didn't handle dependent rw like in Lean 3
        have : {x y : N} → (h'' : x = y) → (hx : x ∈ X.toLinearPMap.domain) →
          (hy : y ∈ Y.toLinearPMap.domain) → X.toLinearPMap ⟨x,hx⟩ = Y.toLinearPMap ⟨y,hy⟩ := by
            rw [h]
            intro _ _ h _ _
            congr
        apply this h' _ _)
    fun X Y =>
    LinearPMap.ext rfl fun x y 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
X Y : ExtensionOf i f
x : ↥(X ⊓ Y).domain
y : ↥(X.toLinearPMap ⊓ Y.toLinearPMap).domain
h : ↑x = ↑y
⊢ ↑(X ⊓ Y).toLinearPMap x = ↑(X.toLinearPMap ⊓ Y.toLinearPMap) y

Next tactic:
congr
instance : SemilatticeInf (ExtensionOf i f) :=
  Function.Injective.semilatticeInf ExtensionOf.toLinearPMap
    (fun X Y h =>
      ExtensionOf.ext (by rw [h]) fun x y h' => by
        -- Porting note: induction didn't handle dependent rw like in Lean 3
        have : {x y : N} → (h'' : x = y) → (hx : x ∈ X.toLinearPMap.domain) →
          (hy : y ∈ Y.toLinearPMap.domain) → X.toLinearPMap ⟨x,hx⟩ = Y.toLinearPMap ⟨y,hy⟩ := by
            rw [h]
            intro _ _ h _ _
            congr
        apply this h' _ _)
    fun X Y =>
    LinearPMap.ext rfl fun x y h => by
      congr
      

Proof state:
case e_a
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
X Y : ExtensionOf i f
x : ↥(X ⊓ Y).domain
y : ↥(X.toLinearPMap ⊓ Y.toLinearPMap).domain
h : ↑x = ↑y
⊢ x = y

Next tactic:
exact mod_cast h
theorem chain_linearPMap_of_chain_extensionOf {c : Set (ExtensionOf i f)}
    (hchain : IsChain (· ≤ ·) c) :
    IsChain (· ≤ ·) <| (fun x : ExtensionOf i f => x.toLinearPMap) '' c := 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
c : Set (ExtensionOf i f)
hchain : IsChain (fun x x_1 => x ≤ x_1) c
⊢ IsChain (fun x x_1 => x ≤ x_1) ((fun x => x.toLinearPMap) '' c)

Next tactic:
rintro _ ⟨a, a_mem, rfl⟩ _ ⟨b, b_mem, rfl⟩ neq
theorem chain_linearPMap_of_chain_extensionOf {c : Set (ExtensionOf i f)}
    (hchain : IsChain (· ≤ ·) c) :
    IsChain (· ≤ ·) <| (fun x : ExtensionOf i f => x.toLinearPMap) '' c := by
  rintro _ ⟨a, a_mem, rfl⟩ _ ⟨b, b_mem, rfl⟩ neq
  

Proof state:
case intro.intro.intro.intro
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
c : Set (ExtensionOf i f)
hchain : IsChain (fun x x_1 => x ≤ x_1) c
a : ExtensionOf i f
a_mem : a ∈ c
b : ExtensionOf i f
b_mem : b ∈ c
neq : (fun x => x.toLinearPMap) a ≠ (fun x => x.toLinearPMap) b
⊢ (fun x x_1 => x ≤ x_1) ((fun x => x.toLinearPMap) a) ((fun x => x.toLinearPMap) b) ∨
    (fun x x_1 => x ≤ x_1) ((fun x => x.toLinearPMap) b) ((fun x => x.toLinearPMap) a)

Next tactic:
exact hchain a_mem b_mem (ne_of_apply_ne _ neq)
/-- The maximal element of every nonempty chain of `extension_of i f`. -/
def ExtensionOf.max {c : Set (ExtensionOf i f)} (hchain : IsChain (· ≤ ·) c)
    (hnonempty : c.Nonempty) : ExtensionOf i f :=
  { LinearPMap.sSup _
      (IsChain.directedOn <|
        chain_linearPMap_of_chain_extensionOf
          hchain) with
    le := 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
c : Set (ExtensionOf i f)
hchain : IsChain (fun x x_1 => x ≤ x_1) c
hnonempty : Set.Nonempty c
src✝ : N →ₗ.[R] Q :=
  LinearPMap.sSup ((fun x => x.toLinearPMap) '' c)
    (_ : DirectedOn (fun x x_1 => x ≤ x_1) ((fun x => x.toLinearPMap) '' c))
⊢ LinearMap.range i ≤ { domain := src✝.domain, toFun := src✝.toFun }.domain

Next tactic:
refine' le_trans hnonempty.some.le <|
        (LinearPMap.le_sSup _ <|
            (Set.mem_image _ _ _).mpr ⟨hnonempty.some, hnonempty.choose_spec, rfl⟩).1
/-- The maximal element of every nonempty chain of `extension_of i f`. -/
def ExtensionOf.max {c : Set (ExtensionOf i f)} (hchain : IsChain (· ≤ ·) c)
    (hnonempty : c.Nonempty) : ExtensionOf i f :=
  { LinearPMap.sSup _
      (IsChain.directedOn <|
        chain_linearPMap_of_chain_extensionOf
          hchain) with
    le := by
      refine' le_trans hnonempty.some.le <|
        (LinearPMap.le_sSup _ <|
            (Set.mem_image _ _ _).mpr ⟨hnonempty.some, hnonempty.choose_spec, rfl⟩).1
      -- porting note: this subgoal didn't exist before the reenableeta branch
      -- follow-up note: the subgoal was moved from after `refine'` in `is_extension` to here
      -- after the behavior of `refine'` changed.
      

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
c : Set (ExtensionOf i f)
hchain : IsChain (fun x x_1 => x ≤ x_1) c
hnonempty : Set.Nonempty c
src✝ : N →ₗ.[R] Q :=
  LinearPMap.sSup ((fun x => x.toLinearPMap) '' c)
    (_ : DirectedOn (fun x x_1 => x ≤ x_1) ((fun x => x.toLinearPMap) '' c))
⊢ DirectedOn (fun x x_1 => x ≤ x_1) (toLinearPMap '' c)

Next tactic:
exact (IsChain.directedOn <| chain_linearPMap_of_chain_extensionOf hchain)
/-- The maximal element of every nonempty chain of `extension_of i f`. -/
def ExtensionOf.max {c : Set (ExtensionOf i f)} (hchain : IsChain (· ≤ ·) c)
    (hnonempty : c.Nonempty) : ExtensionOf i f :=
  { LinearPMap.sSup _
      (IsChain.directedOn <|
        chain_linearPMap_of_chain_extensionOf
          hchain) with
    le := by
      refine' le_trans hnonempty.some.le <|
        (LinearPMap.le_sSup _ <|
            (Set.mem_image _ _ _).mpr ⟨hnonempty.some, hnonempty.choose_spec, rfl⟩).1
      -- porting note: this subgoal didn't exist before the reenableeta branch
      -- follow-up note: the subgoal was moved from after `refine'` in `is_extension` to here
      -- after the behavior of `refine'` changed.
      exact (IsChain.directedOn <| chain_linearPMap_of_chain_extensionOf hchain)
    is_extension := fun m => 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
c : Set (ExtensionOf i f)
hchain : IsChain (fun x x_1 => x ≤ x_1) c
hnonempty : Set.Nonempty c
src✝ : N →ₗ.[R] Q :=
  LinearPMap.sSup ((fun x => x.toLinearPMap) '' c)
    (_ : DirectedOn (fun x x_1 => x ≤ x_1) ((fun x => x.toLinearPMap) '' c))
m : M
⊢ f m =
    ↑{ domain := src✝.domain, toFun := src✝.toFun }
      { val := i m, property := (_ : i m ∈ { domain := src✝.domain, toFun := src✝.toFun }.domain) }

Next tactic:
refine' Eq.trans (hnonempty.some.is_extension m) _
/-- The maximal element of every nonempty chain of `extension_of i f`. -/
def ExtensionOf.max {c : Set (ExtensionOf i f)} (hchain : IsChain (· ≤ ·) c)
    (hnonempty : c.Nonempty) : ExtensionOf i f :=
  { LinearPMap.sSup _
      (IsChain.directedOn <|
        chain_linearPMap_of_chain_extensionOf
          hchain) with
    le := by
      refine' le_trans hnonempty.some.le <|
        (LinearPMap.le_sSup _ <|
            (Set.mem_image _ _ _).mpr ⟨hnonempty.some, hnonempty.choose_spec, rfl⟩).1
      -- porting note: this subgoal didn't exist before the reenableeta branch
      -- follow-up note: the subgoal was moved from after `refine'` in `is_extension` to here
      -- after the behavior of `refine'` changed.
      exact (IsChain.directedOn <| chain_linearPMap_of_chain_extensionOf hchain)
    is_extension := fun m => by
      refine' Eq.trans (hnonempty.some.is_extension m) _
      

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
c : Set (ExtensionOf i f)
hchain : IsChain (fun x x_1 => x ≤ x_1) c
hnonempty : Set.Nonempty c
src✝ : N →ₗ.[R] Q :=
  LinearPMap.sSup ((fun x => x.toLinearPMap) '' c)
    (_ : DirectedOn (fun x x_1 => x ≤ x_1) ((fun x => x.toLinearPMap) '' c))
m : M
⊢ ↑(Set.Nonempty.some hnonempty).toLinearPMap
      { val := i m, property := (_ : i m ∈ (Set.Nonempty.some hnonempty).toLinearPMap.domain) } =
    ↑{ domain := src✝.domain, toFun := src✝.toFun }
      { val := i m, property := (_ : i m ∈ { domain := src✝.domain, toFun := src✝.toFun }.domain) }

Next tactic:
symm
/-- The maximal element of every nonempty chain of `extension_of i f`. -/
def ExtensionOf.max {c : Set (ExtensionOf i f)} (hchain : IsChain (· ≤ ·) c)
    (hnonempty : c.Nonempty) : ExtensionOf i f :=
  { LinearPMap.sSup _
      (IsChain.directedOn <|
        chain_linearPMap_of_chain_extensionOf
          hchain) with
    le := by
      refine' le_trans hnonempty.some.le <|
        (LinearPMap.le_sSup _ <|
            (Set.mem_image _ _ _).mpr ⟨hnonempty.some, hnonempty.choose_spec, rfl⟩).1
      -- porting note: this subgoal didn't exist before the reenableeta branch
      -- follow-up note: the subgoal was moved from after `refine'` in `is_extension` to here
      -- after the behavior of `refine'` changed.
      exact (IsChain.directedOn <| chain_linearPMap_of_chain_extensionOf hchain)
    is_extension := fun m => by
      refine' Eq.trans (hnonempty.some.is_extension m) _
      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
c : Set (ExtensionOf i f)
hchain : IsChain (fun x x_1 => x ≤ x_1) c
hnonempty : Set.Nonempty c
src✝ : N →ₗ.[R] Q :=
  LinearPMap.sSup ((fun x => x.toLinearPMap) '' c)
    (_ : DirectedOn (fun x x_1 => x ≤ x_1) ((fun x => x.toLinearPMap) '' c))
m : M
⊢ ↑{ domain := src✝.domain, toFun := src✝.toFun }
      { val := i m, property := (_ : i m ∈ { domain := src✝.domain, toFun := src✝.toFun }.domain) } =
    ↑(Set.Nonempty.some hnonempty).toLinearPMap
      { val := i m, property := (_ : i m ∈ (Set.Nonempty.some hnonempty).toLinearPMap.domain) }

Next tactic:
generalize_proofs _ h1
/-- The maximal element of every nonempty chain of `extension_of i f`. -/
def ExtensionOf.max {c : Set (ExtensionOf i f)} (hchain : IsChain (· ≤ ·) c)
    (hnonempty : c.Nonempty) : ExtensionOf i f :=
  { LinearPMap.sSup _
      (IsChain.directedOn <|
        chain_linearPMap_of_chain_extensionOf
          hchain) with
    le := by
      refine' le_trans hnonempty.some.le <|
        (LinearPMap.le_sSup _ <|
            (Set.mem_image _ _ _).mpr ⟨hnonempty.some, hnonempty.choose_spec, rfl⟩).1
      -- porting note: this subgoal didn't exist before the reenableeta branch
      -- follow-up note: the subgoal was moved from after `refine'` in `is_extension` to here
      -- after the behavior of `refine'` changed.
      exact (IsChain.directedOn <| chain_linearPMap_of_chain_extensionOf hchain)
    is_extension := fun m => by
      refine' Eq.trans (hnonempty.some.is_extension m) _
      symm
      generalize_proofs _ h1
      

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
c : Set (ExtensionOf i f)
hchain : IsChain (fun x x_1 => x ≤ x_1) c
hnonempty : Set.Nonempty c
src✝ : N →ₗ.[R] Q :=
  LinearPMap.sSup ((fun x => x.toLinearPMap) '' c)
    (_ : DirectedOn (fun x x_1 => x ≤ x_1) ((fun x => x.toLinearPMap) '' c))
m : M
h✝ : i m ∈ { domain := src✝.domain, toFun := src✝.toFun }.domain
h1 : i m ∈ (Set.Nonempty.some hnonempty).toLinearPMap.domain
⊢ ↑{ domain := src✝.domain, toFun := src✝.toFun } { val := i m, property := h✝ } =
    ↑(Set.Nonempty.some hnonempty).toLinearPMap { val := i m, property := h1 }

Next tactic:
exact
        LinearPMap.sSup_apply (IsChain.directedOn <| chain_linearPMap_of_chain_extensionOf hchain)
          ((Set.mem_image _ _ _).mpr ⟨hnonempty.some, hnonempty.choose_spec, rfl⟩) ⟨i m, h1⟩
instance ExtensionOf.inhabited : Inhabited (ExtensionOf i f) where
  default :=
    { domain := LinearMap.range i
      toFun :=
        { toFun := fun x => f x.2.choose
          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)
x y : ↥(LinearMap.range i)
⊢ (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) (x + y) =
    (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) x +
      (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) y

Next tactic:
have eq1 : _ + _ = (x + y).1 := congr_arg₂ (· + ·) x.2.choose_spec y.2.choose_spec
instance ExtensionOf.inhabited : Inhabited (ExtensionOf i f) where
  default :=
    { domain := LinearMap.range i
      toFun :=
        { toFun := fun x => f x.2.choose
          map_add' := fun x y => by
            have eq1 : _ + _ = (x + y).1 := congr_arg₂ (· + ·) x.2.choose_spec y.2.choose_spec
            

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)
x y : ↥(LinearMap.range i)
eq1 : i (Exists.choose (_ : ↑x ∈ LinearMap.range i)) + i (Exists.choose (_ : ↑y ∈ LinearMap.range i)) = ↑(x + y)
⊢ (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) (x + y) =
    (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) x +
      (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) y

Next tactic:
rw [← map_add, ← (x + y).2.choose_spec] at eq1
instance ExtensionOf.inhabited : Inhabited (ExtensionOf i f) where
  default :=
    { domain := LinearMap.range i
      toFun :=
        { toFun := fun x => f x.2.choose
          map_add' := fun x y => by
            have eq1 : _ + _ = (x + y).1 := congr_arg₂ (· + ·) x.2.choose_spec y.2.choose_spec
            rw [← map_add, ← (x + y).2.choose_spec] at eq1
            

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)
x y : ↥(LinearMap.range i)
eq1 :
  i (Exists.choose (_ : ↑x ∈ LinearMap.range i) + Exists.choose (_ : ↑y ∈ LinearMap.range i)) =
    i (Exists.choose (_ : ↑(x + y) ∈ LinearMap.range i))
⊢ (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) (x + y) =
    (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) x +
      (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) y

Next tactic:
dsimp
instance ExtensionOf.inhabited : Inhabited (ExtensionOf i f) where
  default :=
    { domain := LinearMap.range i
      toFun :=
        { toFun := fun x => f x.2.choose
          map_add' := fun x y => by
            have eq1 : _ + _ = (x + y).1 := congr_arg₂ (· + ·) x.2.choose_spec y.2.choose_spec
            rw [← map_add, ← (x + y).2.choose_spec] at eq1
            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)
x y : ↥(LinearMap.range i)
eq1 :
  i (Exists.choose (_ : ↑x ∈ LinearMap.range i) + Exists.choose (_ : ↑y ∈ LinearMap.range i)) =
    i (Exists.choose (_ : ↑(x + y) ∈ LinearMap.range i))
⊢ f (Exists.choose (_ : ↑(x + y) ∈ LinearMap.range i)) =
    f (Exists.choose (_ : ↑x ∈ LinearMap.range i)) + f (Exists.choose (_ : ↑y ∈ LinearMap.range i))

Next tactic:
rw [← Fact.out (p := Function.Injective i) eq1, map_add]
instance ExtensionOf.inhabited : Inhabited (ExtensionOf i f) where
  default :=
    { domain := LinearMap.range i
      toFun :=
        { toFun := fun x => f x.2.choose
          map_add' := fun x y => by
            have eq1 : _ + _ = (x + y).1 := congr_arg₂ (· + ·) x.2.choose_spec y.2.choose_spec
            rw [← map_add, ← (x + y).2.choose_spec] at eq1
            dsimp
            rw [← Fact.out (p := Function.Injective i) eq1, map_add]
          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)
r : R
x : ↥(LinearMap.range i)
⊢ AddHom.toFun
      { toFun := fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i)),
        map_add' :=
          (_ :
            ∀ (x y : ↥(LinearMap.range i)),
              (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) (x + y) =
                (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) x +
                  (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) y) }
      (r • x) =
    (RingHom.id R) r •
      AddHom.toFun
        { toFun := fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i)),
          map_add' :=
            (_ :
              ∀ (x y : ↥(LinearMap.range i)),
                (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) (x + y) =
                  (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) x +
                    (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) y) }
        x

Next tactic:
have eq1 : r • _ = (r • x).1 := congr_arg (r • ·) x.2.choose_spec
instance ExtensionOf.inhabited : Inhabited (ExtensionOf i f) where
  default :=
    { domain := LinearMap.range i
      toFun :=
        { toFun := fun x => f x.2.choose
          map_add' := fun x y => by
            have eq1 : _ + _ = (x + y).1 := congr_arg₂ (· + ·) x.2.choose_spec y.2.choose_spec
            rw [← map_add, ← (x + y).2.choose_spec] at eq1
            dsimp
            rw [← Fact.out (p := Function.Injective i) eq1, map_add]
          map_smul' := fun r x => by
            have eq1 : r • _ = (r • x).1 := congr_arg (r • ·) x.2.choose_spec
            

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)
r : R
x : ↥(LinearMap.range i)
eq1 : r • i (Exists.choose (_ : ↑x ∈ LinearMap.range i)) = ↑(r • x)
⊢ AddHom.toFun
      { toFun := fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i)),
        map_add' :=
          (_ :
            ∀ (x y : ↥(LinearMap.range i)),
              (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) (x + y) =
                (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) x +
                  (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) y) }
      (r • x) =
    (RingHom.id R) r •
      AddHom.toFun
        { toFun := fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i)),
          map_add' :=
            (_ :
              ∀ (x y : ↥(LinearMap.range i)),
                (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) (x + y) =
                  (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) x +
                    (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) y) }
        x

Next tactic:
rw [← LinearMap.map_smul, ← (r • x).2.choose_spec] at eq1
instance ExtensionOf.inhabited : Inhabited (ExtensionOf i f) where
  default :=
    { domain := LinearMap.range i
      toFun :=
        { toFun := fun x => f x.2.choose
          map_add' := fun x y => by
            have eq1 : _ + _ = (x + y).1 := congr_arg₂ (· + ·) x.2.choose_spec y.2.choose_spec
            rw [← map_add, ← (x + y).2.choose_spec] at eq1
            dsimp
            rw [← Fact.out (p := Function.Injective i) eq1, map_add]
          map_smul' := fun r x => by
            have eq1 : r • _ = (r • x).1 := congr_arg (r • ·) x.2.choose_spec
            rw [← LinearMap.map_smul, ← (r • x).2.choose_spec] at eq1
            

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)
r : R
x : ↥(LinearMap.range i)
eq1 : i (r • Exists.choose (_ : ↑x ∈ LinearMap.range i)) = i (Exists.choose (_ : ↑(r • x) ∈ LinearMap.range i))
⊢ AddHom.toFun
      { toFun := fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i)),
        map_add' :=
          (_ :
            ∀ (x y : ↥(LinearMap.range i)),
              (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) (x + y) =
                (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) x +
                  (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) y) }
      (r • x) =
    (RingHom.id R) r •
      AddHom.toFun
        { toFun := fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i)),
          map_add' :=
            (_ :
              ∀ (x y : ↥(LinearMap.range i)),
                (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) (x + y) =
                  (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) x +
                    (fun x => f (Exists.choose (_ : ↑x ∈ LinearMap.range i))) y) }
        x

Next tactic:
dsimp