* spot/tl/formula.hh: More doxygen comments for fnode.
This commit is contained in:
parent
50c2192edf
commit
a4f111f342
1 changed files with 103 additions and 11 deletions
|
|
@ -107,6 +107,10 @@ namespace spot
|
||||||
class SPOT_API fnode final
|
class SPOT_API fnode final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// \brief Clone an fnode.
|
||||||
|
///
|
||||||
|
/// This simply increment the reference counter. If the counter
|
||||||
|
/// saturates, the fnode will stay permanently allocated.
|
||||||
const fnode* clone() const
|
const fnode* clone() const
|
||||||
{
|
{
|
||||||
// Saturate.
|
// Saturate.
|
||||||
|
|
@ -116,6 +120,11 @@ namespace spot
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Dereference an fnode.
|
||||||
|
///
|
||||||
|
/// This decrement the reference counter (unless the counter is
|
||||||
|
/// saturated), and actually deallocate the fnode when the
|
||||||
|
/// counder reaches 0 (unless the fnode denotes a constant).
|
||||||
void destroy() const
|
void destroy() const
|
||||||
{
|
{
|
||||||
if (SPOT_LIKELY(refs_))
|
if (SPOT_LIKELY(refs_))
|
||||||
|
|
@ -125,35 +134,46 @@ namespace spot
|
||||||
destroy_aux();
|
destroy_aux();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::unbounded
|
||||||
static constexpr uint8_t unbounded()
|
static constexpr uint8_t unbounded()
|
||||||
{
|
{
|
||||||
return UINT8_MAX;
|
return UINT8_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::ap
|
||||||
static const fnode* ap(const std::string& name);
|
static const fnode* ap(const std::string& name);
|
||||||
|
/// \see formula::unop
|
||||||
static const fnode* unop(op o, const fnode* f);
|
static const fnode* unop(op o, const fnode* f);
|
||||||
|
/// \see formula::binop
|
||||||
static const fnode* binop(op o, const fnode* f, const fnode* g);
|
static const fnode* binop(op o, const fnode* f, const fnode* g);
|
||||||
|
/// \see formula::multop
|
||||||
static const fnode* multop(op o, std::vector<const fnode*> l);
|
static const fnode* multop(op o, std::vector<const fnode*> l);
|
||||||
|
/// \see formula::bunop
|
||||||
static const fnode* bunop(op o, const fnode* f,
|
static const fnode* bunop(op o, const fnode* f,
|
||||||
uint8_t min, uint8_t max = unbounded());
|
uint8_t min, uint8_t max = unbounded());
|
||||||
|
|
||||||
|
/// \see formula::kind
|
||||||
op kind() const
|
op kind() const
|
||||||
{
|
{
|
||||||
return op_;
|
return op_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::kindstr
|
||||||
std::string kindstr() const;
|
std::string kindstr() const;
|
||||||
|
|
||||||
|
/// \see formula::is
|
||||||
bool is(op o) const
|
bool is(op o) const
|
||||||
{
|
{
|
||||||
return op_ == o;
|
return op_ == o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is
|
||||||
bool is(op o1, op o2) const
|
bool is(op o1, op o2) const
|
||||||
{
|
{
|
||||||
return op_ == o1 || op_ == o2;
|
return op_ == o1 || op_ == o2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is
|
||||||
bool is(std::initializer_list<op> l) const
|
bool is(std::initializer_list<op> l) const
|
||||||
{
|
{
|
||||||
const fnode* n = this;
|
const fnode* n = this;
|
||||||
|
|
@ -166,6 +186,7 @@ namespace spot
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::get_child_of
|
||||||
const fnode* get_child_of(op o) const
|
const fnode* get_child_of(op o) const
|
||||||
{
|
{
|
||||||
if (op_ != o)
|
if (op_ != o)
|
||||||
|
|
@ -174,6 +195,7 @@ namespace spot
|
||||||
return nth(0);
|
return nth(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::get_child_of
|
||||||
const fnode* get_child_of(std::initializer_list<op> l) const
|
const fnode* get_child_of(std::initializer_list<op> l) const
|
||||||
{
|
{
|
||||||
auto c = this;
|
auto c = this;
|
||||||
|
|
@ -186,38 +208,45 @@ namespace spot
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::min
|
||||||
unsigned min() const
|
unsigned min() const
|
||||||
{
|
{
|
||||||
assert(op_ == op::FStar || op_ == op::Star);
|
assert(op_ == op::FStar || op_ == op::Star);
|
||||||
return min_;
|
return min_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::max
|
||||||
unsigned max() const
|
unsigned max() const
|
||||||
{
|
{
|
||||||
assert(op_ == op::FStar || op_ == op::Star);
|
assert(op_ == op::FStar || op_ == op::Star);
|
||||||
return max_;
|
return max_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::size
|
||||||
unsigned size() const
|
unsigned size() const
|
||||||
{
|
{
|
||||||
return size_;
|
return size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::id
|
||||||
size_t id() const
|
size_t id() const
|
||||||
{
|
{
|
||||||
return id_;
|
return id_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::begin
|
||||||
const fnode*const* begin() const
|
const fnode*const* begin() const
|
||||||
{
|
{
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::end
|
||||||
const fnode*const* end() const
|
const fnode*const* end() const
|
||||||
{
|
{
|
||||||
return children + size();
|
return children + size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::nth
|
||||||
const fnode* nth(unsigned i) const
|
const fnode* nth(unsigned i) const
|
||||||
{
|
{
|
||||||
if (i >= size())
|
if (i >= size())
|
||||||
|
|
@ -225,41 +254,49 @@ namespace spot
|
||||||
return children[i];
|
return children[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::ff
|
||||||
static const fnode* ff()
|
static const fnode* ff()
|
||||||
{
|
{
|
||||||
return ff_;
|
return ff_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_ff
|
||||||
bool is_ff() const
|
bool is_ff() const
|
||||||
{
|
{
|
||||||
return op_ == op::ff;
|
return op_ == op::ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::tt
|
||||||
static const fnode* tt()
|
static const fnode* tt()
|
||||||
{
|
{
|
||||||
return tt_;
|
return tt_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_tt
|
||||||
bool is_tt() const
|
bool is_tt() const
|
||||||
{
|
{
|
||||||
return op_ == op::tt;
|
return op_ == op::tt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::eword
|
||||||
static const fnode* eword()
|
static const fnode* eword()
|
||||||
{
|
{
|
||||||
return ew_;
|
return ew_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_eword
|
||||||
bool is_eword() const
|
bool is_eword() const
|
||||||
{
|
{
|
||||||
return op_ == op::eword;
|
return op_ == op::eword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_constant
|
||||||
bool is_constant() const
|
bool is_constant() const
|
||||||
{
|
{
|
||||||
return op_ == op::ff || op_ == op::tt || op_ == op::eword;
|
return op_ == op::ff || op_ == op::tt || op_ == op::eword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_Kleene_star
|
||||||
bool is_Kleene_star() const
|
bool is_Kleene_star() const
|
||||||
{
|
{
|
||||||
if (op_ != op::Star)
|
if (op_ != op::Star)
|
||||||
|
|
@ -267,6 +304,7 @@ namespace spot
|
||||||
return min_ == 0 && max_ == unbounded();
|
return min_ == 0 && max_ == unbounded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::one_star
|
||||||
static const fnode* one_star()
|
static const fnode* one_star()
|
||||||
{
|
{
|
||||||
if (!one_star_)
|
if (!one_star_)
|
||||||
|
|
@ -274,11 +312,16 @@ namespace spot
|
||||||
return one_star_;
|
return one_star_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::ap_name
|
||||||
const std::string& ap_name() const;
|
const std::string& ap_name() const;
|
||||||
|
|
||||||
|
/// \see formula::dump
|
||||||
std::ostream& dump(std::ostream& os) const;
|
std::ostream& dump(std::ostream& os) const;
|
||||||
|
|
||||||
|
/// \see formula::all_but
|
||||||
const fnode* all_but(unsigned i) const;
|
const fnode* all_but(unsigned i) const;
|
||||||
|
|
||||||
|
/// \see formula::boolean_count
|
||||||
unsigned boolean_count() const
|
unsigned boolean_count() const
|
||||||
{
|
{
|
||||||
unsigned pos = 0;
|
unsigned pos = 0;
|
||||||
|
|
@ -288,111 +331,140 @@ namespace spot
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::boolean_operands
|
||||||
const fnode* boolean_operands(unsigned* width = nullptr) const;
|
const fnode* boolean_operands(unsigned* width = nullptr) const;
|
||||||
|
|
||||||
/// return true if the unicity map contains only the globally
|
/// \brief safety check for the reference counters
|
||||||
|
///
|
||||||
|
/// \return true iff the unicity map contains only the globally
|
||||||
/// pre-allocated formulas.
|
/// pre-allocated formulas.
|
||||||
|
///
|
||||||
|
/// This is meant to be used as
|
||||||
|
/// \code
|
||||||
|
/// assert(spot::fnode::instances_check());
|
||||||
|
/// \endcode
|
||||||
|
/// at the end of a program.
|
||||||
static bool instances_check();
|
static bool instances_check();
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
// Properties //
|
// Properties //
|
||||||
////////////////
|
////////////////
|
||||||
|
|
||||||
|
/// \see formula::is_boolean
|
||||||
bool is_boolean() const
|
bool is_boolean() const
|
||||||
{
|
{
|
||||||
return is_.boolean;
|
return is_.boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_sugar_free_boolean
|
||||||
bool is_sugar_free_boolean() const
|
bool is_sugar_free_boolean() const
|
||||||
{
|
{
|
||||||
return is_.sugar_free_boolean;
|
return is_.sugar_free_boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_in_nenoform
|
||||||
bool is_in_nenoform() const
|
bool is_in_nenoform() const
|
||||||
{
|
{
|
||||||
return is_.in_nenoform;
|
return is_.in_nenoform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_syntactic_stutter_invariant
|
||||||
bool is_syntactic_stutter_invariant() const
|
bool is_syntactic_stutter_invariant() const
|
||||||
{
|
{
|
||||||
return is_.syntactic_si;
|
return is_.syntactic_si;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_sugar_free_ltl
|
||||||
bool is_sugar_free_ltl() const
|
bool is_sugar_free_ltl() const
|
||||||
{
|
{
|
||||||
return is_.sugar_free_ltl;
|
return is_.sugar_free_ltl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_ltl_formula
|
||||||
bool is_ltl_formula() const
|
bool is_ltl_formula() const
|
||||||
{
|
{
|
||||||
return is_.ltl_formula;
|
return is_.ltl_formula;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_psl_formula
|
||||||
bool is_psl_formula() const
|
bool is_psl_formula() const
|
||||||
{
|
{
|
||||||
return is_.psl_formula;
|
return is_.psl_formula;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_sere_formula
|
||||||
bool is_sere_formula() const
|
bool is_sere_formula() const
|
||||||
{
|
{
|
||||||
return is_.sere_formula;
|
return is_.sere_formula;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_finite
|
||||||
bool is_finite() const
|
bool is_finite() const
|
||||||
{
|
{
|
||||||
return is_.finite;
|
return is_.finite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_eventual
|
||||||
bool is_eventual() const
|
bool is_eventual() const
|
||||||
{
|
{
|
||||||
return is_.eventual;
|
return is_.eventual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_universal
|
||||||
bool is_universal() const
|
bool is_universal() const
|
||||||
{
|
{
|
||||||
return is_.universal;
|
return is_.universal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_syntactic_safety
|
||||||
bool is_syntactic_safety() const
|
bool is_syntactic_safety() const
|
||||||
{
|
{
|
||||||
return is_.syntactic_safety;
|
return is_.syntactic_safety;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_syntactic_guarantee
|
||||||
bool is_syntactic_guarantee() const
|
bool is_syntactic_guarantee() const
|
||||||
{
|
{
|
||||||
return is_.syntactic_guarantee;
|
return is_.syntactic_guarantee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_syntactic_obligation
|
||||||
bool is_syntactic_obligation() const
|
bool is_syntactic_obligation() const
|
||||||
{
|
{
|
||||||
return is_.syntactic_obligation;
|
return is_.syntactic_obligation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_syntactic_recurrence
|
||||||
bool is_syntactic_recurrence() const
|
bool is_syntactic_recurrence() const
|
||||||
{
|
{
|
||||||
return is_.syntactic_recurrence;
|
return is_.syntactic_recurrence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_syntactic_persistence
|
||||||
bool is_syntactic_persistence() const
|
bool is_syntactic_persistence() const
|
||||||
{
|
{
|
||||||
return is_.syntactic_persistence;
|
return is_.syntactic_persistence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::is_marked
|
||||||
bool is_marked() const
|
bool is_marked() const
|
||||||
{
|
{
|
||||||
return !is_.not_marked;
|
return !is_.not_marked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::accepts_eword
|
||||||
bool accepts_eword() const
|
bool accepts_eword() const
|
||||||
{
|
{
|
||||||
return is_.accepting_eword;
|
return is_.accepting_eword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::has_lbt_atomic_props
|
||||||
bool has_lbt_atomic_props() const
|
bool has_lbt_atomic_props() const
|
||||||
{
|
{
|
||||||
return is_.lbt_atomic_props;
|
return is_.lbt_atomic_props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \see formula::has_spin_atomic_props
|
||||||
bool has_spin_atomic_props() const
|
bool has_spin_atomic_props() const
|
||||||
{
|
{
|
||||||
return is_.spin_atomic_props;
|
return is_.spin_atomic_props;
|
||||||
|
|
@ -579,21 +651,32 @@ namespace spot
|
||||||
{
|
{
|
||||||
const fnode* ptr_;
|
const fnode* ptr_;
|
||||||
public:
|
public:
|
||||||
|
/// \brief Create a formula from an fnode.
|
||||||
|
///
|
||||||
|
/// This constructor is mainly for internal use, as spot::fnode
|
||||||
|
/// object should usually not be manipulated from user code.
|
||||||
explicit formula(const fnode* f) noexcept
|
explicit formula(const fnode* f) noexcept
|
||||||
: ptr_(f)
|
: ptr_(f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Create a null formula.
|
||||||
|
///
|
||||||
|
/// This could be used to default initialize a formula, however
|
||||||
|
/// null formula should be short lived: most algorithms and member
|
||||||
|
/// function assume that formulas should not be null.
|
||||||
formula(std::nullptr_t) noexcept
|
formula(std::nullptr_t) noexcept
|
||||||
: ptr_(nullptr)
|
: ptr_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Default initialize a formula to nullptr.
|
||||||
formula() noexcept
|
formula() noexcept
|
||||||
: ptr_(nullptr)
|
: ptr_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clone a formula.
|
||||||
formula(const formula& f) noexcept
|
formula(const formula& f) noexcept
|
||||||
: ptr_(f.ptr_)
|
: ptr_(f.ptr_)
|
||||||
{
|
{
|
||||||
|
|
@ -601,18 +684,27 @@ namespace spot
|
||||||
ptr_->clone();
|
ptr_->clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clone a formula.
|
||||||
formula(formula&& f) noexcept
|
formula(formula&& f) noexcept
|
||||||
: ptr_(f.ptr_)
|
: ptr_(f.ptr_)
|
||||||
{
|
{
|
||||||
f.ptr_ = nullptr;
|
f.ptr_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Destroy a formula.
|
||||||
~formula()
|
~formula()
|
||||||
{
|
{
|
||||||
if (ptr_)
|
if (ptr_)
|
||||||
ptr_->destroy();
|
ptr_->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Reset a formula to null
|
||||||
|
///
|
||||||
|
/// Note that null formula should be short lived: most algorithms
|
||||||
|
/// and member function assume that formulas should not be null.
|
||||||
|
/// Assigning nullptr to a formula can be useful when cleaning an
|
||||||
|
/// array of formula using multiple passes and marking some
|
||||||
|
/// formula as nullptr before actually erasing them.
|
||||||
const formula& operator=(std::nullptr_t)
|
const formula& operator=(std::nullptr_t)
|
||||||
{
|
{
|
||||||
this->~formula();
|
this->~formula();
|
||||||
|
|
@ -831,52 +923,52 @@ namespace spot
|
||||||
return binop(op::Name, std::move(f), std::move(g)); \
|
return binop(op::Name, std::move(f), std::move(g)); \
|
||||||
}
|
}
|
||||||
#endif // !SWIG
|
#endif // !SWIG
|
||||||
/// \brief Construct an Xor formula
|
/// \brief Construct an `Xor` formula
|
||||||
/// @{
|
/// @{
|
||||||
SPOT_DEF_BINOP(Xor);
|
SPOT_DEF_BINOP(Xor);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// \brief Construct an Implies formula
|
/// \brief Construct an `->` formula
|
||||||
/// @{
|
/// @{
|
||||||
SPOT_DEF_BINOP(Implies);
|
SPOT_DEF_BINOP(Implies);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// \brief Construct an Equiv formula
|
/// \brief Construct an `<->` formula
|
||||||
/// @{
|
/// @{
|
||||||
SPOT_DEF_BINOP(Equiv);
|
SPOT_DEF_BINOP(Equiv);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// \brief Construct an U formula
|
/// \brief Construct a `U` formula
|
||||||
/// @{
|
/// @{
|
||||||
SPOT_DEF_BINOP(U);
|
SPOT_DEF_BINOP(U);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// \brief Construct an R formula
|
/// \brief Construct an `R` formula
|
||||||
/// @{
|
/// @{
|
||||||
SPOT_DEF_BINOP(R);
|
SPOT_DEF_BINOP(R);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// \brief Construct an W formula
|
/// \brief Construct a `W` formula
|
||||||
/// @{
|
/// @{
|
||||||
SPOT_DEF_BINOP(W);
|
SPOT_DEF_BINOP(W);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// \brief Construct an < formula
|
/// \brief Construct an `M` formula
|
||||||
/// @{
|
/// @{
|
||||||
SPOT_DEF_BINOP(M);
|
SPOT_DEF_BINOP(M);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// \brief Construct an <>-> PSL formula
|
/// \brief Construct a `<>->` PSL formula
|
||||||
/// @{
|
/// @{
|
||||||
SPOT_DEF_BINOP(EConcat);
|
SPOT_DEF_BINOP(EConcat);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// \brief Construct a marked <>-> PSL formula
|
/// \brief Construct a marked `<>->` PSL formula
|
||||||
/// @{
|
/// @{
|
||||||
SPOT_DEF_BINOP(EConcatMarked);
|
SPOT_DEF_BINOP(EConcatMarked);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// \brief Construct an []-> PSL formula
|
/// \brief Construct a `[]->` PSL formula
|
||||||
/// @{
|
/// @{
|
||||||
SPOT_DEF_BINOP(UConcat);
|
SPOT_DEF_BINOP(UConcat);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue