LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/util - indexed_root_predicate.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 7 71.4 %
Date: 2025-01-08 11:29:24 Functions: 3 4 75.0 %
Branches: 0 0 -

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

Generated by: LCOV version 1.14