@@ -35,12 +35,12 @@ filter-∈ᶠˢ {P = P} ⦃ d ⦄ {x} xs mem px = ∈ᶠˢ-elim (λ xs _ → x
35
35
(λ {y} {xs} q ind → case d {y} return (λ p → x ∈ᶠˢ cons-if p y (filter P xs)) of λ { (yes _) → thereₛ ind ; (no ¬px) → ind })
36
36
xs mem
37
37
38
- ∈ᶠˢ-filter : ∀ {P : A → Type ℓ} ⦃ d : ∀ {x} → Dec (P x) ⦄ {x : A} xs → x ∈ᶠˢ filter P xs → ∥ P x ∥
39
- ∈ᶠˢ-filter {P = P} ⦃ d = d ⦄ {x = x} = Finset-elim-prop (λ xs → x ∈ filter P xs → ∥ P x ∥)
38
+ ∈ᶠˢ-filter : ∀ {P : A → Type ℓ} ⦃ d : ∀ {x} → Dec (P x) ⦄ {x : A} xs → x ∈ᶠˢ filter P xs → x ∈ xs × ∥ P x ∥
39
+ ∈ᶠˢ-filter {P = P} ⦃ d = d ⦄ {x = x} = Finset-elim-prop (λ xs → x ∈ filter P xs → x ∈ xs × ∥ P x ∥)
40
40
(λ w → absurd (¬mem-[] w))
41
- (λ y {xs} ind → case d {y} return (λ p → x ∈ᶠˢ cons-if p y (filter P xs) → ∥ P x ∥) of λ where
42
- (yes py) → ∈ᶠˢ-split (λ p → inc (substᵢ P (symᵢ p) py)) ind
43
- (no ¬py) q → ind q)
41
+ (λ y {xs} ind → case d {y} return (λ p → x ∈ᶠˢ cons-if p y (filter P xs) → x ∈ (y ∷ xs) × ∥ P x ∥) of λ where
42
+ (yes py) → ∈ᶠˢ-split (λ p → hereₛ' p , inc (substᵢ P (symᵢ p) py)) λ w → case ind w of λ a b → thereₛ a , inc b
43
+ (no ¬py) q → case ind q of λ a b → thereₛ a , inc b )
44
44
45
45
uncons : (x : A) (xs : Finset A) → x ∈ᶠˢ xs → xs ≡ x ∷ xs
46
46
uncons x = Finset-elim-prop _ (λ x → absurd (¬mem-[] x)) λ y {xs} ih → ∈ᶠˢ-split
@@ -208,3 +208,27 @@ powerset (squash x y p q i j) = hlevel 2 (powerset x) (powerset y) (λ i → pow
208
208
ys' p n → ∈ᶠˢ-split {P = λ _ → y ∈ᶠˢ (x ∷ xs)} hereₛ'
209
209
(λ w → thereₛ (ih ys' n y w))
210
210
(substᵢ (y ∈ᶠˢ_) (symᵢ p) m)
211
+
212
+ delete : ⦃ _ : Discrete A ⦄ → A → Finset A → Finset A
213
+ delete x xs = filter (x ≠_) xs
214
+
215
+ powerset-∈ᶠˢ : ⦃ _ : Discrete A ⦄ (xs ys : Finset A) → ys ⊆ xs → ys ∈ powerset xs
216
+ powerset-∈ᶠˢ = Finset-elim-prop _
217
+ (λ ys sube → hereₛ' (Id≃path.from (finset-ext sube (λ a m → absurd (¬mem-[] m)))))
218
+ λ x {xs} ih ys sube → caseᵈ x ∈ ys of λ where
219
+ (yes x∈ys) →
220
+ let
221
+ ys' = delete x ys
222
+
223
+ p : x ∷ ys' ≡ ys
224
+ p = finset-ext
225
+ (λ a m → ∈ᶠˢ-split {P = λ _ → a ∈ ys} (λ p → substᵢ (_∈ ys) (symᵢ p) x∈ys) (λ w → case ∈ᶠˢ-filter {P = x ≠_} ys w of λ p _ → p) m)
226
+ λ a b → case a ≡ᵢ? x of λ { (yes p) → hereₛ' p ; (no ¬q) → thereₛ (filter-∈ᶠˢ ys b λ a → ¬q (Id≃path.from (sym a))) }
227
+
228
+ s' : delete x ys ⊆ xs
229
+ s' a m =
230
+ let (m' , a≠x) = ∈ᶠˢ-filter ys m
231
+ in ∈ᶠˢ-split {P = λ _ → a ∈ xs} (λ p → case a≠x of λ ¬x=a → absurd (¬x=a (Id≃path.to (symᵢ p)))) (λ w → w) (sube a m')
232
+ in unionr-∈ᶠˢ _ (powerset xs) _ $ map-∈ᶠˢ' (x ∷_) (powerset xs) p (ih ys' s')
233
+ (no x∉ys) → unionl-∈ᶠˢ _ (powerset xs) _ $ ih ys λ a m → ∈ᶠˢ-split {P = λ _ → a ∈ xs}
234
+ (λ a=x → absurd (x∉ys (substᵢ (_∈ ys) a=x m))) (λ w → w) (sube a m)
0 commit comments