|
| 1 | +/- |
| 2 | +Copyright (c) 2020 Adam Topaz. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Adam Topaz |
| 5 | +-/ |
| 6 | + |
| 7 | +import tactic |
| 8 | +import data.finset.basic |
| 9 | + |
| 10 | +/-! |
| 11 | +# Constructions involving sets of sets. |
| 12 | +
|
| 13 | +## Finite Intersections |
| 14 | +
|
| 15 | +We define a structure `has_finite_inter` which asserts that a set `S` of subsets of `α` is |
| 16 | +closed under finite intersections. |
| 17 | +
|
| 18 | +We define `finite_inter_closure` which, given a set `S` of subsets of `α`, is the smallest |
| 19 | +set of subsets of `α` which is closed under finite intersections. |
| 20 | +
|
| 21 | +`finite_inter_closure S` is endowed with a term of type `has_finite_inter` using |
| 22 | +`finite_inter_closure_has_finite_inter`. |
| 23 | +
|
| 24 | +-/ |
| 25 | + |
| 26 | +variables {α : Type*} (S : set (set α)) |
| 27 | + |
| 28 | +/-- A structure encapsulating the fact that a set of sets is closed under finite intersection. -/ |
| 29 | +structure has_finite_inter := |
| 30 | +(univ_mem : set.univ ∈ S) |
| 31 | +(inter_mem {s t} : s ∈ S → t ∈ S → s ∩ t ∈ S) |
| 32 | + |
| 33 | +namespace has_finite_inter |
| 34 | + |
| 35 | +-- Satisfying the inhabited linter... |
| 36 | +instance : inhabited (has_finite_inter ({set.univ} : set (set α))) := |
| 37 | +⟨⟨by tauto, λ _ _ h1 h2, by finish⟩⟩ |
| 38 | + |
| 39 | +/-- The smallest set of sets containing `S` which is closed under finite intersections. -/ |
| 40 | +inductive finite_inter_closure : set (set α) |
| 41 | +| basic {s} : s ∈ S → finite_inter_closure s |
| 42 | +| univ : finite_inter_closure set.univ |
| 43 | +| inter {s t} : finite_inter_closure s → finite_inter_closure t → finite_inter_closure (s ∩ t) |
| 44 | + |
| 45 | +/-- Defines `has_finite_inter` for `finite_inter_closure S`. -/ |
| 46 | +def finite_inter_closure_has_finite_inter : has_finite_inter (finite_inter_closure S) := |
| 47 | +{ univ_mem := finite_inter_closure.univ, |
| 48 | + inter_mem := λ _ _, finite_inter_closure.inter } |
| 49 | + |
| 50 | +variable {S} |
| 51 | +lemma finite_inter_mem (cond : has_finite_inter S) (F : finset (set α)) : |
| 52 | + ↑F ⊆ S → ⋂₀ (↑F : set (set α)) ∈ S := |
| 53 | +begin |
| 54 | + classical, |
| 55 | + refine finset.induction_on F (λ _, _) _, |
| 56 | + { simp [cond.univ_mem] }, |
| 57 | + { intros a s h1 h2 h3, |
| 58 | + suffices : a ∩ ⋂₀ ↑s ∈ S, by simpa, |
| 59 | + exact cond.inter_mem (h3 (finset.mem_insert_self a s)) |
| 60 | + (h2 $ λ x hx, h3 $ finset.mem_insert_of_mem hx) } |
| 61 | +end |
| 62 | + |
| 63 | +lemma finite_inter_closure_insert {A : set α} (cond : has_finite_inter S) |
| 64 | + (P ∈ finite_inter_closure (insert A S)) : P ∈ S ∨ ∃ Q ∈ S, P = A ∩ Q := |
| 65 | +begin |
| 66 | + induction H with S h T1 T2 _ _ h1 h2, |
| 67 | + { cases h, |
| 68 | + { exact or.inr ⟨set.univ, cond.univ_mem, by simpa⟩ }, |
| 69 | + { exact or.inl h } }, |
| 70 | + { exact or.inl cond.univ_mem }, |
| 71 | + { rcases h1 with (h | ⟨Q, hQ, rfl⟩); rcases h2 with (i | ⟨R, hR, rfl⟩), |
| 72 | + { exact or.inl (cond.inter_mem h i) }, |
| 73 | + { exact or.inr ⟨T1 ∩ R, cond.inter_mem h hR, by finish⟩ }, |
| 74 | + { exact or.inr ⟨Q ∩ T2, cond.inter_mem hQ i, by finish⟩ }, |
| 75 | + { exact or.inr ⟨Q ∩ R, cond.inter_mem hQ hR , by tidy⟩ } } |
| 76 | +end |
| 77 | + |
| 78 | +end has_finite_inter |
0 commit comments