[fud2] Implment Sat Solver Based Planner #2573
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This implements a planner rustsat as an interface for minisat.
To do so, the planner makes the observation that an op which returns multiple states can be broken into a bunch of ops which return one state. The nomenclature I use in the code is to call these dependencies. Precisely, if state
s1can be made usingop1, I say all of the inputs toop1form a dependency ofs1. Therefore over all the ops, each state gets a bunch of possible dependencies, different ways to make it, using different ops.Dependencies are straightforward to encode in boolean logic. Let each op and state be variables. If that variable is true, that state is taken or that op is used. Let$(s1 \land op1 \Rightarrow s2 \land s3) \land (s1 \land op2 \Rightarrow s1 \land s4)$ .
s1be the variable representing a state with possible dependenciess2, s3usingop1ands1, s4usingop2. This can be encoded as follows:Putting an op as a condition of the implication might feel counter-intuitive, but it is necessary. Using the encoding$(s1 \Rightarrow s2 \land s3 \land op1) \lor (s1 \Rightarrow s1 \land s4 \land op2)$ would allow a solution were ops are taken but never used, for example the following variables being true: $s1, op1, op2, s4$ .
To respond to a request with given input states, output states, and required ops. First, each output state is conjoined together and added to the expression. Then for each possible state a file could be in, if that state is not an input (or an output*) and cannot be constructed with any ops, the state's negation is conjoined to the boolean expression, representing that the state can never be constructed. If the state can be constructed, taking the state implies one of the ops is used. This is then conjoined to the boolean expression. To encode the required ops, they are simply conjoined to the final expression.
As an example, say the same ops as above are used. The desired output is
$(s1 \land op1 \Rightarrow s2 \land s3) \land (s1 \land op2 \Rightarrow s1 \land s4) \land op1 \land s1 \land \lnot s4 \land (s1 \Rightarrow op1 \land op2)$
s1and the input iss2, s3and the required op isop1. The final encoding would be:*Without this, the encoding breaks in the case an output is also an input but there is a path to get to that output using an op.