LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/theory/quantifiers - quant_util.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 6 83.3 %
Date: 2024-11-05 12:39:23 Functions: 5 7 71.4 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * Top contributors (to current version):
       3                 :            :  *   Andrew Reynolds, Andres Noetzli, 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                 :            :  * quantifier util
      14                 :            :  */
      15                 :            : 
      16                 :            : #include "cvc5_private.h"
      17                 :            : 
      18                 :            : #ifndef CVC5__THEORY__QUANT_UTIL_H
      19                 :            : #define CVC5__THEORY__QUANT_UTIL_H
      20                 :            : 
      21                 :            : #include <iostream>
      22                 :            : #include <map>
      23                 :            : #include <vector>
      24                 :            : 
      25                 :            : #include "expr/node.h"
      26                 :            : #include "smt/env_obj.h"
      27                 :            : #include "theory/incomplete_id.h"
      28                 :            : #include "theory/theory.h"
      29                 :            : 
      30                 :            : namespace cvc5::internal {
      31                 :            : namespace theory {
      32                 :            : 
      33                 :            : /** Quantifiers utility
      34                 :            :  *
      35                 :            :  * This is a lightweight version of a quantifiers module that does not implement
      36                 :            :  * methods for checking satisfiability.
      37                 :            :  */
      38                 :            : class QuantifiersUtil : protected EnvObj
      39                 :            : {
      40                 :            :  public:
      41                 :            :   QuantifiersUtil(Env& env);
      42                 :     297411 :   virtual ~QuantifiersUtil(){}
      43                 :            :   /**  Called at the beginning of check-sat call. */
      44                 :     190514 :   virtual void presolve() {}
      45                 :            :   /* reset
      46                 :            :    * Called at the beginning of an instantiation round
      47                 :            :    * Returns false if the reset failed. When reset fails, the utility should
      48                 :            :    * have added a lemma via a call to d_qim.addPendingLemma.
      49                 :            :    */
      50                 :          0 :   virtual bool reset(Theory::Effort e) { return true; }
      51                 :            :   /* Called for new quantifiers */
      52                 :      57894 :   virtual void registerQuantifier(Node q) {}
      53                 :            :   /** Identify this module (for debugging, dynamic configuration, etc..) */
      54                 :            :   virtual std::string identify() const = 0;
      55                 :            :   /** Check complete?
      56                 :            :    *
      57                 :            :    * Returns false if the utility's reasoning was globally incomplete
      58                 :            :    * (e.g. "sat" must be replaced with "incomplete"). If this method returns
      59                 :            :    * false, it should update incId to the reason for incompleteness.
      60                 :            :    */
      61                 :      44708 :   virtual bool checkComplete(IncompleteId& incId) { return true; }
      62                 :            : };
      63                 :            : 
      64                 :            : class QuantPhaseReq
      65                 :            : {
      66                 :            : private:
      67                 :            :   /** helper functions compute phase requirements */
      68                 :            :   void computePhaseReqs( Node n, bool polarity, std::map< Node, int >& phaseReqs );
      69                 :            : public:
      70                 :            :   QuantPhaseReq(){}
      71                 :            :   QuantPhaseReq( Node n, bool computeEq = false );
      72                 :     314674 :   ~QuantPhaseReq(){}
      73                 :            :   void initialize( Node n, bool computeEq );
      74                 :            :   /** is phase required */
      75                 :            :   bool isPhaseReq( Node lit ) { return d_phase_reqs.find( lit )!=d_phase_reqs.end(); }
      76                 :            :   /** get phase requirement */
      77                 :            :   bool getPhaseReq( Node lit ) { return d_phase_reqs.find( lit )==d_phase_reqs.end() ? false : d_phase_reqs[ lit ]; }
      78                 :            :   /** phase requirements for each quantifier for each instantiation literal */
      79                 :            :   std::map< Node, bool > d_phase_reqs;
      80                 :            :   std::map< Node, bool > d_phase_reqs_equality;
      81                 :            :   std::map< Node, Node > d_phase_reqs_equality_term;
      82                 :            : 
      83                 :            :   /**
      84                 :            :    * Get the polarity of the child^th child of n, assuming its polarity
      85                 :            :    * is given by (hasPol, pol). A term has polarity if it is only relevant
      86                 :            :    * if asserted with one polarity. Its polarity is (typically) the number
      87                 :            :    * of negations it is beneath.
      88                 :            :    */
      89                 :            :   static void getPolarity(Node n,
      90                 :            :                           size_t child,
      91                 :            :                           bool hasPol,
      92                 :            :                           bool pol,
      93                 :            :                           bool& newHasPol,
      94                 :            :                           bool& newPol);
      95                 :            : 
      96                 :            :   /**
      97                 :            :    * Get the entailed polarity of the child^th child of n, assuming its
      98                 :            :    * entailed polarity is given by (hasPol, pol). A term has entailed polarity
      99                 :            :    * if it must be asserted with a polarity. Its polarity is (typically) the
     100                 :            :    * number of negations it is beneath.
     101                 :            :    *
     102                 :            :    * Entailed polarity and polarity above differ, e.g.:
     103                 :            :    *   (and A B): A and B have true polarity and true entailed polarity
     104                 :            :    *   (or A B): A and B have true polarity and no entailed polarity
     105                 :            :    */
     106                 :            :   static void getEntailPolarity(Node n,
     107                 :            :                                 size_t child,
     108                 :            :                                 bool hasPol,
     109                 :            :                                 bool pol,
     110                 :            :                                 bool& newHasPol,
     111                 :            :                                 bool& newPol);
     112                 :            : };
     113                 :            : 
     114                 :            : }
     115                 :            : }  // namespace cvc5::internal
     116                 :            : 
     117                 :            : #endif /* CVC5__THEORY__QUANT_UTIL_H */

Generated by: LCOV version 1.14