TuringSim
C++ framework to simulate abstract computing models
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
TuringSim::State::MConfiguration::MConfiguration< NodeType > Class Template Reference

The base class for m-configurations. More...

#include <state/mConfiguration.h>

Inheritance diagram for TuringSim::State::MConfiguration::MConfiguration< NodeType >:
Inheritance graph
[legend]
Collaboration diagram for TuringSim::State::MConfiguration::MConfiguration< NodeType >:
Collaboration graph
[legend]

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, AlphaRewritingAlphaRelation
 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 MConfigurationoperator= (const MConfiguration< NodeType > &)
 Copy assignment operator. More...
 
constexpr MConfigurationoperator= (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< UnificationunifyWithMConf_opt (const std::shared_ptr< const MConfiguration< NodeType >> &state) const noexcept
 Unify the MConfiguration with another. More...
 
std::optional< MatcherTypematch (const StateType &state) const noexcept override final
 Unify the MConfiguration with another. More...
 
std::optional< Unificationunify_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< AlphaRelationisAlphaEquivalent (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 StatePatternoperator= (const StatePattern &other)=default
 Copy a state pattern. More...
 
constexpr StatePatternoperator= (StatePattern &&other)=default
 Move a state pattern. More...
 
virtual ~StatePattern ()=default
 Destructor.
 
virtual std::optional< MatcherTypematch (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...
 

Detailed Description

template<typename NodeType>
class TuringSim::State::MConfiguration::MConfiguration< NodeType >

The base class for m-configurations.

Template Parameters
NodeTypeThe 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.

Constructor & Destructor Documentation

◆ MConfiguration() [1/8]

template<typename NodeType >
constexpr TuringSim::State::MConfiguration::MConfiguration< NodeType >::MConfiguration ( const NodeType &  leaf)
constexpr

Create a constant leaf.

Parameters
[in]leafThe content of the leaf.

Complexity \(\mathcal{O}(1)\)

Definition at line 521 of file mConfiguration.h.

◆ MConfiguration() [2/8]

template<typename NodeType >
constexpr TuringSim::State::MConfiguration::MConfiguration< NodeType >::MConfiguration ( const NodeType &  leaf,
bool  isVar 
)
constexpr

Create a leaf.

Parameters
[in]leafThe content of the leaf.
[in]isVarIf true, the leaf is a variable. Otherwise, it is a constant.

Complexity \(\mathcal{O}(1)\)

Definition at line 530 of file mConfiguration.h.

◆ MConfiguration() [3/8]

template<typename NodeType >
constexpr TuringSim::State::MConfiguration::MConfiguration< NodeType >::MConfiguration ( const NodeType &  node,
const std::vector< MConfiguration< NodeType >> &  subTrees 
)
constexpr

Create an interior node.

Parameters
[in]nodeThe content of the node.
[in]subTreesThe children of the node.

Complexity \(\mathcal{O}(|\texttt{a}|)\)

Definition at line 539 of file mConfiguration.h.

◆ MConfiguration() [4/8]

template<typename NodeType >
constexpr TuringSim::State::MConfiguration::MConfiguration< NodeType >::MConfiguration ( const NodeType &  node,
std::vector< MConfiguration< NodeType >> &&  subTrees 
)
constexpr

Create an interior node and consume the subTrees.

Parameters
[in]nodeThe content of the node.
[in]subTreesThe children of the node.

Complexity \(\mathcal{O}(|\texttt{a}|)\)

Definition at line 552 of file mConfiguration.h.

◆ MConfiguration() [5/8]

template<typename NodeType >
constexpr TuringSim::State::MConfiguration::MConfiguration< NodeType >::MConfiguration ( const NodeType &  node,
const std::vector< std::shared_ptr< const MConfiguration< NodeType >>> &  subTrees 
)
constexpr

Create an interior node.

Parameters
[in]nodeThe content of the node.
[in]subTreesThe children of the node.

Complexity \(\mathcal{O}(|\texttt{a}|)\)

Definition at line 565 of file mConfiguration.h.

◆ MConfiguration() [6/8]

template<typename NodeType >
constexpr TuringSim::State::MConfiguration::MConfiguration< NodeType >::MConfiguration ( const NodeType &  node,
std::vector< std::shared_ptr< const MConfiguration< NodeType >>> &&  subTrees 
)
constexpr

Create an interior node.

Parameters
[in]nodeThe content of the node.
[in]subTreesThe children of the node.

Complexity \(\mathcal{O}(|\texttt{a}|)\)

Definition at line 574 of file mConfiguration.h.

◆ MConfiguration() [7/8]

template<typename NodeType >
constexpr TuringSim::State::MConfiguration::MConfiguration< NodeType >::MConfiguration ( const MConfiguration< NodeType > &  other)
constexpr

Copy constructor.

Parameters
[in]otherMConfiguration to copy. Complexity \(\mathcal{O}(|\texttt{other}|)\)

Definition at line 583 of file mConfiguration.h.

◆ MConfiguration() [8/8]

template<typename NodeType >
constexpr TuringSim::State::MConfiguration::MConfiguration< NodeType >::MConfiguration ( MConfiguration< NodeType > &&  other)
constexpr

Move constructor.

Parameters
[in,out]otherMConfiguration to move.

Complexity \(\mathcal{O}(|\texttt{other}|)\)

Definition at line 592 of file mConfiguration.h.

◆ ~MConfiguration()

template<typename NodeType >
virtual TuringSim::State::MConfiguration::MConfiguration< NodeType >::~MConfiguration ( )
overridevirtualdefault

Destructor.

Complexity \(\mathcal{O}(|\texttt{*this}|)\)

Member Function Documentation

◆ applySubstitution() [1/2]

template<typename NodeType >
std::shared_ptr< const MConfiguration< NodeType > > TuringSim::State::MConfiguration::MConfiguration< NodeType >::applySubstitution ( std::shared_ptr< const MConfiguration< NodeType >>  pattern,
const Unification subs 
)
static

Apply a substitution to the tree.

Parameters
[in]patternThe m-configuration in which to apply the substitution.
[in]subsThe substitution to apply. The substitution is a map from node content to MConfiguration.
Returns
a shared pointer to the const resulting MConfiguration.

Replace all variable leaf by the corresponding MConfiguration.

Complexity \(\mathcal{O}(|\texttt{*this}|)\)

Definition at line 660 of file mConfiguration.h.

Here is the caller graph for this function:

◆ applySubstitution() [2/2]

template<typename NodeType >
std::shared_ptr< const MConfiguration< NodeType > > TuringSim::State::MConfiguration::MConfiguration< NodeType >::applySubstitution ( std::shared_ptr< const MConfiguration< NodeType >>  pattern,
const Unification subs,
const std::shared_ptr< const MConfiguration< NodeType >> &  def 
)
static

Apply a substitution to the tree.

Parameters
[in]patternThe m-configuration in which to apply the substitution.
[in]subsThe substitution to apply. The substitution is a map from node content to MConfiguration.
[in]defThe default tree for all variable without substitution.
Returns
a shared pointer to the const resulting MConfiguration.

Replace all variable leaf by the corresponding MConfiguration.

Complexity \(\mathcal{O}(|\texttt{*this}|)\)

Definition at line 683 of file mConfiguration.h.

◆ compare()

template<typename NodeType >
constexpr int TuringSim::State::MConfiguration::MConfiguration< NodeType >::compare ( const MConfiguration< NodeType > &  other) const
constexpr

Compare two MConfiguration. OCaml style, waiting for <=>. Strong ordering.

Parameters
[in]otherthe other configuration to compare.
Returns
A negative integer if *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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ debug() [1/4]

template<typename NodeType >
template<typename CharT , typename Traits >
std::function< std::basic_ostream< CharT, Traits > &(std::basic_ostream< CharT, Traits > &)> TuringSim::State::MConfiguration::MConfiguration< NodeType >::debug

Return a debug printer for *this.

Template Parameters
CharTchar type.
Traitsstd::basic_ostream trait.
Returns
the debug printer, to use with Utils::Debug::operator<<().

Definition at line 953 of file mConfiguration.h.

Here is the caller graph for this function:

◆ debug() [2/4]

template<typename NodeType >
template<typename CharT , typename Traits >
std::function< std::basic_ostream< CharT, Traits > &(std::basic_ostream< CharT, Traits > &)> TuringSim::State::MConfiguration::MConfiguration< NodeType >::debug ( const AlphaRelation relation)
static

Return a debug printer for relation.

Template Parameters
CharTchar type.
Traitsstd::basic_ostream trait.
Parameters
[in]relationthe relation to print.
Returns
the debug printer, to use with Utils::Debug::operator<<().

Definition at line 982 of file mConfiguration.h.

Here is the call graph for this function:

◆ debug() [3/4]

template<typename NodeType >
template<typename CharT , typename Traits >
std::function< std::basic_ostream< CharT, Traits > &(std::basic_ostream< CharT, Traits > &)> TuringSim::State::MConfiguration::MConfiguration< NodeType >::debug ( const AlphaRewriting rewriting)
static

Return a debug printer for rewriting.

Template Parameters
CharTchar type.
Traitsstd::basic_ostream trait.
Parameters
[in]rewritingthe rewriting to print.
Returns
the debug printer, to use with Utils::Debug::operator<<().

Definition at line 976 of file mConfiguration.h.

Here is the call graph for this function:

◆ debug() [4/4]

template<typename NodeType >
template<typename CharT , typename Traits >
std::function< std::basic_ostream< CharT, Traits > &(std::basic_ostream< CharT, Traits > &)> TuringSim::State::MConfiguration::MConfiguration< NodeType >::debug ( const Unification unification)
static

Return a debug printer for unification.

Template Parameters
CharTchar type.
Traitsstd::basic_ostream trait.
Parameters
[in]unificationthe unification to print.
Returns
the debug printer, to use with Utils::Debug::operator<<().

Definition at line 970 of file mConfiguration.h.

Here is the call graph for this function:

◆ getArg()

template<typename NodeType >
constexpr std::shared_ptr< const MConfiguration< NodeType > > TuringSim::State::MConfiguration::MConfiguration< NodeType >::getArg ( size_t  i) const
constexpr

Returns a child.

Parameters
[in]iThe number of the child to get.
Returns
The i-th child.

Throws std::out_of_bounds exception is i is too large.

Complexity \(\mathcal{O}(1)\)

Definition at line 625 of file mConfiguration.h.

◆ getArity()

template<typename NodeType >
constexpr size_t TuringSim::State::MConfiguration::MConfiguration< NodeType >::getArity
constexpr

Returns the arity of the node.

Returns
The number of children.

Complexity \(\mathcal{O}(1)\)

Definition at line 635 of file mConfiguration.h.

Here is the caller graph for this function:

◆ getNode()

template<typename NodeType >
constexpr const NodeType & TuringSim::State::MConfiguration::MConfiguration< NodeType >::getNode
constexpr

Returns the content of the node.

Returns
the content of the node by const reference.

Complexity \(\mathcal{O}(1)\)

Definition at line 630 of file mConfiguration.h.

Here is the caller graph for this function:

◆ isAlphaEquivalent() [1/2]

template<typename NodeType >
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.

Parameters
[in]otherthe other configuration to test equivalence with.
Returns
an empty option if m-configuration are not equivalent. Otherwise, an option containing the direct and back rewriting.

Complexity \(\mathcal{O}(\min\{|\texttt{*this}|, |\texttt{other}|\})\)

Definition at line 897 of file mConfiguration.h.

◆ isAlphaEquivalent() [2/2]

template<typename NodeType >
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.

Parameters
[in]otherthe other configuration to test equivalence with.
[in,out]directthe current direct rewriting.
[in,out]backthe current back rewriting.
Exceptions
NoAlphaEquivalenceExceptionif states are not alpha-equivalent.

Complexity \(\mathcal{O}(\min\{|\texttt{*this}|, |\texttt{other}|\})\)

Definition at line 909 of file mConfiguration.h.

◆ isLeaf()

template<typename NodeType >
constexpr bool TuringSim::State::MConfiguration::MConfiguration< NodeType >::isLeaf
constexpr

Returns whether the node is a leaf.

Returns
True is the node is a leaf (constant or variable)

Complexity \(\mathcal{O}(1)\)

Definition at line 640 of file mConfiguration.h.

◆ isMFunction()

template<typename NodeType >
constexpr bool TuringSim::State::MConfiguration::MConfiguration< NodeType >::isMFunction
constexpr

Returns whether the MConfiguration is a m-function (ie. not a pattern).

Returns
true iff the MConfiguration rooted at this node is not a pattern.

Complexity \(\mathcal{O}(|\texttt{*this}|)\)

Definition at line 655 of file mConfiguration.h.

◆ isPattern()

template<typename NodeType >
constexpr bool TuringSim::State::MConfiguration::MConfiguration< NodeType >::isPattern
constexpr

Returns whether the MConfiguration is a pattern.

Returns
true iff the MConfiguration rooted at this node is a pattern.

Inspects recursively.

Complexity \(\mathcal{O}(|\texttt{*this}|)\)

Definition at line 650 of file mConfiguration.h.

◆ isVariable()

template<typename NodeType >
constexpr bool TuringSim::State::MConfiguration::MConfiguration< NodeType >::isVariable
constexpr

Returns whether the node is a variable.

Returns
true iff the node is a variable.

Does not inspect recursively.

Complexity \(\mathcal{O}(1)\)

Definition at line 645 of file mConfiguration.h.

Here is the caller graph for this function:

◆ match()

template<typename NodeType >
std::optional< typename MConfiguration< NodeType >::MatcherType > TuringSim::State::MConfiguration::MConfiguration< NodeType >::match ( const StateType state) const
finaloverridenoexcept

Unify the MConfiguration with another.

Parameters
[in]stateThe other MConfiguration, which have to be a m-function.
Returns
an empty option if unification fails, the unification otherwise.

*this have to be a pattern, UB otherwise.

Same as MConfiguration::unifyWithMConf_opt

Definition at line 811 of file mConfiguration.h.

◆ operator!=()

template<typename NodeType >
constexpr bool TuringSim::State::MConfiguration::MConfiguration< NodeType >::operator!= ( const MConfiguration< NodeType > &  other) const
constexpr

Test whether two MConfiguration are different.

Parameters
[in]otherthe other configuration to compare.
Returns
whether the comparison succeeds.

Complexity \(\mathcal{O}(\min\{|\texttt{*this}|, |\texttt{other}|\})\)

Definition at line 882 of file mConfiguration.h.

◆ operator<()

template<typename NodeType >
bool TuringSim::State::MConfiguration::MConfiguration< NodeType >::operator< ( const MConfiguration< NodeType > &  other) const

Compare two MConfiguration.

Parameters
[in]otherthe other configuration to compare.
Returns
whether the comparison succeeds.

Complexity \(\mathcal{O}(\min\{|\texttt{*this}|, |\texttt{other}|\})\)

Definition at line 892 of file mConfiguration.h.

◆ operator=() [1/2]

template<typename NodeType >
constexpr MConfiguration< NodeType > & TuringSim::State::MConfiguration::MConfiguration< NodeType >::operator= ( const MConfiguration< NodeType > &  other)
constexpr

Copy assignment operator.

Parameters
[in]otherMConfiguration to copy.
Returns
A reference to *this

Complexity \(\mathcal{O}(|\texttt{other}|)\)

Definition at line 601 of file mConfiguration.h.

◆ operator=() [2/2]

template<typename NodeType >
constexpr MConfiguration< NodeType > & TuringSim::State::MConfiguration::MConfiguration< NodeType >::operator= ( MConfiguration< NodeType > &&  other)
constexpr

Move assignment operator.

Parameters
[in,out]otherMConfiguration to move.
Returns
A reference to *this

Complexity \(\mathcal{O}(|\texttt{other}|)\)

Definition at line 613 of file mConfiguration.h.

◆ operator==()

template<typename NodeType >
constexpr bool TuringSim::State::MConfiguration::MConfiguration< NodeType >::operator== ( const MConfiguration< NodeType > &  other) const
constexpr

Test whether two MConfiguration are the same.

Parameters
[in]otherthe other configuration to compare.
Returns
whether the comparison succeeds.

Complexity \(\mathcal{O}(\min\{|\texttt{*this}|, |\texttt{other}|\})\)

Definition at line 887 of file mConfiguration.h.

◆ toString()

template<typename NodeType >
template<typename CharT , typename Traits , typename Alloc >
std::basic_string< CharT, Traits, Alloc > TuringSim::State::MConfiguration::MConfiguration< NodeType >::toString

Convert the MConfiguration in a string.

Template Parameters
CharTchar type.
Traitsthe std::basic_ostream trait.
Allocthe allocator.
Returns
a string representing *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.

◆ unify()

template<typename NodeType >
MConfiguration< NodeType >::Unification TuringSim::State::MConfiguration::MConfiguration< NodeType >::unify ( const std::shared_ptr< const MConfiguration< NodeType >> &  state) const

Unify the MConfiguration with another.

Parameters
[in]stateThe other MConfiguration.
Returns
an unification if it succeeds.
Exceptions
NoUnificationExceptionif 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.

◆ unify_opt()

template<typename NodeType >
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.

Parameters
[in]stateThe other MConfiguration.
Returns
an empty option if unification fails, the unification otherwise.
Exceptions
NoUnificationExceptionif 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.

◆ unify_state() [1/2]

template<typename NodeType >
std::map< NodeType, std::shared_ptr< const MConfiguration< NodeType > > > TuringSim::State::MConfiguration::MConfiguration< NodeType >::unify_state ( const std::shared_ptr< const MConfiguration< NodeType >> &  state,
const MConfiguration< NodeType > &  pattern 
)
static

unify a state with a pattern.

Parameters
[in]statea shared pointer to the state to unify.
[in]patternthe pattern against which to unify the state.
Returns
the unification, if any.
Exceptions
NoUnificationExceptionif unification fails.

Definition at line 758 of file mConfiguration.h.

Here is the call graph for this function:

◆ unify_state() [2/2]

template<typename NodeType >
void TuringSim::State::MConfiguration::MConfiguration< NodeType >::unify_state ( const std::shared_ptr< const MConfiguration< NodeType >> &  state,
const MConfiguration< NodeType > &  pattern,
std::map< NodeType, std::shared_ptr< const MConfiguration< NodeType >>> &  unification 
)
static

unify a state with a pattern, while filling a unification.

Parameters
[in]statea shared pointer to the state to unify.
[in]patternthe pattern against which to unify the state.
[in,out]unificationthe unification incrementally filled.
Exceptions
NoUnificationExceptionif unification fails.

Definition at line 706 of file mConfiguration.h.

◆ unifyWithMConf()

template<typename NodeType >
constexpr MConfiguration< NodeType >::Unification TuringSim::State::MConfiguration::MConfiguration< NodeType >::unifyWithMConf ( const std::shared_ptr< const MConfiguration< NodeType >> &  state) const
constexpr

Unify the MConfiguration with another.

Parameters
[in]stateThe other MConfiguration, which have to be a m-function.
Returns
an unification if it succeeds.
Exceptions
NoUnificationExceptionif 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.

◆ unifyWithMConf_opt()

template<typename NodeType >
std::optional< typename MConfiguration< NodeType >::Unification > TuringSim::State::MConfiguration::MConfiguration< NodeType >::unifyWithMConf_opt ( const std::shared_ptr< const MConfiguration< NodeType >> &  state) const
noexcept

Unify the MConfiguration with another.

Parameters
[in]stateThe other MConfiguration, which have to be a m-function.
Returns
an empty option if unification fails, the unification otherwise.

*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.

Friends And Related Function Documentation

◆ operator<<

template<typename NodeType >
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 
)
friend

Print a MConfiguration.

Template Parameters
Uthe type of nodes of the MConfigurations
CharTchar type
Traitsstd::basic_ostream trait.
Parameters
[in,out]osthe output stream
[in]m_confthe MConfiguration to print.
Returns
reference to os.

Type U have to have operator<<(std::basic_ostream<CharT, Traits>&, const U&) implemented.

Definition at line 361 of file mConfiguration.h.

Member Data Documentation

◆ isVar

template<typename NodeType >
bool TuringSim::State::MConfiguration::MConfiguration< NodeType >::isVar
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.


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