Theorem: Finset.gcd_eq_gcd_filter_ne_zero
File: Mathlib/Algebra/GCDMonoid/Finset.lean

tactic: trans ((s.filter fun x ↦ f x = 0) ∪ s.filter fun x ↦ (f x ≠ 0)).gcd f
state_before: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ s.gcd f = (filter (fun x => f x ≠ 0) s).gcd f
state_after: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ s.gcd f = (filter (fun x => f x = 0) s ∪ filter (fun x => f x ≠ 0) s).gcd f

ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ (filter (fun x => f x = 0) s ∪ filter (fun x => f x ≠ 0) s).gcd f = (filter (fun x => f x ≠ 0) s).gcd f

tactic: rw [gcd_union]
state_before: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ (filter (fun x => f x = 0) s ∪ filter (fun x => f x ≠ 0) s).gcd f = (filter (fun x => f x ≠ 0) s).gcd f
state_after: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ GCDMonoid.gcd ((filter (fun x => f x = 0) s).gcd f) ((filter (fun x => f x ≠ 0) s).gcd f) =
    (filter (fun x => f x ≠ 0) s).gcd f

tactic: refine Eq.trans (?_ : _ = GCDMonoid.gcd (0 : α) ?_) (?_ : GCDMonoid.gcd (0 : α) _ = _)
state_before: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ GCDMonoid.gcd ((filter (fun x => f x = 0) s).gcd f) ((filter (fun x => f x ≠ 0) s).gcd f) =
    (filter (fun x => f x ≠ 0) s).gcd f
state_after: case refine_1
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ α

case refine_2
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ GCDMonoid.gcd ((filter (fun x => f x = 0) s).gcd f) ((filter (fun x => f x ≠ 0) s).gcd f) = GCDMonoid.gcd 0 ?refine_1

case refine_3
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ GCDMonoid.gcd 0 ?refine_1 = (filter (fun x => f x ≠ 0) s).gcd f

tactic: simp only [gcd_zero_left, normalize_gcd]
state_before: case refine_3
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ GCDMonoid.gcd 0 ((filter (fun x => f x ≠ 0) s).gcd f) = (filter (fun x => f x ≠ 0) s).gcd f
state_after: no goals

tactic: rw [filter_union_filter_neg_eq]
state_before: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ s.gcd f = (filter (fun x => f x = 0) s ∪ filter (fun x => f x ≠ 0) s).gcd f
state_after: no goals

tactic: exact (gcd (filter (fun x => (f x ≠ 0)) s) f)
state_before: case refine_1
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ α
state_after: no goals

tactic: refine congr (congr rfl <| s.induction_on ?_ ?_) (by simp)
state_before: case refine_2
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ GCDMonoid.gcd ((filter (fun x => f x = 0) s).gcd f) ((filter (fun x => f x ≠ 0) s).gcd f) =
    GCDMonoid.gcd 0 ((filter (fun x => f x ≠ 0) s).gcd f)
state_after: case refine_2.refine_1
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ (filter (fun x => f x = 0) ∅).gcd f = 0

case refine_2.refine_2
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ ∀ ⦃a : β⦄ {s : Finset β},
    a ∉ s → (filter (fun x => f x = 0) s).gcd f = 0 → (filter (fun x => f x = 0) (insert a s)).gcd f = 0

tactic: simp
state_before: ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ (filter (fun x => f x ≠ 0) s).gcd f = (filter (fun x => f x ≠ 0) s).gcd f
state_after: no goals

tactic: simp
state_before: case refine_2.refine_1
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ (filter (fun x => f x = 0) ∅).gcd f = 0
state_after: no goals

tactic: intro a s _ h
state_before: case refine_2.refine_2
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
⊢ ∀ ⦃a : β⦄ {s : Finset β},
    a ∉ s → (filter (fun x => f x = 0) s).gcd f = 0 → (filter (fun x => f x = 0) (insert a s)).gcd f = 0
state_after: case refine_2.refine_2
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s✝ s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
a : β
s : Finset β
a✝ : a ∉ s
h : (filter (fun x => f x = 0) s).gcd f = 0
⊢ (filter (fun x => f x = 0) (insert a s)).gcd f = 0

tactic: rw [filter_insert]
state_before: case refine_2.refine_2
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s✝ s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
a : β
s : Finset β
a✝ : a ∉ s
h : (filter (fun x => f x = 0) s).gcd f = 0
⊢ (filter (fun x => f x = 0) (insert a s)).gcd f = 0
state_after: case refine_2.refine_2
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s✝ s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
a : β
s : Finset β
a✝ : a ∉ s
h : (filter (fun x => f x = 0) s).gcd f = 0
⊢ (if f a = 0 then insert a (filter (fun x => f x = 0) s) else filter (fun x => f x = 0) s).gcd f = 0

tactic: split_ifs with h1 <;> simp [h, h1]
state_before: case refine_2.refine_2
ι : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : NormalizedGCDMonoid α
s✝ s₁ s₂ : Finset β
f : β → α
inst✝ : DecidablePred fun x => f x = 0
a : β
s : Finset β
a✝ : a ∉ s
h : (filter (fun x => f x = 0) s).gcd f = 0
⊢ (if f a = 0 then insert a (filter (fun x => f x = 0) s) else filter (fun x => f x = 0) s).gcd f = 0
state_after: no goals