Theorem: exists_sum_eq_one_iff_pairwise_coprime
File: Mathlib/RingTheory/Coprime/Lemmas.lean

tactic: refine' h.cons_induction _ _
state_before: R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t : Finset I
inst✝ : DecidableEq I
h : Finset.Nonempty t
⊢ (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)

tactic: intro a t hat h ih
state_before: case refine'_2
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t : Finset I
inst✝ : DecidableEq I
h : Finset.Nonempty t
⊢ ∀ ⦃a : I⦄ (s_1 : Finset I) (h : ¬a ∈ s_1),
    Finset.Nonempty s_1 →
      ((∃ μ, ∑ i in s_1, μ i * ∏ j in s_1 \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)) →
        ((∃ μ, ∑ i in cons a s_1 h, μ i * ∏ j in cons a s_1 h \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i))

tactic: rw [pairwise_cons']
state_before: case refine'_2
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
⊢ (∃ μ, ∑ i in cons a t hat, μ i * ∏ j in cons a t hat \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)

tactic: have mem : ∀ x ∈ t, a ∈ insert a t \ {x} := fun x hx ↦ by
  rw [mem_sdiff, mem_singleton]
  refine ⟨mem_insert_self _ _, fun ha ↦ hat (ha ▸ hx)⟩
state_before: case refine'_2
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
⊢ (∃ μ, ∑ i in cons a t hat, μ i * ∏ j in cons a t hat \ {i}, s j = 1) ↔
    Pairwise (IsCoprime on fun a => s ↑a) ∧ ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)

tactic: constructor
state_before: case refine'_2
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
⊢ (∃ μ, ∑ i in cons a t hat, μ i * ∏ j in cons a t hat \ {i}, s j = 1) ↔
    Pairwise (IsCoprime on fun a => s ↑a) ∧ ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)

tactic: simp only [sum_singleton, Finset.sdiff_self, prod_empty, mul_one, exists_apply_eq,
           Pairwise, Ne.def, true_iff_iff]
state_before: case refine'_1
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t : Finset I
inst✝ : DecidableEq I
h : Finset.Nonempty t
⊢ ∀ (a : I), (∃ μ, ∑ i in {a}, μ i * ∏ j in {a} \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)

tactic: rintro a ⟨i, hi⟩ ⟨j, hj⟩ h
state_before: case refine'_1
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t : Finset I
inst✝ : DecidableEq I
h : Finset.Nonempty t
⊢ ∀ (a : I) ⦃i j : { x // x ∈ {a} }⦄, ¬i = j → (IsCoprime on fun i => s ↑i) i j

tactic: rw [Finset.mem_singleton] at hi hj
state_before: case refine'_1.mk.mk
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t
a i : I
hi : i ∈ {a}
j : I
hj : j ∈ {a}
h : ¬{ val := i, property := hi } = { val := j, property := hj }
⊢ (IsCoprime on fun i => s ↑i) { val := i, property := hi } { val := j, property := hj }

tactic: simp [hi, hj] at h
state_before: case refine'_1.mk.mk
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t
a i : I
hi✝ : i ∈ {a}
hi : i = a
j : I
hj✝ : j ∈ {a}
hj : j = a
h : ¬{ val := i, property := hi✝ } = { val := j, property := hj✝ }
⊢ (IsCoprime on fun i => s ↑i) { val := i, property := hi✝ } { val := j, property := hj✝ }

tactic: rw [mem_sdiff, mem_singleton]
state_before: R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
x : I
hx : x ∈ t
⊢ a ∈ insert a t \ {x}

tactic: refine ⟨mem_insert_self _ _, fun ha ↦ hat (ha ▸ hx)⟩
state_before: R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
x : I
hx : x ∈ t
⊢ a ∈ insert a t ∧ ¬a = x

tactic: rintro ⟨μ, hμ⟩
state_before: case refine'_2.mp
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
⊢ (∃ μ, ∑ i in cons a t hat, μ i * ∏ j in cons a t hat \ {i}, s j = 1) →
    Pairwise (IsCoprime on fun a => s ↑a) ∧ ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)

tactic: rw [sum_cons, cons_eq_insert, sdiff_singleton_eq_erase, erase_insert hat] at hμ
state_before: case refine'_2.mp.intro
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ : ∑ i in cons a t hat, μ i * ∏ j in cons a t hat \ {i}, s j = 1
⊢ Pairwise (IsCoprime on fun a => s ↑a) ∧ ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)

tactic: refine' ⟨ih.mp ⟨Pi.single h.choose (μ a * s h.choose) + μ * fun _ ↦ s a, ?_⟩, fun b hb ↦ ?_⟩
state_before: case refine'_2.mp.intro
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ : μ a * ∏ j in t, s j + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
⊢ Pairwise (IsCoprime on fun a => s ↑a) ∧ ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)

tactic: rw [prod_eq_mul_prod_diff_singleton h.choose_spec, ← mul_assoc, ←
  @if_pos _ _ h.choose_spec R (_ * _) 0, ← sum_pi_single', ← sum_add_distrib] at hμ
state_before: case refine'_2.mp.intro.refine'_1
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ : μ a * ∏ j in t, s j + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
⊢ ∑ i in t, (Pi.single (Exists.choose h) (μ a * s (Exists.choose h)) + μ * fun x => s a) i * ∏ j in t \ {i}, s j = 1

tactic: rw [← hμ, sum_congr rfl]
state_before: case refine'_2.mp.intro.refine'_1
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝¹ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ✝ : μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
hμ :
  ∑ x in t,
      (Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
        μ x * ∏ j in insert a t \ {x}, s j) =
    1
⊢ ∑ i in t, (Pi.single (Exists.choose h) (μ a * s (Exists.choose h)) + μ * fun x => s a) i * ∏ j in t \ {i}, s j = 1

tactic: intro x hx
state_before: case refine'_2.mp.intro.refine'_1
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝¹ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ✝ : μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
hμ :
  ∑ x in t,
      (Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
        μ x * ∏ j in insert a t \ {x}, s j) =
    1
⊢ ∀ (x : I),
    x ∈ t →
      (Pi.single (Exists.choose h) (μ a * s (Exists.choose h)) + μ * fun x => s a) x * ∏ j in t \ {x}, s j =
        Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
          μ x * ∏ j in insert a t \ {x}, s j

tactic: dsimp
state_before: case refine'_2.mp.intro.refine'_1
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝¹ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ✝ : μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
hμ :
  ∑ x in t,
      (Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
        μ x * ∏ j in insert a t \ {x}, s j) =
    1
x : I
hx : x ∈ t
⊢ (Pi.single (Exists.choose h) (μ a * s (Exists.choose h)) + μ * fun x => s a) x * ∏ j in t \ {x}, s j =
    Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
      μ x * ∏ j in insert a t \ {x}, s j

tactic: rw [add_mul]
state_before: case refine'_2.mp.intro.refine'_1
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝¹ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ✝ : μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
hμ :
  ∑ x in t,
      (Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
        μ x * ∏ j in insert a t \ {x}, s j) =
    1
x : I
hx : x ∈ t
⊢ (Pi.single (Exists.choose h) (μ a * s (Exists.choose h)) x + μ x * s a) * ∏ j in t \ {x}, s j =
    Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
      μ x * ∏ j in insert a t \ {x}, s j

tactic: congr 1
state_before: case refine'_2.mp.intro.refine'_1
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝¹ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ✝ : μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
hμ :
  ∑ x in t,
      (Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
        μ x * ∏ j in insert a t \ {x}, s j) =
    1
x : I
hx : x ∈ t
⊢ Pi.single (Exists.choose h) (μ a * s (Exists.choose h)) x * ∏ j in t \ {x}, s j + μ x * s a * ∏ j in t \ {x}, s j =
    Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
      μ x * ∏ j in insert a t \ {x}, s j

tactic: by_cases hx : x = h.choose
state_before: case refine'_2.mp.intro.refine'_1.e_a
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝¹ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ✝ : μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
hμ :
  ∑ x in t,
      (Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
        μ x * ∏ j in insert a t \ {x}, s j) =
    1
x : I
hx : x ∈ t
⊢ Pi.single (Exists.choose h) (μ a * s (Exists.choose h)) x * ∏ j in t \ {x}, s j =
    Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x

tactic: rw [hx, Pi.single_eq_same, Pi.single_eq_same]
state_before: case pos
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝¹ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ✝ : μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
hμ :
  ∑ x in t,
      (Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
        μ x * ∏ j in insert a t \ {x}, s j) =
    1
x : I
hx✝ : x ∈ t
hx : x = Exists.choose h
⊢ Pi.single (Exists.choose h) (μ a * s (Exists.choose h)) x * ∏ j in t \ {x}, s j =
    Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x

tactic: rw [Pi.single_eq_of_ne hx, Pi.single_eq_of_ne hx, zero_mul]
state_before: case neg
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝¹ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ✝ : μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
hμ :
  ∑ x in t,
      (Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
        μ x * ∏ j in insert a t \ {x}, s j) =
    1
x : I
hx✝ : x ∈ t
hx : ¬x = Exists.choose h
⊢ Pi.single (Exists.choose h) (μ a * s (Exists.choose h)) x * ∏ j in t \ {x}, s j =
    Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x

tactic: rw [mul_assoc]
state_before: case refine'_2.mp.intro.refine'_1.e_a
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝¹ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ✝ : μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
hμ :
  ∑ x in t,
      (Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
        μ x * ∏ j in insert a t \ {x}, s j) =
    1
x : I
hx : x ∈ t
⊢ μ x * s a * ∏ j in t \ {x}, s j = μ x * ∏ j in insert a t \ {x}, s j

tactic: congr
state_before: case refine'_2.mp.intro.refine'_1.e_a
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝¹ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ✝ : μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
hμ :
  ∑ x in t,
      (Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
        μ x * ∏ j in insert a t \ {x}, s j) =
    1
x : I
hx : x ∈ t
⊢ μ x * (s a * ∏ j in t \ {x}, s j) = μ x * ∏ j in insert a t \ {x}, s j

tactic: rw [prod_eq_prod_diff_singleton_mul (mem x hx) _, mul_comm]
state_before: case refine'_2.mp.intro.refine'_1.e_a.e_a
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝¹ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ✝ : μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
hμ :
  ∑ x in t,
      (Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
        μ x * ∏ j in insert a t \ {x}, s j) =
    1
x : I
hx : x ∈ t
⊢ s a * ∏ j in t \ {x}, s j = ∏ j in insert a t \ {x}, s j

tactic: congr 2
state_before: case refine'_2.mp.intro.refine'_1.e_a.e_a
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝¹ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ✝ : μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
hμ :
  ∑ x in t,
      (Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
        μ x * ∏ j in insert a t \ {x}, s j) =
    1
x : I
hx : x ∈ t
⊢ (∏ j in t \ {x}, s j) * s a = (∏ x in (insert a t \ {x}) \ {a}, s x) * s a

tactic: rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]
state_before: case refine'_2.mp.intro.refine'_1.e_a.e_a.e_a.e_s
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝¹ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ✝ : μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
hμ :
  ∑ x in t,
      (Pi.single (Exists.choose h) (μ a * s (Exists.choose h) * ∏ x in t \ {Exists.choose h}, s x) x +
        μ x * ∏ j in insert a t \ {x}, s j) =
    1
x : I
hx : x ∈ t
⊢ t \ {x} = (insert a t \ {x}) \ {a}

tactic: have : IsCoprime (s b) (s a) :=
  ⟨μ a * ∏ i in t \ {b}, s i, ∑ i in t, μ i * ∏ j in t \ {i}, s j, ?_⟩
state_before: case refine'_2.mp.intro.refine'_2
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ : μ a * ∏ j in t, s j + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
b : I
hb : b ∈ t
⊢ IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)

tactic: rw [mul_assoc, ← prod_eq_prod_diff_singleton_mul hb, sum_mul, ← hμ, sum_congr rfl]
state_before: case refine'_2.mp.intro.refine'_2.refine_1
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ : μ a * ∏ j in t, s j + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
b : I
hb : b ∈ t
⊢ (μ a * ∏ i in t \ {b}, s i) * s b + (∑ i in t, μ i * ∏ j in t \ {i}, s j) * s a = 1

tactic: intro x hx
state_before: case refine'_2.mp.intro.refine'_2.refine_1
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ : μ a * ∏ j in t, s j + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
b : I
hb : b ∈ t
⊢ ∀ (x : I), x ∈ t → (μ x * ∏ j in t \ {x}, s j) * s a = μ x * ∏ j in insert a t \ {x}, s j

tactic: rw [mul_assoc]
state_before: case refine'_2.mp.intro.refine'_2.refine_1
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ : μ a * ∏ j in t, s j + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
b : I
hb : b ∈ t
x : I
hx : x ∈ t
⊢ (μ x * ∏ j in t \ {x}, s j) * s a = μ x * ∏ j in insert a t \ {x}, s j

tactic: congr
state_before: case refine'_2.mp.intro.refine'_2.refine_1
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ : μ a * ∏ j in t, s j + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
b : I
hb : b ∈ t
x : I
hx : x ∈ t
⊢ μ x * ((∏ j in t \ {x}, s j) * s a) = μ x * ∏ j in insert a t \ {x}, s j

tactic: rw [prod_eq_prod_diff_singleton_mul (mem x hx) _]
state_before: case refine'_2.mp.intro.refine'_2.refine_1.e_a
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ : μ a * ∏ j in t, s j + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
b : I
hb : b ∈ t
x : I
hx : x ∈ t
⊢ (∏ j in t \ {x}, s j) * s a = ∏ j in insert a t \ {x}, s j

tactic: congr 2
state_before: case refine'_2.mp.intro.refine'_2.refine_1.e_a
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ : μ a * ∏ j in t, s j + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
b : I
hb : b ∈ t
x : I
hx : x ∈ t
⊢ (∏ j in t \ {x}, s j) * s a = (∏ x in (insert a t \ {x}) \ {a}, s x) * s a

tactic: rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]
state_before: case refine'_2.mp.intro.refine'_2.refine_1.e_a.e_a.e_s
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ : μ a * ∏ j in t, s j + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
b : I
hb : b ∈ t
x : I
hx : x ∈ t
⊢ t \ {x} = (insert a t \ {x}) \ {a}

tactic: exact ⟨this.symm, this⟩
state_before: case refine'_2.mp.intro.refine'_2.refine_2
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
μ : I → R
hμ✝ : μ a * ∏ j in cons a t hat \ {a}, s j + ∑ x in t, μ x * ∏ j in cons a t hat \ {x}, s j = 1
hμ : μ a * ∏ j in t, s j + ∑ x in t, μ x * ∏ j in insert a t \ {x}, s j = 1
b : I
hb : b ∈ t
this : IsCoprime (s b) (s a)
⊢ IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)

tactic: rintro ⟨hs, Hb⟩
state_before: case refine'_2.mpr
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
⊢ (Pairwise (IsCoprime on fun a => s ↑a) ∧ ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)) →
    ∃ μ, ∑ i in cons a t hat, μ i * ∏ j in cons a t hat \ {i}, s j = 1

tactic: obtain ⟨μ, hμ⟩ := ih.mpr hs
state_before: case refine'_2.mpr.intro
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
⊢ ∃ μ, ∑ i in cons a t hat, μ i * ∏ j in cons a t hat \ {i}, s j = 1

tactic: obtain ⟨u, v, huv⟩ := IsCoprime.prod_left fun b hb ↦ (Hb b hb).right
state_before: case refine'_2.mpr.intro.intro
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
μ : I → R
hμ : ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1
⊢ ∃ μ, ∑ i in cons a t hat, μ i * ∏ j in cons a t hat \ {i}, s j = 1

tactic: use fun i ↦ if i = a then u else v * μ i
state_before: case refine'_2.mpr.intro.intro.intro.intro
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
μ : I → R
hμ : ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1
u v : R
huv : u * ∏ i in t, s i + v * s a = 1
⊢ ∃ μ, ∑ i in cons a t hat, μ i * ∏ j in cons a t hat \ {i}, s j = 1

tactic: have hμ' : (∑ i in t, v * ((μ i * ∏ j in t \ {i}, s j) * s a)) = v * s a := by
  rw [← mul_sum, ← sum_mul, hμ, one_mul]
state_before: case refine'_2.mpr.intro.intro.intro.intro
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
μ : I → R
hμ : ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1
u v : R
huv : u * ∏ i in t, s i + v * s a = 1
⊢ ∑ i in cons a t hat, (fun i => if i = a then u else v * μ i) i * ∏ j in cons a t hat \ {i}, s j = 1

tactic: rw [sum_cons, cons_eq_insert, sdiff_singleton_eq_erase, erase_insert hat]
state_before: case refine'_2.mpr.intro.intro.intro.intro
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
μ : I → R
hμ : ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1
u v : R
huv : u * ∏ i in t, s i + v * s a = 1
hμ' : ∑ i in t, v * ((μ i * ∏ j in t \ {i}, s j) * s a) = v * s a
⊢ ∑ i in cons a t hat, (fun i => if i = a then u else v * μ i) i * ∏ j in cons a t hat \ {i}, s j = 1

tactic: dsimp
state_before: case refine'_2.mpr.intro.intro.intro.intro
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
μ : I → R
hμ : ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1
u v : R
huv : u * ∏ i in t, s i + v * s a = 1
hμ' : ∑ i in t, v * ((μ i * ∏ j in t \ {i}, s j) * s a) = v * s a
⊢ (fun i => if i = a then u else v * μ i) a * ∏ j in t, s j +
      ∑ x in t, (fun i => if i = a then u else v * μ i) x * ∏ j in insert a t \ {x}, s j =
    1

tactic: rw [if_pos rfl, ← huv, ← hμ', sum_congr rfl]
state_before: case refine'_2.mpr.intro.intro.intro.intro
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
μ : I → R
hμ : ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1
u v : R
huv : u * ∏ i in t, s i + v * s a = 1
hμ' : ∑ i in t, v * ((μ i * ∏ j in t \ {i}, s j) * s a) = v * s a
⊢ (if a = a then u else v * μ a) * ∏ j in t, s j +
      ∑ x in t, (if x = a then u else v * μ x) * ∏ j in insert a t \ {x}, s j =
    1

tactic: intro x hx
state_before: case refine'_2.mpr.intro.intro.intro.intro
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
μ : I → R
hμ : ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1
u v : R
huv : u * ∏ i in t, s i + v * s a = 1
hμ' : ∑ i in t, v * ((μ i * ∏ j in t \ {i}, s j) * s a) = v * s a
⊢ ∀ (x : I),
    x ∈ t → (if x = a then u else v * μ x) * ∏ j in insert a t \ {x}, s j = v * ((μ x * ∏ j in t \ {x}, s j) * s a)

tactic: rw [mul_assoc, if_neg fun ha : x = a ↦ hat (ha.casesOn hx)]
state_before: case refine'_2.mpr.intro.intro.intro.intro
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
μ : I → R
hμ : ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1
u v : R
huv : u * ∏ i in t, s i + v * s a = 1
hμ' : ∑ i in t, v * ((μ i * ∏ j in t \ {i}, s j) * s a) = v * s a
x : I
hx : x ∈ t
⊢ (if x = a then u else v * μ x) * ∏ j in insert a t \ {x}, s j = v * ((μ x * ∏ j in t \ {x}, s j) * s a)

tactic: rw [mul_assoc]
state_before: case refine'_2.mpr.intro.intro.intro.intro
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
μ : I → R
hμ : ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1
u v : R
huv : u * ∏ i in t, s i + v * s a = 1
hμ' : ∑ i in t, v * ((μ i * ∏ j in t \ {i}, s j) * s a) = v * s a
x : I
hx : x ∈ t
⊢ v * μ x * ∏ j in insert a t \ {x}, s j = v * (μ x * ((∏ j in t \ {x}, s j) * s a))

tactic: congr
state_before: case refine'_2.mpr.intro.intro.intro.intro
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
μ : I → R
hμ : ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1
u v : R
huv : u * ∏ i in t, s i + v * s a = 1
hμ' : ∑ i in t, v * ((μ i * ∏ j in t \ {i}, s j) * s a) = v * s a
x : I
hx : x ∈ t
⊢ v * (μ x * ∏ j in insert a t \ {x}, s j) = v * (μ x * ((∏ j in t \ {x}, s j) * s a))

tactic: rw [prod_eq_prod_diff_singleton_mul (mem x hx) _]
state_before: case refine'_2.mpr.intro.intro.intro.intro.e_a.e_a
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
μ : I → R
hμ : ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1
u v : R
huv : u * ∏ i in t, s i + v * s a = 1
hμ' : ∑ i in t, v * ((μ i * ∏ j in t \ {i}, s j) * s a) = v * s a
x : I
hx : x ∈ t
⊢ ∏ j in insert a t \ {x}, s j = (∏ j in t \ {x}, s j) * s a

tactic: congr 2
state_before: case refine'_2.mpr.intro.intro.intro.intro.e_a.e_a
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
μ : I → R
hμ : ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1
u v : R
huv : u * ∏ i in t, s i + v * s a = 1
hμ' : ∑ i in t, v * ((μ i * ∏ j in t \ {i}, s j) * s a) = v * s a
x : I
hx : x ∈ t
⊢ (∏ x in (insert a t \ {x}) \ {a}, s x) * s a = (∏ j in t \ {x}, s j) * s a

tactic: rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]
state_before: case refine'_2.mpr.intro.intro.intro.intro.e_a.e_a.e_a.e_s
R : Type u
I : Type v
inst✝¹ : CommSemiring R
x✝ y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
μ : I → R
hμ : ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1
u v : R
huv : u * ∏ i in t, s i + v * s a = 1
hμ' : ∑ i in t, v * ((μ i * ∏ j in t \ {i}, s j) * s a) = v * s a
x : I
hx : x ∈ t
⊢ (insert a t \ {x}) \ {a} = t \ {x}

tactic: rw [← mul_sum, ← sum_mul, hμ, one_mul]
state_before: R : Type u
I : Type v
inst✝¹ : CommSemiring R
x y z : R
s : I → R
t✝ : Finset I
inst✝ : DecidableEq I
h✝ : Finset.Nonempty t✝
a : I
t : Finset I
hat : ¬a ∈ t
h : Finset.Nonempty t
ih : (∃ μ, ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1) ↔ Pairwise (IsCoprime on fun i => s ↑i)
mem : ∀ (x : I), x ∈ t → a ∈ insert a t \ {x}
hs : Pairwise (IsCoprime on fun a => s ↑a)
Hb : ∀ (b : I), b ∈ t → IsCoprime (s a) (s b) ∧ IsCoprime (s b) (s a)
μ : I → R
hμ : ∑ i in t, μ i * ∏ j in t \ {i}, s j = 1
u v : R
huv : u * ∏ i in t, s i + v * s a = 1
⊢ ∑ i in t, v * ((μ i * ∏ j in t \ {i}, s j) * s a) = v * s a