clingo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
Clasp::Asp::PrgBody Class Reference

A (rule) body in a logic program. More...

#include <logic_program_types.h>

Inheritance diagram for Clasp::Asp::PrgBody:
Inheritance graph
Collaboration diagram for Clasp::Asp::PrgBody:
Collaboration graph

Public Types

typedef BodyInfo::BodyType BodyType
 
typedef EdgeIterator head_iterator
 

Public Member Functions

void destroy ()
 Destroys a body node created via create(LogicProgram& prg, uint32 id, const Rule& rule, const Rule::RData& rInfo). More...
 
BodyType type () const
 
uint32 size () const
 Returns the number of atoms in the body. More...
 
bool noScc () const
 
weight_t bound () const
 Returns the bound of this body, or size() if the body is a normal body. More...
 
weight_t sumW () const
 Returns the sum of the subgoals weights, or size() if the body is not a SUM_BODY. More...
 
Literal goal (uint32 idx) const
 Returns the idx'th subgoal as a literal. More...
 
weight_t weight (uint32 idx) const
 Returns the weight of the idx'th subgoal. More...
 
bool isSupported () const
 Returns true if the body node is supported. More...
 
bool hasHeads () const
 Returns true if this body defines any head. More...
 
head_iterator heads_begin () const
 
head_iterator heads_end () const
 
void addHead (PrgHead *h, EdgeType t)
 Adds a rule edge between this body and the given head. More...
 
bool simplifyHeads (LogicProgram &prg, bool strong)
 Simplifies the heads of this body and establishes set property. More...
 
bool mergeHeads (LogicProgram &prg, PrgBody &heads, bool strong, bool simplify=true)
 
void removeHead (PrgHead *h, EdgeType t)
 
bool simplifyBody (LogicProgram &prg, bool strong, uint32 *eqId=0)
 Simplifies the body, i.e. its predecessors-lists. More...
 
bool simplify (LogicProgram &prg, bool strong, uint32 *eqId=0)
 Calls simplifyBody() and/or simplifyHeads() if necessary. More...
 
bool eqLits (WeightLitVec &vec, bool &sorted) const
 
bool propagateSupported (Var)
 Notifies the body node about the fact that its positive subgoal v is supported. More...
 
bool propagateAssigned (LogicProgram &prg, Literal p, ValueRep v)
 Propagates the assignment of subgoal p. More...
 
bool propagateAssigned (LogicProgram &prg, PrgHead *h, EdgeType t)
 Propagates the assignment of a head. More...
 
bool propagateValue (LogicProgram &prg, bool backprop)
 Propagates the value of this body. More...
 
bool addConstraints (const LogicProgram &prg, ClauseCreator &c)
 
void markDirty ()
 
void markHeadsDirty ()
 
void clearHeads ()
 
bool resetSupported ()
 
void assignVar (LogicProgram &prg)
 
bool assignValue (ValueRep v)
 
uint32 scc (const LogicProgram &prg) const
 
- Public Member Functions inherited from Clasp::Asp::PrgNode
 PrgNode (uint32 id, bool checkScc=true)
 Creates a new node that corresponds to a literal that is false. More...
 
bool relevant () const
 Is the node still relevant or removed() resp. eq()? More...
 
bool removed () const
 Was the node removed? More...
 
bool ignoreScc () const
 Ignore the node during scc checking? More...
 
bool eq () const
 Returns true if this node is equivalent to some other node. More...
 
bool seen () const
 
bool hasVar () const
 Returns true if node has an associated variable in a solver. More...
 
Var var () const
 Returns the variable associated with this node or sentVar if no var is associated with this node. More...
 
Literal literal () const
 Returns the literal associated with this node or a sentinel literal if no var is associated with this node. More...
 
ValueRep value () const
 Returns the value currently assigned to this node. More...
 
uint32 id () const
 Returns the current id of this node. More...
 
Literal trueLit () const
 Returns the literal that must be true in order to fulfill the truth-value of this node. More...
 
void setLiteral (Literal x)
 
void clearLiteral (bool clVal)
 
void setValue (ValueRep v)
 
void setEq (uint32 eqId)
 
void setIgnoreScc (bool b)
 
void markRemoved ()
 
void markSeen (bool b)
 
void resetId (uint32 id, bool seen)
 
bool assignValueImpl (ValueRep v, bool noWeak)
 

Static Public Member Functions

static PrgBodycreate (LogicProgram &prg, uint32 id, const BodyInfo &info, bool addDeps)
 Creates a new body node and connects the node to its predecessors. More...
 

Additional Inherited Members

- Static Public Attributes inherited from Clasp::Asp::PrgNode
static const uint32 noScc = (1u << 27)-1
 
static const uint32 maxVertex = (1u << 28)-1
 
static const uint32 noIdx = 1
 
- Protected Attributes inherited from Clasp::Asp::PrgNode
uint32 litIdx_: 31
 
uint32 noScc_: 1
 
uint32 id_: 28
 
uint32 val_: 2
 
uint32 eq_: 1
 
uint32 seen_: 1
 

Detailed Description

A (rule) body in a logic program.

Member Typedef Documentation

Member Function Documentation

bool Clasp::Asp::PrgBody::addConstraints ( const LogicProgram prg,
ClauseCreator c 
)

Here is the call graph for this function:

void Clasp::Asp::PrgBody::addHead ( PrgHead h,
EdgeType  t 
)

Adds a rule edge between this body and the given head.

Note
The function also adds a corresponding back edge to the head.
Adding a head invalidates the set property for the heads of this body. To restore it, call simplifyHeads()

Here is the call graph for this function:

bool Clasp::Asp::PrgBody::assignValue ( ValueRep  v)
inline

Here is the call graph for this function:

void Clasp::Asp::PrgBody::assignVar ( LogicProgram prg)

Here is the call graph for this function:

weight_t Clasp::Asp::PrgBody::bound ( ) const
inline

Returns the bound of this body, or size() if the body is a normal body.

Here is the call graph for this function:

void Clasp::Asp::PrgBody::clearHeads ( )
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.

Parameters
prgThe program in which the new body is used.
idThe id of the new body object.
infoThe rule body for which a node is to be created.
addDepsIf true, add an edge between each atom subgoal and the new node.

Here is the call graph for this function:

void Clasp::Asp::PrgBody::destroy ( )

Destroys a body node created via create(LogicProgram& prg, uint32 id, const Rule& rule, const Rule::RData& rInfo).

bool Clasp::Asp::PrgBody::eqLits ( WeightLitVec vec,
bool &  sorted 
) const

Here is the call graph for this function:

Literal Clasp::Asp::PrgBody::goal ( uint32  idx) const
inline

Returns the idx'th subgoal as a literal.

Here is the call graph for this function:

bool Clasp::Asp::PrgBody::hasHeads ( ) const
inline

Returns true if this body defines any head.

head_iterator Clasp::Asp::PrgBody::heads_begin ( ) const
inline
head_iterator Clasp::Asp::PrgBody::heads_end ( ) const
inline
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().

void Clasp::Asp::PrgBody::markDirty ( )
inline
void Clasp::Asp::PrgBody::markHeadsDirty ( )
inline
bool Clasp::Asp::PrgBody::mergeHeads ( LogicProgram prg,
PrgBody heads,
bool  strong,
bool  simplify = true 
)

Here is the call graph for this function:

bool Clasp::Asp::PrgBody::noScc ( ) const
inline

Here is the call graph for this function:

bool Clasp::Asp::PrgBody::propagateAssigned ( LogicProgram prg,
Literal  p,
ValueRep  v 
)

Propagates the assignment of subgoal p.

Here is the call graph for this function:

bool Clasp::Asp::PrgBody::propagateAssigned ( LogicProgram prg,
PrgHead h,
EdgeType  t 
)

Propagates the assignment of a head.

Here is the call graph for this function:

bool Clasp::Asp::PrgBody::propagateSupported ( Var  v)

Notifies the body node about the fact that its positive subgoal v is supported.

Returns
true if the body is now also supported, false otherwise.

Here is the call graph for this function:

bool Clasp::Asp::PrgBody::propagateValue ( LogicProgram prg,
bool  backprop 
)

Propagates the value of this body.

Here is the call graph for this function:

void Clasp::Asp::PrgBody::removeHead ( PrgHead h,
EdgeType  t 
)

Here is the call graph for this function:

bool Clasp::Asp::PrgBody::resetSupported ( )

Here is the call graph for this function:

uint32 Clasp::Asp::PrgBody::scc ( const LogicProgram prg) const

Here is the call graph for this function:

bool Clasp::Asp::PrgBody::simplify ( LogicProgram prg,
bool  strong,
uint32 *  eqId = 0 
)
inline

Calls simplifyBody() and/or simplifyHeads() if necessary.

Here is the call graph for this function:

bool Clasp::Asp::PrgBody::simplifyBody ( LogicProgram prg,
bool  strong,
uint32 *  eqId = 0 
)

Simplifies the body, i.e. its predecessors-lists.

  • removes true/false atoms from B+/B- resp.
  • removes/merges duplicate subgoals
  • checks whether body must be false (e.g. contains false/true atoms in B+/B- resp. or contains p and ~p)
Precondition
prg.getBody(id()) == this
Parameters
[in]prgThe program containing this body.
[in]strongIf true, treats atoms that have no variable associated as false.
[out]The id of a body in prg that is equivalent to this body.
Returns
  • true if simplification was successful
  • false if simplification detected a conflict

Here is the call graph for this function:

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.

Returns
setValue(value_false) if setting a head of this body to true would make the body false (i.e. the body is a selfblocker). Otherwise, true.

Here is the call graph for this function:

uint32 Clasp::Asp::PrgBody::size ( ) const
inline

Returns the number of atoms in the body.

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.

Here is the call graph for this function:

BodyType Clasp::Asp::PrgBody::type ( ) const
inline
weight_t Clasp::Asp::PrgBody::weight ( uint32  idx) const
inline

Returns the weight of the idx'th subgoal.

Here is the call graph for this function:

Member Data Documentation

SumExtra* Clasp::Asp::PrgBody::ext[0]
uint32 Clasp::Asp::PrgBody::lits[0]

The documentation for this class was generated from the following files: