GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/passes/static_learning.cpp Lines: 14 14 100.0 %
Date: 2021-09-29 Branches: 20 36 55.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
6271
StaticLearning::StaticLearning(PreprocessingPassContext* preprocContext)
31
6271
    : PreprocessingPass(preprocContext, "static-learning"){};
32
33
8539
PreprocessingPassResult StaticLearning::applyInternal(
34
    AssertionPipeline* assertionsToPreprocess)
35
{
36
8539
  d_preprocContext->spendResource(Resource::PreprocessStep);
37
38
72058
  for (unsigned i = 0; i < assertionsToPreprocess->size(); ++i)
39
  {
40
127038
    NodeBuilder learned(kind::AND);
41
63519
    learned << (*assertionsToPreprocess)[i];
42
127038
    d_preprocContext->getTheoryEngine()->ppStaticLearn(
43
63519
        (*assertionsToPreprocess)[i], learned);
44
63519
    if (learned.getNumChildren() == 1)
45
    {
46
63331
      learned.clear();
47
    }
48
    else
49
    {
50
188
      assertionsToPreprocess->replace(i, rewrite(learned.constructNode()));
51
    }
52
  }
53
8539
  return PreprocessingPassResult::NO_CONFLICT;
54
}
55
56
57
}  // namespace passes
58
}  // namespace preprocessing
59
22746
}  // namespace cvc5