GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/passes/apply_substs.cpp Lines: 21 21 100.0 %
Date: 2021-09-16 Branches: 30 52 57.7 %

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
9942
ApplySubsts::ApplySubsts(PreprocessingPassContext* preprocContext)
32
9942
    : PreprocessingPass(preprocContext, "apply-substs")
33
{
34
9942
}
35
36
27602
PreprocessingPassResult ApplySubsts::applyInternal(
37
    AssertionPipeline* assertionsToPreprocess)
38
{
39
27602
  Chat() << "applying substitutions..." << std::endl;
40
55204
  Trace("apply-substs") << "SmtEnginePrivate::processAssertions(): "
41
27602
                        << "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
27602
      d_preprocContext->getTopLevelSubstitutions();
47
27602
  unsigned size = assertionsToPreprocess->size();
48
245709
  for (unsigned i = 0; i < size; ++i)
49
  {
50
218109
    if (assertionsToPreprocess->isSubstsIndex(i))
51
    {
52
7508
      continue;
53
    }
54
421202
    Trace("apply-substs") << "applying to " << (*assertionsToPreprocess)[i]
55
210601
                          << std::endl;
56
210601
    d_preprocContext->spendResource(Resource::PreprocessStep);
57
210599
    assertionsToPreprocess->replaceTrusted(
58
421200
        i, tlsm.applyTrusted((*assertionsToPreprocess)[i]));
59
421198
    Trace("apply-substs") << "  got " << (*assertionsToPreprocess)[i]
60
210599
                          << std::endl;
61
  }
62
27600
  return PreprocessingPassResult::NO_CONFLICT;
63
}
64
65
}  // namespace passes
66
}  // namespace preprocessing
67
29577
}  // namespace cvc5