Skip to content

Commit 76b59f0

Browse files
separate function for debugging irrelevant eqc computation (cvc5#11669)
1 parent e2d2cfd commit 76b59f0

File tree

2 files changed

+70
-42
lines changed

2 files changed

+70
-42
lines changed

src/theory/quantifiers/conjecture_generator.cpp

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -380,53 +380,14 @@ void ConjectureGenerator::check(Theory::Effort e, QEffort quant_e)
380380
d_hasAddedLemma = false;
381381
d_tge.d_cg = this;
382382
beginCallDebug();
383-
eq::EqualityEngine* ee = getEqualityEngine();
384383
d_conj_count = 0;
385384
std::vector<TNode> eqcs;
386385
getEquivalenceClasses(eqcs);
387386
computeIrrelevantEqcs(eqcs);
388-
389387
//debug printing
390-
if( TraceIsOn("sg-gen-eqc") ){
391-
for( unsigned i=0; i<eqcs.size(); i++ ){
392-
TNode r = eqcs[i];
393-
//print out members
394-
bool firstTime = true;
395-
bool isFalse = areEqual(r, d_false);
396-
eq::EqClassIterator eqc_i = eq::EqClassIterator( r, ee );
397-
while( !eqc_i.isFinished() ){
398-
TNode n = (*eqc_i);
399-
if (getTermDatabase()->hasTermCurrent(n)
400-
&& getTermDatabase()->isTermActive(n)
401-
&& (n.getKind() != Kind::EQUAL || isFalse))
402-
{
403-
if( firstTime ){
404-
Trace("sg-gen-eqc") << "e" << d_em[r] << " : { " << std::endl;
405-
firstTime = false;
406-
}
407-
if( n.hasOperator() ){
408-
Trace("sg-gen-eqc") << " (" << n.getOperator();
409-
for (const Node& nc : n)
410-
{
411-
TNode ar = d_qstate.getRepresentative(nc);
412-
Trace("sg-gen-eqc") << " e" << d_em[ar];
413-
}
414-
Trace("sg-gen-eqc") << ") :: " << n << std::endl;
415-
}else{
416-
Trace("sg-gen-eqc") << " " << n << std::endl;
417-
}
418-
}
419-
++eqc_i;
420-
}
421-
if( !firstTime ){
422-
Trace("sg-gen-eqc") << "}" << std::endl;
423-
//print out ground term
424-
std::map< TNode, Node >::iterator it = d_ground_eqc_map.find( r );
425-
if( it!=d_ground_eqc_map.end() ){
426-
Trace("sg-gen-eqc") << "- Ground term : " << it->second << std::endl;
427-
}
428-
}
429-
}
388+
if( TraceIsOn("sg-gen-eqc") )
389+
{
390+
debugPrintIrrelevantEqcs(eqcs);
430391
}
431392

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

878+
void ConjectureGenerator::debugPrintIrrelevantEqcs(
879+
const std::vector<TNode>& eqcs)
880+
{
881+
eq::EqualityEngine* ee = getEqualityEngine();
882+
for (unsigned i = 0; i < eqcs.size(); i++)
883+
{
884+
TNode r = eqcs[i];
885+
// print out members
886+
bool firstTime = true;
887+
bool isFalse = areEqual(r, d_false);
888+
eq::EqClassIterator eqc_i = eq::EqClassIterator(r, ee);
889+
while (!eqc_i.isFinished())
890+
{
891+
TNode n = (*eqc_i);
892+
if (getTermDatabase()->hasTermCurrent(n)
893+
&& getTermDatabase()->isTermActive(n)
894+
&& (n.getKind() != Kind::EQUAL || isFalse))
895+
{
896+
if (firstTime)
897+
{
898+
Trace("sg-gen-eqc") << "e" << d_em[r] << " : { " << std::endl;
899+
firstTime = false;
900+
}
901+
if (n.hasOperator())
902+
{
903+
Trace("sg-gen-eqc") << " (" << n.getOperator();
904+
for (const Node& nc : n)
905+
{
906+
TNode ar = d_qstate.getRepresentative(nc);
907+
Trace("sg-gen-eqc") << " e" << d_em[ar];
908+
}
909+
Trace("sg-gen-eqc") << ") :: " << n << std::endl;
910+
}
911+
else
912+
{
913+
Trace("sg-gen-eqc") << " " << n << std::endl;
914+
}
915+
}
916+
++eqc_i;
917+
}
918+
if (!firstTime)
919+
{
920+
Trace("sg-gen-eqc") << "}" << std::endl;
921+
// print out ground term
922+
std::map<TNode, Node>::iterator it = d_ground_eqc_map.find(r);
923+
if (it != d_ground_eqc_map.end())
924+
{
925+
Trace("sg-gen-eqc") << "- Ground term : " << it->second << std::endl;
926+
}
927+
}
928+
}
929+
}
930+
917931
std::string ConjectureGenerator::identify() const { return "induction-cg"; }
918932

919933
unsigned ConjectureGenerator::flushWaitingConjectures( unsigned& addedLemmas, int ldepth, int rdepth ) {

src/theory/quantifiers/conjecture_generator.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,20 @@ class ConjectureGenerator : public QuantifiersModule
542542
* when synthesizing conjectures.
543543
*/
544544
void computeIrrelevantEqcs(const std::vector<TNode>& eqcs);
545+
/** print information related to the computation of irrelevant equivalence
546+
* classes
547+
*
548+
* This function requires that the contents of the input vector 'eqcs' are
549+
* exactly the representatives of each equivalence class in the current model.
550+
*
551+
* For each element e of eqcs other than nodeManager()->mkConst(false), this
552+
* function prints all terms t ~ e such that t is active (according to the
553+
* term database) and t is not an equality. If e is computed irrelevant (see
554+
* computeIrrelevantEqcs) this function also prints a term that explains why e
555+
* is irrelevant.
556+
*/
557+
void debugPrintIrrelevantEqcs(const std::vector<TNode>& eqcs);
558+
545559
public: //for generalization
546560
//generalizations
547561
bool isGeneralization( TNode patg, TNode pat ) {

0 commit comments

Comments
 (0)