libsemigroups  v3.0.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches

Defined in rewriters.hpp.

This class implements a data structure for storing rewriting rules. Here, a rewriting rule is a rule of the form \(A \to B\), where \(A\) and \(B\) are both words over some alphabet \(\Sigma\).

The left-hand and right-hand sides of a rule are specified externally with the type external_string_type, and stored internally with type internal_string_type.

Public Member Functions

 Rule (int64_t id)
 Construct with new empty left-hand and right-hand sides.
 
 Rule (Rule &&copy)=delete
 
 Rule (Rule const &copy)=delete
 
void activate () noexcept
 Activate a rule.
 
bool active () const noexcept
 Check if the Rule is active.
 
void deactivate () noexcept
 Deactivate a rule.
 
bool empty () const noexcept
 Check if the left-hand and right-hand sides are empty.
 
int64_t id () const noexcept
 Return the id of a rule.
 
internal_string_typelhs () const noexcept
 Return the left-hand side of the rule.
 
Ruleoperator= (Rule &&copy)=delete
 
Ruleoperator= (Rule const &copy)=delete
 
void reorder ()
 Reorder the left-hand and right-hand sides.
 
internal_string_typerhs () const noexcept
 Return the right-hand side of the rule.
 
void set_id (int64_t id)
 Set the id of a rule.
 
void set_id_no_checks (int64_t id) noexcept
 Set the id of a rule.
 

Constructor & Destructor Documentation

◆ Rule()

Rule ( int64_t id)
explicit

Construct with new empty left-hand and right-hand sides.

Parameters
idthe id of the new rule.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

Member Function Documentation

◆ activate()

void activate ( )
noexcept

Activate a rule, if it is inactive.

Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.
See also
active

◆ active()

bool active ( ) const
inlinenodiscardnoexcept

Check if the rule is active.

Returns
A value of type bool.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ deactivate()

void deactivate ( )
noexcept

Deactivate a rule, if it is active.

Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.
See also
active

◆ empty()

bool empty ( ) const
inlinenodiscardnoexcept

Check if the words pointed to by both the left-hand and the right-hand sides are empty.

Returns
A value of type bool.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ id()

int64_t id ( ) const
inlinenodiscardnoexcept

Return the id of a rule.

Returns
A value of type int64_t
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ lhs()

internal_string_type * lhs ( ) const
inlinenodiscardnoexcept

Return the left-hand side of the rule. If this rule was create by a KnuthBendix, this is guaranteed to be greater than its right-hand side according to the reduction ordering of that KnuthBendix.

Returns
A pointer to the left-hand side.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.
See also
KnuthBendix

◆ reorder()

void reorder ( )
inline

If the right-hand side is greater than the left-hand side of a rule, with regards to length-lexicographical order, then swap them.

Exceptions
Throws if shortlex_compare(T* const, T* const) does.
Complexity
The same complexity as shortlex_compare(T* const, T* const)
See also
shortlex_compare(T* const, T* const)

◆ rhs()

internal_string_type * rhs ( ) const
inlinenodiscardnoexcept

Return the right-hand side of the rule. If this rule was create by a KnuthBendix, this is guaranteed to be less than its left-hand side according to the reduction ordering of that KnuthBendix.

Returns
A pointer to the right-hand side.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.
See also
KnuthBendix

◆ set_id()

void set_id ( int64_t id)
inline

After checking that the Rule is inactive id is positive, this function performs the same as set_id_no_checks.

Exceptions
LIBSEMIGROUPS_EXCEPTIONif id is non-positive, or if this is active.

◆ set_id_no_checks()

void set_id_no_checks ( int64_t id)
inlinenoexcept

Set the id of a rule.

Parameters
idthe id to set.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.
Note
This function does no checks on its parameters; however, the id of a rule should only be set if the rule is inactive, and the id of a rule should always be positive.

The documentation for this class was generated from the following file: