GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/passes/apply_substs.cpp Lines: 21 21 100.0 %
Date: 2021-05-22 Branches: 30 54 55.6 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Aina Niemetz, Andrew Reynolds, 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
 * Apply substitutions preprocessing pass.
14
 *
15
 * Apply top level substitutions to assertions, rewrite, and store back into
16
 * assertions.
17
 */
18
19
#include "preprocessing/passes/apply_substs.h"
20
21
#include "context/cdo.h"
22
#include "preprocessing/assertion_pipeline.h"
23
#include "preprocessing/preprocessing_pass_context.h"
24
#include "theory/rewriter.h"
25
#include "theory/substitutions.h"
26
27
namespace cvc5 {
28
namespace preprocessing {
29
namespace passes {
30
31
9459
ApplySubsts::ApplySubsts(PreprocessingPassContext* preprocContext)
32
9459
    : PreprocessingPass(preprocContext, "apply-substs")
33
{
34
9459
}
35
36
25766
PreprocessingPassResult ApplySubsts::applyInternal(
37
    AssertionPipeline* assertionsToPreprocess)
38
{
39
25766
  Chat() << "applying substitutions..." << std::endl;
40
51532
  Trace("apply-substs") << "SmtEnginePrivate::processAssertions(): "
41
25766
                        << "applying substitutions" << std::endl;
42
  // TODO(#1255): Substitutions in incremental mode should be managed with a
43
  // proper data structure.
44
45
  theory::TrustSubstitutionMap& tlsm =
46
25766
      d_preprocContext->getTopLevelSubstitutions();
47
25766
  unsigned size = assertionsToPreprocess->size();
48
241350
  for (unsigned i = 0; i < size; ++i)
49
  {
50
215586
    if (assertionsToPreprocess->isSubstsIndex(i))
51
    {
52
6592
      continue;
53
    }
54
417988
    Trace("apply-substs") << "applying to " << (*assertionsToPreprocess)[i]
55
208994
                          << std::endl;
56
208994
    d_preprocContext->spendResource(Resource::PreprocessStep);
57
208992
    assertionsToPreprocess->replaceTrusted(
58
417986
        i, tlsm.applyTrusted((*assertionsToPreprocess)[i]));
59
417984
    Trace("apply-substs") << "  got " << (*assertionsToPreprocess)[i]
60
208992
                          << std::endl;
61
  }
62
25764
  return PreprocessingPassResult::NO_CONFLICT;
63
}
64
65
}  // namespace passes
66
}  // namespace preprocessing
67
28191
}  // namespace cvc5