LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/theory/quantifiers - expr_miner.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 4 4 100.0 %
Date: 2024-09-19 10:47:20 Functions: 5 6 83.3 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * Top contributors (to current version):
       3                 :            :  *   Andrew Reynolds, 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                 :            :  * expr_miner
      14                 :            :  */
      15                 :            : 
      16                 :            : #include "cvc5_private.h"
      17                 :            : 
      18                 :            : #ifndef CVC5__THEORY__QUANTIFIERS__EXPRESSION_MINER_H
      19                 :            : #define CVC5__THEORY__QUANTIFIERS__EXPRESSION_MINER_H
      20                 :            : 
      21                 :            : #include <map>
      22                 :            : #include <memory>
      23                 :            : #include <vector>
      24                 :            : 
      25                 :            : #include "expr/node.h"
      26                 :            : #include "smt/env_obj.h"
      27                 :            : #include "theory/quantifiers/sygus_sampler.h"
      28                 :            : #include "theory/smt_engine_subsolver.h"
      29                 :            : 
      30                 :            : namespace cvc5::internal {
      31                 :            : 
      32                 :            : class Env;
      33                 :            : class SolverEngine;
      34                 :            : 
      35                 :            : namespace theory {
      36                 :            : namespace quantifiers {
      37                 :            : 
      38                 :            : /** Expression miner
      39                 :            :  *
      40                 :            :  * This is a virtual base class for modules that "mines" certain information
      41                 :            :  * from (enumerated) expressions. This includes:
      42                 :            :  * - candidate rewrite rules (find-synth :rewrite)
      43                 :            :  * - unsound rewrite rules (find-synth :rewrite_unsound)
      44                 :            :  * - queries (find-synth :query)
      45                 :            :  */
      46                 :            : class ExprMiner : protected EnvObj
      47                 :            : {
      48                 :            :  public:
      49                 :        730 :   ExprMiner(Env& env) : EnvObj(env), d_sampler(nullptr) {}
      50                 :        715 :   virtual ~ExprMiner() {}
      51                 :            :   /** initialize
      52                 :            :    *
      53                 :            :    * This initializes this expression miner. The argument vars indicates the
      54                 :            :    * free variables of terms that will be added to this class. The argument
      55                 :            :    * sampler gives an (optional) pointer to a sampler, which is used to
      56                 :            :    * sample tuples of valuations of these variables.
      57                 :            :    */
      58                 :            :   virtual void initialize(const std::vector<Node>& vars,
      59                 :            :                           SygusSampler* ss = nullptr);
      60                 :            :   /** add term
      61                 :            :    *
      62                 :            :    * This registers term n with this expression miner, and adds expressions
      63                 :            :    * found (e.g. rewrites, queries) to found.
      64                 :            :    */
      65                 :            :   virtual bool addTerm(Node n, std::vector<Node>& found) = 0;
      66                 :            : 
      67                 :            :  protected:
      68                 :            :   /** the set of variables used by this class */
      69                 :            :   std::vector<Node> d_vars;
      70                 :            :   /**
      71                 :            :    * The set of skolems corresponding to the above variables. These are
      72                 :            :    * used during initializeChecker so that query (which may contain free
      73                 :            :    * variables) is converted to a formula without free variables.
      74                 :            :    */
      75                 :            :   std::vector<Node> d_skolems;
      76                 :            :   /** pointer to the sygus sampler object we are using */
      77                 :            :   SygusSampler* d_sampler;
      78                 :            :   /** Maps to skolems for each free variable based on d_vars/d_skolems. */
      79                 :            :   std::map<Node, Node> d_fv_to_skolem;
      80                 :            :   /** convert */
      81                 :            :   Node convertToSkolem(Node n);
      82                 :            :   /** initialize checker
      83                 :            :    *
      84                 :            :    * This function initializes the smt engine smte to check the satisfiability
      85                 :            :    * of the argument "query", which is a formula whose free variables (of
      86                 :            :    * kind BOUND_VARIABLE) are a subset of d_vars.
      87                 :            :    */
      88                 :            :   void initializeChecker(std::unique_ptr<SolverEngine>& checker,
      89                 :            :                          Node query,
      90                 :            :                          const SubsolverSetupInfo& info);
      91                 :            :   /**
      92                 :            :    * Run the satisfiability check on query and return the result
      93                 :            :    * (sat/unsat/unknown).
      94                 :            :    *
      95                 :            :    * In contrast to the above method, this call should be used for cases where
      96                 :            :    * the model for the query is not important.
      97                 :            :    */
      98                 :            :   Result doCheck(Node query, const SubsolverSetupInfo& info);
      99                 :            : };
     100                 :            : 
     101                 :            : /** Identity expression miner */
     102                 :            : class ExprMinerId : public ExprMiner
     103                 :            : {
     104                 :            :  public:
     105                 :         36 :   ExprMinerId(Env& env) : ExprMiner(env) {}
     106                 :         60 :   virtual ~ExprMinerId() {}
     107                 :            :   /** Returns true and adds n to found */
     108                 :            :   bool addTerm(Node n, std::vector<Node>& found) override;
     109                 :            : };
     110                 :            : 
     111                 :            : }  // namespace quantifiers
     112                 :            : }  // namespace theory
     113                 :            : }  // namespace cvc5::internal
     114                 :            : 
     115                 :            : #endif /* CVC5__THEORY__QUANTIFIERS__EXPRESSION_MINER_H */

Generated by: LCOV version 1.14