Source code on Github
{-# OPTIONS --cubical-compatible #-}
module Class.SeparationAlgebra where

open import Function.Definitions using (Injective)
open import Data.Maybe using (Is-just)
open import Relation.Unary renaming (Irrelevant to Irrelevant¹)

open import Class.Prelude
open import Class.Core

open import Class.Setoid.Core
open import Class.Setoid.Instances
open import Class.PartialSemigroup
open import Class.PartialMonoid

-- A separation algebra is a cancellative, partial commutative monoid (Σ, •, ε).
record SeparationAlgebra
  (Σ : Type )  _ : ISetoid Σ   _ : SetoidLaws Σ  : Type (  relℓ {A = Σ}) where
  field
     ps  : PartialSemigroup Σ
     ps-laws  : PartialSemigroupLaws Σ
     pm  : PartialMonoid Σ
     pm-laws  : PartialMonoidLaws Σ
    cancellative :  (x : Σ)  Injective _≈_ _≈_ (x ◆_)

  -- ** induced relations

  -- "separateness"
  _#_ : Rel Σ _
  x # y = Is-just (x  y )

  -- "substate"
  _≼_ : Rel Σ _
  x  z =  λ y  (x  y)  just z

  -- ** predicates over Σ
   : Type _
   = Pred Σ _

  emp : 
  emp = _≈ ε◆

  _∗_ :     Pred Σ _
  (p  q) σ =  λ (σ₀ : Σ)   λ (σ₁ : Σ)
     (σ₀ # σ₁)
    × (σ₀  p)
    × (σ₁  q)

  -- ** precise predicates
  Prec : Pred  _
  Prec p =  σ  Irrelevant¹  σₚ  (σₚ  p) × (σₚ  σ))

open SeparationAlgebra ⦃...⦄ public