|
enum | Invertibility { CONSTANT = 0,
INVERTIBLE = 1,
NOT_INVERTIBLE = 2
} |
|
using | ProjectRet = std::tuple< UTerm, UTerm, UTerm > |
| Return value of Term::project (replace, projected, project). More...
|
|
using | SVal = std::shared_ptr< Value > |
|
using | VarSet = std::unordered_set< FWString > |
|
using | RenameMap = std::unordered_map< FWString, std::pair< FWString, SVal >> |
|
using | ReferenceMap = std::unordered_map< Term *, SGRef, value_hash< Term * >, value_equal_to< Term * >> |
|
using | DotsMap = std::vector< std::tuple< UTerm, UTerm, UTerm >> |
| Type that stores for each rewritten DotsTerm the associated variable and the lower and upper bound. More...
|
|
using | ScriptMap = std::vector< std::tuple< UTerm, FWString, UTermVec >> |
|
using | ArithmeticsMap = std::vector< std::unordered_map< UTerm, UTerm, value_hash< UTerm >, value_equal_to< UTerm >>> |
|
|
virtual bool | hasVar () const =0 |
| Whether the term contains a VarTerm. More...
|
|
virtual void | rename (FWString name)=0 |
|
virtual void | unpool (UTermVec &x) const =0 |
|
virtual SimplifyRet | simplify (DotsMap &dots, ScriptMap &scripts, unsigned &auxNum, bool positional, bool arithmetic)=0 |
|
virtual ProjectRet | project (bool rename, unsigned &auxNum)=0 |
|
virtual bool | isNotNumeric () const =0 |
|
virtual Invertibility | getInvertibility () const =0 |
|
virtual Value | eval () const =0 |
|
bool | isZero () const |
|
virtual void | collect (VarTermBoundVec &vars, bool bound) const =0 |
|
virtual void | collect (VarTermSet &vars) const |
|
virtual void | collect (VarSet &vars, unsigned minLevel=0, unsigned maxLevel=std::numeric_limits< unsigned >::max()) const =0 |
|
virtual void | collectIds (VarSet &vars) const =0 |
|
virtual unsigned | getLevel () const =0 |
|
virtual UTerm | rewriteArithmetics (ArithmeticsMap &arith, unsigned &auxNum)=0 |
|
virtual bool | match (Value const &val) const =0 |
|
bool | bind (VarSet &bound) |
|
virtual FWSignature | getSig () const =0 |
|
virtual UTerm | renameVars (RenameMap &names) const =0 |
|
SGRef | _newRef (RenameMap &names, ReferenceMap &refs) const |
|
UGTerm | gterm () const |
|
virtual bool | hasPool () const =0 |
|
virtual UGTerm | gterm (RenameMap &names, ReferenceMap &refs) const =0 |
|
virtual UTerm | replace (Defines &defs, bool replace)=0 |
|
virtual double | estimate (double size, VarSet const &bound) const =0 |
|
virtual Value | isEDB () const =0 |
|
virtual | ~Term () |
|
template<class T , class U , class V > |
void | replace (std::unique_ptr< T > &dst, std::unique_ptr< U > &&src, std::unique_ptr< V > &&alt) |
|
template<class It , class TermUnpool , class Callback > |
void | unpool (It const &begin, It const &end, TermUnpool const &f, Callback const &g) |
|
template<class Vec , class TermUnpool > |
void | unpoolJoin (Vec &vec, TermUnpool const &f) |
|
virtual void | print (std::ostream &out) const =0 |
|
virtual | ~Printable () |
|
virtual size_t | hash () const =0 |
|
virtual | ~Hashable () |
|
virtual Location const & | loc () const =0 |
|
virtual void | loc (Location const &loc)=0 |
|
virtual | ~Locatable () |
|
virtual bool | operator== (Termconst &other) const =0 |
|
virtual bool | operator!= (Termconst &other) const |
|
virtual | ~Comparable () |
|
virtual Term * | clone () const =0 |
|
virtual | ~Clonable () |
|
|
static FWString | uniqueName (unsigned &auxNum, char const *prefix="#X") |
| Creates a unique variable name. More...
|
|
static UTerm | uniqueVar (Location const &loc, unsigned &auxNum, unsigned level=0, const char *prefix="#X") |
| Creates a unique variable using #aux(auxNum) as name. More...
|
|
static UTerm | uniqueVal (Location const &loc, unsigned &auxNum, const char *prefix="#X") |
|
static UTerm | insert (ArithmeticsMap &arith, unsigned &auxNum, UTerm &&term) |
| Inserts a term into arith creating a new unique variable if necessary. More...
|
|
template<class T , class U > |
static void | replace (std::unique_ptr< T > &dst, std::unique_ptr< U > &&src) |
| Set dst to src if src is non-zero. More...
|
|
template<class A , class UnpoolA , class Callback > |
static void | unpool (A const &a, UnpoolA const &fA, Callback const &g) |
| Unpools a, calling g on each obtained element. More...
|
|
template<class A , class B , class UnpoolA , class UnpoolB , class Callback > |
static void | unpool (A const &a, B const &b, UnpoolA const &fA, UnpoolB const &fB, Callback const &g) |
| Unpools a and b, calculates cross product, calling g on each obtained tuple. More...
|
|
template<class It , class Unpool , class Callback > |
static void | unpool (It const &begin, It const &end, Unpool const &f, Callback const &g) |
| Iterates of [begin, end] unpooling with f, calculates cross product, calling g on each obtained tuple. More...
|
|
template<class Vec , class Unpool > |
static void | unpoolJoin (Vec &vec, Unpool const &f) |
| Unpools each element of vec using f, and move the union of all pools back to f. More...
|
|
virtual ProjectRet Gringo::Term::project |
( |
bool |
rename, |
|
|
unsigned & |
auxNum |
|
) |
| |
|
pure virtual |
Removes anonymous variables in projectable positions (in outermost function symbols) from a term. The first element of the return value is a replacement term for the current term, which might be null if the term does not have to be replace.. The second and third can be used to create a projection rule where the second is the head and the third is the body element.
- Precondition
- Must be called after simplify.
num = 0; sig = base;
lit = q(X,_)
(
lit', projected, project) = lit.project(&sig, num)
assert(lit' == #p_q(base,X,#
p))
assert(projected == #p_q(base,#X1,#
p))
assert(
project == #p_q(base,#X1,#Y2))
Implemented in Gringo::LinearTerm, Gringo::FunctionTerm, Gringo::LuaTerm, Gringo::DotsTerm, Gringo::BinOpTerm, Gringo::UnOpTerm, Gringo::VarTerm, Gringo::ValTerm, and Gringo::PoolTerm.
template<class A , class B , class UnpoolA , class UnpoolB , class Callback >
void Gringo::Term::unpool |
( |
A const & |
a, |
|
|
B const & |
b, |
|
|
UnpoolA const & |
fA, |
|
|
UnpoolB const & |
fB, |
|
|
Callback const & |
g |
|
) |
| |
|
static |
Unpools a and b, calculates cross product, calling g on each obtained tuple.
template<class It , class Unpool , class Callback >
static void Gringo::Term::unpool |
( |
It const & |
begin, |
|
|
It const & |
end, |
|
|
Unpool const & |
f, |
|
|
Callback const & |
g |
|
) |
| |
|
static |
Iterates of [begin, end] unpooling with f, calculates cross product, calling g on each obtained tuple.