Skip to content

Commit

Permalink
separate function for debugging irrelevant eqc computation (cvc5#11669)
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-sabharwal authored Feb 24, 2025
1 parent e2d2cfd commit 76b59f0
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 42 deletions.
98 changes: 56 additions & 42 deletions src/theory/quantifiers/conjecture_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,53 +380,14 @@ void ConjectureGenerator::check(Theory::Effort e, QEffort quant_e)
d_hasAddedLemma = false;
d_tge.d_cg = this;
beginCallDebug();
eq::EqualityEngine* ee = getEqualityEngine();
d_conj_count = 0;
std::vector<TNode> eqcs;
getEquivalenceClasses(eqcs);
computeIrrelevantEqcs(eqcs);

//debug printing
if( TraceIsOn("sg-gen-eqc") ){
for( unsigned i=0; i<eqcs.size(); i++ ){
TNode r = eqcs[i];
//print out members
bool firstTime = true;
bool isFalse = areEqual(r, d_false);
eq::EqClassIterator eqc_i = eq::EqClassIterator( r, ee );
while( !eqc_i.isFinished() ){
TNode n = (*eqc_i);
if (getTermDatabase()->hasTermCurrent(n)
&& getTermDatabase()->isTermActive(n)
&& (n.getKind() != Kind::EQUAL || isFalse))
{
if( firstTime ){
Trace("sg-gen-eqc") << "e" << d_em[r] << " : { " << std::endl;
firstTime = false;
}
if( n.hasOperator() ){
Trace("sg-gen-eqc") << " (" << n.getOperator();
for (const Node& nc : n)
{
TNode ar = d_qstate.getRepresentative(nc);
Trace("sg-gen-eqc") << " e" << d_em[ar];
}
Trace("sg-gen-eqc") << ") :: " << n << std::endl;
}else{
Trace("sg-gen-eqc") << " " << n << std::endl;
}
}
++eqc_i;
}
if( !firstTime ){
Trace("sg-gen-eqc") << "}" << std::endl;
//print out ground term
std::map< TNode, Node >::iterator it = d_ground_eqc_map.find( r );
if( it!=d_ground_eqc_map.end() ){
Trace("sg-gen-eqc") << "- Ground term : " << it->second << std::endl;
}
}
}
if( TraceIsOn("sg-gen-eqc") )
{
debugPrintIrrelevantEqcs(eqcs);
}

Trace("sg-proc") << "Compute relevant eqc..." << std::endl;
Expand Down Expand Up @@ -914,6 +875,59 @@ void ConjectureGenerator::computeIrrelevantEqcs(const std::vector<TNode>& eqcs)
Trace("sg-proc") << "...done determine ground EQC" << std::endl;
}

void ConjectureGenerator::debugPrintIrrelevantEqcs(
const std::vector<TNode>& eqcs)
{
eq::EqualityEngine* ee = getEqualityEngine();
for (unsigned i = 0; i < eqcs.size(); i++)
{
TNode r = eqcs[i];
// print out members
bool firstTime = true;
bool isFalse = areEqual(r, d_false);
eq::EqClassIterator eqc_i = eq::EqClassIterator(r, ee);
while (!eqc_i.isFinished())
{
TNode n = (*eqc_i);
if (getTermDatabase()->hasTermCurrent(n)
&& getTermDatabase()->isTermActive(n)
&& (n.getKind() != Kind::EQUAL || isFalse))
{
if (firstTime)
{
Trace("sg-gen-eqc") << "e" << d_em[r] << " : { " << std::endl;
firstTime = false;
}
if (n.hasOperator())
{
Trace("sg-gen-eqc") << " (" << n.getOperator();
for (const Node& nc : n)
{
TNode ar = d_qstate.getRepresentative(nc);
Trace("sg-gen-eqc") << " e" << d_em[ar];
}
Trace("sg-gen-eqc") << ") :: " << n << std::endl;
}
else
{
Trace("sg-gen-eqc") << " " << n << std::endl;
}
}
++eqc_i;
}
if (!firstTime)
{
Trace("sg-gen-eqc") << "}" << std::endl;
// print out ground term
std::map<TNode, Node>::iterator it = d_ground_eqc_map.find(r);
if (it != d_ground_eqc_map.end())
{
Trace("sg-gen-eqc") << "- Ground term : " << it->second << std::endl;
}
}
}
}

std::string ConjectureGenerator::identify() const { return "induction-cg"; }

unsigned ConjectureGenerator::flushWaitingConjectures( unsigned& addedLemmas, int ldepth, int rdepth ) {
Expand Down
14 changes: 14 additions & 0 deletions src/theory/quantifiers/conjecture_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,20 @@ class ConjectureGenerator : public QuantifiersModule
* when synthesizing conjectures.
*/
void computeIrrelevantEqcs(const std::vector<TNode>& eqcs);
/** print information related to the computation of irrelevant equivalence
* classes
*
* This function requires that the contents of the input vector 'eqcs' are
* exactly the representatives of each equivalence class in the current model.
*
* For each element e of eqcs other than nodeManager()->mkConst(false), this
* function prints all terms t ~ e such that t is active (according to the
* term database) and t is not an equality. If e is computed irrelevant (see
* computeIrrelevantEqcs) this function also prints a term that explains why e
* is irrelevant.
*/
void debugPrintIrrelevantEqcs(const std::vector<TNode>& eqcs);

public: //for generalization
//generalizations
bool isGeneralization( TNode patg, TNode pat ) {
Expand Down

0 comments on commit 76b59f0

Please sign in to comment.