Riffing off #12 (comment)
This is what I came up with with a very basic Semigroup & Monoid example rather than
the bigger one involving Ring:
||| Inclusion of one signature into another.
-- Do we already have this somewhere?
public export
OpMorph : (p, q : Signature) -> Type
OpMorph p q = {n : Nat} -> p .OpWithArity n -> q .OpWithArity n
Semigroup is what you'd expect. Notice that I have lifted axiom to the
toplevel instead of having MkPresentation _ _ $ \case (...) and that it
takes an OpMorph as an argument: if you can make sense of a semigroup's
operations in a larger context then you can make sense of its axioms too.
||| The syntax and axioms for semigroups
module Frexlet.Semigroup.Theory
import Frex
public export
data Operation : Nat -> Type where
Product : Operation 2
public export
Signature : Signature
Signature = MkSignature Operation
public export
data Axiom
= Associativity
public export
axiom : {sig : _} -> OpMorph Signature sig -> Axiom -> Equation sig
axiom interp Associativity = associativity (interp Product)
public export
SemigroupTheory : Presentation
SemigroupTheory = MkPresentation Theory.Signature Theory.Axiom (axiom id)
And this is the refactored Monoid.Theory. Notice how theSemigroup is
used to focus on Product only out of all the operations.
||| The syntax and axioms for monoids
module Frexlet.Monoid.Theory
import Frexlet.Semigroup.Theory as Semigroup
import Frex
public export
data Operation : Nat -> Type where
Neutral : Operation 0
Product : Operation 2
public export
Signature : Signature
Signature = MkSignature Monoid.Theory.Operation
public export
data Axiom
= LftNeutrality
| RgtNeutrality
| Semigroup Semigroup.Axiom
theSemigroup : OpMorph Semigroup.Signature Monoid.Theory.Signature
theSemigroup Semigroup.Product = Monoid.Theory.Product
public export
axiom : {sig : _} -> OpMorph Monoid.Theory.Signature sig ->
Monoid.Theory.Axiom -> Equation sig
axiom interp LftNeutrality = lftNeutrality (interp Neutral) (interp Product)
axiom interp RgtNeutrality = rgtNeutrality (interp Neutral) (interp Product)
axiom interp (Semigroup ax) = Semigroup.axiom (interp . theSemigroup) ax
public export
MonoidTheory : Presentation
MonoidTheory = MkPresentation Monoid.Theory.Signature Monoid.Theory.Axiom (axiom id)
Is this the kind of stuff you had in mind @ohad?
Riffing off #12 (comment)
This is what I came up with with a very basic
Semigroup&Monoidexample rather thanthe bigger one involving
Ring:Semigroup is what you'd expect. Notice that I have lifted
axiomto thetoplevel instead of having
MkPresentation _ _ $ \case (...)and that ittakes an
OpMorphas an argument: if you can make sense of a semigroup'soperations in a larger context then you can make sense of its axioms too.
And this is the refactored
Monoid.Theory. Notice howtheSemigroupisused to focus on
Productonly out of all the operations.Is this the kind of stuff you had in mind @ohad?