i try formalize groups in coq. want general possible. try something, i'm not happy it. found different implementations , don't know 1 choose.
for example found :
https://people.cs.umass.edu/~arjun/courses/cs691pl-spring2014/assignments/groups.html
(* set of group. *) parameter g : set. (* binary operator. *) parameter f : g -> g -> g. (* group identity. *) parameter e : g. (* inverse operator. *) parameter : g -> g. (* readability, use infix <+> stand binary operator. *) infix "<+>" := f (at level 50, left associativity). (* operator [f] associative. *) axiom assoc : forall b c, <+> b <+> c = <+> (b <+> c). (* [e] right-identity elements [a] *) axiom id_r : forall a, <+> e = a. (* [i a] right-inverse of [a]. *) axiom inv_r : forall a, <+> = e.
but why author use axioms , not definitions ? moreover, don't have parameters @ top level.
on book coqart, found implementation :
record group : type := {a : type; op : a→a→a; sym : a→a; e : a; e_neutral_left : ∀ x:a, op e x = x; sym_op : ∀ x:a, op (sym x) x = e; op_assoc : ∀ x y z:a, op (op x y) z = op x (op y z)}.
on definition think definition specialize, because if want define monoïds, redefine op_assoc or neutre left. beyond that, theorems, don't need use groups. example if want proove right_inverse same left_inverse if law associative.
an other question axioms groups :
- use neutral element axiom or left neutral element
- use inverse element axiom or left inverse
what more convenient work ?
finally, if want proove other theorems, want have syntactic sugar in order use binary operation , inverse elements. advices have convenient notation groups ?
for moment did :
definition binary_operation {s:set} := s -> s -> s. definition commutative {s:set} (dot:binary_operation) := forall (a b:s), dot b = dot b a. definition associative {s:set} (dot:binary_operation) := forall (a b c:s), dot (dot b) c = dot (dot b c). definition left_identity {s:set} (dot:binary_operation) (e:s) := forall a:s, (dot e a) = a. definition right_identity {s:set} (dot:binary_operation) (e:s) := forall a:s, (dot e) = a. definition identity {s:set} (dot: binary_operation) (e:s) := left_identity dot e /\ right_identity dot e. definition left_inv {s:set} (dot:binary_operation) (a' e:s) := identity dot e -> dot a' = e. definition right_inv {s:set} (dot:binary_operation) (a' e:s) := identity dot e -> dot a' = e. definition inv {s:set} (dot:binary_operation) (a' e:s) := left_inv dot a' e /\ right_inv dot a' e.
i found implementation in code source of coq don't understand why implementation : https://github.com/tmiya/coq/blob/master/group/group2.v
i can't provide complete answer, perhaps can bit.
your first article provides definitions , axioms sufficient proving exercises without paying attention being 'good' or 'useful' implementation. that's why axioms , not definitions.
if want 'to general possible', can use example coqart, or wrap group definition in section, using variable
instead of parameter
.
section group. (* set of group. *) variable g : set. (* binary operator. *) variable f : g -> g -> g. (* group identity. *) variable e : g. (* inverse operator. *) variable : g -> g. (* readability, use infix <+> stand binary operator. *) infix "<+>" := f (at level 50, left associativity). (* operator [f] associative. *) variable assoc : forall b c, <+> b <+> c = <+> (b <+> c). (* [e] right-identity elements [a] *) variable id_r : forall a, <+> e = a. (* [i a] right-inverse of [a]. *) variable inv_r : forall a, <+> = e.
if prove theorems inside section, this:
theorem trivial : forall b, <+> e <+> b = <+> b. intros. rewrite id_r. auto. qed.
after section ends,
end group.
coq generalizes them
check trivial.
trivial : forall (g : set) (f : g -> g -> g) (e : g), (forall : g, f e = a) -> forall b : g, f (f e) b = f b
as last example, it's not actual definition of group, instead proving set, binary operation , 4 axioms operation define group.