LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/expr - subs.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 2 2 100.0 %
Date: 2026-06-30 10:35:26 Functions: 2 3 66.7 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * This file is part of the cvc5 project.
       3                 :            :  *
       4                 :            :  * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS
       5                 :            :  * in the top-level source directory and their institutional affiliations.
       6                 :            :  * All rights reserved.  See the file COPYING in the top-level source
       7                 :            :  * directory for licensing information.
       8                 :            :  * ****************************************************************************
       9                 :            :  *
      10                 :            :  * Simple substitution utility.
      11                 :            :  */
      12                 :            : 
      13                 :            : #ifndef CVC5__EXPR__SUBS_H
      14                 :            : #define CVC5__EXPR__SUBS_H
      15                 :            : 
      16                 :            : #include <map>
      17                 :            : #include <optional>
      18                 :            : #include <vector>
      19                 :            : 
      20                 :            : #include "expr/node.h"
      21                 :            : 
      22                 :            : namespace cvc5::internal {
      23                 :            : 
      24                 :            : /**
      25                 :            :  * Helper substitution class. Stores a substitution in parallel vectors
      26                 :            :  * d_vars and d_subs, both of which may be arbitrary terms, having the same
      27                 :            :  * types pairwise.
      28                 :            :  *
      29                 :            :  * Notice this class applies substitutions using Node::substitute. Furthermore,
      30                 :            :  * it does not insist that the terms in d_vars are unique.
      31                 :            :  */
      32                 :            : class Subs
      33                 :            : {
      34                 :            :  public:
      35                 :     657983 :   Subs() {}
      36                 :     666352 :   virtual ~Subs() {}
      37                 :            :   /** Is the substitution empty? */
      38                 :            :   bool empty() const;
      39                 :            :   /** The size of the substitution */
      40                 :            :   size_t size() const;
      41                 :            :   /** Does the substitution contain v? */
      42                 :            :   bool contains(Node v) const;
      43                 :            :   /** Get the substitution for v if it exists, or null otherwise */
      44                 :            :   Node getSubs(Node v) const;
      45                 :            :   /** Find the substitution for v, or return std::nullopt */
      46                 :            :   std::optional<Node> find(TNode v) const;
      47                 :            :   /** Add v -> k for fresh skolem of the same type as v */
      48                 :            :   void add(Node v);
      49                 :            :   /** Add v -> k for fresh skolem of the same type as v for each v in vs */
      50                 :            :   void add(const std::vector<Node>& vs);
      51                 :            :   /** Add v -> s to the substitution */
      52                 :            :   void add(const Node& v, const Node& s);
      53                 :            :   /** Add vs -> ss to the substitution */
      54                 :            :   void add(const std::vector<Node>& vs, const std::vector<Node>& ss);
      55                 :            :   /** Add eq[0] -> eq[1] to the substitution */
      56                 :            :   void addEquality(Node eq);
      57                 :            :   /** Append the substitution s to this */
      58                 :            :   void append(Subs& s);
      59                 :            :   /** Return the result of this substitution on n */
      60                 :            :   Node apply(const Node& n) const;
      61                 :            :   /** Return the result of the reverse of this substitution on n */
      62                 :            :   Node rapply(Node n) const;
      63                 :            :   /** Apply this substitution to all nodes in the range of s */
      64                 :            :   void applyToRange(Subs& s) const;
      65                 :            :   /** Apply the reverse of this substitution to all nodes in the range of s */
      66                 :            :   void rapplyToRange(Subs& s) const;
      67                 :            :   /** Get equality (= v s) where v -> s is the i^th position in the vectors */
      68                 :            :   Node getEquality(size_t i) const;
      69                 :            :   /** Convert substitution to map */
      70                 :            :   std::map<Node, Node> toMap() const;
      71                 :            :   /** Get string for this substitution */
      72                 :            :   std::string toString() const;
      73                 :            :   /** clear the substitution */
      74                 :            :   void clear();
      75                 :            :   /** The data */
      76                 :            :   std::vector<Node> d_vars;
      77                 :            :   std::vector<Node> d_subs;
      78                 :            : };
      79                 :            : 
      80                 :            : /**
      81                 :            :  * Serializes a given substitution to the given stream.
      82                 :            :  *
      83                 :            :  * @param out the output stream to use
      84                 :            :  * @param s the substitution to output to the stream
      85                 :            :  * @return the stream
      86                 :            :  */
      87                 :            : std::ostream& operator<<(std::ostream& out, const Subs& s);
      88                 :            : 
      89                 :            : }  // namespace cvc5::internal
      90                 :            : 
      91                 :            : #endif /* CVC5__EXPR__SUBS_H */

Generated by: LCOV version 1.14