\begin{code}
{-# OPTIONS --safe #-}
open import Prelude
open import Data.Vec
open import Signatures
open import FinitenessConditions
module FreeMonad.Theory where
open import FreeMonad.Syntax
private variable π½ : Signature
infix 4 _β_
record Equation (π½ : Signature) (Ξ½ : Type a) : Type a
\end{code}
%<*equation>
\begin{code}
record Equation π½ Ξ½ where
constructor _β_
field lhs rhs : Syntax π½ Ξ½
\end{code}
%</equation>
\begin{code}
open Equation public
ββΏ : β {n} β (β {A : Type} β CurryβΏ n (Syntax π½ A) (const (Equation π½ A)))
β Equation π½ (Fin n)
ββΏ {n = n} f = uncurryβΏ {A = Syntax _ (Fin n)} f var
record Law (π½ : Signature) (β : Level) : Type (βsuc β)
record Law π½ β where
field Ξ : Type β
Ξ½ : Ξ β Type β
eqn : (Ξ³ : Ξ) β Equation π½ (Ξ½ Ξ³)
record Theory (π½ : Signature) (β : Level) : Type (βsuc β)
record Theory π½ β where
field Laws : Type
Eqns : Laws β Law π½ β
open Theory
_ββ‘_ : {β : Level} β (L : Type) β (L β Law π½ β) β Theory π½ β
(laws ββ‘ eqns) .Laws = laws
(laws ββ‘ eqns) .Eqns = eqns
open Law public
module _ {π½ : Signature} {π : Type a} {Ξ½ : Type b} where
private module RespectsExt where
infix 3 _Respects_
_Respects_ : π½ -Alg[ π ] β Equation π½ Ξ½ β Type _
Ο Respects lhs β rhs = flip (interp π½ Ο) lhs β‘ flip (interp π½ Ο) rhs
infix 3 _Respects_
_Respects_ : π½ -Alg[ π ] β Equation π½ Ξ½ β Type _
\end{code}
%<*respects>
\begin{code}
Ο Respects (lhs β rhs) = β (Ο : Ξ½ β π) β interp π½ Ο Ο lhs β‘ interp π½ Ο Ο rhs
\end{code}
%</respects>
\begin{code}
infix 4 _Models_
_Models_ : π½ -Alg[ A ] β Theory π½ b β Type _
\end{code}
%<*in-theory>
\begin{code}
Ο Models π― = β i Ξ³ β Ο Respects π― .Eqns i .eqn Ξ³
\end{code}
%</in-theory>
\begin{code}
module _ {π½ : Signature} where
_-Model[_] : Theory π½ a β Type b β Type _
\end{code}
%<*t-model>
\begin{code}
π― -Model[ π ] = Ξ£[ Ο β¦ π½ -Alg[ π ] ] Γ Ο Models π―
\end{code}
%</t-model>
\begin{code}
FiniteVars : Theory π½ a β _
FiniteVars π― =
β i β
let law = π― .Eqns i in
(Ξ³ : Ξ law) β
SplitQuotientedChoiceΟ (Ξ½ law Ξ³)
DiscreteVars : Theory π½ a β _
DiscreteVars π― =
β i β
let law = π― .Eqns i in
(Ξ³ : Ξ law) β
Discrete (Ξ½ law Ξ³)
\end{code}