GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/ematching/var_match_generator.cpp Lines: 27 32 84.4 %
Date: 2021-09-07 Branches: 47 98 48.0 %

Line Exec Source
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-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
 * Implementation of variable match generator class.
14
 */
15
#include "theory/quantifiers/ematching/var_match_generator.h"
16
17
#include "theory/quantifiers/term_util.h"
18
#include "theory/rewriter.h"
19
20
using namespace cvc5::kind;
21
22
namespace cvc5 {
23
namespace theory {
24
namespace quantifiers {
25
namespace inst {
26
27
8
VarMatchGeneratorTermSubs::VarMatchGeneratorTermSubs(Trigger* tparent,
28
                                                     Node var,
29
8
                                                     Node subs)
30
16
    : InstMatchGenerator(tparent, Node::null()),
31
      d_var(var),
32
      d_subs(subs),
33
24
      d_rm_prev(false)
34
{
35
8
  d_children_types.push_back(d_var.getAttribute(InstVarNumAttribute()));
36
8
  d_var_type = d_var.getType();
37
8
}
38
39
8
bool VarMatchGeneratorTermSubs::reset(Node eqc)
40
{
41
8
  d_eq_class = eqc;
42
8
  return true;
43
}
44
45
8
int VarMatchGeneratorTermSubs::getNextMatch(Node q, InstMatch& m)
46
{
47
8
  int ret_val = -1;
48
8
  if (!d_eq_class.isNull())
49
  {
50
16
    Trace("var-trigger-matching") << "Matching " << d_eq_class << " against "
51
8
                                  << d_var << " in " << d_subs << std::endl;
52
8
    TNode tvar = d_var;
53
8
    Node s = d_subs.substitute(tvar, d_eq_class);
54
8
    s = Rewriter::rewrite(s);
55
16
    Trace("var-trigger-matching")
56
8
        << "...got " << s << ", " << s.getKind() << std::endl;
57
8
    d_eq_class = Node::null();
58
    // if( s.getType().isSubtypeOf( d_var_type ) ){
59
8
    d_rm_prev = m.get(d_children_types[0]).isNull();
60
8
    if (!m.set(d_qstate, d_children_types[0], s))
61
    {
62
      return -1;
63
    }
64
    else
65
    {
66
8
      ret_val = continueNextMatch(
67
          q, m, InferenceId::QUANTIFIERS_INST_E_MATCHING_VAR_GEN);
68
8
      if (ret_val > 0)
69
      {
70
8
        return ret_val;
71
      }
72
    }
73
  }
74
  if (d_rm_prev)
75
  {
76
    m.d_vals[d_children_types[0]] = Node::null();
77
    d_rm_prev = false;
78
  }
79
  return -1;
80
}
81
82
}  // namespace inst
83
}  // namespace quantifiers
84
}  // namespace theory
85
29502
}  // namespace cvc5