l3lab/ntp-mathlib huggingface dataset:
/-- Equality case in the **Schwarz Lemma**: in the setup of `norm_dslope_le_div_of_mapsTo_ball`, if
`‖dslope f c z₀‖ = R₂ / R₁` holds at a point in the ball then the map `f` is affine. -/
theorem affine_of_mapsTo_ball_of_exists_norm_dslope_eq_div [CompleteSpace E] [StrictConvexSpace ℝ E]
    (hd : DifferentiableOn ℂ f (ball c R₁)) (h_maps : Set.MapsTo f (ball c R₁) (ball (f c) R₂))
    (h_z₀ : z₀ ∈ ball c R₁) (h_eq : ‖dslope f c z₀‖ = R₂ / R₁) :
    Set.EqOn f (fun z => f c + (z - c) • dslope f c z₀) (ball c R₁) := by
  set g := dslope f c
  rintro z hz
  by_cases h : z = c; · simp [h]
  have h_R₁ : 0 < R₁ := nonempty_ball.mp ⟨_, h_z₀⟩
  have g_le_div : ∀ z ∈ ball c R₁, ‖g z‖ ≤ R₂ / R₁ := fun z hz =>
    norm_dslope_le_div_of_mapsTo_ball hd h_maps hz
  have g_max : IsMaxOn (norm ∘ g) (ball c R₁) z₀ :=
    isMaxOn_iff.mpr fun z hz => by simpa [h_eq] using g_le_div z hz
  have g_diff : DifferentiableOn ℂ g (ball c R₁) :=
    (differentiableOn_dslope (isOpen_ball.mem_nhds (mem_ball_self h_R₁))).mpr hd
  have : g z = g z₀ := eqOn_of_isPreconnected_of_isMaxOn_norm (convex_ball c R₁).isPreconnected
    isOpen_ball g_diff h_z₀ g_max hz
  

Proof state:
case neg
E : Type u_1
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℂ E
R R₁ R₂ : ℝ
f : ℂ → E
c z✝ z₀ : ℂ
inst✝¹ : CompleteSpace E
inst✝ : StrictConvexSpace ℝ E
hd : DifferentiableOn ℂ f (ball c R₁)
h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)
h_z₀ : z₀ ∈ ball c R₁
g : ℂ → E := dslope f c
h_eq : ‖g z₀‖ = R₂ / R₁
z : ℂ
hz : z ∈ ball c R₁
h : ¬z = c
h_R₁ : 0 < R₁
g_le_div : ∀ z ∈ ball c R₁, ‖g z‖ ≤ R₂ / R₁
g_max : IsMaxOn (norm ∘ g) (ball c R₁) z₀
g_diff : DifferentiableOn ℂ g (ball c R₁)
this : g z = g z₀
⊢ f z = (fun z => f c + (z - c) • g z₀) z

Next tactic:
simp [← this]
/-- The **Schwarz Lemma**: if `f : ℂ → E` sends an open disk with center `c` and a positive radius
`R₁` to an open ball with center `f c` and radius `R₂`, then the absolute value of the derivative of
`f` at `c` is at most the ratio `R₂ / R₁`. -/
theorem norm_deriv_le_div_of_mapsTo_ball (hd : DifferentiableOn ℂ f (ball c R₁))
    (h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)) (h₀ : 0 < R₁) : ‖deriv f c‖ ≤ R₂ / R₁ := by
  

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℂ E
R R₁ R₂ : ℝ
f : ℂ → E
c z z₀ : ℂ
hd : DifferentiableOn ℂ f (ball c R₁)
h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)
h₀ : 0 < R₁
⊢ ‖deriv f c‖ ≤ R₂ / R₁

Next tactic:
simpa only [dslope_same] using norm_dslope_le_div_of_mapsTo_ball hd h_maps (mem_ball_self h₀)
/-- The **Schwarz Lemma**: if `f : ℂ → E` sends an open disk with center `c` and radius `R₁` to an
open ball with center `f c` and radius `R₂`, then for any `z` in the former disk we have
`dist (f z) (f c) ≤ (R₂ / R₁) * dist z c`. -/
theorem dist_le_div_mul_dist_of_mapsTo_ball (hd : DifferentiableOn ℂ f (ball c R₁))
    (h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)) (hz : z ∈ ball c R₁) :
    dist (f z) (f c) ≤ R₂ / R₁ * dist z c := by
  

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℂ E
R R₁ R₂ : ℝ
f : ℂ → E
c z z₀ : ℂ
hd : DifferentiableOn ℂ f (ball c R₁)
h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)
hz : z ∈ ball c R₁
⊢ dist (f z) (f c) ≤ R₂ / R₁ * dist z c

Next tactic:
rcases eq_or_ne z c with (rfl | hne)
/-- The **Schwarz Lemma**: if `f : ℂ → E` sends an open disk with center `c` and radius `R₁` to an
open ball with center `f c` and radius `R₂`, then for any `z` in the former disk we have
`dist (f z) (f c) ≤ (R₂ / R₁) * dist z c`. -/
theorem dist_le_div_mul_dist_of_mapsTo_ball (hd : DifferentiableOn ℂ f (ball c R₁))
    (h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)) (hz : z ∈ ball c R₁) :
    dist (f z) (f c) ≤ R₂ / R₁ * dist z c := by
  rcases eq_or_ne z c with (rfl | hne);
  · 

Proof state:
case inl
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℂ E
R R₁ R₂ : ℝ
f : ℂ → E
z z₀ : ℂ
hd : DifferentiableOn ℂ f (ball z R₁)
h_maps : MapsTo f (ball z R₁) (ball (f z) R₂)
hz : z ∈ ball z R₁
⊢ dist (f z) (f z) ≤ R₂ / R₁ * dist z z

Next tactic:
simp only [dist_self, mul_zero, le_rfl]
/-- The **Schwarz Lemma**: if `f : ℂ → E` sends an open disk with center `c` and radius `R₁` to an
open ball with center `f c` and radius `R₂`, then for any `z` in the former disk we have
`dist (f z) (f c) ≤ (R₂ / R₁) * dist z c`. -/
theorem dist_le_div_mul_dist_of_mapsTo_ball (hd : DifferentiableOn ℂ f (ball c R₁))
    (h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)) (hz : z ∈ ball c R₁) :
    dist (f z) (f c) ≤ R₂ / R₁ * dist z c := by
  rcases eq_or_ne z c with (rfl | hne);
  · simp only [dist_self, mul_zero, le_rfl]
  

Proof state:
case inr
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℂ E
R R₁ R₂ : ℝ
f : ℂ → E
c z z₀ : ℂ
hd : DifferentiableOn ℂ f (ball c R₁)
h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)
hz : z ∈ ball c R₁
hne : z ≠ c
⊢ dist (f z) (f c) ≤ R₂ / R₁ * dist z c

Next tactic:
simpa only [dslope_of_ne _ hne, slope_def_module, norm_smul, norm_inv, ← div_eq_inv_mul, ←
    dist_eq_norm, div_le_iff (dist_pos.2 hne)] using norm_dslope_le_div_of_mapsTo_ball hd h_maps hz
/-- The **Schwarz Lemma**: if `f : ℂ → ℂ` sends an open disk of positive radius to itself and the
center of this disk to itself, then the absolute value of the derivative of `f` at the center of
this disk is at most `1`. -/
theorem abs_deriv_le_one_of_mapsTo_ball (hd : DifferentiableOn ℂ f (ball c R))
    (h_maps : MapsTo f (ball c R) (ball c R)) (hc : f c = c) (h₀ : 0 < R) : abs (deriv f c) ≤ 1 :=
  (norm_deriv_le_div_of_mapsTo_ball hd (by 

Proof state:
f : ℂ → ℂ
c z : ℂ
R R₁ R₂ : ℝ
hd : DifferentiableOn ℂ f (ball c R)
h_maps : MapsTo f (ball c R) (ball c R)
hc : f c = c
h₀ : 0 < R
⊢ MapsTo f (ball c R) (ball (f c) R)

Next tactic:
rwa [hc]
/-- The **Schwarz Lemma**: if `f : ℂ → ℂ` sends an open disk to itself and the center `c` of this
disk to itself, then for any point `z` of this disk we have `dist (f z) c ≤ dist z c`. -/
theorem dist_le_dist_of_mapsTo_ball_self (hd : DifferentiableOn ℂ f (ball c R))
    (h_maps : MapsTo f (ball c R) (ball c R)) (hc : f c = c) (hz : z ∈ ball c R) :
    dist (f z) c ≤ dist z c := by
  -- porting note: `simp` was failing to use `div_self`
  

Proof state:
f : ℂ → ℂ
c z : ℂ
R R₁ R₂ : ℝ
hd : DifferentiableOn ℂ f (ball c R)
h_maps : MapsTo f (ball c R) (ball c R)
hc : f c = c
hz : z ∈ ball c R
⊢ dist (f z) c ≤ dist z c

Next tactic:
have := dist_le_div_mul_dist_of_mapsTo_ball hd (by rwa [hc]) hz
/-- The **Schwarz Lemma**: if `f : ℂ → ℂ` sends an open disk to itself and the center `c` of this
disk to itself, then for any point `z` of this disk we have `dist (f z) c ≤ dist z c`. -/
theorem dist_le_dist_of_mapsTo_ball_self (hd : DifferentiableOn ℂ f (ball c R))
    (h_maps : MapsTo f (ball c R) (ball c R)) (hc : f c = c) (hz : z ∈ ball c R) :
    dist (f z) c ≤ dist z c := by
  -- porting note: `simp` was failing to use `div_self`
  have := dist_le_div_mul_dist_of_mapsTo_ball hd (by 

Proof state:
f : ℂ → ℂ
c z : ℂ
R R₁ R₂ : ℝ
hd : DifferentiableOn ℂ f (ball c R)
h_maps : MapsTo f (ball c R) (ball c R)
hc : f c = c
hz : z ∈ ball c R
⊢ MapsTo f (ball c R) (ball (f c) ?m.40012)

Next tactic:
rwa [hc]
/-- The **Schwarz Lemma**: if `f : ℂ → ℂ` sends an open disk to itself and the center `c` of this
disk to itself, then for any point `z` of this disk we have `dist (f z) c ≤ dist z c`. -/
theorem dist_le_dist_of_mapsTo_ball_self (hd : DifferentiableOn ℂ f (ball c R))
    (h_maps : MapsTo f (ball c R) (ball c R)) (hc : f c = c) (hz : z ∈ ball c R) :
    dist (f z) c ≤ dist z c := by
  -- porting note: `simp` was failing to use `div_self`
  have := dist_le_div_mul_dist_of_mapsTo_ball hd (by rwa [hc]) hz
  

Proof state:
f : ℂ → ℂ
c z : ℂ
R R₁ R₂ : ℝ
hd : DifferentiableOn ℂ f (ball c R)
h_maps : MapsTo f (ball c R) (ball c R)
hc : f c = c
hz : z ∈ ball c R
this : dist (f z) (f c) ≤ R / R * dist z c
⊢ dist (f z) c ≤ dist z c

Next tactic:
rwa [hc, div_self, one_mul] at this
/-- The **Schwarz Lemma**: if `f : ℂ → ℂ` sends an open disk to itself and the center `c` of this
disk to itself, then for any point `z` of this disk we have `dist (f z) c ≤ dist z c`. -/
theorem dist_le_dist_of_mapsTo_ball_self (hd : DifferentiableOn ℂ f (ball c R))
    (h_maps : MapsTo f (ball c R) (ball c R)) (hc : f c = c) (hz : z ∈ ball c R) :
    dist (f z) c ≤ dist z c := by
  -- porting note: `simp` was failing to use `div_self`
  have := dist_le_div_mul_dist_of_mapsTo_ball hd (by rwa [hc]) hz
  rwa [hc, div_self, one_mul] at this
  

Proof state:
f : ℂ → ℂ
c z : ℂ
R R₁ R₂ : ℝ
hd : DifferentiableOn ℂ f (ball c R)
h_maps : MapsTo f (ball c R) (ball c R)
hc : f c = c
hz : z ∈ ball c R
this : dist (f z) c ≤ R / R * dist z c
⊢ R ≠ 0

Next tactic:
exact (nonempty_ball.1 ⟨z, hz⟩).ne'
/-- The **Schwarz Lemma**: if `f : ℂ → ℂ` sends an open disk with center `0` to itself, then for any
point `z` of this disk we have `abs (f z) ≤ abs z`. -/
theorem abs_le_abs_of_mapsTo_ball_self (hd : DifferentiableOn ℂ f (ball 0 R))
    (h_maps : MapsTo f (ball 0 R) (ball 0 R)) (h₀ : f 0 = 0) (hz : abs z < R) :
    abs (f z) ≤ abs z := by
  

Proof state:
f : ℂ → ℂ
c z : ℂ
R R₁ R₂ : ℝ
hd : DifferentiableOn ℂ f (ball 0 R)
h_maps : MapsTo f (ball 0 R) (ball 0 R)
h₀ : f 0 = 0
hz : abs z < R
⊢ abs (f z) ≤ abs z

Next tactic:
replace hz : z ∈ ball (0 : ℂ) R
/-- The **Schwarz Lemma**: if `f : ℂ → ℂ` sends an open disk with center `0` to itself, then for any
point `z` of this disk we have `abs (f z) ≤ abs z`. -/
theorem abs_le_abs_of_mapsTo_ball_self (hd : DifferentiableOn ℂ f (ball 0 R))
    (h_maps : MapsTo f (ball 0 R) (ball 0 R)) (h₀ : f 0 = 0) (hz : abs z < R) :
    abs (f z) ≤ abs z := by
  replace hz : z ∈ ball (0 : ℂ) R; 

Proof state:
case hz
f : ℂ → ℂ
c z : ℂ
R R₁ R₂ : ℝ
hd : DifferentiableOn ℂ f (ball 0 R)
h_maps : MapsTo f (ball 0 R) (ball 0 R)
h₀ : f 0 = 0
hz : abs z < R
⊢ z ∈ ball 0 R
f : ℂ → ℂ
c z : ℂ
R R₁ R₂ : ℝ
hd : DifferentiableOn ℂ f (ball 0 R)
h_maps : MapsTo f (ball 0 R) (ball 0 R)
h₀ : f 0 = 0
hz : z ∈ ball 0 R
⊢ abs (f z) ≤ abs z

Next tactic:
exact mem_ball_zero_iff.2 hz
/-- The **Schwarz Lemma**: if `f : ℂ → ℂ` sends an open disk with center `0` to itself, then for any
point `z` of this disk we have `abs (f z) ≤ abs z`. -/
theorem abs_le_abs_of_mapsTo_ball_self (hd : DifferentiableOn ℂ f (ball 0 R))
    (h_maps : MapsTo f (ball 0 R) (ball 0 R)) (h₀ : f 0 = 0) (hz : abs z < R) :
    abs (f z) ≤ abs z := by
  replace hz : z ∈ ball (0 : ℂ) R; exact mem_ball_zero_iff.2 hz
  

Proof state:
f : ℂ → ℂ
c z : ℂ
R R₁ R₂ : ℝ
hd : DifferentiableOn ℂ f (ball 0 R)
h_maps : MapsTo f (ball 0 R) (ball 0 R)
h₀ : f 0 = 0
hz : z ∈ ball 0 R
⊢ abs (f z) ≤ abs z

Next tactic:
simpa only [dist_zero_right] using dist_le_dist_of_mapsTo_ball_self hd h_maps h₀ hz
theorem volume_preserving_equiv_pi : MeasurePreserving measurableEquivPi := by
  

Proof state:
⊢ MeasurePreserving ⇑measurableEquivPi

Next tactic:
convert (measurableEquivPi.symm.measurable.measurePreserving volume).symm
theorem volume_preserving_equiv_pi : MeasurePreserving measurableEquivPi := by
  convert (measurableEquivPi.symm.measurable.measurePreserving volume).symm
  

Proof state:
case h.e'_6
⊢ volume = Measure.map (⇑measurableEquivPi.symm) volume

Next tactic:
rw [← addHaarMeasure_eq_volume_pi, ← Basis.parallelepiped_basisFun, ← Basis.addHaar,
    measurableEquivPi, Homeomorph.toMeasurableEquiv_symm_coe,
    ContinuousLinearEquiv.symm_toHomeomorph, ContinuousLinearEquiv.coe_toHomeomorph,
    Basis.map_addHaar, eq_comm]
theorem volume_preserving_equiv_pi : MeasurePreserving measurableEquivPi := by
  convert (measurableEquivPi.symm.measurable.measurePreserving volume).symm
  rw [← addHaarMeasure_eq_volume_pi, ← Basis.parallelepiped_basisFun, ← Basis.addHaar,
    measurableEquivPi, Homeomorph.toMeasurableEquiv_symm_coe,
    ContinuousLinearEquiv.symm_toHomeomorph, ContinuousLinearEquiv.coe_toHomeomorph,
    Basis.map_addHaar, eq_comm]
  

Proof state:
case h.e'_6
⊢ Basis.addHaar
      (Basis.map (Pi.basisFun ℝ (Fin 2))
        (ContinuousLinearEquiv.symm (LinearEquiv.toContinuousLinearEquiv (Basis.equivFun basisOneI))).toLinearEquiv) =
    volume

Next tactic:
exact (Basis.addHaar_eq_iff _ _).mpr Complex.orthonormalBasisOneI.volume_parallelepiped
theorem _root_.Measurable.lmarginal (hf : Measurable f) : Measurable (∫⋯∫⁻_s, f ∂μ) := by
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f g : ((i : δ) → π i) → ℝ≥0∞
x y : (i : δ) → π i
i : δ
hf : Measurable f
⊢ Measurable (∫⋯∫⁻_s, f ∂μ)

Next tactic:
refine' Measurable.lintegral_prod_right _
theorem _root_.Measurable.lmarginal (hf : Measurable f) : Measurable (∫⋯∫⁻_s, f ∂μ) := by
  refine' Measurable.lintegral_prod_right _
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f g : ((i : δ) → π i) → ℝ≥0∞
x y : (i : δ) → π i
i : δ
hf : Measurable f
⊢ Measurable (uncurry fun x y => f (updateFinset x s y))

Next tactic:
refine' hf.comp _
theorem _root_.Measurable.lmarginal (hf : Measurable f) : Measurable (∫⋯∫⁻_s, f ∂μ) := by
  refine' Measurable.lintegral_prod_right _
  refine' hf.comp _
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f g : ((i : δ) → π i) → ℝ≥0∞
x y : (i : δ) → π i
i : δ
hf : Measurable f
⊢ Measurable fun a => updateFinset a.1 s a.2

Next tactic:
rw [measurable_pi_iff]
theorem _root_.Measurable.lmarginal (hf : Measurable f) : Measurable (∫⋯∫⁻_s, f ∂μ) := by
  refine' Measurable.lintegral_prod_right _
  refine' hf.comp _
  rw [measurable_pi_iff]; 

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f g : ((i : δ) → π i) → ℝ≥0∞
x y : (i : δ) → π i
i : δ
hf : Measurable f
⊢ ∀ (a : δ), Measurable fun x => updateFinset x.1 s x.2 a

Next tactic:
intro i
theorem _root_.Measurable.lmarginal (hf : Measurable f) : Measurable (∫⋯∫⁻_s, f ∂μ) := by
  refine' Measurable.lintegral_prod_right _
  refine' hf.comp _
  rw [measurable_pi_iff]; intro i
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f g : ((i : δ) → π i) → ℝ≥0∞
x y : (i : δ) → π i
i✝ : δ
hf : Measurable f
i : δ
⊢ Measurable fun x => updateFinset x.1 s x.2 i

Next tactic:
by_cases hi : i ∈ s
theorem _root_.Measurable.lmarginal (hf : Measurable f) : Measurable (∫⋯∫⁻_s, f ∂μ) := by
  refine' Measurable.lintegral_prod_right _
  refine' hf.comp _
  rw [measurable_pi_iff]; intro i
  by_cases hi : i ∈ s
  · 

Proof state:
case pos
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f g : ((i : δ) → π i) → ℝ≥0∞
x y : (i : δ) → π i
i✝ : δ
hf : Measurable f
i : δ
hi : i ∈ s
⊢ Measurable fun x => updateFinset x.1 s x.2 i

Next tactic:
simp [hi, updateFinset]
theorem _root_.Measurable.lmarginal (hf : Measurable f) : Measurable (∫⋯∫⁻_s, f ∂μ) := by
  refine' Measurable.lintegral_prod_right _
  refine' hf.comp _
  rw [measurable_pi_iff]; intro i
  by_cases hi : i ∈ s
  · simp [hi, updateFinset]
    

Proof state:
case pos
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f g : ((i : δ) → π i) → ℝ≥0∞
x y : (i : δ) → π i
i✝ : δ
hf : Measurable f
i : δ
hi : i ∈ s
⊢ Measurable fun x => x.2 { val := i, property := (_ : i ∈ s) }

Next tactic:
exact measurable_pi_iff.1 measurable_snd _
theorem _root_.Measurable.lmarginal (hf : Measurable f) : Measurable (∫⋯∫⁻_s, f ∂μ) := by
  refine' Measurable.lintegral_prod_right _
  refine' hf.comp _
  rw [measurable_pi_iff]; intro i
  by_cases hi : i ∈ s
  · simp [hi, updateFinset]
    exact measurable_pi_iff.1 measurable_snd _
  · 

Proof state:
case neg
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f g : ((i : δ) → π i) → ℝ≥0∞
x y : (i : δ) → π i
i✝ : δ
hf : Measurable f
i : δ
hi : i ∉ s
⊢ Measurable fun x => updateFinset x.1 s x.2 i

Next tactic:
simp [hi, updateFinset]
theorem _root_.Measurable.lmarginal (hf : Measurable f) : Measurable (∫⋯∫⁻_s, f ∂μ) := by
  refine' Measurable.lintegral_prod_right _
  refine' hf.comp _
  rw [measurable_pi_iff]; intro i
  by_cases hi : i ∈ s
  · simp [hi, updateFinset]
    exact measurable_pi_iff.1 measurable_snd _
  · simp [hi, updateFinset]
    

Proof state:
case neg
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f g : ((i : δ) → π i) → ℝ≥0∞
x y : (i : δ) → π i
i✝ : δ
hf : Measurable f
i : δ
hi : i ∉ s
⊢ Measurable fun x => x.1 i

Next tactic:
exact measurable_pi_iff.1 measurable_fst _
@[simp] theorem lmarginal_empty (f : (∀ i, π i) → ℝ≥0∞) : ∫⋯∫⁻_∅, f ∂μ = f := by
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x y : (i : δ) → π i
i : δ
f : ((i : δ) → π i) → ℝ≥0∞
⊢ ∫⋯∫⁻_∅, f ∂μ = f

Next tactic:
ext1 x
@[simp] theorem lmarginal_empty (f : (∀ i, π i) → ℝ≥0∞) : ∫⋯∫⁻_∅, f ∂μ = f := by
  ext1 x
  

Proof state:
case h
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i : δ
f : ((i : δ) → π i) → ℝ≥0∞
x : (i : δ) → π i
⊢ (∫⋯∫⁻_∅, f ∂μ) x = f x

Next tactic:
simp_rw [lmarginal, Measure.pi_of_empty fun i : (∅ : Finset δ) => μ i]
@[simp] theorem lmarginal_empty (f : (∀ i, π i) → ℝ≥0∞) : ∫⋯∫⁻_∅, f ∂μ = f := by
  ext1 x
  simp_rw [lmarginal, Measure.pi_of_empty fun i : (∅ : Finset δ) => μ i]
  

Proof state:
case h
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i : δ
f : ((i : δ) → π i) → ℝ≥0∞
x : (i : δ) → π i
⊢ (∫⁻ (y : (i : { x // x ∈ ∅ }) → π ↑i), f (updateFinset x ∅ y) ∂Measure.dirac fun a => isEmptyElim a) = f x

Next tactic:
apply lintegral_dirac'
@[simp] theorem lmarginal_empty (f : (∀ i, π i) → ℝ≥0∞) : ∫⋯∫⁻_∅, f ∂μ = f := by
  ext1 x
  simp_rw [lmarginal, Measure.pi_of_empty fun i : (∅ : Finset δ) => μ i]
  apply lintegral_dirac'
  

Proof state:
case h.hf
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i : δ
f : ((i : δ) → π i) → ℝ≥0∞
x : (i : δ) → π i
⊢ Measurable fun a => f (updateFinset x ∅ a)

Next tactic:
exact Subsingleton.measurable
/-- The marginal distribution is independent of the variables in `s`. -/
theorem lmarginal_congr {x y : ∀ i, π i} (f : (∀ i, π i) → ℝ≥0∞)
    (h : ∀ i ∉ s, x i = y i) :
    (∫⋯∫⁻_s, f ∂μ) x = (∫⋯∫⁻_s, f ∂μ) y := by
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i : δ
x y : (i : δ) → π i
f : ((i : δ) → π i) → ℝ≥0∞
h : ∀ i ∉ s, x i = y i
⊢ (∫⋯∫⁻_s, f ∂μ) x = (∫⋯∫⁻_s, f ∂μ) y

Next tactic:
dsimp [lmarginal, updateFinset_def]
/-- The marginal distribution is independent of the variables in `s`. -/
theorem lmarginal_congr {x y : ∀ i, π i} (f : (∀ i, π i) → ℝ≥0∞)
    (h : ∀ i ∉ s, x i = y i) :
    (∫⋯∫⁻_s, f ∂μ) x = (∫⋯∫⁻_s, f ∂μ) y := by
  dsimp [lmarginal, updateFinset_def]; 

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i : δ
x y : (i : δ) → π i
f : ((i : δ) → π i) → ℝ≥0∞
h : ∀ i ∉ s, x i = y i
⊢ (∫⁻ (y : (i : { x // x ∈ s }) → π ↑i),
      f fun i => if hi : i ∈ s then y { val := i, property := hi } else x i ∂Measure.pi fun i => μ ↑i) =
    ∫⁻ (y_1 : (i : { x // x ∈ s }) → π ↑i),
      f fun i => if hi : i ∈ s then y_1 { val := i, property := hi } else y i ∂Measure.pi fun i => μ ↑i

Next tactic:
rcongr
/-- The marginal distribution is independent of the variables in `s`. -/
theorem lmarginal_congr {x y : ∀ i, π i} (f : (∀ i, π i) → ℝ≥0∞)
    (h : ∀ i ∉ s, x i = y i) :
    (∫⋯∫⁻_s, f ∂μ) x = (∫⋯∫⁻_s, f ∂μ) y := by
  dsimp [lmarginal, updateFinset_def]; rcongr; 

Proof state:
case e_f.h.e_a.h.e_e.h
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝³ y✝ : (i : δ) → π i
i : δ
x y : (i : δ) → π i
f : ((i : δ) → π i) → ℝ≥0∞
h : ∀ i ∉ s, x i = y i
x✝² : (i : { x // x ∈ s }) → π ↑i
x✝¹ : δ
x✝ : x✝¹ ∉ s
⊢ x x✝¹ = y x✝¹

Next tactic:
exact h _ ‹_›
theorem lmarginal_update_of_mem {i : δ} (hi : i ∈ s)
    (f : (∀ i, π i) → ℝ≥0∞) (x : ∀ i, π i) (y : π i) :
    (∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∂μ) x := by
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i✝ i : δ
hi : i ∈ s
f : ((i : δ) → π i) → ℝ≥0∞
x : (i : δ) → π i
y : π i
⊢ (∫⋯∫⁻_s, f ∂μ) (update x i y) = (∫⋯∫⁻_s, f ∂μ) x

Next tactic:
apply lmarginal_congr
theorem lmarginal_update_of_mem {i : δ} (hi : i ∈ s)
    (f : (∀ i, π i) → ℝ≥0∞) (x : ∀ i, π i) (y : π i) :
    (∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∂μ) x := by
  apply lmarginal_congr
  

Proof state:
case h
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i✝ i : δ
hi : i ∈ s
f : ((i : δ) → π i) → ℝ≥0∞
x : (i : δ) → π i
y : π i
⊢ ∀ i_1 ∉ s, update x i y i_1 = x i_1

Next tactic:
intro j hj
theorem lmarginal_update_of_mem {i : δ} (hi : i ∈ s)
    (f : (∀ i, π i) → ℝ≥0∞) (x : ∀ i, π i) (y : π i) :
    (∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∂μ) x := by
  apply lmarginal_congr
  intro j hj
  

Proof state:
case h
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i✝ i : δ
hi : i ∈ s
f : ((i : δ) → π i) → ℝ≥0∞
x : (i : δ) → π i
y : π i
j : δ
hj : j ∉ s
⊢ update x i y j = x j

Next tactic:
have : j ≠ i := by rintro rfl; exact hj hi
theorem lmarginal_update_of_mem {i : δ} (hi : i ∈ s)
    (f : (∀ i, π i) → ℝ≥0∞) (x : ∀ i, π i) (y : π i) :
    (∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∂μ) x := by
  apply lmarginal_congr
  intro j hj
  have : j ≠ i := by 

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i✝ i : δ
hi : i ∈ s
f : ((i : δ) → π i) → ℝ≥0∞
x : (i : δ) → π i
y : π i
j : δ
hj : j ∉ s
⊢ j ≠ i

Next tactic:
rintro rfl