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-21 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
51
void RConsTypeInfo::initialize(TermDbSygus* tds,
27
                               SygusStatistics& s,
28
                               TypeNode stn,
29
                               const std::vector<Node>& builtinVars)
30
{
31
51
  NodeManager* nm = NodeManager::currentNM();
32
51
  SkolemManager* sm = nm->getSkolemManager();
33
34
51
  d_enumerator.reset(new SygusEnumerator(tds, nullptr, s, true));
35
51
  d_enumerator->initialize(sm->mkDummySkolem("sygus_rcons", stn));
36
51
  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
51
  d_sygusSampler.initialize(stn, builtinVars, 0);
40
51
  d_crd->initialize(builtinVars, &d_sygusSampler);
41
51
}
42
43
10497
Node RConsTypeInfo::nextEnum()
44
{
45
10497
  if (!d_enumerator->increment())
46
  {
47
58
    Trace("sygus-rcons") << "no increment" << std::endl;
48
58
    return Node::null();
49
  }
50
51
20878
  Node sz = d_enumerator->getCurrent();
52
53
20878
  Trace("sygus-rcons") << (sz == Node::null()
54
20878
                               ? sz
55
10439
                               : datatypes::utils::sygusToBuiltin(sz))
56
10439
                       << std::endl;
57
58
10439
  return sz;
59
}
60
61
739
Node RConsTypeInfo::addTerm(Node n)
62
{
63
1478
  std::stringstream out;
64
1478
  return d_crd->addTerm(n, false, out);
65
}
66
67
671
void RConsTypeInfo::setBuiltinToOb(Node t, RConsObligation* ob)
68
{
69
671
  d_ob.emplace(t, ob);
70
671
}
71
72
14351
RConsObligation* RConsTypeInfo::builtinToOb(Node t)
73
{
74
14351
  auto it = d_ob.find(t);
75
14351
  if (it != d_ob.cend())
76
  {
77
13703
    return it->second;
78
  }
79
648
  return nullptr;
80
}
81
82
}  // namespace quantifiers
83
}  // namespace theory
84
27735
}  // namespace cvc5