| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Properties of binary relations |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
-- The contents of this module should be accessed via `Relation.Binary`. |
| 8 |
|
| 9 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 10 |
|
| 11 |
module Relation.Binary.Core where |
| 12 |
|
| 13 |
open import Data.Product.Base using (_×_) |
| 14 |
open import Function.Base using (_on_) |
| 15 |
open import Level using (Level; _⊔_; suc) |
| 16 |
|
| 17 |
private |
| 18 |
variable |
| 19 |
a b c ℓ ℓ₁ ℓ₂ ℓ₃ : Level |
| 20 |
A : Set a |
| 21 |
B : Set b |
| 22 |
C : Set c |
| 23 |
|
| 24 |
------------------------------------------------------------------------ |
| 25 |
-- Definitions |
| 26 |
------------------------------------------------------------------------ |
| 27 |
|
| 28 |
-- Heterogeneous binary relations |
| 29 |
|
| 30 |
REL : Set a → Set b → (ℓ : Level) → Set (a ⊔ b ⊔ suc ℓ) |
| 31 |
REL A B ℓ = A → B → Set ℓ |
| 32 |
|
| 33 |
-- Homogeneous binary relations |
| 34 |
|
| 35 |
Rel : Set a → (ℓ : Level) → Set (a ⊔ suc ℓ) |
| 36 |
Rel A ℓ = REL A A ℓ |
| 37 |
|
| 38 |
------------------------------------------------------------------------ |
| 39 |
-- Relationships between relations |
| 40 |
------------------------------------------------------------------------ |
| 41 |
|
| 42 |
infix 4 _⇒_ _⇔_ _=[_]⇒_ |
| 43 |
|
| 44 |
-- Implication/containment - could also be written _⊆_. |
| 45 |
-- and corresponding notion of equivalence |
| 46 |
|
| 47 |
_⇒_ : REL A B ℓ₁ → REL A B ℓ₂ → Set _ |
| 48 |
P ⇒ Q = ∀ {x y} → P x y → Q x y |
| 49 |
|
| 50 |
_⇔_ : REL A B ℓ₁ → REL A B ℓ₂ → Set _ |
| 51 |
P ⇔ Q = P ⇒ Q × Q ⇒ P |
| 52 |
|
| 53 |
-- Generalised implication - if P ≡ Q it can be read as "f preserves P". |
| 54 |
|
| 55 |
_=[_]⇒_ : Rel A ℓ₁ → (A → B) → Rel B ℓ₂ → Set _ |
| 56 |
P =[ f ]⇒ Q = P ⇒ (Q on f) |
| 57 |
|
| 58 |
-- A synonym for _=[_]⇒_. |
| 59 |
|
| 60 |
_Preserves_⟶_ : (A → B) → Rel A ℓ₁ → Rel B ℓ₂ → Set _ |
| 61 |
f Preserves P ⟶ Q = P =[ f ]⇒ Q |
| 62 |
|
| 63 |
-- A binary variant of _Preserves_⟶_. |
| 64 |
|
| 65 |
_Preserves₂_⟶_⟶_ : (A → B → C) → Rel A ℓ₁ → Rel B ℓ₂ → Rel C ℓ₃ → Set _ |
| 66 |
_∙_ Preserves₂ P ⟶ Q ⟶ R = ∀ {x y u v} → P x y → Q u v → R (x ∙ u) (y ∙ v) |