GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/sygus/rcons_type_info.cpp Lines: 31 31 100.0 %
Date: 2021-09-07 Branches: 38 70 54.3 %

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(Env& env,
27
                               TermDbSygus* tds,
28
                               SygusStatistics& s,
29
                               TypeNode stn,
30
                               const std::vector<Node>& builtinVars)
31
{
32
53
  NodeManager* nm = NodeManager::currentNM();
33
53
  SkolemManager* sm = nm->getSkolemManager();
34
35
53
  d_enumerator.reset(new SygusEnumerator(tds, nullptr, &s, true));
36
53
  d_enumerator->initialize(sm->mkDummySkolem("sygus_rcons", stn));
37
53
  d_crd.reset(new CandidateRewriteDatabase(env, true, false, true, false));
38
  // since initial samples are not always useful for equivalence checks, set
39
  // their number to 0
40
53
  d_sygusSampler.initialize(stn, builtinVars, 0);
41
53
  d_crd->initialize(builtinVars, &d_sygusSampler);
42
53
}
43
44
11508
Node RConsTypeInfo::nextEnum()
45
{
46
11508
  if (!d_enumerator->increment())
47
  {
48
656
    Trace("sygus-rcons") << "no increment" << std::endl;
49
656
    return Node::null();
50
  }
51
52
21704
  Node sz = d_enumerator->getCurrent();
53
54
21704
  Trace("sygus-rcons") << (sz == Node::null()
55
21704
                               ? sz
56
10852
                               : datatypes::utils::sygusToBuiltin(sz))
57
10852
                       << std::endl;
58
59
10852
  return sz;
60
}
61
62
768
Node RConsTypeInfo::addTerm(Node n)
63
{
64
1536
  std::stringstream out;
65
1536
  return d_crd->addTerm(n, false, out);
66
}
67
68
699
void RConsTypeInfo::setBuiltinToOb(Node t, RConsObligation* ob)
69
{
70
699
  d_ob.emplace(t, ob);
71
699
}
72
73
15640
RConsObligation* RConsTypeInfo::builtinToOb(Node t)
74
{
75
15640
  auto it = d_ob.find(t);
76
15640
  if (it != d_ob.cend())
77
  {
78
14966
    return it->second;
79
  }
80
674
  return nullptr;
81
}
82
83
}  // namespace quantifiers
84
}  // namespace theory
85
29502
}  // namespace cvc5