-
Notifications
You must be signed in to change notification settings - Fork 5
Encode domains and axioms for traits #52
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
base: rewrite-2023
Are you sure you want to change the base?
Encode domains and axioms for traits #52
Conversation
|
relevant diff: |
| traits::ImplSource::UserDefined(ud) => { | ||
| self.deps.require_dep::<UserDefinedTraitImplEnc>(ud.impl_def_id).unwrap(); | ||
| } | ||
| traits::ImplSource::Param(_) => {} |
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'm a little surprised to see that there's nothing generated for trait bounds on parameters? Don't we need to generate some opaque value so that we can instantiate trait axioms?
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'm afraid I don't quite understand this comment. I think what the ImplSource::Param case corresponds to is e.g. the call to g(x) in :
fn f<T: Clone + Eq>(x: T) {
g(x)
}
fn g<T: Clone>(t: T) {
}where the call is allowed because the type of x must implement Clone in f. So we don't need to add any additional Viper axioms because the precondition implements_Clone(typeof(x)) in the encoding of f will satisfy the corresponding precondition in g.
BTW in case it's not clear this would be different for a call of e.g. g(1) somewhere in the code; we would want to ensure the axiom asserting implements_Clone(s_u32_type()) is generated.
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.
ah yea, i didn't catch that this was for the bounds of a called function, where indeed we don't want to generate axioms.
Encodes domains for traits, uninterpreted functions (i.e. to check if a type implements a trait), and axioms based on trait impls; #51 should be merged first.