l3lab/ntp-mathlib huggingface dataset:
/-- The n-ary version of `Set.image_mul_prod`. -/
@[to_additive "The n-ary version of `Set.add_image_prod`. "]
theorem image_finset_prod_pi (l : Finset ι) (S : ι → Set α) :
    (fun f : ι → α => ∏ i in l, f i) '' (l : Set ι).pi S = ∏ i in l, S i := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
F : Type u_4
inst✝² : CommMonoid α
inst✝¹ : CommMonoid β
inst✝ : MonoidHomClass F α β
l : Finset ι
S : ι → Set α
⊢ (fun f => ∏ i in l, f i) '' pi (↑l) S = ∏ i in l, S i

Next tactic:
ext
/-- The n-ary version of `Set.image_mul_prod`. -/
@[to_additive "The n-ary version of `Set.add_image_prod`. "]
theorem image_finset_prod_pi (l : Finset ι) (S : ι → Set α) :
    (fun f : ι → α => ∏ i in l, f i) '' (l : Set ι).pi S = ∏ i in l, S i := by
  ext
  

Proof state:
case h
ι : Type u_1
α : Type u_2
β : Type u_3
F : Type u_4
inst✝² : CommMonoid α
inst✝¹ : CommMonoid β
inst✝ : MonoidHomClass F α β
l : Finset ι
S : ι → Set α
x✝ : α
⊢ x✝ ∈ (fun f => ∏ i in l, f i) '' pi (↑l) S ↔ x✝ ∈ ∏ i in l, S i

Next tactic:
simp_rw [mem_finset_prod, mem_image, mem_pi, exists_prop, Finset.mem_coe]
/-- A special case of `Set.image_finset_prod_pi` for `Finset.univ`. -/
@[to_additive "A special case of `Set.image_finset_sum_pi` for `Finset.univ`. "]
theorem image_fintype_prod_pi [Fintype ι] (S : ι → Set α) :
    (fun f : ι → α => ∏ i, f i) '' univ.pi S = ∏ i, S i := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
F : Type u_4
inst✝³ : CommMonoid α
inst✝² : CommMonoid β
inst✝¹ : MonoidHomClass F α β
inst✝ : Fintype ι
S : ι → Set α
⊢ (fun f => ∏ i : ι, f i) '' pi univ S = ∏ i : ι, S i

Next tactic:
simpa only [Finset.coe_univ] using image_finset_prod_pi Finset.univ S
@[simp]
theorem condCount_empty_meas : (condCount ∅ : Measure Ω) = 0 := by 

Proof state:
Ω : Type u_1
inst✝ : MeasurableSpace Ω
⊢ condCount ∅ = 0

Next tactic:
simp [condCount]
theorem condCount_empty {s : Set Ω} : condCount s ∅ = 0 := by 

Proof state:
Ω : Type u_1
inst✝ : MeasurableSpace Ω
s : Set Ω
⊢ ↑↑(condCount s) ∅ = 0

Next tactic:
simp
theorem finite_of_condCount_ne_zero {s t : Set Ω} (h : condCount s t ≠ 0) : s.Finite := by
  

Proof state:
Ω : Type u_1
inst✝ : MeasurableSpace Ω
s t : Set Ω
h : ↑↑(condCount s) t ≠ 0
⊢ Set.Finite s

Next tactic:
by_contra hs'
theorem finite_of_condCount_ne_zero {s t : Set Ω} (h : condCount s t ≠ 0) : s.Finite := by
  by_contra hs'
  

Proof state:
Ω : Type u_1
inst✝ : MeasurableSpace Ω
s t : Set Ω
h : ↑↑(condCount s) t ≠ 0
hs' : ¬Set.Finite s
⊢ False

Next tactic:
simp [condCount, cond, Measure.count_apply_infinite hs'] at h
theorem condCount_univ [Fintype Ω] {s : Set Ω} :
    condCount Set.univ s = Measure.count s / Fintype.card Ω := by
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : Fintype Ω
s : Set Ω
⊢ ↑↑(condCount Set.univ) s = ↑↑Measure.count s / ↑(Fintype.card Ω)

Next tactic:
rw [condCount, cond_apply _ MeasurableSet.univ, ← ENNReal.div_eq_inv_mul, Set.univ_inter]
theorem condCount_univ [Fintype Ω] {s : Set Ω} :
    condCount Set.univ s = Measure.count s / Fintype.card Ω := by
  rw [condCount, cond_apply _ MeasurableSet.univ, ← ENNReal.div_eq_inv_mul, Set.univ_inter]
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : Fintype Ω
s : Set Ω
⊢ ↑↑Measure.count s / ↑↑Measure.count Set.univ = ↑↑Measure.count s / ↑(Fintype.card Ω)

Next tactic:
congr
theorem condCount_univ [Fintype Ω] {s : Set Ω} :
    condCount Set.univ s = Measure.count s / Fintype.card Ω := by
  rw [condCount, cond_apply _ MeasurableSet.univ, ← ENNReal.div_eq_inv_mul, Set.univ_inter]
  congr
  

Proof state:
case e_a
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : Fintype Ω
s : Set Ω
⊢ ↑↑Measure.count Set.univ = ↑(Fintype.card Ω)

Next tactic:
rw [← Finset.coe_univ, Measure.count_apply, Finset.univ.tsum_subtype' fun _ => (1 : ENNReal)]
theorem condCount_univ [Fintype Ω] {s : Set Ω} :
    condCount Set.univ s = Measure.count s / Fintype.card Ω := by
  rw [condCount, cond_apply _ MeasurableSet.univ, ← ENNReal.div_eq_inv_mul, Set.univ_inter]
  congr
  rw [← Finset.coe_univ, Measure.count_apply, Finset.univ.tsum_subtype' fun _ => (1 : ENNReal)]
  · 

Proof state:
case e_a
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : Fintype Ω
s : Set Ω
⊢ (Finset.sum Finset.univ fun x => 1) = ↑(Fintype.card Ω)

Next tactic:
simp [Finset.card_univ]
theorem condCount_univ [Fintype Ω] {s : Set Ω} :
    condCount Set.univ s = Measure.count s / Fintype.card Ω := by
  rw [condCount, cond_apply _ MeasurableSet.univ, ← ENNReal.div_eq_inv_mul, Set.univ_inter]
  congr
  rw [← Finset.coe_univ, Measure.count_apply, Finset.univ.tsum_subtype' fun _ => (1 : ENNReal)]
  · simp [Finset.card_univ]
  · 

Proof state:
case e_a
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : Fintype Ω
s : Set Ω
⊢ MeasurableSet ↑Finset.univ

Next tactic:
exact (@Finset.coe_univ Ω _).symm ▸ MeasurableSet.univ
theorem condCount_isProbabilityMeasure {s : Set Ω} (hs : s.Finite) (hs' : s.Nonempty) :
    IsProbabilityMeasure (condCount s) :=
  { measure_univ := by
      

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s : Set Ω
hs : Set.Finite s
hs' : Set.Nonempty s
⊢ ↑↑(condCount s) Set.univ = 1

Next tactic:
rw [condCount, cond_apply _ hs.measurableSet, Set.inter_univ, ENNReal.inv_mul_cancel]
theorem condCount_isProbabilityMeasure {s : Set Ω} (hs : s.Finite) (hs' : s.Nonempty) :
    IsProbabilityMeasure (condCount s) :=
  { measure_univ := by
      rw [condCount, cond_apply _ hs.measurableSet, Set.inter_univ, ENNReal.inv_mul_cancel]
      · 

Proof state:
case h0
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s : Set Ω
hs : Set.Finite s
hs' : Set.Nonempty s
⊢ ↑↑Measure.count s ≠ 0

Next tactic:
exact fun h => hs'.ne_empty <| Measure.empty_of_count_eq_zero h
theorem condCount_isProbabilityMeasure {s : Set Ω} (hs : s.Finite) (hs' : s.Nonempty) :
    IsProbabilityMeasure (condCount s) :=
  { measure_univ := by
      rw [condCount, cond_apply _ hs.measurableSet, Set.inter_univ, ENNReal.inv_mul_cancel]
      · exact fun h => hs'.ne_empty <| Measure.empty_of_count_eq_zero h
      · 

Proof state:
case ht
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s : Set Ω
hs : Set.Finite s
hs' : Set.Nonempty s
⊢ ↑↑Measure.count s ≠ ⊤

Next tactic:
exact (Measure.count_apply_lt_top.2 hs).ne
theorem condCount_singleton (ω : Ω) (t : Set Ω) [Decidable (ω ∈ t)] :
    condCount {ω} t = if ω ∈ t then 1 else 0 := by
  

Proof state:
Ω : Type u_1
inst✝² : MeasurableSpace Ω
inst✝¹ : MeasurableSingletonClass Ω
ω : Ω
t : Set Ω
inst✝ : Decidable (ω ∈ t)
⊢ ↑↑(condCount {ω}) t = if ω ∈ t then 1 else 0

Next tactic:
rw [condCount, cond_apply _ (measurableSet_singleton ω), Measure.count_singleton, inv_one,
    one_mul]
theorem condCount_singleton (ω : Ω) (t : Set Ω) [Decidable (ω ∈ t)] :
    condCount {ω} t = if ω ∈ t then 1 else 0 := by
  rw [condCount, cond_apply _ (measurableSet_singleton ω), Measure.count_singleton, inv_one,
    one_mul]
  

Proof state:
Ω : Type u_1
inst✝² : MeasurableSpace Ω
inst✝¹ : MeasurableSingletonClass Ω
ω : Ω
t : Set Ω
inst✝ : Decidable (ω ∈ t)
⊢ ↑↑Measure.count ({ω} ∩ t) = if ω ∈ t then 1 else 0

Next tactic:
split_ifs
theorem condCount_singleton (ω : Ω) (t : Set Ω) [Decidable (ω ∈ t)] :
    condCount {ω} t = if ω ∈ t then 1 else 0 := by
  rw [condCount, cond_apply _ (measurableSet_singleton ω), Measure.count_singleton, inv_one,
    one_mul]
  split_ifs
  · 

Proof state:
case pos
Ω : Type u_1
inst✝² : MeasurableSpace Ω
inst✝¹ : MeasurableSingletonClass Ω
ω : Ω
t : Set Ω
inst✝ : Decidable (ω ∈ t)
h✝ : ω ∈ t
⊢ ↑↑Measure.count ({ω} ∩ t) = 1

Next tactic:
rw [(by simpa : ({ω} : Set Ω) ∩ t = {ω}), Measure.count_singleton]
theorem condCount_singleton (ω : Ω) (t : Set Ω) [Decidable (ω ∈ t)] :
    condCount {ω} t = if ω ∈ t then 1 else 0 := by
  rw [condCount, cond_apply _ (measurableSet_singleton ω), Measure.count_singleton, inv_one,
    one_mul]
  split_ifs
  · rw [(by 

Proof state:
Ω : Type u_1
inst✝² : MeasurableSpace Ω
inst✝¹ : MeasurableSingletonClass Ω
ω : Ω
t : Set Ω
inst✝ : Decidable (ω ∈ t)
h✝ : ω ∈ t
⊢ {ω} ∩ t = {ω}

Next tactic:
simpa
theorem condCount_singleton (ω : Ω) (t : Set Ω) [Decidable (ω ∈ t)] :
    condCount {ω} t = if ω ∈ t then 1 else 0 := by
  rw [condCount, cond_apply _ (measurableSet_singleton ω), Measure.count_singleton, inv_one,
    one_mul]
  split_ifs
  · rw [(by simpa : ({ω} : Set Ω) ∩ t = {ω}), Measure.count_singleton]
  · 

Proof state:
case neg
Ω : Type u_1
inst✝² : MeasurableSpace Ω
inst✝¹ : MeasurableSingletonClass Ω
ω : Ω
t : Set Ω
inst✝ : Decidable (ω ∈ t)
h✝ : ω ∉ t
⊢ ↑↑Measure.count ({ω} ∩ t) = 0

Next tactic:
rw [(by simpa : ({ω} : Set Ω) ∩ t = ∅), Measure.count_empty]
theorem condCount_singleton (ω : Ω) (t : Set Ω) [Decidable (ω ∈ t)] :
    condCount {ω} t = if ω ∈ t then 1 else 0 := by
  rw [condCount, cond_apply _ (measurableSet_singleton ω), Measure.count_singleton, inv_one,
    one_mul]
  split_ifs
  · rw [(by simpa : ({ω} : Set Ω) ∩ t = {ω}), Measure.count_singleton]
  · rw [(by 

Proof state:
Ω : Type u_1
inst✝² : MeasurableSpace Ω
inst✝¹ : MeasurableSingletonClass Ω
ω : Ω
t : Set Ω
inst✝ : Decidable (ω ∈ t)
h✝ : ω ∉ t
⊢ {ω} ∩ t = ∅

Next tactic:
simpa
theorem condCount_inter_self (hs : s.Finite) : condCount s (s ∩ t) = condCount s t := by
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
⊢ ↑↑(condCount s) (s ∩ t) = ↑↑(condCount s) t

Next tactic:
rw [condCount, cond_inter_self _ hs.measurableSet]
theorem condCount_self (hs : s.Finite) (hs' : s.Nonempty) : condCount s s = 1 := by
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
hs' : Set.Nonempty s
⊢ ↑↑(condCount s) s = 1

Next tactic:
rw [condCount, cond_apply _ hs.measurableSet, Set.inter_self, ENNReal.inv_mul_cancel]
theorem condCount_self (hs : s.Finite) (hs' : s.Nonempty) : condCount s s = 1 := by
  rw [condCount, cond_apply _ hs.measurableSet, Set.inter_self, ENNReal.inv_mul_cancel]
  · 

Proof state:
case h0
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
hs' : Set.Nonempty s
⊢ ↑↑Measure.count s ≠ 0

Next tactic:
exact fun h => hs'.ne_empty <| Measure.empty_of_count_eq_zero h
theorem condCount_self (hs : s.Finite) (hs' : s.Nonempty) : condCount s s = 1 := by
  rw [condCount, cond_apply _ hs.measurableSet, Set.inter_self, ENNReal.inv_mul_cancel]
  · exact fun h => hs'.ne_empty <| Measure.empty_of_count_eq_zero h
  · 

Proof state:
case ht
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
hs' : Set.Nonempty s
⊢ ↑↑Measure.count s ≠ ⊤

Next tactic:
exact (Measure.count_apply_lt_top.2 hs).ne
theorem condCount_eq_one_of (hs : s.Finite) (hs' : s.Nonempty) (ht : s ⊆ t) :
    condCount s t = 1 := by
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
hs' : Set.Nonempty s
ht : s ⊆ t
⊢ ↑↑(condCount s) t = 1

Next tactic:
haveI := condCount_isProbabilityMeasure hs hs'
theorem condCount_eq_one_of (hs : s.Finite) (hs' : s.Nonempty) (ht : s ⊆ t) :
    condCount s t = 1 := by
  haveI := condCount_isProbabilityMeasure hs hs'
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
hs' : Set.Nonempty s
ht : s ⊆ t
this : IsProbabilityMeasure (condCount s)
⊢ ↑↑(condCount s) t = 1

Next tactic:
refine' eq_of_le_of_not_lt prob_le_one _
theorem condCount_eq_one_of (hs : s.Finite) (hs' : s.Nonempty) (ht : s ⊆ t) :
    condCount s t = 1 := by
  haveI := condCount_isProbabilityMeasure hs hs'
  refine' eq_of_le_of_not_lt prob_le_one _
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
hs' : Set.Nonempty s
ht : s ⊆ t
this : IsProbabilityMeasure (condCount s)
⊢ ¬↑↑(condCount s) t < 1

Next tactic:
rw [not_lt, ← condCount_self hs hs']
theorem condCount_eq_one_of (hs : s.Finite) (hs' : s.Nonempty) (ht : s ⊆ t) :
    condCount s t = 1 := by
  haveI := condCount_isProbabilityMeasure hs hs'
  refine' eq_of_le_of_not_lt prob_le_one _
  rw [not_lt, ← condCount_self hs hs']
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
hs' : Set.Nonempty s
ht : s ⊆ t
this : IsProbabilityMeasure (condCount s)
⊢ ↑↑(condCount s) s ≤ ↑↑(condCount s) t

Next tactic:
exact measure_mono ht
theorem pred_true_of_condCount_eq_one (h : condCount s t = 1) : s ⊆ t := by
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
h : ↑↑(condCount s) t = 1
⊢ s ⊆ t

Next tactic:
have hsf := finite_of_condCount_ne_zero (by rw [h]; exact one_ne_zero)
theorem pred_true_of_condCount_eq_one (h : condCount s t = 1) : s ⊆ t := by
  have hsf := finite_of_condCount_ne_zero (by 

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
h : ↑↑(condCount s) t = 1
⊢ ↑↑(condCount ?m.8960) ?m.8961 ≠ 0

Next tactic:
rw [h]
theorem pred_true_of_condCount_eq_one (h : condCount s t = 1) : s ⊆ t := by
  have hsf := finite_of_condCount_ne_zero (by rw [h]; 

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
h : ↑↑(condCount s) t = 1
⊢ 1 ≠ 0

Next tactic:
exact one_ne_zero
theorem pred_true_of_condCount_eq_one (h : condCount s t = 1) : s ⊆ t := by
  have hsf := finite_of_condCount_ne_zero (by rw [h]; exact one_ne_zero)
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
h : ↑↑(condCount s) t = 1
hsf : Set.Finite s
⊢ s ⊆ t

Next tactic:
rw [condCount, cond_apply _ hsf.measurableSet, mul_comm] at h
theorem pred_true_of_condCount_eq_one (h : condCount s t = 1) : s ⊆ t := by
  have hsf := finite_of_condCount_ne_zero (by rw [h]; exact one_ne_zero)
  rw [condCount, cond_apply _ hsf.measurableSet, mul_comm] at h
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
h : ↑↑Measure.count (s ∩ t) * (↑↑Measure.count s)⁻¹ = 1
hsf : Set.Finite s
⊢ s ⊆ t

Next tactic:
replace h := ENNReal.eq_inv_of_mul_eq_one_left h
theorem pred_true_of_condCount_eq_one (h : condCount s t = 1) : s ⊆ t := by
  have hsf := finite_of_condCount_ne_zero (by rw [h]; exact one_ne_zero)
  rw [condCount, cond_apply _ hsf.measurableSet, mul_comm] at h
  replace h := ENNReal.eq_inv_of_mul_eq_one_left h
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hsf : Set.Finite s
h : ↑↑Measure.count (s ∩ t) = (↑↑Measure.count s)⁻¹⁻¹
⊢ s ⊆ t

Next tactic:
rw [inv_inv, Measure.count_apply_finite _ hsf, Measure.count_apply_finite _ (hsf.inter_of_left _),
    Nat.cast_inj] at h
theorem pred_true_of_condCount_eq_one (h : condCount s t = 1) : s ⊆ t := by
  have hsf := finite_of_condCount_ne_zero (by rw [h]; exact one_ne_zero)
  rw [condCount, cond_apply _ hsf.measurableSet, mul_comm] at h
  replace h := ENNReal.eq_inv_of_mul_eq_one_left h
  rw [inv_inv, Measure.count_apply_finite _ hsf, Measure.count_apply_finite _ (hsf.inter_of_left _),
    Nat.cast_inj] at h
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hsf : Set.Finite s
h : Finset.card (Set.Finite.toFinset (_ : Set.Finite (s ∩ t))) = Finset.card (Set.Finite.toFinset hsf)
⊢ s ⊆ t

Next tactic:
suffices s ∩ t = s by exact this ▸ fun x hx => hx.2
theorem pred_true_of_condCount_eq_one (h : condCount s t = 1) : s ⊆ t := by
  have hsf := finite_of_condCount_ne_zero (by rw [h]; exact one_ne_zero)
  rw [condCount, cond_apply _ hsf.measurableSet, mul_comm] at h
  replace h := ENNReal.eq_inv_of_mul_eq_one_left h
  rw [inv_inv, Measure.count_apply_finite _ hsf, Measure.count_apply_finite _ (hsf.inter_of_left _),
    Nat.cast_inj] at h
  suffices s ∩ t = s by 

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hsf : Set.Finite s
h : Finset.card (Set.Finite.toFinset (_ : Set.Finite (s ∩ t))) = Finset.card (Set.Finite.toFinset hsf)
this : s ∩ t = s
⊢ s ⊆ t

Next tactic:
exact this ▸ fun x hx => hx.2
theorem pred_true_of_condCount_eq_one (h : condCount s t = 1) : s ⊆ t := by
  have hsf := finite_of_condCount_ne_zero (by rw [h]; exact one_ne_zero)
  rw [condCount, cond_apply _ hsf.measurableSet, mul_comm] at h
  replace h := ENNReal.eq_inv_of_mul_eq_one_left h
  rw [inv_inv, Measure.count_apply_finite _ hsf, Measure.count_apply_finite _ (hsf.inter_of_left _),
    Nat.cast_inj] at h
  suffices s ∩ t = s by exact this ▸ fun x hx => hx.2
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hsf : Set.Finite s
h : Finset.card (Set.Finite.toFinset (_ : Set.Finite (s ∩ t))) = Finset.card (Set.Finite.toFinset hsf)
⊢ s ∩ t = s

Next tactic:
rw [← @Set.Finite.toFinset_inj _ _ _ (hsf.inter_of_left _) hsf]
theorem pred_true_of_condCount_eq_one (h : condCount s t = 1) : s ⊆ t := by
  have hsf := finite_of_condCount_ne_zero (by rw [h]; exact one_ne_zero)
  rw [condCount, cond_apply _ hsf.measurableSet, mul_comm] at h
  replace h := ENNReal.eq_inv_of_mul_eq_one_left h
  rw [inv_inv, Measure.count_apply_finite _ hsf, Measure.count_apply_finite _ (hsf.inter_of_left _),
    Nat.cast_inj] at h
  suffices s ∩ t = s by exact this ▸ fun x hx => hx.2
  rw [← @Set.Finite.toFinset_inj _ _ _ (hsf.inter_of_left _) hsf]
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hsf : Set.Finite s
h : Finset.card (Set.Finite.toFinset (_ : Set.Finite (s ∩ t))) = Finset.card (Set.Finite.toFinset hsf)
⊢ Set.Finite.toFinset (_ : Set.Finite (s ∩ t)) = Set.Finite.toFinset hsf

Next tactic:
exact Finset.eq_of_subset_of_card_le (Set.Finite.toFinset_mono <| s.inter_subset_left t) h.ge
theorem condCount_eq_zero_iff (hs : s.Finite) : condCount s t = 0 ↔ s ∩ t = ∅ := by
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
⊢ ↑↑(condCount s) t = 0 ↔ s ∩ t = ∅

Next tactic:
simp [condCount, cond_apply _ hs.measurableSet, Measure.count_apply_eq_top, Set.not_infinite.2 hs,
    Measure.count_apply_finite _ (hs.inter_of_left _)]
theorem condCount_inter (hs : s.Finite) :
    condCount s (t ∩ u) = condCount (s ∩ t) u * condCount s t := by
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
⊢ ↑↑(condCount s) (t ∩ u) = ↑↑(condCount (s ∩ t)) u * ↑↑(condCount s) t

Next tactic:
by_cases hst : s ∩ t = ∅
theorem condCount_inter (hs : s.Finite) :
    condCount s (t ∩ u) = condCount (s ∩ t) u * condCount s t := by
  by_cases hst : s ∩ t = ∅
  · 

Proof state:
case pos
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
hst : s ∩ t = ∅
⊢ ↑↑(condCount s) (t ∩ u) = ↑↑(condCount (s ∩ t)) u * ↑↑(condCount s) t

Next tactic:
rw [hst, condCount_empty_meas, Measure.coe_zero, Pi.zero_apply, zero_mul,
      condCount_eq_zero_iff hs, ← Set.inter_assoc, hst, Set.empty_inter]
theorem condCount_inter (hs : s.Finite) :
    condCount s (t ∩ u) = condCount (s ∩ t) u * condCount s t := by
  by_cases hst : s ∩ t = ∅
  · rw [hst, condCount_empty_meas, Measure.coe_zero, Pi.zero_apply, zero_mul,
      condCount_eq_zero_iff hs, ← Set.inter_assoc, hst, Set.empty_inter]
  

Proof state:
case neg
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
hst : ¬s ∩ t = ∅
⊢ ↑↑(condCount s) (t ∩ u) = ↑↑(condCount (s ∩ t)) u * ↑↑(condCount s) t

Next tactic:
rw [condCount, condCount, cond_apply _ hs.measurableSet, cond_apply _ hs.measurableSet,
    cond_apply _ (hs.inter_of_left _).measurableSet, mul_comm _ (Measure.count (s ∩ t)),
    ← mul_assoc, mul_comm _ (Measure.count (s ∩ t)), ← mul_assoc, ENNReal.mul_inv_cancel, one_mul,
    mul_comm, Set.inter_assoc]
theorem condCount_inter (hs : s.Finite) :
    condCount s (t ∩ u) = condCount (s ∩ t) u * condCount s t := by
  by_cases hst : s ∩ t = ∅
  · rw [hst, condCount_empty_meas, Measure.coe_zero, Pi.zero_apply, zero_mul,
      condCount_eq_zero_iff hs, ← Set.inter_assoc, hst, Set.empty_inter]
  rw [condCount, condCount, cond_apply _ hs.measurableSet, cond_apply _ hs.measurableSet,
    cond_apply _ (hs.inter_of_left _).measurableSet, mul_comm _ (Measure.count (s ∩ t)),
    ← mul_assoc, mul_comm _ (Measure.count (s ∩ t)), ← mul_assoc, ENNReal.mul_inv_cancel, one_mul,
    mul_comm, Set.inter_assoc]
  · 

Proof state:
case neg.h0
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
hst : ¬s ∩ t = ∅
⊢ ↑↑Measure.count (s ∩ t) ≠ 0

Next tactic:
rwa [← Measure.count_eq_zero_iff] at hst
theorem condCount_inter (hs : s.Finite) :
    condCount s (t ∩ u) = condCount (s ∩ t) u * condCount s t := by
  by_cases hst : s ∩ t = ∅
  · rw [hst, condCount_empty_meas, Measure.coe_zero, Pi.zero_apply, zero_mul,
      condCount_eq_zero_iff hs, ← Set.inter_assoc, hst, Set.empty_inter]
  rw [condCount, condCount, cond_apply _ hs.measurableSet, cond_apply _ hs.measurableSet,
    cond_apply _ (hs.inter_of_left _).measurableSet, mul_comm _ (Measure.count (s ∩ t)),
    ← mul_assoc, mul_comm _ (Measure.count (s ∩ t)), ← mul_assoc, ENNReal.mul_inv_cancel, one_mul,
    mul_comm, Set.inter_assoc]
  · rwa [← Measure.count_eq_zero_iff] at hst
  · 

Proof state:
case neg.ht
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
hst : ¬s ∩ t = ∅
⊢ ↑↑Measure.count (s ∩ t) ≠ ⊤

Next tactic:
exact (Measure.count_apply_lt_top.2 <| hs.inter_of_left _).ne
theorem condCount_inter' (hs : s.Finite) :
    condCount s (t ∩ u) = condCount (s ∩ u) t * condCount s u := by
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
⊢ ↑↑(condCount s) (t ∩ u) = ↑↑(condCount (s ∩ u)) t * ↑↑(condCount s) u

Next tactic:
rw [← Set.inter_comm]
theorem condCount_inter' (hs : s.Finite) :
    condCount s (t ∩ u) = condCount (s ∩ u) t * condCount s u := by
  rw [← Set.inter_comm]
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
⊢ ↑↑(condCount s) (u ∩ t) = ↑↑(condCount (s ∩ u)) t * ↑↑(condCount s) u

Next tactic:
exact condCount_inter hs
theorem condCount_union (hs : s.Finite) (htu : Disjoint t u) :
    condCount s (t ∪ u) = condCount s t + condCount s u := by
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
htu : Disjoint t u
⊢ ↑↑(condCount s) (t ∪ u) = ↑↑(condCount s) t + ↑↑(condCount s) u

Next tactic:
rw [condCount, cond_apply _ hs.measurableSet, cond_apply _ hs.measurableSet,
    cond_apply _ hs.measurableSet, Set.inter_union_distrib_left, measure_union, mul_add]
theorem condCount_union (hs : s.Finite) (htu : Disjoint t u) :
    condCount s (t ∪ u) = condCount s t + condCount s u := by
  rw [condCount, cond_apply _ hs.measurableSet, cond_apply _ hs.measurableSet,
    cond_apply _ hs.measurableSet, Set.inter_union_distrib_left, measure_union, mul_add]
  

Proof state:
case hd
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
htu : Disjoint t u
⊢ Disjoint (s ∩ t) (s ∩ u)
case h
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t u : Set Ω
hs : Set.Finite s
htu : Disjoint t u
⊢ MeasurableSet (s ∩ u)

Next tactic:
exacts [htu.mono inf_le_right inf_le_right, (hs.inter_of_left _).measurableSet]
theorem condCount_compl (t : Set Ω) (hs : s.Finite) (hs' : s.Nonempty) :
    condCount s t + condCount s tᶜ = 1 := by
  

Proof state:
Ω : Type u_1
inst✝¹ : MeasurableSpace Ω
inst✝ : MeasurableSingletonClass Ω
s t✝ u t : Set Ω
hs : Set.Finite s
hs' : Set.Nonempty s
⊢ ↑↑(condCount s) t + ↑↑(condCount s) tᶜ = 1

Next tactic:
rw [← condCount_union hs disjoint_compl_right, Set.union_compl_self,
    (condCount_isProbabilityMeasure hs hs').measure_univ]