l3lab/ntp-mathlib huggingface dataset:
theorem subseq_tendsto_of_neBot {f : Filter α} [IsCountablyGenerated f] {u : ℕ → α}
    (hx : NeBot (f ⊓ map u atTop)) : ∃ θ : ℕ → ℕ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f := by
  obtain ⟨B, h⟩ := f.exists_antitone_basis
  

Proof state:
case intro
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f : Filter α
inst✝ : IsCountablyGenerated f
u : ℕ → α
hx : NeBot (f ⊓ map u atTop)
B : ℕ → Set α
h : HasAntitoneBasis f B
⊢ ∃ θ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f

Next tactic:
have : ∀ N, ∃ n ≥ N, u n ∈ B N := fun N =>
    Filter.inf_map_atTop_neBot_iff.mp hx _ (h.1.mem_of_mem trivial) N
theorem subseq_tendsto_of_neBot {f : Filter α} [IsCountablyGenerated f] {u : ℕ → α}
    (hx : NeBot (f ⊓ map u atTop)) : ∃ θ : ℕ → ℕ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f := by
  obtain ⟨B, h⟩ := f.exists_antitone_basis
  have : ∀ N, ∃ n ≥ N, u n ∈ B N := fun N =>
    Filter.inf_map_atTop_neBot_iff.mp hx _ (h.1.mem_of_mem trivial) N
  

Proof state:
case intro
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f : Filter α
inst✝ : IsCountablyGenerated f
u : ℕ → α
hx : NeBot (f ⊓ map u atTop)
B : ℕ → Set α
h : HasAntitoneBasis f B
this : ∀ (N : ℕ), ∃ n ≥ N, u n ∈ B N
⊢ ∃ θ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f

Next tactic:
choose φ hφ using this
theorem subseq_tendsto_of_neBot {f : Filter α} [IsCountablyGenerated f] {u : ℕ → α}
    (hx : NeBot (f ⊓ map u atTop)) : ∃ θ : ℕ → ℕ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f := by
  obtain ⟨B, h⟩ := f.exists_antitone_basis
  have : ∀ N, ∃ n ≥ N, u n ∈ B N := fun N =>
    Filter.inf_map_atTop_neBot_iff.mp hx _ (h.1.mem_of_mem trivial) N
  choose φ hφ using this
  

Proof state:
case intro
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f : Filter α
inst✝ : IsCountablyGenerated f
u : ℕ → α
hx : NeBot (f ⊓ map u atTop)
B : ℕ → Set α
h : HasAntitoneBasis f B
φ : ℕ → ℕ
hφ : ∀ (N : ℕ), φ N ≥ N ∧ u (φ N) ∈ B N
⊢ ∃ θ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f

Next tactic:
cases' forall_and.mp hφ with φ_ge φ_in
theorem subseq_tendsto_of_neBot {f : Filter α} [IsCountablyGenerated f] {u : ℕ → α}
    (hx : NeBot (f ⊓ map u atTop)) : ∃ θ : ℕ → ℕ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f := by
  obtain ⟨B, h⟩ := f.exists_antitone_basis
  have : ∀ N, ∃ n ≥ N, u n ∈ B N := fun N =>
    Filter.inf_map_atTop_neBot_iff.mp hx _ (h.1.mem_of_mem trivial) N
  choose φ hφ using this
  cases' forall_and.mp hφ with φ_ge φ_in
  

Proof state:
case intro.intro
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f : Filter α
inst✝ : IsCountablyGenerated f
u : ℕ → α
hx : NeBot (f ⊓ map u atTop)
B : ℕ → Set α
h : HasAntitoneBasis f B
φ : ℕ → ℕ
hφ : ∀ (N : ℕ), φ N ≥ N ∧ u (φ N) ∈ B N
φ_ge : ∀ (x : ℕ), φ x ≥ x
φ_in : ∀ (x : ℕ), u (φ x) ∈ B x
⊢ ∃ θ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f

Next tactic:
have lim_uφ : Tendsto (u ∘ φ) atTop f := h.tendsto φ_in
theorem subseq_tendsto_of_neBot {f : Filter α} [IsCountablyGenerated f] {u : ℕ → α}
    (hx : NeBot (f ⊓ map u atTop)) : ∃ θ : ℕ → ℕ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f := by
  obtain ⟨B, h⟩ := f.exists_antitone_basis
  have : ∀ N, ∃ n ≥ N, u n ∈ B N := fun N =>
    Filter.inf_map_atTop_neBot_iff.mp hx _ (h.1.mem_of_mem trivial) N
  choose φ hφ using this
  cases' forall_and.mp hφ with φ_ge φ_in
  have lim_uφ : Tendsto (u ∘ φ) atTop f := h.tendsto φ_in
  

Proof state:
case intro.intro
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f : Filter α
inst✝ : IsCountablyGenerated f
u : ℕ → α
hx : NeBot (f ⊓ map u atTop)
B : ℕ → Set α
h : HasAntitoneBasis f B
φ : ℕ → ℕ
hφ : ∀ (N : ℕ), φ N ≥ N ∧ u (φ N) ∈ B N
φ_ge : ∀ (x : ℕ), φ x ≥ x
φ_in : ∀ (x : ℕ), u (φ x) ∈ B x
lim_uφ : Tendsto (u ∘ φ) atTop f
⊢ ∃ θ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f

Next tactic:
have lim_φ : Tendsto φ atTop atTop := tendsto_atTop_mono φ_ge tendsto_id
theorem subseq_tendsto_of_neBot {f : Filter α} [IsCountablyGenerated f] {u : ℕ → α}
    (hx : NeBot (f ⊓ map u atTop)) : ∃ θ : ℕ → ℕ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f := by
  obtain ⟨B, h⟩ := f.exists_antitone_basis
  have : ∀ N, ∃ n ≥ N, u n ∈ B N := fun N =>
    Filter.inf_map_atTop_neBot_iff.mp hx _ (h.1.mem_of_mem trivial) N
  choose φ hφ using this
  cases' forall_and.mp hφ with φ_ge φ_in
  have lim_uφ : Tendsto (u ∘ φ) atTop f := h.tendsto φ_in
  have lim_φ : Tendsto φ atTop atTop := tendsto_atTop_mono φ_ge tendsto_id
  

Proof state:
case intro.intro
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f : Filter α
inst✝ : IsCountablyGenerated f
u : ℕ → α
hx : NeBot (f ⊓ map u atTop)
B : ℕ → Set α
h : HasAntitoneBasis f B
φ : ℕ → ℕ
hφ : ∀ (N : ℕ), φ N ≥ N ∧ u (φ N) ∈ B N
φ_ge : ∀ (x : ℕ), φ x ≥ x
φ_in : ∀ (x : ℕ), u (φ x) ∈ B x
lim_uφ : Tendsto (u ∘ φ) atTop f
lim_φ : Tendsto φ atTop atTop
⊢ ∃ θ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f

Next tactic:
obtain ⟨ψ, hψ, hψφ⟩ : ∃ ψ : ℕ → ℕ, StrictMono ψ ∧ StrictMono (φ ∘ ψ)
theorem subseq_tendsto_of_neBot {f : Filter α} [IsCountablyGenerated f] {u : ℕ → α}
    (hx : NeBot (f ⊓ map u atTop)) : ∃ θ : ℕ → ℕ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f := by
  obtain ⟨B, h⟩ := f.exists_antitone_basis
  have : ∀ N, ∃ n ≥ N, u n ∈ B N := fun N =>
    Filter.inf_map_atTop_neBot_iff.mp hx _ (h.1.mem_of_mem trivial) N
  choose φ hφ using this
  cases' forall_and.mp hφ with φ_ge φ_in
  have lim_uφ : Tendsto (u ∘ φ) atTop f := h.tendsto φ_in
  have lim_φ : Tendsto φ atTop atTop := tendsto_atTop_mono φ_ge tendsto_id
  obtain ⟨ψ, hψ, hψφ⟩ : ∃ ψ : ℕ → ℕ, StrictMono ψ ∧ StrictMono (φ ∘ ψ)
  

Proof state:
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f : Filter α
inst✝ : IsCountablyGenerated f
u : ℕ → α
hx : NeBot (f ⊓ map u atTop)
B : ℕ → Set α
h : HasAntitoneBasis f B
φ : ℕ → ℕ
hφ : ∀ (N : ℕ), φ N ≥ N ∧ u (φ N) ∈ B N
φ_ge : ∀ (x : ℕ), φ x ≥ x
φ_in : ∀ (x : ℕ), u (φ x) ∈ B x
lim_uφ : Tendsto (u ∘ φ) atTop f
lim_φ : Tendsto φ atTop atTop
⊢ ∃ ψ, StrictMono ψ ∧ StrictMono (φ ∘ ψ)
case intro.intro.intro.intro
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f : Filter α
inst✝ : IsCountablyGenerated f
u : ℕ → α
hx : NeBot (f ⊓ map u atTop)
B : ℕ → Set α
h : HasAntitoneBasis f B
φ : ℕ → ℕ
hφ : ∀ (N : ℕ), φ N ≥ N ∧ u (φ N) ∈ B N
φ_ge : ∀ (x : ℕ), φ x ≥ x
φ_in : ∀ (x : ℕ), u (φ x) ∈ B x
lim_uφ : Tendsto (u ∘ φ) atTop f
lim_φ : Tendsto φ atTop atTop
ψ : ℕ → ℕ
hψ : StrictMono ψ
hψφ : StrictMono (φ ∘ ψ)
⊢ ∃ θ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f

Next tactic:
exact strictMono_subseq_of_tendsto_atTop lim_φ
theorem subseq_tendsto_of_neBot {f : Filter α} [IsCountablyGenerated f] {u : ℕ → α}
    (hx : NeBot (f ⊓ map u atTop)) : ∃ θ : ℕ → ℕ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f := by
  obtain ⟨B, h⟩ := f.exists_antitone_basis
  have : ∀ N, ∃ n ≥ N, u n ∈ B N := fun N =>
    Filter.inf_map_atTop_neBot_iff.mp hx _ (h.1.mem_of_mem trivial) N
  choose φ hφ using this
  cases' forall_and.mp hφ with φ_ge φ_in
  have lim_uφ : Tendsto (u ∘ φ) atTop f := h.tendsto φ_in
  have lim_φ : Tendsto φ atTop atTop := tendsto_atTop_mono φ_ge tendsto_id
  obtain ⟨ψ, hψ, hψφ⟩ : ∃ ψ : ℕ → ℕ, StrictMono ψ ∧ StrictMono (φ ∘ ψ)
  exact strictMono_subseq_of_tendsto_atTop lim_φ
  

Proof state:
case intro.intro.intro.intro
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
f : Filter α
inst✝ : IsCountablyGenerated f
u : ℕ → α
hx : NeBot (f ⊓ map u atTop)
B : ℕ → Set α
h : HasAntitoneBasis f B
φ : ℕ → ℕ
hφ : ∀ (N : ℕ), φ N ≥ N ∧ u (φ N) ∈ B N
φ_ge : ∀ (x : ℕ), φ x ≥ x
φ_in : ∀ (x : ℕ), u (φ x) ∈ B x
lim_uφ : Tendsto (u ∘ φ) atTop f
lim_φ : Tendsto φ atTop atTop
ψ : ℕ → ℕ
hψ : StrictMono ψ
hψφ : StrictMono (φ ∘ ψ)
⊢ ∃ θ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f

Next tactic:
exact ⟨φ ∘ ψ, hψφ, lim_uφ.comp hψ.tendsto_atTop⟩
theorem Monotone.piecewise_eventually_eq_iUnion {β : α → Type*} [Preorder ι] {s : ι → Set α}
    [∀ i, DecidablePred (· ∈ s i)] [DecidablePred (· ∈ ⋃ i, s i)]
    (hs : Monotone s) (f g : (a : α) → β a) (a : α) :
    ∀ᶠ i in atTop, (s i).piecewise f g a = (⋃ i, s i).piecewise f g a := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
α : Type u_3
β✝ : Type u_4
γ : Type u_5
β : α → Type u_6
inst✝² : Preorder ι
s : ι → Set α
inst✝¹ : (i : ι) → DecidablePred fun x => x ∈ s i
inst✝ : DecidablePred fun x => x ∈ ⋃ i, s i
hs : Monotone s
f g : (a : α) → β a
a : α
⊢ ∀ᶠ (i : ι) in atTop, Set.piecewise (s i) f g a = Set.piecewise (⋃ i, s i) f g a

Next tactic:
rcases em (∃ i, a ∈ s i) with ⟨i, hi⟩ | ha
theorem Monotone.piecewise_eventually_eq_iUnion {β : α → Type*} [Preorder ι] {s : ι → Set α}
    [∀ i, DecidablePred (· ∈ s i)] [DecidablePred (· ∈ ⋃ i, s i)]
    (hs : Monotone s) (f g : (a : α) → β a) (a : α) :
    ∀ᶠ i in atTop, (s i).piecewise f g a = (⋃ i, s i).piecewise f g a := by
  rcases em (∃ i, a ∈ s i) with ⟨i, hi⟩ | ha
  · 

Proof state:
case inl.intro
ι : Type u_1
ι' : Type u_2
α : Type u_3
β✝ : Type u_4
γ : Type u_5
β : α → Type u_6
inst✝² : Preorder ι
s : ι → Set α
inst✝¹ : (i : ι) → DecidablePred fun x => x ∈ s i
inst✝ : DecidablePred fun x => x ∈ ⋃ i, s i
hs : Monotone s
f g : (a : α) → β a
a : α
i : ι
hi : a ∈ s i
⊢ ∀ᶠ (i : ι) in atTop, Set.piecewise (s i) f g a = Set.piecewise (⋃ i, s i) f g a

Next tactic:
refine (eventually_ge_atTop i).mono fun j hij ↦ ?_
theorem Monotone.piecewise_eventually_eq_iUnion {β : α → Type*} [Preorder ι] {s : ι → Set α}
    [∀ i, DecidablePred (· ∈ s i)] [DecidablePred (· ∈ ⋃ i, s i)]
    (hs : Monotone s) (f g : (a : α) → β a) (a : α) :
    ∀ᶠ i in atTop, (s i).piecewise f g a = (⋃ i, s i).piecewise f g a := by
  rcases em (∃ i, a ∈ s i) with ⟨i, hi⟩ | ha
  · refine (eventually_ge_atTop i).mono fun j hij ↦ ?_
    

Proof state:
case inl.intro
ι : Type u_1
ι' : Type u_2
α : Type u_3
β✝ : Type u_4
γ : Type u_5
β : α → Type u_6
inst✝² : Preorder ι
s : ι → Set α
inst✝¹ : (i : ι) → DecidablePred fun x => x ∈ s i
inst✝ : DecidablePred fun x => x ∈ ⋃ i, s i
hs : Monotone s
f g : (a : α) → β a
a : α
i : ι
hi : a ∈ s i
j : ι
hij : i ≤ j
⊢ Set.piecewise (s j) f g a = Set.piecewise (⋃ i, s i) f g a

Next tactic:
simp only [Set.piecewise_eq_of_mem, hs hij hi, subset_iUnion _ _ hi]
theorem Monotone.piecewise_eventually_eq_iUnion {β : α → Type*} [Preorder ι] {s : ι → Set α}
    [∀ i, DecidablePred (· ∈ s i)] [DecidablePred (· ∈ ⋃ i, s i)]
    (hs : Monotone s) (f g : (a : α) → β a) (a : α) :
    ∀ᶠ i in atTop, (s i).piecewise f g a = (⋃ i, s i).piecewise f g a := by
  rcases em (∃ i, a ∈ s i) with ⟨i, hi⟩ | ha
  · refine (eventually_ge_atTop i).mono fun j hij ↦ ?_
    simp only [Set.piecewise_eq_of_mem, hs hij hi, subset_iUnion _ _ hi]
  · 

Proof state:
case inr
ι : Type u_1
ι' : Type u_2
α : Type u_3
β✝ : Type u_4
γ : Type u_5
β : α → Type u_6
inst✝² : Preorder ι
s : ι → Set α
inst✝¹ : (i : ι) → DecidablePred fun x => x ∈ s i
inst✝ : DecidablePred fun x => x ∈ ⋃ i, s i
hs : Monotone s
f g : (a : α) → β a
a : α
ha : ¬∃ i, a ∈ s i
⊢ ∀ᶠ (i : ι) in atTop, Set.piecewise (s i) f g a = Set.piecewise (⋃ i, s i) f g a

Next tactic:
refine eventually_of_forall fun i ↦ ?_
theorem Monotone.piecewise_eventually_eq_iUnion {β : α → Type*} [Preorder ι] {s : ι → Set α}
    [∀ i, DecidablePred (· ∈ s i)] [DecidablePred (· ∈ ⋃ i, s i)]
    (hs : Monotone s) (f g : (a : α) → β a) (a : α) :
    ∀ᶠ i in atTop, (s i).piecewise f g a = (⋃ i, s i).piecewise f g a := by
  rcases em (∃ i, a ∈ s i) with ⟨i, hi⟩ | ha
  · refine (eventually_ge_atTop i).mono fun j hij ↦ ?_
    simp only [Set.piecewise_eq_of_mem, hs hij hi, subset_iUnion _ _ hi]
  · refine eventually_of_forall fun i ↦ ?_
    

Proof state:
case inr
ι : Type u_1
ι' : Type u_2
α : Type u_3
β✝ : Type u_4
γ : Type u_5
β : α → Type u_6
inst✝² : Preorder ι
s : ι → Set α
inst✝¹ : (i : ι) → DecidablePred fun x => x ∈ s i
inst✝ : DecidablePred fun x => x ∈ ⋃ i, s i
hs : Monotone s
f g : (a : α) → β a
a : α
ha : ¬∃ i, a ∈ s i
i : ι
⊢ Set.piecewise (s i) f g a = Set.piecewise (⋃ i, s i) f g a

Next tactic:
simp only [Set.piecewise_eq_of_not_mem, not_exists.1 ha i, mt mem_iUnion.1 ha,
      not_false_eq_true, exists_false]
theorem Antitone.piecewise_eventually_eq_iInter {β : α → Type*} [Preorder ι] {s : ι → Set α}
    [∀ i, DecidablePred (· ∈ s i)] [DecidablePred (· ∈ ⋂ i, s i)]
    (hs : Antitone s) (f g : (a : α) → β a) (a : α) :
    ∀ᶠ i in atTop, (s i).piecewise f g a = (⋂ i, s i).piecewise f g a := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
α : Type u_3
β✝ : Type u_4
γ : Type u_5
β : α → Type u_6
inst✝² : Preorder ι
s : ι → Set α
inst✝¹ : (i : ι) → DecidablePred fun x => x ∈ s i
inst✝ : DecidablePred fun x => x ∈ ⋂ i, s i
hs : Antitone s
f g : (a : α) → β a
a : α
⊢ ∀ᶠ (i : ι) in atTop, Set.piecewise (s i) f g a = Set.piecewise (⋂ i, s i) f g a

Next tactic:
classical
  convert ← (compl_anti.comp hs).piecewise_eventually_eq_iUnion g f a using 3
  · convert congr_fun (Set.piecewise_compl (s _) g f) a
  · simp only [(· ∘ ·), ← compl_iInter, Set.piecewise_compl]
theorem Antitone.piecewise_eventually_eq_iInter {β : α → Type*} [Preorder ι] {s : ι → Set α}
    [∀ i, DecidablePred (· ∈ s i)] [DecidablePred (· ∈ ⋂ i, s i)]
    (hs : Antitone s) (f g : (a : α) → β a) (a : α) :
    ∀ᶠ i in atTop, (s i).piecewise f g a = (⋂ i, s i).piecewise f g a := by
  classical
  

Proof state:
ι : Type u_1
ι' : Type u_2
α : Type u_3
β✝ : Type u_4
γ : Type u_5
β : α → Type u_6
inst✝² : Preorder ι
s : ι → Set α
inst✝¹ : (i : ι) → DecidablePred fun x => x ∈ s i
inst✝ : DecidablePred fun x => x ∈ ⋂ i, s i
hs : Antitone s
f g : (a : α) → β a
a : α
⊢ ∀ᶠ (i : ι) in atTop, Set.piecewise (s i) f g a = Set.piecewise (⋂ i, s i) f g a

Next tactic:
convert ← (compl_anti.comp hs).piecewise_eventually_eq_iUnion g f a using 3
theorem Antitone.piecewise_eventually_eq_iInter {β : α → Type*} [Preorder ι] {s : ι → Set α}
    [∀ i, DecidablePred (· ∈ s i)] [DecidablePred (· ∈ ⋂ i, s i)]
    (hs : Antitone s) (f g : (a : α) → β a) (a : α) :
    ∀ᶠ i in atTop, (s i).piecewise f g a = (⋂ i, s i).piecewise f g a := by
  classical
  convert ← (compl_anti.comp hs).piecewise_eventually_eq_iUnion g f a using 3
  · 

Proof state:
case h.e'_2.h.h.e'_2
ι : Type u_1
ι' : Type u_2
α : Type u_3
β✝ : Type u_4
γ : Type u_5
β : α → Type u_6
inst✝² : Preorder ι
s : ι → Set α
inst✝¹ : (i : ι) → DecidablePred fun x => x ∈ s i
inst✝ : DecidablePred fun x => x ∈ ⋂ i, s i
hs : Antitone s
f g : (a : α) → β a
a : α
x✝ : ι
⊢ Set.piecewise ((compl ∘ s) x✝) g f a = Set.piecewise (s x✝) f g a

Next tactic:
convert congr_fun (Set.piecewise_compl (s _) g f) a
theorem Antitone.piecewise_eventually_eq_iInter {β : α → Type*} [Preorder ι] {s : ι → Set α}
    [∀ i, DecidablePred (· ∈ s i)] [DecidablePred (· ∈ ⋂ i, s i)]
    (hs : Antitone s) (f g : (a : α) → β a) (a : α) :
    ∀ᶠ i in atTop, (s i).piecewise f g a = (⋂ i, s i).piecewise f g a := by
  classical
  convert ← (compl_anti.comp hs).piecewise_eventually_eq_iUnion g f a using 3
  · convert congr_fun (Set.piecewise_compl (s _) g f) a
  · 

Proof state:
case h.e'_2.h.h.e'_3
ι : Type u_1
ι' : Type u_2
α : Type u_3
β✝ : Type u_4
γ : Type u_5
β : α → Type u_6
inst✝² : Preorder ι
s : ι → Set α
inst✝¹ : (i : ι) → DecidablePred fun x => x ∈ s i
inst✝ : DecidablePred fun x => x ∈ ⋂ i, s i
hs : Antitone s
f g : (a : α) → β a
a : α
x✝ : ι
⊢ Set.piecewise (⋃ i, (compl ∘ s) i) g f a = Set.piecewise (⋂ i, s i) f g a

Next tactic:
simp only [(· ∘ ·), ← compl_iInter, Set.piecewise_compl]
/-- Let `g : γ → β` be an injective function and `f : β → α` be a function from the codomain of `g`
to a commutative monoid. Suppose that `f x = 1` outside of the range of `g`. Then the filters
`atTop.map (fun s ↦ ∏ i in s, f (g i))` and `atTop.map (fun s ↦ ∏ i in s, f i)` coincide.

The additive version of this lemma is used to prove the equality `∑' x, f (g x) = ∑' y, f y` under
the same assumptions.-/
@[to_additive]
theorem Function.Injective.map_atTop_finset_prod_eq [CommMonoid α] {g : γ → β}
    (hg : Function.Injective g) {f : β → α} (hf : ∀ x, x ∉ Set.range g → f x = 1) :
    map (fun s => ∏ i in s, f (g i)) atTop = map (fun s => ∏ i in s, f i) atTop := by
  

Proof state:
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
inst✝ : CommMonoid α
g : γ → β
hg : Injective g
f : β → α
hf : ∀ x ∉ Set.range g, f x = 1
⊢ Filter.map (fun s => ∏ i in s, f (g i)) atTop = Filter.map (fun s => ∏ i in s, f i) atTop

Next tactic:
haveI := Classical.decEq β
/-- Let `g : γ → β` be an injective function and `f : β → α` be a function from the codomain of `g`
to a commutative monoid. Suppose that `f x = 1` outside of the range of `g`. Then the filters
`atTop.map (fun s ↦ ∏ i in s, f (g i))` and `atTop.map (fun s ↦ ∏ i in s, f i)` coincide.

The additive version of this lemma is used to prove the equality `∑' x, f (g x) = ∑' y, f y` under
the same assumptions.-/
@[to_additive]
theorem Function.Injective.map_atTop_finset_prod_eq [CommMonoid α] {g : γ → β}
    (hg : Function.Injective g) {f : β → α} (hf : ∀ x, x ∉ Set.range g → f x = 1) :
    map (fun s => ∏ i in s, f (g i)) atTop = map (fun s => ∏ i in s, f i) atTop := by
  haveI := Classical.decEq β
  

Proof state:
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
inst✝ : CommMonoid α
g : γ → β
hg : Injective g
f : β → α
hf : ∀ x ∉ Set.range g, f x = 1
this : DecidableEq β
⊢ Filter.map (fun s => ∏ i in s, f (g i)) atTop = Filter.map (fun s => ∏ i in s, f i) atTop

Next tactic:
apply le_antisymm
/-- Let `g : γ → β` be an injective function and `f : β → α` be a function from the codomain of `g`
to a commutative monoid. Suppose that `f x = 1` outside of the range of `g`. Then the filters
`atTop.map (fun s ↦ ∏ i in s, f (g i))` and `atTop.map (fun s ↦ ∏ i in s, f i)` coincide.

The additive version of this lemma is used to prove the equality `∑' x, f (g x) = ∑' y, f y` under
the same assumptions.-/
@[to_additive]
theorem Function.Injective.map_atTop_finset_prod_eq [CommMonoid α] {g : γ → β}
    (hg : Function.Injective g) {f : β → α} (hf : ∀ x, x ∉ Set.range g → f x = 1) :
    map (fun s => ∏ i in s, f (g i)) atTop = map (fun s => ∏ i in s, f i) atTop := by
  haveI := Classical.decEq β
  apply le_antisymm <;> 

Proof state:
case a
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
inst✝ : CommMonoid α
g : γ → β
hg : Injective g
f : β → α
hf : ∀ x ∉ Set.range g, f x = 1
this : DecidableEq β
⊢ Filter.map (fun s => ∏ i in s, f (g i)) atTop ≤ Filter.map (fun s => ∏ i in s, f i) atTop

Next tactic:
refine' map_atTop_finset_prod_le_of_prod_eq fun s => _
/-- Let `g : γ → β` be an injective function and `f : β → α` be a function from the codomain of `g`
to a commutative monoid. Suppose that `f x = 1` outside of the range of `g`. Then the filters
`atTop.map (fun s ↦ ∏ i in s, f (g i))` and `atTop.map (fun s ↦ ∏ i in s, f i)` coincide.

The additive version of this lemma is used to prove the equality `∑' x, f (g x) = ∑' y, f y` under
the same assumptions.-/
@[to_additive]
theorem Function.Injective.map_atTop_finset_prod_eq [CommMonoid α] {g : γ → β}
    (hg : Function.Injective g) {f : β → α} (hf : ∀ x, x ∉ Set.range g → f x = 1) :
    map (fun s => ∏ i in s, f (g i)) atTop = map (fun s => ∏ i in s, f i) atTop := by
  haveI := Classical.decEq β
  apply le_antisymm <;> 

Proof state:
case a
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
inst✝ : CommMonoid α
g : γ → β
hg : Injective g
f : β → α
hf : ∀ x ∉ Set.range g, f x = 1
this : DecidableEq β
⊢ Filter.map (fun s => ∏ i in s, f i) atTop ≤ Filter.map (fun s => ∏ i in s, f (g i)) atTop

Next tactic:
refine' map_atTop_finset_prod_le_of_prod_eq fun s => _
/-- Let `g : γ → β` be an injective function and `f : β → α` be a function from the codomain of `g`
to a commutative monoid. Suppose that `f x = 1` outside of the range of `g`. Then the filters
`atTop.map (fun s ↦ ∏ i in s, f (g i))` and `atTop.map (fun s ↦ ∏ i in s, f i)` coincide.

The additive version of this lemma is used to prove the equality `∑' x, f (g x) = ∑' y, f y` under
the same assumptions.-/
@[to_additive]
theorem Function.Injective.map_atTop_finset_prod_eq [CommMonoid α] {g : γ → β}
    (hg : Function.Injective g) {f : β → α} (hf : ∀ x, x ∉ Set.range g → f x = 1) :
    map (fun s => ∏ i in s, f (g i)) atTop = map (fun s => ∏ i in s, f i) atTop := by
  haveI := Classical.decEq β
  apply le_antisymm <;> refine' map_atTop_finset_prod_le_of_prod_eq fun s => _
  · 

Proof state:
case a
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
inst✝ : CommMonoid α
g : γ → β
hg : Injective g
f : β → α
hf : ∀ x ∉ Set.range g, f x = 1
this : DecidableEq β
s : Finset β
⊢ ∃ v, ∀ (v' : Finset γ), v ⊆ v' → ∃ u', s ⊆ u' ∧ ∏ x in u', f x = ∏ b in v', f (g b)

Next tactic:
refine' ⟨s.preimage g (hg.injOn _), fun t ht => _⟩
/-- Let `g : γ → β` be an injective function and `f : β → α` be a function from the codomain of `g`
to a commutative monoid. Suppose that `f x = 1` outside of the range of `g`. Then the filters
`atTop.map (fun s ↦ ∏ i in s, f (g i))` and `atTop.map (fun s ↦ ∏ i in s, f i)` coincide.

The additive version of this lemma is used to prove the equality `∑' x, f (g x) = ∑' y, f y` under
the same assumptions.-/
@[to_additive]
theorem Function.Injective.map_atTop_finset_prod_eq [CommMonoid α] {g : γ → β}
    (hg : Function.Injective g) {f : β → α} (hf : ∀ x, x ∉ Set.range g → f x = 1) :
    map (fun s => ∏ i in s, f (g i)) atTop = map (fun s => ∏ i in s, f i) atTop := by
  haveI := Classical.decEq β
  apply le_antisymm <;> refine' map_atTop_finset_prod_le_of_prod_eq fun s => _
  · refine' ⟨s.preimage g (hg.injOn _), fun t ht => _⟩
    

Proof state:
case a
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
inst✝ : CommMonoid α
g : γ → β
hg : Injective g
f : β → α
hf : ∀ x ∉ Set.range g, f x = 1
this : DecidableEq β
s : Finset β
t : Finset γ
ht : Finset.preimage s g (_ : InjOn g (g ⁻¹' ↑s)) ⊆ t
⊢ ∃ u', s ⊆ u' ∧ ∏ x in u', f x = ∏ b in t, f (g b)

Next tactic:
refine' ⟨t.image g ∪ s, Finset.subset_union_right _ _, _⟩
/-- Let `g : γ → β` be an injective function and `f : β → α` be a function from the codomain of `g`
to a commutative monoid. Suppose that `f x = 1` outside of the range of `g`. Then the filters
`atTop.map (fun s ↦ ∏ i in s, f (g i))` and `atTop.map (fun s ↦ ∏ i in s, f i)` coincide.

The additive version of this lemma is used to prove the equality `∑' x, f (g x) = ∑' y, f y` under
the same assumptions.-/
@[to_additive]
theorem Function.Injective.map_atTop_finset_prod_eq [CommMonoid α] {g : γ → β}
    (hg : Function.Injective g) {f : β → α} (hf : ∀ x, x ∉ Set.range g → f x = 1) :
    map (fun s => ∏ i in s, f (g i)) atTop = map (fun s => ∏ i in s, f i) atTop := by
  haveI := Classical.decEq β
  apply le_antisymm <;> refine' map_atTop_finset_prod_le_of_prod_eq fun s => _
  · refine' ⟨s.preimage g (hg.injOn _), fun t ht => _⟩
    refine' ⟨t.image g ∪ s, Finset.subset_union_right _ _, _⟩
    

Proof state:
case a
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
inst✝ : CommMonoid α
g : γ → β
hg : Injective g
f : β → α
hf : ∀ x ∉ Set.range g, f x = 1
this : DecidableEq β
s : Finset β
t : Finset γ
ht : Finset.preimage s g (_ : InjOn g (g ⁻¹' ↑s)) ⊆ t
⊢ ∏ x in Finset.image g t ∪ s, f x = ∏ b in t, f (g b)

Next tactic:
rw [← Finset.prod_image (hg.injOn _)]
/-- Let `g : γ → β` be an injective function and `f : β → α` be a function from the codomain of `g`
to a commutative monoid. Suppose that `f x = 1` outside of the range of `g`. Then the filters
`atTop.map (fun s ↦ ∏ i in s, f (g i))` and `atTop.map (fun s ↦ ∏ i in s, f i)` coincide.

The additive version of this lemma is used to prove the equality `∑' x, f (g x) = ∑' y, f y` under
the same assumptions.-/
@[to_additive]
theorem Function.Injective.map_atTop_finset_prod_eq [CommMonoid α] {g : γ → β}
    (hg : Function.Injective g) {f : β → α} (hf : ∀ x, x ∉ Set.range g → f x = 1) :
    map (fun s => ∏ i in s, f (g i)) atTop = map (fun s => ∏ i in s, f i) atTop := by
  haveI := Classical.decEq β
  apply le_antisymm <;> refine' map_atTop_finset_prod_le_of_prod_eq fun s => _
  · refine' ⟨s.preimage g (hg.injOn _), fun t ht => _⟩
    refine' ⟨t.image g ∪ s, Finset.subset_union_right _ _, _⟩
    rw [← Finset.prod_image (hg.injOn _)]
    

Proof state:
case a
ι : Type u_1
ι' : Type u_2
α : Type u_3
β : Type u_4
γ : Type u_5
inst✝ : CommMonoid α
g : γ → β
hg : Injective g
f : β → α
hf : ∀ x ∉ Set.range g, f x = 1
this : DecidableEq β
s : Finset β
t : Finset γ
ht : Finset.preimage s g (_ : InjOn g (g ⁻¹' ↑s)) ⊆ t
⊢ ∏ x in Finset.image g t ∪ s, f x = ∏ x in Finset.image (fun x => g x) t, f x

Next tactic:
refine' (prod_subset (subset_union_left _ _) _).symm