LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/theory - subs_minimize.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2026-01-19 13:01:48 Functions: 1 2 50.0 %
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-2025 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                 :            :  * Substitution minimization.
      14                 :            :  */
      15                 :            : 
      16                 :            : #include "cvc5_private.h"
      17                 :            : 
      18                 :            : #ifndef CVC5__THEORY__SUBS_MINIMIZE_H
      19                 :            : #define CVC5__THEORY__SUBS_MINIMIZE_H
      20                 :            : 
      21                 :            : #include <vector>
      22                 :            : 
      23                 :            : #include "expr/node.h"
      24                 :            : #include "smt/env_obj.h"
      25                 :            : 
      26                 :            : namespace cvc5::internal {
      27                 :            : namespace theory {
      28                 :            : 
      29                 :            : /** SubstitutionMinimize
      30                 :            :  *
      31                 :            :  * This class is used for finding a minimal substitution under which an
      32                 :            :  * evaluation holds.
      33                 :            :  */
      34                 :            : class SubstitutionMinimize : protected EnvObj
      35                 :            : {
      36                 :            :  public:
      37                 :            :   SubstitutionMinimize(Env& env);
      38                 :        202 :   ~SubstitutionMinimize() {}
      39                 :            :   /** find
      40                 :            :    *
      41                 :            :    * If t { vars -> subs } rewrites to target, this method returns true, and
      42                 :            :    * vars[i_1], ..., vars[i_n] are added to reqVars, such that i_1, ..., i_n are
      43                 :            :    * distinct, and t { vars[i_1] -> subs[i_1], ..., vars[i_n] -> subs[i_n] }
      44                 :            :    * rewrites to target.
      45                 :            :    *
      46                 :            :    * If t { vars -> subs } does not rewrite to target, this method returns
      47                 :            :    * false.
      48                 :            :    */
      49                 :            :   bool find(Node t,
      50                 :            :             Node target,
      51                 :            :             const std::vector<Node>& vars,
      52                 :            :             const std::vector<Node>& subs,
      53                 :            :             std::vector<Node>& reqVars);
      54                 :            :   /** find with implied
      55                 :            :    *
      56                 :            :    * This method should be called on a formula t.
      57                 :            :    *
      58                 :            :    * If t { vars -> subs } rewrites to true, this method returns true,
      59                 :            :    * vars[i_1], ..., vars[i_n] are added to reqVars, and
      60                 :            :    * vars[i_{n+1}], ..., vars[i_{n+m}] are added to impliedVars such that
      61                 :            :    * i_1...i_{n+m} are distinct, i_{n+1} < ... < i_{n+m}, and:
      62                 :            :    *
      63                 :            :    * (1) t { vars[i_1]->subs[i_1], ..., vars[i_{n+k}]->subs[i_{n+k}] } implies
      64                 :            :    * vars[i_{n+k+1}] = subs[i_{n+k+1}] for k = 0, ..., m-1.
      65                 :            :    *
      66                 :            :    * (2) t { vars[i_1] -> subs[i_1], ..., vars[i_{n+m}] -> subs[i_{n+m}] }
      67                 :            :    * rewrites to true.
      68                 :            :    *
      69                 :            :    * For example, given (x>0 ^ x = y ^ y = z){ x -> 1, y -> 1, z -> 1, w -> 0 },
      70                 :            :    * this method may add { x } to reqVars, and { y, z } to impliedVars.
      71                 :            :    *
      72                 :            :    * Notice that the order of variables in vars matters. By the semantics above,
      73                 :            :    * variables that appear earlier in the variable list vars are more likely
      74                 :            :    * to appear in reqVars, whereas those later in the vars are more likely to
      75                 :            :    * appear in impliedVars.
      76                 :            :    */
      77                 :            :   bool findWithImplied(Node t,
      78                 :            :                        const std::vector<Node>& vars,
      79                 :            :                        const std::vector<Node>& subs,
      80                 :            :                        std::vector<Node>& reqVars,
      81                 :            :                        std::vector<Node>& impliedVars);
      82                 :            : 
      83                 :            :  private:
      84                 :            :   /** Common helper function for the above functions. */
      85                 :            :   bool findInternal(Node t,
      86                 :            :                     Node target,
      87                 :            :                     const std::vector<Node>& vars,
      88                 :            :                     const std::vector<Node>& subs,
      89                 :            :                     std::vector<Node>& reqVars);
      90                 :            :   /** is singular arg
      91                 :            :    *
      92                 :            :    * Returns true if
      93                 :            :    *   <k>( ... t_{arg-1}, n, t_{arg+1}...) = c
      94                 :            :    * always holds for some constant c.
      95                 :            :    */
      96                 :            :   bool isSingularArg(Node n, Kind k, unsigned arg);
      97                 :            : };
      98                 :            : 
      99                 :            : }  // namespace theory
     100                 :            : }  // namespace cvc5::internal
     101                 :            : 
     102                 :            : #endif /* CVC5__THEORY__SUBS_MINIMIZE_H */

Generated by: LCOV version 1.14