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 non-linear constraints. 11 : : */ 12 : : 13 : : #ifndef CVC5__THEORY__ARITH__NL__EXT__CONSTRAINT_H 14 : : #define CVC5__THEORY__ARITH__NL__EXT__CONSTRAINT_H 15 : : 16 : : #include <map> 17 : : #include <vector> 18 : : 19 : : #include "expr/kind.h" 20 : : #include "expr/node.h" 21 : : 22 : : namespace cvc5::internal { 23 : : namespace theory { 24 : : namespace arith { 25 : : namespace nl { 26 : : 27 : : class MonomialDb; 28 : : 29 : : /** constraint information 30 : : * 31 : : * The struct ( d_rhs, d_coeff, d_type ) represents that a literal is of the 32 : : * form (d_coeff * x) <d_type> d_rhs. 33 : : */ 34 : : struct ConstraintInfo 35 : : { 36 : : public: 37 : : /** The term on the right hand side of the constraint */ 38 : : Node d_rhs; 39 : : /** The coefficent */ 40 : : Node d_coeff; 41 : : /** The type (relation) of the constraint */ 42 : : Kind d_type; 43 : : }; /* struct ConstraintInfo */ 44 : : 45 : : /** A database for constraints */ 46 : : class ConstraintDb 47 : : { 48 : : public: 49 : : ConstraintDb(MonomialDb& mdb); 50 : 32768 : ~ConstraintDb() {} 51 : : /** register constraint 52 : : * 53 : : * This ensures that atom is in the domain of the constraints maintained by 54 : : * this database. 55 : : */ 56 : : void registerConstraint(Node atom); 57 : : /** get constraints 58 : : * 59 : : * Returns a map m such that whenever 60 : : * m[lit][x] = ( r, coeff, k ), then 61 : : * ( lit <=> (coeff * x) <k> r ) 62 : : */ 63 : : const std::map<Node, std::map<Node, ConstraintInfo> >& getConstraints(); 64 : : /** Returns true if m is of maximal degree in atom 65 : : * 66 : : * For example, for atom x^2 + x*y + y >=0, the monomials x^2 and x*y 67 : : * are of maximal degree (2). 68 : : */ 69 : : bool isMaximal(Node atom, Node m) const; 70 : : 71 : : private: 72 : : /** Reference to a monomial database */ 73 : : MonomialDb& d_mdb; 74 : : /** List of all constraints */ 75 : : std::vector<Node> d_constraints; 76 : : /** Is maximal degree */ 77 : : std::map<Node, std::map<Node, bool> > d_c_info_maxm; 78 : : /** Constraint information */ 79 : : std::map<Node, std::map<Node, ConstraintInfo> > d_c_info; 80 : : }; 81 : : 82 : : } // namespace nl 83 : : } // namespace arith 84 : : } // namespace theory 85 : : } // namespace cvc5::internal 86 : : 87 : : #endif /* CVC5__THEORY__ARITH__NL_SOLVER_H */