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

Axiom ordering seems may be missing an edge when using a spec definition to satisfy the postcondition on a proof fn in a trait #885

Open
utaal opened this issue Nov 3, 2023 · 0 comments · May be fixed by #905

Comments

@utaal
Copy link
Collaborator

utaal commented Nov 3, 2023

There's code like this:

        pub trait KeyTrait : Sized {
            fn zero() -> (z: Self) ensures z == Self::zero_spec(); // <-- should this force the definition for `zero_spec` to appear before the proof obligation for `zero` in the impl?

            spec fn zero_spec() -> Self where Self: std::marker::Sized;
        }
        
        pub struct KeyStruct { pub ukey: u64, }
        
        impl KeyTrait for KeyStruct {
            fn zero() -> (z: Self) { KeyStruct{ukey: 0} }

            open spec fn zero_spec() -> Self { KeyStruct{ukey: 0} }
        }

that fails to verify, in:

2023-11-03-19-25-29.zip

ordering zero() after zero_spec() in the impl KeyTrait for SHTKey makes it pass.

utaal added a commit that referenced this issue Nov 16, 2023
…completeness

fix #885, and non-deterministic incompleteness for cases like:

```rust
trait T {
    spec fn a() -> bool;
    proof fn p() ensures Self::a();
    proof fn q() ensures Self::a();
}

struct S { pub dummy: nat }
impl T for S {
    spec fn a() -> bool;
    proof fn p() { Self::q(); }
    proof fn q() { /* ... */  }
}
```

without this change, Self::p was sometimes lowered to AIR without having processed
Self::q first, which was not found as a function with a postcondition,
which resulted in the encoding for `p()` to be an empty block instead of
the expected `(assume <q's postcondition>)`.
@utaal utaal linked a pull request Nov 16, 2023 that will close this issue
utaal added a commit that referenced this issue Nov 16, 2023
… SCC ordering

fix #885, and non-deterministic incompleteness for cases like:

```rust
trait T {
    spec fn a() -> bool;
    proof fn p() ensures Self::a();
    proof fn q() ensures Self::a();
}

struct S { pub dummy: nat }
impl T for S {
    spec fn a() -> bool;
    proof fn p() { Self::q(); }
    proof fn q() { /* ... */  }
}
```

without this change, Self::p was sometimes lowered to AIR without having processed
Self::q first, which was not found as a function with a postcondition,
which resulted in the encoding for `p()` to be an empty block instead of
the expected `(assume <q's postcondition>)`.
utaal added a commit that referenced this issue Nov 16, 2023
… SCC ordering

fix #885, and non-deterministic incompleteness for cases like:

```rust
trait T {
    spec fn a() -> bool;
    proof fn p() ensures Self::a();
    proof fn q() ensures Self::a();
}

struct S { pub dummy: nat }
impl T for S {
    spec fn a() -> bool;
    proof fn p() { Self::q(); }
    proof fn q() { /* ... */  }
}
```

without this change, Self::p was sometimes lowered to AIR without having processed
Self::q first, which was not found as a function with a postcondition,
which resulted in the encoding for `p()` to be an empty block instead of
the expected `(assume <q's postcondition>)`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant