Source code on Github
{-# OPTIONS --without-K --safe #-}
module Relation.Ternary.Core where
open import Data.Product using (_×_)
open import Function.Base using (_on_)
open import Level using (Level; _⊔_; suc)
private
variable
a b c ℓ ℓ₁ ℓ₂ ℓ₃ : Level
A : Set a
B : Set b
C : Set c
3REL : Set a → Set b → Set c → (ℓ : Level) → Set (a ⊔ b ⊔ c ⊔ suc ℓ)
3REL A B C ℓ = A → B → C → Set ℓ
3Rel : Set a → (ℓ : Level) → Set (a ⊔ suc ℓ)
3Rel A ℓ = 3REL A A A ℓ
infix 4 _⇒_ _⇔_ _=[_]⇒_
_⇒_ : 3REL A B C ℓ₁ → 3REL A B C ℓ₂ → Set _
P ⇒ Q = ∀ {x y z} → P x y z → Q x y z
_⇔_ : 3REL A B C ℓ₁ → 3REL A B C ℓ₂ → Set _
P ⇔ Q = P ⇒ Q × Q ⇒ P
_on³_ : (B → B → B → C) → (A → B) → (A → A → A → C)
(_~_~_ on³ f) x y z = f x ~ f y ~ f z
_=[_]⇒_ : 3Rel A ℓ₁ → (A → B) → 3Rel B ℓ₂ → Set _
P =[ f ]⇒ Q = P ⇒ (Q on³ f)
_Preserves_⟶_ : (A → B) → 3Rel A ℓ₁ → 3Rel B ℓ₂ → Set _
f Preserves P ⟶ Q = P =[ f ]⇒ Q
_Preserves_⟶_⟶_ : (A → B → C) → 3Rel A ℓ₁ → 3Rel B ℓ₂ → 3Rel C ℓ₃ → Set _
_∙_ Preserves P ⟶ Q ⟶ R = ∀ {x y z u v w} → P x y z → Q u v w → R (x ∙ u) (y ∙ v) (z ∙ w)