-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Structured assertions #151
Structured assertions #151
Conversation
I think this would be most useful (and reduce most duplication) if I try to get rid of |
GT -> GTF | ||
EQ -> -- This is safe as long as the 'compareC' is doing a nontrivial | ||
-- comparison, i.e. actually using 'subterms' | ||
unsafeCoerce EQF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid this unsafeCoerce
? I don't understand the correctness argument you're making here in this comment, and it seems like it depends on the OrdC
instance in a nontrivial way that makes me uneasy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the issue is that we don't have the type-level evidence we need in this branch, but we can't say these things are unequal. This is a pretty fundamental issue because of the shift from PartExr p v ~= Maybe (p, v)
to a type more like (p, Maybe v)
. I wonder if we can get rid of the Maybe
altogether, there should be reasonable "zero" values for each type... I'll look into that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done away with the Maybe
here, see "What4.Partial". This actually led me to combine the ideas from a few different types expressing partiality, and I think leads to a better overall solution.
FYI, I did a merge with |
Instead, just import qualified if necessary
I think this is generally ready for review, with the caveat that it might be hard to get Crucible to exhibit these structured messages, because the way memory reads work is to calll a "fallback" function |
39dbc9e
to
64dfa14
Compare
There's a pretty big merge conflict with the refactoring related to registering intrinsics. Can you take a look @siddharthist? I can't tell if there are changes that need to be preserved. |
Yep! |
@robdockins This is current again. |
Motivation
Execution of syntax extensions produces values whose validity depends on the
truth of certain (symbolic) predicates (call such predicates "safety
assertions"). The values are often operated on further, compounding and
combining their paired safety assertions. When these safety assertions are
actually discharged, it would be nice to be able to explain to users why
symbolic simulation failed.
The current state of affairs
Assertions arise both at runtime, when instructions are being executed, and
as expressions at translation time. The way these are dealt with right now
is:
PartExpr
datatype (isomorphic toMaybe (Value, Predicate)
) with the predicate summing up all theassertions made
AddSideCondition
constructor of Crucible'sExpr
with a pair of(Predicate, Explanation)
The downsides of this approach are:
assertions are being made
be made
Design
There are a few observations that influce the design here:
operation. Java and LLVM have different things to assert.
and so should go in Crucible proper.
symbolic execution time.
These lead to the following design decisions:
AssertionClassifier
, keyed on the syntax extensionHasStructuredAssertions
classFor runtime assertions, the new idea is that partial values should be
(isomorphic to) a pair
(Value sym, AssertionTree sym)
whereAssertionTree sym
is a tree which has boolean connectives (and, or, ite)as non-leaf vertices and predicates together with classifiers and
explanations as leaves.
Since assertions can also come up at translation time, the type family is
parameterized over a type of expressions
e :: CrucibleType -> Type
that getsconverted from
Expr ext s f
at translation time toRegValue sym ty
atruntime. This allows for predicates to be constructed using Crucible syntax at
translation time. The safety assertions will participate in the translation
process so they can be asserted at runtime.
Possible next steps
HasStructuredAssertions
classasConstantPred
undef
or
poison
when the assertion fails