|
| 1 | +/*******************************************************************\ |
| 2 | +
|
| 3 | +Module: Loop Invariant Synthesizer Interface |
| 4 | +
|
| 5 | +Author: Qinheping Hu |
| 6 | +
|
| 7 | +\*******************************************************************/ |
| 8 | + |
| 9 | +/// \file |
| 10 | +/// Loop Invariant Synthesizer Interface |
| 11 | + |
| 12 | +#ifndef CPROVER_GOTO_INSTRUMENT_SYNTHESIZER_LOOP_INVARIANT_SYNTHESIZER_BASE_H |
| 13 | +#define CPROVER_GOTO_INSTRUMENT_SYNTHESIZER_LOOP_INVARIANT_SYNTHESIZER_BASE_H |
| 14 | + |
| 15 | +#include <goto-programs/goto_model.h> |
| 16 | + |
| 17 | +#include "synthesizer_utils.h" |
| 18 | + |
| 19 | +#define OPT_SYNTHESIZE_LOOP_INVARIANTS "(synthesize-loop-invariants)" |
| 20 | +#define HELP_LOOP_INVARIANT_SYNTHESIZER \ |
| 21 | + " --synthesize-loop-invariants\n" \ |
| 22 | + " synthesize and apply loop invariants\n" |
| 23 | + |
| 24 | +class messaget; |
| 25 | + |
| 26 | +/// A base class for loop invariant synthesizers. |
| 27 | +/// Provides a method for synthesizing loop invariants in a given `goto_model`. |
| 28 | +/// |
| 29 | +/// Derived class should clarify what types of `goto_model` they targets, e.g., |
| 30 | +/// a `goto_model` contains only memory safety checks, or a `goto_model` |
| 31 | +/// contains both memory safety checks and correctness checks. |
| 32 | +class loop_invariant_synthesizer_baset |
| 33 | +{ |
| 34 | +public: |
| 35 | + loop_invariant_synthesizer_baset(const goto_modelt &goto_model, messaget &log) |
| 36 | + : goto_model(goto_model), log(log) |
| 37 | + { |
| 38 | + } |
| 39 | + virtual ~loop_invariant_synthesizer_baset() = default; |
| 40 | + |
| 41 | + /// Synthesize loop invariants with which all checks in `goto_model` |
| 42 | + /// succeed. The result is a map from `loop_idt` ids of loops to `exprt` |
| 43 | + /// the goto-expression representation of synthesized invariants. |
| 44 | + virtual invariant_mapt synthesize_all() = 0; |
| 45 | + |
| 46 | + /// Synthesize loop invariant for a specified loop in the `goto_model` |
| 47 | + virtual exprt synthesize(loop_idt) = 0; |
| 48 | + |
| 49 | +protected: |
| 50 | + const goto_modelt &goto_model; |
| 51 | + messaget &log; |
| 52 | +}; |
| 53 | + |
| 54 | +#endif // CPROVER_GOTO_INSTRUMENT_SYNTHESIZER_LOOP_INVARIANT_SYNTHESIZER_BASE_H |
0 commit comments