l3lab/ntp-mathlib huggingface dataset:
/-- Let `t i` be a nonempty countable family of measurable sets in `α`. Let `g i : α → β` be a
family of measurable functions such that `g i` agrees with `g j` on `t i ∩ t j`. Then there exists
a measurable function `f : α → β` that agrees with each `g i` on `t i`.

We only need the assumption `[Nonempty ι]` to prove `[Nonempty (α → β)]`. -/
theorem exists_measurable_piecewise {ι} [Countable ι] [Nonempty ι] (t : ι → Set α)
    (t_meas : ∀ n, MeasurableSet (t n)) (g : ι → α → β) (hg : ∀ n, Measurable (g n))
    (ht : Pairwise fun i j => EqOn (g i) (g j) (t i ∩ t j)) :
    ∃ f : α → β, Measurable f ∧ ∀ n, EqOn f (g n) (t n) := by
  inhabit ι
  set g' : (i : ι) → t i → β := fun i => g i ∘ (↑)
  -- see #2184
  have ht' : ∀ (i j) (x : α) (hxi : x ∈ t i) (hxj : x ∈ t j), g' i ⟨x, hxi⟩ = g' j ⟨x, hxj⟩
  · intro i j x hxi hxj
    rcases eq_or_ne i j with rfl | hij
    · rfl
    · exact ht hij ⟨hxi, hxj⟩
  set f : (⋃ i, t i) → β := iUnionLift t g' ht' _ Subset.rfl
  have hfm : Measurable f := measurable_iUnionLift _ _ t_meas
    (fun i => (hg i).comp measurable_subtype_coe)
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι✝ : Sort uι
s t✝ u : Set α
m : MeasurableSpace α
mβ : MeasurableSpace β
mγ : MeasurableSpace γ
ι : Type u_6
inst✝¹ : Countable ι
inst✝ : Nonempty ι
t : ι → Set α
t_meas : ∀ (n : ι), MeasurableSet (t n)
g : ι → α → β
hg : ∀ (n : ι), Measurable (g n)
ht : Pairwise fun i j => EqOn (g i) (g j) (t i ∩ t j)
inhabited_h : Inhabited ι
g' : (i : ι) → ↑(t i) → β := fun i => g i ∘ Subtype.val
ht' :
  ∀ (i j : ι) (x : α) (hxi : x ∈ t i) (hxj : x ∈ t j),
    g' i { val := x, property := hxi } = g' j { val := x, property := hxj }
f : ↑(⋃ i, t i) → β := iUnionLift t g' ht' (⋃ i, t i) (_ : ⋃ i, t i ⊆ ⋃ i, t i)
hfm : Measurable f
⊢ ∃ f, Measurable f ∧ ∀ (n : ι), EqOn f (g n) (t n)

Next tactic:
classical
    refine ⟨fun x => if hx : x ∈ ⋃ i, t i then f ⟨x, hx⟩ else g default x,
      hfm.dite ((hg default).comp measurable_subtype_coe) (.iUnion t_meas), fun i x hx => ?_⟩
    simp only [dif_pos (mem_iUnion.2 ⟨i, hx⟩)]
    exact iUnionLift_of_mem ⟨x, mem_iUnion.2 ⟨i, hx⟩⟩ hx
/-- Let `t i` be a nonempty countable family of measurable sets in `α`. Let `g i : α → β` be a
family of measurable functions such that `g i` agrees with `g j` on `t i ∩ t j`. Then there exists
a measurable function `f : α → β` that agrees with each `g i` on `t i`.

We only need the assumption `[Nonempty ι]` to prove `[Nonempty (α → β)]`. -/
theorem exists_measurable_piecewise {ι} [Countable ι] [Nonempty ι] (t : ι → Set α)
    (t_meas : ∀ n, MeasurableSet (t n)) (g : ι → α → β) (hg : ∀ n, Measurable (g n))
    (ht : Pairwise fun i j => EqOn (g i) (g j) (t i ∩ t j)) :
    ∃ f : α → β, Measurable f ∧ ∀ n, EqOn f (g n) (t n) := by
  inhabit ι
  set g' : (i : ι) → t i → β := fun i => g i ∘ (↑)
  -- see #2184
  have ht' : ∀ (i j) (x : α) (hxi : x ∈ t i) (hxj : x ∈ t j), g' i ⟨x, hxi⟩ = g' j ⟨x, hxj⟩
  · intro i j x hxi hxj
    rcases eq_or_ne i j with rfl | hij
    · rfl
    · exact ht hij ⟨hxi, hxj⟩
  set f : (⋃ i, t i) → β := iUnionLift t g' ht' _ Subset.rfl
  have hfm : Measurable f := measurable_iUnionLift _ _ t_meas
    (fun i => (hg i).comp measurable_subtype_coe)
  classical
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι✝ : Sort uι
s t✝ u : Set α
m : MeasurableSpace α
mβ : MeasurableSpace β
mγ : MeasurableSpace γ
ι : Type u_6
inst✝¹ : Countable ι
inst✝ : Nonempty ι
t : ι → Set α
t_meas : ∀ (n : ι), MeasurableSet (t n)
g : ι → α → β
hg : ∀ (n : ι), Measurable (g n)
ht : Pairwise fun i j => EqOn (g i) (g j) (t i ∩ t j)
inhabited_h : Inhabited ι
g' : (i : ι) → ↑(t i) → β := fun i => g i ∘ Subtype.val
ht' :
  ∀ (i j : ι) (x : α) (hxi : x ∈ t i) (hxj : x ∈ t j),
    g' i { val := x, property := hxi } = g' j { val := x, property := hxj }
f : ↑(⋃ i, t i) → β := iUnionLift t g' ht' (⋃ i, t i) (_ : ⋃ i, t i ⊆ ⋃ i, t i)
hfm : Measurable f
⊢ ∃ f, Measurable f ∧ ∀ (n : ι), EqOn f (g n) (t n)

Next tactic:
refine ⟨fun x => if hx : x ∈ ⋃ i, t i then f ⟨x, hx⟩ else g default x,
      hfm.dite ((hg default).comp measurable_subtype_coe) (.iUnion t_meas), fun i x hx => ?_⟩
/-- Let `t i` be a nonempty countable family of measurable sets in `α`. Let `g i : α → β` be a
family of measurable functions such that `g i` agrees with `g j` on `t i ∩ t j`. Then there exists
a measurable function `f : α → β` that agrees with each `g i` on `t i`.

We only need the assumption `[Nonempty ι]` to prove `[Nonempty (α → β)]`. -/
theorem exists_measurable_piecewise {ι} [Countable ι] [Nonempty ι] (t : ι → Set α)
    (t_meas : ∀ n, MeasurableSet (t n)) (g : ι → α → β) (hg : ∀ n, Measurable (g n))
    (ht : Pairwise fun i j => EqOn (g i) (g j) (t i ∩ t j)) :
    ∃ f : α → β, Measurable f ∧ ∀ n, EqOn f (g n) (t n) := by
  inhabit ι
  set g' : (i : ι) → t i → β := fun i => g i ∘ (↑)
  -- see #2184
  have ht' : ∀ (i j) (x : α) (hxi : x ∈ t i) (hxj : x ∈ t j), g' i ⟨x, hxi⟩ = g' j ⟨x, hxj⟩
  · intro i j x hxi hxj
    rcases eq_or_ne i j with rfl | hij
    · rfl
    · exact ht hij ⟨hxi, hxj⟩
  set f : (⋃ i, t i) → β := iUnionLift t g' ht' _ Subset.rfl
  have hfm : Measurable f := measurable_iUnionLift _ _ t_meas
    (fun i => (hg i).comp measurable_subtype_coe)
  classical
    refine ⟨fun x => if hx : x ∈ ⋃ i, t i then f ⟨x, hx⟩ else g default x,
      hfm.dite ((hg default).comp measurable_subtype_coe) (.iUnion t_meas), fun i x hx => ?_⟩
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι✝ : Sort uι
s t✝ u : Set α
m : MeasurableSpace α
mβ : MeasurableSpace β
mγ : MeasurableSpace γ
ι : Type u_6
inst✝¹ : Countable ι
inst✝ : Nonempty ι
t : ι → Set α
t_meas : ∀ (n : ι), MeasurableSet (t n)
g : ι → α → β
hg : ∀ (n : ι), Measurable (g n)
ht : Pairwise fun i j => EqOn (g i) (g j) (t i ∩ t j)
inhabited_h : Inhabited ι
g' : (i : ι) → ↑(t i) → β := fun i => g i ∘ Subtype.val
ht' :
  ∀ (i j : ι) (x : α) (hxi : x ∈ t i) (hxj : x ∈ t j),
    g' i { val := x, property := hxi } = g' j { val := x, property := hxj }
f : ↑(⋃ i, t i) → β := iUnionLift t g' ht' (⋃ i, t i) (_ : ⋃ i, t i ⊆ ⋃ i, t i)
hfm : Measurable f
i : ι
x : α
hx : x ∈ t i
⊢ (fun x => if hx : x ∈ ⋃ i, t i then f { val := x, property := hx } else g default x) x = g i x

Next tactic:
simp only [dif_pos (mem_iUnion.2 ⟨i, hx⟩)]
/-- Let `t i` be a nonempty countable family of measurable sets in `α`. Let `g i : α → β` be a
family of measurable functions such that `g i` agrees with `g j` on `t i ∩ t j`. Then there exists
a measurable function `f : α → β` that agrees with each `g i` on `t i`.

We only need the assumption `[Nonempty ι]` to prove `[Nonempty (α → β)]`. -/
theorem exists_measurable_piecewise {ι} [Countable ι] [Nonempty ι] (t : ι → Set α)
    (t_meas : ∀ n, MeasurableSet (t n)) (g : ι → α → β) (hg : ∀ n, Measurable (g n))
    (ht : Pairwise fun i j => EqOn (g i) (g j) (t i ∩ t j)) :
    ∃ f : α → β, Measurable f ∧ ∀ n, EqOn f (g n) (t n) := by
  inhabit ι
  set g' : (i : ι) → t i → β := fun i => g i ∘ (↑)
  -- see #2184
  have ht' : ∀ (i j) (x : α) (hxi : x ∈ t i) (hxj : x ∈ t j), g' i ⟨x, hxi⟩ = g' j ⟨x, hxj⟩
  · intro i j x hxi hxj
    rcases eq_or_ne i j with rfl | hij
    · rfl
    · exact ht hij ⟨hxi, hxj⟩
  set f : (⋃ i, t i) → β := iUnionLift t g' ht' _ Subset.rfl
  have hfm : Measurable f := measurable_iUnionLift _ _ t_meas
    (fun i => (hg i).comp measurable_subtype_coe)
  classical
    refine ⟨fun x => if hx : x ∈ ⋃ i, t i then f ⟨x, hx⟩ else g default x,
      hfm.dite ((hg default).comp measurable_subtype_coe) (.iUnion t_meas), fun i x hx => ?_⟩
    simp only [dif_pos (mem_iUnion.2 ⟨i, hx⟩)]
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι✝ : Sort uι
s t✝ u : Set α
m : MeasurableSpace α
mβ : MeasurableSpace β
mγ : MeasurableSpace γ
ι : Type u_6
inst✝¹ : Countable ι
inst✝ : Nonempty ι
t : ι → Set α
t_meas : ∀ (n : ι), MeasurableSet (t n)
g : ι → α → β
hg : ∀ (n : ι), Measurable (g n)
ht : Pairwise fun i j => EqOn (g i) (g j) (t i ∩ t j)
inhabited_h : Inhabited ι
g' : (i : ι) → ↑(t i) → β := fun i => g i ∘ Subtype.val
ht' :
  ∀ (i j : ι) (x : α) (hxi : x ∈ t i) (hxj : x ∈ t j),
    g' i { val := x, property := hxi } = g' j { val := x, property := hxj }
f : ↑(⋃ i, t i) → β := iUnionLift t g' ht' (⋃ i, t i) (_ : ⋃ i, t i ⊆ ⋃ i, t i)
hfm : Measurable f
i : ι
x : α
hx : x ∈ t i
⊢ iUnionLift t (fun i => g i ∘ Subtype.val) ht' (⋃ i, t i) (_ : ⋃ i, t i ⊆ ⋃ i, t i)
      { val := x, property := (_ : x ∈ ⋃ i, t i) } =
    g i x

Next tactic:
exact iUnionLift_of_mem ⟨x, mem_iUnion.2 ⟨i, hx⟩⟩ hx
/-- Given countably many disjoint measurable sets `t n` and countably many measurable
functions `g n`, one can construct a measurable function that coincides with `g n` on `t n`. -/
@[deprecated exists_measurable_piecewise]
theorem exists_measurable_piecewise_nat {m : MeasurableSpace α} (t : ℕ → Set β)
    (t_meas : ∀ n, MeasurableSet (t n)) (t_disj : Pairwise (Disjoint on t)) (g : ℕ → β → α)
    (hg : ∀ n, Measurable (g n)) : ∃ f : β → α, Measurable f ∧ ∀ n x, x ∈ t n → f x = g n x :=
  exists_measurable_piecewise t t_meas g hg <| t_disj.mono fun i j h => by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t✝ u : Set α
m✝ : MeasurableSpace α
mβ : MeasurableSpace β
mγ : MeasurableSpace γ
m : MeasurableSpace α
t : ℕ → Set β
t_meas : ∀ (n : ℕ), MeasurableSet (t n)
t_disj : Pairwise (Disjoint on t)
g : ℕ → β → α
hg : ∀ (n : ℕ), Measurable (g n)
i j : ℕ
h : (Disjoint on t) i j
⊢ EqOn (g i) (g j) (t i ∩ t j)

Next tactic:
simp only [h.inter_eq, eqOn_empty]
theorem measurable_pi_iff {g : α → ∀ a, π a} : Measurable g ↔ ∀ a, Measurable fun x => g x a := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝² : MeasurableSpace α
inst✝¹ : (a : δ) → MeasurableSpace (π a)
inst✝ : MeasurableSpace γ
g : α → (a : δ) → π a
⊢ Measurable g ↔ ∀ (a : δ), Measurable fun x => g x a

Next tactic:
simp_rw [measurable_iff_comap_le, MeasurableSpace.pi, MeasurableSpace.comap_iSup,
    MeasurableSpace.comap_comp, Function.comp, iSup_le_iff]
/-- The function `(f, x) ↦ update f a x : (Π a, π a) × π a → Π a, π a` is measurable. -/
theorem measurable_update'  {a : δ} [DecidableEq δ] :
    Measurable (fun p : (∀ i, π i) × π a ↦ update p.1 a p.2) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝³ : MeasurableSpace α
inst✝² : (a : δ) → MeasurableSpace (π a)
inst✝¹ : MeasurableSpace γ
a : δ
inst✝ : DecidableEq δ
⊢ Measurable fun p => update p.1 a p.2

Next tactic:
rw [measurable_pi_iff]
/-- The function `(f, x) ↦ update f a x : (Π a, π a) × π a → Π a, π a` is measurable. -/
theorem measurable_update'  {a : δ} [DecidableEq δ] :
    Measurable (fun p : (∀ i, π i) × π a ↦ update p.1 a p.2) := by
  rw [measurable_pi_iff]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝³ : MeasurableSpace α
inst✝² : (a : δ) → MeasurableSpace (π a)
inst✝¹ : MeasurableSpace γ
a : δ
inst✝ : DecidableEq δ
⊢ ∀ (a_1 : δ), Measurable fun x => update x.1 a x.2 a_1

Next tactic:
intro j
/-- The function `(f, x) ↦ update f a x : (Π a, π a) × π a → Π a, π a` is measurable. -/
theorem measurable_update'  {a : δ} [DecidableEq δ] :
    Measurable (fun p : (∀ i, π i) × π a ↦ update p.1 a p.2) := by
  rw [measurable_pi_iff]
  intro j
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝³ : MeasurableSpace α
inst✝² : (a : δ) → MeasurableSpace (π a)
inst✝¹ : MeasurableSpace γ
a : δ
inst✝ : DecidableEq δ
j : δ
⊢ Measurable fun x => update x.1 a x.2 j

Next tactic:
dsimp [update]
/-- The function `(f, x) ↦ update f a x : (Π a, π a) × π a → Π a, π a` is measurable. -/
theorem measurable_update'  {a : δ} [DecidableEq δ] :
    Measurable (fun p : (∀ i, π i) × π a ↦ update p.1 a p.2) := by
  rw [measurable_pi_iff]
  intro j
  dsimp [update]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝³ : MeasurableSpace α
inst✝² : (a : δ) → MeasurableSpace (π a)
inst✝¹ : MeasurableSpace γ
a : δ
inst✝ : DecidableEq δ
j : δ
⊢ Measurable fun x => if h : j = a then (_ : a = j) ▸ x.2 else x.1 j

Next tactic:
split_ifs with h
/-- The function `(f, x) ↦ update f a x : (Π a, π a) × π a → Π a, π a` is measurable. -/
theorem measurable_update'  {a : δ} [DecidableEq δ] :
    Measurable (fun p : (∀ i, π i) × π a ↦ update p.1 a p.2) := by
  rw [measurable_pi_iff]
  intro j
  dsimp [update]
  split_ifs with h
  · 

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝³ : MeasurableSpace α
inst✝² : (a : δ) → MeasurableSpace (π a)
inst✝¹ : MeasurableSpace γ
a : δ
inst✝ : DecidableEq δ
j : δ
h : j = a
⊢ Measurable fun x => (_ : a = j) ▸ x.2

Next tactic:
subst h
/-- The function `(f, x) ↦ update f a x : (Π a, π a) × π a → Π a, π a` is measurable. -/
theorem measurable_update'  {a : δ} [DecidableEq δ] :
    Measurable (fun p : (∀ i, π i) × π a ↦ update p.1 a p.2) := by
  rw [measurable_pi_iff]
  intro j
  dsimp [update]
  split_ifs with h
  · subst h
    

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝³ : MeasurableSpace α
inst✝² : (a : δ) → MeasurableSpace (π a)
inst✝¹ : MeasurableSpace γ
inst✝ : DecidableEq δ
j : δ
⊢ Measurable fun x => (_ : j = j) ▸ x.2

Next tactic:
dsimp
/-- The function `(f, x) ↦ update f a x : (Π a, π a) × π a → Π a, π a` is measurable. -/
theorem measurable_update'  {a : δ} [DecidableEq δ] :
    Measurable (fun p : (∀ i, π i) × π a ↦ update p.1 a p.2) := by
  rw [measurable_pi_iff]
  intro j
  dsimp [update]
  split_ifs with h
  · subst h
    dsimp
    

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝³ : MeasurableSpace α
inst✝² : (a : δ) → MeasurableSpace (π a)
inst✝¹ : MeasurableSpace γ
inst✝ : DecidableEq δ
j : δ
⊢ Measurable fun x => x.2

Next tactic:
exact measurable_snd
/-- The function `(f, x) ↦ update f a x : (Π a, π a) × π a → Π a, π a` is measurable. -/
theorem measurable_update'  {a : δ} [DecidableEq δ] :
    Measurable (fun p : (∀ i, π i) × π a ↦ update p.1 a p.2) := by
  rw [measurable_pi_iff]
  intro j
  dsimp [update]
  split_ifs with h
  · subst h
    dsimp
    exact measurable_snd
  · 

Proof state:
case neg
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝³ : MeasurableSpace α
inst✝² : (a : δ) → MeasurableSpace (π a)
inst✝¹ : MeasurableSpace γ
a : δ
inst✝ : DecidableEq δ
j : δ
h : ¬j = a
⊢ Measurable fun x => x.1 j

Next tactic:
exact measurable_pi_iff.1 measurable_fst _
theorem measurable_uniqueElim [Unique δ] [∀ i, MeasurableSpace (π i)] :
    Measurable (uniqueElim : π (default : δ) → ∀ i, π i) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝⁴ : MeasurableSpace α
inst✝³ : (a : δ) → MeasurableSpace (π a)
inst✝² : MeasurableSpace γ
inst✝¹ : Unique δ
inst✝ : (i : δ) → MeasurableSpace (π i)
⊢ Measurable uniqueElim

Next tactic:
simp_rw [measurable_pi_iff, Unique.forall_iff, uniqueElim_default]
theorem measurable_uniqueElim [Unique δ] [∀ i, MeasurableSpace (π i)] :
    Measurable (uniqueElim : π (default : δ) → ∀ i, π i) := by
  simp_rw [measurable_pi_iff, Unique.forall_iff, uniqueElim_default]; 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝⁴ : MeasurableSpace α
inst✝³ : (a : δ) → MeasurableSpace (π a)
inst✝² : MeasurableSpace γ
inst✝¹ : Unique δ
inst✝ : (i : δ) → MeasurableSpace (π i)
⊢ Measurable fun x => x

Next tactic:
exact measurable_id
theorem measurable_updateFinset [DecidableEq δ] {s : Finset δ} {x : ∀ i, π i} :
    Measurable (updateFinset x s) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s✝ t u : Set α
π : δ → Type u_6
inst✝³ : MeasurableSpace α
inst✝² : (a : δ) → MeasurableSpace (π a)
inst✝¹ : MeasurableSpace γ
inst✝ : DecidableEq δ
s : Finset δ
x : (i : δ) → π i
⊢ Measurable (updateFinset x s)

Next tactic:
simp (config := { unfoldPartialApp := true }) only [updateFinset, measurable_pi_iff]
theorem measurable_updateFinset [DecidableEq δ] {s : Finset δ} {x : ∀ i, π i} :
    Measurable (updateFinset x s) := by
  simp (config := { unfoldPartialApp := true }) only [updateFinset, measurable_pi_iff]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s✝ t u : Set α
π : δ → Type u_6
inst✝³ : MeasurableSpace α
inst✝² : (a : δ) → MeasurableSpace (π a)
inst✝¹ : MeasurableSpace γ
inst✝ : DecidableEq δ
s : Finset δ
x : (i : δ) → π i
⊢ ∀ (a : δ), Measurable fun x_1 => if hi : a ∈ s then x_1 { val := a, property := hi } else x a

Next tactic:
intro i
theorem measurable_updateFinset [DecidableEq δ] {s : Finset δ} {x : ∀ i, π i} :
    Measurable (updateFinset x s) := by
  simp (config := { unfoldPartialApp := true }) only [updateFinset, measurable_pi_iff]
  intro i
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s✝ t u : Set α
π : δ → Type u_6
inst✝³ : MeasurableSpace α
inst✝² : (a : δ) → MeasurableSpace (π a)
inst✝¹ : MeasurableSpace γ
inst✝ : DecidableEq δ
s : Finset δ
x : (i : δ) → π i
i : δ
⊢ Measurable fun x_1 => if hi : i ∈ s then x_1 { val := i, property := hi } else x i

Next tactic:
by_cases h : i ∈ s
theorem measurable_updateFinset [DecidableEq δ] {s : Finset δ} {x : ∀ i, π i} :
    Measurable (updateFinset x s) := by
  simp (config := { unfoldPartialApp := true }) only [updateFinset, measurable_pi_iff]
  intro i
  by_cases h : i ∈ s <;> 

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s✝ t u : Set α
π : δ → Type u_6
inst✝³ : MeasurableSpace α
inst✝² : (a : δ) → MeasurableSpace (π a)
inst✝¹ : MeasurableSpace γ
inst✝ : DecidableEq δ
s : Finset δ
x : (i : δ) → π i
i : δ
h : i ∈ s
⊢ Measurable fun x_1 => if hi : i ∈ s then x_1 { val := i, property := hi } else x i

Next tactic:
simp [h, measurable_pi_apply]
theorem measurable_updateFinset [DecidableEq δ] {s : Finset δ} {x : ∀ i, π i} :
    Measurable (updateFinset x s) := by
  simp (config := { unfoldPartialApp := true }) only [updateFinset, measurable_pi_iff]
  intro i
  by_cases h : i ∈ s <;> 

Proof state:
case neg
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s✝ t u : Set α
π : δ → Type u_6
inst✝³ : MeasurableSpace α
inst✝² : (a : δ) → MeasurableSpace (π a)
inst✝¹ : MeasurableSpace γ
inst✝ : DecidableEq δ
s : Finset δ
x : (i : δ) → π i
i : δ
h : i ∉ s
⊢ Measurable fun x_1 => if hi : i ∈ s then x_1 { val := i, property := hi } else x i

Next tactic:
simp [h, measurable_pi_apply]
variable (π) in
theorem measurable_eq_mp {i i' : δ} (h : i = i') : Measurable (congr_arg π h).mp := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝² : MeasurableSpace α
inst✝¹ : (a : δ) → MeasurableSpace (π a)
inst✝ : MeasurableSpace γ
i i' : δ
h : i = i'
⊢ Measurable (Eq.mp (_ : π i = π i'))

Next tactic:
cases h
variable (π) in
theorem measurable_eq_mp {i i' : δ} (h : i = i') : Measurable (congr_arg π h).mp := by
  cases h
  

Proof state:
case refl
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝² : MeasurableSpace α
inst✝¹ : (a : δ) → MeasurableSpace (π a)
inst✝ : MeasurableSpace γ
i : δ
⊢ Measurable (Eq.mp (_ : π i = π i))

Next tactic:
exact measurable_id
theorem measurable_piCongrLeft (f : δ' ≃ δ) : Measurable (piCongrLeft π f) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝² : MeasurableSpace α
inst✝¹ : (a : δ) → MeasurableSpace (π a)
inst✝ : MeasurableSpace γ
f : δ' ≃ δ
⊢ Measurable ⇑(piCongrLeft π f)

Next tactic:
rw [measurable_pi_iff]
theorem measurable_piCongrLeft (f : δ' ≃ δ) : Measurable (piCongrLeft π f) := by
  rw [measurable_pi_iff]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝² : MeasurableSpace α
inst✝¹ : (a : δ) → MeasurableSpace (π a)
inst✝ : MeasurableSpace γ
f : δ' ≃ δ
⊢ ∀ (a : δ), Measurable fun x => (piCongrLeft π f) x a

Next tactic:
intro i
theorem measurable_piCongrLeft (f : δ' ≃ δ) : Measurable (piCongrLeft π f) := by
  rw [measurable_pi_iff]
  intro i
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝² : MeasurableSpace α
inst✝¹ : (a : δ) → MeasurableSpace (π a)
inst✝ : MeasurableSpace γ
f : δ' ≃ δ
i : δ
⊢ Measurable fun x => (piCongrLeft π f) x i

Next tactic:
simp_rw [piCongrLeft_apply_eq_cast]
theorem measurable_piCongrLeft (f : δ' ≃ δ) : Measurable (piCongrLeft π f) := by
  rw [measurable_pi_iff]
  intro i
  simp_rw [piCongrLeft_apply_eq_cast]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s t u : Set α
π : δ → Type u_6
inst✝² : MeasurableSpace α
inst✝¹ : (a : δ) → MeasurableSpace (π a)
inst✝ : MeasurableSpace γ
f : δ' ≃ δ
i : δ
⊢ Measurable fun x => cast (_ : π (f (f.symm i)) = π i) (x (f.symm i))

Next tactic:
exact Measurable.eq_mp π (f.apply_symm_apply i) <| measurable_pi_apply <| f.symm i
@[measurability]
protected theorem MeasurableSet.pi {s : Set δ} {t : ∀ i : δ, Set (π i)} (hs : s.Countable)
    (ht : ∀ i ∈ s, MeasurableSet (t i)) : MeasurableSet (s.pi t) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s✝ t✝ u : Set α
π : δ → Type u_6
inst✝² : MeasurableSpace α
inst✝¹ : (a : δ) → MeasurableSpace (π a)
inst✝ : MeasurableSpace γ
s : Set δ
t : (i : δ) → Set (π i)
hs : Set.Countable s
ht : ∀ i ∈ s, MeasurableSet (t i)
⊢ MeasurableSet (Set.pi s t)

Next tactic:
rw [pi_def]
@[measurability]
protected theorem MeasurableSet.pi {s : Set δ} {t : ∀ i : δ, Set (π i)} (hs : s.Countable)
    (ht : ∀ i ∈ s, MeasurableSet (t i)) : MeasurableSet (s.pi t) := by
  rw [pi_def]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s✝ t✝ u : Set α
π : δ → Type u_6
inst✝² : MeasurableSpace α
inst✝¹ : (a : δ) → MeasurableSpace (π a)
inst✝ : MeasurableSpace γ
s : Set δ
t : (i : δ) → Set (π i)
hs : Set.Countable s
ht : ∀ i ∈ s, MeasurableSet (t i)
⊢ MeasurableSet (⋂ a ∈ s, eval a ⁻¹' t a)

Next tactic:
exact MeasurableSet.biInter hs fun i hi => measurable_pi_apply _ (ht i hi)
theorem measurableSet_pi_of_nonempty {s : Set δ} {t : ∀ i, Set (π i)} (hs : s.Countable)
    (h : (pi s t).Nonempty) : MeasurableSet (pi s t) ↔ ∀ i ∈ s, MeasurableSet (t i) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s✝ t✝ u : Set α
π : δ → Type u_6
inst✝² : MeasurableSpace α
inst✝¹ : (a : δ) → MeasurableSpace (π a)
inst✝ : MeasurableSpace γ
s : Set δ
t : (i : δ) → Set (π i)
hs : Set.Countable s
h : Set.Nonempty (Set.pi s t)
⊢ MeasurableSet (Set.pi s t) ↔ ∀ i ∈ s, MeasurableSet (t i)

Next tactic:
classical
    rcases h with ⟨f, hf⟩
    refine' ⟨fun hst i hi => _, MeasurableSet.pi hs⟩
    convert measurable_update f (a := i) hst
    rw [update_preimage_pi hi]
    exact fun j hj _ => hf j hj
theorem measurableSet_pi_of_nonempty {s : Set δ} {t : ∀ i, Set (π i)} (hs : s.Countable)
    (h : (pi s t).Nonempty) : MeasurableSet (pi s t) ↔ ∀ i ∈ s, MeasurableSet (t i) := by
  classical
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
δ' : Type u_5
ι : Sort uι
s✝ t✝ u : Set α
π : δ → Type u_6
inst✝² : MeasurableSpace α
inst✝¹ : (a : δ) → MeasurableSpace (π a)
inst✝ : MeasurableSpace γ
s : Set δ
t : (i : δ) → Set (π i)
hs : Set.Countable s
h : Set.Nonempty (Set.pi s t)
⊢ MeasurableSet (Set.pi s t) ↔ ∀ i ∈ s, MeasurableSet (t i)

Next tactic:
rcases h with ⟨f, hf⟩