Add mir_mux_values
command for muxing two MIR values
#2000
Labels
subsystem: crucible-mir
Issues related to Rust verification with crucible-mir and/or mir-json
type: enhancement
Issues describing an improvement to an existing feature or capability
Motivation: Currently, it is not possible to embed MIR struct or enum values into Cryptol. This makes it awkward or impossible to write certain SAW specifications. For instance, consider this Rust function:
How would you write a SAW spec for
increment
that works for all possible values ofcount
? Sadly, you can't. There is no way to constructmir_return mv
statement such thatmv
properly takes thecount < MAX
condition into account. The only way to do make this work would be to write two separate specs forincrement
: one wherecount < MAX
and the spec always returnsOk
, and another wherecount == MAX
and the spec always returnsErr
. Not terribly satisfying.We do want to support embedding structs (#1976) and enums (GaloisInc/cryptol#1588) into Cryptol someday. This will require a fair bit of work to achieve, however. In the mean time, it would be helpful to have some kind of solution to the problem above, even if it isn't as generic as Cryptol would be.
Solution: I propose adding the following command to SAW:
This command can be thought of as a particular form of
if
expression. If the condition (represented by theTerm
) holds, then return the firstMIRValue
argument. Otherwise, return the secondMIRValue
argument. The reason that the word "mux
" is in the command's name is because theTerm
might conceivably be symbolic, in which case it would be necessary to perform a symbolic branch (i.e., a mux) of the twoMIRValue
arguments.Using
mir_mux_value
, one could write a comprehensive spec forincrement
above like so:This should be relatively straightforward to implement under the hood, as a use of
mir_mux_value
would translate to something akin to Crucible'smuxRegForType
function.The text was updated successfully, but these errors were encountered: