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

Improve handling of idents when generating Why3 code #1239

Open
jhjourdan opened this issue Nov 18, 2024 · 2 comments
Open

Improve handling of idents when generating Why3 code #1239

jhjourdan opened this issue Nov 18, 2024 · 2 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request soundness Enhance soundness

Comments

@jhjourdan
Copy link
Collaborator

My proposal: have an Ident type in the Why3 crate with a string and a unique identifier. The Why3 crates generates colision-free names when printing (while trying to use the string when possible), by maintaining the local environment. The Creusot crate needs to be audited to use this new API.

This is related with #108 .

@jhjourdan jhjourdan added enhancement New feature or request soundness Enhance soundness labels Nov 18, 2024
@Lysxia Lysxia added the bug Something isn't working label Feb 13, 2025
@Lysxia
Copy link
Collaborator

Lysxia commented Feb 13, 2025

While working on this I found a bug. It was probably to be expected given the current state of things. Now we have a concrete test case:

extern crate creusot_contracts;
use creusot_contracts::*;

#[open]
#[logic]
#[ensures(result == (1, 2))]
pub fn f() -> (Int, Int) {
    let x = 2;
    ({let x = 1; x}, x)
}

Translated VC:

goal vc_f'0 : let x = 2 in let x_1 = 1 in [%#sxxx0] (x_1, x_1) = (1, 2)

The VCGen is written in CPS. When it finishes translating the first component {let x = 1; x} of the pair, it calls a continuation to translate the second component x while the x = 1 binding is still in scope.

The add_bounds/pop_bounds calls here are basically just broken:

self.add_bounds(bounds);
// FIXME: this totally breaks the tail-call potential... which needs desparate fixing.
let r = k(pat);
self.pop_bounds();

The postcondition of build_vc should be a plain term instead of a function, with some delayed substitution trickery to avoid a quadratic time blow up.

@jhjourdan
Copy link
Collaborator Author

I see... good to know that we will not keep this mechanism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request soundness Enhance soundness
Projects
None yet
Development

No branches or pull requests

2 participants