GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/passes/static_learning.cpp Lines: 15 15 100.0 %
Date: 2021-05-22 Branches: 20 38 52.6 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Yoni Zohar, Gereon Kremer, 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
 * The static learning preprocessing pass.
14
 */
15
16
#include "preprocessing/passes/static_learning.h"
17
18
#include <string>
19
20
#include "expr/node.h"
21
#include "preprocessing/assertion_pipeline.h"
22
#include "preprocessing/preprocessing_pass_context.h"
23
#include "theory/rewriter.h"
24
#include "theory/theory_engine.h"
25
26
namespace cvc5 {
27
namespace preprocessing {
28
namespace passes {
29
30
9459
StaticLearning::StaticLearning(PreprocessingPassContext* preprocContext)
31
9459
    : PreprocessingPass(preprocContext, "static-learning"){};
32
33
12881
PreprocessingPassResult StaticLearning::applyInternal(
34
    AssertionPipeline* assertionsToPreprocess)
35
{
36
12881
  d_preprocContext->spendResource(Resource::PreprocessStep);
37
38
116953
  for (unsigned i = 0; i < assertionsToPreprocess->size(); ++i)
39
  {
40
208144
    NodeBuilder learned(kind::AND);
41
104072
    learned << (*assertionsToPreprocess)[i];
42
208144
    d_preprocContext->getTheoryEngine()->ppStaticLearn(
43
104072
        (*assertionsToPreprocess)[i], learned);
44
104072
    if (learned.getNumChildren() == 1)
45
    {
46
103687
      learned.clear();
47
    }
48
    else
49
    {
50
385
      assertionsToPreprocess->replace(
51
770
          i, theory::Rewriter::rewrite(learned.constructNode()));
52
    }
53
  }
54
12881
  return PreprocessingPassResult::NO_CONFLICT;
55
}
56
57
58
}  // namespace passes
59
}  // namespace preprocessing
60
28191
}  // namespace cvc5