GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/passes/theory_preprocess.cpp Lines: 19 19 100.0 %
Date: 2021-05-22 Branches: 23 52 44.2 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Mathias Preiner, Andres Noetzli
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 TheoryPreprocess preprocessing pass.
14
 *
15
 * Calls Theory::preprocess(...) on every assertion of the formula.
16
 */
17
18
#include "preprocessing/passes/theory_preprocess.h"
19
20
#include "options/smt_options.h"
21
#include "preprocessing/assertion_pipeline.h"
22
#include "preprocessing/preprocessing_pass_context.h"
23
#include "prop/prop_engine.h"
24
#include "theory/rewriter.h"
25
#include "theory/theory_engine.h"
26
27
namespace cvc5 {
28
namespace preprocessing {
29
namespace passes {
30
31
using namespace cvc5::theory;
32
33
9459
TheoryPreprocess::TheoryPreprocess(PreprocessingPassContext* preprocContext)
34
9459
    : PreprocessingPass(preprocContext, "theory-preprocess"){};
35
36
12881
PreprocessingPassResult TheoryPreprocess::applyInternal(
37
    AssertionPipeline* assertions)
38
{
39
12881
  d_preprocContext->spendResource(Resource::PreprocessStep);
40
41
12881
  IteSkolemMap& imap = assertions->getIteSkolemMap();
42
12881
  prop::PropEngine* propEngine = d_preprocContext->getPropEngine();
43
  // Remove all of the ITE occurrences and normalize
44
117586
  for (unsigned i = 0, size = assertions->size(); i < size; ++i)
45
  {
46
209424
    Node assertion = (*assertions)[i];
47
209424
    std::vector<theory::TrustNode> newAsserts;
48
209424
    std::vector<Node> newSkolems;
49
209424
    TrustNode trn = propEngine->preprocess(assertion, newAsserts, newSkolems);
50
104705
    if (!trn.isNull())
51
    {
52
      // process
53
2864
      assertions->replaceTrusted(i, trn);
54
    }
55
104705
    Assert(newSkolems.size() == newAsserts.size());
56
123279
    for (unsigned j = 0, nnasserts = newAsserts.size(); j < nnasserts; j++)
57
    {
58
18574
      imap[assertions->size()] = newSkolems[j];
59
18574
      assertions->pushBackTrusted(newAsserts[j]);
60
    }
61
  }
62
63
12874
  return PreprocessingPassResult::NO_CONFLICT;
64
}
65
66
67
}  // namespace passes
68
}  // namespace preprocessing
69
28191
}  // namespace cvc5