|
TuringSim
C++ framework to simulate abstract computing models
|
The base class for m-configurations. More...
#include <state/mConfiguration.h>


Public Types | |
| typedef std::map< NodeType, std::shared_ptr< const MConfiguration< NodeType > > > | Unification |
| The unification type between a pattern and a m-configuration. | |
| typedef std::map< NodeType, NodeType > | AlphaRewriting |
| The type of rewriting in an alpha-equivalence, in one direction only. | |
| typedef std::pair< AlphaRewriting, AlphaRewriting > | AlphaRelation |
| The type of bi-directional alpha-equivalence. | |
| typedef StateType_ | StateType |
| The type of states matched. | |
| typedef MatcherType_ | MatcherType |
| The type returned when a state matches the pattern. | |
Public Types inherited from TuringSim::State::StatePattern< std::shared_ptr< const MConfiguration< NodeType > >, std::map< NodeType, std::shared_ptr< const MConfiguration< NodeType > > > > | |
| typedef std::shared_ptr< const MConfiguration< NodeType > > | StateType |
| The type of states matched. | |
| typedef std::map< NodeType, std::shared_ptr< const MConfiguration< NodeType > > > | MatcherType |
| The type returned when a state matches the pattern. | |
Public Member Functions | |
| constexpr | MConfiguration (const NodeType &leaf) |
| Create a constant leaf. More... | |
| constexpr | MConfiguration (const NodeType &leaf, bool isVar) |
| Create a leaf. More... | |
| constexpr | MConfiguration (const NodeType &node, const std::vector< MConfiguration< NodeType >> &subTrees) |
| Create an interior node. More... | |
| constexpr | MConfiguration (const NodeType &node, std::vector< MConfiguration< NodeType >> &&subTrees) |
| Create an interior node and consume the subTrees. More... | |
| constexpr | MConfiguration (const NodeType &node, const std::vector< std::shared_ptr< const MConfiguration< NodeType >>> &subTrees) |
| Create an interior node. More... | |
| constexpr | MConfiguration (const NodeType &node, std::vector< std::shared_ptr< const MConfiguration< NodeType >>> &&subTrees) |
| Create an interior node. More... | |
| constexpr | MConfiguration (const MConfiguration< NodeType > &other) |
| Copy constructor. More... | |
| constexpr | MConfiguration (MConfiguration< NodeType > &&) |
| Move constructor. More... | |
| constexpr MConfiguration & | operator= (const MConfiguration< NodeType > &) |
| Copy assignment operator. More... | |
| constexpr MConfiguration & | operator= (MConfiguration< NodeType > &&) |
| Move assignment operator. More... | |
| virtual | ~MConfiguration () override=default |
| Destructor. More... | |
| constexpr std::shared_ptr< const MConfiguration< NodeType > > | getArg (size_t) const |
| Returns a child. More... | |
| constexpr const NodeType & | getNode () const |
| Returns the content of the node. More... | |
| constexpr size_t | getArity () const |
| Returns the arity of the node. More... | |
| constexpr bool | isLeaf () const |
| Returns whether the node is a leaf. More... | |
| constexpr bool | isVariable () const |
| Returns whether the node is a variable. More... | |
| constexpr bool | isPattern () const |
| Returns whether the MConfiguration is a pattern. More... | |
| constexpr bool | isMFunction () const |
| Returns whether the MConfiguration is a m-function (ie. not a pattern). More... | |
| constexpr Unification | unifyWithMConf (const std::shared_ptr< const MConfiguration< NodeType >> &state) const |
| Unify the MConfiguration with another. More... | |
| Unification | unify (const std::shared_ptr< const MConfiguration< NodeType >> &state) const |
| Unify the MConfiguration with another. More... | |
| std::optional< Unification > | unifyWithMConf_opt (const std::shared_ptr< const MConfiguration< NodeType >> &state) const noexcept |
| Unify the MConfiguration with another. More... | |
| std::optional< MatcherType > | match (const StateType &state) const noexcept override final |
| Unify the MConfiguration with another. More... | |
| std::optional< Unification > | unify_opt (const std::shared_ptr< const MConfiguration< NodeType >> &state) const |
| Unify the MConfiguration with another. More... | |
| template<typename CharT = char, typename Traits = std::char_traits<CharT>, typename Alloc = std::allocator<CharT>> | |
| std::basic_string< CharT, Traits, Alloc > | toString () const |
| Convert the MConfiguration in a string. More... | |
| constexpr int | compare (const MConfiguration< NodeType > &other) const |
| Compare two MConfiguration. OCaml style, waiting for <=>. Strong ordering. More... | |
| constexpr bool | operator!= (const MConfiguration< NodeType > &other) const |
| Test whether two MConfiguration are different. More... | |
| constexpr bool | operator== (const MConfiguration< NodeType > &other) const |
| Test whether two MConfiguration are the same. More... | |
| bool | operator< (const MConfiguration< NodeType > &other) const |
| Compare two MConfiguration. More... | |
| std::optional< AlphaRelation > | isAlphaEquivalent (const std::shared_ptr< const MConfiguration< NodeType >> &other) const |
| Test whether two MConfiguration are alpha-equivalent. More... | |
| void | isAlphaEquivalent (const std::shared_ptr< const MConfiguration< NodeType >> &other, AlphaRewriting &direct, AlphaRewriting &back) const |
| Test whether two MConfiguration are alpha-equivalent. More... | |
| template<typename CharT = char, typename Traits = std::char_traits<CharT>> | |
| std::function< std::basic_ostream< CharT, Traits > &(std::basic_ostream< CharT, Traits > &)> | debug () const |
Return a debug printer for *this. More... | |
Public Member Functions inherited from TuringSim::State::StatePattern< std::shared_ptr< const MConfiguration< NodeType > >, std::map< NodeType, std::shared_ptr< const MConfiguration< NodeType > > > > | |
| constexpr | StatePattern ()=default |
| Default constructor. | |
| constexpr | StatePattern (const StatePattern &other)=default |
| Copy a state pattern. More... | |
| constexpr | StatePattern (StatePattern &&other)=default |
| Move a state pattern. More... | |
| constexpr StatePattern & | operator= (const StatePattern &other)=default |
| Copy a state pattern. More... | |
| constexpr StatePattern & | operator= (StatePattern &&other)=default |
| Move a state pattern. More... | |
| virtual | ~StatePattern ()=default |
| Destructor. | |
| virtual std::optional< MatcherType > | match (const StateType &state) const noexcept=0 |
| Test if a state matches. More... | |
Static Public Member Functions | |
| static std::shared_ptr< const MConfiguration< NodeType > > | applySubstitution (std::shared_ptr< const MConfiguration< NodeType >> pattern, const Unification &subs) |
| Apply a substitution to the tree. More... | |
| static std::shared_ptr< const MConfiguration< NodeType > > | applySubstitution (std::shared_ptr< const MConfiguration< NodeType >> pattern, const Unification &subs, const std::shared_ptr< const MConfiguration< NodeType >> &def) |
| Apply a substitution to the tree. More... | |
| static void | unify_state (const std::shared_ptr< const MConfiguration< NodeType >> &state, const MConfiguration< NodeType > &pattern, std::map< NodeType, std::shared_ptr< const MConfiguration< NodeType >>> &unification) |
| unify a state with a pattern, while filling a unification. More... | |
| static std::map< NodeType, std::shared_ptr< const MConfiguration< NodeType > > > | unify_state (const std::shared_ptr< const MConfiguration< NodeType >> &state, const MConfiguration< NodeType > &pattern) |
| unify a state with a pattern. More... | |
| template<typename CharT = char, typename Traits = std::char_traits<CharT>> | |
| static std::function< std::basic_ostream< CharT, Traits > &(std::basic_ostream< CharT, Traits > &)> | debug (const Unification &unification) |
Return a debug printer for unification. More... | |
| template<typename CharT = char, typename Traits = std::char_traits<CharT>> | |
| static std::function< std::basic_ostream< CharT, Traits > &(std::basic_ostream< CharT, Traits > &)> | debug (const AlphaRewriting &rewriting) |
Return a debug printer for rewriting. More... | |
| template<typename CharT = char, typename Traits = std::char_traits<CharT>> | |
| static std::function< std::basic_ostream< CharT, Traits > &(std::basic_ostream< CharT, Traits > &)> | debug (const AlphaRelation &relation) |
Return a debug printer for relation. More... | |
Protected Attributes | |
| NodeType | node |
| The content of the node. | |
| bool | isVar |
| Whether the node is a variable. More... | |
| std::vector< std::shared_ptr< const MConfiguration< NodeType > > > | args |
| The ordered list of children. | |
| bool | is_pattern |
| Whether the MConfiguration is a pattern. | |
Friends | |
| template<typename U , typename CharT , typename Traits > | |
| constexpr friend std::basic_ostream< CharT, Traits > & | operator<< (std::basic_ostream< CharT, Traits > &os, const MConfiguration< U > &m_conf) |
| Print a MConfiguration. More... | |
The base class for m-configurations.
| NodeType | The type of the leaves |
A m-configuration is a tree with ordered nodes of type T. Such a tree can encode a state or a pattern where some leaves are variables.
Definition at line 21 of file mConfiguration.h.
|
constexpr |
Create a constant leaf.
| [in] | leaf | The content of the leaf. |
Complexity \(\mathcal{O}(1)\)
Definition at line 521 of file mConfiguration.h.
|
constexpr |
Create a leaf.
| [in] | leaf | The content of the leaf. |
| [in] | isVar | If true, the leaf is a variable. Otherwise, it is a constant. |
Complexity \(\mathcal{O}(1)\)
Definition at line 530 of file mConfiguration.h.
|
constexpr |
Create an interior node.
| [in] | node | The content of the node. |
| [in] | subTrees | The children of the node. |
Complexity \(\mathcal{O}(|\texttt{a}|)\)
Definition at line 539 of file mConfiguration.h.
|
constexpr |
Create an interior node and consume the subTrees.
| [in] | node | The content of the node. |
| [in] | subTrees | The children of the node. |
Complexity \(\mathcal{O}(|\texttt{a}|)\)
Definition at line 552 of file mConfiguration.h.
|
constexpr |
Create an interior node.
| [in] | node | The content of the node. |
| [in] | subTrees | The children of the node. |
Complexity \(\mathcal{O}(|\texttt{a}|)\)
Definition at line 565 of file mConfiguration.h.
|
constexpr |
Create an interior node.
| [in] | node | The content of the node. |
| [in] | subTrees | The children of the node. |
Complexity \(\mathcal{O}(|\texttt{a}|)\)
Definition at line 574 of file mConfiguration.h.
|
constexpr |
Copy constructor.
| [in] | other | MConfiguration to copy. Complexity \(\mathcal{O}(|\texttt{other}|)\) |
Definition at line 583 of file mConfiguration.h.
|
constexpr |
Move constructor.
| [in,out] | other | MConfiguration to move. |
Complexity \(\mathcal{O}(|\texttt{other}|)\)
Definition at line 592 of file mConfiguration.h.
|
overridevirtualdefault |
Destructor.
Complexity \(\mathcal{O}(|\texttt{*this}|)\)
|
static |
Apply a substitution to the tree.
| [in] | pattern | The m-configuration in which to apply the substitution. |
| [in] | subs | The substitution to apply. The substitution is a map from node content to MConfiguration. |
Replace all variable leaf by the corresponding MConfiguration.
Complexity \(\mathcal{O}(|\texttt{*this}|)\)
Definition at line 660 of file mConfiguration.h.

|
static |
Apply a substitution to the tree.
| [in] | pattern | The m-configuration in which to apply the substitution. |
| [in] | subs | The substitution to apply. The substitution is a map from node content to MConfiguration. |
| [in] | def | The default tree for all variable without substitution. |
Replace all variable leaf by the corresponding MConfiguration.
Complexity \(\mathcal{O}(|\texttt{*this}|)\)
Definition at line 683 of file mConfiguration.h.
|
constexpr |
Compare two MConfiguration. OCaml style, waiting for <=>. Strong ordering.
| [in] | other | the other configuration to compare. |
*this < other, positive if *this > other, and zero if *this == other.Complexity \(\mathcal{O}(\min\{|\texttt{*this}|, |\texttt{other}|\})\)
Definition at line 842 of file mConfiguration.h.


| std::function< std::basic_ostream< CharT, Traits > &(std::basic_ostream< CharT, Traits > &)> TuringSim::State::MConfiguration::MConfiguration< NodeType >::debug |
Return a debug printer for *this.
| CharT | char type. |
| Traits | std::basic_ostream trait. |
Definition at line 953 of file mConfiguration.h.

|
static |
Return a debug printer for relation.
| CharT | char type. |
| Traits | std::basic_ostream trait. |
| [in] | relation | the relation to print. |
Definition at line 982 of file mConfiguration.h.

|
static |
Return a debug printer for rewriting.
| CharT | char type. |
| Traits | std::basic_ostream trait. |
| [in] | rewriting | the rewriting to print. |
Definition at line 976 of file mConfiguration.h.

|
static |
Return a debug printer for unification.
| CharT | char type. |
| Traits | std::basic_ostream trait. |
| [in] | unification | the unification to print. |
Definition at line 970 of file mConfiguration.h.

|
constexpr |
Returns a child.
| [in] | i | The number of the child to get. |
Throws std::out_of_bounds exception is i is too large.
Complexity \(\mathcal{O}(1)\)
Definition at line 625 of file mConfiguration.h.
|
constexpr |
Returns the arity of the node.
Complexity \(\mathcal{O}(1)\)
Definition at line 635 of file mConfiguration.h.

|
constexpr |
Returns the content of the node.
Complexity \(\mathcal{O}(1)\)
Definition at line 630 of file mConfiguration.h.

| std::optional< typename MConfiguration< NodeType >::AlphaRelation > TuringSim::State::MConfiguration::MConfiguration< NodeType >::isAlphaEquivalent | ( | const std::shared_ptr< const MConfiguration< NodeType >> & | other | ) | const |
Test whether two MConfiguration are alpha-equivalent.
| [in] | other | the other configuration to test equivalence with. |
Complexity \(\mathcal{O}(\min\{|\texttt{*this}|, |\texttt{other}|\})\)
Definition at line 897 of file mConfiguration.h.
| void TuringSim::State::MConfiguration::MConfiguration< NodeType >::isAlphaEquivalent | ( | const std::shared_ptr< const MConfiguration< NodeType >> & | other, |
| AlphaRewriting & | direct, | ||
| AlphaRewriting & | back | ||
| ) | const |
Test whether two MConfiguration are alpha-equivalent.
| [in] | other | the other configuration to test equivalence with. |
| [in,out] | direct | the current direct rewriting. |
| [in,out] | back | the current back rewriting. |
| NoAlphaEquivalenceException | if states are not alpha-equivalent. |
Complexity \(\mathcal{O}(\min\{|\texttt{*this}|, |\texttt{other}|\})\)
Definition at line 909 of file mConfiguration.h.
|
constexpr |
Returns whether the node is a leaf.
Complexity \(\mathcal{O}(1)\)
Definition at line 640 of file mConfiguration.h.
|
constexpr |
Returns whether the MConfiguration is a m-function (ie. not a pattern).
Complexity \(\mathcal{O}(|\texttt{*this}|)\)
Definition at line 655 of file mConfiguration.h.
|
constexpr |
Returns whether the MConfiguration is a pattern.
Inspects recursively.
Complexity \(\mathcal{O}(|\texttt{*this}|)\)
Definition at line 650 of file mConfiguration.h.
|
constexpr |
Returns whether the node is a variable.
Does not inspect recursively.
Complexity \(\mathcal{O}(1)\)
Definition at line 645 of file mConfiguration.h.

|
finaloverridenoexcept |
Unify the MConfiguration with another.
| [in] | state | The other MConfiguration, which have to be a m-function. |
*this have to be a pattern, UB otherwise.
Same as MConfiguration::unifyWithMConf_opt
Definition at line 811 of file mConfiguration.h.
|
constexpr |
Test whether two MConfiguration are different.
| [in] | other | the other configuration to compare. |
Complexity \(\mathcal{O}(\min\{|\texttt{*this}|, |\texttt{other}|\})\)
Definition at line 882 of file mConfiguration.h.
| bool TuringSim::State::MConfiguration::MConfiguration< NodeType >::operator< | ( | const MConfiguration< NodeType > & | other | ) | const |
Compare two MConfiguration.
| [in] | other | the other configuration to compare. |
Complexity \(\mathcal{O}(\min\{|\texttt{*this}|, |\texttt{other}|\})\)
Definition at line 892 of file mConfiguration.h.
|
constexpr |
Copy assignment operator.
| [in] | other | MConfiguration to copy. |
*thisComplexity \(\mathcal{O}(|\texttt{other}|)\)
Definition at line 601 of file mConfiguration.h.
|
constexpr |
Move assignment operator.
| [in,out] | other | MConfiguration to move. |
*thisComplexity \(\mathcal{O}(|\texttt{other}|)\)
Definition at line 613 of file mConfiguration.h.
|
constexpr |
Test whether two MConfiguration are the same.
| [in] | other | the other configuration to compare. |
Complexity \(\mathcal{O}(\min\{|\texttt{*this}|, |\texttt{other}|\})\)
Definition at line 887 of file mConfiguration.h.
| std::basic_string< CharT, Traits, Alloc > TuringSim::State::MConfiguration::MConfiguration< NodeType >::toString |
Convert the MConfiguration in a string.
| CharT | char type. |
| Traits | the std::basic_ostream trait. |
| Alloc | the allocator. |
*this, for debug purpose.The type T have to be convertible to std::string.
Complexity \(\mathcal{O}(|\texttt{*this}|)\)
Definition at line 835 of file mConfiguration.h.
| MConfiguration< NodeType >::Unification TuringSim::State::MConfiguration::MConfiguration< NodeType >::unify | ( | const std::shared_ptr< const MConfiguration< NodeType >> & | state | ) | const |
Unify the MConfiguration with another.
| [in] | state | The other MConfiguration. |
| NoUnificationException | if unification fails. |
It must be one pattern and one m-function in *this and other. This function simply call unifyWithMConf or unifyWithPattern.
Complexity \(\mathcal{O}(\max\{|\texttt{*this}|, |\texttt{other}|\})\)
Definition at line 783 of file mConfiguration.h.
| std::optional< typename MConfiguration< NodeType >::Unification > TuringSim::State::MConfiguration::MConfiguration< NodeType >::unify_opt | ( | const std::shared_ptr< const MConfiguration< NodeType >> & | state | ) | const |
Unify the MConfiguration with another.
| [in] | state | The other MConfiguration. |
| NoUnificationException | if state is not a m-function or *this is not a pattern. |
It must be one pattern and one m-function in *this and other. This function simply call unifyWithMConf or unifyWithPattern.
Complexity \(\mathcal{O}(\max\{|\texttt{*this}|, |\texttt{other}|\})\)
Apart from exceptions, same as MConfiguration::unifyWithMConf_opt
Definition at line 816 of file mConfiguration.h.
|
static |
unify a state with a pattern.
| [in] | state | a shared pointer to the state to unify. |
| [in] | pattern | the pattern against which to unify the state. |
| NoUnificationException | if unification fails. |
Definition at line 758 of file mConfiguration.h.

|
static |
unify a state with a pattern, while filling a unification.
| [in] | state | a shared pointer to the state to unify. |
| [in] | pattern | the pattern against which to unify the state. |
| [in,out] | unification | the unification incrementally filled. |
| NoUnificationException | if unification fails. |
Definition at line 706 of file mConfiguration.h.
|
constexpr |
Unify the MConfiguration with another.
| [in] | state | The other MConfiguration, which have to be a m-function. |
| NoUnificationException | if unification fails. |
*this have to be a pattern.
Complexity \(\mathcal{O}(\max\{|\texttt{*this}|, |\texttt{m_conf}|\})\)
Definition at line 778 of file mConfiguration.h.
|
noexcept |
Unify the MConfiguration with another.
| [in] | state | The other MConfiguration, which have to be a m-function. |
*this have to be a pattern, UB otherwise.
Complexity \(\mathcal{O}(\max\{|\texttt{*this}|, |\texttt{m_conf}|\})\)
Definition at line 801 of file mConfiguration.h.
|
friend |
Print a MConfiguration.
| U | the type of nodes of the MConfigurations |
| CharT | char type |
| Traits | std::basic_ostream trait. |
| [in,out] | os | the output stream |
| [in] | m_conf | the MConfiguration to print. |
os.Type U have to have operator<<(std::basic_ostream<CharT, Traits>&, const U&) implemented.
Definition at line 361 of file mConfiguration.h.
|
protected |
Whether the node is a variable.
Must be false if the node is not a leaf.
Definition at line 391 of file mConfiguration.h.