Skip to content

Commit

Permalink
no interpreted distinct groups; should be done by InterpretedEvaluati…
Browse files Browse the repository at this point in the history
…on + some polishing
  • Loading branch information
Martin Suda committed Nov 15, 2017
1 parent f63f373 commit 81ffc0e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 36 deletions.
30 changes: 13 additions & 17 deletions Kernel/Signature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "Lib/Environment.hpp"
#include "Lib/Int.hpp"
#include "Shell/Options.hpp"
#include "Shell/DistinctGroupExpansion.hpp"

#include "Signature.hpp"

Expand All @@ -32,10 +33,6 @@ using namespace Kernel;
using namespace Shell;

const unsigned Signature::STRING_DISTINCT_GROUP = 0;
const unsigned Signature::INTEGER_DISTINCT_GROUP = 1;
const unsigned Signature::RATIONAL_DISTINCT_GROUP = 2;
const unsigned Signature::REAL_DISTINCT_GROUP = 3;
const unsigned Signature::LAST_BUILT_IN_DISTINCT_GROUP = 3;

/**
* Standard constructor.
Expand Down Expand Up @@ -131,9 +128,10 @@ void Signature::Symbol::addToDistinctGroup(unsigned group,unsigned this_number)
env.signature->_distinctGroupsAddedTo=true;

Stack<unsigned>* members = env.signature->_distinctGroupMembers[group];
// see DistinctGroupExpansion::apply for why 141
if(members->size()<141 || env.options->bfnt()
|| env.options->saturationAlgorithm()==Options::SaturationAlgorithm::FINITE_MODEL_BUILDING){
if(members->size() <= DistinctGroupExpansion::EXPAND_UP_TO_SIZE || env.options->bfnt()
|| env.options->saturationAlgorithm()==Options::SaturationAlgorithm::FINITE_MODEL_BUILDING){
// we add one more than EXPAND_UP_TO_SIZE to signal to DistinctGroupExpansion::apply not to expand
// ... instead DistinctEqualitySimplifier will take over
members->push(this_number);
}

Expand Down Expand Up @@ -225,17 +223,8 @@ Signature::Signature ():
getPredicate(0)->markSkip();

unsigned aux;
// Warning! reordering or removing some of below may brake the code in
// DistinctGroupExpansion::apply(UnitList*& units)
aux = createDistinctGroup();
ASS_EQ(STRING_DISTINCT_GROUP, aux);
aux = createDistinctGroup();
ASS_EQ(INTEGER_DISTINCT_GROUP, aux);
aux = createDistinctGroup();
ASS_EQ(RATIONAL_DISTINCT_GROUP, aux);
aux = createDistinctGroup();
ASS_EQ(REAL_DISTINCT_GROUP, aux);

} // Signature::Signature

/**
Expand Down Expand Up @@ -277,10 +266,12 @@ unsigned Signature::addIntegerConstant(const vstring& number,bool defaultSort)

result = _funs.length();
Symbol* sym = new Symbol(name,0,false,false,true);
/*
sym->addToDistinctGroup(INTEGER_DISTINCT_GROUP,result);
if(defaultSort){
sym->addToDistinctGroup(STRING_DISTINCT_GROUP,result); // numbers are disctinct from strings
}
*/
_funs.push(sym);
_funNames.insert(symbolKey,result);
return result;
Expand All @@ -304,8 +295,9 @@ unsigned Signature::addIntegerConstant(const IntegerConstantType& value)
Symbol* sym = new IntegerSymbol(value);
_funs.push(sym);
_funNames.insert(key,result);
/*
sym->addToDistinctGroup(INTEGER_DISTINCT_GROUP,result);
//sym->addToDistinctGroup(STRING_DISTINCT_GROUP,result); // numbers are distinct from strings
*/
return result;
} // addIntegerConstant

Expand All @@ -332,10 +324,12 @@ unsigned Signature::addRationalConstant(const vstring& numerator, const vstring&
}
result = _funs.length();
Symbol* sym = new Symbol(name,0,false,false,true);
/*
if(defaultSort){
sym->addToDistinctGroup(STRING_DISTINCT_GROUP,result); // numbers are distinct from strings
}
sym->addToDistinctGroup(RATIONAL_DISTINCT_GROUP,result);
*/
_funs.push(sym);
_funNames.insert(key,result);
return result;
Expand Down Expand Up @@ -378,10 +372,12 @@ unsigned Signature::addRealConstant(const vstring& number,bool defaultSort)
}
result = _funs.length();
Symbol* sym = new Symbol(value.toNiceString(),0,false,false,true);
/*
if(defaultSort){
sym->addToDistinctGroup(STRING_DISTINCT_GROUP,result); // numbers are distinct from strings
}
sym->addToDistinctGroup(REAL_DISTINCT_GROUP,result);
*/
_funs.push(sym);
_funNames.insert(key,result);
return result;
Expand Down
4 changes: 0 additions & 4 deletions Kernel/Signature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,6 @@ class Signature
unsigned reals() const {return _reals;}

static const unsigned STRING_DISTINCT_GROUP;
static const unsigned INTEGER_DISTINCT_GROUP;
static const unsigned RATIONAL_DISTINCT_GROUP;
static const unsigned REAL_DISTINCT_GROUP;
static const unsigned LAST_BUILT_IN_DISTINCT_GROUP;

unsigned getFoolConstantSymbol(bool isTrue){
if(!_foolConstantsDefined){
Expand Down
2 changes: 1 addition & 1 deletion Parse/TPTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2492,7 +2492,7 @@ Formula* TPTP::createPredicateApplication(vstring name, unsigned arity)
}
env.signature->addToDistinctGroup(ts.term()->functor(),grpIdx);
}
return new Formula(true); // we ignore it, it evalutes to true as we have recorded it elsewhere
return new Formula(true); // we ignore it, it evaluates to true as we have recorded it elsewhere
}
}
// not equality or distinct
Expand Down
16 changes: 2 additions & 14 deletions Shell/DistinctGroupExpansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,8 @@ bool DistinctGroupExpansion::apply(UnitList*& units)

for(unsigned i=0;i<group_members.size();i++){
Stack<unsigned>* members = group_members[i];
if(i==Signature::STRING_DISTINCT_GROUP && !env.signature->strings()){ continue;} // If there are no strings do not expand group
if(members->size() > 0){
// If the non-empty distinct group represents numbers then we need to keep
// the distinct processing later as new numbers can be generated from the
// existing ones

Signature::Symbol* sym = env.signature->getFunction(members->top());
unsigned grp_sort = sym->fnType()->result();

if(grp_sort==Sorts::SRT_INTEGER || grp_sort==Sorts::SRT_RATIONAL || grp_sort==Sorts::SRT_REAL){ someLeft=true; }

// This 140 is a magic number, if it is changed then the corresponding
// 141 should be changed in Kernel::Signature::Symbol::addToDistinctGroup
if( members->size()>1 && (members->size() < 140 || expandEverything)){
if(members->size() > 0) {
if( members->size()>1 && (members->size() <= EXPAND_UP_TO_SIZE || expandEverything)) {
added=true;
Formula* expansion = expand(*members);
if(env.options->showPreprocessing()){
Expand Down
2 changes: 2 additions & 0 deletions Shell/DistinctGroupExpansion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ using namespace Kernel;
*/
class DistinctGroupExpansion {
public:
static const unsigned EXPAND_UP_TO_SIZE = 140;

DistinctGroupExpansion(){}

void apply(Problem& prb);
Expand Down

0 comments on commit 81ffc0e

Please sign in to comment.