GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/passes/ackermann.h Lines: 1 1 100.0 %
Date: 2021-05-22 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Ying Sheng, Aina Niemetz, Yoni Zohar
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
 * Ackermannization preprocessing pass.
14
 *
15
 * This implements the Ackermannization preprocessing pass, which enables
16
 * very limited theory combination support for eager bit-blasting via
17
 * Ackermannization. It reduces constraints over the combination of the
18
 * theories of fixed-size bit-vectors and uninterpreted functions as
19
 * described in
20
 *   Liana Hadarean, An Efficient and Trustworthy Theory Solver for
21
 *   Bit-vectors in Satisfiability Modulo Theories.
22
 *   https://cs.nyu.edu/media/publications/hadarean_liana.pdf
23
 */
24
25
#include "cvc5_private.h"
26
27
#ifndef CVC5__PREPROCESSING__PASSES__ACKERMANN_H
28
#define CVC5__PREPROCESSING__PASSES__ACKERMANN_H
29
30
#include <unordered_map>
31
32
#include "expr/node.h"
33
#include "preprocessing/preprocessing_pass.h"
34
#include "theory/logic_info.h"
35
#include "theory/substitutions.h"
36
37
namespace cvc5 {
38
namespace preprocessing {
39
namespace passes {
40
41
using TNodeSet = std::unordered_set<TNode>;
42
using FunctionToArgsMap = std::unordered_map<TNode, TNodeSet>;
43
using USortToBVSizeMap = std::unordered_map<TypeNode, size_t>;
44
45
18918
class Ackermann : public PreprocessingPass
46
{
47
 public:
48
  Ackermann(PreprocessingPassContext* preprocContext);
49
50
 protected:
51
  /**
52
   * Apply Ackermannization as follows:
53
   *
54
   * - For each application f(X) where X = (x1, . . . , xn), introduce a fresh
55
   *   variable f_X and use it to replace all occurrences of f(X).
56
   *
57
   * - For each f(X) and f(Y) with X = (x1, . . . , xn) and Y = (y1, . . . , yn)
58
   *   occurring in the input formula, add the following lemma:
59
   *     (x_1 = y_1 /\ ... /\ x_n = y_n) => f_X = f_Y
60
   *
61
   * - For each uninterpreted sort S, suppose k is the number of variables with
62
   *   sort S, then for each such variable X, introduce a fresh variable BV_X
63
   *   with BV with size log_2(k)+1 and use it to replace all occurrences of X.
64
   */
65
  PreprocessingPassResult applyInternal(
66
      AssertionPipeline* assertionsToPreprocess) override;
67
68
 private:
69
  /* Map each function to a set of terms associated with it */
70
  FunctionToArgsMap d_funcToArgs;
71
  /* Map each function-application term to the new Skolem variable created by
72
   * ackermannization */
73
  theory::SubstitutionMap d_funcToSkolem;
74
  /* Map each variable with uninterpreted sort to the new Skolem BV variable
75
   * created by ackermannization */
76
  theory::SubstitutionMap d_usVarsToBVVars;
77
  /* Map each uninterpreted sort to the number of variables in this sort. */
78
  USortToBVSizeMap d_usortCardinality;
79
  LogicInfo d_logic;
80
};
81
82
}  // namespace passes
83
}  // namespace preprocessing
84
}  // namespace cvc5
85
86
#endif /* CVC5__PREPROCESSING__PASSES__ACKERMANN_H */