stack_decision_proceduret for solving under assumptions/contexts#4581
Conversation
8a19559 to
9ae2e3e
Compare
| \*******************************************************************/ | ||
|
|
||
| /// \file | ||
| /// Decision procedure with incremental solving with contexts |
There was a problem hiding this comment.
Perhaps give an example of intended usage?
There was a problem hiding this comment.
I've added two examples
| } | ||
|
|
||
| void prop_conv_solvert::set_to(const exprt &expr, bool value) | ||
| void prop_conv_solvert::do_set_to(const exprt &expr, bool value) |
There was a problem hiding this comment.
Give this a better name, or provide some documentation to advise a future editor on whether they want set_to or do_set_to
There was a problem hiding this comment.
documentation extended
src/solvers/prop/prop_conv_solver.h
Outdated
| virtual void ignoring(const exprt &expr); | ||
|
|
||
| // deliberately protected now to protect lower-level API | ||
| /// Actually adds the constraints to `prop` |
There was a problem hiding this comment.
Explicitly mention that set_to is a wrapper around this, and which one ought to be used
There was a problem hiding this comment.
do_set_to is not a great name, why not naming it add_constraint_to_prop?
| { | ||
| // We remove the context from the stack. | ||
| for(size_t i = 0; i < context_size_stack.back(); ++i) | ||
| assumption_stack.pop_back(); |
There was a problem hiding this comment.
assumption_stack.resize(assumption_stack.size() - context_size_stack.back())?
There was a problem hiding this comment.
Yes, should work. Shrinking resize doesn't reallocate.
|
|
||
| /// Push a new context on the stack | ||
| /// This context becomes a child context nested in the current context. | ||
| virtual void push() = 0; |
There was a problem hiding this comment.
Is this equivalent to a push of an empty vector?
There was a problem hiding this comment.
No - clarified in docs
| virtual void push() = 0; | ||
|
|
||
| /// Pop whatever has been pushed in the last call to `push` | ||
| virtual void pop() = 0; |
There was a problem hiding this comment.
I don't think the documentation is accurate: two calls to pop wouldn't remove the same element? I think the documentation should refer to the top of the stack. And what's the behaviour when stack underflow would occur? Is an implementation expected to handle this gracefully (by ignoring it), or should it fail hard?
|
|
||
| messaget log; | ||
|
|
||
| static const char *context_prefix; |
There was a problem hiding this comment.
Can we just initialise it right here rather than in the implementation file?
There was a problem hiding this comment.
What would be the advantage of that?
There was a problem hiding this comment.
Fewer lines of code and easier to locate. But clearly a nit-pick and all up to you.
src/solvers/prop/prop_minimize.cpp
Outdated
| prop_conv.set_assumptions(assumptions); | ||
| exprt::operandst assumptions; | ||
| assumptions.push_back(literal_exprt(c)); | ||
| prop_conv.push(assumptions); |
There was a problem hiding this comment.
How about simplifying all this to prop_conv.push({literal_exprt{c}});?
src/solvers/prop/prop_conv_solver.h
Outdated
| virtual void ignoring(const exprt &expr); | ||
|
|
||
| // deliberately protected now to protect lower-level API | ||
| /// Actually adds the constraints to `prop` |
There was a problem hiding this comment.
do_set_to is not a great name, why not naming it add_constraint_to_prop?
Provides combined push/pop + assumptions interface
and carry over the current, partial support in smt2_convt.
9ae2e3e to
bc3837e
Compare
Replaces #4451 and #4054