Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _CoqProject.test-suite
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ tests/hnf.v
tests/fun_instance.v
tests/issue284.v
tests/issue287.v
tests/monoid_law_structure.v
tests/monoid_law_structure_clone.v

-R tests HB.tests
-R examples HB.examples
Expand Down
37 changes: 37 additions & 0 deletions tests/monoid_enriched_cat.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
From HB Require Import structures.
From Coq Require Import ssreflect ssrfun.

HB.mixin Record isQuiver Obj := { hom : Obj -> Obj -> Type }.

HB.structure Definition Quiver := { Obj of isQuiver Obj }.

HB.mixin Record isMon A := {
zero : A;
add : A -> A -> A;
addrA : associative add;
add0r : left_id zero add;
addr0 : right_id zero add;
}.

HB.structure
Definition Monoid := { A of isMon A }.

Fail HB.structure
Definition Monoid_enriched_quiver :=
{ Obj of isQuiver Obj &
(forall A B : Obj, isMon (@hom (Quiver.clone Obj _) A B)) }.


HB.mixin Record hom_isMon T of Quiver T :=
{ private : forall A B, isMon (@hom T A B) }.

HB.structure
Definition Monoid_enriched_quiver :=
{ Obj of isQuiver Obj & hom_isMon Obj }.

HB.instance Definition _ (T : Monoid_enriched_quiver.type) (A B : T) : isMon (@hom T A B) :=
@private T A B.

(* each instance of isMon should be tried as an instance of hom_isMon *)


18 changes: 18 additions & 0 deletions tests/monoid_law_structure.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
From HB Require Import structures.

HB.mixin Record isMonLaw T (e : T) (op : T -> T -> T) := {
opmA : forall a b c, op (op a b) c = op a (op b c);
op1m : forall x, op e x = x;
opm1 : forall x, op x e = x;
}.

HB.structure Definition MonLaw T e := { op of isMonLaw T e op }.

HB.mixin Record isPreMonoid T := {
zero : T;
add : T -> T -> T;
}.
HB.structure Definition PreMonoid := { T of isPreMonoid T }.

HB.structure Definition Monoid :=
{ T of isPreMonoid T & isMonLaw T zero add }.
19 changes: 19 additions & 0 deletions tests/monoid_law_structure_clone.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
From HB Require Import structures.

HB.mixin Record isMonLaw T (e : T) (op : T -> T -> T) := {
opmA : forall a b c, op (op a b) c = op a (op b c);
op1m : forall x, op e x = x;
opm1 : forall x, op x e = x;
}.

HB.structure Definition MonLaw T e := { op of isMonLaw T e op }.

HB.mixin Record isPreMonoid T := {
zero : T;
add : T -> T -> T;
}.
HB.structure Definition PreMonoid := { T of isPreMonoid T }.

HB.structure Definition Monoid :=
{ T of isPreMonoid T &
isMonLaw T (@zero (PreMonoid.clone T _)) (@add (PreMonoid.clone T _)) }.