group.hpp 3.7 KB

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