}\r
}\r
Trace("sg-proc") << "...done generate terms at depth " << depth << std::endl;\r
- Trace("sg-stats") << "--------> Total LHS of depth : " << rel_term_count << std::endl;\r
+ Trace("sg-stats") << "--------> Total LHS of depth " << depth << " : " << rel_term_count << std::endl;\r
//Trace("conjecture-count") << "Total LHS of depth " << depth << " : " << conj_lhs[depth].size() << std::endl;\r
- //now generate right hand sides\r
+ \r
+ /* test...\r
+ for( unsigned i=0; i<rt_types.size(); i++ ){\r
+ Trace("sg-term-enum") << "Term enumeration for " << rt_types[i] << " : " << std::endl;\r
+ Trace("sg-term-enum") << "Ground term : " << rt_types[i].mkGroundTerm() << std::endl;\r
+ for( unsigned j=0; j<10; j++ ){\r
+ Trace("sg-term-enum") << " " << getEnumerateTerm( rt_types[i], j ) << std::endl;\r
+ }\r
+ }\r
+ */\r
\r
//consider types from relevant terms\r
for( unsigned rdepth=0; rdepth<=depth; rdepth++ ){\r
}\r
}\r
}\r
+ if( (int)addedLemmas>=options::conjectureGenPerRound() ){\r
+ break;\r
+ }\r
}\r
if( (int)addedLemmas>=options::conjectureGenPerRound() ){\r
break;\r
TNode r = (*ueqcs_i);\r
bool firstTime = true;\r
TNode rr = getUniversalRepresentative( r );\r
- Trace("thm-ee") << " " << r;\r
- if( rr!=r ){ Trace("thm-ee") << " [" << rr << "]"; }\r
+ Trace("thm-ee") << " " << rr;\r
Trace("thm-ee") << " : { ";\r
eq::EqClassIterator ueqc_i = eq::EqClassIterator( r, &d_uequalityEngine );\r
while( !ueqc_i.isFinished() ){\r
TNode n = (*ueqc_i);\r
- if( r!=n ){\r
+ if( rr!=n ){\r
if( firstTime ){\r
Trace("thm-ee") << std::endl;\r
firstTime = false;\r
//we have determined a relevant subgoal\r
Node lhs = d_waiting_conjectures_lhs[indices[i]];\r
Node rhs = d_waiting_conjectures_rhs[indices[i]];\r
- Trace("sg-engine") << "*** Consider conjecture : " << lhs << " == " << rhs << std::endl;\r
- Trace("sg-engine-debug") << " score : " << d_waiting_conjectures_score[indices[i]] << std::endl;\r
- std::vector< Node > bvs;\r
- for( std::map< TypeNode, unsigned >::iterator it = d_pattern_var_id[lhs].begin(); it != d_pattern_var_id[lhs].end(); ++it ){\r
- for( unsigned i=0; i<=it->second; i++ ){\r
- bvs.push_back( getFreeVar( it->first, i ) );\r
- }\r
- }\r
- Node rsg;\r
- if( !bvs.empty() ){\r
- Node bvl = NodeManager::currentNM()->mkNode( BOUND_VAR_LIST, bvs );\r
- rsg = NodeManager::currentNM()->mkNode( FORALL, bvl, lhs.eqNode( rhs ) );\r
+ if( options::conjectureFilterCanonical() && ( getUniversalRepresentative( lhs )!=lhs || getUniversalRepresentative( rhs )!=rhs ) ){\r
+ //skip\r
}else{\r
- rsg = lhs.eqNode( rhs );\r
- }\r
- rsg = Rewriter::rewrite( rsg );\r
- d_conjectures.push_back( rsg );\r
- d_eq_conjectures[lhs].push_back( rhs );\r
- d_eq_conjectures[rhs].push_back( lhs );\r
-\r
- Node lem = NodeManager::currentNM()->mkNode( OR, rsg.negate(), rsg );\r
- d_quantEngine->addLemma( lem, false );\r
- d_quantEngine->addRequirePhase( rsg, false );\r
- addedLemmas++;\r
- if( (int)addedLemmas>=options::conjectureGenPerRound() ){\r
- break;\r
+ Trace("sg-engine") << "*** Consider conjecture : " << lhs << " == " << rhs << std::endl;\r
+ Trace("sg-engine-debug") << " score : " << d_waiting_conjectures_score[indices[i]] << std::endl;\r
+ std::vector< Node > bvs;\r
+ for( std::map< TypeNode, unsigned >::iterator it = d_pattern_var_id[lhs].begin(); it != d_pattern_var_id[lhs].end(); ++it ){\r
+ for( unsigned i=0; i<=it->second; i++ ){\r
+ bvs.push_back( getFreeVar( it->first, i ) );\r
+ }\r
+ }\r
+ Node rsg;\r
+ if( !bvs.empty() ){\r
+ Node bvl = NodeManager::currentNM()->mkNode( BOUND_VAR_LIST, bvs );\r
+ rsg = NodeManager::currentNM()->mkNode( FORALL, bvl, lhs.eqNode( rhs ) );\r
+ }else{\r
+ rsg = lhs.eqNode( rhs );\r
+ }\r
+ rsg = Rewriter::rewrite( rsg );\r
+ d_conjectures.push_back( rsg );\r
+ d_eq_conjectures[lhs].push_back( rhs );\r
+ d_eq_conjectures[rhs].push_back( lhs );\r
+\r
+ Node lem = NodeManager::currentNM()->mkNode( OR, rsg.negate(), rsg );\r
+ d_quantEngine->addLemma( lem, false );\r
+ d_quantEngine->addRequirePhase( rsg, false );\r
+ addedLemmas++;\r
+ if( (int)addedLemmas>=options::conjectureGenPerRound() ){\r
+ break;\r
+ }\r
}\r
}else{\r
if( doSort ){\r
}\r
}\r
\r
+Node ConjectureGenerator::getEnumerateTerm( TypeNode tn, unsigned index ) {\r
+ std::map< TypeNode, unsigned >::iterator it = d_typ_enum_map.find( tn );\r
+ unsigned teIndex;\r
+ if( it==d_typ_enum_map.end() ){\r
+ teIndex = (int)d_typ_enum.size();\r
+ d_typ_enum_map[tn] = teIndex;\r
+ d_typ_enum.push_back( TypeEnumerator(tn) );\r
+ }else{\r
+ teIndex = it->second;\r
+ }\r
+ while( index>=d_enum_terms[tn].size() ){\r
+ if( d_typ_enum[teIndex].isFinished() ){\r
+ return Node::null();\r
+ }\r
+ d_enum_terms[tn].push_back( *d_typ_enum[teIndex] );\r
+ ++d_typ_enum[teIndex];\r
+ }\r
+ return d_enum_terms[tn][index];\r
+}\r
+\r
void ConjectureGenerator::processCandidateConjecture( TNode lhs, TNode rhs, unsigned lhs_depth, unsigned rhs_depth ) {\r
int score = considerCandidateConjecture( lhs, rhs ); \r
if( score>0 ){\r
#include "context/cdhashmap.h"\r
#include "context/cdchunk_list.h"\r
#include "theory/quantifiers_engine.h"\r
+#include "theory/type_enumerator.h"\r
\r
namespace CVC4 {\r
namespace theory {\r
bool isGeneralization( TNode patg, TNode pat, std::map< TNode, TNode >& subs );\r
// get generalization depth\r
int calculateGeneralizationDepth( TNode n, std::vector< TNode >& fv );\r
+private:\r
+ //ground term enumeration\r
+ std::map< TypeNode, std::vector< Node > > d_enum_terms;\r
+ //type enumerators\r
+ std::map< TypeNode, unsigned > d_typ_enum_map;\r
+ std::vector< TypeEnumerator > d_typ_enum;\r
+ //get nth term for type\r
+ Node getEnumerateTerm( TypeNode tn, unsigned index );\r
public: //for property enumeration\r
//process this candidate conjecture\r
void processCandidateConjecture( TNode lhs, TNode rhs, unsigned lhs_depth, unsigned rhs_depth );\r
void assertNode( Node n );\r
/** Identify this module (for debugging, dynamic configuration, etc..) */\r
std::string identify() const { return "ConjectureGenerator"; }\r
-\r
//options\r
private:\r
bool optReqDistinctVarPatterns();\r