{-# OPTIONS --universe-polymorphism #-}
module Relation.Unary where
open import Data.Empty
open import Function
open import Data.Unit
open import Data.Product
open import Data.Sum
open import Level
open import Relation.Nullary
Pred : ∀ {a} → Set a → (ℓ : Level) → Set (a ⊔ suc ℓ)
Pred A ℓ = A → Set ℓ
private
module Dummy {a} {A : Set a}
where
infix 4 _∈_ _∉_
_∈_ : ∀ {ℓ} → A → Pred A ℓ → Set _
x ∈ P = P x
_∉_ : ∀ {ℓ} → A → Pred A ℓ → Set _
x ∉ P = ¬ x ∈ P
∅ : Pred A zero
∅ = λ _ → ⊥
Empty : ∀ {ℓ} → Pred A ℓ → Set _
Empty P = ∀ x → x ∉ P
∅-Empty : Empty ∅
∅-Empty x ()
U : Pred A zero
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 ℓ₁ ℓ₂} {A : Set a} {B : Set b} →
Pred A ℓ₁ → Pred B ℓ₂ → Pred (A × B) _
P ⟨×⟩ Q = uncurry (λ p q → P p × Q q)
_⟨⊎⟩_ : ∀ {a b ℓ} {A : Set a} {B : Set b} →
Pred A ℓ → Pred B ℓ → Pred (A ⊎ B) _
P ⟨⊎⟩ Q = [ P , Q ]
_⟨→⟩_ : ∀ {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b} →
Pred A ℓ₁ → Pred B ℓ₂ → Pred (A → B) _
(P ⟨→⟩ Q) f = P ⊆ Q ∘ f