@@ -38,6 +38,11 @@ def compl {X : Type u} (s : Set X) : Set X := fun x => ¬s x
3838-- (⋃ intervals) x = ∃ i, intervals i x = ∃ i, i ≤ x ∧ x ≤ i+1 (covers all reals)
3939def iUnion {X : Type u} {ι : Type u} (s : ι → Set X) : Set X := fun x => ∃ i, s i x
4040
41+ -- Indexed intersection: element is in all sets from the family
42+ -- Example: if halflines i := fun x => x ≥ i, then
43+ -- (⋂ halflines) x = ∀ i, halflines i x = ∀ i, x ≥ i (only satisfied by no real number)
44+ def iInter {X : Type u} {ι : Type u} (s : ι → Set X) : Set X := fun x => ∀ i, s i x
45+
4146protected def Mem (s : Set α) (a : α) : Prop := s a
4247
4348instance : Membership α (Set α) := ⟨Set.Mem⟩
@@ -48,6 +53,7 @@ infixl:70 " ∩ " => Set.inter
4853infixl :65 " ∪ " => Set.union
4954postfix :max " ᶜ" => Set.compl
5055notation " ⋃ " f => Set.iUnion f
56+ notation " ⋂ " f => Set.iInter f
5157
5258-- Basic subset relation
5359def subset (s t : Set X) : Prop := ∀ x, x ∈ s → x ∈ t
@@ -80,5 +86,40 @@ theorem compl_inter {X : Type u} (s t : Set X) : (s ∩ t)ᶜ = sᶜ ∪ tᶜ :=
8086
8187theorem compl_union {X : Type u} (s t : Set X) : (s ∪ t)ᶜ = sᶜ ∩ tᶜ := by ode_to_grind
8288
89+ -- De Morgan's laws for indexed unions and intersections
90+ theorem compl_iUnion {X : Type u} {ι : Type u} (s : ι → Set X) : (⋃ s)ᶜ = ⋂ (fun i => (s i)ᶜ) := by
91+ apply ext
92+ intro x
93+ constructor
94+ · intro h i hi
95+ -- h : ¬∃ i, s i x, hi : s i x, goal: False
96+ exact h ⟨i, hi⟩
97+ · intro h ⟨i, hi⟩
98+ -- h : ∀ i, ¬s i x, hi : s i x, goal: False
99+ exact h i hi
100+
101+ theorem compl_iInter {X : Type u} {ι : Type u} (s : ι → Set X) : (⋂ s)ᶜ = ⋃ (fun i => (s i)ᶜ) := by
102+ apply ext
103+ intro x
104+ constructor
105+ · intro h
106+ -- h : ¬∀ i, s i x, goal: ∃ i, ¬s i x
107+ -- Use classical logic via excluded middle
108+ classical
109+ have em : (∃ i, ¬s i x) ∨ ¬(∃ i, ¬s i x) := Classical.em (∃ i, ¬s i x)
110+ cases em with
111+ | inl hex => exact hex
112+ | inr hnex =>
113+ -- hnex : ¬∃ i, ¬s i x, which means ∀ i, s i x
114+ exfalso
115+ apply h
116+ intro i
117+ -- Need to show s i x from ¬∃ i, ¬s i x
118+ have : ¬¬s i x := fun hi => hnex ⟨i, hi⟩
119+ exact Classical.not_not.mp this
120+ · intro ⟨i, hi⟩ h
121+ -- hi : ¬s i x, h : ∀ i, s i x, goal: False
122+ exact hi (h i)
123+
83124
84125end Set
0 commit comments