Skip to content

Commit

Permalink
fix URR to be (really) complete also under AVATAR
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Suda committed Nov 29, 2023
1 parent 92afa25 commit a3f7bad
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 19 deletions.
22 changes: 12 additions & 10 deletions Inferences/URResolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ using namespace Kernel;
using namespace Indexing;
using namespace Saturation;

URResolution::URResolution()
: _selectedOnly(false), _unitIndex(0), _nonUnitIndex(0) {}
URResolution::URResolution(bool full)
: _full(full), _selectedOnly(false), _unitIndex(0), _nonUnitIndex(0) {}

/**
* Creates URResolution object with explicitely supplied
Expand All @@ -58,9 +58,9 @@ URResolution::URResolution()
* For objects created using this constructor it is not allowed
* to call the @c attach() function.
*/
URResolution::URResolution(bool selectedOnly, UnitClauseLiteralIndex* unitIndex,
URResolution::URResolution(bool full, bool selectedOnly, UnitClauseLiteralIndex* unitIndex,
NonUnitClauseLiteralIndex* nonUnitIndex)
: _emptyClauseOnly(false), _selectedOnly(selectedOnly), _unitIndex(unitIndex), _nonUnitIndex(nonUnitIndex) {}
: _full(full), _emptyClauseOnly(false), _selectedOnly(selectedOnly), _unitIndex(unitIndex), _nonUnitIndex(nonUnitIndex) {}

void URResolution::attach(SaturationAlgorithm* salg)
{
Expand Down Expand Up @@ -99,8 +99,8 @@ void URResolution::detach()

struct URResolution::Item
{
USE_ALLOCATOR(URResolution::Item);
USE_ALLOCATOR(URResolution::Item);

Item(Clause* cl, bool selectedOnly, URResolution& parent, bool mustResolveAll)
: _orig(cl), _color(cl->color()), _parent(parent)
{
Expand Down Expand Up @@ -151,7 +151,7 @@ struct URResolution::Item
if (!_ansLit) {
_ansLit = premAnsLit;
} else if (_ansLit != premAnsLit) {
bool neg = rlit->isNegative();
bool neg = rlit->isNegative();
Literal* resolved = unif.substitution->apply(rlit, !useQuerySubstitution);
if (neg) {
resolved = Literal::complementaryLiteral(resolved);
Expand Down Expand Up @@ -311,9 +311,11 @@ void URResolution::processLiteral(ItemList*& itms, unsigned idx)
itm2->resolveLiteral(idx, unif, unif.clause, true);
iit.insert(itm2);

if(itm->_atMostOneNonGround && (!synthesis || !unif.clause->hasAnswerLiteral())) {
//if there is only one non-ground literal left, there is no need to retrieve
//all unifications
if(!_full && itm->_atMostOneNonGround && (!synthesis || !unif.clause->hasAnswerLiteral())) {
/* if there is only one non-ground literal left, there is no need to retrieve all unifications.
However, this does not hold under AVATAR where different empty clauses may close different
splitting branches, that's why only "full" URR is complete under AVATAR (see Options::complete)
*/
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions Inferences/URResolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class URResolution
public:
USE_ALLOCATOR(URResolution);

URResolution();
URResolution(bool selectedOnly, UnitClauseLiteralIndex* unitIndex,
URResolution(bool full);
URResolution(bool full, bool selectedOnly, UnitClauseLiteralIndex* unitIndex,
NonUnitClauseLiteralIndex* nonUnitIndex);

void attach(SaturationAlgorithm* salg);
Expand All @@ -51,7 +51,7 @@ class URResolution

void doBackwardInferences(Clause* cl, ClauseList*& acc);


bool _full;
bool _emptyClauseOnly;
bool _selectedOnly;
UnitClauseLiteralIndex* _unitIndex;
Expand Down
2 changes: 1 addition & 1 deletion Saturation/SaturationAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ SaturationAlgorithm* SaturationAlgorithm::createFromOptions(Problem& prb, const
gie->addFront(new BinaryResolution());
}
if (opt.unitResultingResolution() != Options::URResolution::OFF) {
gie->addFront(new URResolution());
gie->addFront(new URResolution(opt.unitResultingResolution() == Options::URResolution::FULL));
}
if (opt.extensionalityResolution() != Options::ExtensionalityResolution::OFF) {
gie->addFront(new ExtensionalityResolution());
Expand Down
12 changes: 8 additions & 4 deletions Shell/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1658,13 +1658,16 @@ void Options::init()
_equationalTautologyRemoval.onlyUsefulWith(ProperSaturationAlgorithm());
_equationalTautologyRemoval.tag(OptionTag::INFERENCES);

_unitResultingResolution = ChoiceOptionValue<URResolution>("unit_resulting_resolution","urr",URResolution::OFF,{"ec_only","off","on"});
_unitResultingResolution = ChoiceOptionValue<URResolution>("unit_resulting_resolution","urr",URResolution::OFF,{"ec_only","off","on","full"});
_unitResultingResolution.description=
"Uses unit resulting resolution only to derive empty clauses (may be useful for splitting)";
"Uses unit resulting resolution only to derive empty clauses (may be useful for splitting)."
" 'ec_only' only derives empty clauses, 'on' does everything (but implements a heuristic to skip deriving more than one empty clause)"
" 'full' ignores this heuristic is thus complete also under AVATAR.";
_lookup.insert(&_unitResultingResolution);
_unitResultingResolution.tag(OptionTag::INFERENCES);
_unitResultingResolution.onlyUsefulWith(ProperSaturationAlgorithm());
_unitResultingResolution.addProblemConstraint(notJustEquality());
_unitResultingResolution.addConstraint(If(equal(URResolution::FULL)).then(_splitting.is(equal(true))));
// If br has already been set off then this will be forced on, if br has not yet been set
// then setting this to off will force br on

Expand Down Expand Up @@ -3414,9 +3417,10 @@ bool Options::complete(const Problem& prb) const

if (!hasEquality) {
if (_binaryResolution.actualValue) return true;
if (_unitResultingResolution.actualValue!=URResolution::ON) return false;
// binary resolution is off
return prop.category() == Property::HNE; // URR is complete for Horn problems
if (_unitResultingResolution.actualValue!=URResolution::FULL &&
(_unitResultingResolution.actualValue!=URResolution::ON || _splitting.actualValue) ) return false;
return prop.category() == Property::HNE; // enough URR is complete for Horn problems
}

if (_demodulationRedundancyCheck.actualValue == DemodulationRedunancyCheck::OFF) {
Expand Down
3 changes: 2 additions & 1 deletion Shell/Options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,8 @@ class Options
enum class URResolution : unsigned int {
EC_ONLY = 0,
OFF = 1,
ON = 2
ON = 2,
FULL = 3
};

enum class TermOrdering : unsigned int {
Expand Down

0 comments on commit a3f7bad

Please sign in to comment.