|
TuringSim
C++ framework to simulate abstract computing models
|
Represent a tree of properties with alternating quantifiers. More...
#include <runner/nonDeterministicMachineRunner.h>
Public Types | |
| enum | Quantifier { Quantifier::Existential, Quantifier::Universal } |
| The quantifier for each node of an alternating tree. More... | |
| typedef size_t | Uid |
| The keys of leaves and sub-Trees. | |
Public Member Functions | |
| void | insert (Uid subUid, Quantifier q, std::vector< std::tuple< LeafType, std::optional< bool >>> &newLeaves) |
| Replace a uid with a a leaf of new leaves. More... | |
| std::pair< const Uid, LeafType > & | pick () |
| Pick a leaf with its uid. More... | |
| Uid | lastLeafUid () |
| The last uid of the leaves. More... | |
| bool | hasLeaves () const |
| Whether the node has leaves. More... | |
| const std::map< Uid, std::shared_ptr< AlternatingTree< LeafType > > > & | getSubTrees () |
| Get sub trees. More... | |
| void | decide (Uid subUid, bool d) |
| Decide a leaf. More... | |
| bool | decided () const noexcept |
| Whether the node is decided. More... | |
| std::optional< bool > | getDecision () const noexcept |
| Get the optional decision. 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 |
| Debug printer for the alternating tree. More... | |
| template<typename CharT = char, typename Traits = std::char_traits<CharT>> | |
| std::function< std::basic_ostream< CharT, Traits > &(std::basic_ostream< CharT, Traits > &)> | debug (size_t i) const |
| Debug printer for the alternating tree, with initial indentation. More... | |
| void | compact () |
| Remove decided items, since they are useless, except for documentation. | |
Static Public Member Functions | |
| static std::shared_ptr< AlternatingTree > | makeAlternatingTreeRoot (Quantifier quantifier, const std::vector< LeafType > &leaves) |
| Build a new alternating tree, with provided leaves and quantifier. 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 Quantifier &q) |
| Debug printer for a quantifier. More... | |
Friends | |
| template<typename CharT = char, typename Traits = std::char_traits<CharT>> | |
| std::basic_ostream< CharT, Traits > & | operator<< (std::basic_ostream< CharT, Traits > &os, const AlternatingTree &tree) |
| Debug printer for the alternating tree. More... | |
Represent a tree of properties with alternating quantifiers.
| LeafType | the type of leaves. |
This tree is a structure ad-hoc for alternating machines. Each node has:
Leaves and sub-trees are identified by non conflicting integers. In addition, non-root nodes have a smart pointer to its parent, with its own id, from the point of view of its parent.
Alternating trees can only be built with leaves, but no sub-trees. Leaves can either be decided, or replaced by a sub-tree. Sub-trees with same quantifier and smashed.
When a leaf is decided, if the decision allows to decide the node, it is immediately done and propagated upwards. When a leaf is decided but does not allows to decide the node, it is removed. The same apply to the decision of sub-trees. When a node has no sub-trees and leaves left, it can be decided.
Definition at line 32 of file nonDeterministicMachineRunner.h.
|
strong |
The quantifier for each node of an alternating tree.
| Enumerator | |
|---|---|
| Existential | The node is existential. |
| Universal | The node is universal. |
Definition at line 37 of file nonDeterministicMachineRunner.h.
|
inline |
Debug printer for the alternating tree.
| CharT | char type. |
| Traits | std::basic_ostream trait. |
Definition at line 162 of file nonDeterministicMachineRunner.h.

|
inlinestatic |
Debug printer for a quantifier.
| CharT | char type. |
| Traits | std::basic_ostream trait. |
| q | the quantifier. |
Definition at line 173 of file nonDeterministicMachineRunner.h.
|
inline |
Debug printer for the alternating tree, with initial indentation.
| CharT | char type. |
| Traits | std::basic_ostream trait. |
| i | the indentation level. |
Definition at line 206 of file nonDeterministicMachineRunner.h.

|
inline |
Decide a leaf.
| subUid | the uid of the leaf to decide. |
| d | the decision for this leaf. |
Definition at line 110 of file nonDeterministicMachineRunner.h.

|
inlinenoexcept |
Whether the node is decided.
Definition at line 135 of file nonDeterministicMachineRunner.h.
|
inlinenoexcept |
Get the optional decision.
Definition at line 142 of file nonDeterministicMachineRunner.h.
|
inline |
Get sub trees.
Definition at line 102 of file nonDeterministicMachineRunner.h.
|
inline |
Whether the node has leaves.
Definition at line 95 of file nonDeterministicMachineRunner.h.
|
inline |
Replace a uid with a a leaf of new leaves.
| [in] | subUid | the uid of the leaf to replace. |
| [in] | q | the quantifier between new nodes. |
| [in] | newLeaves | new leaves, with optional decision. |
Remove the leaf with id subUid. If q is:
For nodes with decisions, this decision is applied.
Definition at line 59 of file nonDeterministicMachineRunner.h.


|
inline |
The last uid of the leaves.
Definition at line 88 of file nonDeterministicMachineRunner.h.
|
inlinestatic |
Build a new alternating tree, with provided leaves and quantifier.
| quantifier | the quantifier of the root node. |
| leaves | the list of of the root node. |
Definition at line 151 of file nonDeterministicMachineRunner.h.

|
inline |
Pick a leaf with its uid.
UB is there is no more leaves.
Definition at line 81 of file nonDeterministicMachineRunner.h.
|
friend |
Debug printer for the alternating tree.
| CharT | char type. |
| Traits | std::basic_ostream trait. |
| os | the output stream. |
| tree | the tree to print. |
os.. Definition at line 194 of file nonDeterministicMachineRunner.h.