l3lab/ntp-mathlib huggingface dataset:
theorem IsPiSystem.insert_univ {α} {S : Set (Set α)} (h_pi : IsPiSystem S) :
    IsPiSystem (insert Set.univ S) := by
  intro s hs t ht hst
  cases' hs with hs hs
  · cases' ht with ht ht <;> 

Proof state:
case inl.inr
α : Type u_1
S : Set (Set α)
h_pi : IsPiSystem S
s t : Set α
hst : Set.Nonempty (s ∩ t)
hs : s = univ
ht : t ∈ S
⊢ s ∩ t ∈ insert univ S

Next tactic:
simp [hs, ht]
theorem IsPiSystem.insert_univ {α} {S : Set (Set α)} (h_pi : IsPiSystem S) :
    IsPiSystem (insert Set.univ S) := by
  intro s hs t ht hst
  cases' hs with hs hs
  · cases' ht with ht ht <;> simp [hs, ht]
  · 

Proof state:
case inr
α : Type u_1
S : Set (Set α)
h_pi : IsPiSystem S
s t : Set α
ht : t ∈ insert univ S
hst : Set.Nonempty (s ∩ t)
hs : s ∈ S
⊢ s ∩ t ∈ insert univ S

Next tactic:
cases' ht with ht ht
theorem IsPiSystem.insert_univ {α} {S : Set (Set α)} (h_pi : IsPiSystem S) :
    IsPiSystem (insert Set.univ S) := by
  intro s hs t ht hst
  cases' hs with hs hs
  · cases' ht with ht ht <;> simp [hs, ht]
  · cases' ht with ht ht
    · 

Proof state:
case inr.inl
α : Type u_1
S : Set (Set α)
h_pi : IsPiSystem S
s t : Set α
hst : Set.Nonempty (s ∩ t)
hs : s ∈ S
ht : t = univ
⊢ s ∩ t ∈ insert univ S

Next tactic:
simp [hs, ht]
theorem IsPiSystem.insert_univ {α} {S : Set (Set α)} (h_pi : IsPiSystem S) :
    IsPiSystem (insert Set.univ S) := by
  intro s hs t ht hst
  cases' hs with hs hs
  · cases' ht with ht ht <;> simp [hs, ht]
  · cases' ht with ht ht
    · simp [hs, ht]
    · 

Proof state:
case inr.inr
α : Type u_1
S : Set (Set α)
h_pi : IsPiSystem S
s t : Set α
hst : Set.Nonempty (s ∩ t)
hs : s ∈ S
ht : t ∈ S
⊢ s ∩ t ∈ insert univ S

Next tactic:
exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst)
theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) :
    IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by
  

Proof state:
α : Type u_1
β : Type u_2
S : Set (Set β)
h_pi : IsPiSystem S
f : α → β
⊢ IsPiSystem {s | ∃ t ∈ S, f ⁻¹' t = s}

Next tactic:
rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst
theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) :
    IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by
  rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
S : Set (Set β)
h_pi : IsPiSystem S
f : α → β
s : Set β
hs_mem : s ∈ S
t : Set β
ht_mem : t ∈ S
hst : Set.Nonempty (f ⁻¹' s ∩ f ⁻¹' t)
⊢ f ⁻¹' s ∩ f ⁻¹' t ∈ {s | ∃ t ∈ S, f ⁻¹' t = s}

Next tactic:
rw [← Set.preimage_inter] at hst ⊢
theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) :
    IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by
  rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst
  rw [← Set.preimage_inter] at hst ⊢
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
S : Set (Set β)
h_pi : IsPiSystem S
f : α → β
s : Set β
hs_mem : s ∈ S
t : Set β
ht_mem : t ∈ S
hst : Set.Nonempty (f ⁻¹' (s ∩ t))
⊢ f ⁻¹' (s ∩ t) ∈ {s | ∃ t ∈ S, f ⁻¹' t = s}

Next tactic:
refine' ⟨s ∩ t, h_pi s hs_mem t ht_mem _, rfl⟩
theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) :
    IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by
  rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst
  rw [← Set.preimage_inter] at hst ⊢
  refine' ⟨s ∩ t, h_pi s hs_mem t ht_mem _, rfl⟩
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
S : Set (Set β)
h_pi : IsPiSystem S
f : α → β
s : Set β
hs_mem : s ∈ S
t : Set β
ht_mem : t ∈ S
hst : Set.Nonempty (f ⁻¹' (s ∩ t))
⊢ Set.Nonempty (s ∩ t)

Next tactic:
by_contra h
theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) :
    IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by
  rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst
  rw [← Set.preimage_inter] at hst ⊢
  refine' ⟨s ∩ t, h_pi s hs_mem t ht_mem _, rfl⟩
  by_contra h
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
S : Set (Set β)
h_pi : IsPiSystem S
f : α → β
s : Set β
hs_mem : s ∈ S
t : Set β
ht_mem : t ∈ S
hst : Set.Nonempty (f ⁻¹' (s ∩ t))
h : ¬Set.Nonempty (s ∩ t)
⊢ False

Next tactic:
rw [Set.not_nonempty_iff_eq_empty] at h
theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) :
    IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by
  rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst
  rw [← Set.preimage_inter] at hst ⊢
  refine' ⟨s ∩ t, h_pi s hs_mem t ht_mem _, rfl⟩
  by_contra h
  rw [Set.not_nonempty_iff_eq_empty] at h
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
S : Set (Set β)
h_pi : IsPiSystem S
f : α → β
s : Set β
hs_mem : s ∈ S
t : Set β
ht_mem : t ∈ S
hst : Set.Nonempty (f ⁻¹' (s ∩ t))
h : s ∩ t = ∅
⊢ False

Next tactic:
rw [h] at hst
theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) :
    IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by
  rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst
  rw [← Set.preimage_inter] at hst ⊢
  refine' ⟨s ∩ t, h_pi s hs_mem t ht_mem _, rfl⟩
  by_contra h
  rw [Set.not_nonempty_iff_eq_empty] at h
  rw [h] at hst
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
β : Type u_2
S : Set (Set β)
h_pi : IsPiSystem S
f : α → β
s : Set β
hs_mem : s ∈ S
t : Set β
ht_mem : t ∈ S
hst : Set.Nonempty (f ⁻¹' ∅)
h : s ∩ t = ∅
⊢ False

Next tactic:
simp at hst
theorem isPiSystem_iUnion_of_directed_le {α ι} (p : ι → Set (Set α))
    (hp_pi : ∀ n, IsPiSystem (p n)) (hp_directed : Directed (· ≤ ·) p) :
    IsPiSystem (⋃ n, p n) := by
  

Proof state:
α : Type u_1
ι : Sort u_2
p : ι → Set (Set α)
hp_pi : ∀ (n : ι), IsPiSystem (p n)
hp_directed : Directed (fun x x_1 => x ≤ x_1) p
⊢ IsPiSystem (⋃ n, p n)

Next tactic:
intro t1 ht1 t2 ht2 h
theorem isPiSystem_iUnion_of_directed_le {α ι} (p : ι → Set (Set α))
    (hp_pi : ∀ n, IsPiSystem (p n)) (hp_directed : Directed (· ≤ ·) p) :
    IsPiSystem (⋃ n, p n) := by
  intro t1 ht1 t2 ht2 h
  

Proof state:
α : Type u_1
ι : Sort u_2
p : ι → Set (Set α)
hp_pi : ∀ (n : ι), IsPiSystem (p n)
hp_directed : Directed (fun x x_1 => x ≤ x_1) p
t1 : Set α
ht1 : t1 ∈ ⋃ n, p n
t2 : Set α
ht2 : t2 ∈ ⋃ n, p n
h : Set.Nonempty (t1 ∩ t2)
⊢ t1 ∩ t2 ∈ ⋃ n, p n

Next tactic:
rw [Set.mem_iUnion] at ht1 ht2 ⊢
theorem isPiSystem_iUnion_of_directed_le {α ι} (p : ι → Set (Set α))
    (hp_pi : ∀ n, IsPiSystem (p n)) (hp_directed : Directed (· ≤ ·) p) :
    IsPiSystem (⋃ n, p n) := by
  intro t1 ht1 t2 ht2 h
  rw [Set.mem_iUnion] at ht1 ht2 ⊢
  

Proof state:
α : Type u_1
ι : Sort u_2
p : ι → Set (Set α)
hp_pi : ∀ (n : ι), IsPiSystem (p n)
hp_directed : Directed (fun x x_1 => x ≤ x_1) p
t1 : Set α
ht1 : ∃ i, t1 ∈ p i
t2 : Set α
ht2 : ∃ i, t2 ∈ p i
h : Set.Nonempty (t1 ∩ t2)
⊢ ∃ i, t1 ∩ t2 ∈ p i

Next tactic:
cases' ht1 with n ht1
theorem isPiSystem_iUnion_of_directed_le {α ι} (p : ι → Set (Set α))
    (hp_pi : ∀ n, IsPiSystem (p n)) (hp_directed : Directed (· ≤ ·) p) :
    IsPiSystem (⋃ n, p n) := by
  intro t1 ht1 t2 ht2 h
  rw [Set.mem_iUnion] at ht1 ht2 ⊢
  cases' ht1 with n ht1
  

Proof state:
case intro
α : Type u_1
ι : Sort u_2
p : ι → Set (Set α)
hp_pi : ∀ (n : ι), IsPiSystem (p n)
hp_directed : Directed (fun x x_1 => x ≤ x_1) p
t1 t2 : Set α
ht2 : ∃ i, t2 ∈ p i
h : Set.Nonempty (t1 ∩ t2)
n : ι
ht1 : t1 ∈ p n
⊢ ∃ i, t1 ∩ t2 ∈ p i

Next tactic:
cases' ht2 with m ht2
theorem isPiSystem_iUnion_of_directed_le {α ι} (p : ι → Set (Set α))
    (hp_pi : ∀ n, IsPiSystem (p n)) (hp_directed : Directed (· ≤ ·) p) :
    IsPiSystem (⋃ n, p n) := by
  intro t1 ht1 t2 ht2 h
  rw [Set.mem_iUnion] at ht1 ht2 ⊢
  cases' ht1 with n ht1
  cases' ht2 with m ht2
  

Proof state:
case intro.intro
α : Type u_1
ι : Sort u_2
p : ι → Set (Set α)
hp_pi : ∀ (n : ι), IsPiSystem (p n)
hp_directed : Directed (fun x x_1 => x ≤ x_1) p
t1 t2 : Set α
h : Set.Nonempty (t1 ∩ t2)
n : ι
ht1 : t1 ∈ p n
m : ι
ht2 : t2 ∈ p m
⊢ ∃ i, t1 ∩ t2 ∈ p i

Next tactic:
obtain ⟨k, hpnk, hpmk⟩ : ∃ k, p n ≤ p k ∧ p m ≤ p k := hp_directed n m
theorem isPiSystem_iUnion_of_directed_le {α ι} (p : ι → Set (Set α))
    (hp_pi : ∀ n, IsPiSystem (p n)) (hp_directed : Directed (· ≤ ·) p) :
    IsPiSystem (⋃ n, p n) := by
  intro t1 ht1 t2 ht2 h
  rw [Set.mem_iUnion] at ht1 ht2 ⊢
  cases' ht1 with n ht1
  cases' ht2 with m ht2
  obtain ⟨k, hpnk, hpmk⟩ : ∃ k, p n ≤ p k ∧ p m ≤ p k := hp_directed n m
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
ι : Sort u_2
p : ι → Set (Set α)
hp_pi : ∀ (n : ι), IsPiSystem (p n)
hp_directed : Directed (fun x x_1 => x ≤ x_1) p
t1 t2 : Set α
h : Set.Nonempty (t1 ∩ t2)
n : ι
ht1 : t1 ∈ p n
m : ι
ht2 : t2 ∈ p m
k : ι
hpnk : p n ≤ p k
hpmk : p m ≤ p k
⊢ ∃ i, t1 ∩ t2 ∈ p i

Next tactic:
exact ⟨k, hp_pi k t1 (hpnk ht1) t2 (hpmk ht2) h⟩
theorem isPiSystem_image_Iio (s : Set α) : IsPiSystem (Iio '' s) := by
  

Proof state:
α : Type u_1
ι : Sort u_2
ι' : Sort u_3
inst✝ : LinearOrder α
s : Set α
⊢ IsPiSystem (Iio '' s)

Next tactic:
rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ -
theorem isPiSystem_image_Iio (s : Set α) : IsPiSystem (Iio '' s) := by
  rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ -
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
ι : Sort u_2
ι' : Sort u_3
inst✝ : LinearOrder α
s : Set α
a : α
ha : a ∈ s
b : α
hb : b ∈ s
⊢ Iio a ∩ Iio b ∈ Iio '' s

Next tactic:
exact ⟨a ⊓ b, inf_ind a b ha hb, Iio_inter_Iio.symm⟩
theorem isPiSystem_image_Iic (s : Set α) : IsPiSystem (Iic '' s) := by
  

Proof state:
α : Type u_1
ι : Sort u_2
ι' : Sort u_3
inst✝ : LinearOrder α
s : Set α
⊢ IsPiSystem (Iic '' s)

Next tactic:
rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ -
theorem isPiSystem_image_Iic (s : Set α) : IsPiSystem (Iic '' s) := by
  rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ -
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
ι : Sort u_2
ι' : Sort u_3
inst✝ : LinearOrder α
s : Set α
a : α
ha : a ∈ s
b : α
hb : b ∈ s
⊢ Iic a ∩ Iic b ∈ Iic '' s

Next tactic:
exact ⟨a ⊓ b, inf_ind a b ha hb, Iic_inter_Iic.symm⟩
theorem isPiSystem_Ixx_mem {Ixx : α → α → Set α} {p : α → α → Prop}
    (Hne : ∀ {a b}, (Ixx a b).Nonempty → p a b)
    (Hi : ∀ {a₁ b₁ a₂ b₂}, Ixx a₁ b₁ ∩ Ixx a₂ b₂ = Ixx (max a₁ a₂) (min b₁ b₂)) (s t : Set α) :
    IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), p l u ∧ Ixx l u = S } := by
  

Proof state:
α : Type u_1
ι : Sort u_2
ι' : Sort u_3
inst✝ : LinearOrder α
Ixx : α → α → Set α
p : α → α → Prop
Hne : ∀ {a b : α}, Set.Nonempty (Ixx a b) → p a b
Hi : ∀ {a₁ b₁ a₂ b₂ : α}, Ixx a₁ b₁ ∩ Ixx a₂ b₂ = Ixx (max a₁ a₂) (min b₁ b₂)
s t : Set α
⊢ IsPiSystem {S | ∃ l ∈ s, ∃ u ∈ t, p l u ∧ Ixx l u = S}

Next tactic:
rintro _ ⟨l₁, hls₁, u₁, hut₁, _, rfl⟩ _ ⟨l₂, hls₂, u₂, hut₂, _, rfl⟩
theorem isPiSystem_Ixx_mem {Ixx : α → α → Set α} {p : α → α → Prop}
    (Hne : ∀ {a b}, (Ixx a b).Nonempty → p a b)
    (Hi : ∀ {a₁ b₁ a₂ b₂}, Ixx a₁ b₁ ∩ Ixx a₂ b₂ = Ixx (max a₁ a₂) (min b₁ b₂)) (s t : Set α) :
    IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), p l u ∧ Ixx l u = S } := by
  rintro _ ⟨l₁, hls₁, u₁, hut₁, _, rfl⟩ _ ⟨l₂, hls₂, u₂, hut₂, _, rfl⟩
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
ι : Sort u_2
ι' : Sort u_3
inst✝ : LinearOrder α
Ixx : α → α → Set α
p : α → α → Prop
Hne : ∀ {a b : α}, Set.Nonempty (Ixx a b) → p a b
Hi : ∀ {a₁ b₁ a₂ b₂ : α}, Ixx a₁ b₁ ∩ Ixx a₂ b₂ = Ixx (max a₁ a₂) (min b₁ b₂)
s t : Set α
l₁ : α
hls₁ : l₁ ∈ s
u₁ : α
hut₁ : u₁ ∈ t
left✝¹ : p l₁ u₁
l₂ : α
hls₂ : l₂ ∈ s
u₂ : α
hut₂ : u₂ ∈ t
left✝ : p l₂ u₂
⊢ Set.Nonempty (Ixx l₁ u₁ ∩ Ixx l₂ u₂) → Ixx l₁ u₁ ∩ Ixx l₂ u₂ ∈ {S | ∃ l ∈ s, ∃ u ∈ t, p l u ∧ Ixx l u = S}

Next tactic:
simp only [Hi]
theorem isPiSystem_Ixx_mem {Ixx : α → α → Set α} {p : α → α → Prop}
    (Hne : ∀ {a b}, (Ixx a b).Nonempty → p a b)
    (Hi : ∀ {a₁ b₁ a₂ b₂}, Ixx a₁ b₁ ∩ Ixx a₂ b₂ = Ixx (max a₁ a₂) (min b₁ b₂)) (s t : Set α) :
    IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), p l u ∧ Ixx l u = S } := by
  rintro _ ⟨l₁, hls₁, u₁, hut₁, _, rfl⟩ _ ⟨l₂, hls₂, u₂, hut₂, _, rfl⟩
  simp only [Hi]
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
α : Type u_1
ι : Sort u_2
ι' : Sort u_3
inst✝ : LinearOrder α
Ixx : α → α → Set α
p : α → α → Prop
Hne : ∀ {a b : α}, Set.Nonempty (Ixx a b) → p a b
Hi : ∀ {a₁ b₁ a₂ b₂ : α}, Ixx a₁ b₁ ∩ Ixx a₂ b₂ = Ixx (max a₁ a₂) (min b₁ b₂)
s t : Set α
l₁ : α
hls₁ : l₁ ∈ s
u₁ : α
hut₁ : u₁ ∈ t
left✝¹ : p l₁ u₁
l₂ : α
hls₂ : l₂ ∈ s
u₂ : α
hut₂ : u₂ ∈ t
left✝ : p l₂ u₂
⊢ Set.Nonempty (Ixx (max l₁ l₂) (min u₁ u₂)) → Ixx (max l₁ l₂) (min u₁ u₂) ∈ {S | ∃ l ∈ s, ∃ u ∈ t, p l u ∧ Ixx l u = S}

Next tactic:
exact fun H => ⟨l₁ ⊔ l₂, sup_ind l₁ l₂ hls₁ hls₂, u₁ ⊓ u₂, inf_ind u₁ u₂ hut₁ hut₂, Hne H, rfl⟩
theorem isPiSystem_Ixx {Ixx : α → α → Set α} {p : α → α → Prop}
    (Hne : ∀ {a b}, (Ixx a b).Nonempty → p a b)
    (Hi : ∀ {a₁ b₁ a₂ b₂}, Ixx a₁ b₁ ∩ Ixx a₂ b₂ = Ixx (max a₁ a₂) (min b₁ b₂)) (f : ι → α)
    (g : ι' → α) : @IsPiSystem α { S | ∃ i j, p (f i) (g j) ∧ Ixx (f i) (g j) = S } := by
  

Proof state:
α : Type u_1
ι : Sort u_2
ι' : Sort u_3
inst✝ : LinearOrder α
Ixx : α → α → Set α
p : α → α → Prop
Hne : ∀ {a b : α}, Set.Nonempty (Ixx a b) → p a b
Hi : ∀ {a₁ b₁ a₂ b₂ : α}, Ixx a₁ b₁ ∩ Ixx a₂ b₂ = Ixx (max a₁ a₂) (min b₁ b₂)
f : ι → α
g : ι' → α
⊢ IsPiSystem {S | ∃ i j, p (f i) (g j) ∧ Ixx (f i) (g j) = S}

Next tactic:
simpa only [exists_range_iff] using isPiSystem_Ixx_mem (@Hne) (@Hi) (range f) (range g)
theorem isPiSystem_Icc_mem (s t : Set α) :
    IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), l ≤ u ∧ Icc l u = S } :=
  isPiSystem_Ixx_mem (Ixx := Icc) nonempty_Icc.1 (by 

Proof state:
α : Type u_1
ι : Sort u_2
ι' : Sort u_3
inst✝ : LinearOrder α
s t : Set α
⊢ ∀ {a₁ b₁ a₂ b₂ : α}, Icc a₁ b₁ ∩ Icc a₂ b₂ = Icc (max a₁ a₂) (min b₁ b₂)

Next tactic:
exact Icc_inter_Icc
theorem isPiSystem_Icc (f : ι → α) (g : ι' → α) :
    @IsPiSystem α { S | ∃ i j, f i ≤ g j ∧ Icc (f i) (g j) = S } :=
  isPiSystem_Ixx (Ixx := Icc) nonempty_Icc.1 (by 

Proof state:
α : Type u_1
ι : Sort u_2
ι' : Sort u_3
inst✝ : LinearOrder α
f : ι → α
g : ι' → α
⊢ ∀ {a₁ b₁ a₂ b₂ : α}, Icc a₁ b₁ ∩ Icc a₂ b₂ = Icc (max a₁ a₂) (min b₁ b₂)

Next tactic:
exact Icc_inter_Icc
theorem generatePiSystem_subset_self {α} {S : Set (Set α)} (h_S : IsPiSystem S) :
    generatePiSystem S ⊆ S := fun x h => by
  

Proof state:
α : Type u_1
S : Set (Set α)
h_S : IsPiSystem S
x : Set α
h : x ∈ generatePiSystem S
⊢ x ∈ S

Next tactic:
induction' h with _ h_s s u _ _ h_nonempty h_s h_u
theorem generatePiSystem_subset_self {α} {S : Set (Set α)} (h_S : IsPiSystem S) :
    generatePiSystem S ⊆ S := fun x h => by
  induction' h with _ h_s s u _ _ h_nonempty h_s h_u
  · 

Proof state:
case base
α : Type u_1
S : Set (Set α)
h_S : IsPiSystem S
x s✝ : Set α
h_s : s✝ ∈ S
⊢ s✝ ∈ S

Next tactic:
exact h_s
theorem generatePiSystem_subset_self {α} {S : Set (Set α)} (h_S : IsPiSystem S) :
    generatePiSystem S ⊆ S := fun x h => by
  induction' h with _ h_s s u _ _ h_nonempty h_s h_u
  · exact h_s
  · 

Proof state:
case inter
α : Type u_1
S : Set (Set α)
h_S : IsPiSystem S
x s u : Set α
h_s✝ : generatePiSystem S s
h_t✝ : generatePiSystem S u
h_nonempty : Set.Nonempty (s ∩ u)
h_s : s ∈ S
h_u : u ∈ S
⊢ s ∩ u ∈ S

Next tactic:
exact h_S _ h_s _ h_u h_nonempty
theorem generatePiSystem_mono {α} {S T : Set (Set α)} (hST : S ⊆ T) :
    generatePiSystem S ⊆ generatePiSystem T := fun t ht => by
  

Proof state:
α : Type u_1
S T : Set (Set α)
hST : S ⊆ T
t : Set α
ht : t ∈ generatePiSystem S
⊢ t ∈ generatePiSystem T

Next tactic:
induction' ht with s h_s s u _ _ h_nonempty h_s h_u
theorem generatePiSystem_mono {α} {S T : Set (Set α)} (hST : S ⊆ T) :
    generatePiSystem S ⊆ generatePiSystem T := fun t ht => by
  induction' ht with s h_s s u _ _ h_nonempty h_s h_u
  · 

Proof state:
case base
α : Type u_1
S T : Set (Set α)
hST : S ⊆ T
t s : Set α
h_s : s ∈ S
⊢ s ∈ generatePiSystem T

Next tactic:
exact generatePiSystem.base (Set.mem_of_subset_of_mem hST h_s)
theorem generatePiSystem_mono {α} {S T : Set (Set α)} (hST : S ⊆ T) :
    generatePiSystem S ⊆ generatePiSystem T := fun t ht => by
  induction' ht with s h_s s u _ _ h_nonempty h_s h_u
  · exact generatePiSystem.base (Set.mem_of_subset_of_mem hST h_s)
  · 

Proof state:
case inter
α : Type u_1
S T : Set (Set α)
hST : S ⊆ T
t s u : Set α
h_s✝ : generatePiSystem S s
h_t✝ : generatePiSystem S u
h_nonempty : Set.Nonempty (s ∩ u)
h_s : s ∈ generatePiSystem T
h_u : u ∈ generatePiSystem T
⊢ s ∩ u ∈ generatePiSystem T

Next tactic:
exact isPiSystem_generatePiSystem T _ h_s _ h_u h_nonempty
theorem generatePiSystem_measurableSet {α} [M : MeasurableSpace α] {S : Set (Set α)}
    (h_meas_S : ∀ s ∈ S, MeasurableSet s) (t : Set α) (h_in_pi : t ∈ generatePiSystem S) :
    MeasurableSet t := by
  

Proof state:
α : Type u_1
M : MeasurableSpace α
S : Set (Set α)
h_meas_S : ∀ s ∈ S, MeasurableSet s
t : Set α
h_in_pi : t ∈ generatePiSystem S
⊢ MeasurableSet t

Next tactic:
induction' h_in_pi with s h_s s u _ _ _ h_s h_u
theorem generatePiSystem_measurableSet {α} [M : MeasurableSpace α] {S : Set (Set α)}
    (h_meas_S : ∀ s ∈ S, MeasurableSet s) (t : Set α) (h_in_pi : t ∈ generatePiSystem S) :
    MeasurableSet t := by
  induction' h_in_pi with s h_s s u _ _ _ h_s h_u
  · 

Proof state:
case base
α : Type u_1
M : MeasurableSpace α
S : Set (Set α)
h_meas_S : ∀ s ∈ S, MeasurableSet s
t s : Set α
h_s : s ∈ S
⊢ MeasurableSet s

Next tactic:
apply h_meas_S _ h_s
theorem generatePiSystem_measurableSet {α} [M : MeasurableSpace α] {S : Set (Set α)}
    (h_meas_S : ∀ s ∈ S, MeasurableSet s) (t : Set α) (h_in_pi : t ∈ generatePiSystem S) :
    MeasurableSet t := by
  induction' h_in_pi with s h_s s u _ _ _ h_s h_u
  · apply h_meas_S _ h_s
  · 

Proof state:
case inter
α : Type u_1
M : MeasurableSpace α
S : Set (Set α)
h_meas_S : ∀ s ∈ S, MeasurableSet s
t s u : Set α
h_s✝ : generatePiSystem S s
h_t✝ : generatePiSystem S u
h_nonempty✝ : Set.Nonempty (s ∩ u)
h_s : MeasurableSet s
h_u : MeasurableSet u
⊢ MeasurableSet (s ∩ u)

Next tactic:
apply MeasurableSet.inter h_s h_u
theorem generateFrom_generatePiSystem_eq {α} {g : Set (Set α)} :
    generateFrom (generatePiSystem g) = generateFrom g := by
  

Proof state:
α : Type u_1
g : Set (Set α)
⊢ generateFrom (generatePiSystem g) = generateFrom g

Next tactic:
apply le_antisymm
theorem generateFrom_generatePiSystem_eq {α} {g : Set (Set α)} :
    generateFrom (generatePiSystem g) = generateFrom g := by
  apply le_antisymm <;> 

Proof state:
case a
α : Type u_1
g : Set (Set α)
⊢ generateFrom (generatePiSystem g) ≤ generateFrom g

Next tactic:
apply generateFrom_le
theorem generateFrom_generatePiSystem_eq {α} {g : Set (Set α)} :
    generateFrom (generatePiSystem g) = generateFrom g := by
  apply le_antisymm <;> 

Proof state:
case a
α : Type u_1
g : Set (Set α)
⊢ generateFrom g ≤ generateFrom (generatePiSystem g)

Next tactic:
apply generateFrom_le
theorem generateFrom_generatePiSystem_eq {α} {g : Set (Set α)} :
    generateFrom (generatePiSystem g) = generateFrom g := by
  apply le_antisymm <;> apply generateFrom_le
  · 

Proof state:
case a.h
α : Type u_1
g : Set (Set α)
⊢ ∀ t ∈ generatePiSystem g, MeasurableSet t

Next tactic:
exact fun t h_t => generateFrom_measurableSet_of_generatePiSystem t h_t
theorem generateFrom_generatePiSystem_eq {α} {g : Set (Set α)} :
    generateFrom (generatePiSystem g) = generateFrom g := by
  apply le_antisymm <;> apply generateFrom_le
  · exact fun t h_t => generateFrom_measurableSet_of_generatePiSystem t h_t
  · 

Proof state:
case a.h
α : Type u_1
g : Set (Set α)
⊢ ∀ t ∈ g, MeasurableSet t

Next tactic:
exact fun t h_t => measurableSet_generateFrom (generatePiSystem.base h_t)
theorem mem_generatePiSystem_iUnion_elim {α β} {g : β → Set (Set α)} (h_pi : ∀ b, IsPiSystem (g b))
    (t : Set α) (h_t : t ∈ generatePiSystem (⋃ b, g b)) :
    ∃ (T : Finset β) (f : β → Set α), (t = ⋂ b ∈ T, f b) ∧ ∀ b ∈ T, f b ∈ g b := by
  

Proof state:
α : Type u_1
β : Type u_2
g : β → Set (Set α)
h_pi : ∀ (b : β), IsPiSystem (g b)
t : Set α
h_t : t ∈ generatePiSystem (⋃ b, g b)
⊢ ∃ T f, t = ⋂ b ∈ T, f b ∧ ∀ b ∈ T, f b ∈ g b

Next tactic:
induction' h_t with s h_s s t' h_gen_s h_gen_t' h_nonempty h_s h_t'
theorem mem_generatePiSystem_iUnion_elim {α β} {g : β → Set (Set α)} (h_pi : ∀ b, IsPiSystem (g b))
    (t : Set α) (h_t : t ∈ generatePiSystem (⋃ b, g b)) :
    ∃ (T : Finset β) (f : β → Set α), (t = ⋂ b ∈ T, f b) ∧ ∀ b ∈ T, f b ∈ g b := by
  induction' h_t with s h_s s t' h_gen_s h_gen_t' h_nonempty h_s h_t'
  · 

Proof state:
case base
α : Type u_1
β : Type u_2
g : β → Set (Set α)
h_pi : ∀ (b : β), IsPiSystem (g b)
t s : Set α
h_s : s ∈ ⋃ b, g b
⊢ ∃ T f, s = ⋂ b ∈ T, f b ∧ ∀ b ∈ T, f b ∈ g b

Next tactic:
rcases h_s with ⟨t', ⟨⟨b, rfl⟩, h_s_in_t'⟩⟩
theorem mem_generatePiSystem_iUnion_elim {α β} {g : β → Set (Set α)} (h_pi : ∀ b, IsPiSystem (g b))
    (t : Set α) (h_t : t ∈ generatePiSystem (⋃ b, g b)) :
    ∃ (T : Finset β) (f : β → Set α), (t = ⋂ b ∈ T, f b) ∧ ∀ b ∈ T, f b ∈ g b := by
  induction' h_t with s h_s s t' h_gen_s h_gen_t' h_nonempty h_s h_t'
  · rcases h_s with ⟨t', ⟨⟨b, rfl⟩, h_s_in_t'⟩⟩
    

Proof state:
case base.intro.intro.intro
α : Type u_1
β : Type u_2
g : β → Set (Set α)
h_pi : ∀ (b : β), IsPiSystem (g b)
t s : Set α
b : β
h_s_in_t' : s ∈ (fun b => g b) b
⊢ ∃ T f, s = ⋂ b ∈ T, f b ∧ ∀ b ∈ T, f b ∈ g b

Next tactic:
refine' ⟨{b}, fun _ => s, _⟩
theorem mem_generatePiSystem_iUnion_elim {α β} {g : β → Set (Set α)} (h_pi : ∀ b, IsPiSystem (g b))
    (t : Set α) (h_t : t ∈ generatePiSystem (⋃ b, g b)) :
    ∃ (T : Finset β) (f : β → Set α), (t = ⋂ b ∈ T, f b) ∧ ∀ b ∈ T, f b ∈ g b := by
  induction' h_t with s h_s s t' h_gen_s h_gen_t' h_nonempty h_s h_t'
  · rcases h_s with ⟨t', ⟨⟨b, rfl⟩, h_s_in_t'⟩⟩
    refine' ⟨{b}, fun _ => s, _⟩
    

Proof state:
case base.intro.intro.intro
α : Type u_1
β : Type u_2
g : β → Set (Set α)
h_pi : ∀ (b : β), IsPiSystem (g b)
t s : Set α
b : β
h_s_in_t' : s ∈ (fun b => g b) b
⊢ s = ⋂ b_1 ∈ {b}, (fun x => s) b_1 ∧ ∀ b_1 ∈ {b}, (fun x => s) b_1 ∈ g b_1

Next tactic:
simpa using h_s_in_t'
theorem mem_generatePiSystem_iUnion_elim {α β} {g : β → Set (Set α)} (h_pi : ∀ b, IsPiSystem (g b))
    (t : Set α) (h_t : t ∈ generatePiSystem (⋃ b, g b)) :
    ∃ (T : Finset β) (f : β → Set α), (t = ⋂ b ∈ T, f b) ∧ ∀ b ∈ T, f b ∈ g b := by
  induction' h_t with s h_s s t' h_gen_s h_gen_t' h_nonempty h_s h_t'
  · rcases h_s with ⟨t', ⟨⟨b, rfl⟩, h_s_in_t'⟩⟩
    refine' ⟨{b}, fun _ => s, _⟩
    simpa using h_s_in_t'
  · 

Proof state:
case inter
α : Type u_1
β : Type u_2
g : β → Set (Set α)
h_pi : ∀ (b : β), IsPiSystem (g b)
t s t' : Set α
h_gen_s : generatePiSystem (⋃ b, g b) s
h_gen_t' : generatePiSystem (⋃ b, g b) t'
h_nonempty : Set.Nonempty (s ∩ t')
h_s : ∃ T f, s = ⋂ b ∈ T, f b ∧ ∀ b ∈ T, f b ∈ g b
h_t' : ∃ T f, t' = ⋂ b ∈ T, f b ∧ ∀ b ∈ T, f b ∈ g b
⊢ ∃ T f, s ∩ t' = ⋂ b ∈ T, f b ∧ ∀ b ∈ T, f b ∈ g b

Next tactic:
rcases h_t' with ⟨T_t', ⟨f_t', ⟨rfl, h_t'⟩⟩⟩
theorem mem_generatePiSystem_iUnion_elim {α β} {g : β → Set (Set α)} (h_pi : ∀ b, IsPiSystem (g b))
    (t : Set α) (h_t : t ∈ generatePiSystem (⋃ b, g b)) :
    ∃ (T : Finset β) (f : β → Set α), (t = ⋂ b ∈ T, f b) ∧ ∀ b ∈ T, f b ∈ g b := by
  induction' h_t with s h_s s t' h_gen_s h_gen_t' h_nonempty h_s h_t'
  · rcases h_s with ⟨t', ⟨⟨b, rfl⟩, h_s_in_t'⟩⟩
    refine' ⟨{b}, fun _ => s, _⟩
    simpa using h_s_in_t'
  · rcases h_t' with ⟨T_t', ⟨f_t', ⟨rfl, h_t'⟩⟩⟩
    

Proof state:
case inter.intro.intro.intro
α : Type u_1
β : Type u_2
g : β → Set (Set α)
h_pi : ∀ (b : β), IsPiSystem (g b)
t s : Set α
h_gen_s : generatePiSystem (⋃ b, g b) s
h_s : ∃ T f, s = ⋂ b ∈ T, f b ∧ ∀ b ∈ T, f b ∈ g b
T_t' : Finset β
f_t' : β → Set α
h_t' : ∀ b ∈ T_t', f_t' b ∈ g b
h_gen_t' : generatePiSystem (⋃ b, g b) (⋂ b ∈ T_t', f_t' b)
h_nonempty : Set.Nonempty (s ∩ ⋂ b ∈ T_t', f_t' b)
⊢ ∃ T f, s ∩ ⋂ b ∈ T_t', f_t' b = ⋂ b ∈ T, f b ∧ ∀ b ∈ T, f b ∈ g b

Next tactic:
rcases h_s with ⟨T_s, ⟨f_s, ⟨rfl, h_s⟩⟩⟩