l3lab/ntp-mathlib huggingface dataset:
lemma NullMeasurable.measure_preimage_eq_measure_restrict_preimage_of_ae_compl_eq_const
    {β : Type*} [MeasurableSpace β] {b : β} {f : α → β} {s : Set α}
    (f_mble : NullMeasurable f (μ.restrict s)) (hs : f =ᵐ[Measure.restrict μ sᶜ] (fun _ ↦ b))
    {t : Set β} (t_mble : MeasurableSet t) (ht : b ∉ t) :
    μ (f ⁻¹' t) = μ.restrict s (f ⁻¹' t) := by
  rw [Measure.restrict_apply₀ (f_mble t_mble)]
  simp only [EventuallyEq, Filter.Eventually, Pi.zero_apply, Measure.ae,
             MeasurableSet.compl_iff, Filter.mem_mk, mem_setOf_eq] at hs
  rw [Measure.restrict_apply₀] at hs
  · apply le_antisymm _ (measure_mono (inter_subset_left _ _))
    apply (measure_mono (Eq.symm (inter_union_compl (f ⁻¹' t) s)).le).trans
    apply (measure_union_le _ _).trans
    have obs : μ ((f ⁻¹' t) ∩ sᶜ) = 0 := by
      apply le_antisymm _ (zero_le _)
      rw [← hs]
      apply measure_mono (inter_subset_inter_left _ _)
      intro x hx hfx
      simp only [mem_preimage, mem_setOf_eq] at hx hfx
      

Proof state:
R : Type u_1
α : Type u_2
β✝ : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝² : MeasurableSpace β✝
inst✝¹ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s✝ s' t✝ : Set α
β : Type u_7
inst✝ : MeasurableSpace β
b : β
f : α → β
s : Set α
f_mble : NullMeasurable f
t : Set β
t_mble : MeasurableSet t
ht : b ∉ t
hs : ↑↑μ ({x | f x = b}ᶜ ∩ sᶜ) = 0
x : α
hfx : f x = b
hx : f x ∈ t
⊢ False

Next tactic:
exact ht (hfx ▸ hx)
lemma NullMeasurable.measure_preimage_eq_measure_restrict_preimage_of_ae_compl_eq_const
    {β : Type*} [MeasurableSpace β] {b : β} {f : α → β} {s : Set α}
    (f_mble : NullMeasurable f (μ.restrict s)) (hs : f =ᵐ[Measure.restrict μ sᶜ] (fun _ ↦ b))
    {t : Set β} (t_mble : MeasurableSet t) (ht : b ∉ t) :
    μ (f ⁻¹' t) = μ.restrict s (f ⁻¹' t) := by
  rw [Measure.restrict_apply₀ (f_mble t_mble)]
  simp only [EventuallyEq, Filter.Eventually, Pi.zero_apply, Measure.ae,
             MeasurableSet.compl_iff, Filter.mem_mk, mem_setOf_eq] at hs
  rw [Measure.restrict_apply₀] at hs
  · apply le_antisymm _ (measure_mono (inter_subset_left _ _))
    apply (measure_mono (Eq.symm (inter_union_compl (f ⁻¹' t) s)).le).trans
    apply (measure_union_le _ _).trans
    have obs : μ ((f ⁻¹' t) ∩ sᶜ) = 0 := by
      apply le_antisymm _ (zero_le _)
      rw [← hs]
      apply measure_mono (inter_subset_inter_left _ _)
      intro x hx hfx
      simp only [mem_preimage, mem_setOf_eq] at hx hfx
      exact ht (hfx ▸ hx)
    

Proof state:
R : Type u_1
α : Type u_2
β✝ : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝² : MeasurableSpace β✝
inst✝¹ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s✝ s' t✝ : Set α
β : Type u_7
inst✝ : MeasurableSpace β
b : β
f : α → β
s : Set α
f_mble : NullMeasurable f
t : Set β
t_mble : MeasurableSet t
ht : b ∉ t
hs : ↑↑μ ({x | f x = b}ᶜ ∩ sᶜ) = 0
obs : ↑↑μ (f ⁻¹' t ∩ sᶜ) = 0
⊢ ↑↑μ (f ⁻¹' t ∩ s) + ↑↑μ (f ⁻¹' t ∩ sᶜ) ≤ ↑↑μ (f ⁻¹' t ∩ s)

Next tactic:
simp only [obs, add_zero, le_refl]
lemma NullMeasurable.measure_preimage_eq_measure_restrict_preimage_of_ae_compl_eq_const
    {β : Type*} [MeasurableSpace β] {b : β} {f : α → β} {s : Set α}
    (f_mble : NullMeasurable f (μ.restrict s)) (hs : f =ᵐ[Measure.restrict μ sᶜ] (fun _ ↦ b))
    {t : Set β} (t_mble : MeasurableSet t) (ht : b ∉ t) :
    μ (f ⁻¹' t) = μ.restrict s (f ⁻¹' t) := by
  rw [Measure.restrict_apply₀ (f_mble t_mble)]
  simp only [EventuallyEq, Filter.Eventually, Pi.zero_apply, Measure.ae,
             MeasurableSet.compl_iff, Filter.mem_mk, mem_setOf_eq] at hs
  rw [Measure.restrict_apply₀] at hs
  · apply le_antisymm _ (measure_mono (inter_subset_left _ _))
    apply (measure_mono (Eq.symm (inter_union_compl (f ⁻¹' t) s)).le).trans
    apply (measure_union_le _ _).trans
    have obs : μ ((f ⁻¹' t) ∩ sᶜ) = 0 := by
      apply le_antisymm _ (zero_le _)
      rw [← hs]
      apply measure_mono (inter_subset_inter_left _ _)
      intro x hx hfx
      simp only [mem_preimage, mem_setOf_eq] at hx hfx
      exact ht (hfx ▸ hx)
    simp only [obs, add_zero, le_refl]
  · 

Proof state:
R : Type u_1
α : Type u_2
β✝ : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝² : MeasurableSpace β✝
inst✝¹ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s✝ s' t✝ : Set α
β : Type u_7
inst✝ : MeasurableSpace β
b : β
f : α → β
s : Set α
f_mble : NullMeasurable f
t : Set β
t_mble : MeasurableSet t
ht : b ∉ t
hs : ↑↑(Measure.restrict μ sᶜ) {x | f x = b}ᶜ = 0
⊢ NullMeasurableSet {x | f x = b}ᶜ

Next tactic:
exact NullMeasurableSet.of_null hs
theorem MeasurableSet.nullMeasurableSet_subtype_coe {t : Set s} (hs : NullMeasurableSet s μ)
    (ht : MeasurableSet t) : NullMeasurableSet ((↑) '' t) μ := by
  

Proof state:
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝¹ : MeasurableSpace β
inst✝ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t✝ : Set α
t : Set ↑s
hs : NullMeasurableSet s
ht : MeasurableSet t
⊢ NullMeasurableSet (Subtype.val '' t)

Next tactic:
rw [Subtype.instMeasurableSpace, comap_eq_generateFrom] at ht
theorem MeasurableSet.nullMeasurableSet_subtype_coe {t : Set s} (hs : NullMeasurableSet s μ)
    (ht : MeasurableSet t) : NullMeasurableSet ((↑) '' t) μ := by
  rw [Subtype.instMeasurableSpace, comap_eq_generateFrom] at ht
  

Proof state:
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝¹ : MeasurableSpace β
inst✝ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t✝ : Set α
t : Set ↑s
hs : NullMeasurableSet s
ht : MeasurableSet t
⊢ NullMeasurableSet (Subtype.val '' t)

Next tactic:
refine'
    generateFrom_induction (p := fun t : Set s => NullMeasurableSet ((↑) '' t) μ)
      { t : Set s | ∃ s' : Set α, MeasurableSet s' ∧ (↑) ⁻¹' s' = t } _ _ _ _ ht
theorem MeasurableSet.nullMeasurableSet_subtype_coe {t : Set s} (hs : NullMeasurableSet s μ)
    (ht : MeasurableSet t) : NullMeasurableSet ((↑) '' t) μ := by
  rw [Subtype.instMeasurableSpace, comap_eq_generateFrom] at ht
  refine'
    generateFrom_induction (p := fun t : Set s => NullMeasurableSet ((↑) '' t) μ)
      { t : Set s | ∃ s' : Set α, MeasurableSet s' ∧ (↑) ⁻¹' s' = t } _ _ _ _ ht
  · 

Proof state:
case refine'_1
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝¹ : MeasurableSpace β
inst✝ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t✝ : Set α
t : Set ↑s
hs : NullMeasurableSet s
ht : MeasurableSet t
⊢ ∀ t ∈ {t | ∃ s', MeasurableSet s' ∧ Subtype.val ⁻¹' s' = t}, (fun t => NullMeasurableSet (Subtype.val '' t)) t

Next tactic:
rintro t' ⟨s', hs', rfl⟩
theorem MeasurableSet.nullMeasurableSet_subtype_coe {t : Set s} (hs : NullMeasurableSet s μ)
    (ht : MeasurableSet t) : NullMeasurableSet ((↑) '' t) μ := by
  rw [Subtype.instMeasurableSpace, comap_eq_generateFrom] at ht
  refine'
    generateFrom_induction (p := fun t : Set s => NullMeasurableSet ((↑) '' t) μ)
      { t : Set s | ∃ s' : Set α, MeasurableSet s' ∧ (↑) ⁻¹' s' = t } _ _ _ _ ht
  · rintro t' ⟨s', hs', rfl⟩
    

Proof state:
case refine'_1.intro.intro
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝¹ : MeasurableSpace β
inst✝ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s'✝ t✝ : Set α
t : Set ↑s
hs : NullMeasurableSet s
ht : MeasurableSet t
s' : Set α
hs' : MeasurableSet s'
⊢ NullMeasurableSet (Subtype.val '' (Subtype.val ⁻¹' s'))

Next tactic:
rw [Subtype.image_preimage_coe]
theorem MeasurableSet.nullMeasurableSet_subtype_coe {t : Set s} (hs : NullMeasurableSet s μ)
    (ht : MeasurableSet t) : NullMeasurableSet ((↑) '' t) μ := by
  rw [Subtype.instMeasurableSpace, comap_eq_generateFrom] at ht
  refine'
    generateFrom_induction (p := fun t : Set s => NullMeasurableSet ((↑) '' t) μ)
      { t : Set s | ∃ s' : Set α, MeasurableSet s' ∧ (↑) ⁻¹' s' = t } _ _ _ _ ht
  · rintro t' ⟨s', hs', rfl⟩
    rw [Subtype.image_preimage_coe]
    

Proof state:
case refine'_1.intro.intro
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝¹ : MeasurableSpace β
inst✝ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s'✝ t✝ : Set α
t : Set ↑s
hs : NullMeasurableSet s
ht : MeasurableSet t
s' : Set α
hs' : MeasurableSet s'
⊢ NullMeasurableSet (s' ∩ s)

Next tactic:
exact hs'.nullMeasurableSet.inter hs
theorem MeasurableSet.nullMeasurableSet_subtype_coe {t : Set s} (hs : NullMeasurableSet s μ)
    (ht : MeasurableSet t) : NullMeasurableSet ((↑) '' t) μ := by
  rw [Subtype.instMeasurableSpace, comap_eq_generateFrom] at ht
  refine'
    generateFrom_induction (p := fun t : Set s => NullMeasurableSet ((↑) '' t) μ)
      { t : Set s | ∃ s' : Set α, MeasurableSet s' ∧ (↑) ⁻¹' s' = t } _ _ _ _ ht
  · rintro t' ⟨s', hs', rfl⟩
    rw [Subtype.image_preimage_coe]
    exact hs'.nullMeasurableSet.inter hs
  · 

Proof state:
case refine'_2
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝¹ : MeasurableSpace β
inst✝ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t✝ : Set α
t : Set ↑s
hs : NullMeasurableSet s
ht : MeasurableSet t
⊢ (fun t => NullMeasurableSet (Subtype.val '' t)) ∅

Next tactic:
simp only [image_empty, nullMeasurableSet_empty]
theorem MeasurableSet.nullMeasurableSet_subtype_coe {t : Set s} (hs : NullMeasurableSet s μ)
    (ht : MeasurableSet t) : NullMeasurableSet ((↑) '' t) μ := by
  rw [Subtype.instMeasurableSpace, comap_eq_generateFrom] at ht
  refine'
    generateFrom_induction (p := fun t : Set s => NullMeasurableSet ((↑) '' t) μ)
      { t : Set s | ∃ s' : Set α, MeasurableSet s' ∧ (↑) ⁻¹' s' = t } _ _ _ _ ht
  · rintro t' ⟨s', hs', rfl⟩
    rw [Subtype.image_preimage_coe]
    exact hs'.nullMeasurableSet.inter hs
  · simp only [image_empty, nullMeasurableSet_empty]
  · 

Proof state:
case refine'_3
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝¹ : MeasurableSpace β
inst✝ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t✝ : Set α
t : Set ↑s
hs : NullMeasurableSet s
ht : MeasurableSet t
⊢ ∀ (t : Set ↑s), (fun t => NullMeasurableSet (Subtype.val '' t)) t → (fun t => NullMeasurableSet (Subtype.val '' t)) tᶜ

Next tactic:
intro t'
theorem MeasurableSet.nullMeasurableSet_subtype_coe {t : Set s} (hs : NullMeasurableSet s μ)
    (ht : MeasurableSet t) : NullMeasurableSet ((↑) '' t) μ := by
  rw [Subtype.instMeasurableSpace, comap_eq_generateFrom] at ht
  refine'
    generateFrom_induction (p := fun t : Set s => NullMeasurableSet ((↑) '' t) μ)
      { t : Set s | ∃ s' : Set α, MeasurableSet s' ∧ (↑) ⁻¹' s' = t } _ _ _ _ ht
  · rintro t' ⟨s', hs', rfl⟩
    rw [Subtype.image_preimage_coe]
    exact hs'.nullMeasurableSet.inter hs
  · simp only [image_empty, nullMeasurableSet_empty]
  · intro t'
    

Proof state:
case refine'_3
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝¹ : MeasurableSpace β
inst✝ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t✝ : Set α
t : Set ↑s
hs : NullMeasurableSet s
ht : MeasurableSet t
t' : Set ↑s
⊢ (fun t => NullMeasurableSet (Subtype.val '' t)) t' → (fun t => NullMeasurableSet (Subtype.val '' t)) t'ᶜ

Next tactic:
simp only [← range_diff_image Subtype.coe_injective, Subtype.range_coe_subtype, setOf_mem_eq]
theorem MeasurableSet.nullMeasurableSet_subtype_coe {t : Set s} (hs : NullMeasurableSet s μ)
    (ht : MeasurableSet t) : NullMeasurableSet ((↑) '' t) μ := by
  rw [Subtype.instMeasurableSpace, comap_eq_generateFrom] at ht
  refine'
    generateFrom_induction (p := fun t : Set s => NullMeasurableSet ((↑) '' t) μ)
      { t : Set s | ∃ s' : Set α, MeasurableSet s' ∧ (↑) ⁻¹' s' = t } _ _ _ _ ht
  · rintro t' ⟨s', hs', rfl⟩
    rw [Subtype.image_preimage_coe]
    exact hs'.nullMeasurableSet.inter hs
  · simp only [image_empty, nullMeasurableSet_empty]
  · intro t'
    simp only [← range_diff_image Subtype.coe_injective, Subtype.range_coe_subtype, setOf_mem_eq]
    

Proof state:
case refine'_3
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝¹ : MeasurableSpace β
inst✝ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t✝ : Set α
t : Set ↑s
hs : NullMeasurableSet s
ht : MeasurableSet t
t' : Set ↑s
⊢ NullMeasurableSet (Subtype.val '' t') → NullMeasurableSet (s \ (fun a => ↑a) '' t')

Next tactic:
exact hs.diff
theorem MeasurableSet.nullMeasurableSet_subtype_coe {t : Set s} (hs : NullMeasurableSet s μ)
    (ht : MeasurableSet t) : NullMeasurableSet ((↑) '' t) μ := by
  rw [Subtype.instMeasurableSpace, comap_eq_generateFrom] at ht
  refine'
    generateFrom_induction (p := fun t : Set s => NullMeasurableSet ((↑) '' t) μ)
      { t : Set s | ∃ s' : Set α, MeasurableSet s' ∧ (↑) ⁻¹' s' = t } _ _ _ _ ht
  · rintro t' ⟨s', hs', rfl⟩
    rw [Subtype.image_preimage_coe]
    exact hs'.nullMeasurableSet.inter hs
  · simp only [image_empty, nullMeasurableSet_empty]
  · intro t'
    simp only [← range_diff_image Subtype.coe_injective, Subtype.range_coe_subtype, setOf_mem_eq]
    exact hs.diff
  · 

Proof state:
case refine'_4
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝¹ : MeasurableSpace β
inst✝ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t✝ : Set α
t : Set ↑s
hs : NullMeasurableSet s
ht : MeasurableSet t
⊢ ∀ (f : ℕ → Set ↑s),
    (∀ (n : ℕ), (fun t => NullMeasurableSet (Subtype.val '' t)) (f n)) →
      (fun t => NullMeasurableSet (Subtype.val '' t)) (⋃ i, f i)

Next tactic:
intro f
theorem MeasurableSet.nullMeasurableSet_subtype_coe {t : Set s} (hs : NullMeasurableSet s μ)
    (ht : MeasurableSet t) : NullMeasurableSet ((↑) '' t) μ := by
  rw [Subtype.instMeasurableSpace, comap_eq_generateFrom] at ht
  refine'
    generateFrom_induction (p := fun t : Set s => NullMeasurableSet ((↑) '' t) μ)
      { t : Set s | ∃ s' : Set α, MeasurableSet s' ∧ (↑) ⁻¹' s' = t } _ _ _ _ ht
  · rintro t' ⟨s', hs', rfl⟩
    rw [Subtype.image_preimage_coe]
    exact hs'.nullMeasurableSet.inter hs
  · simp only [image_empty, nullMeasurableSet_empty]
  · intro t'
    simp only [← range_diff_image Subtype.coe_injective, Subtype.range_coe_subtype, setOf_mem_eq]
    exact hs.diff
  · intro f
    

Proof state:
case refine'_4
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝¹ : MeasurableSpace β
inst✝ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t✝ : Set α
t : Set ↑s
hs : NullMeasurableSet s
ht : MeasurableSet t
f : ℕ → Set ↑s
⊢ (∀ (n : ℕ), (fun t => NullMeasurableSet (Subtype.val '' t)) (f n)) →
    (fun t => NullMeasurableSet (Subtype.val '' t)) (⋃ i, f i)

Next tactic:
dsimp only []
theorem MeasurableSet.nullMeasurableSet_subtype_coe {t : Set s} (hs : NullMeasurableSet s μ)
    (ht : MeasurableSet t) : NullMeasurableSet ((↑) '' t) μ := by
  rw [Subtype.instMeasurableSpace, comap_eq_generateFrom] at ht
  refine'
    generateFrom_induction (p := fun t : Set s => NullMeasurableSet ((↑) '' t) μ)
      { t : Set s | ∃ s' : Set α, MeasurableSet s' ∧ (↑) ⁻¹' s' = t } _ _ _ _ ht
  · rintro t' ⟨s', hs', rfl⟩
    rw [Subtype.image_preimage_coe]
    exact hs'.nullMeasurableSet.inter hs
  · simp only [image_empty, nullMeasurableSet_empty]
  · intro t'
    simp only [← range_diff_image Subtype.coe_injective, Subtype.range_coe_subtype, setOf_mem_eq]
    exact hs.diff
  · intro f
    dsimp only []
    

Proof state:
case refine'_4
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝¹ : MeasurableSpace β
inst✝ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t✝ : Set α
t : Set ↑s
hs : NullMeasurableSet s
ht : MeasurableSet t
f : ℕ → Set ↑s
⊢ (∀ (n : ℕ), NullMeasurableSet (Subtype.val '' f n)) → NullMeasurableSet (Subtype.val '' ⋃ i, f i)

Next tactic:
rw [image_iUnion]
theorem MeasurableSet.nullMeasurableSet_subtype_coe {t : Set s} (hs : NullMeasurableSet s μ)
    (ht : MeasurableSet t) : NullMeasurableSet ((↑) '' t) μ := by
  rw [Subtype.instMeasurableSpace, comap_eq_generateFrom] at ht
  refine'
    generateFrom_induction (p := fun t : Set s => NullMeasurableSet ((↑) '' t) μ)
      { t : Set s | ∃ s' : Set α, MeasurableSet s' ∧ (↑) ⁻¹' s' = t } _ _ _ _ ht
  · rintro t' ⟨s', hs', rfl⟩
    rw [Subtype.image_preimage_coe]
    exact hs'.nullMeasurableSet.inter hs
  · simp only [image_empty, nullMeasurableSet_empty]
  · intro t'
    simp only [← range_diff_image Subtype.coe_injective, Subtype.range_coe_subtype, setOf_mem_eq]
    exact hs.diff
  · intro f
    dsimp only []
    rw [image_iUnion]
    

Proof state:
case refine'_4
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝¹ : MeasurableSpace β
inst✝ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t✝ : Set α
t : Set ↑s
hs : NullMeasurableSet s
ht : MeasurableSet t
f : ℕ → Set ↑s
⊢ (∀ (n : ℕ), NullMeasurableSet (Subtype.val '' f n)) → NullMeasurableSet (⋃ i, Subtype.val '' f i)

Next tactic:
exact NullMeasurableSet.iUnion
theorem Subtype.volume_univ (hu : NullMeasurableSet u) : volume (univ : Set u) = volume u := by
  

Proof state:
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝² : MeasurableSpace β
inst✝¹ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t : Set α
u : Set δ
inst✝ : MeasureSpace δ
p : δ → Prop
hu : NullMeasurableSet u
⊢ ↑↑volume univ = ↑↑volume u

Next tactic:
rw [Subtype.volume_def, comap_apply₀ _ _ _ _ MeasurableSet.univ.nullMeasurableSet]
theorem Subtype.volume_univ (hu : NullMeasurableSet u) : volume (univ : Set u) = volume u := by
  rw [Subtype.volume_def, comap_apply₀ _ _ _ _ MeasurableSet.univ.nullMeasurableSet]
  · 

Proof state:
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝² : MeasurableSpace β
inst✝¹ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t : Set α
u : Set δ
inst✝ : MeasureSpace δ
p : δ → Prop
hu : NullMeasurableSet u
⊢ ↑↑volume (Subtype.val '' univ) = ↑↑volume u

Next tactic:
congr
theorem Subtype.volume_univ (hu : NullMeasurableSet u) : volume (univ : Set u) = volume u := by
  rw [Subtype.volume_def, comap_apply₀ _ _ _ _ MeasurableSet.univ.nullMeasurableSet]
  · congr
    

Proof state:
case e_a
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝² : MeasurableSpace β
inst✝¹ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t : Set α
u : Set δ
inst✝ : MeasureSpace δ
p : δ → Prop
hu : NullMeasurableSet u
⊢ Subtype.val '' univ = u

Next tactic:
simp only [image_univ, Subtype.range_coe_subtype, setOf_mem_eq]
theorem Subtype.volume_univ (hu : NullMeasurableSet u) : volume (univ : Set u) = volume u := by
  rw [Subtype.volume_def, comap_apply₀ _ _ _ _ MeasurableSet.univ.nullMeasurableSet]
  · congr
    simp only [image_univ, Subtype.range_coe_subtype, setOf_mem_eq]
  · 

Proof state:
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝² : MeasurableSpace β
inst✝¹ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t : Set α
u : Set δ
inst✝ : MeasureSpace δ
p : δ → Prop
hu : NullMeasurableSet u
⊢ Injective Subtype.val

Next tactic:
exact Subtype.coe_injective
theorem Subtype.volume_univ (hu : NullMeasurableSet u) : volume (univ : Set u) = volume u := by
  rw [Subtype.volume_def, comap_apply₀ _ _ _ _ MeasurableSet.univ.nullMeasurableSet]
  · congr
    simp only [image_univ, Subtype.range_coe_subtype, setOf_mem_eq]
  · exact Subtype.coe_injective
  · 

Proof state:
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
inst✝² : MeasurableSpace β
inst✝¹ : MeasurableSpace γ
μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α
s s' t : Set α
u : Set δ
inst✝ : MeasureSpace δ
p : δ → Prop
hu : NullMeasurableSet u
⊢ ∀ (s : Set ↑u), MeasurableSet s → NullMeasurableSet (Subtype.val '' s)

Next tactic:
exact fun t => MeasurableSet.nullMeasurableSet_subtype_coe hu
theorem map_comap (μ : Measure β) : (comap f μ).map f = μ.restrict (range f) := by
  

Proof state:
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
m1 : MeasurableSpace β
f : α → β
hf : MeasurableEmbedding f
μ : Measure β
⊢ Measure.map f (Measure.comap f μ) = Measure.restrict μ (range f)

Next tactic:
ext1 t ht
theorem map_comap (μ : Measure β) : (comap f μ).map f = μ.restrict (range f) := by
  ext1 t ht
  

Proof state:
case h
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
m1 : MeasurableSpace β
f : α → β
hf : MeasurableEmbedding f
μ : Measure β
t : Set β
ht : MeasurableSet t
⊢ ↑↑(Measure.map f (Measure.comap f μ)) t = ↑↑(Measure.restrict μ (range f)) t

Next tactic:
rw [hf.map_apply, comap_apply f hf.injective hf.measurableSet_image' _ (hf.measurable ht),
    image_preimage_eq_inter_range, Measure.restrict_apply ht]
theorem comap_apply (μ : Measure β) (s : Set α) : comap f μ s = μ (f '' s) :=
  calc
    comap f μ s = comap f μ (f ⁻¹' (f '' s)) := by 

Proof state:
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
m1 : MeasurableSpace β
f : α → β
hf : MeasurableEmbedding f
μ : Measure β
s : Set α
⊢ ↑↑(Measure.comap f μ) s = ↑↑(Measure.comap f μ) (f ⁻¹' (f '' s))

Next tactic:
rw [hf.injective.preimage_image]
theorem comap_apply (μ : Measure β) (s : Set α) : comap f μ s = μ (f '' s) :=
  calc
    comap f μ s = comap f μ (f ⁻¹' (f '' s)) := by rw [hf.injective.preimage_image]
    _ = (comap f μ).map f (f '' s) := (hf.map_apply _ _).symm
    _ = μ (f '' s) := by
      

Proof state:
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
m1 : MeasurableSpace β
f : α → β
hf : MeasurableEmbedding f
μ : Measure β
s : Set α
⊢ ↑↑(Measure.map f (Measure.comap f μ)) (f '' s) = ↑↑μ (f '' s)

Next tactic:
rw [hf.map_comap, restrict_apply' hf.measurableSet_range,
        inter_eq_self_of_subset_left (image_subset_range _ _)]
theorem comap_map (μ : Measure α) : (map f μ).comap f = μ := by
  

Proof state:
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
m1 : MeasurableSpace β
f : α → β
hf : MeasurableEmbedding f
μ : Measure α
⊢ Measure.comap f (Measure.map f μ) = μ

Next tactic:
ext t _
theorem comap_map (μ : Measure α) : (map f μ).comap f = μ := by
  ext t _
  

Proof state:
case h
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
m1 : MeasurableSpace β
f : α → β
hf : MeasurableEmbedding f
μ : Measure α
t : Set α
a✝ : MeasurableSet t
⊢ ↑↑(Measure.comap f (Measure.map f μ)) t = ↑↑μ t

Next tactic:
rw [hf.comap_apply, hf.map_apply, preimage_image_eq _ hf.injective]
theorem ae_map_iff {p : β → Prop} {μ : Measure α} : (∀ᵐ x ∂μ.map f, p x) ↔ ∀ᵐ x ∂μ, p (f x) := by
  

Proof state:
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
m1 : MeasurableSpace β
f : α → β
hf : MeasurableEmbedding f
p : β → Prop
μ : Measure α
⊢ (∀ᵐ (x : β) ∂Measure.map f μ, p x) ↔ ∀ᵐ (x : α) ∂μ, p (f x)

Next tactic:
simp only [ae_iff, hf.map_apply, preimage_setOf_eq]
theorem restrict_map (μ : Measure α) (s : Set β) :
    (μ.map f).restrict s = (μ.restrict <| f ⁻¹' s).map f :=
  Measure.ext fun t ht => by 

Proof state:
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
m1 : MeasurableSpace β
f : α → β
hf : MeasurableEmbedding f
μ : Measure α
s t : Set β
ht : MeasurableSet t
⊢ ↑↑(Measure.restrict (Measure.map f μ) s) t = ↑↑(Measure.map f (Measure.restrict μ (f ⁻¹' s))) t

Next tactic:
simp [hf.map_apply, ht, hf.measurable ht]
protected theorem comap_preimage (μ : Measure β) (s : Set β) :
    μ.comap f (f ⁻¹' s) = μ (s ∩ range f) := by
  

Proof state:
R : Type u_1
α : Type u_2
β : Type u_3
δ : Type u_4
γ : Type u_5
ι : Type u_6
m0 : MeasurableSpace α
m1 : MeasurableSpace β
f : α → β
hf : MeasurableEmbedding f
μ : Measure β
s : Set β
⊢ ↑↑(Measure.comap f μ) (f ⁻¹' s) = ↑↑μ (s ∩ range f)

Next tactic:
rw [← hf.map_apply, hf.map_comap, restrict_apply' hf.measurableSet_range]