GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/inst_match.h Lines: 1 14 7.1 %
Date: 2021-09-17 Branches: 0 8 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Morgan Deters, Mathias Preiner
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 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
 * Inst match class.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__QUANTIFIERS__INST_MATCH_H
19
#define CVC5__THEORY__QUANTIFIERS__INST_MATCH_H
20
21
#include <vector>
22
23
#include "expr/node.h"
24
25
namespace cvc5 {
26
namespace theory {
27
namespace quantifiers {
28
29
class QuantifiersState;
30
31
/** Inst match
32
 *
33
 * This is the basic class specifying an instantiation. Its domain size (the
34
 * size of d_vals) is the number of bound variables of the quantified formula
35
 * that is passed to its constructor.
36
 *
37
 * The values of d_vals may be null, which indicate that the field has
38
 * yet to be initialized.
39
 */
40
62395
class InstMatch {
41
public:
42
  InstMatch(){}
43
  explicit InstMatch(TNode q);
44
  InstMatch( InstMatch* m );
45
  /* map from variable to ground terms */
46
  std::vector<Node> d_vals;
47
  /** add match m
48
   *
49
   * This adds the initialized fields of m to this match for each field that is
50
   * not already initialized in this match.
51
   */
52
  void add(InstMatch& m);
53
  /** is this complete, i.e. are all fields non-null? */
54
  bool isComplete();
55
  /** is this empty, i.e. are all fields the null node? */
56
  bool empty();
57
  /** clear the instantiation, i.e. set all fields to the null node */
58
  void clear();
59
  /** debug print method */
60
  void debugPrint(const char* c);
61
  /** to stream */
62
  inline void toStream(std::ostream& out) const {
63
    out << "INST_MATCH( ";
64
    bool printed = false;
65
    for( unsigned i=0; i<d_vals.size(); i++ ){
66
      if( !d_vals[i].isNull() ){
67
        if( printed ){ out << ", "; }
68
        out << i << " -> " << d_vals[i];
69
        printed = true;
70
      }
71
    }
72
    out << " )";
73
  }
74
  /** get the i^th term in the instantiation */
75
  Node get(size_t i) const;
76
  /** set/overwrites the i^th field in the instantiation with n */
77
  void setValue(size_t i, TNode n);
78
  /** set the i^th term in the instantiation to n
79
   *
80
   * This method returns true if the i^th field was previously uninitialized,
81
   * or is equivalent to n modulo the equalities given by q.
82
   */
83
  bool set(QuantifiersState& qs, size_t i, TNode n);
84
};
85
86
inline std::ostream& operator<<(std::ostream& out, const InstMatch& m) {
87
  m.toStream(out);
88
  return out;
89
}
90
91
}  // namespace quantifiers
92
}  // namespace theory
93
}  // namespace cvc5
94
95
#endif /* CVC5__THEORY__QUANTIFIERS__INST_MATCH_H */