| 1 | /*! |
| 2 | @file |
| 3 | Forward declares `boost::hana::Group`. |
| 4 | |
| 5 | Copyright Louis Dionne 2013-2022 |
| 6 | Distributed under the Boost Software License, Version 1.0. |
| 7 | (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) |
| 8 | */ |
| 9 | |
| 10 | #ifndef BOOST_HANA_FWD_CONCEPT_GROUP_HPP |
| 11 | #define BOOST_HANA_FWD_CONCEPT_GROUP_HPP |
| 12 | |
| 13 | #include <boost/hana/config.hpp> |
| 14 | |
| 15 | |
| 16 | namespace boost { namespace hana { |
| 17 | //! @ingroup group-concepts |
| 18 | //! @defgroup group-Group Group |
| 19 | //! The `Group` concept represents `Monoid`s where all objects have |
| 20 | //! an inverse w.r.t. the `Monoid`'s binary operation. |
| 21 | //! |
| 22 | //! A [Group][1] is an algebraic structure built on top of a `Monoid` |
| 23 | //! which adds the ability to invert the action of the `Monoid`'s binary |
| 24 | //! operation on any element of the set. Specifically, a `Group` is a |
| 25 | //! `Monoid` `(S, +)` such that every element `s` in `S` has an inverse |
| 26 | //! (say `s'`) which is such that |
| 27 | //! @code |
| 28 | //! s + s' == s' + s == identity of the Monoid |
| 29 | //! @endcode |
| 30 | //! |
| 31 | //! There are many examples of `Group`s, one of which would be the |
| 32 | //! additive `Monoid` on integers, where the inverse of any integer |
| 33 | //! `n` is the integer `-n`. The method names used here refer to |
| 34 | //! exactly this model. |
| 35 | //! |
| 36 | //! |
| 37 | //! Minimal complete definitions |
| 38 | //! ---------------------------- |
| 39 | //! 1. `minus`\n |
| 40 | //! When `minus` is specified, the `negate` method is defaulted by setting |
| 41 | //! @code |
| 42 | //! negate(x) = minus(zero<G>(), x) |
| 43 | //! @endcode |
| 44 | //! |
| 45 | //! 2. `negate`\n |
| 46 | //! When `negate` is specified, the `minus` method is defaulted by setting |
| 47 | //! @code |
| 48 | //! minus(x, y) = plus(x, negate(y)) |
| 49 | //! @endcode |
| 50 | //! |
| 51 | //! |
| 52 | //! Laws |
| 53 | //! ---- |
| 54 | //! For all objects `x` of a `Group` `G`, the following laws must be |
| 55 | //! satisfied: |
| 56 | //! @code |
| 57 | //! plus(x, negate(x)) == zero<G>() // right inverse |
| 58 | //! plus(negate(x), x) == zero<G>() // left inverse |
| 59 | //! @endcode |
| 60 | //! |
| 61 | //! |
| 62 | //! Refined concept |
| 63 | //! --------------- |
| 64 | //! `Monoid` |
| 65 | //! |
| 66 | //! |
| 67 | //! Concrete models |
| 68 | //! --------------- |
| 69 | //! `hana::integral_constant` |
| 70 | //! |
| 71 | //! |
| 72 | //! Free model for non-boolean arithmetic data types |
| 73 | //! ------------------------------------------------ |
| 74 | //! A data type `T` is arithmetic if `std::is_arithmetic<T>::%value` is |
| 75 | //! true. For a non-boolean arithmetic data type `T`, a model of `Group` |
| 76 | //! is automatically defined by setting |
| 77 | //! @code |
| 78 | //! minus(x, y) = (x - y) |
| 79 | //! negate(x) = -x |
| 80 | //! @endcode |
| 81 | //! |
| 82 | //! @note |
| 83 | //! The rationale for not providing a Group model for `bool` is the same |
| 84 | //! as for not providing a `Monoid` model. |
| 85 | //! |
| 86 | //! |
| 87 | //! Structure-preserving functions |
| 88 | //! ------------------------------ |
| 89 | //! Let `A` and `B` be two `Group`s. A function `f : A -> B` is said to |
| 90 | //! be a [Group morphism][2] if it preserves the group structure between |
| 91 | //! `A` and `B`. Rigorously, for all objects `x, y` of data type `A`, |
| 92 | //! @code |
| 93 | //! f(plus(x, y)) == plus(f(x), f(y)) |
| 94 | //! @endcode |
| 95 | //! Because of the `Group` structure, it is easy to prove that the |
| 96 | //! following will then also be satisfied: |
| 97 | //! @code |
| 98 | //! f(negate(x)) == negate(f(x)) |
| 99 | //! f(zero<A>()) == zero<B>() |
| 100 | //! @endcode |
| 101 | //! Functions with these properties interact nicely with `Group`s, which |
| 102 | //! is why they are given such a special treatment. |
| 103 | //! |
| 104 | //! |
| 105 | //! [1]: http://en.wikipedia.org/wiki/Group_(mathematics) |
| 106 | //! [2]: http://en.wikipedia.org/wiki/Group_homomorphism |
| 107 | template <typename G> |
| 108 | struct Group; |
| 109 | }} // end namespace boost::hana |
| 110 | |
| 111 | #endif // !BOOST_HANA_FWD_CONCEPT_GROUP_HPP |
| 112 | |