SmtChecker

Struct SmtChecker 

Source
pub struct SmtChecker<'tcx> {
    pub(crate) tcx: TyCtxt<'tcx>,
}
Expand description

SMT backend for verifier properties.

Fields§

§tcx: TyCtxt<'tcx>

Implementations§

Source§

impl<'tcx> SmtChecker<'tcx>

Source

pub fn new(tcx: TyCtxt<'tcx>) -> Self

Create an SMT checker for the current compiler type context.

Source

pub fn check( &self, checkpoint: &Checkpoint<'tcx>, property: &Property<'tcx>, forward: &ForwardVisitResult<'tcx>, ) -> SmtCheckResult

Try to prove one property using SMT.

Source

pub fn check_for_checkpoint( &self, caller: DefId, property: &Property<'tcx>, forward: &ForwardVisitResult<'tcx>, ) -> SmtCheckResult

Try to prove one property at a return checkpoint (struct invariant).

Unlike [check], this does not use callee-to-caller argument mapping because struct invariant properties are already resolved in the caller’s local namespace.

Source

pub(crate) fn prove_obligation( &self, checkpoint: &Checkpoint<'tcx>, forward: &ForwardVisitResult<'tcx>, obligation: SmtObligation, ) -> SmtCheckResult

Prove one already-lowered common SMT obligation.

Source

pub(crate) fn prove_obligation_for_checkpoint( &self, caller: DefId, forward: &ForwardVisitResult<'tcx>, obligation: SmtObligation, ) -> SmtCheckResult

Prove one lowered obligation at a return checkpoint (struct invariant).

Wraps prove_obligation with a minimal dummy checkpoint that only carries the caller DefId. No callee-to-caller argument mapping is needed.

Source

pub(crate) fn property_target( &self, checkpoint: &Checkpoint<'tcx>, property: &Property<'tcx>, ) -> Option<PlaceKey>

Resolve the target place of a property at a concrete checkpoint.

Source

pub(crate) fn property_place_arg( &self, checkpoint: &Checkpoint<'tcx>, property: &Property<'tcx>, index: usize, ) -> Option<PlaceKey>

Resolve the index-th property argument as a concrete checkpoint place.

Source

pub(crate) fn property_target_direct( &self, property: &Property<'tcx>, ) -> Option<PlaceKey>

Resolve the target place of a property directly from a contract place without going through callee argument mapping.

Source

fn resolve_contract_place(&self, place: &ContractPlace<'tcx>) -> PlaceKey

Convert a contract place to a PlaceKey, resolving Arg(n) to Local(n+1).

Source

pub(crate) fn property_required_ty( &self, checkpoint: &Checkpoint<'tcx>, property: &Property<'tcx>, ) -> Option<Ty<'tcx>>

Resolve the type argument used by an alignment property.

Source

pub(crate) fn property_required_ty_direct( &self, property: &Property<'tcx>, ) -> Option<Ty<'tcx>>

Resolve the type argument of a property directly without callee generic instantiation.

Source

pub(crate) fn property_len_expr_direct( &self, property: &Property<'tcx>, ) -> Option<ContractExpr<'tcx>>

Resolve the trailing length expression directly (without checkpoint binding).

For checkpoint checks this extracts the last argument as an expression using the function’s own parameter space.

Source

pub(crate) fn property_len_expr( &self, checkpoint: &Checkpoint<'tcx>, property: &Property<'tcx>, ) -> Option<ContractExpr<'tcx>>

Resolve the trailing length expression at a concrete checkpoint.

This keeps constants unchanged and rewrites callee argument places, such as Arg_2 from std-contract JSON, to the concrete MIR place passed by the caller at this checkpoint. Composite numeric expressions are rebound recursively.

Source

pub(crate) fn contract_expr_to_smt_term( &self, caller: DefId, expr: &ContractExpr<'tcx>, ) -> Option<SmtTerm>

Lower a rebound contract arithmetic expression into the common SMT term model.

Source

pub(crate) fn property_numeric_predicates( &self, checkpoint: &Checkpoint<'tcx>, property: &Property<'tcx>, ) -> Option<Vec<NumericPredicate<'tcx>>>

Resolve a ValidNum predicate list at a concrete checkpoint.

Source

pub(crate) fn numeric_predicate_to_smt_predicate( &self, caller: DefId, predicate: &NumericPredicate<'tcx>, ) -> Option<SmtPredicate>

Convert a rebound contract predicate into the shared SMT predicate model.

Source

pub(crate) fn property_numeric_smt_predicates( &self, checkpoint: &Checkpoint<'tcx>, property: &Property<'tcx>, ) -> Option<Vec<SmtPredicate>>

Resolve and lower ValidNum predicates, expanding non-scalar helpers.

Source

pub(crate) fn property_index_access_in_bound_predicates( &self, checkpoint: &Checkpoint<'tcx>, property: &Property<'tcx>, ) -> Option<Vec<SmtPredicate>>

Resolve an InBound(index_access(slice, index)) property to range predicates.

Source

fn expand_index_access_predicate( &self, checkpoint: &Checkpoint<'tcx>, predicate: &NumericPredicate<'tcx>, ) -> Option<Option<Vec<SmtPredicate>>>

Source

fn index_access_in_bound_predicates( &self, checkpoint: &Checkpoint<'tcx>, expr: &ContractExpr<'tcx>, ) -> Option<Vec<SmtPredicate>>

Source

fn slice_index_bounds( &self, caller: DefId, index: &ContractExpr<'tcx>, len: SmtTerm, ) -> Option<(SmtTerm, SmtTerm)>

Source

fn slice_index_kind( &self, caller: DefId, index: &ContractExpr<'tcx>, ) -> Option<SliceIndexKind>

Source

fn contract_expr_field_term( &self, caller: DefId, expr: &ContractExpr<'tcx>, field: usize, ) -> Option<SmtTerm>

Source

fn contract_expr_place(&self, expr: &ContractExpr<'tcx>) -> Option<PlaceKey>

Source

fn contract_expr_label(&self, expr: &ContractExpr<'tcx>) -> Option<String>

Source

fn place_ty_for_caller( &self, caller: DefId, place: &PlaceKey, ) -> Option<Ty<'tcx>>

Source

pub(crate) fn infer_pointee_ty( &self, caller: DefId, place: &PlaceKey, ) -> Option<Ty<'tcx>>

Source

pub(crate) fn is_len_carrying_place_for_caller( &self, caller: DefId, place: &PlaceKey, ) -> bool

Return true if a place is a safe reference/slice/string carrying object length.

Source

fn bind_contract_expr_to_callsite( &self, checkpoint: &Checkpoint<'tcx>, expr: &ContractExpr<'tcx>, ) -> Option<ContractExpr<'tcx>>

Source

fn contract_place_to_callsite_expr( &self, checkpoint: &Checkpoint<'tcx>, place: &ContractPlace<'tcx>, ) -> Option<ContractExpr<'tcx>>

Source

fn callsite_arg_expr( &self, checkpoint: &Checkpoint<'tcx>, index: usize, fields: &[usize], ) -> Option<ContractExpr<'tcx>>

Source

pub(crate) fn contract_place_to_callsite_place( &self, checkpoint: &Checkpoint<'tcx>, place: &ContractPlace<'tcx>, ) -> Option<PlaceKey>

Convert a contract place into a concrete MIR place when possible.

Source

pub(crate) fn callsite_arg_place( &self, checkpoint: &Checkpoint<'tcx>, index: usize, ) -> Option<PlaceKey>

Return the concrete MIR place used as the index-th call argument.

Source

pub(crate) fn callsite_arg_smt_term( &self, checkpoint: &Checkpoint<'tcx>, index: usize, ) -> Option<SmtTerm>

Return the index-th call argument as a common SMT term.

Source

pub(crate) fn place_pointee_size( &self, caller: DefId, place: &PlaceKey, ) -> Option<u64>

Return the pointee size for a concrete pointer place.

Source

pub(crate) fn callsite_arg_place_with_fields( &self, checkpoint: &Checkpoint<'tcx>, index: usize, fields: &[usize], ) -> Option<PlaceKey>

Return the index-th call argument with contract projections appended.

Source

pub(crate) fn instantiate_callsite_ty( &self, checkpoint: &Checkpoint<'tcx>, ty: Ty<'tcx>, ) -> Ty<'tcx>

Replace a callee generic parameter with its concrete checkpoint type.

Source

pub(crate) fn instantiate_callsite_const( &self, checkpoint: &Checkpoint<'tcx>, index: u32, ) -> Option<u128>

Replace a callee const generic parameter with its concrete checkpoint value.

Source

pub(crate) fn type_layout( &self, caller: DefId, ty: Ty<'tcx>, ) -> Option<(u64, u64)>

Return ABI alignment and size for a type.

Source

pub(crate) fn required_alignment( &self, caller: DefId, ty: Ty<'tcx>, ) -> Option<u64>

Return the alignment required by a property type.

For concrete types this is the ABI alignment. For generic parameters with finite representative candidates, the requirement must hold for every candidate, so we use the maximum candidate alignment.

Source

pub(crate) fn required_size(&self, caller: DefId, ty: Ty<'tcx>) -> Option<u64>

Return a conservative byte size for a concrete or bounded generic type.

For a generic parameter with representative candidates, every candidate must satisfy a numeric precondition. We therefore use the maximum candidate size for upper-bound formulas such as size_of(T) * len <= isize::MAX.

Source

pub(crate) fn type_size_class( &self, caller: DefId, ty: Ty<'tcx>, ) -> TypeSizeClass

Classify whether a type is definitely zero-sized, definitely non-zero, or still layout-ambiguous under the current generic bounds.

Source

fn generic_candidate_alignments( &self, caller: DefId, ty: Ty<'tcx>, ) -> Option<Vec<u64>>

Source

fn generic_candidate_sizes( &self, caller: DefId, ty: Ty<'tcx>, ) -> Option<Vec<u64>>

Auto Trait Implementations§

§

impl<'tcx> Freeze for SmtChecker<'tcx>

§

impl<'tcx> !RefUnwindSafe for SmtChecker<'tcx>

§

impl<'tcx> !Send for SmtChecker<'tcx>

§

impl<'tcx> !Sync for SmtChecker<'tcx>

§

impl<'tcx> Unpin for SmtChecker<'tcx>

§

impl<'tcx> !UnwindSafe for SmtChecker<'tcx>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,