Theorem: Finset.prod_add_ordered
File: Mathlib/Algebra/BigOperators/Ring.lean

Proof steps:
state_before: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
s : Finset ι
f g : ι → α
⊢ ∏ i ∈ s, (f i + g i) =
    ∏ i ∈ s, f i + ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j
state_after: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
s : Finset ι
f g : ι → α
⊢ ∀ (a : ι) (s : Finset ι),
    (∀ x ∈ s, x < a) →
      ∏ i ∈ s, (f i + g i) =
          ∏ i ∈ s, f i +
            ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j →
        ∏ i ∈ insert a s, (f i + g i) =
          ∏ i ∈ insert a s, f i +
            ∑ i ∈ insert a s,
              (g i * ∏ j ∈ filter (fun x => x < i) (insert a s), (f j + g j)) *
                ∏ j ∈ filter (fun j => i < j) (insert a s), f j
tactic: refine Finset.induction_on_max s (by simp) ?_
state_before: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
s : Finset ι
f g : ι → α
⊢ ∀ (a : ι) (s : Finset ι),
    (∀ x ∈ s, x < a) →
      ∏ i ∈ s, (f i + g i) =
          ∏ i ∈ s, f i +
            ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j →
        ∏ i ∈ insert a s, (f i + g i) =
          ∏ i ∈ insert a s, f i +
            ∑ i ∈ insert a s,
              (g i * ∏ j ∈ filter (fun x => x < i) (insert a s), (f j + g j)) *
                ∏ j ∈ filter (fun j => i < j) (insert a s), f j
state_after: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s s₁ s₂ : Finset ι
i : ι
a : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
f g : ι → α
⊢ ∀ (a : ι) (s : Finset ι),
    (∀ x ∈ s, x < a) →
      ∏ i ∈ s, (f i + g i) =
          ∏ i ∈ s, f i +
            ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j →
        ∏ i ∈ insert a s, (f i + g i) =
          ∏ i ∈ insert a s, f i +
            ∑ i ∈ insert a s,
              (g i * ∏ j ∈ filter (fun x => x < i) (insert a s), (f j + g j)) *
                ∏ j ∈ filter (fun j => i < j) (insert a s), f j
tactic: clear s
state_before: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s s₁ s₂ : Finset ι
i : ι
a : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
f g : ι → α
⊢ ∀ (a : ι) (s : Finset ι),
    (∀ x ∈ s, x < a) →
      ∏ i ∈ s, (f i + g i) =
          ∏ i ∈ s, f i +
            ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j →
        ∏ i ∈ insert a s, (f i + g i) =
          ∏ i ∈ insert a s, f i +
            ∑ i ∈ insert a s,
              (g i * ∏ j ∈ filter (fun x => x < i) (insert a s), (f j + g j)) *
                ∏ j ∈ filter (fun j => i < j) (insert a s), f j
state_after: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a✝ : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
f g : ι → α
a : ι
s : Finset ι
ha : ∀ x ∈ s, x < a
ihs :
  ∏ i ∈ s, (f i + g i) =
    ∏ i ∈ s, f i + ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j
⊢ ∏ i ∈ insert a s, (f i + g i) =
    ∏ i ∈ insert a s, f i +
      ∑ i ∈ insert a s,
        (g i * ∏ j ∈ filter (fun x => x < i) (insert a s), (f j + g j)) *
          ∏ j ∈ filter (fun j => i < j) (insert a s), f j
tactic: intro a s ha ihs
state_before: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a✝ : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
f g : ι → α
a : ι
s : Finset ι
ha : ∀ x ∈ s, x < a
ihs :
  ∏ i ∈ s, (f i + g i) =
    ∏ i ∈ s, f i + ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j
⊢ ∏ i ∈ insert a s, (f i + g i) =
    ∏ i ∈ insert a s, f i +
      ∑ i ∈ insert a s,
        (g i * ∏ j ∈ filter (fun x => x < i) (insert a s), (f j + g j)) *
          ∏ j ∈ filter (fun j => i < j) (insert a s), f j
state_after: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a✝ : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
f g : ι → α
a : ι
s : Finset ι
ha : ∀ x ∈ s, x < a
ihs :
  ∏ i ∈ s, (f i + g i) =
    ∏ i ∈ s, f i + ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j
ha' : a ∉ s
⊢ ∏ i ∈ insert a s, (f i + g i) =
    ∏ i ∈ insert a s, f i +
      ∑ i ∈ insert a s,
        (g i * ∏ j ∈ filter (fun x => x < i) (insert a s), (f j + g j)) *
          ∏ j ∈ filter (fun j => i < j) (insert a s), f j
tactic: have ha' : a ∉ s := fun ha' => lt_irrefl a (ha a ha')
state_before: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a✝ : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
f g : ι → α
a : ι
s : Finset ι
ha : ∀ x ∈ s, x < a
ihs :
  ∏ i ∈ s, (f i + g i) =
    ∏ i ∈ s, f i + ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j
ha' : a ∉ s
⊢ ∏ i ∈ insert a s, (f i + g i) =
    ∏ i ∈ insert a s, f i +
      ∑ i ∈ insert a s,
        (g i * ∏ j ∈ filter (fun x => x < i) (insert a s), (f j + g j)) *
          ∏ j ∈ filter (fun j => i < j) (insert a s), f j
state_after: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a✝ : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
f g : ι → α
a : ι
s : Finset ι
ha : ∀ x ∈ s, x < a
ihs :
  ∏ i ∈ s, (f i + g i) =
    ∏ i ∈ s, f i + ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j
ha' : a ∉ s
⊢ f a * ∏ i ∈ s, f i +
      (f a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j +
        (g a * ∏ i ∈ s, f i +
          g a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j)) =
    f a * ∏ x ∈ s, f x +
      ((g a * ∏ i ∈ s, f i +
            g a *
              ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j) *
          ∏ j ∈ filter (fun j => a < j) (insert a s), f j +
        ∑ x ∈ s,
          (g x * ∏ j ∈ filter (fun x_1 => x_1 < x) (insert a s), (f j + g j)) *
            ∏ j ∈ filter (fun j => x < j) (insert a s), f j)
tactic: rw [prod_insert ha', prod_insert ha', sum_insert ha', filter_insert, if_neg (lt_irrefl a),
    filter_true_of_mem ha, ihs, add_mul, mul_add, mul_add, add_assoc]
state_before: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a✝ : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
f g : ι → α
a : ι
s : Finset ι
ha : ∀ x ∈ s, x < a
ihs :
  ∏ i ∈ s, (f i + g i) =
    ∏ i ∈ s, f i + ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j
ha' : a ∉ s
⊢ f a * ∏ i ∈ s, f i +
      (f a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j +
        (g a * ∏ i ∈ s, f i +
          g a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j)) =
    f a * ∏ x ∈ s, f x +
      ((g a * ∏ i ∈ s, f i +
            g a *
              ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j) *
          ∏ j ∈ filter (fun j => a < j) (insert a s), f j +
        ∑ x ∈ s,
          (g x * ∏ j ∈ filter (fun x_1 => x_1 < x) (insert a s), (f j + g j)) *
            ∏ j ∈ filter (fun j => x < j) (insert a s), f j)
state_after: case e_a
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a✝ : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
f g : ι → α
a : ι
s : Finset ι
ha : ∀ x ∈ s, x < a
ihs :
  ∏ i ∈ s, (f i + g i) =
    ∏ i ∈ s, f i + ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j
ha' : a ∉ s
⊢ f a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j +
      (g a * ∏ i ∈ s, f i +
        g a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j) =
    (g a * ∏ i ∈ s, f i +
          g a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j) *
        ∏ j ∈ filter (fun j => a < j) (insert a s), f j +
      ∑ x ∈ s,
        (g x * ∏ j ∈ filter (fun x_1 => x_1 < x) (insert a s), (f j + g j)) *
          ∏ j ∈ filter (fun j => x < j) (insert a s), f j
tactic: congr 1
state_before: case e_a
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a✝ : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
f g : ι → α
a : ι
s : Finset ι
ha : ∀ x ∈ s, x < a
ihs :
  ∏ i ∈ s, (f i + g i) =
    ∏ i ∈ s, f i + ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j
ha' : a ∉ s
⊢ f a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j +
      (g a * ∏ i ∈ s, f i +
        g a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j) =
    (g a * ∏ i ∈ s, f i +
          g a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j) *
        ∏ j ∈ filter (fun j => a < j) (insert a s), f j +
      ∑ x ∈ s,
        (g x * ∏ j ∈ filter (fun x_1 => x_1 < x) (insert a s), (f j + g j)) *
          ∏ j ∈ filter (fun j => x < j) (insert a s), f j
state_after: case e_a
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a✝ : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
f g : ι → α
a : ι
s : Finset ι
ha : ∀ x ∈ s, x < a
ihs :
  ∏ i ∈ s, (f i + g i) =
    ∏ i ∈ s, f i + ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j
ha' : a ∉ s
⊢ g a * ∏ i ∈ s, f i +
        g a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j +
      f a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j =
    (g a * ∏ i ∈ s, f i +
          g a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j) *
        ∏ j ∈ filter (fun j => a < j) (insert a s), f j +
      ∑ x ∈ s,
        (g x * ∏ j ∈ filter (fun x_1 => x_1 < x) (insert a s), (f j + g j)) *
          ∏ j ∈ filter (fun j => x < j) (insert a s), f j
tactic: rw [add_comm]
state_before: case e_a
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a✝ : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
f g : ι → α
a : ι
s : Finset ι
ha : ∀ x ∈ s, x < a
ihs :
  ∏ i ∈ s, (f i + g i) =
    ∏ i ∈ s, f i + ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j
ha' : a ∉ s
⊢ g a * ∏ i ∈ s, f i +
        g a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j +
      f a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j =
    (g a * ∏ i ∈ s, f i +
          g a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j) *
        ∏ j ∈ filter (fun j => a < j) (insert a s), f j +
      ∑ x ∈ s,
        (g x * ∏ j ∈ filter (fun x_1 => x_1 < x) (insert a s), (f j + g j)) *
          ∏ j ∈ filter (fun j => x < j) (insert a s), f j
state_after: case e_a.e_a
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a✝ : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
f g : ι → α
a : ι
s : Finset ι
ha : ∀ x ∈ s, x < a
ihs :
  ∏ i ∈ s, (f i + g i) =
    ∏ i ∈ s, f i + ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j
ha' : a ∉ s
⊢ g a * ∏ i ∈ s, f i +
      g a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j =
    (g a * ∏ i ∈ s, f i +
        g a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j) *
      ∏ j ∈ filter (fun j => a < j) (insert a s), f j

case e_a.e_a
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
κ : ι → Type u_5
s✝ s₁ s₂ : Finset ι
i : ι
a✝ : α
f✝ g✝ : ι → α
inst✝² : CommSemiring α
inst✝¹ : LinearOrder ι
inst✝ : CommSemiring α
f g : ι → α
a : ι
s : Finset ι
ha : ∀ x ∈ s, x < a
ihs :
  ∏ i ∈ s, (f i + g i) =
    ∏ i ∈ s, f i + ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j
ha' : a ∉ s
⊢ f a * ∑ i ∈ s, (g i * ∏ j ∈ filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ filter (fun j => i < j) s, f j =
    ∑ x ∈ s,
      (g x * ∏ j ∈ filter (fun x_1 => x_1 < x) (insert a s), (f j + g j)) *
        ∏ j ∈ filter (fun j => x < j) (insert a s), f j
tactic: congr 1