clingo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
logic_program.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2013 Benjamin Kaufmann
3 //
4 // This file is part of Clasp. See http://www.cs.uni-potsdam.de/clasp/
5 //
6 // Clasp is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // Clasp is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with Clasp; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 //
20 
21 #ifndef CLASP_LOGIC_PROGRAM_H_INCLUDED
22 #define CLASP_LOGIC_PROGRAM_H_INCLUDED
23 
24 #ifdef _MSC_VER
25 #pragma once
26 #endif
27 
29 #include <clasp/program_builder.h>
30 #include <clasp/util/misc_types.h>
31 #include <map>
32 
33 namespace Clasp { namespace Asp {
35 class LpStats {
36 public:
37  typedef std::pair<uint32, uint32> RPair;
38  LpStats() { reset(); }
39  void reset();
41  uint32 eqs(VarType t) const { return eqs_[t-1]; }
42  uint32 rules() const;
43  RPair rules(RuleType t) const { return rules_[ruleIndex(t)]; }
44  RPair& rules(RuleType t) { return rules_[ruleIndex(t)]; }
45  bool tr() const { return rules_[0].first != rules_[0].second; }
46  void incEqs(VarType t) { ++eqs_[t-1]; }
47  void upRule(RuleType t, int32 i) { RPair& x = rules_[ruleIndex(t)]; x.first += i; x.second += i; }
48  void trRule(RuleType t, uint32 i) { --rules_[ruleIndex(t)].second; rules_[0].first -= i; }
49  void accu(const LpStats& o);
50  double operator[](const char* key) const;
51  static const char* keys(const char* path);
52  uint32 bodies;
53  uint32 atoms;
54  uint32 auxAtoms;
55  uint32 sccs;
56  uint32 nonHcfs;
57  uint32 gammas;
58  uint32 ufsNodes;
59 private:
60  uint32 eqs_[3];
61  RPair rules_[NUM_RULE_TYPES];
62 };
64 class RedefinitionError : public std::logic_error {
65 public:
66  explicit RedefinitionError(unsigned atomId, const char* atomName = "");
67  unsigned atom() const { return atomId_; }
68 private:
69  unsigned atomId_;
70 };
71 
73 
77 class LogicProgram : public ProgramBuilder {
78 public:
79  LogicProgram();
80  ~LogicProgram();
92  };
93 
95  struct AspOptions {
96  static const uint32 MAX_EQ_ITERS = static_cast<uint32>( (1u<<26)-1 );
98  AspOptions& iterations(uint32 it) { iters = it;return *this;}
99  AspOptions& depthFirst() { dfOrder = 1; return *this;}
100  AspOptions& backpropagate() { backprop= 1; return *this;}
101  AspOptions& noScc() { noSCC = 1; return *this;}
102  AspOptions& noEq() { iters = 0; return *this;}
103  AspOptions& disableGamma() { noGamma = 1; return *this;}
104  AspOptions& ext(ExtendedRuleMode m) { erMode = m; return *this;}
105  AspOptions& supportedModels() { suppMod = 1; noEq(); return noScc(); }
107  uint32 iters : 26;
108  uint32 noSCC : 1;
109  uint32 dfOrder : 1;
110  uint32 backprop : 1;
111  uint32 normalize: 1;
112  uint32 suppMod : 1;
113  uint32 noGamma : 1;
114  };
119 
122  startProgram(ctx);
123  setOptions(opts);
124  return *this;
125  }
129  void setOptions(const AspOptions& opts);
131  void setNonHcfConfiguration(Configuration* c){ nonHcfCfg_ = c; }
132 
134 
148  bool update() { return updateProgram(); }
149 
151 
165  bool end() { return endProgram(); }
166 
168  void write(std::ostream& os);
169 
171 
176  void dispose(bool forceFullDispose);
177 
179  /*
180  * \pre The program is currently frozen.
181  */
182  bool clone(SharedContext& ctx, bool shareSymbols = false);
183 
185 
195 
197 
200  Var newAtom();
201 
203 
216  LogicProgram& setAtomName(Var atomId, const char* name);
217 
219 
226  LogicProgram& setCompute(Var atomId, bool value);
227 
229 
235  LogicProgram& freeze(Var atomId, ValueRep value = value_false);
236 
238 
246  LogicProgram& unfreeze(Var atomId);
247 
249 
263  LogicProgram& addRule(const Rule& r);
264 
266 
277 
279 
287  rule_.clear();
288  rule_.setType(t);
289  if ((t == CONSTRAINTRULE || t == WEIGHTRULE) && bound > 0) {
290  rule_.setBound(bound);
291  }
292  return *this;
293  }
294 
296 
300  LogicProgram& setBound(weight_t bound) { // only valid for CONSTRAINT and WEIGHTRULES
301  rule_.setBound(bound);
302  return *this;
303  }
304 
307  assert(atomId > 0);
308  rule_.addHead(atomId);
309  return *this;
310  }
311 
313 
320  LogicProgram& addToBody(Var atomId, bool pos, weight_t weight = 1) {
321  rule_.addToBody(atomId, pos, weight);
322  return *this;
323  }
324 
326 
330  return addRule(rule_);
331  }
332 
334 
342  bool hasMinimize() const { return minimize_ != 0; }
345  uint32 numAtoms() const { return (uint32)atoms_.size()-1; }
347  uint32 numBodies() const { return (uint32)bodies_.size(); }
349  uint32 numDisjunctions() const { return (uint32)disjunctions_.size(); }
351  Var startAtom() const { return incData_?incData_->startAtom:1; }
353 
360  Literal getLiteral(Var atomId) const;
364 
371  typedef VarVec::const_iterator VarIter;
372  typedef PrgHead*const* HeadIter;
373  typedef std::pair<EdgeIterator, EdgeIterator> EdgeRange;
374  typedef std::pair<HeadIter, HeadIter> HeadRange;
375  const AspOptions& options() const { return opts_; }
376  bool hasConflict() const { return getFalseAtom()->literal() == posLit(0); }
377  bool ok() const { return !hasConflict() && ProgramBuilder::ok(); }
378  PrgAtom* getAtom(Var atomId) const { return atoms_[atomId]; }
379  PrgHead* getHead(PrgEdge it) const { return it.isAtom() ? (PrgHead*)getAtom(it.node()) : (PrgHead*)getDisj(it.node()); }
380  PrgNode* getSupp(PrgEdge it) const { return it.isBody() ? (PrgNode*)getBody(it.node()) : (PrgNode*)getDisj(it.node()); }
381  Var getEqAtom(Var a) const { return getEqNode(atoms_, a); }
382  PrgBody* getBody(Var bodyId) const { return bodies_[bodyId]; }
383  Var getEqBody(Var b) const { return getEqNode(bodies_, b); }
384  PrgDisj* getDisj(Var disjId) const { return disjunctions_[disjId]; }
385  bool isFact(PrgAtom* a) const { return a->value() == value_true && opts_.noSCC == false; }
386  HeadIter disj_begin() const { return disjunctions_.empty() ? 0 : reinterpret_cast<HeadIter>(&disjunctions_[0]); }
387  HeadIter disj_end() const { return disj_begin() + numDisjunctions(); }
388  HeadIter atom_begin() const { return reinterpret_cast<HeadIter>(&atoms_[0]); }
389  HeadIter atom_end() const { return atom_begin() + (numAtoms()+1); }
390  VarIter unfreeze_begin() const { return incData_?incData_->update.begin() : activeHead_.end(); }
391  VarIter unfreeze_end() const { return incData_?incData_->update.end() : activeHead_.end(); }
392  const char*getAtomName(Var id) const;
393  RuleType simplifyRule(const Rule& r, VarVec& head, BodyInfo& info);
394  VarVec& getSupportedBodies(bool sorted);
395  uint32 update(PrgBody* b, uint32 oldHash, uint32 newHash);
396  bool assignValue(PrgAtom* a, ValueRep v);
397  bool assignValue(PrgHead* h, ValueRep v);
398  bool propagate(bool backprop);
399  PrgAtom* mergeEqAtoms(PrgAtom* a, Var rootAtom);
400  PrgBody* mergeEqBodies(PrgBody* b, Var rootBody, bool hashEq, bool atomsAssigned);
401  bool propagate() { return propagate(options().backprop); }
402  void setConflict() { getFalseAtom()->setLiteral(posLit(0)); }
403  RuleState& ruleState() { return ruleState_; }
404  void addMinimize();
405  // ------------------------------------------------------------------------
406  // Statistics
407  void upRules(RuleType r, int i) { stats.upRule(r, i); }
408  void incTr(RuleType r, uint32 n){ stats.trRule(r, n); }
409  void incTrAux(uint32 n) { stats.auxAtoms += n; }
410  void incEqs(VarType t) { stats.incEqs(t); }
411  // ------------------------------------------------------------------------
413 private:
414  LogicProgram(const LogicProgram&);
415  LogicProgram& operator=(const LogicProgram&);
416  typedef PodVector<Rule*>::type RuleList;
417  typedef std::multimap<uint32, uint32> IndexMap; // hash -> vec[offset]
418  typedef IndexMap::iterator IndexIter;
419  typedef std::pair<IndexIter, IndexIter> IndexRange;
420  typedef PodVector<uint8>::type SccMap;
421  struct MinimizeRule;
422  // ------------------------------------------------------------------------
423  // virtual overrides
424  bool doStartProgram();
425  bool doUpdateProgram();
426  bool doEndProgram();
427  void doGetAssumptions(LitVec& out) const;
428  bool doParse(StreamSource& prg);
429  int doType() const { return Problem_t::ASP; }
430  // ------------------------------------------------------------------------
431  // Program definition
432  PrgAtom* resize(Var atomId);
433  void addRuleImpl(RuleType t, const VarVec& head, BodyInfo& body);
434  bool handleNatively(RuleType t, const BodyInfo& i) const;
435  bool transformNoAux(RuleType t, const BodyInfo& i) const;
436  void transformExtended();
437  void transformIntegrity(uint32 maxAux);
438  PrgBody* getBodyFor(BodyInfo& body, bool addDeps = true);
439  PrgDisj* getDisjFor(const VarVec& heads, uint32 headHash);
440  PrgBody* assignBodyFor(BodyInfo& body, EdgeType x, bool strongSimp);
441  uint32 findEqBody(PrgBody* b, uint32 hash);
442  uint32 equalBody(const IndexRange& range, BodyInfo& info) const;
443  RuleType simplifyBody(const Rule& r, BodyInfo& info);
444  uint32 removeBody(PrgBody* b, uint32 oldHash);
445  Literal getEqAtomLit(Literal lit, const BodyList& supports, Preprocessor& p, const SccMap& x);
446  bool positiveLoopSafe(PrgBody* b, PrgBody* root) const;
447  void updateFrozenAtoms();
448  void normalize();
449  template <class C>
450  Var getEqNode(C& vec, Var id) const {
451  if (!vec[id]->eq()) return id;
452  typedef typename C::value_type NodeType;
453  NodeType n = vec[id];
454  NodeType r;
455  Var root = n->id();
456  for (r = vec[root]; r->eq(); r = vec[root]) {
457  // if n == r and r == r' -> n == r'
458  n->setEq(root = r->id());
459  }
460  return root;
461  }
462  // ------------------------------------------------------------------------
463  // Nogood creation
464  void prepareProgram(bool checkSccs);
465  void finalizeDisjunctions(Preprocessor& p, uint32 numSccs);
466  void prepareComponents();
467  void simplifyMinimize();
468  bool addConstraints();
469  // ------------------------------------------------------------------------
470  void writeBody(const BodyInfo& body, std::ostream&) const;
471  bool transform(const PrgBody& body, BodyInfo& out) const;
472  void transform(const MinimizeRule&, BodyInfo& out) const;
473  Var getFalseId() const { return 0; }
474  PrgAtom* getFalseAtom() const { return atoms_[0]; }
475  Var findLpFalseAtom() const;
476  Rule rule_; // active rule
477  BodyInfo activeBody_; // simplified body of active rule
478  VarVec activeHead_; // simplified head of active rule
479  RuleState ruleState_; // which atoms appear in the active rule?
480  RuleList extended_; // extended rules to be translated
481  IndexMap bodyIndex_; // hash -> body
482  IndexMap disjIndex_; // hash -> disjunction
483  BodyList bodies_; // all bodies
484  AtomList atoms_; // all atoms
485  AtomList sccAtoms_; // atoms that are strongly connected
486  DisjList disjunctions_;// all (head) disjunctions
487  VarVec initialSupp_; // bodies that are (initially) supported
488  VarVec propQ_; // assigned atoms
489  NonHcfSet nonHcfs_; // set of non-hcf sccs
490  Configuration* nonHcfCfg_; // optional configuration second level solvers
491  struct MinimizeRule {
492  WeightLitVec lits_;
493  MinimizeRule* next_;
494  }* minimize_; // list of minimize-rules
495  struct Incremental {
496  Incremental();
497  uint32 startAtom;// first atom of current iteration
498  uint32 startAux; // first aux atom of current iteration
499  uint32 startScc; // first valid scc number in this iteration
500  VarVec frozen; // list of frozen atoms
501  VarVec update; // list of atoms to be updated (freeze/unfreeze) in this step
502  }* incData_;// additional state to handle incrementally defined programs
503  AspOptions opts_; // preprocessing
504 };
505 } } // end namespace Asp
506 #endif
Definition: logic_program.h:88
uint32 numDisjunctions() const
Returns the number of disjunctive heads.
Definition: logic_program.h:349
uint32 auxAtoms
Definition: logic_program.h:54
PodVector< PrgBody * >::type BodyList
Definition: logic_program_types.h:35
AspOptions & supportedModels()
Definition: logic_program.h:105
uint32 nonHcfs
Definition: logic_program.h:56
Literal posLit(Var v)
Creates the positive literal of variable v.
Definition: literal.h:168
PrgAtom * getAtom(Var atomId) const
Definition: logic_program.h:378
Supported edge types.
Definition: logic_program_types.h:86
bool isFact(PrgAtom *a) const
Definition: logic_program.h:385
VarVec::const_iterator VarIter
Definition: logic_program.h:371
Definition: literal.h:55
LogicProgram & setBound(weight_t bound)
Sets the bound (resp. min weight) of the currently active rule.
Definition: logic_program.h:300
uint32 ufsNodes
Definition: logic_program.h:58
Var getEqBody(Var b) const
Definition: logic_program.h:383
void setExtendedRuleMode(ExtendedRuleMode m)
Sets the mode for handling extended rules (default: mode_native).
Definition: logic_program.h:127
bool propagate()
Definition: logic_program.h:401
uint32 noSCC
Definition: logic_program.h:108
bool hasMinimize() const
Returns whether the program contains any minimize statements.
Definition: logic_program.h:343
uint32 eqs(VarType t) const
Definition: logic_program.h:41
bool assignValue(PrgAtom *a, ValueRep v)
Definition: logic_program.cpp:535
LogicProgram()
Definition: logic_program.cpp:132
LogicProgram & start(SharedContext &ctx, const AspOptions &opts=AspOptions())
Starts the definition of a logic program.
Definition: logic_program.h:121
The head of a disjunctive rule.
Definition: logic_program_types.h:643
Var newAtom()
Adds a new atom to the program.
Definition: logic_program.cpp:396
void trRule(RuleType t, uint32 i)
Definition: logic_program.h:48
AspOptions & depthFirst()
Definition: logic_program.h:99
std::pair< HeadIter, HeadIter > HeadRange
Definition: logic_program.h:374
uint32 numBodies() const
Returns the number of bodies in the current (slice of the) logic program.
Definition: logic_program.h:347
Definition: logic_program_types.h:46
static const uint32 MAX_EQ_ITERS
Definition: logic_program.h:96
PrgHead * getHead(PrgEdge it) const
Definition: logic_program.h:379
PodVector< PrgDisj * >::type DisjList
Definition: logic_program_types.h:36
PodVector< Var >::type VarVec
Definition: literal.h:192
A head node of a program-dependency graph.
Definition: logic_program_types.h:396
Definition: literal.h:55
HeadIter disj_end() const
Definition: logic_program.h:387
HeadIter atom_end() const
Definition: logic_program.h:389
Rule & addToBody(Var v, bool pos, weight_t w=1)
Adds v to the positive/negative body of the rule.
Definition: logic_program_types.cpp:57
bool endProgram()
Loads the program into the shared context passed to startProgram().
Definition: program_builder.cpp:54
Literal getLiteral(Var atomId) const
Returns the internal literal that is associated with the given atom.
Definition: logic_program.cpp:482
std::pair< EdgeIterator, EdgeIterator > EdgeRange
Definition: logic_program.h:373
bool startProgram(SharedContext &ctx)
Starts the definition of a program.
Definition: program_builder.cpp:36
uint32 Var
A variable is currently nothing more but an integer in the range [0..varMax).
Definition: literal.h:42
uint32 sccs
Definition: logic_program.h:55
Aggregates information to be shared between solver objects.
Definition: shared_context.h:396
const BodyList * bodies_
Definition: logic_program.cpp:120
VarIter unfreeze_begin() const
Definition: logic_program.h:390
RedefinitionError(unsigned atomId, const char *atomName="")
Definition: logic_program.cpp:393
VarVec & getSupportedBodies(bool sorted)
Definition: logic_program.cpp:1368
Rule & setType(RuleType t)
Sets the type of the rule.
Definition: logic_program_types.h:155
uint32 atoms
Definition: logic_program.h:53
tuple a
Definition: pyclingo.py:6
void setLiteral(Literal x)
Definition: logic_program_types.h:358
void setConflict()
Definition: logic_program.h:402
PrgBody * getBody(Var bodyId) const
Definition: logic_program.h:382
Definition: literal.h:55
Definition: logic_program.h:84
void incTr(RuleType r, uint32 n)
Definition: logic_program.h:408
bool end()
Finishes the definition of the logic program (or its current increment).
Definition: logic_program.h:165
bool update()
Unfreezes a currently frozen program and starts an incremental step.
Definition: logic_program.h:148
Options for the Asp-Preprocessor.
Definition: logic_program.h:95
uint32 gammas
Definition: logic_program.h:57
double operator[](const char *key) const
Definition: logic_program.cpp:70
Literal & lit
Definition: statements.cc:1284
void incEqs(VarType t)
Definition: logic_program.h:410
PodVector< Literal >::type LitVec
Definition: literal.h:193
PrgAtom * mergeEqAtoms(PrgAtom *a, Var rootAtom)
Definition: logic_program.cpp:1309
PrgNode * getSupp(PrgEdge it) const
Definition: logic_program.h:380
PrgEdge::NodeType NodeType
Definition: logic_program_types.h:125
LogicProgram & addToBody(Var atomId, bool pos, weight_t weight=1)
Adds a subgoal to the currently active rule.
Definition: logic_program.h:320
RuleType simplifyRule(const Rule &r, VarVec &head, BodyInfo &info)
Definition: logic_program.cpp:1087
bool isBody() const
Returns true if the adjacent node is a body.
Definition: logic_program_types.h:111
RuleState & ruleState()
Definition: logic_program.h:403
Literal literal() const
Returns the literal associated with this node or a sentinel literal if no var is associated with this...
Definition: logic_program_types.h:340
uint32 noGamma
Definition: logic_program.h:113
uint8 ValueRep
Definition: literal.h:203
PrgHead *const * HeadIter
Definition: logic_program.h:372
virtual bool ok() const
Returns true if the program is not conflicting.
Definition: program_builder.cpp:35
LogicProgram & setCompute(Var atomId, bool value)
Forces the atom's truth-value to value.
Definition: logic_program.cpp:411
uint32 backprop
Definition: logic_program.h:110
uint32 rules() const
Definition: logic_program.cpp:44
LogicProgram & unfreeze(Var atomId)
Removes any protection from the given atom.
Definition: logic_program.cpp:434
Program statistics for one incremental step.
Definition: logic_program.h:35
HeadIter atom_begin() const
Definition: logic_program.h:388
Definition: logic_program.h:83
A rule of a logic program.
Definition: logic_program_types.h:135
void incEqs(VarType t)
Definition: logic_program.h:46
uint32 bodies
Definition: logic_program.h:52
unsigned atom() const
Definition: logic_program.h:67
bool ok() const
Returns true if the program is not conflicting.
Definition: logic_program.h:377
bool updateProgram()
Unfreezes a currently frozen program.
Definition: program_builder.cpp:44
Var startAtom() const
Returns the id of the first atom of the current step.
Definition: logic_program.h:351
HeadIter disj_begin() const
Definition: logic_program.h:386
LogicProgram & addHead(Var atomId)
Adds the atom with the given id as a head to the currently active rule.
Definition: logic_program.h:306
AspOptions & noScc()
Definition: logic_program.h:101
tuple b
Definition: pyclingo.py:47
A (rule) body in a logic program.
Definition: logic_program_types.h:497
uint32 normalize
Definition: logic_program.h:111
Definition: logic_program_types.h:48
A node of a program-dependency graph.
Definition: logic_program_types.h:314
void accu(const LpStats &o)
Definition: logic_program.cpp:49
int32 weight_t
A signed integer type used to represent weights.
Definition: literal.h:66
bool tr() const
Definition: logic_program.h:45
Var getEqAtom(Var a) const
Definition: logic_program.h:381
const char * getAtomName(Var id) const
Definition: logic_program.cpp:1362
LogicProgram & endRule()
Finishes the construction of the active rule and adds it to the program.
Definition: logic_program.h:329
Bound & bound
Definition: output.cc:122
bool frozen() const
Returns true if the program is currently frozen.
Definition: program_builder.h:80
uint32 node() const
Returns the id of the adjacent node.
Definition: logic_program_types.h:99
Definition: logic_program.h:89
const AspOptions & options() const
Definition: logic_program.h:375
void incTrAux(uint32 n)
Definition: logic_program.h:409
void upRule(RuleType t, int32 i)
Definition: logic_program.h:47
Definition: claspfwd.h:30
LpStats * accu
Definition: logic_program.h:362
Type
Definition: literal.h:55
LpStats stats
Definition: logic_program.h:361
Interface for configuring a SharedContext object and its associated solvers.
Definition: solver_strategies.h:389
uint32 iters
Definition: logic_program.h:107
uint32 suppMod
Definition: logic_program.h:112
RPair & rules(RuleType t)
Definition: logic_program.h:44
Rule & setBound(weight_t bound)
Sets the lower bound of the rule.
Definition: logic_program_types.h:167
~LogicProgram()
Definition: logic_program.cpp:133
VarIter unfreeze_end() const
Definition: logic_program.h:391
void setNonHcfConfiguration(Configuration *c)
Sets the configuration to be used for checker solvers in disjunctive LP solving.
Definition: logic_program.h:131
RuleType
Supported rule-types.
Definition: logic_program_types.h:43
tuple p
Definition: server.py:49
AspOptions & backpropagate()
Definition: logic_program.h:100
void addMinimize()
Definition: logic_program.cpp:279
uint32 dfOrder
Definition: logic_program.h:109
bool clone(SharedContext &ctx, bool shareSymbols=false)
Clones the program and adds it to the given ctx.
Definition: logic_program.cpp:266
Definition: logic_program_types.h:225
tuple c
Definition: visualize.py:132
bool hasConflict() const
Definition: logic_program.h:376
PrgEdge::EdgeType EdgeType
Definition: logic_program_types.h:124
uint32 ruleIndex(RuleType x)
Definition: logic_program_types.h:53
ValueRep value() const
Returns the value currently assigned to this node.
Definition: logic_program_types.h:342
bool isAtom() const
Returns true if the adjacant node is an atom.
Definition: logic_program_types.h:113
ExtendedRuleMode erMode
Definition: logic_program.h:106
AspOptions & disableGamma()
Definition: logic_program.h:103
int x
Definition: utility.cc:65
void clear()
Resets the rule.
Definition: logic_program_types.cpp:41
void write(std::ostream &os)
Writes the (possibly simplified) program in lparse-format to the given stream.
Definition: logic_program.cpp:295
PrgBody * mergeEqBodies(PrgBody *b, Var rootBody, bool hashEq, bool atomsAssigned)
Definition: logic_program.cpp:1329
Definition: logic_program.h:86
Wrapps an std::istream and provides basic functions for extracting numbers and strings.
Definition: parser.h:165
A class for defining a logic program.
Definition: logic_program.h:77
PodVector< PrgAtom * >::type AtomList
Definition: logic_program_types.h:34
Definition: pod_vector.h:36
Rule & addHead(Var v)
Adds v as a head of this rule.
Definition: logic_program_types.cpp:49
AspOptions & iterations(uint32 it)
Definition: logic_program.h:98
Definition: logic_program_types.h:51
Exception type for signaling an invalid incremental program update.
Definition: logic_program.h:64
Interface for defining an input program.
Definition: program_builder.h:43
Definition: logic_program_types.h:45
static const char * keys(const char *path)
Definition: logic_program.cpp:100
RangeLiteralShared & range
Definition: literals.cc:60
LogicProgram & setAtomName(Var atomId, const char *name)
Sets the name of the given atom and adds it to the program's symbol table.
Definition: logic_program.cpp:403
uint32 eqs() const
Definition: logic_program.h:40
const ValueRep value_true
Definition: literal.h:204
const ValueRep value_false
Definition: literal.h:205
void dispose(bool forceFullDispose)
Disposes (parts of) the internal representation of the logic program.
Definition: logic_program.cpp:135
SharedContext * ctx() const
Returns the stored context object.
Definition: program_builder.h:84
AspOptions & ext(ExtendedRuleMode m)
Definition: logic_program.h:104
LogicProgram & startRule(RuleType t=BASICRULE, weight_t bound=-1)
Starts the construction of a rule.
Definition: logic_program.h:286
ExtendedRuleMode
Defines the possible modes for handling extended rules, i.e. choice, cardinality, and weight rules...
Definition: logic_program.h:82
RPair rules(RuleType t) const
Definition: logic_program.h:43
LogicProgram & addRule(const Rule &r)
Adds the given rule to the program.
Definition: logic_program.cpp:446
LpStats()
Definition: logic_program.h:38
PrgDisj * getDisj(Var disjId) const
Definition: logic_program.h:384
std::pair< uint32, uint32 > RPair
Definition: logic_program.h:37
Used during rule simplification.
Definition: logic_program_types.h:269
A literal is a variable or its negation.
Definition: literal.h:80
An atom in a logic program.
Definition: logic_program_types.h:456
LogicProgram & freeze(Var atomId, ValueRep value=value_false)
Protects an otherwise undefined atom from preprocessing.
Definition: logic_program.cpp:420
void reset()
Definition: logic_program.cpp:41
void setOptions(const AspOptions &opts)
Sets preprocessing options.
Definition: logic_program.cpp:224
PodVector< WeightLiteral >::type WeightLitVec
Definition: literal.h:198
AspOptions()
Definition: logic_program.h:97
std::forward_list< S > heads
Definition: dependency.cc:141
LparseOutputter & out
Definition: output.cc:685
AspOptions & noEq()
Definition: logic_program.h:102
void upRules(RuleType r, int i)
Definition: logic_program.h:407
uint32 numAtoms() const
Returns the number of atoms in the logic program.
Definition: logic_program.h:345