I am trying to bow my head to class classes in Coq (I have done this in the past, but I am far from being an experienced user). As an exercise, I am trying to write a group theory library. This is what I came up with:
Class Group {S : Type} {op : S → S → S} := {
id : S;
inverse : S → S;
id_left {x} : (op id x) = x;
id_right {x} : (op x id) = x;
assoc {x y z} : (op (op x y) z) = (op x (op y z));
right_inv {x} : (op x (inverse x)) = id;
}.
I especially like implicit parameters S
and op
(if I understand them correctly).
Making some notation for inversions is easy:
Notation "- x" := (@inverse _ _ _ x)
(at level 35, right associativity) : group_scope.
Now I would like to make a x * y
cut for (op x y)
. When working with partitions, this is quite simple:
Section Group.
Context {S} {op} { G : @Group S op }.
(* Reserved at top of file *)
Notation "x * y" := (op x y) : group_scope.
(* ... *)
End Group.
, , . , . , ( inverse
), , op
Group
, ( (@op _ _ _ x y)
). , , , . - ?
(25 2018 .)
, , :
Reserved Notation "x * y" (at level 40, left associativity).
Class alg_group_binop (S : Type) := alg_group_op : S → S → S.
Delimit Scope group_scope with group.
Infix "*" := alg_group_op: group_scope.
Open Scope group_scope.
Class Group {S : Type} {op : alg_group_binop S} : Type := {
id : S;
inverse : S → S;
id_left {x} : id * x = x;
id_right {x} : x * id = x;
assoc {x y z} : (x * y) * z = x * (y * z);
right_inv {x} : x * (inverse x) = id;
}.