smats  0.0.1
Satisfability Modulo Arithmetic Theories Symbols
Loading...
Searching...
No Matches
smats Namespace Reference

ExpressionKind enum. More...

Classes

class  BinaryExpressionCell
 
struct  DelegatingHasher
 
class  Environment
 
class  Expression
 
class  ExpressionAbs
 
class  ExpressionAcos
 
class  ExpressionAdd
 
class  ExpressionAddFactory
 
class  ExpressionAsin
 
class  ExpressionAtan
 
class  ExpressionAtan2
 
class  ExpressionCeiling
 
class  ExpressionCell
 
class  ExpressionConstant
 
class  ExpressionCos
 
class  ExpressionCosh
 
class  ExpressionDiv
 
class  ExpressionExp
 
class  ExpressionFloor
 
class  ExpressionIfThenElse
 
class  ExpressionLog
 
class  ExpressionMax
 
class  ExpressionMin
 
class  ExpressionMul
 
class  ExpressionMulFactory
 
class  ExpressionNaN
 
class  ExpressionPow
 
class  ExpressionSin
 
class  ExpressionSinh
 
class  ExpressionSqrt
 
class  ExpressionTan
 
class  ExpressionTanh
 
class  ExpressionUninterpretedFunction
 
class  ExpressionVar
 
class  ExpressionVisitor
 
class  Formula
 
class  IterationStats
 
class  SmatsAssertionError
 
class  SmatsException
 
class  SmatsInvalidArgument
 
class  SmatsInvalidCommandLineArgument
 
class  SmatsInvalidState
 
class  SmatsNotImplementedException
 
class  SmatsNotSupported
 
class  SmatsOutOfRange
 
class  SmatsUnreachable
 
class  Stats
 
class  Timer
 
class  TimerBase
 
class  TimerGuard
 
struct  uhash
 
class  UnaryExpressionCell
 
struct  user_clock
 
class  UserTimer
 
class  Variable
 
class  Variables
 
class  Visitor
 

Concepts

concept  IsEnum
 
concept  IsAnyOf
 
concept  IsNotAnyOf
 
concept  Arithmetic
 
concept  Numeric
 
concept  InvocableHashAlgorithm
 
concept  Hashable
 
concept  Spannable
 
concept  SpannableOfType
 

Typedefs

using EnvironmentI = Environment<int>
 
using EnvironmentL = Environment<long>
 
using EnvironmentF = Environment<float>
 
using EnvironmentD = Environment<double>
 
using ExpressionD = Expression<double>
 
using ExpressionF = Expression<float>
 
using ExpressionI = Expression<int>
 
using ExpressionL = Expression<long>
 
template<class T >
using Substitution = std::unordered_map<Variable, Expression<T>>
 
using DefaultHashAlgorithm = hash::FNV1a
 The default hashing algorithm. The return type is size_t.
 
using DefaultHash = smats::uhash<DefaultHashAlgorithm>
 The default hashing functor. It behaves like std::hash.
 
using chosen_steady_clock
 

Enumerations

enum class  ExpressionKind {
  Constant , Var , Add , Mul ,
  Div , Log , Abs , Exp ,
  Sqrt , Pow , Sin , Cos ,
  Tan , Asin , Acos , Atan ,
  Atan2 , Sinh , Cosh , Tanh ,
  Min , Max , Ceil , Floor ,
  IfThenElse , NaN , UninterpretedFunction
}
 

Functions

template<class T >
std::ostream & operator<< (std::ostream &os, const Environment< T > &env)
 
template std::ostream & operator<< (std::ostream &os, const Environment< int > &env)
 
template std::ostream & operator<< (std::ostream &os, const Environment< long > &env)
 
template std::ostream & operator<< (std::ostream &os, const Environment< float > &env)
 
template std::ostream & operator<< (std::ostream &os, const Environment< double > &env)
 
template<class T >
Expression< T > operator+ (const T &c, const Expression< T > &e)
 
template<class T >
Expression< T > operator- (const T &c, const Expression< T > &e)
 
template<class T >
Expression< T > operator* (const T &c, const Expression< T > &e)
 
template<class T >
Expression< T > operator/ (const T &c, const Expression< T > &e)
 
template<class T >
Expression< T > operator^ (const T &c, const Expression< T > &e)
 
template<class T >
std::ostream & operator<< (std::ostream &os, const Expression< T > &expr)
 
 EXPLICIT_TEMPLATE_INSTANTIATION_NUMERIC (Expression)
 
template Expression< int > operator+ (const int &c, const Expression< int > &e)
 
template Expression< long > operator+ (const long &c, const Expression< long > &e)
 
template Expression< double > operator+ (const double &c, const Expression< double > &e)
 
template Expression< float > operator+ (const float &c, const Expression< float > &e)
 
template Expression< int > operator- (const int &c, const Expression< int > &e)
 
template Expression< long > operator- (const long &c, const Expression< long > &e)
 
template Expression< double > operator- (const double &c, const Expression< double > &e)
 
template Expression< float > operator- (const float &c, const Expression< float > &e)
 
template Expression< int > operator* (const int &c, const Expression< int > &e)
 
template Expression< long > operator* (const long &c, const Expression< long > &e)
 
template Expression< double > operator* (const double &c, const Expression< double > &e)
 
template Expression< float > operator* (const float &c, const Expression< float > &e)
 
template Expression< int > operator/ (const int &c, const Expression< int > &e)
 
template Expression< long > operator/ (const long &c, const Expression< long > &e)
 
template Expression< double > operator/ (const double &c, const Expression< double > &e)
 
template Expression< float > operator/ (const float &c, const Expression< float > &e)
 
template Expression< int > operator^ (const int &c, const Expression< int > &e)
 
template Expression< long > operator^ (const long &c, const Expression< long > &e)
 
template Expression< double > operator^ (const double &c, const Expression< double > &e)
 
template Expression< float > operator^ (const float &c, const Expression< float > &e)
 
template std::ostream & operator<< (std::ostream &os, const Expression< int > &expr)
 
template std::ostream & operator<< (std::ostream &os, const Expression< long > &expr)
 
template std::ostream & operator<< (std::ostream &os, const Expression< double > &expr)
 
template std::ostream & operator<< (std::ostream &os, const Expression< float > &expr)
 
 EXTERNAL_TEMPLATE_INSTANTIATION_NUMERIC (Expression)
 
 EXPLICIT_TEMPLATE_INSTANTIATION_NUMERIC (ExpressionCell)
 
 EXPLICIT_TEMPLATE_INSTANTIATION_NUMERIC (UnaryExpressionCell)
 
 EXPLICIT_TEMPLATE_INSTANTIATION_NUMERIC (BinaryExpressionCell)
 
 EXPLICIT_TEMPLATE_INSTANTIATION_NUMERIC (ExpressionConstant)
 
 EXPLICIT_TEMPLATE_INSTANTIATION_NUMERIC (ExpressionVar)
 
 EXPLICIT_TEMPLATE_INSTANTIATION_NUMERIC (ExpressionNaN)
 
 EXPLICIT_TEMPLATE_INSTANTIATION_NUMERIC (ExpressionAdd)
 
 EXPLICIT_TEMPLATE_INSTANTIATION_NUMERIC (ExpressionMul)
 
 EXPLICIT_TEMPLATE_INSTANTIATION_NUMERIC (ExpressionPow)
 
 EXPLICIT_TEMPLATE_INSTANTIATION_NUMERIC (ExpressionDiv)
 
 EXPLICIT_TEMPLATE_INSTANTIATION_NUMERIC (ExpressionAddFactory)
 
 EXPLICIT_TEMPLATE_INSTANTIATION_NUMERIC (ExpressionMulFactory)
 
std::ostream & operator<< (std::ostream &os, const ExpressionKind &kind)
 
bool operator< (ExpressionKind k1, ExpressionKind k2)
 
template<>
bool is_integer (const int &v)
 
template<>
bool is_integer (const long &v)
 
template<>
bool is_integer (const float &v)
 
template<>
bool is_integer (const double &v)
 
template<>
int pow (const int &base, const int &exponent)
 
template<>
long pow (const long &base, const long &exponent)
 
template<>
float pow (const float &base, const float &exponent)
 
template<>
double pow (const double &base, const double &exponent)
 
template<class T >
bool is_integer (const T &v)
 
template<class T >
pow (const T &base, const T &exponent)
 
std::ostream & operator<< (std::ostream &os, const Variable &var)
 
std::ostream & operator<< (std::ostream &os, Variable::Type type)
 
Variables operator+ (const Variable &var, Variables vars)
 
std::ostream & operator<< (std::ostream &os, const Variables &vars)
 
template<InvocableHashAlgorithm HashAlgorithm, Hashable< HashAlgorithm > T>
void hash_append (HashAlgorithm &hasher, const T &hashable) noexcept
 
void hash_append (InvocableHashAlgorithm auto &hasher, const std::integral auto &item) noexcept
 
template<class T >
void hash_append (InvocableHashAlgorithm auto &hasher, const T *item) noexcept
 
void hash_append (InvocableHashAlgorithm auto &hasher, const IsEnum auto &item) noexcept
 
template<std::floating_point T>
void hash_append (InvocableHashAlgorithm auto &hasher, const T &item) noexcept
 
template<class Traits , class Allocator >
void hash_append (InvocableHashAlgorithm auto &hasher, const std::basic_string< char, Traits, Allocator > &item) noexcept
 
template<class T1 , class T2 >
void hash_append (InvocableHashAlgorithm auto &hasher, const std::pair< T1, T2 > &item) noexcept
 
template<class T >
void hash_append (InvocableHashAlgorithm auto &hasher, const std::optional< T > &item) noexcept
 
template<class T1 , class T2 , class Compare , class Allocator >
void hash_append (InvocableHashAlgorithm auto &hasher, const std::map< T1, T2, Compare, Allocator > &item) noexcept
 
template<class Key , class Compare , class Allocator >
void hash_append (InvocableHashAlgorithm auto &hasher, const std::set< Key, Compare, Allocator > &item) noexcept
 
template<class Iter >
void hash_append_range (InvocableHashAlgorithm auto &hasher, Iter begin, Iter end) noexcept
 
std::shared_ptr< spdlog::logger > get_logger (const bool to_stdout)
 
std::ostream & operator<< (std::ostream &os, const Stats &stats)
 
std::ostream & operator<< (std::ostream &os, const IterationStats &stats)
 

Variables

std::map< ExpressionKind, std::string > expression_kind_to_string
 

Detailed Description

ExpressionKind enum.

Hash functions.

Variable class.

ExpressionVisitor class.

Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license

The main namespace for the smats library.

Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license
Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license Environment class

Represents a symbolic environment (mapping from a variable to a value).

Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license Expression class.
Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license ExpressionCell class and its subclasses.
Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license ExpressionCell factory classes
Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license
Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license

Kinds of symbolic expressions.

Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license

Base class for expression visitors.

Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license Symbolic utilities.

A collection of utilities to work with symbolic expressions and formulas.

Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license

Represents a symbolic variable. A symbolic variable is a named entity that can take a value from a specific domain.

Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license Collection of concepts used in the smats library.

Utility file that contains c++20 concepts used in the smats library in order to make the code more readable and to provide better error messages.

Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license Custom exception classes.

This file contains the definition of the custom exception classes. They inherit from std::exception and override the what() method, returning a custom message to aid in debugging.

Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license

smats implements the hash_append pattern as described by N3980, based on Drake's implementation. For more information, refer to N3980.

To provide hash_append support within a class, the class must implement a hash_append function. The function appends every hash-relevant member field into the hasher.

class MyValue {
public:
...
* Implements the @ref hash_append concept.
template <class HashAlgorithm>
friend void hash_append(
HashAlgorithm& hasher, const MyValue& item) noexcept {
hash_append(hasher, item.my_data_);
}
...
private:
std::string my_data_;
};
void hash_append(HashAlgorithm &hasher, const T &hashable) noexcept
Definition hash.hpp:79

Checklist for reviewing a hash_append implementation:

  • The function cites @ref hash_append in its Doxygen comment.
  • The function is marked noexcept.

To use hashable types, Drake types may be used in unordered collections:

std::unordered_set<MyValue, smats::DefaultHash> foo;

Some types may also choose to specialize std::hash<MyValue> to use DefaultHash, so that the second template argument to std::unordered_set can be omitted. For example smats::Expression header states:

namespace std {
struct hash<smats::Expression> : public smats::DefaultHash {};
} // namespace std
Definition expression.h:185
ExpressionKind enum.
Definition gmp.cpp:14
Definition hash.hpp:265

so that users are able to simply write:

std::unordered_set<smats::Expression> foo;
Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license Logging macros. Allows logging with different verbosity levels using spdlog.

The verbosity level is set with the –verbosity flag. The verbosity level is an integer between 0 and 5. The higher the verbosity level, the more information is logged. If another value is provided, the logging is turned off.

Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license Stats class. Used as a base class for more specialized stats classes.

Simple dataclass to store the statistics of a solver run.

Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license Timer classes.

The Timer class is a simple timer class to evaluate the performance of the software. The TimerGuard class wraps a timer object and pauses it when the guard object is destructed.

Author
Ernesto Casablanca (casab.nosp@m.lanc.nosp@m.aerne.nosp@m.sto@.nosp@m.gmail.nosp@m..com)
Licence:
Apache-2.0 license Visitor class.

Base class for visitors.

Typedef Documentation

◆ chosen_steady_clock

using smats::chosen_steady_clock
Initial value:
std::conditional<std::chrono::high_resolution_clock::is_steady,
std::chrono::high_resolution_clock, std::chrono::steady_clock>::type

Enumeration Type Documentation

◆ ExpressionKind

enum class smats::ExpressionKind
strong

Kinds of symbolic expressions.

Enumerator
Constant 

constant (double)

Var 

variable

Add 

addition (+)

Mul 

multiplication (*)

Div 

division (/)

Log 

logarithms

Abs 

absolute value function

Exp 

exponentiation

Sqrt 

square root

Pow 

power function

Sin 

sine

Cos 

cosine

Tan 

tangent

Asin 

arcsine

Acos 

arccosine

Atan 

arctangent

Atan2 

arctangent2 (atan2(y,x) = atan(y/x))

Sinh 

hyperbolic sine

Cosh 

hyperbolic cosine

Tanh 

hyperbolic tangent

Min 

min

Max 

max

Ceil 

ceil

Floor 

floor

IfThenElse 

if then else

NaN 

NaN.

UninterpretedFunction 

Uninterpreted function.

Function Documentation

◆ hash_append() [1/10]

template<InvocableHashAlgorithm HashAlgorithm, Hashable< HashAlgorithm > T>
void smats::hash_append ( HashAlgorithm & hasher,
const T & hashable )
noexcept

Hash append implementation for an object that implements the Hashable concept.

Template Parameters
InvocableHashAlgorithmHashAlgorithm type of the hash algorithm to use
Hashablehashable type
Parameters
hasherhash algorithm
hashableobject to hash

◆ hash_append() [2/10]

void smats::hash_append ( InvocableHashAlgorithm auto & hasher,
const IsEnum auto & item )
noexcept

Hash append implementation for enum types

Template Parameters
InvocableHashAlgorithmtype of the hash algorithm to use
IsEnumenum type
Parameters
hasherhash algorithm
itemenum to hash

◆ hash_append() [3/10]

template<class Traits , class Allocator >
void smats::hash_append ( InvocableHashAlgorithm auto & hasher,
const std::basic_string< char, Traits, Allocator > & item )
noexcept

Hash append implementation for std::string

Template Parameters
InvocableHashAlgorithmtype of the hash algorithm to use
Traitsstring traits
Allocatorstring allocator
Parameters
hasherhash algorithm
itemstring to hash

◆ hash_append() [4/10]

void smats::hash_append ( InvocableHashAlgorithm auto & hasher,
const std::integral auto & item )
noexcept

Hash append implementation for integral types

Template Parameters
InvocableHashAlgorithmtype of the hash algorithm to use
std::integralintegral type
Parameters
hasherhash algorithm
itemintegral to hash

◆ hash_append() [5/10]

template<class T1 , class T2 , class Compare , class Allocator >
void smats::hash_append ( InvocableHashAlgorithm auto & hasher,
const std::map< T1, T2, Compare, Allocator > & item )
noexcept

Hash append implementation for std::map

Note
There is no hash_append overload for std::unordered_map. See N3980 for details.
Template Parameters
InvocableHashAlgorithmtype of the hash algorithm to use
T1key type
T2value type
Comparecomparison function
Allocatorallocator
Parameters
hasherhash algorithm
itemmap to hash

◆ hash_append() [6/10]

template<class T >
void smats::hash_append ( InvocableHashAlgorithm auto & hasher,
const std::optional< T > & item )
noexcept

Hash append implementation for std::optional

Note
std::hash<std::optional<T>> provides the peculiar invariant that the hash of an optional bearing a value v shall evaluate to the same hash as that of the value v itself. Hash operations implemented with this hash_append do not provide that invariant.
Template Parameters
InvocableHashAlgorithmtype of the hash algorithm to use
Ttype of the optional
Parameters
hasherhash algorithm
itemoptional to hash

◆ hash_append() [7/10]

template<class T1 , class T2 >
void smats::hash_append ( InvocableHashAlgorithm auto & hasher,
const std::pair< T1, T2 > & item )
noexcept

Hash append implementation for a pair

Template Parameters
InvocableHashAlgorithmtype of the hash algorithm to use
T1type of the first element
T2type of the second element
Parameters
hasherhash algorithm
itempair to hash

◆ hash_append() [8/10]

template<class Key , class Compare , class Allocator >
void smats::hash_append ( InvocableHashAlgorithm auto & hasher,
const std::set< Key, Compare, Allocator > & item )
noexcept

Hash append implementation for std::set

Note
There is no hash_append overload for std::unordered_set. See N3980 for details.
Template Parameters
InvocableHashAlgorithmtype of the hash algorithm to use
Keykey type
Comparecomparison function
Allocatorallocator
Parameters
hasherhash algorithm
itemset to hash

◆ hash_append() [9/10]

template<std::floating_point T>
void smats::hash_append ( InvocableHashAlgorithm auto & hasher,
const T & item )
noexcept

Hash append implementation for floating point types

Template Parameters
InvocableHashAlgorithmtype of the hash algorithm to use
std::floating_pointT floating point type
Parameters
hasherhash algorithm
itemfloating point to hash

◆ hash_append() [10/10]

template<class T >
void smats::hash_append ( InvocableHashAlgorithm auto & hasher,
const T * item )
noexcept

Hash append implementation for pointer types

Template Parameters
InvocableHashAlgorithmtype of the hash algorithm to use
Tany type
Parameters
hasherhash algorithm
itempointer to hash

◆ is_integer()

template<class T >
bool smats::is_integer ( const T & v)

Helper function to check if a value v is an integer.

A value is an integer if it is in the range of [int_min, int_max] and its fractional part is zero.

Template Parameters
Ttype of the value
Parameters
vvalue to check
Returns
true if v can be represented as an integer
false if v cannot be represented as an integer

◆ pow()

template<class T >
T smats::pow ( const T & base,
const T & exponent )

Helper function to evaluate the value of base raised to the power of exponent.

It supports more types than std::pow.

Template Parameters
Ttype of the value
Parameters
basebase value
exponentexponent value
Returns
the value of base raised to the power of exponent

Variable Documentation

◆ expression_kind_to_string

std::map<ExpressionKind, std::string> smats::expression_kind_to_string
Initial value:
= {
{ExpressionKind::Constant, "Constant"},
{ExpressionKind::Var, "Var"},
{ExpressionKind::Add, "Add"},
{ExpressionKind::Mul, "Mul"},
{ExpressionKind::Div, "Div"},
{ExpressionKind::Pow, "Pow"},
{ExpressionKind::Sin, "Sin"},
{ExpressionKind::Cos, "Cos"},
{ExpressionKind::Tan, "Tan"},
{ExpressionKind::Asin, "Asin"},
{ExpressionKind::Acos, "Acos"},
{ExpressionKind::Atan, "Atan"},
{ExpressionKind::Atan2, "Atan2"},
{ExpressionKind::Sinh, "Sinh"},
{ExpressionKind::Cosh, "Cosh"},
{ExpressionKind::Tanh, "Tanh"},
{ExpressionKind::Log, "Log"},
{ExpressionKind::Exp, "Exp"},
{ExpressionKind::Sqrt, "Sqrt"},
{ExpressionKind::Abs, "Abs"},
{ExpressionKind::Floor, "Floor"},
{ExpressionKind::Ceil, "Ceil"},
{ExpressionKind::Min, "Min"},
{ExpressionKind::Max, "Max"},
{ExpressionKind::IfThenElse, "IfThenElse"},
{ExpressionKind::NaN, "NaN"},
{ExpressionKind::UninterpretedFunction, "UninterpretedFunction"}}