GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/passes/ite_removal.cpp Lines: 22 22 100.0 %
Date: 2021-05-22 Branches: 26 58 44.8 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Andres Noetzli, Mathias Preiner
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
 * Remove ITEs from the assertions.
14
 *
15
 * [[ Add lengthier description here ]]
16
 * \todo document this file
17
 */
18
19
#include "preprocessing/passes/ite_removal.h"
20
21
#include "options/smt_options.h"
22
#include "preprocessing/assertion_pipeline.h"
23
#include "preprocessing/preprocessing_pass_context.h"
24
#include "prop/prop_engine.h"
25
#include "theory/rewriter.h"
26
#include "theory/theory_preprocessor.h"
27
28
namespace cvc5 {
29
namespace preprocessing {
30
namespace passes {
31
32
using namespace cvc5::theory;
33
34
// TODO (project #42): note this preprocessing pass is deprecated
35
9459
IteRemoval::IteRemoval(PreprocessingPassContext* preprocContext)
36
9459
    : PreprocessingPass(preprocContext, "ite-removal")
37
{
38
9459
}
39
40
2
PreprocessingPassResult IteRemoval::applyInternal(AssertionPipeline* assertions)
41
{
42
2
  d_preprocContext->spendResource(Resource::PreprocessStep);
43
44
2
  IteSkolemMap& imap = assertions->getIteSkolemMap();
45
  // Remove all of the ITE occurrences and normalize
46
2
  prop::PropEngine* pe = d_preprocContext->getPropEngine();
47
6
  for (unsigned i = 0, size = assertions->size(); i < size; ++i)
48
  {
49
8
    Node assertion = (*assertions)[i];
50
8
    std::vector<theory::TrustNode> newAsserts;
51
8
    std::vector<Node> newSkolems;
52
8
    TrustNode trn = pe->removeItes(assertion, newAsserts, newSkolems);
53
4
    if (!trn.isNull())
54
    {
55
      // process
56
2
      assertions->replaceTrusted(i, trn);
57
    }
58
4
    Assert(newSkolems.size() == newAsserts.size());
59
652
    for (unsigned j = 0, nnasserts = newAsserts.size(); j < nnasserts; j++)
60
    {
61
648
      imap[assertions->size()] = newSkolems[j];
62
648
      assertions->pushBackTrusted(newAsserts[j]);
63
    }
64
  }
65
654
  for (unsigned i = 0, size = assertions->size(); i < size; ++i)
66
  {
67
652
    assertions->replace(i, Rewriter::rewrite((*assertions)[i]));
68
  }
69
70
2
  return PreprocessingPassResult::NO_CONFLICT;
71
}
72
73
74
}  // namespace passes
75
}  // namespace preprocessing
76
28191
}  // namespace cvc5