Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * Top contributors (to current version): 3 : : * Andrew Reynolds 4 : : * 5 : : * This file is part of the cvc5 project. 6 : : * 7 : : * Copyright (c) 2009-2025 by the authors listed in the file AUTHORS 8 : : * in the top-level source directory and their institutional affiliations. 9 : : * All rights reserved. See the file COPYING in the top-level source 10 : : * directory for licensing information. 11 : : * **************************************************************************** 12 : : * 13 : : * Implementation of expression miner manager. 14 : : */ 15 : : 16 : : #include "theory/quantifiers/expr_miner_manager.h" 17 : : 18 : : #include "options/quantifiers_options.h" 19 : : #include "smt/env.h" 20 : : #include "theory/datatypes/sygus_datatype_utils.h" 21 : : #include "theory/quantifiers/query_generator_sample_sat.h" 22 : : #include "theory/quantifiers/query_generator_unsat.h" 23 : : 24 : : namespace cvc5::internal { 25 : : namespace theory { 26 : : namespace quantifiers { 27 : : 28 : 511 : ExpressionMinerManager::ExpressionMinerManager(Env& env) 29 : 511 : : EnvObj(env), d_doFilterLogicalStrength(false), d_sols(env) 30 : : { 31 : 511 : } 32 : : 33 : 511 : void ExpressionMinerManager::initializeSygus(const TypeNode& tn) 34 : : { 35 [ - + ][ - + ]: 511 : Assert(tn.isDatatype()); [ - - ] 36 : 511 : const DType& dt = tn.getDType(); 37 [ - + ][ - + ]: 511 : Assert(dt.isSygus()); [ - - ] 38 : 1022 : Node vlist = dt.getSygusVarList(); 39 : 1022 : std::vector<Node> vars; 40 [ + + ]: 511 : if (!vlist.isNull()) 41 : : { 42 [ + + ]: 1544 : for (const Node& sv : vlist) 43 : : { 44 : 1037 : d_vars.push_back(sv); 45 : : } 46 : : } 47 : 511 : if (options().quantifiers.sygusFilterSolMode 48 [ + - ]: 511 : == options::SygusFilterSolMode::STRONG) 49 : : { 50 : 511 : enableFilterStrongSolutions(); 51 : : } 52 : 0 : else if (options().quantifiers.sygusFilterSolMode 53 [ - - ]: 0 : == options::SygusFilterSolMode::WEAK) 54 : : { 55 : 0 : enableFilterWeakSolutions(); 56 : : } 57 : 511 : } 58 : : 59 : 0 : void ExpressionMinerManager::enableFilterWeakSolutions() 60 : : { 61 : 0 : d_doFilterLogicalStrength = true; 62 : 0 : d_sols.initialize(d_vars); 63 : 0 : d_sols.setLogicallyStrong(true); 64 : 0 : } 65 : : 66 : 511 : void ExpressionMinerManager::enableFilterStrongSolutions() 67 : : { 68 : 511 : d_doFilterLogicalStrength = true; 69 : 511 : d_sols.initialize(d_vars); 70 : 511 : d_sols.setLogicallyStrong(false); 71 : 511 : } 72 : : 73 : 1479 : bool ExpressionMinerManager::addTerm(Node sol) 74 : : { 75 : : // set the builtin version 76 : 1479 : Node solb = datatypes::utils::sygusToBuiltin(sol, true); 77 : : 78 : 1479 : bool ret = true; 79 : : // filter based on logical strength 80 [ + - ]: 1479 : if (d_doFilterLogicalStrength) 81 : : { 82 : 1479 : std::vector<Node> filtered; 83 : 1479 : ret = d_sols.addTerm(solb, filtered); 84 : : } 85 : 2958 : return ret; 86 : : } 87 : : 88 : : } // namespace quantifiers 89 : : } // namespace theory 90 : : } // namespace cvc5::internal