3.2.13.1. rule/Composer.hpp

3.2.13.1.1. Class rule::Composer

class rule::Composer

This class can evaluate rule composition expressions. During evaluation an expression graph is recorded.

The expression graph is a directed hypergraph \((V, E)\), with each vertex representing a rule. Each edge represent all compositions calculated for a unique input. That is every edge \(e\in E\) is on the form \(((u, v), R_e)\) with \((u, v)\in V\times V\) as an ordered pair of rules and \(R_e\subseteq V\) is the set of all resulting rules found.

The graph is visualized as a bipartite graph with point-shaped vertices representing the hyperedges. The in-edges to these hyperedge vertices are labelled with 1 and 2.

3.2.13.1.1.1. Synopsis

const std::unordered_set<std::shared_ptr<Rule>> &getRuleDatabase() const
const std::unordered_set<std::shared_ptr<Rule>> &getProducts() const
std::vector<std::shared_ptr<Rule>> eval(const RCExp::Expression &exp, bool onlyUnique, int verbosity)
void print() const
static std::shared_ptr<Composer> create(const std::unordered_set<std::shared_ptr<Rule>> &database, LabelSettings labelSettings)

3.2.13.1.1.2. Details

const std::unordered_set<std::shared_ptr<Rule>> &getRuleDatabase() const
Returns:

the set of unique rules known by the evaluator.

const std::unordered_set<std::shared_ptr<Rule>> &getProducts() const
Returns:

the set of unique rules this evaluator has constructed.

std::vector<std::shared_ptr<Rule>> eval(const RCExp::Expression &exp, bool onlyUnique, int verbosity)

Evaluates a rule composition expression. Any created rule is replaced by a rule in the database if they are isomorphic.

The onlyUnique parameter controls whether each composition (sub-)result may contain duplicates or not. Unless you need to count possibilities, prefer passing true to avoid accidental combinatorial explosion.

The verbosity has the following meaning:

  • 0 (or less): no information is printed.

  • 10: print information about morphism generation for rule composition.

  • 20: print rule composition information.

Returns:

the result of the expression.

void print() const

Print the graph representing all expressions evaluated so far.

static std::shared_ptr<Composer> create(const std::unordered_set<std::shared_ptr<Rule>> &database, LabelSettings labelSettings)
Returns:

a new instance of an evaluator with its database initialised with the given rules.

Note

The caller is responsible for ensuring the given rules are unique.