equality.rs

verification/proofs/page-pool/creusot/equality.rs

equality.rs86 lines← SDK documentation
1//! Imported source equality contracts, qualified by the native Kani producer.2//! These four comparison leaves are an explicit cross-verifier boundary.3use super::*;45#[trusted]6#[check(terminates)]7#[erasure(<Owner as core::cmp::PartialEq>::eq)]8#[ensures(result == same_variant(*left, *right))]9pub(super) fn owner_eq(left: &Owner, right: &Owner) -> bool {10    <Owner as core::cmp::PartialEq>::eq(left, right)11}1213#[trusted]14#[check(terminates)]15#[erasure(<Owner as core::cmp::PartialEq>::ne)]16#[ensures(result == !same_variant(*left, *right))]17pub(super) fn owner_ne(left: &Owner, right: &Owner) -> bool {18    <Owner as core::cmp::PartialEq>::ne(left, right)19}2021#[trusted]22#[check(terminates)]23#[erasure(<Run as core::cmp::PartialEq>::eq)]24#[ensures(result == same_fields(*left, *right))]25pub(super) fn run_eq(left: &Run, right: &Run) -> bool {26    <Run as core::cmp::PartialEq>::eq(left, right)27}2829#[trusted]30#[check(terminates)]31#[erasure(<Run as core::cmp::PartialEq>::ne)]32#[ensures(result == !same_fields(*left, *right))]33pub(super) fn run_ne(left: &Run, right: &Run) -> bool {34    <Run as core::cmp::PartialEq>::ne(left, right)35}3637#[logic(open(super))]38pub(super) fn same_variant(left: Owner, right: Owner) -> bool {39    match (left, right) {40        (Owner::Runtime, Owner::Runtime)41        | (Owner::Store, Owner::Store)42        | (Owner::Control, Owner::Control) => true,43        _ => false,44    }45}4647#[logic(open(super))]48pub(super) fn same_fields(left: Run, right: Run) -> bool {49    left.start == right.start && left.count == right.count50}5152#[check(ghost)]53#[ensures((left.deep_model() == right.deep_model()) == same_variant(left, right))]54fn owner_model_matches_oracle(left: Owner, right: Owner) {}5556#[check(ghost)]57#[ensures((left.deep_model() == right.deep_model()) == same_fields(left, right))]58fn run_model_matches_oracle(left: Run, right: Run) {}5960#[ensures(result == (left.deep_model() == right.deep_model()))]61#[erasure(super::super::equality_targets::owner_eq)]62pub(super) fn owner_eq_client(left: &Owner, right: &Owner) -> bool {63    ghost!(owner_model_matches_oracle(*left, *right));64    owner_eq(left, right)65}6667#[ensures(result == (left.deep_model() != right.deep_model()))]68#[erasure(super::super::equality_targets::owner_ne)]69pub(super) fn owner_ne_client(left: &Owner, right: &Owner) -> bool {70    ghost!(owner_model_matches_oracle(*left, *right));71    owner_ne(left, right)72}7374#[ensures(result == (left.deep_model() == right.deep_model()))]75#[erasure(super::super::equality_targets::run_eq)]76pub(super) fn run_eq_client(left: &Run, right: &Run) -> bool {77    ghost!(run_model_matches_oracle(*left, *right));78    run_eq(left, right)79}8081#[ensures(result == (left.deep_model() != right.deep_model()))]82#[erasure(super::super::equality_targets::run_ne)]83pub(super) fn run_ne_client(left: &Run, right: &Run) -> bool {84    ghost!(run_model_matches_oracle(*left, *right));85    run_ne(left, right)86}