Skip to content

Commit d7b3f48

Browse files
committed
Document state of smt2_incremental_decision_proceduret
Because the state has grown large enough that saying a bit more about the purpose of each piece of state will help with maintaining it.
1 parent 75b1e03 commit d7b3f48

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

src/solvers/smt2_incremental/smt2_incremental_decision_procedure.h

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,21 @@ class smt2_incremental_decision_proceduret final
7070
/// Sends the solver the definitions of the object sizes.
7171
void define_object_sizes();
7272

73+
/// Namespace for looking up the expressions which symbol_exprts relate to.
74+
/// This includes the symbols defined outside of the decision procedure but
75+
/// does not include any additional SMT function identifiers introduced by the
76+
/// decision procedure.
7377
const namespacet &ns;
74-
78+
/// The number of times `dec_solve()` has been called.
7579
size_t number_of_solver_calls;
76-
80+
/// \brief For handling the lifetime of and communication with the separate
81+
/// SMT solver process.
82+
/// \note This may be mocked for unit testing purposes.
7783
std::unique_ptr<smt_base_solver_processt> solver_process;
84+
/// For reporting errors, warnings and debugging information back to the user.
7885
messaget log;
79-
86+
/// Generators of sequences of uniquely identifying numbers used for naming
87+
/// SMT functions introduced by the decision procedure.
8088
class sequencet
8189
{
8290
size_t next_id = 0;
@@ -87,14 +95,38 @@ class smt2_incremental_decision_proceduret final
8795
return next_id++;
8896
}
8997
} handle_sequence, array_sequence;
90-
98+
/// When the `handle(exprt)` member function is called, the decision procedure
99+
/// commands the SMT solver to define a new function corresponding to the
100+
/// given expression. The mapping of the expressions to the function
101+
/// identifiers is stored in this map so that when there is as subsequent
102+
/// `get(exprt)` call for the same expression, the function identifier can be
103+
/// requested from the solver, rather than reconverting the expression.
91104
std::unordered_map<exprt, smt_identifier_termt, irep_hash>
92105
expression_handle_identifiers;
106+
/// As part of the decision procedure's overall translation of CBMCs `exprt`s
107+
/// into SMT terms, some subexpressions are substituted for separate SMT
108+
/// functions. This map associates these sub-expressions to the identifiers of
109+
/// the separated functions. This applies to `symbol_exprt` where it is fairly
110+
/// natural to define the value of the symbol using a separate function, but
111+
/// also to the expressions which define entire arrays. This includes
112+
/// `array_exprt` for example and will additionally include other similar
113+
/// array expressions when support for them is implemented.
93114
std::unordered_map<exprt, smt_identifier_termt, irep_hash>
94115
expression_identifiers;
116+
/// This map is used to track object related state. See documentation in
117+
/// object_tracking.h for details.
95118
smt_object_mapt object_map;
119+
/// The size of each object is separately defined as a pre-solving step.
120+
/// `object_size_defined[object ID]` is set to true for objects where the size
121+
/// has been defined. This is used to avoid defining the size of the same
122+
/// object multiple times in the case where multiple rounds of solving are
123+
/// carried out.
96124
std::vector<bool> object_size_defined;
125+
/// Implementation of the SMT formula for the object size function. This is
126+
/// stateful because it depends on the configuration of the number of object
127+
/// bits and how many bits wide the size type is configured to be.
97128
smt_object_sizet object_size_function;
129+
/// Precalculated type sizes used for pointer arithmetic.
98130
type_size_mapt pointer_sizes_map;
99131
};
100132

0 commit comments

Comments
 (0)