dlvhex
2.5.0
|
Factory for model generators which provides capability for true FLP reduct computation via rewriting, guessing, and checking. More...
#include <include/dlvhex2/FLPModelGeneratorBase.h>
Public Member Functions | |
FLPModelGeneratorFactoryBase (ProgramCtx &ctx) | |
virtual | ~FLPModelGeneratorFactoryBase () |
Protected Member Functions | |
void | createEatomGuessingRules (const ProgramCtx &ctx) |
Creates guessing rules for all external atoms in the component. | |
ID | createEatomGuessingRule (const ProgramCtx &ctx, ID ruleID, ID litID) |
Creates guessing rules for one external atom in the component. | |
void | createFLPRules () |
Create rules from xidb. | |
void | computeCyclicInputPredicates (RegistryPtr reg, ProgramCtx &ctx, const std::vector< ID > &idb) |
Computes the set of predicates which occur in a cycle. | |
Protected Attributes | |
ProgramCtx & | ctx |
ProgramCtx. | |
RegistryPtr | reg |
RegistryPtr. | |
std::vector< ID > | idb |
Original idb, possibly augmented with domain predicates (may contain eatoms where all inputs are known). | |
std::vector< ID > | innerEatoms |
Inner external atoms (those are guessed). | |
std::vector< ID > | gidb |
One guessing rule for each inner eatom. | |
std::vector< ID > | xidb |
IDB rewritten with eatom replacement atoms. | |
std::vector< ID > | deidb |
IDB for domain exploration (equivalent to xidb, except that it does not contain domain predicates). | |
std::vector< ID > | deidbInnerEatoms |
Inner external Atoms in deidb. | |
std::vector< ID > | xidbflphead |
Rewriting to find out which body is satisfied -> creates heads. | |
std::vector< ID > | xidbflpbody |
Rewriting to compute the reduct's models -> has flp auxiliaries in bodies. | |
PredicateMask | gpMask |
Mask for positive external atom guesses. | |
PredicateMask | gnMask |
Mask for negative external atom guesses. | |
PredicateMask | fMask |
Incrementally updated bitmask for FLP auxiliary predicates. | |
Friends | |
class | FLPModelGeneratorBase |
Factory for model generators which provides capability for true FLP reduct computation via rewriting, guessing, and checking.
Definition at line 49 of file FLPModelGeneratorBase.h.
DLVHEX_NAMESPACE_BEGIN FLPModelGeneratorFactoryBase::FLPModelGeneratorFactoryBase | ( | ProgramCtx & | ctx | ) |
Definition at line 58 of file FLPModelGeneratorBase.cpp.
References fMask, gnMask, gpMask, reg, and PredicateMask::setRegistry().
virtual FLPModelGeneratorFactoryBase::~FLPModelGeneratorFactoryBase | ( | ) | [inline, virtual] |
Definition at line 54 of file FLPModelGeneratorBase.h.
void FLPModelGeneratorFactoryBase::computeCyclicInputPredicates | ( | RegistryPtr | reg, |
ProgramCtx & | ctx, | ||
const std::vector< ID > & | idb | ||
) | [protected] |
Computes the set of predicates which occur in a cycle.
reg | Registry. |
ctx | ProgramCtx. |
idb | Original IDB. |
ID FLPModelGeneratorFactoryBase::createEatomGuessingRule | ( | const ProgramCtx & | ctx, |
ID | ruleID, | ||
ID | litID | ||
) | [protected] |
Creates guessing rules for one external atom in the component.
ctx | ProgramCtx. |
ruleID | Rule which contains the external atom. |
litID | External atom ID. |
Definition at line 112 of file FLPModelGeneratorBase.cpp.
References PredicateMask::addPredicate(), ExternalAtom::auxInputMapping, ExternalAtom::auxInputPredicate, Rule::body, ProgramCtx::config, DBGLOG, DBGLOG_INDENT, Configuration::getOption(), gnMask, gpMask, Rule::head, ID_FAIL(), ExternalAtom::inputs, ID::isAggregateAtom(), ID::isBuiltinAtom(), ID::isExternalAtom(), ID::isNaf(), ID::isOrdinaryNongroundAtom(), ID::isVariableTerm(), Atom::kind, ID::MAINKIND_ATOM, ID::MAINKIND_RULE, ID::posLiteralFromAtom(), ExternalAtom::predicate, ID::PROPERTY_AUX, ID::PROPERTY_EXTERNALAUX, ID::PROPERTY_EXTERNALINPUTAUX, ID::PROPERTY_RULE_DISJ, reg, ID::SUBKIND_ATOM_ORDINARYG, ID::SUBKIND_ATOM_ORDINARYN, ID::SUBKIND_RULE_REGULAR, ID::TERM_BUILTIN_EQ, ID::TERM_BUILTIN_GE, ID::TERM_BUILTIN_GT, ID::TERM_BUILTIN_LE, ID::TERM_BUILTIN_LT, ID::TERM_BUILTIN_NE, and Atom::tuple.
Referenced by createEatomGuessingRules().
void FLPModelGeneratorFactoryBase::createEatomGuessingRules | ( | const ProgramCtx & | ctx | ) | [protected] |
Creates guessing rules for all external atoms in the component.
go through all rules with external atoms for each such rule and each inner eatom in the body: * collect all variables in the eatom (input and output) * collect all positive non-external predicates in the rule body containing these variables * build rule <aux_ext_eatompos>(<all variables>="">) v <aux_ext_eatomneg>(<all variables>="">) :- <all bodies>=""> * store into gidb
ctx | ProgramCtx. |
Definition at line 76 of file FLPModelGeneratorBase.cpp.
References ID::atomFromLiteral(), Rule::body, createEatomGuessingRule(), DBGLOG, DBGLOG_SCOPE, ID::doesRuleContainExtatoms(), gidb, idb, innerEatoms, ID::isExternalAtom(), and reg.
Referenced by GenuineGuessAndCheckModelGeneratorFactory::GenuineGuessAndCheckModelGeneratorFactory().
void FLPModelGeneratorFactoryBase::createFLPRules | ( | ) | [protected] |
Create rules from xidb.
for each rule in xidb * keep disjunctive facts: copy ID to xidbflphead and xidbflpbody * (note: nondisjunctive facts are stored in edb) * for all other rules: * collect all variables in the body (which means also all variables in the head) * create ground or nonground flp replacement atom containing all variables * create rule <flpreplacement>(<allvariables>) :- <body> and store in xidbflphead * create rule <head> :- <flpreplacement>(<allvariables>), <body> and store in xidbflpbody
* For evaluating which bodies are satisfied -> xidbflphead -> this program creates flp auxiliary atoms * For evaluating the reduct -> xidbflpbody -> this program has flp auxiliary atoms in the body
Definition at line 277 of file FLPModelGeneratorBase.cpp.
References PredicateMask::addPredicate(), Rule::body, ProgramCtx::config, ctx, DBGLOG, DBGLOG_SCOPE, fMask, Configuration::getOption(), Rule::head, ID_FAIL(), IDKind, ID::isAggregateAtom(), ID::isBuiltinAtom(), ID::isConstraint(), Rule::isEAAuxInputRule(), ID::isExternalAtom(), ID::isOrdinaryGroundAtom(), ID::isOrdinaryNongroundAtom(), ID::isRegularRule(), ID::isVariableTerm(), Rule::kind, Atom::kind, ID::literalFromAtom(), LOG, ID::MAINKIND_ATOM, ID::MAINKIND_RULE, RawPrinter::print(), printset(), ID::PROPERTY_AUX, ID::PROPERTY_FLPAUX, ID::PROPERTY_RULE_DISJ, reg, ID::SUBKIND_ATOM_ORDINARYG, ID::SUBKIND_ATOM_ORDINARYN, ID::SUBKIND_RULE_CONSTRAINT, ID::SUBKIND_RULE_REGULAR, Atom::tuple, WARNING(), xidb, xidbflpbody, and xidbflphead.
Referenced by GenuineGuessAndCheckModelGeneratorFactory::GenuineGuessAndCheckModelGeneratorFactory().
friend class FLPModelGeneratorBase [friend] |
Definition at line 132 of file FLPModelGeneratorBase.h.
ProgramCtx& FLPModelGeneratorFactoryBase::ctx [protected] |
Reimplemented in GenuineGuessAndCheckModelGeneratorFactory, and GuessAndCheckModelGeneratorFactory.
Definition at line 59 of file FLPModelGeneratorBase.h.
Referenced by createFLPRules().
std::vector<ID> FLPModelGeneratorFactoryBase::deidb [protected] |
IDB for domain exploration (equivalent to xidb, except that it does not contain domain predicates).
Definition at line 83 of file FLPModelGeneratorBase.h.
Referenced by GenuineGuessAndCheckModelGenerator::GenuineGuessAndCheckModelGenerator(), and GenuineGuessAndCheckModelGeneratorFactory::GenuineGuessAndCheckModelGeneratorFactory().
std::vector<ID> FLPModelGeneratorFactoryBase::deidbInnerEatoms [protected] |
Inner external Atoms in deidb.
Definition at line 85 of file FLPModelGeneratorBase.h.
Referenced by GenuineGuessAndCheckModelGenerator::GenuineGuessAndCheckModelGenerator(), and GenuineGuessAndCheckModelGeneratorFactory::GenuineGuessAndCheckModelGeneratorFactory().
PredicateMask FLPModelGeneratorFactoryBase::fMask [protected] |
Incrementally updated bitmask for FLP auxiliary predicates.
Definition at line 101 of file FLPModelGeneratorBase.h.
Referenced by createFLPRules(), FLPModelGeneratorFactoryBase(), and FLPModelGeneratorBase::isSubsetMinimalFLPModel().
std::vector<ID> FLPModelGeneratorFactoryBase::gidb [protected] |
One guessing rule for each inner eatom.
If one rule contains two inner eatoms, two guessing rules are created.
Definition at line 77 of file FLPModelGeneratorBase.h.
Referenced by createEatomGuessingRules(), GenuineGuessAndCheckModelGenerator::GenuineGuessAndCheckModelGenerator(), GuessAndCheckModelGenerator::GuessAndCheckModelGenerator(), FLPModelGeneratorBase::isSubsetMinimalFLPModel(), GuessAndCheckModelGeneratorFactory::print(), and GenuineGuessAndCheckModelGeneratorFactory::print().
PredicateMask FLPModelGeneratorFactoryBase::gnMask [protected] |
Mask for negative external atom guesses.
Definition at line 98 of file FLPModelGeneratorBase.h.
Referenced by createEatomGuessingRule(), FLPModelGeneratorFactoryBase(), GuessAndCheckModelGenerator::generateNextModel(), GenuineGuessAndCheckModelGenerator::generateNextModel(), FLPModelGeneratorBase::isCompatibleSet(), and FLPModelGeneratorBase::isSubsetMinimalFLPModel().
PredicateMask FLPModelGeneratorFactoryBase::gpMask [protected] |
Mask for positive external atom guesses.
Definition at line 96 of file FLPModelGeneratorBase.h.
Referenced by createEatomGuessingRule(), FLPModelGeneratorFactoryBase(), GuessAndCheckModelGenerator::generateNextModel(), GenuineGuessAndCheckModelGenerator::generateNextModel(), FLPModelGeneratorBase::isCompatibleSet(), and FLPModelGeneratorBase::isSubsetMinimalFLPModel().
std::vector<ID> FLPModelGeneratorFactoryBase::idb [protected] |
Original idb, possibly augmented with domain predicates (may contain eatoms where all inputs are known).
Auxiliary input rules of these eatoms must be in predecessor unit!
Definition at line 69 of file FLPModelGeneratorBase.h.
Referenced by createEatomGuessingRules(), GenuineGuessAndCheckModelGeneratorFactory::GenuineGuessAndCheckModelGeneratorFactory(), GuessAndCheckModelGeneratorFactory::print(), and GenuineGuessAndCheckModelGeneratorFactory::print().
std::vector<ID> FLPModelGeneratorFactoryBase::innerEatoms [protected] |
Inner external atoms (those are guessed).
Definition at line 72 of file FLPModelGeneratorBase.h.
Referenced by createEatomGuessingRules(), GenuineGuessAndCheckModelGenerator::GenuineGuessAndCheckModelGenerator(), GenuineGuessAndCheckModelGeneratorFactory::GenuineGuessAndCheckModelGeneratorFactory(), GuessAndCheckModelGeneratorFactory::GuessAndCheckModelGeneratorFactory(), GenuineGuessAndCheckModelGenerator::inlineExternalAtoms(), FLPModelGeneratorBase::isCompatibleSet(), FLPModelGeneratorBase::isSubsetMinimalFLPModel(), GuessAndCheckModelGeneratorFactory::print(), and GenuineGuessAndCheckModelGeneratorFactory::print().
RegistryPtr FLPModelGeneratorFactoryBase::reg [protected] |
RegistryPtr.
Definition at line 63 of file FLPModelGeneratorBase.h.
Referenced by createEatomGuessingRule(), createEatomGuessingRules(), createFLPRules(), FLPModelGeneratorFactoryBase(), GuessAndCheckModelGenerator::generateNextModel(), GenuineGuessAndCheckModelGenerator::GenuineGuessAndCheckModelGenerator(), FLPModelGeneratorBase::getFLPNogood(), GuessAndCheckModelGenerator::GuessAndCheckModelGenerator(), FLPModelGeneratorBase::isCompatibleSet(), and FLPModelGeneratorBase::isSubsetMinimalFLPModel().
std::vector<ID> FLPModelGeneratorFactoryBase::xidb [protected] |
IDB rewritten with eatom replacement atoms.
Definition at line 80 of file FLPModelGeneratorBase.h.
Referenced by createFLPRules(), GenuineGuessAndCheckModelGenerator::GenuineGuessAndCheckModelGenerator(), GenuineGuessAndCheckModelGeneratorFactory::GenuineGuessAndCheckModelGeneratorFactory(), GuessAndCheckModelGenerator::GuessAndCheckModelGenerator(), GuessAndCheckModelGeneratorFactory::print(), and GenuineGuessAndCheckModelGeneratorFactory::print().
std::vector<ID> FLPModelGeneratorFactoryBase::xidbflpbody [protected] |
Rewriting to compute the reduct's models -> has flp auxiliaries in bodies.
Definition at line 91 of file FLPModelGeneratorBase.h.
Referenced by createFLPRules(), FLPModelGeneratorBase::isSubsetMinimalFLPModel(), GuessAndCheckModelGeneratorFactory::print(), and GenuineGuessAndCheckModelGeneratorFactory::print().
std::vector<ID> FLPModelGeneratorFactoryBase::xidbflphead [protected] |
Rewriting to find out which body is satisfied -> creates heads.
Definition at line 89 of file FLPModelGeneratorBase.h.
Referenced by createFLPRules(), FLPModelGeneratorBase::isSubsetMinimalFLPModel(), GuessAndCheckModelGeneratorFactory::print(), and GenuineGuessAndCheckModelGeneratorFactory::print().