-
Notifications
You must be signed in to change notification settings - Fork 1
Support user-defined predicate call in annotation #22
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: main
Are you sure you want to change the base?
Conversation
Support logical connectives in annotations
Define rty::Formula and replace UnboundAssumption and Refinement with it
Introduce PlaceTypeBuilder to simplify PlaceType construction
Add documentation to annot, chc, and pretty modules
Add documentation to rty and some other modules
Add GitHub Actions workflow to host docs in GitHub pages
Handle parens in annotations properly
Ignore lifetime parameters properly when numbering type params
More annotation syntax
…nto annot-preds-call
a user-defined predicate call
8b90c59 to
4cd0a34
Compare
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
| pub struct UserDefinedPred { |
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.
This struct seems to be unused. I think it's more natural to rename UserDefinedPredSymbol to UserDefinedPred and remove this one.
| } | ||
| } | ||
|
|
||
| // TODO: This struct is almost copy of `DatatypeSymbol`. Two traits maight be unified with aliases. |
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.
It's actually better to have different structs for different purposes; that makes them more resilient to change, since each might be updated for different reasons and in different ways in the future.
| Pred::Known(p) => p.name().into(), | ||
| Pred::Var(p) => p.to_string().into(), | ||
| Pred::Matcher(p) => p.name().into(), | ||
| Pred::UserDefined(p) => p.inner.clone().into(), |
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.
(nit) using p.to_string().into() would be better because we don't have to access the implementation details (like .inner).
| cursor: args.trees(), | ||
| formula_existentials: self.formula_existentials.clone(), | ||
| }; | ||
| let args = parser.parse_datatype_ctor_args()?; |
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.
Could you rename parse_datatype_ctor_args to parse_arg_terms or something similar, because it's no longer used solely for datatype constructor arguments?
This extention allows users to call arbitrary user-defined predicates (e.g., is_double(x, result)) within annotations.
Currently, a dedicated syntax for defining user-defined predicates is not yet supported. Therefore, users must define them using the #![thrust::raw_define()] (introduced in #21 ) attribute for now.
The predicate
is_double()defined using#![thrust::raw_define()]can be called in the annotations such as#[thrust::ensures()]: