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

Time reasoning #1275

Closed
wants to merge 26 commits into from
Closed

Time reasoning #1275

wants to merge 26 commits into from

Conversation

Pialex99
Copy link

@Pialex99 Pialex99 commented Jan 6, 2023

Add time reasoning functionality.

  • The error reporting is a bit hacky but it works.
  • Does not work on pure functions and closures.
  • Quadratic runtime does not work because z3 can't handle it out of the box.

Comment on lines +97 to +98
}) => if b {
conjunct
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vakaras If we inline a dummy trigger function body (with the body true) and also simplify, this would change semantics of quantifiers. Do you know in what order the inlining is performed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this can be a problem. For this and other reasons, it is better to use domain functions as triggers (with an axiom that says its value is always true).


use prusti_contracts::*;

// ignore-test: prusti-constract functions used outside specification check not yet implemented
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about "not yet" here: we don't want to implement something like this. Many specification functions don't make sense in executable code, and branching on time_credits or receipts is also such an example. I would remove this test.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As they don't make sense in executable code why don't we report them when we find them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because nobody has implemented that feature yet...

vir/src/legacy/ast/expr.rs Outdated Show resolved Hide resolved

use prusti_contracts::*;

// ignore-test: prusti-constract functions used outside specification check not yet implemented
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this test.

fn safe_array_cmp<T: Eq>(a: &[T], b: &[T]) -> bool {
let mut i = 0;
let mut res = true;
while i < a.len() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we need to put time_credits in the invariant?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prusti didn't complain so I thought I didn't have to and the loop.rs tests were passing without so I thought that it was okay but playing a bit with the generated Viper code showed me that it doesn't 😅


use prusti_contracts::*;

// This test checks that setting the time reasoning option to false ignores timing constrains
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As written in another comment, I don't think this should be the behaviour. This test also isn't even fully testing what the comment says: there is no timing specification to "ignore", only the default zero permissions.

@Aurel300
Copy link
Member

Superseded by #1408.

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