module Data.Fin.Subset where
open import Data.Nat
open import Data.Vec hiding (_∈_)
open import Data.Fin
open import Data.Product
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
infixr 2 _∈_ _∉_ _⊆_ _⊈_
data Side : Set where
inside : Side
outside : Side
Subset : ℕ → Set
Subset = Vec Side
_∈_ : ∀ {n} → Fin n → Subset n → Set
x ∈ p = p [ x ]= inside
_∉_ : ∀ {n} → Fin n → Subset n → Set
x ∉ p = ¬ (x ∈ p)
_⊆_ : ∀ {n} → Subset n → Subset n → Set
p₁ ⊆ p₂ = ∀ {x} → x ∈ p₁ → x ∈ p₂
_⊈_ : ∀ {n} → Subset n → Subset n → Set
p₁ ⊈ p₂ = ¬ (p₁ ⊆ p₂)
all : ∀ {n} → Side → Subset n
all {zero} _ = []
all {suc n} s = s ∷ all s
Nonempty : ∀ {n} (p : Subset n) → Set
Nonempty p = ∃ λ f → f ∈ p
Empty : ∀ {n} (p : Subset n) → Set
Empty p = ¬ Nonempty p
Lift : ∀ {n} → (Fin n → Set) → (Subset n → Set)
Lift P p = ∀ {x} → x ∈ p → P x