Encode trait bounds in AIR/SMT to enable broadcast_forall with trait bounds #747
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.
Up to now,
broadcast_forall
was only allowed for proof functions with no trait bounds. This pull request adds AIR/SMT encodings of trait bounds so that we generate axioms forbroadcast_forall
that can include trait bounds as preconditions. This is also relevant to #744 , since axioms about spec function ensures may need preconditions for trait bounds.Here is an example test:
In this, only
test1
succeeds, becausep
's trait boundA: T2<S<int>, u16>
is satisfied byA
=S<(bool, u8)>
but not byA
=S<(u32, u8)>
orA
=S<(bool, u32)>
. For Z3 to see that the trait bound is satisfied, we need to encode the trait bounds as AIR/SMT predicates. This encoding looks like the following, where each relevant traitimpl
becomes an axiom:With this, the axiom for
p
'sbroadcast_forall
can use the trait boundtr_bound%!T2.
as a precondition, so that it only applies toA
that satisfy the properT2
trait bound: