LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/expr - elim_shadow_converter.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2025-03-18 11:47:40 Functions: 1 2 50.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * Top contributors (to current version):
       3                 :            :  *   Andrew Reynolds, Daniel Larraz
       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                 :            :  * Implementation of shadow elimination node conversion
      14                 :            :  */
      15                 :            : #include "cvc5_private.h"
      16                 :            : 
      17                 :            : #ifndef CVC5__EXPR__ELIM_SHADOW_NODE_CONVERTER_H
      18                 :            : #define CVC5__EXPR__ELIM_SHADOW_NODE_CONVERTER_H
      19                 :            : 
      20                 :            : #include <unordered_set>
      21                 :            : 
      22                 :            : #include "expr/node.h"
      23                 :            : #include "expr/node_converter.h"
      24                 :            : 
      25                 :            : namespace cvc5::internal {
      26                 :            : 
      27                 :            : /**
      28                 :            :  * This converts a node into one that does not involve shadowing with the
      29                 :            :  * given variables. In particular, if the given vars passed to the constructor
      30                 :            :  * are bound in any binder in a subterm of the node to convert, they
      31                 :            :  * are replaced by fresh variables.
      32                 :            :  *
      33                 :            :  * Shadowed variables may be introduced when e.g. quantified formulas
      34                 :            :  * appear on the right hand sides of substitutions in preprocessing. They should
      35                 :            :  * be eliminated by the rewriter. This utility is the standard method for
      36                 :            :  * eliminating them.
      37                 :            :  */
      38                 :            : class ElimShadowNodeConverter : public NodeConverter
      39                 :            : {
      40                 :            :  public:
      41                 :            :   /**
      42                 :            :    * Eliminate shadowing of the top-most variables in closure q.
      43                 :            :    */
      44                 :            :   ElimShadowNodeConverter(NodeManager* nm, const Node& q);
      45                 :            :   /**
      46                 :            :    * Eliminate shadowing of variables vars. Node n is a term used as a unique
      47                 :            :    * identifier for which the introduced bound variables are indexed on.
      48                 :            :    */
      49                 :            :   ElimShadowNodeConverter(NodeManager* nm,
      50                 :            :                           const Node& n,
      51                 :            :                           const std::unordered_set<Node>& vars);
      52                 :     191710 :   ~ElimShadowNodeConverter() {}
      53                 :            :   /**
      54                 :            :    * Convert node n as described above during post-order traversal. This
      55                 :            :    * typically should be a subterm of the body of q, assuming that convert
      56                 :            :    * was called on the body of q.
      57                 :            :    */
      58                 :            :   Node postConvert(Node n) override;
      59                 :            :   /**
      60                 :            :    * Get the bound variable used for eliminating shadowing of the i^th variable
      61                 :            :    * bound by closure n that occurs as a subterm of closure q.
      62                 :            :    */
      63                 :            :   static Node getElimShadowVar(const Node& q, const Node& n, size_t i);
      64                 :            : 
      65                 :            :   /**
      66                 :            :    * Eliminate shadowing in the closure q. This includes eliminating duplicate
      67                 :            :    * variables in the quantifier prefix of q.
      68                 :            :    * @param q The term to process which should have a binder kind.
      69                 :            :    * @return The result of eliminating shadowing in q.
      70                 :            :    */
      71                 :            :   static Node eliminateShadow(const Node& q);
      72                 :            : 
      73                 :            :  private:
      74                 :            :   /** The closure to eliminate shadowing from */
      75                 :            :   Node d_closure;
      76                 :            :   /** The variables */
      77                 :            :   std::vector<Node> d_vars;
      78                 :            : };
      79                 :            : 
      80                 :            : }  // namespace cvc5::internal
      81                 :            : 
      82                 :            : #endif

Generated by: LCOV version 1.14