A (rule) body in a logic program. More...
#include <logic_program_types.h>

Classes | |
| union | Head |
| struct | SumExtra |
Public Types | |
| typedef BodyInfo::BodyType | BodyType |
| typedef EdgeIterator | head_iterator |
Public Member Functions | |
| bool | addConstraints (const LogicProgram &prg, ClauseCreator &c) |
| void | addHead (PrgHead *h, EdgeType t) |
| Adds a rule edge between this body and the given head. | |
| bool | assignValue (ValueRep v) |
| void | assignVar (LogicProgram &prg) |
| weight_t | bound () const |
| Returns the bound of this body, or size() if the body is a normal body. | |
| void | clearHeads () |
| void | destroy () |
| Destroys a body node created via create(LogicProgram& prg, uint32 id, const Rule& rule, const Rule::RData& rInfo). | |
| bool | eqLits (WeightLitVec &vec, bool &sorted) const |
| Literal | goal (uint32 idx) const |
| Returns the idx'th subgoal as a literal. | |
| bool | hasHeads () const |
| Returns true if this body defines any head. | |
| head_iterator | heads_begin () const |
| head_iterator | heads_end () const |
| bool | isSupported () const |
| Returns true if the body node is supported. | |
| void | markDirty () |
| void | markHeadsDirty () |
| bool | mergeHeads (LogicProgram &prg, PrgBody &heads, bool strong, bool simplify=true) |
| bool | noScc () const |
| bool | propagateAssigned (LogicProgram &prg, Literal p, ValueRep v) |
| Propagates the assignment of subgoal p. | |
| bool | propagateAssigned (LogicProgram &prg, PrgHead *h, EdgeType t) |
| Propagates the assignment of a head. | |
| bool | propagateSupported (Var) |
| Notifies the body node about the fact that its positive subgoal v is supported. | |
| bool | propagateValue (LogicProgram &prg, bool backprop) |
| Propagates the value of this body. | |
| void | removeHead (PrgHead *h, EdgeType t) |
| bool | resetSupported () |
| uint32 | scc (const LogicProgram &prg) const |
| bool | simplify (LogicProgram &prg, bool strong, uint32 *eqId=0) |
| Calls simplifyBody() and/or simplifyHeads() if necessary. | |
| bool | simplifyBody (LogicProgram &prg, bool strong, uint32 *eqId=0) |
| Simplifies the body, i.e. its predecessors-lists. | |
| bool | simplifyHeads (LogicProgram &prg, bool strong) |
| Simplifies the heads of this body and establishes set property. | |
| uint32 | size () const |
| Returns the number of atoms in the body. | |
| weight_t | sumW () const |
| Returns the sum of the subgoals weights, or size() if the body is not a SUM_BODY. | |
| BodyType | type () const |
| weight_t | weight (uint32 idx) const |
| Returns the weight of the idx'th subgoal. | |
Static Public Member Functions | |
| static PrgBody * | create (LogicProgram &prg, uint32 id, const BodyInfo &info, bool addDeps) |
| Creates a new body node and connects the node to its predecessors. | |
Private Member Functions | |
| void | addHead (PrgEdge h) |
| bool | blockedHead (PrgEdge it, const RuleState &rs) const |
| weight_t | boundImpl () const |
| bool | eraseHead (PrgEdge h) |
| bool | extHead () const |
| uint32 | findLit (const LogicProgram &prg, Literal p) const |
| const Literal * | goals_begin () const |
| Literal * | goals_begin () |
| const Literal * | goals_end () const |
| Literal * | goals_end () |
| bool | hasWeights () const |
| bool | normalize (const LogicProgram &prg, weight_t bound, weight_t sumW, weight_t reachW, uint32 &hashOut) |
| void | prepareSimplifyHeads (LogicProgram &prg, RuleState &rs) |
| PrgBody (LogicProgram &prg, uint32 id, const BodyInfo &info, bool addDep) | |
| bool | simplifyHeadsImpl (LogicProgram &prg, PrgBody &target, RuleState &rs, bool strong) |
| bool | superfluousHead (const LogicProgram &prg, const PrgHead *head, PrgEdge it, const RuleState &rs) const |
| ~PrgBody () | |
Private Attributes | |
| struct { | |
| union { | |
| SumExtra * ext [0] | |
| uint32 lits [0] | |
| } | |
| } | data_ |
| uint32 | extHead_: 2 |
| union Clasp::Asp::PrgBody::Head | heads_ |
| uint32 | sBody_: 1 |
| uint32 | sHead_: 1 |
| uint32 | size_: 26 |
| uint32 | type_: 2 |
| weight_t | unsupp_ |
Static Private Attributes | |
| static const uint32 | maxSize = (1u<<26)-1 |
A (rule) body in a logic program.
Definition at line 497 of file logic_program_types.h.
Definition at line 499 of file logic_program_types.h.
Definition at line 500 of file logic_program_types.h.
| Clasp::Asp::PrgBody::PrgBody | ( | LogicProgram & | prg, |
| uint32 | id, | ||
| const BodyInfo & | info, | ||
| bool | addDep | ||
| ) | [explicit, private] |
Definition at line 760 of file logic_program_types.cpp.
| Clasp::Asp::PrgBody::~PrgBody | ( | ) | [private] |
Definition at line 802 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::addConstraints | ( | const LogicProgram & | prg, |
| ClauseCreator & | c | ||
| ) |
Definition at line 1340 of file logic_program_types.cpp.
| void Clasp::Asp::PrgBody::addHead | ( | PrgHead * | h, |
| EdgeType | t | ||
| ) |
Adds a rule edge between this body and the given head.
Definition at line 849 of file logic_program_types.cpp.
| void Clasp::Asp::PrgBody::addHead | ( | PrgEdge | h | ) | [private] |
Definition at line 859 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::assignValue | ( | ValueRep | v | ) | [inline] |
Definition at line 597 of file logic_program_types.h.
| void Clasp::Asp::PrgBody::assignVar | ( | LogicProgram & | prg | ) |
Definition at line 1221 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::blockedHead | ( | PrgEdge | it, |
| const RuleState & | rs | ||
| ) | const [private] |
Definition at line 1207 of file logic_program_types.cpp.
| weight_t Clasp::Asp::PrgBody::bound | ( | ) | const [inline] |
Returns the bound of this body, or size() if the body is a normal body.
Definition at line 518 of file logic_program_types.h.
| weight_t Clasp::Asp::PrgBody::boundImpl | ( | ) | const [inline, private] |
Definition at line 613 of file logic_program_types.h.
| void Clasp::Asp::PrgBody::clearHeads | ( | ) |
Definition at line 842 of file logic_program_types.cpp.
| PrgBody * Clasp::Asp::PrgBody::create | ( | LogicProgram & | prg, |
| uint32 | id, | ||
| const BodyInfo & | info, | ||
| bool | addDeps | ||
| ) | [static] |
Creates a new body node and connects the node to its predecessors.
| prg | The program in which the new body is used. |
| id | The id of the new body object. |
| info | The rule body for which a node is to be created. |
| addDeps | If true, add an edge between each atom subgoal and the new node. |
Definition at line 794 of file logic_program_types.cpp.
| void Clasp::Asp::PrgBody::destroy | ( | ) |
Destroys a body node created via create(LogicProgram& prg, uint32 id, const Rule& rule, const Rule::RData& rInfo).
Definition at line 809 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::eqLits | ( | WeightLitVec & | vec, |
| bool & | sorted | ||
| ) | const |
Definition at line 1241 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::eraseHead | ( | PrgEdge | h | ) | [private] |
Definition at line 877 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::extHead | ( | ) | const [inline, private] |
Definition at line 611 of file logic_program_types.h.
| uint32 Clasp::Asp::PrgBody::findLit | ( | const LogicProgram & | prg, |
| Literal | p | ||
| ) | const [private] |
Definition at line 822 of file logic_program_types.cpp.
| Literal Clasp::Asp::PrgBody::goal | ( | uint32 | idx | ) | const [inline] |
Returns the idx'th subgoal as a literal.
Definition at line 522 of file logic_program_types.h.
| const Literal* Clasp::Asp::PrgBody::goals_begin | ( | ) | const [inline, private] |
Definition at line 615 of file logic_program_types.h.
| Literal* Clasp::Asp::PrgBody::goals_begin | ( | ) | [inline, private] |
Definition at line 617 of file logic_program_types.h.
| const Literal* Clasp::Asp::PrgBody::goals_end | ( | ) | const [inline, private] |
Definition at line 614 of file logic_program_types.h.
| Literal* Clasp::Asp::PrgBody::goals_end | ( | ) | [inline, private] |
Definition at line 616 of file logic_program_types.h.
| bool Clasp::Asp::PrgBody::hasHeads | ( | ) | const [inline] |
Returns true if this body defines any head.
Definition at line 533 of file logic_program_types.h.
| bool Clasp::Asp::PrgBody::hasWeights | ( | ) | const [inline, private] |
Definition at line 612 of file logic_program_types.h.
| head_iterator Clasp::Asp::PrgBody::heads_begin | ( | ) | const [inline] |
Definition at line 534 of file logic_program_types.h.
| head_iterator Clasp::Asp::PrgBody::heads_end | ( | ) | const [inline] |
Definition at line 535 of file logic_program_types.h.
| bool Clasp::Asp::PrgBody::isSupported | ( | ) | const [inline] |
Returns true if the body node is supported.
A normal body is supported, iff all of its positive subgoals are supported. A count/sum body is supported if the sum of the weights of the supported positive + the sum of the negative weights is >= lowerBound().
Definition at line 531 of file logic_program_types.h.
| void Clasp::Asp::PrgBody::markDirty | ( | ) | [inline] |
Definition at line 592 of file logic_program_types.h.
| void Clasp::Asp::PrgBody::markHeadsDirty | ( | ) | [inline] |
Definition at line 593 of file logic_program_types.h.
| bool Clasp::Asp::PrgBody::mergeHeads | ( | LogicProgram & | prg, |
| PrgBody & | heads, | ||
| bool | strong, | ||
| bool | simplify = true |
||
| ) |
Definition at line 1111 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::normalize | ( | const LogicProgram & | prg, |
| weight_t | bound, | ||
| weight_t | sumW, | ||
| weight_t | reachW, | ||
| uint32 & | hashOut | ||
| ) | [private] |
Definition at line 1018 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::noScc | ( | ) | const [inline] |
Definition at line 516 of file logic_program_types.h.
| void Clasp::Asp::PrgBody::prepareSimplifyHeads | ( | LogicProgram & | prg, |
| RuleState & | rs | ||
| ) | [private] |
Definition at line 1058 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::propagateAssigned | ( | LogicProgram & | prg, |
| Literal | p, | ||
| ValueRep | v | ||
| ) |
Propagates the assignment of subgoal p.
Definition at line 1270 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::propagateAssigned | ( | LogicProgram & | prg, |
| PrgHead * | h, | ||
| EdgeType | t | ||
| ) |
Propagates the assignment of a head.
Definition at line 1285 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::propagateSupported | ( | Var | v | ) |
Notifies the body node about the fact that its positive subgoal v is supported.
Definition at line 1261 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::propagateValue | ( | LogicProgram & | prg, |
| bool | backprop | ||
| ) |
Propagates the value of this body.
Definition at line 1294 of file logic_program_types.cpp.
| void Clasp::Asp::PrgBody::removeHead | ( | PrgHead * | h, |
| EdgeType | t | ||
| ) |
Definition at line 870 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::resetSupported | ( | ) |
Definition at line 833 of file logic_program_types.cpp.
| uint32 Clasp::Asp::PrgBody::scc | ( | const LogicProgram & | prg | ) | const |
Definition at line 1367 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::simplify | ( | LogicProgram & | prg, |
| bool | strong, | ||
| uint32 * | eqId = 0 |
||
| ) | [inline] |
Calls simplifyBody() and/or simplifyHeads() if necessary.
Definition at line 576 of file logic_program_types.h.
| bool Clasp::Asp::PrgBody::simplifyBody | ( | LogicProgram & | prg, |
| bool | strong, | ||
| uint32 * | eqId = 0 |
||
| ) |
Simplifies the body, i.e. its predecessors-lists.
| [in] | prg | The program containing this body. |
| [in] | strong | If true, treats atoms that have no variable associated as false. |
| [out] | The id of a body in prg that is equivalent to this body. |
Definition at line 893 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::simplifyHeads | ( | LogicProgram & | prg, |
| bool | strong | ||
| ) |
Simplifies the heads of this body and establishes set property.
Removes superfluous heads and sets the body to false if for some atom a in the head of this body B, Ta -> FB. In that case, all heads atoms are removed, because a false body can't define any atom. If strong is true, removes head atoms that are not associated with a variable.
Definition at line 1106 of file logic_program_types.cpp.
| bool Clasp::Asp::PrgBody::simplifyHeadsImpl | ( | LogicProgram & | prg, |
| PrgBody & | target, | ||
| RuleState & | rs, | ||
| bool | strong | ||
| ) | [private] |
Definition at line 1079 of file logic_program_types.cpp.
| uint32 Clasp::Asp::PrgBody::size | ( | ) | const [inline] |
Returns the number of atoms in the body.
Definition at line 515 of file logic_program_types.h.
| weight_t Clasp::Asp::PrgBody::sumW | ( | ) | const [inline] |
Returns the sum of the subgoals weights, or size() if the body is not a SUM_BODY.
Definition at line 520 of file logic_program_types.h.
| bool Clasp::Asp::PrgBody::superfluousHead | ( | const LogicProgram & | prg, |
| const PrgHead * | head, | ||
| PrgEdge | it, | ||
| const RuleState & | rs | ||
| ) | const [private] |
Definition at line 1155 of file logic_program_types.cpp.
| BodyType Clasp::Asp::PrgBody::type | ( | ) | const [inline] |
Definition at line 513 of file logic_program_types.h.
| weight_t Clasp::Asp::PrgBody::weight | ( | uint32 | idx | ) | const [inline] |
Returns the weight of the idx'th subgoal.
Definition at line 524 of file logic_program_types.h.
struct { ... } Clasp::Asp::PrgBody::data_ [private] |
Definition at line 638 of file logic_program_types.h.
uint32 Clasp::Asp::PrgBody::extHead_ [private] |
Definition at line 631 of file logic_program_types.h.
union Clasp::Asp::PrgBody::Head Clasp::Asp::PrgBody::heads_ [private] |
| uint32 Clasp::Asp::PrgBody::lits[0] |
Definition at line 637 of file logic_program_types.h.
const uint32 Clasp::Asp::PrgBody::maxSize = (1u<<26)-1 [static, private] |
Definition at line 600 of file logic_program_types.h.
uint32 Clasp::Asp::PrgBody::sBody_ [private] |
Definition at line 633 of file logic_program_types.h.
uint32 Clasp::Asp::PrgBody::sHead_ [private] |
Definition at line 634 of file logic_program_types.h.
uint32 Clasp::Asp::PrgBody::size_ [private] |
Definition at line 630 of file logic_program_types.h.
uint32 Clasp::Asp::PrgBody::type_ [private] |
Definition at line 632 of file logic_program_types.h.
weight_t Clasp::Asp::PrgBody::unsupp_ [private] |
Definition at line 635 of file logic_program_types.h.