Class mata::nft::Levels

class Levels : private std::vector<Level>

Public Functions

void append(const Levels &levels_vector)

Append levels_vector to the end of this.

Parameters:

levels_vector[in] Vector of levels to be appended.

inline size_t count(const Level level) const

Count the number of occurrences of a level in this.

Parameters:

level[in] Level to be counted.

std::vector<Level> get_levels_of(const utils::SparseSet<State> &states) const

Get levels of states in states.

std::vector<Level> get_levels_of(const StateSet &states) const

Get levels of states in states.

std::optional<Level> get_minimal_level_of(const StateSet &states, Ordering::Compare levels_ordering = Ordering::Minimal) const

Get the minimal level for the states in states.

“Minimal level” is defined as the level with the lowest numerical value, i.e., 0 < 1 < 2 < ... < num_of_levels-1. “Minimal” often relates to the current states (“What is the current state with minimal level?”)

std::optional<Level> get_minimal_next_level_of(const StateSet &states) const

Get the minimal next level for the states in states.

“Minimal next level” is defined as the minimal level in the next transition (that may follow another level), i.e., 1 < 2 < ... < num_of_levels-1 < 0. “Minimal next” relates to the next target states (“What is the next minimal level to target in a transition?”).

bool can_follow_for_states(State source, State target) const

Check whether a transition can be made from source to target.

A transition can be made if the level of target is higher than the level of source, or if the level of target is 0.

Parameters:
  • source[in] Source state.

  • target[in] Target state.

Returns:

true if the transition can be made, false otherwise.

Public Members

size_t num_of_levels = {DEFAULT_NUM_OF_LEVELS}

Number of levels (tracks) the transducer recognizes.

Each transducer transition will comprise num_of_levels of NFA transitions.

Note

The number of levels has to be at least 1.

Public Static Functions

static bool can_follow(Level source_level, Level target_level)

Check whether a transition can be made from a state with level source_level to a state with level target_level.

A transition can be made if the target level is higher than the source level, or we can always jump to a state with level 0.

Parameters:
  • source_level[in] Level of the source state.

  • target_level[in] Level of the target state.

Returns:

true if the transition can be made, false otherwise.

class Ordering

Orderings of levels.

Public Static Functions

static inline bool Minimal(const Level lhs, const Level rhs)

Ordering for Levels in NFTs where lower levels precede higher levels.

That is, levels are ordered as follows: 0 < 1 < 2 < … < num_of_levels-1.

static inline bool Next(const Level lhs, const Level rhs)

Ordering for levels in NFTs where lower levels precede higher levels, except for 0 which is the highest level.

That is, levels are ordered as follows: 1 < 2 < … < num_of_levels-1 < 0. This ordering is used when handling intermediate states (with non-zero levels) in NFTs for determining the next lowest level of the next state.