{-# OPTIONS --cubical-compatible --safe #-}

module Algebra.Cost.Bundles where

open import Algebra.Core
open import Algebra.Cost.Structures
open import Relation.Binary using (Rel; Preorder; _Preserves_⟶_; _Preserves₂_⟶_⟶_)
open import Relation.Binary.PropositionalEquality using (_≡_; resp₂)
open import Level using (0ℓ)


record CostMonoid : Set₁ where
  infixl 6 _+_

  field
                : Set
    zero         : 
    _+_          : Op₂ 
    _≤_          : Rel  0ℓ
    isCostMonoid : IsCostMonoid  zero _+_ _≤_

  open IsCostMonoid isCostMonoid public

  ≤-preorder : Preorder 0ℓ 0ℓ 0ℓ
  Preorder.Carrier ≤-preorder = 
  Preorder._≈_ ≤-preorder = _≡_
  Preorder._≲_ ≤-preorder = _≤_
  Preorder.isPreorder ≤-preorder = isPreorder

  module ≤-Reasoning where
    open import Relation.Binary.Reasoning.Preorder ≤-preorder public


record ParCostMonoid : Set₁ where
  infixl 7 _⊗_
  infixl 6 _⊕_

  field
                   : Set
    𝟘               : 
    _⊕_             : Op₂ 
    _⊗_             : Op₂ 
    _≤_             : Rel  0ℓ
    isParCostMonoid : IsParCostMonoid  𝟘 _⊕_ _⊗_ _≤_

  open IsParCostMonoid isParCostMonoid public

  costMonoid : CostMonoid
  costMonoid = record
    {  = 
    ; _+_ = _⊕_
    ; zero = 𝟘
    ; _≤_ = _≤_
    ; isCostMonoid = record
      { isMonoid = isMonoid
      ; isPreorder = isPreorder
      ; isMonotone = isMonotone-⊕
      }
    }

  ≤-preorder : Preorder 0ℓ 0ℓ 0ℓ
  Preorder.Carrier ≤-preorder = 
  Preorder._≈_ ≤-preorder = _≡_
  Preorder._≲_ ≤-preorder = _≤_
  Preorder.isPreorder ≤-preorder = isPreorder

  module ≤-Reasoning where
    open import Relation.Binary.Reasoning.Preorder ≤-preorder public