LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/expr - match_trie.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2025-02-01 11:33:18 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, Andres Noetzli
       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                 :            :  * Implements a match trie, also known as a discrimination tree.
      14                 :            :  */
      15                 :            : 
      16                 :            : #include "cvc5_private.h"
      17                 :            : 
      18                 :            : #ifndef CVC5__EXPR__MATCH_TRIE_H
      19                 :            : #define CVC5__EXPR__MATCH_TRIE_H
      20                 :            : 
      21                 :            : #include <map>
      22                 :            : #include <vector>
      23                 :            : 
      24                 :            : #include "expr/node.h"
      25                 :            : 
      26                 :            : namespace cvc5::internal {
      27                 :            : namespace expr {
      28                 :            : 
      29                 :            : /** A virtual class for notifications regarding matches. */
      30                 :            : class NotifyMatch
      31                 :            : {
      32                 :            :  public:
      33                 :      10741 :   virtual ~NotifyMatch() {}
      34                 :            :   /**
      35                 :            :    * A notification that s is equal to n * { vars -> subs }. This function
      36                 :            :    * should return false if we do not wish to be notified of further matches.
      37                 :            :    */
      38                 :            :   virtual bool notify(Node s,
      39                 :            :                       Node n,
      40                 :            :                       std::vector<Node>& vars,
      41                 :            :                       std::vector<Node>& subs) = 0;
      42                 :            : };
      43                 :            : 
      44                 :            : /**
      45                 :            :  * A trie (discrimination tree) storing a set of terms S, that can be used to
      46                 :            :  * query, for a given term t, all terms s from S that are matchable with t,
      47                 :            :  * that is s*sigma = t for some substitution sigma.
      48                 :            :  */
      49                 :            : class MatchTrie
      50                 :            : {
      51                 :            :  public:
      52                 :            :   /** Get matches
      53                 :            :    *
      54                 :            :    * This calls ntm->notify( n, s, vars, subs ) for each term s stored in this
      55                 :            :    * trie that is matchable with n where s = n * { vars -> subs } for some
      56                 :            :    * vars, subs. This function returns false if one of these calls to notify
      57                 :            :    * returns false.
      58                 :            :    */
      59                 :            :   bool getMatches(Node n, NotifyMatch* ntm);
      60                 :            :   /** Adds node n to this trie */
      61                 :            :   void addTerm(Node n);
      62                 :            :   /** Clear this trie */
      63                 :            :   void clear();
      64                 :            : 
      65                 :            :  private:
      66                 :            :   /**
      67                 :            :    * The children of this node in the trie. Terms t are indexed by a
      68                 :            :    * depth-first (right to left) traversal on its subterms, where the
      69                 :            :    * top-symbol of t is indexed by:
      70                 :            :    * - (operator, #children) if t has an operator, or
      71                 :            :    * - (t, 0) if t does not have an operator.
      72                 :            :    */
      73                 :            :   std::map<Node, std::map<unsigned, MatchTrie> > d_children;
      74                 :            :   /** The set of variables in the domain of d_children */
      75                 :            :   std::vector<Node> d_vars;
      76                 :            :   /** The data of this node in the trie */
      77                 :            :   Node d_data;
      78                 :            : };
      79                 :            : 
      80                 :            : }  // namespace expr
      81                 :            : }  // namespace cvc5::internal
      82                 :            : 
      83                 :            : #endif /* CVC5__THEORY__QUANTIFIERS__CANDIDATE_REWRITE_FILTER_H */

Generated by: LCOV version 1.14