Skip to content
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

Resources, Obligations, Time Reasoning #1408

Open
wants to merge 90 commits into
base: master
Choose a base branch
from

Conversation

vfukala
Copy link

@vfukala vfukala commented Jun 5, 2023

NOTE: Caching has been disabled in this PR (see prusti-server/src/process_verification.rs) because it led to errors in the Github CI. Consider re-enabling it before merging.

Adding time reasoning (see #1275), resources, and obligations to Prusti. Obligations can be defined by the user with arbitrary arguments. For each obligation, Prusti checks that no instances of it are leaked. This means that all obligation instances held at the end of a function must be asserted (exhaled) in the postcondition.

For example, the following program verifies.

use prusti_contracts::*;

obligation! {
    fn alloced(amount: usize, loc: usize);
}

#[trusted]
#[ensures(alloced(1, loc))]
fn alloc(loc: usize) {
    // do allocation here
}

#[trusted]
#[requires(alloced(1, loc))]
fn dealloc(loc: usize) {
    // do deallocation here
}

#[ensures(alloced(1, base + offset))]
fn alloc_offset(base: usize, offset: usize) {
    alloc(base + offset);
}

#[ensures(alloced(1, 67))]
fn main() {
    alloc_offset(32, 1);
    alloc_offset(64, 3);
    dealloc(33);
}

It wouldn't verify if the postcondition of main were left out, for example.

TO DO (in future):

  • Check for misplaced impure expressions (resources in negations, disjunctions, etc.) while encoding MIR into VIR and not separately after the optimizations have been done. (Contrary to how it was before, it should now be possible to do these checks on the directly generated VIR without relying on optimizations to remove some internally introduced constructs.)

out of scope:

  • In some cases, quantified obligations don't verify even though they should due to an incompleteness in Silicon (like here, also see Silicon incompleteness).

@vfukala vfukala changed the title Obligations [WIP] Obligations Jun 5, 2023
@Aurel300 Aurel300 mentioned this pull request Jun 26, 2023
@vfukala vfukala marked this pull request as ready for review July 18, 2023 14:46
@vfukala vfukala changed the title [WIP] Obligations Resources, Obligations, Time Reasoning Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants