proconlib

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub anqooqie/proconlib

:heavy_check_mark: Concept for ring (tools/ring.hpp)

template <typename R>
concept ring = tools::semiring<R> && tools::commutative_group<typename R::add>;

It is a concept that represents a ring. Note that semantic constraints must be guaranteed by the user.

Semantically, you can define that the results of R::add::op, R::add::inv and R::mul::op are undefined depending on the arguments. For example, you can define that integer addition is not defined for overflowing pairs.

Constraints

Time Complexity

License

Author

Depends on

Required by

Verified with

Code

#ifndef TOOLS_RING_HPP
#define TOOLS_RING_HPP

#include "tools/commutative_group.hpp"
#include "tools/semiring.hpp"

namespace tools {
  template <typename R>
  concept ring = tools::semiring<R> && tools::commutative_group<typename R::add>;
}

#endif
#line 1 "tools/ring.hpp"



#line 1 "tools/commutative_group.hpp"



#line 1 "tools/commutative_monoid.hpp"



#line 1 "tools/monoid.hpp"



#include <concepts>

namespace tools {
  template <typename M>
  concept monoid = requires(typename M::T x, typename M::T y) {
    { M::op(x, y) } -> std::same_as<typename M::T>;
    { M::e() } -> std::same_as<typename M::T>;
  };
}


#line 5 "tools/commutative_monoid.hpp"

namespace tools {
  template <typename M>
  concept commutative_monoid = tools::monoid<M>;
}


#line 1 "tools/group.hpp"



#line 6 "tools/group.hpp"

namespace tools {
  template <typename G>
  concept group = tools::monoid<G> && requires(typename G::T x) {
    { G::inv(x) } -> std::same_as<typename G::T>;
  };
}


#line 6 "tools/commutative_group.hpp"

namespace tools {
  template <typename G>
  concept commutative_group = tools::group<G> && tools::commutative_monoid<G>;
}


#line 1 "tools/semiring.hpp"



#line 6 "tools/semiring.hpp"

namespace tools {
  template <typename R>
  concept semiring = tools::commutative_monoid<typename R::add> && tools::monoid<typename R::mul> && std::same_as<typename R::add::T, typename R::mul::T>;
}


#line 6 "tools/ring.hpp"

namespace tools {
  template <typename R>
  concept ring = tools::semiring<R> && tools::commutative_group<typename R::add>;
}


Back to top page