GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/sygus/sygus_enumerator.cpp Lines: 627 645 97.2 %
Date: 2021-09-29 Branches: 991 2260 43.8 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Mathias Preiner, 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 sygus_enumerator.
14
 */
15
16
#include "theory/quantifiers/sygus/sygus_enumerator.h"
17
18
#include "expr/dtype_cons.h"
19
#include "expr/node_algorithm.h"
20
#include "options/datatypes_options.h"
21
#include "options/quantifiers_options.h"
22
#include "smt/logic_exception.h"
23
#include "theory/datatypes/sygus_datatype_utils.h"
24
#include "theory/datatypes/theory_datatypes_utils.h"
25
#include "theory/quantifiers/sygus/synth_engine.h"
26
#include "theory/quantifiers/sygus/type_node_id_trie.h"
27
#include "theory/rewriter.h"
28
#include "util/rational.h"
29
30
using namespace cvc5::kind;
31
32
namespace cvc5 {
33
namespace theory {
34
namespace quantifiers {
35
36
167
SygusEnumerator::SygusEnumerator(TermDbSygus* tds,
37
                                 SygusEnumeratorCallback* sec,
38
                                 SygusStatistics* s,
39
                                 bool enumShapes,
40
167
                                 bool enumAnyConstHoles)
41
    : d_tds(tds),
42
      d_sec(sec),
43
      d_stats(s),
44
      d_enumShapes(enumShapes),
45
      d_enumAnyConstHoles(enumAnyConstHoles),
46
      d_tlEnum(nullptr),
47
167
      d_abortSize(-1)
48
{
49
167
}
50
51
167
void SygusEnumerator::initialize(Node e)
52
{
53
167
  Trace("sygus-enum") << "SygusEnumerator::initialize " << e << std::endl;
54
167
  d_enum = e;
55
  // allocate the default callback
56
167
  if (d_sec == nullptr && options::sygusSymBreakDynamic())
57
  {
58
53
    d_secd.reset(new SygusEnumeratorCallbackDefault(e, d_stats));
59
53
    d_sec = d_secd.get();
60
  }
61
167
  d_etype = d_enum.getType();
62
167
  Assert(d_etype.isDatatype());
63
167
  Assert(d_etype.getDType().isSygus());
64
167
  d_tlEnum = getMasterEnumForType(d_etype);
65
167
  d_abortSize = options::sygusAbortSize();
66
67
  // if we don't have a term database, we don't register symmetry breaking
68
  // lemmas
69
167
  if (d_tds == nullptr)
70
  {
71
    return;
72
  }
73
  // Get the statically registered symmetry breaking clauses for e, see if they
74
  // can be used for speeding up the enumeration.
75
167
  NodeManager* nm = NodeManager::currentNM();
76
334
  std::vector<Node> sbl;
77
167
  d_tds->getSymBreakLemmas(e, sbl);
78
334
  Node ag = d_tds->getActiveGuardForEnumerator(e);
79
334
  Node truen = nm->mkConst(true);
80
  // use TNode for substitute below
81
334
  TNode agt = ag;
82
334
  TNode truent = truen;
83
167
  Assert(d_tcache.find(d_etype) != d_tcache.end());
84
167
  const DType& dt = d_etype.getDType();
85
237
  for (const Node& lem : sbl)
86
  {
87
70
    if (!d_tds->isSymBreakLemmaTemplate(lem))
88
    {
89
      // substitute its active guard by true and rewrite
90
72
      Node slem = lem.substitute(agt, truent);
91
36
      slem = Rewriter::rewrite(slem);
92
      // break into conjuncts
93
72
      std::vector<Node> sblc;
94
36
      if (slem.getKind() == AND)
95
      {
96
9
        for (const Node& slemc : slem)
97
        {
98
6
          sblc.push_back(slemc);
99
        }
100
      }
101
      else
102
      {
103
33
        sblc.push_back(slem);
104
      }
105
75
      for (const Node& sblemma : sblc)
106
      {
107
78
        Trace("sygus-enum")
108
39
            << "  symmetry breaking lemma : " << sblemma << std::endl;
109
        // if its a negation of a unit top-level tester, then this specifies
110
        // that we should not enumerate terms whose top symbol is that
111
        // constructor
112
39
        if (sblemma.getKind() == NOT)
113
        {
114
74
          Node a;
115
37
          int tst = datatypes::utils::isTester(sblemma[0], a);
116
37
          if (tst >= 0)
117
          {
118
37
            if (a == e)
119
            {
120
74
              Node cons = dt[tst].getConstructor();
121
74
              Trace("sygus-enum") << "  ...unit exclude constructor #" << tst
122
37
                                  << ", constructor " << cons << std::endl;
123
37
              d_sbExcTlCons.insert(cons);
124
            }
125
          }
126
        }
127
        // other symmetry breaking lemmas such as disjunctions are not used
128
      }
129
    }
130
  }
131
}
132
133
114
void SygusEnumerator::addValue(Node v)
134
{
135
  // do nothing
136
114
}
137
138
46363
bool SygusEnumerator::increment() { return d_tlEnum->increment(); }
139
45817
Node SygusEnumerator::getCurrent()
140
{
141
45817
  if (d_abortSize >= 0)
142
  {
143
4237
    int cs = static_cast<int>(d_tlEnum->getCurrentSize());
144
4237
    if (cs > d_abortSize)
145
    {
146
18
      std::stringstream ss;
147
9
      ss << "Maximum term size (" << options::sygusAbortSize()
148
9
         << ") for enumerative SyGuS exceeded.";
149
9
      throw LogicException(ss.str());
150
    }
151
  }
152
45808
  Node ret = d_tlEnum->getCurrent();
153
45808
  if (!ret.isNull() && !d_sbExcTlCons.empty())
154
  {
155
433
    Assert(ret.hasOperator());
156
    // might be excluded by an externally provided symmetry breaking clause
157
433
    if (d_sbExcTlCons.find(ret.getOperator()) != d_sbExcTlCons.end())
158
    {
159
48
      Trace("sygus-enum-exc")
160
48
          << "Exclude (external) : " << datatypes::utils::sygusToBuiltin(ret)
161
24
          << std::endl;
162
24
      ret = Node::null();
163
    }
164
  }
165
45808
  if (Trace.isOn("sygus-enum"))
166
  {
167
    Trace("sygus-enum") << "Enumerate : ";
168
    TermDbSygus::toStreamSygus("sygus-enum", ret);
169
    Trace("sygus-enum") << std::endl;
170
  }
171
45808
  return ret;
172
}
173
174
295
bool SygusEnumerator::isEnumShapes() const { return d_enumShapes; }
175
176
311
SygusEnumerator::TermCache::TermCache()
177
    : d_sec(nullptr),
178
      d_isSygusType(false),
179
      d_numConClasses(0),
180
      d_sizeEnum(0),
181
311
      d_isComplete(false)
182
{
183
311
}
184
185
311
void SygusEnumerator::TermCache::initialize(SygusStatistics* s,
186
                                            Node e,
187
                                            TypeNode tn,
188
                                            SygusEnumeratorCallback* sec)
189
{
190
311
  Trace("sygus-enum-debug") << "Init term cache " << tn << "..." << std::endl;
191
311
  d_stats = s;
192
311
  d_enum = e;
193
311
  d_tn = tn;
194
311
  d_sec = sec;
195
311
  d_sizeStartIndex[0] = 0;
196
311
  d_isSygusType = false;
197
198
  // compute static information about tn
199
311
  if (!d_tn.isDatatype())
200
  {
201
    // not a datatype, finish
202
32
    return;
203
  }
204
295
  const DType& dt = tn.getDType();
205
295
  if (!dt.isSygus())
206
  {
207
    // not a sygus datatype, finish
208
    return;
209
  }
210
211
295
  d_isSygusType = true;
212
213
  // get argument types for all constructors
214
590
  std::map<unsigned, std::vector<TypeNode>> argTypes;
215
  // map weights to constructors
216
590
  std::map<unsigned, std::vector<unsigned>> weightsToIndices;
217
218
  // constructor class 0 is reserved for nullary operators with 0 weight
219
  // this is an optimization so that we always skip them for sizes >= 1
220
295
  ConstructorClass& ccZero = d_cclass[0];
221
295
  ccZero.d_weight = 0;
222
295
  d_numConClasses = 1;
223
  // we must indicate that we should process zero weight constructor classes
224
295
  weightsToIndices[0].clear();
225
1802
  for (unsigned i = 0, ncons = dt.getNumConstructors(); i < ncons; i++)
226
  {
227
    // record weight information
228
1507
    unsigned w = dt[i].getWeight();
229
3014
    Trace("sygus-enum-debug") << "Weight " << dt[i].getSygusOp() << ": " << w
230
1507
                              << std::endl;
231
1507
    weightsToIndices[w].push_back(i);
232
    // record type information
233
3113
    for (unsigned j = 0, nargs = dt[i].getNumArgs(); j < nargs; j++)
234
    {
235
3212
      TypeNode type = dt[i].getArgType(j);
236
1606
      argTypes[i].push_back(type);
237
    }
238
  }
239
295
  NodeManager* nm = NodeManager::currentNM();
240
821
  for (std::pair<const unsigned, std::vector<unsigned>>& wp : weightsToIndices)
241
  {
242
526
    unsigned w = wp.first;
243
244
    // assign constructors to constructor classes
245
1052
    TypeNodeIdTrie tnit;
246
1052
    std::map<Node, unsigned> nToC;
247
2033
    for (unsigned i : wp.second)
248
    {
249
1507
      if (argTypes[i].empty() && w == 0)
250
      {
251
631
        ccZero.d_cons.push_back(i);
252
      }
253
      else
254
      {
255
        // we merge those whose argument types are the same
256
        // We could, but choose not to, order these types, which would lead to
257
        // more aggressive merging of constructor classes. On the negative side,
258
        // this adds another level of indirection to remember which argument
259
        // positions the argument types occur in, for each constructor.
260
1752
        Node n = nm->mkConst(Rational(i));
261
876
        nToC[n] = i;
262
876
        tnit.add(n, argTypes[i]);
263
      }
264
    }
265
1052
    std::map<Node, unsigned> assign;
266
526
    tnit.assignIds(assign, d_numConClasses);
267
1402
    for (std::pair<const Node, unsigned>& cp : assign)
268
    {
269
      // determine which constructor class this goes into using tnit
270
876
      unsigned cclassi = cp.second;
271
876
      unsigned i = nToC[cp.first];
272
1752
      Trace("sygus-enum-debug") << "Constructor class for "
273
1752
                                << dt[i].getSygusOp() << " is " << cclassi
274
876
                                << std::endl;
275
      // initialize the constructor class
276
876
      if (d_cclass.find(cclassi) == d_cclass.end())
277
      {
278
513
        d_cclass[cclassi].d_weight = w;
279
2052
        d_cclass[cclassi].d_types.insert(d_cclass[cclassi].d_types.end(),
280
513
                                         argTypes[i].begin(),
281
2052
                                         argTypes[i].end());
282
      }
283
      // add to constructor class
284
876
      d_cclass[cclassi].d_cons.push_back(i);
285
    }
286
1052
    Trace("sygus-enum-debug") << "#cons classes for weight <= " << w << " : "
287
526
                              << d_numConClasses << std::endl;
288
526
    d_weightToCcIndex[w] = d_numConClasses;
289
  }
290
295
  Trace("sygus-enum-debug") << "...finish" << std::endl;
291
}
292
293
56254
unsigned SygusEnumerator::TermCache::getLastConstructorClassIndexForWeight(
294
    unsigned w) const
295
{
296
56254
  std::map<unsigned, unsigned>::const_iterator it = d_weightToCcIndex.find(w);
297
56254
  if (it == d_weightToCcIndex.end())
298
  {
299
47545
    return d_numConClasses;
300
  }
301
8709
  return it->second;
302
}
303
92
unsigned SygusEnumerator::TermCache::getNumConstructorClasses() const
304
{
305
92
  return d_numConClasses;
306
}
307
869
void SygusEnumerator::TermCache::getConstructorClass(
308
    unsigned i, std::vector<unsigned>& cclass) const
309
{
310
869
  std::map<unsigned, ConstructorClass>::const_iterator it = d_cclass.find(i);
311
869
  Assert(it != d_cclass.end());
312
869
  cclass.insert(
313
1738
      cclass.end(), it->second.d_cons.begin(), it->second.d_cons.end());
314
869
}
315
832
void SygusEnumerator::TermCache::getTypesForConstructorClass(
316
    unsigned i, std::vector<TypeNode>& types) const
317
{
318
832
  std::map<unsigned, ConstructorClass>::const_iterator it = d_cclass.find(i);
319
832
  Assert(it != d_cclass.end());
320
832
  types.insert(
321
1664
      types.end(), it->second.d_types.begin(), it->second.d_types.end());
322
832
}
323
324
832
unsigned SygusEnumerator::TermCache::getWeightForConstructorClass(
325
    unsigned i) const
326
{
327
832
  std::map<unsigned, ConstructorClass>::const_iterator it = d_cclass.find(i);
328
832
  Assert(it != d_cclass.end());
329
832
  return it->second.d_weight;
330
}
331
332
55393
bool SygusEnumerator::TermCache::addTerm(Node n)
333
{
334
55393
  if (!d_isSygusType)
335
  {
336
    // non-sygus terms generated by TermEnumMasterInterp/TermEnumMasterFv
337
    // enumeration are unique by construction
338
222
    Trace("sygus-enum-terms") << "tc(" << d_tn << "): term (builtin): " << n
339
111
                              << std::endl;
340
111
    d_terms.push_back(n);
341
111
    return true;
342
  }
343
55282
  Assert(!n.isNull());
344
55282
  if (d_sec != nullptr)
345
  {
346
55282
    if (!d_sec->addTerm(n, d_bterms))
347
    {
348
62868
      Trace("sygus-enum-exc")
349
62868
          << "Exclude: " << datatypes::utils::sygusToBuiltin(n)
350
31434
          << " due to callback" << std::endl;
351
31434
      return false;
352
    }
353
  }
354
23848
  if (d_stats != nullptr)
355
  {
356
23848
    ++(d_stats->d_enumTerms);
357
  }
358
23848
  d_terms.push_back(n);
359
23848
  return true;
360
}
361
424
void SygusEnumerator::TermCache::pushEnumSizeIndex()
362
{
363
424
  d_sizeEnum++;
364
424
  d_sizeStartIndex[d_sizeEnum] = d_terms.size();
365
848
  Trace("sygus-enum-debug") << "tc(" << d_tn << "): size " << d_sizeEnum
366
848
                            << " terms start at index " << d_terms.size()
367
424
                            << std::endl;
368
424
}
369
40498
unsigned SygusEnumerator::TermCache::getEnumSize() const { return d_sizeEnum; }
370
35086
unsigned SygusEnumerator::TermCache::getIndexForSize(unsigned s) const
371
{
372
35086
  Assert(s <= d_sizeEnum);
373
35086
  std::map<unsigned, unsigned>::const_iterator it = d_sizeStartIndex.find(s);
374
35086
  Assert(it != d_sizeStartIndex.end());
375
35086
  return it->second;
376
}
377
217056
Node SygusEnumerator::TermCache::getTerm(unsigned index) const
378
{
379
217056
  Assert(index < d_terms.size());
380
217056
  return d_terms[index];
381
}
382
383
54463
unsigned SygusEnumerator::TermCache::getNumTerms() const
384
{
385
54463
  return d_terms.size();
386
}
387
388
57049
bool SygusEnumerator::TermCache::isComplete() const { return d_isComplete; }
389
43
void SygusEnumerator::TermCache::setComplete() { d_isComplete = true; }
390
216394
unsigned SygusEnumerator::TermEnum::getCurrentSize() { return d_currSize; }
391
3608
SygusEnumerator::TermEnum::TermEnum() : d_se(nullptr), d_currSize(0) {}
392
3297
SygusEnumerator::TermEnumSlave::TermEnumSlave()
393
    : TermEnum(),
394
      d_sizeLim(0),
395
      d_index(0),
396
      d_indexNextEnd(0),
397
      d_hasIndexNextEnd(false),
398
3297
      d_master(nullptr)
399
{
400
3297
}
401
402
3297
bool SygusEnumerator::TermEnumSlave::initialize(SygusEnumerator* se,
403
                                                TypeNode tn,
404
                                                unsigned sizeMin,
405
                                                unsigned sizeMax)
406
{
407
3297
  d_se = se;
408
3297
  d_tn = tn;
409
3297
  d_sizeLim = sizeMax;
410
6594
  Trace("sygus-enum-debug2") << "slave(" << d_tn
411
3297
                             << "): init, min/max=" << sizeMin << "/" << sizeMax
412
3297
                             << "...\n";
413
414
  // must have pointer to the master
415
3297
  d_master = d_se->getMasterEnumForType(d_tn);
416
417
3297
  SygusEnumerator::TermCache& tc = d_se->d_tcache[d_tn];
418
  // if the size is exact, we start at the limit
419
3297
  d_currSize = sizeMin;
420
  // initialize the index
421
3303
  while (d_currSize > tc.getEnumSize())
422
  {
423
76
    Trace("sygus-enum-debug2") << "slave(" << d_tn
424
38
                               << "): init force increment master...\n";
425
    // increment the master until we have enough terms
426
38
    if (!d_master->increment())
427
    {
428
70
      Trace("sygus-enum-debug2") << "slave(" << d_tn
429
35
                                 << "): ...fail init force master\n";
430
35
      return false;
431
    }
432
6
    Trace("sygus-enum-debug2") << "slave(" << d_tn
433
3
                               << "): ...success init force master\n";
434
  }
435
3262
  d_index = tc.getIndexForSize(d_currSize);
436
3262
  Trace("sygus-enum-debug2") << "slave(" << d_tn << "): validate indices...\n";
437
  // initialize the next end index (marks where size increments)
438
3262
  validateIndexNextEnd();
439
6524
  Trace("sygus-enum-debug2")
440
3262
      << "slave(" << d_tn << "): validate init end: " << d_hasIndexNextEnd
441
3262
      << " " << d_indexNextEnd << " " << d_index << " " << d_currSize << "\n";
442
  // ensure that indexNextEnd is valid (it must be greater than d_index)
443
3262
  bool ret = validateIndex();
444
6524
  Trace("sygus-enum-debug2")
445
6524
      << "slave(" << d_tn << "): ..." << (ret ? "success" : "fail")
446
3262
      << " init, now: " << d_hasIndexNextEnd << " " << d_indexNextEnd << " "
447
3262
      << d_index << " " << d_currSize << "\n";
448
3262
  return ret;
449
}
450
451
108528
Node SygusEnumerator::TermEnumSlave::getCurrent()
452
{
453
108528
  SygusEnumerator::TermCache& tc = d_se->d_tcache[d_tn];
454
217056
  Node curr = tc.getTerm(d_index);
455
217056
  Trace("sygus-enum-debug2")
456
108528
      << "slave(" << d_tn
457
217056
      << "): current : " << datatypes::utils::sygusToBuiltin(curr)
458
217056
      << ", sizes = " << datatypes::utils::getSygusTermSize(curr) << " "
459
108528
      << getCurrentSize() << std::endl;
460
217056
  Trace("sygus-enum-debug2") << "slave(" << d_tn
461
108528
                             << "): indices : " << d_hasIndexNextEnd << " "
462
108528
                             << d_indexNextEnd << " " << d_index << std::endl;
463
  // lookup in the cache
464
217056
  return tc.getTerm(d_index);
465
}
466
467
30976
bool SygusEnumerator::TermEnumSlave::increment()
468
{
469
  // increment index
470
30976
  d_index++;
471
  // ensure that index is valid
472
30976
  return validateIndex();
473
}
474
475
34238
bool SygusEnumerator::TermEnumSlave::validateIndex()
476
{
477
34238
  Trace("sygus-enum-debug2") << "slave(" << d_tn << ") : validate index...\n";
478
34238
  SygusEnumerator::TermCache& tc = d_se->d_tcache[d_tn];
479
  // ensure that index is in the range
480
53816
  while (d_index >= tc.getNumTerms())
481
  {
482
10335
    Assert(d_index == tc.getNumTerms());
483
10335
    Trace("sygus-enum-debug2") << "slave(" << d_tn << ") : force master...\n";
484
    // if the size of the master is larger than the size limit, then
485
    // there is no use continuing, since there are no more terms that this
486
    // slave enumerator can return.
487
10335
    if (d_master->getCurrentSize() > d_sizeLim)
488
    {
489
444
      return false;
490
    }
491
    // must push the master index
492
9891
    if (!d_master->increment())
493
    {
494
204
      Trace("sygus-enum-debug2") << "slave(" << d_tn
495
102
                                 << ") : ...fail force master\n";
496
102
      return false;
497
    }
498
19578
    Trace("sygus-enum-debug2") << "slave(" << d_tn
499
9789
                               << ") : ...success force master\n";
500
  }
501
  // always validate the next index end here
502
33692
  validateIndexNextEnd();
503
67384
  Trace("sygus-enum-debug2") << "slave(" << d_tn
504
33692
                             << ") : validate index end...\n";
505
  // if we are at the beginning of the next size, increment current size
506
34142
  while (d_hasIndexNextEnd && d_index == d_indexNextEnd)
507
  {
508
2640
    d_currSize++;
509
5280
    Trace("sygus-enum-debug2") << "slave(" << d_tn << ") : size++ ("
510
2640
                               << d_currSize << "/" << d_sizeLim << ")\n";
511
    // if we've hit the size limit, return false
512
2640
    if (d_currSize > d_sizeLim)
513
    {
514
2415
      Trace("sygus-enum-debug2") << "slave(" << d_tn << ") : fail size\n";
515
2415
      return false;
516
    }
517
225
    validateIndexNextEnd();
518
  }
519
31277
  Trace("sygus-enum-debug2") << "slave(" << d_tn << ") : finished\n";
520
31277
  return true;
521
}
522
523
37179
void SygusEnumerator::TermEnumSlave::validateIndexNextEnd()
524
{
525
37179
  SygusEnumerator::TermCache& tc = d_se->d_tcache[d_tn];
526
  // update the next end index
527
37179
  d_hasIndexNextEnd = d_currSize < tc.getEnumSize();
528
37179
  if (d_hasIndexNextEnd)
529
  {
530
31824
    d_indexNextEnd = tc.getIndexForSize(d_currSize + 1);
531
  }
532
37179
}
533
534
311
void SygusEnumerator::initializeTermCache(TypeNode tn)
535
{
536
  // initialize the term cache
537
311
  d_tcache[tn].initialize(d_stats, d_enum, tn, d_sec);
538
311
}
539
540
3464
SygusEnumerator::TermEnum* SygusEnumerator::getMasterEnumForType(TypeNode tn)
541
{
542
3464
  if (tn.isDatatype() && tn.getDType().isSygus())
543
  {
544
3437
    std::map<TypeNode, TermEnumMaster>::iterator it = d_masterEnum.find(tn);
545
3437
    if (it != d_masterEnum.end())
546
    {
547
3142
      return &it->second;
548
    }
549
295
    initializeTermCache(tn);
550
    // initialize the master enumerator
551
295
    bool ret = d_masterEnum[tn].initialize(this, tn);
552
295
    AlwaysAssert(ret);
553
295
    return &d_masterEnum[tn];
554
  }
555
27
  if (d_enumAnyConstHoles)
556
  {
557
5
    std::map<TypeNode, TermEnumMasterFv>::iterator it = d_masterEnumFv.find(tn);
558
5
    if (it != d_masterEnumFv.end())
559
    {
560
      return &it->second;
561
    }
562
5
    initializeTermCache(tn);
563
    // initialize the master enumerator
564
5
    bool ret = d_masterEnumFv[tn].initialize(this, tn);
565
5
    AlwaysAssert(ret);
566
5
    return &d_masterEnumFv[tn];
567
  }
568
  std::map<TypeNode, std::unique_ptr<TermEnumMasterInterp>>::iterator it =
569
22
      d_masterEnumInt.find(tn);
570
22
  if (it != d_masterEnumInt.end())
571
  {
572
11
    return it->second.get();
573
  }
574
11
  initializeTermCache(tn);
575
  // create the master enumerator
576
11
  d_masterEnumInt[tn].reset(new TermEnumMasterInterp(tn));
577
  // initialize the master enumerator
578
11
  TermEnumMasterInterp* temi = d_masterEnumInt[tn].get();
579
11
  bool ret = temi->initialize(this, tn);
580
11
  AlwaysAssert(ret);
581
11
  return temi;
582
}
583
584
295
SygusEnumerator::TermEnumMaster::TermEnumMaster()
585
    : TermEnum(),
586
      d_enumShapes(false),
587
      d_enumShapesInit(false),
588
      d_isIncrementing(false),
589
      d_currTermSet(false),
590
      d_consClassNum(0),
591
      d_ccWeight(0),
592
      d_consNum(0),
593
      d_currChildSize(0),
594
295
      d_childrenValid(0)
595
{
596
295
}
597
598
295
bool SygusEnumerator::TermEnumMaster::initialize(SygusEnumerator* se,
599
                                                 TypeNode tn)
600
{
601
295
  Trace("sygus-enum-debug") << "master(" << tn << "): init...\n";
602
295
  d_tds = se->d_tds;
603
295
  d_se = se;
604
295
  d_tn = tn;
605
606
295
  d_currSize = 0;
607
  // we will start with constructor class zero
608
295
  d_consClassNum = 0;
609
295
  d_currChildSize = 0;
610
295
  d_ccCons.clear();
611
295
  d_enumShapes = se->isEnumShapes();
612
295
  d_enumShapesInit = false;
613
295
  d_isIncrementing = false;
614
295
  d_currTermSet = false;
615
295
  bool ret = increment();
616
590
  Trace("sygus-enum-debug") << "master(" << tn
617
295
                            << "): finish init, ret = " << ret << "\n";
618
295
  return ret;
619
}
620
621
101024
Node SygusEnumerator::TermEnumMaster::getCurrent()
622
{
623
101024
  if (d_currTermSet)
624
  {
625
45808
    return d_currTerm;
626
  }
627
55216
  d_currTermSet = true;
628
  // construct based on the children
629
110432
  std::vector<Node> children;
630
55216
  const DType& dt = d_tn.getDType();
631
55216
  Assert(d_consNum > 0 && d_consNum <= d_ccCons.size());
632
  // get the current constructor number
633
55216
  unsigned cnum = d_ccCons[d_consNum - 1];
634
55216
  children.push_back(dt[cnum].getConstructor());
635
  // add the current of each child to children
636
163744
  for (unsigned i = 0, nargs = dt[cnum].getNumArgs(); i < nargs; i++)
637
  {
638
108528
    Assert(d_children.find(i) != d_children.end());
639
217056
    Node cc = d_children[i].getCurrent();
640
108528
    if (cc.isNull())
641
    {
642
      d_currTerm = cc;
643
      return cc;
644
    }
645
108528
    children.push_back(cc);
646
  }
647
55216
  if (d_enumShapes)
648
  {
649
    // ensure all variables are unique
650
10977
    childrenToShape(children);
651
  }
652
55216
  d_currTerm = NodeManager::currentNM()->mkNode(APPLY_CONSTRUCTOR, children);
653
55216
  return d_currTerm;
654
}
655
656
56480
bool SygusEnumerator::TermEnumMaster::increment()
657
{
658
  // Am I already incrementing? If so, fail.
659
  // This is to break infinite loops for slave enumerators who request an
660
  // increment() from the master enumerator of their type that is also their
661
  // parent. This ensures we do not loop on a grammar like:
662
  //   A -> -( A ) | B+B
663
  //   B -> x | y
664
  // where we require the first term enumerated to be over B+B.
665
  // Set that we are incrementing
666
56480
  if (d_isIncrementing)
667
  {
668
    return false;
669
  }
670
112960
  Trace("sygus-enum-summary") << "SygusEnumerator::TermEnumMaster: increment "
671
56480
                              << d_tn << "..." << std::endl;
672
56480
  d_isIncrementing = true;
673
56480
  bool ret = incrementInternal();
674
56480
  d_isIncrementing = false;
675
112960
  Trace("sygus-enum-summary")
676
56480
      << "SygusEnumerator::TermEnumMaster: finished increment " << d_tn
677
56480
      << std::endl;
678
56480
  return ret;
679
}
680
681
57006
bool SygusEnumerator::TermEnumMaster::incrementInternal()
682
{
683
57006
  SygusEnumerator::TermCache& tc = d_se->d_tcache[d_tn];
684
57006
  if (tc.isComplete())
685
  {
686
752
    return false;
687
  }
688
112508
  Trace("sygus-enum-debug2") << "master(" << d_tn
689
56254
                             << "): get last constructor class..." << std::endl;
690
  // the maximum index of a constructor class to consider
691
56254
  unsigned ncc = tc.getLastConstructorClassIndexForWeight(d_currSize);
692
112508
  Trace("sygus-enum-debug2") << "Last constructor class " << d_currSize << ": "
693
56254
                             << ncc << std::endl;
694
  // If we are enumerating shapes, the first enumerated term is a free variable.
695
56254
  if (d_enumShapes && !d_enumShapesInit)
696
  {
697
66
    Assert(d_tds != nullptr);
698
132
    Node fv = d_tds->getFreeVar(d_tn, 0);
699
66
    d_enumShapesInit = true;
700
66
    d_currTermSet = true;
701
66
    d_currTerm = fv;
702
    // must add to term cache
703
66
    tc.addTerm(fv);
704
66
    return true;
705
  }
706
707
  // have we initialized the current constructor class?
708
57926
  while (d_ccCons.empty() && d_consClassNum < ncc)
709
  {
710
869
    Assert(d_ccTypes.empty());
711
1738
    Trace("sygus-enum-debug2") << "master(" << d_tn
712
869
                               << "): try constructor class " << d_consClassNum
713
869
                               << std::endl;
714
    // get the list of constructors in the constructor class
715
869
    tc.getConstructorClass(d_consClassNum, d_ccCons);
716
    // if there are any...
717
869
    if (!d_ccCons.empty())
718
    {
719
      // successfully initialized the constructor class
720
797
      d_consNum = 0;
721
      // we will populate the children
722
797
      Assert(d_children.empty());
723
797
      Assert(d_ccTypes.empty());
724
797
      tc.getTypesForConstructorClass(d_consClassNum, d_ccTypes);
725
797
      d_ccWeight = tc.getWeightForConstructorClass(d_consClassNum);
726
797
      d_childrenValid = 0;
727
      // initialize the children into their initial state
728
797
      if (!initializeChildren())
729
      {
730
        // didn't work (due to size), we will try the next class
731
104
        d_ccCons.clear();
732
104
        d_ccTypes.clear();
733
208
        Trace("sygus-enum-debug2") << "master(" << d_tn
734
104
                                   << "): failed due to init size\n";
735
      }
736
    }
737
    else
738
    {
739
      // No constructors in constructor class. This can happen for class 0 if a
740
      // type has no nullary constructors with weight 0.
741
144
      Trace("sygus-enum-debug2") << "master(" << d_tn
742
72
                                 << "): failed due to no cons\n";
743
    }
744
    // increment the next constructor class we will try
745
869
    d_consClassNum++;
746
  }
747
748
  // have we run out of constructor classes for this size?
749
56188
  if (d_ccCons.empty())
750
  {
751
    // check whether we should terminate, which notice always treats
752
    // uninterpreted sorts as infinite, since we do not put bounds on them
753
    // in our enumeration.
754
446
    if (isCardinalityClassFinite(d_tn.getCardinalityClass(), false))
755
    {
756
92
      if (ncc == tc.getNumConstructorClasses())
757
      {
758
67
        bool doTerminate = true;
759
78
        for (unsigned i = 1; i < ncc; i++)
760
        {
761
          // The maximum size of terms from a constructor class can be
762
          // determined if all of its argument types are finished enumerating.
763
          // If this maximum size is less than or equal to d_currSize for
764
          // each constructor class, we are done.
765
35
          unsigned sum = tc.getWeightForConstructorClass(i);
766
46
          std::vector<TypeNode> cctns;
767
35
          tc.getTypesForConstructorClass(i, cctns);
768
54
          for (unsigned j = 0, ntypes = cctns.size(); j < ntypes; j++)
769
          {
770
62
            TypeNode tnc = cctns[j];
771
43
            SygusEnumerator::TermCache& tcc = d_se->d_tcache[tnc];
772
43
            if (!tcc.isComplete())
773
            {
774
              // maximum size of this constructor class cannot be determined
775
24
              doTerminate = false;
776
24
              break;
777
            }
778
            else
779
            {
780
19
              sum += tcc.getEnumSize();
781
19
              if (sum > d_currSize)
782
              {
783
                // maximum size of this constructor class is greater than size
784
                doTerminate = false;
785
                break;
786
              }
787
            }
788
          }
789
35
          if (!doTerminate)
790
          {
791
24
            break;
792
          }
793
        }
794
67
        if (doTerminate)
795
        {
796
86
          Trace("sygus-engine") << "master(" << d_tn << "): complete at size "
797
43
                                << d_currSize << std::endl;
798
43
          tc.setComplete();
799
43
          return false;
800
        }
801
      }
802
    }
803
804
    // increment the size bound
805
403
    d_currSize++;
806
806
    Trace("sygus-enum-debug2") << "master(" << d_tn
807
403
                               << "): size++ : " << d_currSize << "\n";
808
403
    if (Trace.isOn("sygus-engine"))
809
    {
810
      // am i the master enumerator? if so, print
811
      if (d_se->d_tlEnum == this)
812
      {
813
        Trace("sygus-engine") << "SygusEnumerator::size = " << d_currSize
814
                              << std::endl;
815
      }
816
    }
817
818
    // push the bound
819
403
    tc.pushEnumSizeIndex();
820
821
    // restart with constructor class one (skip nullary constructors)
822
403
    d_consClassNum = 1;
823
824
    // We break for a round: return the null term when we cross a size
825
    // boundary. This ensures that the necessary breaks are taken, e.g.
826
    // in slave enumerators who may instead want to abandon this call to
827
    // increment master when the size of the master makes their increment
828
    // infeasible.
829
403
    d_currTermSet = true;
830
403
    d_currTerm = Node::null();
831
403
    return true;
832
  }
833
834
55742
  bool incSuccess = false;
835
28640
  do
836
  {
837
167712
    Trace("sygus-enum-debug2") << "master(" << d_tn << "): check return "
838
167712
                               << d_childrenValid << "/" << d_ccTypes.size()
839
83856
                               << std::endl;
840
    // the children should be initialized by here
841
83856
    Assert(d_childrenValid == d_ccTypes.size());
842
843
    // do we have more constructors for the given children?
844
83856
    if (d_consNum < d_ccCons.size())
845
    {
846
110432
      Trace("sygus-enum-debug2") << "master(" << d_tn << "): try constructor "
847
55216
                                 << d_consNum << std::endl;
848
      // increment constructor index
849
      // we will build for the current constructor and the given children
850
55216
      d_consNum++;
851
55216
      d_currTermSet = false;
852
55216
      d_currTerm = Node::null();
853
110432
      Node c = getCurrent();
854
55216
      if (!c.isNull())
855
      {
856
55216
        if (!tc.addTerm(c))
857
        {
858
          // the term was not unique based on rewriting
859
62868
          Trace("sygus-enum-debug2") << "master(" << d_tn
860
31434
                                     << "): failed addTerm\n";
861
          // we will return null (d_currTermSet is true at this point)
862
31434
          Assert(d_currTermSet);
863
31434
          d_currTerm = Node::null();
864
        }
865
      }
866
55216
      return true;
867
    }
868
869
    // finished constructors for this set of children, must increment children
870
871
    // reset the constructor number
872
28640
    d_consNum = 0;
873
874
    // try incrementing the last child until we find one that works
875
28640
    incSuccess = false;
876
90592
    while (!incSuccess && d_childrenValid > 0)
877
    {
878
61952
      Trace("sygus-enum-debug2") << "master(" << d_tn << "): try incrementing "
879
30976
                                 << d_childrenValid << std::endl;
880
30976
      unsigned i = d_childrenValid - 1;
881
30976
      Assert(d_children[i].getCurrentSize() <= d_currChildSize);
882
      // track the size
883
30976
      d_currChildSize -= d_children[i].getCurrentSize();
884
30976
      if (d_children[i].increment())
885
      {
886
56238
        Trace("sygus-enum-debug2") << "master(" << d_tn
887
28119
                                   << "): increment success...\n";
888
28119
        d_currChildSize += d_children[i].getCurrentSize();
889
        // must see if we can initialize the remaining children here
890
        // if not, there is no use continuing.
891
28119
        if (initializeChildren())
892
        {
893
56228
          Trace("sygus-enum-debug2")
894
28114
              << "master(" << d_tn << "): success init children\n";
895
28114
          Assert(d_currChildSize + d_ccWeight <= d_currSize);
896
28114
          incSuccess = true;
897
        }
898
        else
899
        {
900
          // failed to initialize the remaining children (likely due to a
901
          // child having a non-zero minimum size bound).
902
10
          Trace("sygus-enum-debug2")
903
5
              << "master(" << d_tn << "): fail init children\n";
904
5
          d_currChildSize -= d_children[i].getCurrentSize();
905
        }
906
      }
907
30976
      if (!incSuccess)
908
      {
909
5724
        Trace("sygus-enum-debug2") << "master(" << d_tn
910
2862
                                   << "): fail, backtrack...\n";
911
        // current child is out of values
912
2862
        d_children.erase(i);
913
2862
        d_childrenValid--;
914
      }
915
    }
916
  } while (incSuccess);
917
1052
  Trace("sygus-enum-debug2") << "master(" << d_tn
918
526
                             << "): failed increment children\n";
919
  // restart with the next constructor class
920
526
  d_ccCons.clear();
921
526
  d_ccTypes.clear();
922
526
  return incrementInternal();
923
}
924
925
28916
bool SygusEnumerator::TermEnumMaster::initializeChildren()
926
{
927
57832
  Trace("sygus-enum-debug2")
928
28916
      << "master(" << d_tn << "): init children, start = " << d_childrenValid
929
57832
      << ", #types=" << d_ccTypes.size() << ", sizes=" << d_currChildSize << "/"
930
28916
      << d_currSize << std::endl;
931
28916
  unsigned currChildren = d_childrenValid;
932
28916
  unsigned sizeMin = 0;
933
  // while we need to initialize the current child
934
35352
  while (d_childrenValid < d_ccTypes.size())
935
  {
936
3327
    if (!initializeChild(d_childrenValid, sizeMin))
937
    {
938
169
      if (d_childrenValid == currChildren)
939
      {
940
        // we are back to the child we started with, we terminate now.
941
218
        Trace("sygus-enum-debug2") << "master(" << d_tn
942
109
                                   << "): init children : failed, finished"
943
109
                                   << std::endl;
944
109
        return false;
945
      }
946
120
      Trace("sygus-enum-debug2") << "master(" << d_tn
947
60
                                 << "): init children : failed" << std::endl;
948
      // we failed in this size configuration
949
      // reinitialize with the next size up
950
60
      unsigned currSize = d_children[d_childrenValid - 1].getCurrentSize();
951
60
      d_currChildSize -= currSize;
952
60
      sizeMin = currSize + 1;
953
60
      d_children.erase(d_childrenValid - 1);
954
60
      d_childrenValid--;
955
    }
956
    else
957
    {
958
3158
      sizeMin = 0;
959
3158
      d_childrenValid++;
960
    }
961
  }
962
57614
  Trace("sygus-enum-debug2") << "master(" << d_tn
963
28807
                             << "): init children : success" << std::endl;
964
  // initialized all children
965
28807
  return true;
966
}
967
968
3327
bool SygusEnumerator::TermEnumMaster::initializeChild(unsigned i,
969
                                                      unsigned sizeMin)
970
{
971
3327
  Assert(d_ccWeight <= d_currSize);
972
3327
  Assert(d_currChildSize + d_ccWeight <= d_currSize);
973
3327
  unsigned sizeMax = (d_currSize - d_ccWeight) - d_currChildSize;
974
6654
  Trace("sygus-enum-debug2") << "master(" << d_tn << "): initializeChild " << i
975
3327
                             << " (" << d_currSize << ", " << d_ccWeight << ", "
976
3327
                             << d_currChildSize << ")\n";
977
3327
  if (sizeMin > sizeMax)
978
  {
979
60
    Trace("sygus-enum-debug2") << "master(" << d_tn << "): failed due to size "
980
30
                               << sizeMin << "/" << sizeMax << "\n";
981
30
    return false;
982
  }
983
  // initialize the child to enumerate exactly the terms that sum to size
984
3297
  sizeMin = (i + 1 == d_ccTypes.size()) ? sizeMax : sizeMin;
985
3297
  TermEnumSlave& te = d_children[i];
986
3297
  bool init = te.initialize(d_se, d_ccTypes[i], sizeMin, sizeMax);
987
3297
  if (!init)
988
  {
989
    // failed to initialize
990
139
    d_children.erase(i);
991
278
    Trace("sygus-enum-debug2") << "master(" << d_tn
992
139
                               << "): failed due to child init\n";
993
139
    return false;
994
  }
995
3158
  unsigned teSize = te.getCurrentSize();
996
  // fail if the initial children size does not fit d_currSize-d_ccWeight
997
3158
  if (teSize + d_currChildSize + d_ccWeight > d_currSize)
998
  {
999
    d_children.erase(i);
1000
    Trace("sygus-enum-debug2") << "master(" << d_tn
1001
                               << "): failed due to child size\n";
1002
    return false;
1003
  }
1004
3158
  d_currChildSize += teSize;
1005
6316
  Trace("sygus-enum-debug2") << "master(" << d_tn
1006
3158
                             << "): success initializeChild " << i << "\n";
1007
3158
  return true;
1008
}
1009
1010
10977
void SygusEnumerator::TermEnumMaster::childrenToShape(
1011
    std::vector<Node>& children)
1012
{
1013
10977
  if (children.size() <= 2)
1014
  {
1015
    // don't need to convert constants and unary applications
1016
961
    return;
1017
  }
1018
20032
  std::map<TypeNode, int> vcounter;
1019
  // Buffered child, so that we only compute vcounter if there are more than
1020
  // one children with free variables, since otherwise there is no change.
1021
  // For example, if we are given { C, (+ x1 x2), 1 }, we buffer child (+ x1 x2)
1022
  // noting that it has free variables. We proceed with processing the remaining
1023
  // children, and note that no other child contains free variables, and hence
1024
  // no change is necessary (since by construction, all children have the
1025
  // property of having unique variable subterms). On the other hand if the
1026
  // last child above was x1, then this would trigger us to convert (+ x1 x2)
1027
  // while computing vcounter, and subsequently update x1 to x3 to obtain
1028
  // { C, (+ x1 x2), x3 }.
1029
  // Have we set the buffer child index
1030
10016
  bool bufferChildSet = false;
1031
  // Have we processed the buffer child index
1032
10016
  bool bufferChildProcessed = false;
1033
  // The buffer child index
1034
10016
  size_t bufferChild = 0;
1035
32121
  for (size_t i = 1, nchildren = children.size(); i < nchildren; i++)
1036
  {
1037
22105
    if (!expr::hasBoundVar(children[i]))
1038
    {
1039
      // don't need to care about expressions with no bound variables
1040
10145
      continue;
1041
    }
1042
20815
    else if (!bufferChildSet)
1043
    {
1044
8855
      bufferChild = i;
1045
8855
      bufferChildSet = true;
1046
8855
      continue;
1047
    }
1048
3105
    else if (!bufferChildProcessed)
1049
    {
1050
      // process the buffer child
1051
2910
      children[bufferChild] = convertShape(children[bufferChild], vcounter);
1052
2910
      bufferChildProcessed = true;
1053
    }
1054
3105
    children[i] = convertShape(children[i], vcounter);
1055
  }
1056
}
1057
1058
6015
Node SygusEnumerator::TermEnumMaster::convertShape(
1059
    Node n, std::map<TypeNode, int>& vcounter)
1060
{
1061
6015
  Assert(d_tds != nullptr);
1062
6015
  NodeManager* nm = NodeManager::currentNM();
1063
12030
  std::unordered_map<TNode, Node> visited;
1064
6015
  std::unordered_map<TNode, Node>::iterator it;
1065
12030
  std::vector<TNode> visit;
1066
12030
  TNode cur;
1067
6015
  visit.push_back(n);
1068
15853
  do
1069
  {
1070
21868
    cur = visit.back();
1071
21868
    visit.pop_back();
1072
21868
    it = visited.find(cur);
1073
1074
21868
    if (it == visited.end())
1075
    {
1076
16491
      if (cur.isVar())
1077
      {
1078
        // do the conversion
1079
8136
        visited[cur] = d_tds->getFreeVarInc(cur.getType(), vcounter);
1080
      }
1081
8355
      else if (!expr::hasBoundVar(cur))
1082
      {
1083
        // no bound variables, no change
1084
3028
        visited[cur] = cur;
1085
      }
1086
      else
1087
      {
1088
5327
        visited[cur] = Node::null();
1089
5327
        visit.push_back(cur);
1090
5327
        visit.insert(visit.end(), cur.begin(), cur.end());
1091
      }
1092
    }
1093
5377
    else if (it->second.isNull())
1094
    {
1095
10654
      Node ret = cur;
1096
5327
      bool childChanged = false;
1097
10654
      std::vector<Node> children;
1098
5327
      if (cur.getMetaKind() == metakind::PARAMETERIZED)
1099
      {
1100
5327
        children.push_back(cur.getOperator());
1101
      }
1102
15853
      for (const Node& cn : cur)
1103
      {
1104
10526
        it = visited.find(cn);
1105
10526
        Assert(it != visited.end());
1106
10526
        Assert(!it->second.isNull());
1107
10526
        childChanged = childChanged || cn != it->second;
1108
10526
        children.push_back(it->second);
1109
      }
1110
5327
      if (childChanged)
1111
      {
1112
3721
        ret = nm->mkNode(cur.getKind(), children);
1113
      }
1114
5327
      visited[cur] = ret;
1115
    }
1116
21868
  } while (!visit.empty());
1117
6015
  Assert(visited.find(n) != visited.end());
1118
6015
  Assert(!visited.find(n)->second.isNull());
1119
12030
  return visited[n];
1120
}
1121
1122
11
SygusEnumerator::TermEnumMasterInterp::TermEnumMasterInterp(TypeNode tn)
1123
11
    : TermEnum(), d_te(tn), d_currNumConsts(0), d_nextIndexEnd(0)
1124
{
1125
11
}
1126
1127
11
bool SygusEnumerator::TermEnumMasterInterp::initialize(SygusEnumerator* se,
1128
                                                       TypeNode tn)
1129
{
1130
11
  d_se = se;
1131
11
  d_tn = tn;
1132
11
  d_currSize = 0;
1133
11
  d_currNumConsts = 1;
1134
11
  d_nextIndexEnd = 1;
1135
11
  return true;
1136
}
1137
1138
101
Node SygusEnumerator::TermEnumMasterInterp::getCurrent() { return *d_te; }
1139
102
bool SygusEnumerator::TermEnumMasterInterp::increment()
1140
{
1141
102
  if (d_te.isFinished())
1142
  {
1143
1
    return false;
1144
  }
1145
101
  SygusEnumerator::TermCache& tc = d_se->d_tcache[d_tn];
1146
202
  Node curr = getCurrent();
1147
101
  tc.addTerm(curr);
1148
101
  if (tc.getNumTerms() == d_nextIndexEnd)
1149
  {
1150
16
    tc.pushEnumSizeIndex();
1151
16
    d_currSize++;
1152
16
    d_currNumConsts = d_currNumConsts * options::sygusActiveGenEnumConsts();
1153
16
    d_nextIndexEnd = d_nextIndexEnd + d_currNumConsts;
1154
  }
1155
101
  ++d_te;
1156
101
  return !d_te.isFinished();
1157
}
1158
5
SygusEnumerator::TermEnumMasterFv::TermEnumMasterFv() : TermEnum() {}
1159
5
bool SygusEnumerator::TermEnumMasterFv::initialize(SygusEnumerator* se,
1160
                                                   TypeNode tn)
1161
{
1162
5
  d_se = se;
1163
5
  d_tn = tn;
1164
5
  d_currSize = 0;
1165
10
  Node ret = getCurrent();
1166
5
  AlwaysAssert(!ret.isNull());
1167
5
  SygusEnumerator::TermCache& tc = d_se->d_tcache[d_tn];
1168
5
  tc.addTerm(ret);
1169
10
  return true;
1170
}
1171
1172
10
Node SygusEnumerator::TermEnumMasterFv::getCurrent()
1173
{
1174
10
  Assert(d_se->d_tds != nullptr);
1175
10
  Node ret = d_se->d_tds->getFreeVar(d_tn, d_currSize);
1176
20
  Trace("sygus-enum-debug2") << "master_fv(" << d_tn << "): mk " << ret
1177
10
                             << std::endl;
1178
10
  return ret;
1179
}
1180
1181
5
bool SygusEnumerator::TermEnumMasterFv::increment()
1182
{
1183
5
  SygusEnumerator::TermCache& tc = d_se->d_tcache[d_tn];
1184
  // size increments at a constant rate
1185
5
  d_currSize++;
1186
5
  tc.pushEnumSizeIndex();
1187
10
  Node curr = getCurrent();
1188
10
  Trace("sygus-enum-debug2") << "master_fv(" << d_tn << "): increment, add "
1189
5
                             << curr << std::endl;
1190
5
  bool ret = tc.addTerm(curr);
1191
5
  AlwaysAssert(ret);
1192
10
  return true;
1193
}
1194
1195
}  // namespace quantifiers
1196
}  // namespace theory
1197
22746
}  // namespace cvc5