1 // {{{ MIT License
2 
3 // Copyright 2017 Roland Kaminski
4 
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to
7 // deal in the Software without restriction, including without limitation the
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 // sell copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 // IN THE SOFTWARE.
22 
23 // }}}
24 
25 #include "gringo/input/literals.hh"
26 #include "gringo/ground/literals.hh"
27 #include "gringo/output/output.hh"
28 #include "gringo/utility.hh"
29 
30 namespace Gringo { namespace Input {
31 
32 // {{{1 definition of Literal::projectScore
33 
projectScore() const34 unsigned RelationLiteral::projectScore() const {
35     return left->projectScore() + right->projectScore();
36 }
37 
38 // {{{1 definition of Literal::print
39 
print(std::ostream & out) const40 inline void RelationLiteral::print(std::ostream &out) const  { out << *left << rel << *right; }
print(std::ostream & out) const41 inline void RangeLiteral::print(std::ostream &out) const     { out << "#range(" << *assign << "," << *lower << "," << *upper << ")"; }
print(std::ostream & out) const42 inline void FalseLiteral::print(std::ostream &out) const     { out << "#false"; }
print(std::ostream & out) const43 inline void ScriptLiteral::print(std::ostream &out) const    {
44     out << "#script(" << *assign << "," << name << "(";
45     print_comma(out, args, ",", [](std::ostream &out, UTerm const &term) { out << *term; });
46     out << ")";
47 }
print(std::ostream & out) const48 inline void CSPLiteral::print(std::ostream &out) const {
49     assert(!terms.empty());
50     if (auxiliary()) { out << "["; }
51     out << terms.front().term;
52     for (auto it = terms.begin() + 1, ie = terms.end(); it != ie; ++it) { out << *it; }
53     if (auxiliary()) { out << "]"; }
54 }
55 
56 // {{{1 definition of Literal::clone
57 
clone() const58 RelationLiteral *RelationLiteral::clone() const {
59     return make_locatable<RelationLiteral>(loc(), rel, get_clone(left), get_clone(right)).release();
60 }
clone() const61 RangeLiteral *RangeLiteral::clone() const {
62     return make_locatable<RangeLiteral>(loc(), get_clone(assign), get_clone(lower), get_clone(upper)).release();
63 }
clone() const64 FalseLiteral *FalseLiteral::clone() const {
65     return make_locatable<FalseLiteral>(loc()).release();
66 }
clone() const67 ScriptLiteral *ScriptLiteral::clone() const {
68     return make_locatable<ScriptLiteral>(loc(), get_clone(assign), name, get_clone(args)).release();
69 }
clone() const70 CSPLiteral *CSPLiteral::clone() const {
71     return make_locatable<CSPLiteral>(loc(), get_clone(terms)).release();
72 }
73 
74 // {{{1 definition of Literal::simplify
75 
simplify(Logger & log,Projections &,SimplifyState & state,bool,bool)76 bool RelationLiteral::simplify(Logger &log, Projections &, SimplifyState &state, bool, bool) {
77     if (left->simplify(state, false, false, log).update(left, false).undefined()) { return false; }
78     if (right->simplify(state, false, false, log).update(right, false).undefined()) { return false; }
79     return true;
80 }
simplify(Logger &,Projections &,SimplifyState &,bool,bool)81 bool RangeLiteral::simplify(Logger &, Projections &, SimplifyState &, bool, bool) {
82     throw std::logic_error("RangeLiteral::simplify should never be called  if used properly");
83 }
simplify(Logger &,Projections &,SimplifyState &,bool,bool)84 bool FalseLiteral::simplify(Logger &, Projections &, SimplifyState &, bool, bool) { return true; }
simplify(Logger &,Projections &,SimplifyState &,bool,bool)85 bool ScriptLiteral::simplify(Logger &, Projections &, SimplifyState &, bool, bool) {
86     throw std::logic_error("ScriptLiteral::simplify should never be called  if used properly");
87 }
simplify(Logger & log,Projections &,SimplifyState & state,bool,bool)88 bool CSPLiteral::simplify(Logger &log, Projections &, SimplifyState &state, bool, bool) {
89     for (auto &x : terms) {
90         if (!x.simplify(state, log)) { return false; };
91     }
92     return true;
93 }
94 
95 // {{{1 definition of Literal::collect
96 
collect(VarTermBoundVec & vars,bool bound) const97 void RelationLiteral::collect(VarTermBoundVec &vars, bool bound) const {
98     left->collect(vars, bound && rel == Relation::EQ);
99     right->collect(vars, false);
100 }
collect(VarTermBoundVec & vars,bool bound) const101 void RangeLiteral::collect(VarTermBoundVec &vars, bool bound) const {
102     assign->collect(vars, bound);
103     lower->collect(vars, false);
104     upper->collect(vars, false);
105 }
collect(VarTermBoundVec &,bool) const106 void FalseLiteral::collect(VarTermBoundVec &, bool) const { }
collect(VarTermBoundVec & vars,bool bound) const107 void ScriptLiteral::collect(VarTermBoundVec &vars, bool bound) const {
108     assign->collect(vars, bound);
109     for (auto &x : args) { x->collect(vars, false); }
110 }
collect(VarTermBoundVec & vars,bool) const111 void CSPLiteral::collect(VarTermBoundVec &vars, bool) const {
112     for (auto &x : terms) { x.collect(vars); }
113 }
114 
115 // {{{1 definition of Literal::operator==
116 
operator ==(Literal const & x) const117 inline bool RelationLiteral::operator==(Literal const &x) const {
118     auto t = dynamic_cast<RelationLiteral const *>(&x);
119     return t && rel == t->rel && is_value_equal_to(left, t->left) && is_value_equal_to(right, t->right);
120 }
operator ==(Literal const & x) const121 inline bool RangeLiteral::operator==(Literal const &x) const {
122     auto t = dynamic_cast<RangeLiteral const *>(&x);
123     return t && is_value_equal_to(assign, t->assign) && is_value_equal_to(lower, t->lower) && is_value_equal_to(upper, t->upper);
124 }
operator ==(Literal const & x) const125 inline bool FalseLiteral::operator==(Literal const &x) const {
126     return dynamic_cast<FalseLiteral const *>(&x) != nullptr;
127 }
operator ==(Literal const & x) const128 inline bool ScriptLiteral::operator==(Literal const &x) const {
129     auto t = dynamic_cast<ScriptLiteral const *>(&x);
130     return t && is_value_equal_to(assign, t->assign) && name == t->name && is_value_equal_to(args, t->args);
131 }
operator ==(Literal const & x) const132 inline bool CSPLiteral::operator==(Literal const &x) const {
133     auto t = dynamic_cast<CSPLiteral const *>(&x);
134     return t && is_value_equal_to(terms, t->terms) && (auxiliary_ == t->auxiliary_);
135 }
136 
137 // {{{1 definition of Literal::rewriteArithmetics
138 
rewriteArithmetics(Term::ArithmeticsMap & arith,AssignVec & assign,AuxGen & auxGen)139 void RelationLiteral::rewriteArithmetics(Term::ArithmeticsMap &arith, AssignVec &assign, AuxGen &auxGen) {
140     if (rel == Relation::EQ) {
141         if (right->hasVar()) {
142             assign.emplace_back(get_clone(right), get_clone(left));
143             Term::replace(assign.back().first, assign.back().first->rewriteArithmetics(arith, auxGen));
144         }
145         Term::replace(left, left->rewriteArithmetics(arith, auxGen));
146     }
147 }
rewriteArithmetics(Term::ArithmeticsMap & arith,AssignVec &,AuxGen & auxGen)148 void RangeLiteral::rewriteArithmetics(Term::ArithmeticsMap &arith, AssignVec &, AuxGen &auxGen) {
149     Term::replace(this->assign, this->assign->rewriteArithmetics(arith, auxGen));
150 }
rewriteArithmetics(Term::ArithmeticsMap &,AssignVec &,AuxGen &)151 void FalseLiteral::rewriteArithmetics(Term::ArithmeticsMap &, AssignVec &, AuxGen &) { }
rewriteArithmetics(Term::ArithmeticsMap & arith,AssignVec &,AuxGen & auxGen)152 void ScriptLiteral::rewriteArithmetics(Term::ArithmeticsMap &arith, AssignVec &, AuxGen &auxGen) {
153     Term::replace(this->assign, this->assign->rewriteArithmetics(arith, auxGen));
154 }
rewriteArithmetics(Term::ArithmeticsMap & arith,AssignVec &,AuxGen & auxGen)155 void CSPLiteral::rewriteArithmetics(Term::ArithmeticsMap &arith, AssignVec &, AuxGen &auxGen) {
156     for (auto &x : terms) { x.rewriteArithmetics(arith, auxGen); }
157 }
158 
159 // {{{1 definition of Literal::hash
160 
hash() const161 inline size_t RelationLiteral::hash() const {
162     return get_value_hash(typeid(RelationLiteral).hash_code(), size_t(rel), left, right);
163 }
hash() const164 inline size_t RangeLiteral::hash() const {
165     return get_value_hash(typeid(RangeLiteral).hash_code(), assign, lower, upper);
166 }
hash() const167 inline size_t FalseLiteral::hash() const {
168     return get_value_hash(typeid(FalseLiteral).hash_code());
169 }
hash() const170 inline size_t ScriptLiteral::hash() const {
171     return get_value_hash(typeid(RangeLiteral).hash_code(), assign, name, args);
172 }
hash() const173 inline size_t CSPLiteral::hash() const {
174     return get_value_hash(typeid(CSPLiteral).hash_code(), terms);
175 }
176 
177 // {{{1 definition of Literal::unpool
178 
unpool(bool) const179 ULitVec RelationLiteral::unpool(bool) const {
180     ULitVec value;
181     auto f = [&](UTerm &&l, UTerm &&r) { value.emplace_back(make_locatable<RelationLiteral>(loc(), rel, std::move(l), std::move(r))); };
182     Term::unpool(left, right, Gringo::unpool, Gringo::unpool, f);
183     return value;
184 }
unpool(bool) const185 ULitVec RangeLiteral::unpool(bool) const {
186     ULitVec value;
187     value.emplace_back(ULit(clone()));
188     return value;
189 }
unpool(bool) const190 ULitVec FalseLiteral::unpool(bool) const {
191     ULitVec value;
192     value.emplace_back(ULit(clone()));
193     return value;
194 }
unpool(bool) const195 ULitVec ScriptLiteral::unpool(bool) const {
196     ULitVec value;
197     value.emplace_back(ULit(clone()));
198     return value;
199 }
unpool(bool beforeRewrite) const200 ULitVec CSPLiteral::unpool(bool beforeRewrite) const {
201     using namespace std::placeholders;
202     ULitVec value;
203     auto f = [&](Terms &&args)                { value.emplace_back(make_locatable<CSPLiteral>(loc(), std::move(args))); };
204     auto unpoolLit = [&](CSPLiteral const &x) { Term::unpool(x.terms.begin(), x.terms.end(), std::bind(&CSPRelTerm::unpool, _1), f); };
205     if (!beforeRewrite) {
206         for (auto it = terms.begin() + 1, ie = terms.end(); it != ie; ++it) {
207             unpoolLit(*make_locatable<CSPLiteral>(loc(), it->rel, get_clone((it-1)->term), get_clone(it->term)));
208         }
209     }
210     else { unpoolLit(*this); }
211     return value;
212 }
213 
214 // {{{1 definition of Literal::toTuple
215 
toTuple(UTermVec & tuple,int & id)216 void RelationLiteral::toTuple(UTermVec &tuple, int &id) {
217     tuple.emplace_back(make_locatable<ValTerm>(loc(), Symbol::createNum(id+3)));
218     tuple.emplace_back(get_clone(left));
219     tuple.emplace_back(get_clone(right));
220     id++;
221 }
toTuple(UTermVec &,int &)222 void RangeLiteral::toTuple(UTermVec &, int &) {
223     throw std::logic_error("RangeLiteral::toTuple should never be called  if used properly");
224 }
toTuple(UTermVec & tuple,int & id)225 void FalseLiteral::toTuple(UTermVec &tuple, int &id) {
226     tuple.emplace_back(make_locatable<ValTerm>(loc(), Symbol::createNum(id+3)));
227     id++;
228 }
toTuple(UTermVec &,int &)229 void ScriptLiteral::toTuple(UTermVec &, int &) {
230     throw std::logic_error("ScriptLiteral::toTuple should never be called  if used properly");
231 }
toTuple(UTermVec & tuple,int & id)232 void CSPLiteral::toTuple(UTermVec &tuple, int &id) {
233     VarTermSet vars;
234     for (auto &x : terms) { x.collect(vars); }
235     tuple.emplace_back(make_locatable<ValTerm>(loc(), Symbol::createNum(id+3)));
236     for (auto &x : vars) { tuple.emplace_back(UTerm(x.get().clone())); }
237     id++;
238 }
239 
240 // {{{1 definition of Literal::isEDB
241 
isEDB() const242 Symbol Literal::isEDB() const          { return {}; }
243 
244 // {{{1 definition of Literal::hasPool
245 
hasPool(bool) const246 inline bool RelationLiteral::hasPool(bool) const  { return left->hasPool() || right->hasPool(); }
hasPool(bool) const247 inline bool RangeLiteral::hasPool(bool) const                   { return false; }
hasPool(bool) const248 inline bool FalseLiteral::hasPool(bool) const                   { return false; }
hasPool(bool) const249 inline bool ScriptLiteral::hasPool(bool) const                  { return false; }
hasPool(bool beforeRewrite) const250 inline bool CSPLiteral::hasPool(bool beforeRewrite) const       {
251     if (beforeRewrite) {
252         for (auto &x : terms) {
253             if (x.hasPool()) { return true; }
254         }
255         return false;
256     }
257     else { return terms.size() > 2; }
258 }
259 
260 // {{{1 definition of Literal::replace
261 
replace(Defines & x)262 inline void RelationLiteral::replace(Defines &x) {
263     Term::replace(left, left->replace(x, true));
264     Term::replace(right, right->replace(x, true));
265 }
replace(Defines & x)266 inline void RangeLiteral::replace(Defines &x) {
267     Term::replace(assign, assign->replace(x, true));
268     Term::replace(lower, lower->replace(x, true));
269     Term::replace(upper, upper->replace(x, true));
270 }
replace(Defines &)271 inline void FalseLiteral::replace(Defines &) { }
replace(Defines & x)272 inline void ScriptLiteral::replace(Defines &x) {
273     Term::replace(assign, assign->replace(x, true));
274     for (auto &y : args) { Term::replace(y, y->replace(x, true)); }
275 }
replace(Defines & x)276 inline void CSPLiteral::replace(Defines &x) {
277     for (auto &y : terms) { y.replace(x); }
278 }
279 
280 // {{{1 definition of Literal::toGround
281 
toGround(DomainData &,bool) const282 inline Ground::ULit RelationLiteral::toGround(DomainData &, bool) const {
283     return gringo_make_unique<Ground::RelationLiteral>(rel, get_clone(left), get_clone(right));
284 }
toGround(DomainData &,bool) const285 inline Ground::ULit RangeLiteral::toGround(DomainData &, bool) const {
286     return gringo_make_unique<Ground::RangeLiteral>(get_clone(assign), get_clone(lower), get_clone(upper));
287 }
toGround(DomainData &,bool) const288 inline Ground::ULit FalseLiteral::toGround(DomainData &, bool) const {
289     throw std::logic_error("FalseLiteral::toGround: must not happen");
290 }
toGround(DomainData &,bool) const291 inline Ground::ULit ScriptLiteral::toGround(DomainData &, bool) const {
292     return gringo_make_unique<Ground::ScriptLiteral>(get_clone(assign), name, get_clone(args));
293 }
toGround(DomainData & data,bool auxiliary) const294 inline Ground::ULit CSPLiteral::toGround(DomainData &data, bool auxiliary) const {
295     assert(terms.size() == 2);
296     return gringo_make_unique<Ground::CSPLiteral>(data, auxiliary_ || auxiliary, terms[1].rel, get_clone(terms[0].term), get_clone(terms[1].term));
297 }
298 
299 // {{{1 definition of Literal::shift
300 
shift(bool negate)301 ULit RelationLiteral::shift(bool negate) {
302     return make_locatable<RelationLiteral>(loc(), negate ? neg(rel) : rel, std::move(left), std::move(right));
303 }
shift(bool)304 ULit RangeLiteral::shift(bool)  { throw std::logic_error("RangeLiteral::shift should never be called  if used properly"); }
shift(bool)305 ULit FalseLiteral::shift(bool)  { return nullptr; }
shift(bool)306 ULit ScriptLiteral::shift(bool) { throw std::logic_error("ScriptLiteral::shift should never be called  if used properly"); }
shift(bool negate)307 ULit CSPLiteral::shift(bool negate) {
308     if (negate) {
309         assert(terms.size() == 2);
310         return make_locatable<CSPLiteral>(loc(), neg(terms[1].rel), std::move(terms[0].term), std::move(terms[1].term));
311     }
312     else { return make_locatable<CSPLiteral>(loc(), std::move(terms)); }
313 }
314 
315 // {{{1 definition of Literal::headRepr
316 
headRepr() const317 UTerm RelationLiteral::headRepr() const {
318     throw std::logic_error("RelationLiteral::toTuple should never be called if used properly");
319 }
headRepr() const320 UTerm RangeLiteral::headRepr() const {
321     throw std::logic_error("RangeLiteral::toTuple should never be called if used properly");
322 }
headRepr() const323 UTerm FalseLiteral::headRepr() const {
324     return nullptr;
325 }
headRepr() const326 UTerm ScriptLiteral::headRepr() const {
327     throw std::logic_error("ScriptLiteral::toTuple should never be called if used properly");
328 }
headRepr() const329 UTerm CSPLiteral::headRepr() const {
330     throw std::logic_error("CSPLiteral::toTuple should never be called if used properly");
331 }
332 
333 // }}}1
334 
335 // {{{1 definition of PredicateLiteral
336 
PredicateLiteral(NAF naf,UTerm && repr,bool auxiliary)337 PredicateLiteral::PredicateLiteral(NAF naf, UTerm &&repr, bool auxiliary)
338 : naf(naf)
339 , auxiliary_(auxiliary)
340 , repr(std::move(repr)) {
341     if (!this->repr->isAtom()) {
342         throw std::runtime_error("atom expected");
343     }
344 }
345 
~PredicateLiteral()346 PredicateLiteral::~PredicateLiteral() { }
347 
projectScore() const348 unsigned PredicateLiteral::projectScore() const {
349     return 1 + repr->projectScore();
350 }
351 
print(std::ostream & out) const352 inline void PredicateLiteral::print(std::ostream &out) const {
353     if (auxiliary()) { out << "["; }
354     out << naf << *repr;
355     if (auxiliary()) { out << "]"; }
356 }
357 
clone() const358 PredicateLiteral *PredicateLiteral::clone() const {
359     return make_locatable<PredicateLiteral>(loc(), naf, get_clone(repr)).release();
360 }
361 
simplify(Logger & log,Projections & project,SimplifyState & state,bool positional,bool singleton)362 bool PredicateLiteral::simplify(Logger &log, Projections &project, SimplifyState &state, bool positional, bool singleton) {
363     if (singleton && positional && naf == NAF::POS) {
364         positional = false;
365     }
366     auto ret(repr->simplify(state, positional, false, log));
367     ret.update(repr, false);
368     if (ret.undefined()) { return false; }
369     if (repr->simplify(state, positional, false, log).update(repr, false).project) {
370         auto rep(project.add(*repr));
371         Term::replace(repr, std::move(rep));
372     }
373     return true;
374 }
375 
collect(VarTermBoundVec & vars,bool bound) const376 void PredicateLiteral::collect(VarTermBoundVec &vars, bool bound) const {
377     repr->collect(vars, bound && naf == NAF::POS);
378 }
379 
operator ==(Literal const & x) const380 inline bool PredicateLiteral::operator==(Literal const &x) const {
381     auto t = dynamic_cast<PredicateLiteral const *>(&x);
382     return t && naf == t->naf && is_value_equal_to(repr, t->repr) && (auxiliary_ == t->auxiliary_);
383 }
384 
rewriteArithmetics(Term::ArithmeticsMap & arith,AssignVec &,AuxGen & auxGen)385 void PredicateLiteral::rewriteArithmetics(Term::ArithmeticsMap &arith, AssignVec &, AuxGen &auxGen) {
386     if (naf == NAF::POS) { Term::replace(repr, repr->rewriteArithmetics(arith, auxGen)); }
387 }
388 
hash() const389 inline size_t PredicateLiteral::hash() const {
390     return get_value_hash(typeid(PredicateLiteral).hash_code(), size_t(naf), repr);
391 }
392 
unpool(bool) const393 ULitVec PredicateLiteral::unpool(bool) const {
394     ULitVec value;
395     auto f = [&](UTerm &&y){ value.emplace_back(make_locatable<PredicateLiteral>(loc(), naf, std::move(y))); };
396     Term::unpool(repr, Gringo::unpool, f);
397     return  value;
398 }
399 
toTuple(UTermVec & tuple,int &)400 void PredicateLiteral::toTuple(UTermVec &tuple, int &) {
401     int id = 0;
402     switch (naf) {
403         case NAF::POS:    { id = 0; break; }
404         case NAF::NOT:    { id = 1; break; }
405         case NAF::NOTNOT: { id = 2; break; }
406     }
407     tuple.emplace_back(make_locatable<ValTerm>(loc(), Symbol::createNum(id)));
408     tuple.emplace_back(get_clone(repr));
409 }
410 
isEDB() const411 Symbol PredicateLiteral::isEDB() const { return naf == NAF::POS ? repr->isEDB() : Symbol(); }
412 
hasPool(bool) const413 inline bool PredicateLiteral::hasPool(bool) const { return repr->hasPool(); }
414 
replace(Defines & x)415 inline void PredicateLiteral::replace(Defines &x) { Term::replace(repr, repr->replace(x, false)); }
416 
toGround(DomainData & x,bool auxiliary) const417 inline Ground::ULit PredicateLiteral::toGround(DomainData &x, bool auxiliary) const {
418     return gringo_make_unique<Ground::PredicateLiteral>(auxiliary_ || auxiliary, x.add(repr->getSig()), naf, get_clone(repr));
419 }
420 
shift(bool negate)421 ULit PredicateLiteral::shift(bool negate) {
422     if (naf == NAF::POS) { return nullptr; }
423     else {
424         NAF inv = (naf == NAF::NOT) == negate ? NAF::NOTNOT : NAF::NOT;
425         return make_locatable<PredicateLiteral>(loc(), inv, std::move(repr));
426     }
427 }
428 
headRepr() const429 UTerm PredicateLiteral::headRepr() const {
430     assert(naf == NAF::POS);
431     return get_clone(repr);
432 }
433 
434 // {{{1 definition of ProjectionLiteral
435 
ProjectionLiteral(UTerm && repr)436 ProjectionLiteral::ProjectionLiteral(UTerm &&repr)
437     : PredicateLiteral(NAF::POS, std::move(repr)), initialized_(false) { }
438 
~ProjectionLiteral()439 ProjectionLiteral::~ProjectionLiteral() { }
440 
clone() const441 ProjectionLiteral *ProjectionLiteral::clone() const {
442     throw std::logic_error("ProjectionLiteral::clone must not be called!!!");
443 }
444 
unpool(bool) const445 ULitVec ProjectionLiteral::unpool(bool) const {
446     throw std::logic_error("ProjectionLiteral::unpool must not be called!!!");
447 }
448 
toGround(DomainData & x,bool auxiliary) const449 inline Ground::ULit ProjectionLiteral::toGround(DomainData &x, bool auxiliary) const {
450     bool initialized = initialized_;
451     initialized_ = true;
452     return gringo_make_unique<Ground::ProjectionLiteral>(auxiliary_ || auxiliary, x.add(repr->getSig()), get_clone(repr), initialized);
453 }
454 
shift(bool)455 ULit ProjectionLiteral::shift(bool) {
456     throw std::logic_error("ProjectionLiteral::shift must not be called!!!");
457 }
458 
459 // {{{1 definition of RelationLiteral
460 
RelationLiteral(Relation rel,UTerm && left,UTerm && right)461 RelationLiteral::RelationLiteral(Relation rel, UTerm &&left, UTerm &&right)
462     : rel(rel)
463     , left(std::move(left))
464     , right(std::move(right)) { }
465 
make(Term::LevelMap::value_type & x)466 ULit RelationLiteral::make(Term::LevelMap::value_type &x) {
467     Location loc(x.first->loc());
468     return make_locatable<RelationLiteral>(loc, Relation::EQ, std::move(x.second), get_clone(x.first));
469 }
470 
make(Literal::AssignVec::value_type & x)471 ULit RelationLiteral::make(Literal::AssignVec::value_type &x) {
472     Location loc(x.first->loc() + x.second->loc());
473     return make_locatable<RelationLiteral>(loc, Relation::EQ, std::move(x.first), get_clone(x.second));
474 }
475 
~RelationLiteral()476 RelationLiteral::~RelationLiteral() { }
477 
478 // {{{1 definition of RangeLiteral
479 
RangeLiteral(UTerm && assign,UTerm && lower,UTerm && upper)480 RangeLiteral::RangeLiteral(UTerm &&assign, UTerm &&lower, UTerm &&upper)
481     : assign(std::move(assign))
482     , lower(std::move(lower))
483     , upper(std::move(upper)) { }
484 
make(SimplifyState::DotsMap::value_type & dot)485 ULit RangeLiteral::make(SimplifyState::DotsMap::value_type &dot) {
486     Location loc(std::get<0>(dot)->loc());
487     return make_locatable<RangeLiteral>(loc, std::move(std::get<0>(dot)), std::move(std::get<1>(dot)), std::move(std::get<2>(dot)));
488 }
489 
~RangeLiteral()490 RangeLiteral::~RangeLiteral() { }
491 
492 // {{{1 definition of FalseLiteral
493 
FalseLiteral()494 FalseLiteral::FalseLiteral() { }
~FalseLiteral()495 FalseLiteral::~FalseLiteral() { }
496 
497 // {{{1 definition of ScriptLiteral
498 
ScriptLiteral(UTerm && assign,String name,UTermVec && args)499 ScriptLiteral::ScriptLiteral(UTerm &&assign, String name, UTermVec &&args)
500     : assign(std::move(assign))
501     , name(name)
502     , args(std::move(args)) { }
503 
make(SimplifyState::ScriptMap::value_type & script)504 ULit ScriptLiteral::make(SimplifyState::ScriptMap::value_type &script) {
505     Location loc(std::get<0>(script)->loc());
506     return make_locatable<ScriptLiteral>(loc, std::move(std::get<0>(script)), std::move(std::get<1>(script)), std::move(std::get<2>(script)));
507 }
508 
~ScriptLiteral()509 ScriptLiteral::~ScriptLiteral() { }
510 
511 // {{{1 definition of CSPLiteral
512 
CSPLiteral(Relation rel,CSPAddTerm && left,CSPAddTerm && right)513 CSPLiteral::CSPLiteral(Relation rel, CSPAddTerm &&left, CSPAddTerm &&right) {
514     terms.emplace_back(rel, std::move(left));
515     terms.emplace_back(rel, std::move(right));
516 }
append(Relation rel,CSPAddTerm && x)517 void CSPLiteral::append(Relation rel, CSPAddTerm &&x) { terms.emplace_back(rel, std::move(x)); }
CSPLiteral(Terms && terms)518 CSPLiteral::CSPLiteral(Terms &&terms) : terms(std::move(terms)) { }
~CSPLiteral()519 CSPLiteral::~CSPLiteral() { }
520 
521 // }}}1
522 
523 } } // namespace Input Gringo
524 
525