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 : : * Utils for indexed root predicates. 11 : : */ 12 : : 13 : : #include <cstdint> 14 : : #include <ostream> 15 : : 16 : : #include "cvc5_public.h" 17 : : 18 : : #ifndef CVC5__UTIL__INDEXED_ROOT_PREDICATE_H 19 : : #define CVC5__UTIL__INDEXED_ROOT_PREDICATE_H 20 : : 21 : : namespace cvc5::internal { 22 : : 23 : : /** 24 : : * The structure representing the index of a root predicate. 25 : : * An indexed root predicate has the form 26 : : * IRP_k(x ~ 0, p) 27 : : * where k is a positive integer (d_index), x is a real variable, 28 : : * ~ an arithmetic relation symbol and p a (possibly multivariate polynomial). 29 : : * The evaluation of the predicate is obtained by comparing the k'th root of p 30 : : * (as polynomial in x) to the value of x according to the relation symbol ~. 31 : : * Note that p may be multivariate: in this case we can only evaluate with 32 : : * respect to a (partial) variable assignment, that (at least) contains values 33 : : * for all variables from p except x. 34 : : * 35 : : * Some examples: 36 : : * IRP_1(x > 0, x) <=> x > 0 37 : : * IRP_1(x < 0, x*x-1) <=> x < -1 38 : : * IRP_2(x < 0, x*x-1) <=> x < 1 39 : : * IRP_1(x = 0, x*x-2) <=> x = -sqrt(2) 40 : : * IRP_1(x = 0, x*x-y), y=3 <=> x = -sqrt(3) 41 : : */ 42 : : struct IndexedRootPredicate 43 : : { 44 : : /** The index of the root */ 45 : : std::uint64_t d_index; 46 : : 47 : 2164 : IndexedRootPredicate(unsigned index) : d_index(index) {} 48 : : 49 : 2222 : bool operator==(const IndexedRootPredicate& irp) const 50 : : { 51 : 2222 : return d_index == irp.d_index; 52 : : } 53 : : }; /* struct IndexedRootPredicate */ 54 : : 55 : : inline std::ostream& operator<<(std::ostream& os, 56 : : const IndexedRootPredicate& irp); 57 : 0 : inline std::ostream& operator<<(std::ostream& os, 58 : : const IndexedRootPredicate& irp) 59 : : { 60 : 0 : return os << "k=" << irp.d_index; 61 : : } 62 : : 63 : : struct IndexedRootPredicateHashFunction 64 : : { 65 : 2396 : std::size_t operator()(const IndexedRootPredicate& irp) const 66 : : { 67 : 2396 : return irp.d_index; 68 : : } 69 : : }; /* struct IndexedRootPredicateHashFunction */ 70 : : 71 : : } // namespace cvc5::internal 72 : : 73 : : #endif