module Relation.Unary where
open import Data.Empty
open import Data.Function
open import Data.Unit
open import Data.Product
open import Data.Sum
open import Relation.Nullary
Pred : Set → Set₁
Pred a = a → Set
private
module Dummy {a : Set}
where
infix 4 _∈_ _∉_
_∈_ : a → Pred a → Set
x ∈ P = P x
_∉_ : a → Pred a → Set
x ∉ P = ¬ x ∈ P
∅ : Pred a
∅ = λ _ → ⊥
Empty : Pred a → Set
Empty P = ∀ x → x ∉ P
∅-Empty : Empty ∅
∅-Empty x ()
U : Pred a
U = λ _ → ⊤
Universal : Pred a → Set
Universal P = ∀ x → x ∈ P
U-Universal : Universal U
U-Universal = λ _ → _
∁ : Pred a → Pred a
∁ P = λ x → x ∉ P
∁∅-Universal : Universal (∁ ∅)
∁∅-Universal = λ x x∈∅ → x∈∅
∁U-Empty : Empty (∁ U)
∁U-Empty = λ x x∈∁U → x∈∁U _
infix 4 _⊆_ _⊇_ _⊆′_ _⊇′_
_⊆_ : Pred a → Pred a → Set
P ⊆ Q = ∀ {x} → x ∈ P → x ∈ Q
_⊆′_ : Pred a → Pred a → Set
P ⊆′ Q = ∀ x → x ∈ P → x ∈ Q
_⊇_ : Pred a → Pred a → Set
Q ⊇ P = P ⊆ Q
_⊇′_ : Pred a → Pred a → Set
Q ⊇′ P = P ⊆′ Q
∅-⊆ : (P : Pred a) → ∅ ⊆ P
∅-⊆ P ()
⊆-U : (P : Pred a) → P ⊆ U
⊆-U P _ = _
infixl 6 _∪_
_∪_ : Pred a → Pred a → Pred a
P ∪ Q = λ x → x ∈ P ⊎ x ∈ Q
infixl 7 _∩_
_∩_ : Pred a → Pred a → Pred a
P ∩ Q = λ x → x ∈ P × x ∈ Q
open Dummy public
infixr 2 _⟨×⟩_
infixr 1 _⟨⊎⟩_
infixr 0 _⟨→⟩_
_⟨×⟩_ : ∀ {A B} → Pred A → Pred B → Pred (A × B)
(P ⟨×⟩ Q) p = P (proj₁ p) × Q (proj₂ p)
_⟨⊎⟩_ : ∀ {A B} → Pred A → Pred B → Pred (A ⊎ B)
(P ⟨⊎⟩ Q) (inj₁ p) = P p
(P ⟨⊎⟩ Q) (inj₂ q) = Q q
_⟨→⟩_ : ∀ {A B} → Pred A → Pred B → Pred (A → B)
(P ⟨→⟩ Q) f = P ⊆ Q ∘₀ f