GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/sygus/rcons_type_info.cpp Lines: 31 31 100.0 %
Date: 2021-05-22 Branches: 38 72 52.8 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Abdalrhman Mohamed, Andrew Reynolds
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
 * Reconstruct Type Info class implementation.
14
 */
15
16
#include "theory/quantifiers/sygus/rcons_type_info.h"
17
18
#include "expr/skolem_manager.h"
19
#include "theory/datatypes/sygus_datatype_utils.h"
20
#include "theory/quantifiers/sygus/rcons_obligation.h"
21
22
namespace cvc5 {
23
namespace theory {
24
namespace quantifiers {
25
26
53
void RConsTypeInfo::initialize(TermDbSygus* tds,
27
                               SygusStatistics& s,
28
                               TypeNode stn,
29
                               const std::vector<Node>& builtinVars)
30
{
31
53
  NodeManager* nm = NodeManager::currentNM();
32
53
  SkolemManager* sm = nm->getSkolemManager();
33
34
53
  d_enumerator.reset(new SygusEnumerator(tds, nullptr, s, true));
35
53
  d_enumerator->initialize(sm->mkDummySkolem("sygus_rcons", stn));
36
53
  d_crd.reset(new CandidateRewriteDatabase(true, false, true, false));
37
  // since initial samples are not always useful for equivalence checks, set
38
  // their number to 0
39
53
  d_sygusSampler.initialize(stn, builtinVars, 0);
40
53
  d_crd->initialize(builtinVars, &d_sygusSampler);
41
53
}
42
43
10587
Node RConsTypeInfo::nextEnum()
44
{
45
10587
  if (!d_enumerator->increment())
46
  {
47
58
    Trace("sygus-rcons") << "no increment" << std::endl;
48
58
    return Node::null();
49
  }
50
51
21058
  Node sz = d_enumerator->getCurrent();
52
53
21058
  Trace("sygus-rcons") << (sz == Node::null()
54
21058
                               ? sz
55
10529
                               : datatypes::utils::sygusToBuiltin(sz))
56
10529
                       << std::endl;
57
58
10529
  return sz;
59
}
60
61
752
Node RConsTypeInfo::addTerm(Node n)
62
{
63
1504
  std::stringstream out;
64
1504
  return d_crd->addTerm(n, false, out);
65
}
66
67
682
void RConsTypeInfo::setBuiltinToOb(Node t, RConsObligation* ob)
68
{
69
682
  d_ob.emplace(t, ob);
70
682
}
71
72
14470
RConsObligation* RConsTypeInfo::builtinToOb(Node t)
73
{
74
14470
  auto it = d_ob.find(t);
75
14470
  if (it != d_ob.cend())
76
  {
77
13813
    return it->second;
78
  }
79
657
  return nullptr;
80
}
81
82
}  // namespace quantifiers
83
}  // namespace theory
84
28194
}  // namespace cvc5