l3lab/ntp-mathlib huggingface dataset:
theorem of.zero_exact_aux [Nonempty ι] [IsDirected ι (· ≤ ·)] {x : FreeCommRing (Σi, G i)}
    (H : (Ideal.Quotient.mk _ x : DirectLimit G fun i j h => f' i j h)
        = (0 : DirectLimit G fun i j h => f' i j h)) :
    ∃ j s,
      ∃ H : ∀ k : Σi, G i, k ∈ s → k.1 ≤ j,
        IsSupported x s ∧
          lift (fun ix : s => f' ix.1.1 j (H ix ix.2) ix.1.2) (restriction s x) = (0 : G j) := by
  refine' span_induction (Ideal.Quotient.eq_zero_iff_mem.1 H) _ _ _ _
  · rintro x (⟨i, j, hij, x, rfl⟩ | ⟨i, rfl⟩ | ⟨i, x, y, rfl⟩ | ⟨i, x, y, rfl⟩)
    · refine'
        ⟨j, {⟨i, x⟩, ⟨j, f' i j hij x⟩}, _,
          isSupported_sub (isSupported_of.2 <| Or.inr rfl) (isSupported_of.2 <| Or.inl rfl), _⟩
      · rintro k (rfl | ⟨rfl | _⟩)
        exact hij
        rfl
      · rw [(restriction _).map_sub, RingHom.map_sub, restriction_of, dif_pos,
          restriction_of, dif_pos, lift_of, lift_of]
        dsimp only
        have := DirectedSystem.map_map (fun i j h => f' i j h) hij (le_refl j : j ≤ j)
        rw [this]
        exact sub_self _
        exacts [Or.inr rfl, Or.inl rfl]
    · refine' ⟨i, {⟨i, 1⟩}, _, isSupported_sub (isSupported_of.2 rfl) isSupported_one, _⟩
      · rintro k (rfl | h)
        rfl
        -- porting note: the Lean3 proof contained `rw [restriction_of]`, but this
        -- lemma does not seem to work here
      · rw [RingHom.map_sub, RingHom.map_sub]
        erw [lift_of, dif_pos rfl, RingHom.map_one, lift_of, RingHom.map_one, sub_self]
    · refine'
        ⟨i, {⟨i, x + y⟩, ⟨i, x⟩, ⟨i, y⟩}, _,
          isSupported_sub (isSupported_of.2 <| Or.inl rfl)
            (isSupported_add (isSupported_of.2 <| Or.inr <| Or.inl rfl)
              (isSupported_of.2 <| Or.inr <| Or.inr rfl)),
          _⟩
      · rintro k (rfl | ⟨rfl | ⟨rfl | hk⟩⟩) <;> 

Proof state:
case refine'_1.inr.inr.inl.intro.intro.intro.refine'_1.inl
R : Type u
inst✝⁵ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁴ : Preorder ι
G : ι → Type w
inst✝³ : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝² : DirectedSystem G fun i j h => ⇑(f' i j h)
inst✝¹ : Nonempty ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
x✝ : FreeCommRing ((i : ι) × G i)
H :
  (Ideal.Quotient.mk
        (Ideal.span
          {a |
            (∃ i j,
                ∃ (H : i ≤ j),
                  ∃ x,
                    FreeCommRing.of { fst := j, snd := (fun i j h => ⇑(f' i j h)) i j H x } -
                        FreeCommRing.of { fst := i, snd := x } =
                      a) ∨
              (∃ i, FreeCommRing.of { fst := i, snd := 1 } - 1 = a) ∨
                (∃ i x y,
                    FreeCommRing.of { fst := i, snd := x + y } -
                        (FreeCommRing.of { fst := i, snd := x } + FreeCommRing.of { fst := i, snd := y }) =
                      a) ∨
                  ∃ i x y,
                    FreeCommRing.of { fst := i, snd := x * y } -
                        FreeCommRing.of { fst := i, snd := x } * FreeCommRing.of { fst := i, snd := y } =
                      a}))
      x✝ =
    0
i : ι
x y : G i
⊢ { fst := i, snd := x + y }.fst ≤ i

Next tactic:
rfl
theorem of.zero_exact_aux [Nonempty ι] [IsDirected ι (· ≤ ·)] {x : FreeCommRing (Σi, G i)}
    (H : (Ideal.Quotient.mk _ x : DirectLimit G fun i j h => f' i j h)
        = (0 : DirectLimit G fun i j h => f' i j h)) :
    ∃ j s,
      ∃ H : ∀ k : Σi, G i, k ∈ s → k.1 ≤ j,
        IsSupported x s ∧
          lift (fun ix : s => f' ix.1.1 j (H ix ix.2) ix.1.2) (restriction s x) = (0 : G j) := by
  refine' span_induction (Ideal.Quotient.eq_zero_iff_mem.1 H) _ _ _ _
  · rintro x (⟨i, j, hij, x, rfl⟩ | ⟨i, rfl⟩ | ⟨i, x, y, rfl⟩ | ⟨i, x, y, rfl⟩)
    · refine'
        ⟨j, {⟨i, x⟩, ⟨j, f' i j hij x⟩}, _,
          isSupported_sub (isSupported_of.2 <| Or.inr rfl) (isSupported_of.2 <| Or.inl rfl), _⟩
      · rintro k (rfl | ⟨rfl | _⟩)
        exact hij
        rfl
      · rw [(restriction _).map_sub, RingHom.map_sub, restriction_of, dif_pos,
          restriction_of, dif_pos, lift_of, lift_of]
        dsimp only
        have := DirectedSystem.map_map (fun i j h => f' i j h) hij (le_refl j : j ≤ j)
        rw [this]
        exact sub_self _
        exacts [Or.inr rfl, Or.inl rfl]
    · refine' ⟨i, {⟨i, 1⟩}, _, isSupported_sub (isSupported_of.2 rfl) isSupported_one, _⟩
      · rintro k (rfl | h)
        rfl
        -- porting note: the Lean3 proof contained `rw [restriction_of]`, but this
        -- lemma does not seem to work here
      · rw [RingHom.map_sub, RingHom.map_sub]
        erw [lift_of, dif_pos rfl, RingHom.map_one, lift_of, RingHom.map_one, sub_self]
    · refine'
        ⟨i, {⟨i, x + y⟩, ⟨i, x⟩, ⟨i, y⟩}, _,
          isSupported_sub (isSupported_of.2 <| Or.inl rfl)
            (isSupported_add (isSupported_of.2 <| Or.inr <| Or.inl rfl)
              (isSupported_of.2 <| Or.inr <| Or.inr rfl)),
          _⟩
      · rintro k (rfl | ⟨rfl | ⟨rfl | hk⟩⟩) <;> 

Proof state:
case refine'_1.inr.inr.inl.intro.intro.intro.refine'_1.inr.inl
R : Type u
inst✝⁵ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁴ : Preorder ι
G : ι → Type w
inst✝³ : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝² : DirectedSystem G fun i j h => ⇑(f' i j h)
inst✝¹ : Nonempty ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
x✝ : FreeCommRing ((i : ι) × G i)
H :
  (Ideal.Quotient.mk
        (Ideal.span
          {a |
            (∃ i j,
                ∃ (H : i ≤ j),
                  ∃ x,
                    FreeCommRing.of { fst := j, snd := (fun i j h => ⇑(f' i j h)) i j H x } -
                        FreeCommRing.of { fst := i, snd := x } =
                      a) ∨
              (∃ i, FreeCommRing.of { fst := i, snd := 1 } - 1 = a) ∨
                (∃ i x y,
                    FreeCommRing.of { fst := i, snd := x + y } -
                        (FreeCommRing.of { fst := i, snd := x } + FreeCommRing.of { fst := i, snd := y }) =
                      a) ∨
                  ∃ i x y,
                    FreeCommRing.of { fst := i, snd := x * y } -
                        FreeCommRing.of { fst := i, snd := x } * FreeCommRing.of { fst := i, snd := y } =
                      a}))
      x✝ =
    0
i : ι
x y : G i
⊢ { fst := i, snd := x }.fst ≤ i

Next tactic:
rfl
theorem of.zero_exact_aux [Nonempty ι] [IsDirected ι (· ≤ ·)] {x : FreeCommRing (Σi, G i)}
    (H : (Ideal.Quotient.mk _ x : DirectLimit G fun i j h => f' i j h)
        = (0 : DirectLimit G fun i j h => f' i j h)) :
    ∃ j s,
      ∃ H : ∀ k : Σi, G i, k ∈ s → k.1 ≤ j,
        IsSupported x s ∧
          lift (fun ix : s => f' ix.1.1 j (H ix ix.2) ix.1.2) (restriction s x) = (0 : G j) := by
  refine' span_induction (Ideal.Quotient.eq_zero_iff_mem.1 H) _ _ _ _
  · rintro x (⟨i, j, hij, x, rfl⟩ | ⟨i, rfl⟩ | ⟨i, x, y, rfl⟩ | ⟨i, x, y, rfl⟩)
    · refine'
        ⟨j, {⟨i, x⟩, ⟨j, f' i j hij x⟩}, _,
          isSupported_sub (isSupported_of.2 <| Or.inr rfl) (isSupported_of.2 <| Or.inl rfl), _⟩
      · rintro k (rfl | ⟨rfl | _⟩)
        exact hij
        rfl
      · rw [(restriction _).map_sub, RingHom.map_sub, restriction_of, dif_pos,
          restriction_of, dif_pos, lift_of, lift_of]
        dsimp only
        have := DirectedSystem.map_map (fun i j h => f' i j h) hij (le_refl j : j ≤ j)
        rw [this]
        exact sub_self _
        exacts [Or.inr rfl, Or.inl rfl]
    · refine' ⟨i, {⟨i, 1⟩}, _, isSupported_sub (isSupported_of.2 rfl) isSupported_one, _⟩
      · rintro k (rfl | h)
        rfl
        -- porting note: the Lean3 proof contained `rw [restriction_of]`, but this
        -- lemma does not seem to work here
      · rw [RingHom.map_sub, RingHom.map_sub]
        erw [lift_of, dif_pos rfl, RingHom.map_one, lift_of, RingHom.map_one, sub_self]
    · refine'
        ⟨i, {⟨i, x + y⟩, ⟨i, x⟩, ⟨i, y⟩}, _,
          isSupported_sub (isSupported_of.2 <| Or.inl rfl)
            (isSupported_add (isSupported_of.2 <| Or.inr <| Or.inl rfl)
              (isSupported_of.2 <| Or.inr <| Or.inr rfl)),
          _⟩
      · rintro k (rfl | ⟨rfl | ⟨rfl | hk⟩⟩) <;> 

Proof state:
case refine'_1.inr.inr.inl.intro.intro.intro.refine'_1.inr.inr.refl
R : Type u
inst✝⁵ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁴ : Preorder ι
G : ι → Type w
inst✝³ : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝² : DirectedSystem G fun i j h => ⇑(f' i j h)
inst✝¹ : Nonempty ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
x✝ : FreeCommRing ((i : ι) × G i)
H :
  (Ideal.Quotient.mk
        (Ideal.span
          {a |
            (∃ i j,
                ∃ (H : i ≤ j),
                  ∃ x,
                    FreeCommRing.of { fst := j, snd := (fun i j h => ⇑(f' i j h)) i j H x } -
                        FreeCommRing.of { fst := i, snd := x } =
                      a) ∨
              (∃ i, FreeCommRing.of { fst := i, snd := 1 } - 1 = a) ∨
                (∃ i x y,
                    FreeCommRing.of { fst := i, snd := x + y } -
                        (FreeCommRing.of { fst := i, snd := x } + FreeCommRing.of { fst := i, snd := y }) =
                      a) ∨
                  ∃ i x y,
                    FreeCommRing.of { fst := i, snd := x * y } -
                        FreeCommRing.of { fst := i, snd := x } * FreeCommRing.of { fst := i, snd := y } =
                      a}))
      x✝ =
    0
i : ι
x y : G i
⊢ { fst := i, snd := y }.fst ≤ i

Next tactic:
rfl
/-- A component that corresponds to zero in the direct limit is already zero in some
bigger module in the directed system. -/
theorem of.zero_exact [IsDirected ι (· ≤ ·)] {i x} (hix : of G (fun i j h => f' i j h) i x = 0) :
    ∃ (j : _) (hij : i ≤ j), f' i j hij x = 0 :=
  haveI : Nonempty ι := ⟨i⟩
  let ⟨j, s, H, hxs, hx⟩ := of.zero_exact_aux hix
  have hixs : (⟨i, x⟩ : Σi, G i) ∈ s := isSupported_of.1 hxs
  ⟨j, H ⟨i, x⟩ hixs, by 

Proof state:
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝¹ : DirectedSystem G fun i j h => ⇑(f' i j h)
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
i : ι
x : G i
hix : (of G (fun i j h => ⇑(f' i j h)) i) x = 0
this : Nonempty ι
j : ι
s : Set ((i : ι) × G i)
H : ∀ k ∈ s, k.fst ≤ j
hxs : IsSupported (FreeCommRing.of { fst := i, snd := x }) s
hx :
  (lift fun ix => (f' (↑ix).fst j (_ : (↑ix).fst ≤ j)) (↑ix).snd)
      ((restriction s) (FreeCommRing.of { fst := i, snd := x })) =
    0
hixs : { fst := i, snd := x } ∈ s
⊢ (f' i j (_ : { fst := i, snd := x }.fst ≤ j)) x = 0

Next tactic:
rw [restriction_of, dif_pos hixs, lift_of] at hx
/-- A component that corresponds to zero in the direct limit is already zero in some
bigger module in the directed system. -/
theorem of.zero_exact [IsDirected ι (· ≤ ·)] {i x} (hix : of G (fun i j h => f' i j h) i x = 0) :
    ∃ (j : _) (hij : i ≤ j), f' i j hij x = 0 :=
  haveI : Nonempty ι := ⟨i⟩
  let ⟨j, s, H, hxs, hx⟩ := of.zero_exact_aux hix
  have hixs : (⟨i, x⟩ : Σi, G i) ∈ s := isSupported_of.1 hxs
  ⟨j, H ⟨i, x⟩ hixs, by rw [restriction_of, dif_pos hixs, lift_of] at hx; 

Proof state:
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝¹ : DirectedSystem G fun i j h => ⇑(f' i j h)
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
i : ι
x : G i
hix : (of G (fun i j h => ⇑(f' i j h)) i) x = 0
this : Nonempty ι
j : ι
s : Set ((i : ι) × G i)
H : ∀ k ∈ s, k.fst ≤ j
hxs : IsSupported (FreeCommRing.of { fst := i, snd := x }) s
hixs : { fst := i, snd := x } ∈ s
hx :
  (f' (↑{ val := { fst := i, snd := x }, property := hixs }).fst j
        (_ : (↑{ val := { fst := i, snd := x }, property := hixs }).fst ≤ j))
      (↑{ val := { fst := i, snd := x }, property := hixs }).snd =
    0
⊢ (f' i j (_ : { fst := i, snd := x }.fst ≤ j)) x = 0

Next tactic:
exact hx
/-- If the maps in the directed system are injective, then the canonical maps
from the components to the direct limits are injective. -/
theorem of_injective [IsDirected ι (· ≤ ·)] [DirectedSystem G fun i j h => f' i j h]
    (hf : ∀ i j hij, Function.Injective (f' i j hij)) (i) :
    Function.Injective (of G (fun i j h => f' i j h) i) := by
  

Proof state:
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
hf : ∀ (i j : ι) (hij : i ≤ j), Function.Injective ⇑(f' i j hij)
i : ι
⊢ Function.Injective ⇑(of G (fun i j h => ⇑(f' i j h)) i)

Next tactic:
suffices ∀ x, of G (fun i j h => f' i j h) i x = 0 → x = 0 by
    intro x y hxy
    rw [← sub_eq_zero]
    apply this
    rw [(of G _ i).map_sub, hxy, sub_self]
/-- If the maps in the directed system are injective, then the canonical maps
from the components to the direct limits are injective. -/
theorem of_injective [IsDirected ι (· ≤ ·)] [DirectedSystem G fun i j h => f' i j h]
    (hf : ∀ i j hij, Function.Injective (f' i j hij)) (i) :
    Function.Injective (of G (fun i j h => f' i j h) i) := by
  suffices ∀ x, of G (fun i j h => f' i j h) i x = 0 → x = 0 by
    

Proof state:
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
hf : ∀ (i j : ι) (hij : i ≤ j), Function.Injective ⇑(f' i j hij)
i : ι
this : ∀ (x : G i), (of G (fun i j h => ⇑(f' i j h)) i) x = 0 → x = 0
⊢ Function.Injective ⇑(of G (fun i j h => ⇑(f' i j h)) i)

Next tactic:
intro x y hxy
/-- If the maps in the directed system are injective, then the canonical maps
from the components to the direct limits are injective. -/
theorem of_injective [IsDirected ι (· ≤ ·)] [DirectedSystem G fun i j h => f' i j h]
    (hf : ∀ i j hij, Function.Injective (f' i j hij)) (i) :
    Function.Injective (of G (fun i j h => f' i j h) i) := by
  suffices ∀ x, of G (fun i j h => f' i j h) i x = 0 → x = 0 by
    intro x y hxy
    

Proof state:
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
hf : ∀ (i j : ι) (hij : i ≤ j), Function.Injective ⇑(f' i j hij)
i : ι
this : ∀ (x : G i), (of G (fun i j h => ⇑(f' i j h)) i) x = 0 → x = 0
x y : G i
hxy : (of G (fun i j h => ⇑(f' i j h)) i) x = (of G (fun i j h => ⇑(f' i j h)) i) y
⊢ x = y

Next tactic:
rw [← sub_eq_zero]
/-- If the maps in the directed system are injective, then the canonical maps
from the components to the direct limits are injective. -/
theorem of_injective [IsDirected ι (· ≤ ·)] [DirectedSystem G fun i j h => f' i j h]
    (hf : ∀ i j hij, Function.Injective (f' i j hij)) (i) :
    Function.Injective (of G (fun i j h => f' i j h) i) := by
  suffices ∀ x, of G (fun i j h => f' i j h) i x = 0 → x = 0 by
    intro x y hxy
    rw [← sub_eq_zero]
    

Proof state:
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
hf : ∀ (i j : ι) (hij : i ≤ j), Function.Injective ⇑(f' i j hij)
i : ι
this : ∀ (x : G i), (of G (fun i j h => ⇑(f' i j h)) i) x = 0 → x = 0
x y : G i
hxy : (of G (fun i j h => ⇑(f' i j h)) i) x = (of G (fun i j h => ⇑(f' i j h)) i) y
⊢ x - y = 0

Next tactic:
apply this
/-- If the maps in the directed system are injective, then the canonical maps
from the components to the direct limits are injective. -/
theorem of_injective [IsDirected ι (· ≤ ·)] [DirectedSystem G fun i j h => f' i j h]
    (hf : ∀ i j hij, Function.Injective (f' i j hij)) (i) :
    Function.Injective (of G (fun i j h => f' i j h) i) := by
  suffices ∀ x, of G (fun i j h => f' i j h) i x = 0 → x = 0 by
    intro x y hxy
    rw [← sub_eq_zero]
    apply this
    

Proof state:
case a
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
hf : ∀ (i j : ι) (hij : i ≤ j), Function.Injective ⇑(f' i j hij)
i : ι
this : ∀ (x : G i), (of G (fun i j h => ⇑(f' i j h)) i) x = 0 → x = 0
x y : G i
hxy : (of G (fun i j h => ⇑(f' i j h)) i) x = (of G (fun i j h => ⇑(f' i j h)) i) y
⊢ (of G (fun i j h => ⇑(f' i j h)) i) (x - y) = 0

Next tactic:
rw [(of G _ i).map_sub, hxy, sub_self]
/-- If the maps in the directed system are injective, then the canonical maps
from the components to the direct limits are injective. -/
theorem of_injective [IsDirected ι (· ≤ ·)] [DirectedSystem G fun i j h => f' i j h]
    (hf : ∀ i j hij, Function.Injective (f' i j hij)) (i) :
    Function.Injective (of G (fun i j h => f' i j h) i) := by
  suffices ∀ x, of G (fun i j h => f' i j h) i x = 0 → x = 0 by
    intro x y hxy
    rw [← sub_eq_zero]
    apply this
    rw [(of G _ i).map_sub, hxy, sub_self]
  

Proof state:
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
hf : ∀ (i j : ι) (hij : i ≤ j), Function.Injective ⇑(f' i j hij)
i : ι
⊢ ∀ (x : G i), (of G (fun i j h => ⇑(f' i j h)) i) x = 0 → x = 0

Next tactic:
intro x hx
/-- If the maps in the directed system are injective, then the canonical maps
from the components to the direct limits are injective. -/
theorem of_injective [IsDirected ι (· ≤ ·)] [DirectedSystem G fun i j h => f' i j h]
    (hf : ∀ i j hij, Function.Injective (f' i j hij)) (i) :
    Function.Injective (of G (fun i j h => f' i j h) i) := by
  suffices ∀ x, of G (fun i j h => f' i j h) i x = 0 → x = 0 by
    intro x y hxy
    rw [← sub_eq_zero]
    apply this
    rw [(of G _ i).map_sub, hxy, sub_self]
  intro x hx
  

Proof state:
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
hf : ∀ (i j : ι) (hij : i ≤ j), Function.Injective ⇑(f' i j hij)
i : ι
x : G i
hx : (of G (fun i j h => ⇑(f' i j h)) i) x = 0
⊢ x = 0

Next tactic:
rcases of.zero_exact hx with ⟨j, hij, hfx⟩
/-- If the maps in the directed system are injective, then the canonical maps
from the components to the direct limits are injective. -/
theorem of_injective [IsDirected ι (· ≤ ·)] [DirectedSystem G fun i j h => f' i j h]
    (hf : ∀ i j hij, Function.Injective (f' i j hij)) (i) :
    Function.Injective (of G (fun i j h => f' i j h) i) := by
  suffices ∀ x, of G (fun i j h => f' i j h) i x = 0 → x = 0 by
    intro x y hxy
    rw [← sub_eq_zero]
    apply this
    rw [(of G _ i).map_sub, hxy, sub_self]
  intro x hx
  rcases of.zero_exact hx with ⟨j, hij, hfx⟩
  

Proof state:
case intro.intro
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
hf : ∀ (i j : ι) (hij : i ≤ j), Function.Injective ⇑(f' i j hij)
i : ι
x : G i
hx : (of G (fun i j h => ⇑(f' i j h)) i) x = 0
j : ι
hij : i ≤ j
hfx : (f' i j hij) x = 0
⊢ x = 0

Next tactic:
apply hf i j hij
/-- If the maps in the directed system are injective, then the canonical maps
from the components to the direct limits are injective. -/
theorem of_injective [IsDirected ι (· ≤ ·)] [DirectedSystem G fun i j h => f' i j h]
    (hf : ∀ i j hij, Function.Injective (f' i j hij)) (i) :
    Function.Injective (of G (fun i j h => f' i j h) i) := by
  suffices ∀ x, of G (fun i j h => f' i j h) i x = 0 → x = 0 by
    intro x y hxy
    rw [← sub_eq_zero]
    apply this
    rw [(of G _ i).map_sub, hxy, sub_self]
  intro x hx
  rcases of.zero_exact hx with ⟨j, hij, hfx⟩
  apply hf i j hij
  

Proof state:
case intro.intro.a
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
hf : ∀ (i j : ι) (hij : i ≤ j), Function.Injective ⇑(f' i j hij)
i : ι
x : G i
hx : (of G (fun i j h => ⇑(f' i j h)) i) x = 0
j : ι
hij : i ≤ j
hfx : (f' i j hij) x = 0
⊢ (f' i j hij) x = (f' i j hij) 0

Next tactic:
rw [hfx, (f' i j hij).map_zero]
/-- The universal property of the direct limit: maps from the components to another ring
that respect the directed system structure (i.e. make some diagram commute) give rise
to a unique map out of the direct limit.
-/
def lift : DirectLimit G f →+* P :=
  Ideal.Quotient.lift _ (FreeCommRing.lift fun x : Σi, G i => g x.1 x.2)
    (by
      

Proof state:
R : Type u
inst✝³ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝² : Preorder ι
G : ι → Type w
inst✝¹ : (i : ι) → CommRing (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
P : Type u₁
inst✝ : CommRing P
g : (i : ι) → G i →+* P
Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), (g j) (f i j hij x) = (g i) x
⊢ ∀
    a ∈
      Ideal.span
        {a |
          (∃ i j,
              ∃ (H : i ≤ j),
                ∃ x, FreeCommRing.of { fst := j, snd := f i j H x } - FreeCommRing.of { fst := i, snd := x } = a) ∨
            (∃ i, FreeCommRing.of { fst := i, snd := 1 } - 1 = a) ∨
              (∃ i x y,
                  FreeCommRing.of { fst := i, snd := x + y } -
                      (FreeCommRing.of { fst := i, snd := x } + FreeCommRing.of { fst := i, snd := y }) =
                    a) ∨
                ∃ i x y,
                  FreeCommRing.of { fst := i, snd := x * y } -
                      FreeCommRing.of { fst := i, snd := x } * FreeCommRing.of { fst := i, snd := y } =
                    a},
    (FreeCommRing.lift fun x => (g x.fst) x.snd) a = 0

Next tactic:
suffices Ideal.span _ ≤
          Ideal.comap (FreeCommRing.lift fun x : Σi : ι, G i => g x.fst x.snd) ⊥ by
        intro x hx
        exact (mem_bot P).1 (this hx)