l3lab/ntp-mathlib huggingface dataset:
/-- Let R be an integral domain and f ∈ R[X]. Let s be a finite index set.
Then, a fraction of the form f / ∏ (g i) can be rewritten as q + ∑ (r i) / (g i), where
deg(r i) < deg(g i), provided that the g i are monic and pairwise coprime.
-/
theorem div_eq_quo_add_sum_rem_div (f : R[X]) {ι : Type*} {g : ι → R[X]} {s : Finset ι}
    (hg : ∀ i ∈ s, (g i).Monic) (hcop : Set.Pairwise ↑s fun i j => IsCoprime (g i) (g j)) :
    ∃ (q : R[X]) (r : ι → R[X]),
      (∀ i ∈ s, (r i).degree < (g i).degree) ∧
        ((↑f : K) / ∏ i in s, ↑(g i)) = ↑q + ∑ i in s, (r i : K) / (g i : K) := by
  classical
  induction' s using Finset.induction_on with a b hab Hind f generalizing f
  · refine' ⟨f, fun _ : ι => (0 : R[X]), fun i => _, by 

Proof state:
R : Type
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type
inst✝² : Field K
inst✝¹ : Algebra R[X] K
inst✝ : IsFractionRing R[X] K
ι : Type u_1
g : ι → R[X]
f : R[X]
hg : ∀ i ∈ ∅, Monic (g i)
hcop : Set.Pairwise ↑∅ fun i j => IsCoprime (g i) (g j)
⊢ ↑f / ∏ i in ∅, ↑(g i) = ↑f + ∑ i in ∅, ↑((fun x => 0) i) / ↑(g i)

Next tactic:
simp
/-- Let R be an integral domain and f ∈ R[X]. Let s be a finite index set.
Then, a fraction of the form f / ∏ (g i) can be rewritten as q + ∑ (r i) / (g i), where
deg(r i) < deg(g i), provided that the g i are monic and pairwise coprime.
-/
theorem div_eq_quo_add_sum_rem_div (f : R[X]) {ι : Type*} {g : ι → R[X]} {s : Finset ι}
    (hg : ∀ i ∈ s, (g i).Monic) (hcop : Set.Pairwise ↑s fun i j => IsCoprime (g i) (g j)) :
    ∃ (q : R[X]) (r : ι → R[X]),
      (∀ i ∈ s, (r i).degree < (g i).degree) ∧
        ((↑f : K) / ∏ i in s, ↑(g i)) = ↑q + ∑ i in s, (r i : K) / (g i : K) := by
  classical
  induction' s using Finset.induction_on with a b hab Hind f generalizing f
  · refine' ⟨f, fun _ : ι => (0 : R[X]), fun i => _, by simp⟩
    

Proof state:
case empty
R : Type
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type
inst✝² : Field K
inst✝¹ : Algebra R[X] K
inst✝ : IsFractionRing R[X] K
ι : Type u_1
g : ι → R[X]
f : R[X]
hg : ∀ i ∈ ∅, Monic (g i)
hcop : Set.Pairwise ↑∅ fun i j => IsCoprime (g i) (g j)
i : ι
⊢ i ∈ ∅ → degree ((fun x => 0) i) < degree (g i)

Next tactic:
rintro ⟨⟩
/-- Let R be an integral domain and f ∈ R[X]. Let s be a finite index set.
Then, a fraction of the form f / ∏ (g i) can be rewritten as q + ∑ (r i) / (g i), where
deg(r i) < deg(g i), provided that the g i are monic and pairwise coprime.
-/
theorem div_eq_quo_add_sum_rem_div (f : R[X]) {ι : Type*} {g : ι → R[X]} {s : Finset ι}
    (hg : ∀ i ∈ s, (g i).Monic) (hcop : Set.Pairwise ↑s fun i j => IsCoprime (g i) (g j)) :
    ∃ (q : R[X]) (r : ι → R[X]),
      (∀ i ∈ s, (r i).degree < (g i).degree) ∧
        ((↑f : K) / ∏ i in s, ↑(g i)) = ↑q + ∑ i in s, (r i : K) / (g i : K) := by
  classical
  induction' s using Finset.induction_on with a b hab Hind f generalizing f
  · refine' ⟨f, fun _ : ι => (0 : R[X]), fun i => _, by simp⟩
    rintro ⟨⟩
  

Proof state:
case insert
R : Type
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type
inst✝² : Field K
inst✝¹ : Algebra R[X] K
inst✝ : IsFractionRing R[X] K
ι : Type u_1
g : ι → R[X]
a : ι
b : Finset ι
hab : a ∉ b
Hind :
  ∀ (f : R[X]),
    (∀ i ∈ b, Monic (g i)) →
      (Set.Pairwise ↑b fun i j => IsCoprime (g i) (g j)) →
        ∃ q r, (∀ i ∈ b, degree (r i) < degree (g i)) ∧ ↑f / ∏ i in b, ↑(g i) = ↑q + ∑ i in b, ↑(r i) / ↑(g i)
f : R[X]
hg : ∀ i ∈ insert a b, Monic (g i)
hcop : Set.Pairwise ↑(insert a b) fun i j => IsCoprime (g i) (g j)
⊢ ∃ q r,
    (∀ i ∈ insert a b, degree (r i) < degree (g i)) ∧
      ↑f / ∏ i in insert a b, ↑(g i) = ↑q + ∑ i in insert a b, ↑(r i) / ↑(g i)

Next tactic:
obtain ⟨q₀, r₁, r₂, hdeg₁, _, hf : (↑f : K) / _ = _⟩ :=
    div_eq_quo_add_rem_div_add_rem_div R K f
      (hg a (b.mem_insert_self a) : Monic (g a))
      (monic_prod_of_monic _ _ fun i hi => hg i (Finset.mem_insert_of_mem hi) :
        Monic (∏ i : ι in b, g i))
      (IsCoprime.prod_right fun i hi =>
        hcop (Finset.mem_coe.2 (b.mem_insert_self a))
          (Finset.mem_coe.2 (Finset.mem_insert_of_mem hi)) (by rintro rfl; exact hab hi))
/-- Let R be an integral domain and f ∈ R[X]. Let s be a finite index set.
Then, a fraction of the form f / ∏ (g i) can be rewritten as q + ∑ (r i) / (g i), where
deg(r i) < deg(g i), provided that the g i are monic and pairwise coprime.
-/
theorem div_eq_quo_add_sum_rem_div (f : R[X]) {ι : Type*} {g : ι → R[X]} {s : Finset ι}
    (hg : ∀ i ∈ s, (g i).Monic) (hcop : Set.Pairwise ↑s fun i j => IsCoprime (g i) (g j)) :
    ∃ (q : R[X]) (r : ι → R[X]),
      (∀ i ∈ s, (r i).degree < (g i).degree) ∧
        ((↑f : K) / ∏ i in s, ↑(g i)) = ↑q + ∑ i in s, (r i : K) / (g i : K) := by
  classical
  induction' s using Finset.induction_on with a b hab Hind f generalizing f
  · refine' ⟨f, fun _ : ι => (0 : R[X]), fun i => _, by simp⟩
    rintro ⟨⟩
  obtain ⟨q₀, r₁, r₂, hdeg₁, _, hf : (↑f : K) / _ = _⟩ :=
    div_eq_quo_add_rem_div_add_rem_div R K f
      (hg a (b.mem_insert_self a) : Monic (g a))
      (monic_prod_of_monic _ _ fun i hi => hg i (Finset.mem_insert_of_mem hi) :
        Monic (∏ i : ι in b, g i))
      (IsCoprime.prod_right fun i hi =>
        hcop (Finset.mem_coe.2 (b.mem_insert_self a))
          (Finset.mem_coe.2 (Finset.mem_insert_of_mem hi)) (by 

Proof state:
R : Type
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type
inst✝² : Field K
inst✝¹ : Algebra R[X] K
inst✝ : IsFractionRing R[X] K
ι : Type u_1
g : ι → R[X]
a : ι
b : Finset ι
hab : a ∉ b
Hind :
  ∀ (f : R[X]),
    (∀ i ∈ b, Monic (g i)) →
      (Set.Pairwise ↑b fun i j => IsCoprime (g i) (g j)) →
        ∃ q r, (∀ i ∈ b, degree (r i) < degree (g i)) ∧ ↑f / ∏ i in b, ↑(g i) = ↑q + ∑ i in b, ↑(r i) / ↑(g i)
f : R[X]
hg : ∀ i ∈ insert a b, Monic (g i)
hcop : Set.Pairwise ↑(insert a b) fun i j => IsCoprime (g i) (g j)
i : ι
hi : i ∈ b
⊢ a ≠ i

Next tactic:
rintro rfl
/-- Let R be an integral domain and f ∈ R[X]. Let s be a finite index set.
Then, a fraction of the form f / ∏ (g i) can be rewritten as q + ∑ (r i) / (g i), where
deg(r i) < deg(g i), provided that the g i are monic and pairwise coprime.
-/
theorem div_eq_quo_add_sum_rem_div (f : R[X]) {ι : Type*} {g : ι → R[X]} {s : Finset ι}
    (hg : ∀ i ∈ s, (g i).Monic) (hcop : Set.Pairwise ↑s fun i j => IsCoprime (g i) (g j)) :
    ∃ (q : R[X]) (r : ι → R[X]),
      (∀ i ∈ s, (r i).degree < (g i).degree) ∧
        ((↑f : K) / ∏ i in s, ↑(g i)) = ↑q + ∑ i in s, (r i : K) / (g i : K) := by
  classical
  induction' s using Finset.induction_on with a b hab Hind f generalizing f
  · refine' ⟨f, fun _ : ι => (0 : R[X]), fun i => _, by simp⟩
    rintro ⟨⟩
  obtain ⟨q₀, r₁, r₂, hdeg₁, _, hf : (↑f : K) / _ = _⟩ :=
    div_eq_quo_add_rem_div_add_rem_div R K f
      (hg a (b.mem_insert_self a) : Monic (g a))
      (monic_prod_of_monic _ _ fun i hi => hg i (Finset.mem_insert_of_mem hi) :
        Monic (∏ i : ι in b, g i))
      (IsCoprime.prod_right fun i hi =>
        hcop (Finset.mem_coe.2 (b.mem_insert_self a))
          (Finset.mem_coe.2 (Finset.mem_insert_of_mem hi)) (by rintro rfl; 

Proof state:
R : Type
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type
inst✝² : Field K
inst✝¹ : Algebra R[X] K
inst✝ : IsFractionRing R[X] K
ι : Type u_1
g : ι → R[X]
a : ι
b : Finset ι
hab : a ∉ b
Hind :
  ∀ (f : R[X]),
    (∀ i ∈ b, Monic (g i)) →
      (Set.Pairwise ↑b fun i j => IsCoprime (g i) (g j)) →
        ∃ q r, (∀ i ∈ b, degree (r i) < degree (g i)) ∧ ↑f / ∏ i in b, ↑(g i) = ↑q + ∑ i in b, ↑(r i) / ↑(g i)
f : R[X]
hg : ∀ i ∈ insert a b, Monic (g i)
hcop : Set.Pairwise ↑(insert a b) fun i j => IsCoprime (g i) (g j)
hi : a ∈ b
⊢ False

Next tactic:
exact hab hi
/-- Let R be an integral domain and f ∈ R[X]. Let s be a finite index set.
Then, a fraction of the form f / ∏ (g i) can be rewritten as q + ∑ (r i) / (g i), where
deg(r i) < deg(g i), provided that the g i are monic and pairwise coprime.
-/
theorem div_eq_quo_add_sum_rem_div (f : R[X]) {ι : Type*} {g : ι → R[X]} {s : Finset ι}
    (hg : ∀ i ∈ s, (g i).Monic) (hcop : Set.Pairwise ↑s fun i j => IsCoprime (g i) (g j)) :
    ∃ (q : R[X]) (r : ι → R[X]),
      (∀ i ∈ s, (r i).degree < (g i).degree) ∧
        ((↑f : K) / ∏ i in s, ↑(g i)) = ↑q + ∑ i in s, (r i : K) / (g i : K) := by
  classical
  induction' s using Finset.induction_on with a b hab Hind f generalizing f
  · refine' ⟨f, fun _ : ι => (0 : R[X]), fun i => _, by simp⟩
    rintro ⟨⟩
  obtain ⟨q₀, r₁, r₂, hdeg₁, _, hf : (↑f : K) / _ = _⟩ :=
    div_eq_quo_add_rem_div_add_rem_div R K f
      (hg a (b.mem_insert_self a) : Monic (g a))
      (monic_prod_of_monic _ _ fun i hi => hg i (Finset.mem_insert_of_mem hi) :
        Monic (∏ i : ι in b, g i))
      (IsCoprime.prod_right fun i hi =>
        hcop (Finset.mem_coe.2 (b.mem_insert_self a))
          (Finset.mem_coe.2 (Finset.mem_insert_of_mem hi)) (by rintro rfl; exact hab hi))
  · 

Proof state:
case insert.intro.intro.intro.intro.intro
R : Type
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type
inst✝² : Field K
inst✝¹ : Algebra R[X] K
inst✝ : IsFractionRing R[X] K
ι : Type u_1
g : ι → R[X]
a : ι
b : Finset ι
hab : a ∉ b
Hind :
  ∀ (f : R[X]),
    (∀ i ∈ b, Monic (g i)) →
      (Set.Pairwise ↑b fun i j => IsCoprime (g i) (g j)) →
        ∃ q r, (∀ i ∈ b, degree (r i) < degree (g i)) ∧ ↑f / ∏ i in b, ↑(g i) = ↑q + ∑ i in b, ↑(r i) / ↑(g i)
f : R[X]
hg : ∀ i ∈ insert a b, Monic (g i)
hcop : Set.Pairwise ↑(insert a b) fun i j => IsCoprime (g i) (g j)
q₀ r₁ r₂ : R[X]
hdeg₁ : degree r₁ < degree (g a)
left✝ : degree r₂ < degree (∏ i in b, g i)
hf : ↑f / (↑(g a) * ↑(∏ i in b, g i)) = ↑q₀ + ↑r₁ / ↑(g a) + ↑r₂ / ↑(∏ i in b, g i)
⊢ ∃ q r,
    (∀ i ∈ insert a b, degree (r i) < degree (g i)) ∧
      ↑f / ∏ i in insert a b, ↑(g i) = ↑q + ∑ i in insert a b, ↑(r i) / ↑(g i)

Next tactic:
obtain ⟨q, r, hrdeg, IH⟩ :=
      Hind _ (fun i hi => hg i (Finset.mem_insert_of_mem hi))
        (Set.Pairwise.mono (Finset.coe_subset.2 fun i hi => Finset.mem_insert_of_mem hi) hcop)
/-- Let R be an integral domain and f ∈ R[X]. Let s be a finite index set.
Then, a fraction of the form f / ∏ (g i) can be rewritten as q + ∑ (r i) / (g i), where
deg(r i) < deg(g i), provided that the g i are monic and pairwise coprime.
-/
theorem div_eq_quo_add_sum_rem_div (f : R[X]) {ι : Type*} {g : ι → R[X]} {s : Finset ι}
    (hg : ∀ i ∈ s, (g i).Monic) (hcop : Set.Pairwise ↑s fun i j => IsCoprime (g i) (g j)) :
    ∃ (q : R[X]) (r : ι → R[X]),
      (∀ i ∈ s, (r i).degree < (g i).degree) ∧
        ((↑f : K) / ∏ i in s, ↑(g i)) = ↑q + ∑ i in s, (r i : K) / (g i : K) := by
  classical
  induction' s using Finset.induction_on with a b hab Hind f generalizing f
  · refine' ⟨f, fun _ : ι => (0 : R[X]), fun i => _, by simp⟩
    rintro ⟨⟩
  obtain ⟨q₀, r₁, r₂, hdeg₁, _, hf : (↑f : K) / _ = _⟩ :=
    div_eq_quo_add_rem_div_add_rem_div R K f
      (hg a (b.mem_insert_self a) : Monic (g a))
      (monic_prod_of_monic _ _ fun i hi => hg i (Finset.mem_insert_of_mem hi) :
        Monic (∏ i : ι in b, g i))
      (IsCoprime.prod_right fun i hi =>
        hcop (Finset.mem_coe.2 (b.mem_insert_self a))
          (Finset.mem_coe.2 (Finset.mem_insert_of_mem hi)) (by rintro rfl; exact hab hi))
  · obtain ⟨q, r, hrdeg, IH⟩ :=
      Hind _ (fun i hi => hg i (Finset.mem_insert_of_mem hi))
        (Set.Pairwise.mono (Finset.coe_subset.2 fun i hi => Finset.mem_insert_of_mem hi) hcop)
    

Proof state:
case insert.intro.intro.intro.intro.intro.intro.intro.intro
R : Type
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type
inst✝² : Field K
inst✝¹ : Algebra R[X] K
inst✝ : IsFractionRing R[X] K
ι : Type u_1
g : ι → R[X]
a : ι
b : Finset ι
hab : a ∉ b
Hind :
  ∀ (f : R[X]),
    (∀ i ∈ b, Monic (g i)) →
      (Set.Pairwise ↑b fun i j => IsCoprime (g i) (g j)) →
        ∃ q r, (∀ i ∈ b, degree (r i) < degree (g i)) ∧ ↑f / ∏ i in b, ↑(g i) = ↑q + ∑ i in b, ↑(r i) / ↑(g i)
f : R[X]
hg : ∀ i ∈ insert a b, Monic (g i)
hcop : Set.Pairwise ↑(insert a b) fun i j => IsCoprime (g i) (g j)
q₀ r₁ r₂ : R[X]
hdeg₁ : degree r₁ < degree (g a)
left✝ : degree r₂ < degree (∏ i in b, g i)
hf : ↑f / (↑(g a) * ↑(∏ i in b, g i)) = ↑q₀ + ↑r₁ / ↑(g a) + ↑r₂ / ↑(∏ i in b, g i)
q : R[X]
r : ι → R[X]
hrdeg : ∀ i ∈ b, degree (r i) < degree (g i)
IH : ↑?m.67289 / ∏ i in b, ↑(g i) = ↑q + ∑ i in b, ↑(r i) / ↑(g i)
⊢ ∃ q r,
    (∀ i ∈ insert a b, degree (r i) < degree (g i)) ∧
      ↑f / ∏ i in insert a b, ↑(g i) = ↑q + ∑ i in insert a b, ↑(r i) / ↑(g i)

Next tactic:
refine ⟨q₀ + q, fun i => if i = a then r₁ else r i, ?_, ?_⟩
/-- Let R be an integral domain and f ∈ R[X]. Let s be a finite index set.
Then, a fraction of the form f / ∏ (g i) can be rewritten as q + ∑ (r i) / (g i), where
deg(r i) < deg(g i), provided that the g i are monic and pairwise coprime.
-/
theorem div_eq_quo_add_sum_rem_div (f : R[X]) {ι : Type*} {g : ι → R[X]} {s : Finset ι}
    (hg : ∀ i ∈ s, (g i).Monic) (hcop : Set.Pairwise ↑s fun i j => IsCoprime (g i) (g j)) :
    ∃ (q : R[X]) (r : ι → R[X]),
      (∀ i ∈ s, (r i).degree < (g i).degree) ∧
        ((↑f : K) / ∏ i in s, ↑(g i)) = ↑q + ∑ i in s, (r i : K) / (g i : K) := by
  classical
  induction' s using Finset.induction_on with a b hab Hind f generalizing f
  · refine' ⟨f, fun _ : ι => (0 : R[X]), fun i => _, by simp⟩
    rintro ⟨⟩
  obtain ⟨q₀, r₁, r₂, hdeg₁, _, hf : (↑f : K) / _ = _⟩ :=
    div_eq_quo_add_rem_div_add_rem_div R K f
      (hg a (b.mem_insert_self a) : Monic (g a))
      (monic_prod_of_monic _ _ fun i hi => hg i (Finset.mem_insert_of_mem hi) :
        Monic (∏ i : ι in b, g i))
      (IsCoprime.prod_right fun i hi =>
        hcop (Finset.mem_coe.2 (b.mem_insert_self a))
          (Finset.mem_coe.2 (Finset.mem_insert_of_mem hi)) (by rintro rfl; exact hab hi))
  · obtain ⟨q, r, hrdeg, IH⟩ :=
      Hind _ (fun i hi => hg i (Finset.mem_insert_of_mem hi))
        (Set.Pairwise.mono (Finset.coe_subset.2 fun i hi => Finset.mem_insert_of_mem hi) hcop)
    refine ⟨q₀ + q, fun i => if i = a then r₁ else r i, ?_, ?_⟩
    · 

Proof state:
case insert.intro.intro.intro.intro.intro.intro.intro.intro.refine_1
R : Type
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type
inst✝² : Field K
inst✝¹ : Algebra R[X] K
inst✝ : IsFractionRing R[X] K
ι : Type u_1
g : ι → R[X]
a : ι
b : Finset ι
hab : a ∉ b
Hind :
  ∀ (f : R[X]),
    (∀ i ∈ b, Monic (g i)) →
      (Set.Pairwise ↑b fun i j => IsCoprime (g i) (g j)) →
        ∃ q r, (∀ i ∈ b, degree (r i) < degree (g i)) ∧ ↑f / ∏ i in b, ↑(g i) = ↑q + ∑ i in b, ↑(r i) / ↑(g i)
f : R[X]
hg : ∀ i ∈ insert a b, Monic (g i)
hcop : Set.Pairwise ↑(insert a b) fun i j => IsCoprime (g i) (g j)
q₀ r₁ r₂ : R[X]
hdeg₁ : degree r₁ < degree (g a)
left✝ : degree r₂ < degree (∏ i in b, g i)
hf : ↑f / (↑(g a) * ↑(∏ i in b, g i)) = ↑q₀ + ↑r₁ / ↑(g a) + ↑r₂ / ↑(∏ i in b, g i)
q : R[X]
r : ι → R[X]
hrdeg : ∀ i ∈ b, degree (r i) < degree (g i)
IH : ↑?m.67289 / ∏ i in b, ↑(g i) = ↑q + ∑ i in b, ↑(r i) / ↑(g i)
⊢ ∀ i ∈ insert a b, degree ((fun i => if i = a then r₁ else r i) i) < degree (g i)

Next tactic:
intro i
/-- Let R be an integral domain and f ∈ R[X]. Let s be a finite index set.
Then, a fraction of the form f / ∏ (g i) can be rewritten as q + ∑ (r i) / (g i), where
deg(r i) < deg(g i), provided that the g i are monic and pairwise coprime.
-/
theorem div_eq_quo_add_sum_rem_div (f : R[X]) {ι : Type*} {g : ι → R[X]} {s : Finset ι}
    (hg : ∀ i ∈ s, (g i).Monic) (hcop : Set.Pairwise ↑s fun i j => IsCoprime (g i) (g j)) :
    ∃ (q : R[X]) (r : ι → R[X]),
      (∀ i ∈ s, (r i).degree < (g i).degree) ∧
        ((↑f : K) / ∏ i in s, ↑(g i)) = ↑q + ∑ i in s, (r i : K) / (g i : K) := by
  classical
  induction' s using Finset.induction_on with a b hab Hind f generalizing f
  · refine' ⟨f, fun _ : ι => (0 : R[X]), fun i => _, by simp⟩
    rintro ⟨⟩
  obtain ⟨q₀, r₁, r₂, hdeg₁, _, hf : (↑f : K) / _ = _⟩ :=
    div_eq_quo_add_rem_div_add_rem_div R K f
      (hg a (b.mem_insert_self a) : Monic (g a))
      (monic_prod_of_monic _ _ fun i hi => hg i (Finset.mem_insert_of_mem hi) :
        Monic (∏ i : ι in b, g i))
      (IsCoprime.prod_right fun i hi =>
        hcop (Finset.mem_coe.2 (b.mem_insert_self a))
          (Finset.mem_coe.2 (Finset.mem_insert_of_mem hi)) (by rintro rfl; exact hab hi))
  · obtain ⟨q, r, hrdeg, IH⟩ :=
      Hind _ (fun i hi => hg i (Finset.mem_insert_of_mem hi))
        (Set.Pairwise.mono (Finset.coe_subset.2 fun i hi => Finset.mem_insert_of_mem hi) hcop)
    refine ⟨q₀ + q, fun i => if i = a then r₁ else r i, ?_, ?_⟩
    · intro i
      

Proof state:
case insert.intro.intro.intro.intro.intro.intro.intro.intro.refine_1
R : Type
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type
inst✝² : Field K
inst✝¹ : Algebra R[X] K
inst✝ : IsFractionRing R[X] K
ι : Type u_1
g : ι → R[X]
a : ι
b : Finset ι
hab : a ∉ b
Hind :
  ∀ (f : R[X]),
    (∀ i ∈ b, Monic (g i)) →
      (Set.Pairwise ↑b fun i j => IsCoprime (g i) (g j)) →
        ∃ q r, (∀ i ∈ b, degree (r i) < degree (g i)) ∧ ↑f / ∏ i in b, ↑(g i) = ↑q + ∑ i in b, ↑(r i) / ↑(g i)
f : R[X]
hg : ∀ i ∈ insert a b, Monic (g i)
hcop : Set.Pairwise ↑(insert a b) fun i j => IsCoprime (g i) (g j)
q₀ r₁ r₂ : R[X]
hdeg₁ : degree r₁ < degree (g a)
left✝ : degree r₂ < degree (∏ i in b, g i)
hf : ↑f / (↑(g a) * ↑(∏ i in b, g i)) = ↑q₀ + ↑r₁ / ↑(g a) + ↑r₂ / ↑(∏ i in b, g i)
q : R[X]
r : ι → R[X]
hrdeg : ∀ i ∈ b, degree (r i) < degree (g i)
IH : ↑?m.67289 / ∏ i in b, ↑(g i) = ↑q + ∑ i in b, ↑(r i) / ↑(g i)
i : ι
⊢ i ∈ insert a b → degree ((fun i => if i = a then r₁ else r i) i) < degree (g i)

Next tactic:
dsimp only
/-- Let R be an integral domain and f ∈ R[X]. Let s be a finite index set.
Then, a fraction of the form f / ∏ (g i) can be rewritten as q + ∑ (r i) / (g i), where
deg(r i) < deg(g i), provided that the g i are monic and pairwise coprime.
-/
theorem div_eq_quo_add_sum_rem_div (f : R[X]) {ι : Type*} {g : ι → R[X]} {s : Finset ι}
    (hg : ∀ i ∈ s, (g i).Monic) (hcop : Set.Pairwise ↑s fun i j => IsCoprime (g i) (g j)) :
    ∃ (q : R[X]) (r : ι → R[X]),
      (∀ i ∈ s, (r i).degree < (g i).degree) ∧
        ((↑f : K) / ∏ i in s, ↑(g i)) = ↑q + ∑ i in s, (r i : K) / (g i : K) := by
  classical
  induction' s using Finset.induction_on with a b hab Hind f generalizing f
  · refine' ⟨f, fun _ : ι => (0 : R[X]), fun i => _, by simp⟩
    rintro ⟨⟩
  obtain ⟨q₀, r₁, r₂, hdeg₁, _, hf : (↑f : K) / _ = _⟩ :=
    div_eq_quo_add_rem_div_add_rem_div R K f
      (hg a (b.mem_insert_self a) : Monic (g a))
      (monic_prod_of_monic _ _ fun i hi => hg i (Finset.mem_insert_of_mem hi) :
        Monic (∏ i : ι in b, g i))
      (IsCoprime.prod_right fun i hi =>
        hcop (Finset.mem_coe.2 (b.mem_insert_self a))
          (Finset.mem_coe.2 (Finset.mem_insert_of_mem hi)) (by rintro rfl; exact hab hi))
  · obtain ⟨q, r, hrdeg, IH⟩ :=
      Hind _ (fun i hi => hg i (Finset.mem_insert_of_mem hi))
        (Set.Pairwise.mono (Finset.coe_subset.2 fun i hi => Finset.mem_insert_of_mem hi) hcop)
    refine ⟨q₀ + q, fun i => if i = a then r₁ else r i, ?_, ?_⟩
    · intro i
      dsimp only
      

Proof state:
case insert.intro.intro.intro.intro.intro.intro.intro.intro.refine_1
R : Type
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type
inst✝² : Field K
inst✝¹ : Algebra R[X] K
inst✝ : IsFractionRing R[X] K
ι : Type u_1
g : ι → R[X]
a : ι
b : Finset ι
hab : a ∉ b
Hind :
  ∀ (f : R[X]),
    (∀ i ∈ b, Monic (g i)) →
      (Set.Pairwise ↑b fun i j => IsCoprime (g i) (g j)) →
        ∃ q r, (∀ i ∈ b, degree (r i) < degree (g i)) ∧ ↑f / ∏ i in b, ↑(g i) = ↑q + ∑ i in b, ↑(r i) / ↑(g i)
f : R[X]
hg : ∀ i ∈ insert a b, Monic (g i)
hcop : Set.Pairwise ↑(insert a b) fun i j => IsCoprime (g i) (g j)
q₀ r₁ r₂ : R[X]
hdeg₁ : degree r₁ < degree (g a)
left✝ : degree r₂ < degree (∏ i in b, g i)
hf : ↑f / (↑(g a) * ↑(∏ i in b, g i)) = ↑q₀ + ↑r₁ / ↑(g a) + ↑r₂ / ↑(∏ i in b, g i)
q : R[X]
r : ι → R[X]
hrdeg : ∀ i ∈ b, degree (r i) < degree (g i)
IH : ↑?m.67289 / ∏ i in b, ↑(g i) = ↑q + ∑ i in b, ↑(r i) / ↑(g i)
i : ι
⊢ i ∈ insert a b → degree (if i = a then r₁ else r i) < degree (g i)

Next tactic:
split_ifs with h1
/-- Let R be an integral domain and f ∈ R[X]. Let s be a finite index set.
Then, a fraction of the form f / ∏ (g i) can be rewritten as q + ∑ (r i) / (g i), where
deg(r i) < deg(g i), provided that the g i are monic and pairwise coprime.
-/
theorem div_eq_quo_add_sum_rem_div (f : R[X]) {ι : Type*} {g : ι → R[X]} {s : Finset ι}
    (hg : ∀ i ∈ s, (g i).Monic) (hcop : Set.Pairwise ↑s fun i j => IsCoprime (g i) (g j)) :
    ∃ (q : R[X]) (r : ι → R[X]),
      (∀ i ∈ s, (r i).degree < (g i).degree) ∧
        ((↑f : K) / ∏ i in s, ↑(g i)) = ↑q + ∑ i in s, (r i : K) / (g i : K) := by
  classical
  induction' s using Finset.induction_on with a b hab Hind f generalizing f
  · refine' ⟨f, fun _ : ι => (0 : R[X]), fun i => _, by simp⟩
    rintro ⟨⟩
  obtain ⟨q₀, r₁, r₂, hdeg₁, _, hf : (↑f : K) / _ = _⟩ :=
    div_eq_quo_add_rem_div_add_rem_div R K f
      (hg a (b.mem_insert_self a) : Monic (g a))
      (monic_prod_of_monic _ _ fun i hi => hg i (Finset.mem_insert_of_mem hi) :
        Monic (∏ i : ι in b, g i))
      (IsCoprime.prod_right fun i hi =>
        hcop (Finset.mem_coe.2 (b.mem_insert_self a))
          (Finset.mem_coe.2 (Finset.mem_insert_of_mem hi)) (by rintro rfl; exact hab hi))
  · obtain ⟨q, r, hrdeg, IH⟩ :=
      Hind _ (fun i hi => hg i (Finset.mem_insert_of_mem hi))
        (Set.Pairwise.mono (Finset.coe_subset.2 fun i hi => Finset.mem_insert_of_mem hi) hcop)
    refine ⟨q₀ + q, fun i => if i = a then r₁ else r i, ?_, ?_⟩
    · intro i
      dsimp only
      split_ifs with h1
      · 

Proof state:
case pos
R : Type
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type
inst✝² : Field K
inst✝¹ : Algebra R[X] K
inst✝ : IsFractionRing R[X] K
ι : Type u_1
g : ι → R[X]
a : ι
b : Finset ι
hab : a ∉ b
Hind :
  ∀ (f : R[X]),
    (∀ i ∈ b, Monic (g i)) →
      (Set.Pairwise ↑b fun i j => IsCoprime (g i) (g j)) →
        ∃ q r, (∀ i ∈ b, degree (r i) < degree (g i)) ∧ ↑f / ∏ i in b, ↑(g i) = ↑q + ∑ i in b, ↑(r i) / ↑(g i)
f : R[X]
hg : ∀ i ∈ insert a b, Monic (g i)
hcop : Set.Pairwise ↑(insert a b) fun i j => IsCoprime (g i) (g j)
q₀ r₁ r₂ : R[X]
hdeg₁ : degree r₁ < degree (g a)
left✝ : degree r₂ < degree (∏ i in b, g i)
hf : ↑f / (↑(g a) * ↑(∏ i in b, g i)) = ↑q₀ + ↑r₁ / ↑(g a) + ↑r₂ / ↑(∏ i in b, g i)
q : R[X]
r : ι → R[X]
hrdeg : ∀ i ∈ b, degree (r i) < degree (g i)
IH : ↑?m.67289 / ∏ i in b, ↑(g i) = ↑q + ∑ i in b, ↑(r i) / ↑(g i)
i : ι
h1 : i = a
⊢ i ∈ insert a b → degree r₁ < degree (g i)

Next tactic:
cases h1