Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * Utilities for converting CaDiCaL-specific types to cvc5 types. 11 : : */ 12 : : #include "prop/cadical/util.h" 13 : : 14 : : #include "base/check.h" 15 : : 16 : : namespace cvc5::internal::prop::cadical { 17 : : 18 : 73951 : SatValue toSatValue(int result) 19 : : { 20 [ + + ]: 73951 : if (result == 10) return SAT_VALUE_TRUE; 21 [ + + ]: 20054 : if (result == 20) return SAT_VALUE_FALSE; 22 [ - + ][ - + ]: 2 : Assert(result == 0); [ - - ] 23 : 2 : return SAT_VALUE_UNKNOWN; 24 : : } 25 : : 26 : : // Note: CaDiCaL returns lit/-lit for true/false. Older versions returned 1/-1. 27 : 430180 : SatValue toSatValueLit(int value) 28 : : { 29 [ + + ]: 430180 : if (value > 0) return SAT_VALUE_TRUE; 30 [ - + ][ - + ]: 151190 : Assert(value < 0); [ - - ] 31 : 151190 : return SAT_VALUE_FALSE; 32 : : } 33 : : 34 : 30546742 : CadicalLit toCadicalLit(const SatLiteral lit) 35 : : { 36 [ + + ]: 30546742 : return lit.isNegated() ? -lit.getSatVariable() : lit.getSatVariable(); 37 : : } 38 : : 39 : 926 : SatLiteral toSatLiteral(CadicalLit lit) 40 : : { 41 : 926 : return SatLiteral(std::abs(lit), lit < 0); 42 : : } 43 : : 44 : 510710 : CadicalVar toCadicalVar(SatVariable var) { return var; } 45 : : 46 : 0 : SatClause toSatClause(const std::unordered_set<int64_t>& activation_literals, 47 : : const std::vector<int32_t>& cl) 48 : : { 49 : 0 : SatClause clause; 50 [ - - ]: 0 : for (int32_t lit : cl) 51 : : { 52 : : // Filter out activation literals 53 [ - - ]: 0 : if (activation_literals.find(std::abs(lit)) == activation_literals.end()) 54 : : { 55 : 0 : clause.push_back(toSatLiteral(lit)); 56 : : } 57 : : } 58 : 0 : return clause; 59 : 0 : } 60 : : 61 : : } // namespace cvc5::internal::prop::cadical