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

tactic: classical
calc
  ∏ i ∈ s, (f i + g i) =
      ∏ i ∈ s, ∑ p ∈ ({True, False} : Finset Prop), if p then f i else g i := by simp
  _ = ∑ p ∈ (s.pi fun _ => {True, False} : Finset (∀ a ∈ s, Prop)),
        ∏ a ∈ s.attach, if p a.1 a.2 then f a.1 else g a.1 := prod_sum _ _ _
  _ = ∑ t ∈ s.powerset, (∏ a ∈ t, f a) * ∏ a ∈ s \ t, g a :=
    sum_bij'
      (fun f _ ↦ s.filter fun a ↦ ∃ h : a ∈ s, f a h)
      (fun t _ a _ => a ∈ t)
      (by simp)
      (by simp [Classical.em])
      (by simp_rw [mem_filter, Function.funext_iff, eq_iff_iff, mem_pi, mem_insert]; tauto)
      (by simp_rw [ext_iff, @mem_filter _ _ (id _), mem_powerset]; tauto)
      (fun a _ ↦ by
        simp only [prod_ite, filter_attach', prod_map, Function.Embedding.coeFn_mk,
          Subtype.map_coe, id_eq, prod_attach, filter_congr_decidable]
        congr 2 with x
        simp only [mem_filter, mem_sdiff, not_and, not_exists, and_congr_right_iff]
        tauto)
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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
⊢ ∏ i ∈ s, (f i + g i) = ∑ t ∈ s.powerset, (∏ i ∈ t, f i) * ∏ i ∈ s \ t, g i
state_after: no goals

tactic: calc
  ∏ i ∈ s, (f i + g i) =
      ∏ i ∈ s, ∑ p ∈ ({True, False} : Finset Prop), if p then f i else g i := by simp
  _ = ∑ p ∈ (s.pi fun _ => {True, False} : Finset (∀ a ∈ s, Prop)),
        ∏ a ∈ s.attach, if p a.1 a.2 then f a.1 else g a.1 := prod_sum _ _ _
  _ = ∑ t ∈ s.powerset, (∏ a ∈ t, f a) * ∏ a ∈ s \ t, g a :=
    sum_bij'
      (fun f _ ↦ s.filter fun a ↦ ∃ h : a ∈ s, f a h)
      (fun t _ a _ => a ∈ t)
      (by simp)
      (by simp [Classical.em])
      (by simp_rw [mem_filter, Function.funext_iff, eq_iff_iff, mem_pi, mem_insert]; tauto)
      (by simp_rw [ext_iff, @mem_filter _ _ (id _), mem_powerset]; tauto)
      (fun a _ ↦ by
        simp only [prod_ite, filter_attach', prod_map, Function.Embedding.coeFn_mk,
          Subtype.map_coe, id_eq, prod_attach, filter_congr_decidable]
        congr 2 with x
        simp only [mem_filter, mem_sdiff, not_and, not_exists, and_congr_right_iff]
        tauto)
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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
⊢ ∏ i ∈ s, (f i + g i) = ∑ t ∈ s.powerset, (∏ i ∈ t, f i) * ∏ i ∈ s \ t, g i
state_after: no goals

tactic: 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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
⊢ ∏ i ∈ s, (f i + g i) = ∏ i ∈ s, ∑ p ∈ {True, False}, if p then f i else g i
state_after: no goals

tactic: 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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
⊢ ∀ (a : (a : ι) → a ∈ s → Prop) (ha : a ∈ s.pi fun x => {True, False}),
    (fun f x => filter (fun a => ∃ (h : a ∈ s), f a h) s) a ha ∈ s.powerset
state_after: no goals

tactic: simp [Classical.em]
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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
⊢ ∀ (a : Finset ι) (ha : a ∈ s.powerset), (fun t x a x => a ∈ t) a ha ∈ s.pi fun x => {True, False}
state_after: no goals

tactic: simp_rw [mem_filter, Function.funext_iff, eq_iff_iff, mem_pi, mem_insert]
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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
⊢ ∀ (a : (a : ι) → a ∈ s → Prop) (ha : a ∈ s.pi fun x => {True, False}),
    (fun t x a x => a ∈ t) ((fun f x => filter (fun a => ∃ (h : a ∈ s), f a h) s) a ha) ⋯ = a
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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
⊢ ∀ (a : (a : ι) → a ∈ s → Prop),
    (∀ (a_1 : ι) (h : a_1 ∈ s), a a_1 h = True ∨ a a_1 h ∈ {False}) →
      ∀ (a_1 : ι) (a_2 : a_1 ∈ s), (a_1 ∈ s ∧ ∃ (h : a_1 ∈ s), a a_1 h) ↔ a a_1 a_2

tactic: tauto
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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
⊢ ∀ (a : (a : ι) → a ∈ s → Prop),
    (∀ (a_1 : ι) (h : a_1 ∈ s), a a_1 h = True ∨ a a_1 h ∈ {False}) →
      ∀ (a_1 : ι) (a_2 : a_1 ∈ s), (a_1 ∈ s ∧ ∃ (h : a_1 ∈ s), a a_1 h) ↔ a a_1 a_2
state_after: no goals

tactic: simp_rw [ext_iff, @mem_filter _ _ (id _), mem_powerset]
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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
⊢ ∀ (a : Finset ι) (ha : a ∈ s.powerset),
    (fun f x => filter (fun a => ∃ (h : a ∈ s), f a h) s) ((fun t x a x => a ∈ t) a ha) ⋯ = a
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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
⊢ ∀ a ⊆ s, ∀ (a_1 : ι), (a_1 ∈ s ∧ ∃ (_ : a_1 ∈ s), a_1 ∈ a) ↔ a_1 ∈ a

tactic: tauto
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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
⊢ ∀ a ⊆ s, ∀ (a_1 : ι), (a_1 ∈ s ∧ ∃ (_ : a_1 ∈ s), a_1 ∈ a) ↔ a_1 ∈ a
state_after: no goals

tactic: simp only [prod_ite, filter_attach', prod_map, Function.Embedding.coeFn_mk,
  Subtype.map_coe, id_eq, prod_attach, filter_congr_decidable]
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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
a : (a : ι) → a ∈ s → Prop
x✝ : a ∈ s.pi fun x => {True, False}
⊢ (∏ a_1 ∈ s.attach, if a ↑a_1 ⋯ then f ↑a_1 else g ↑a_1) =
    (∏ a ∈ (fun f x => filter (fun a => ∃ (h : a ∈ s), f a h) s) a x✝, f a) *
      ∏ a ∈ s \ (fun f x => filter (fun a => ∃ (h : a ∈ s), f a h) s) a x✝, g a
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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
a : (a : ι) → a ∈ s → Prop
x✝ : a ∈ s.pi fun x => {True, False}
⊢ (∏ x ∈ filter (fun x => ∃ (h : x ∈ s), a x ⋯) s, f x) * ∏ x ∈ filter (fun x => ∃ (h : x ∈ s), ¬a x ⋯) s, g x =
    (∏ x ∈ filter (fun a_1 => ∃ (h : a_1 ∈ s), a a_1 h) s, f x) *
      ∏ x ∈ s \ filter (fun a_1 => ∃ (h : a_1 ∈ s), a a_1 h) s, g x

tactic: congr 2 with x
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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
a : (a : ι) → a ∈ s → Prop
x✝ : a ∈ s.pi fun x => {True, False}
⊢ (∏ x ∈ filter (fun x => ∃ (h : x ∈ s), a x ⋯) s, f x) * ∏ x ∈ filter (fun x => ∃ (h : x ∈ s), ¬a x ⋯) s, g x =
    (∏ x ∈ filter (fun a_1 => ∃ (h : a_1 ∈ s), a a_1 h) s, f x) *
      ∏ x ∈ s \ filter (fun a_1 => ∃ (h : a_1 ∈ s), a a_1 h) s, g x
state_after: case e_a.e_s.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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
a : (a : ι) → a ∈ s → Prop
x✝ : a ∈ s.pi fun x => {True, False}
x : ι
⊢ x ∈ filter (fun x => ∃ (h : x ∈ s), ¬a x ⋯) s ↔ x ∈ s \ filter (fun a_1 => ∃ (h : a_1 ∈ s), a a_1 h) s

tactic: simp only [mem_filter, mem_sdiff, not_and, not_exists, and_congr_right_iff]
state_before: case e_a.e_s.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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
a : (a : ι) → a ∈ s → Prop
x✝ : a ∈ s.pi fun x => {True, False}
x : ι
⊢ x ∈ filter (fun x => ∃ (h : x ∈ s), ¬a x ⋯) s ↔ x ∈ s \ filter (fun a_1 => ∃ (h : a_1 ∈ s), a a_1 h) s
state_after: case e_a.e_s.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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
a : (a : ι) → a ∈ s → Prop
x✝ : a ∈ s.pi fun x => {True, False}
x : ι
⊢ x ∈ s → ((∃ (h : x ∈ s), ¬a x ⋯) ↔ x ∈ s → ∀ (x_1 : x ∈ s), ¬a x x_1)

tactic: tauto
state_before: case e_a.e_s.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✝ : DecidableEq ι
f g : ι → α
s : Finset ι
a : (a : ι) → a ∈ s → Prop
x✝ : a ∈ s.pi fun x => {True, False}
x : ι
⊢ x ∈ s → ((∃ (h : x ∈ s), ¬a x ⋯) ↔ x ∈ s → ∀ (x_1 : x ∈ s), ¬a x x_1)
state_after: no goals