Types
Inside annotations, the syntax of types is extended as follows:
Syntax
Type :
... |*_|any| PureFunctionType | PredicateType |realPureFunctionType :
fix(( ParamType,)* ParamType?)ParamType :
(IDENTIFIER:)? TypePredicateType :
pred(((( ParamType,) ParamType )?;)? ( ParamType,) ParamType?)
In addition to (some subset of) Rust's types, VeriFast supports the following types:
- Type
*_(pointer-to-anything) is a pointer type implicitly convertible to any other pointer type. It is analogous to C'svoid *. - Type
anyis the union of all inductive types that themselves containanyonly in positive positions. - The pure function type
fix(T1, ..., Tn, U)is the type of mathematical functions taking N arguments, of types T1 through Tn, and returning a value of type U. - The predicate type
pred(T1, ..., Tn)is the type of separation logic predicates taking N arguments, of types T1 through Tn. The typepred(T1, ..., Tn; U1, ..., Um)is the type of precise separation logic predicates taking N input arguments and M output arguments. - Type
realis the type of real numbers. (It is mostly used for chunk coefficients and for reasoning about floating-point numbers.)
In pure function types and predicate types, parameter names may optionally be written for documentation purposes; they are ignored by VeriFast.
Note, furthermore:
- VeriFast does not distinguish between
*const Tand*mut Tand supports the syntax*T. That is, VeriFast treats the type expressions*const T,*mut T, and*Tidentically. - When used as the type of a ghost variable (e.g. a pure function parameter or return value, a predicate parameter, a lemma parameter, or a ghost cell) or as the type of an expression in an annotation, all integer types are interpreted as the mathematical type ℤ of all integers. Also, inside annotations arithmetic operations on integers are always interpreted as operations on ℤ and never wrap around.