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

Panic when decreases clause is on a set with generic #1372

Open
matthias-brun opened this issue Dec 29, 2024 · 1 comment
Open

Panic when decreases clause is on a set with generic #1372

matthias-brun opened this issue Dec 29, 2024 · 1 comment

Comments

@matthias-brun
Copy link
Collaborator

I wasn't sure if using a set directly in the decreases clause (rather than using s.len()) is valid. It seems to work for fixed types but Verus panics when the set elements are a generic type:

use vstd::prelude::*; verus! {

spec fn foo<A>(s: Set<A>) -> int
    decreases s when s.finite()
{
    if s.is_empty() {
        0
    } else {
        foo(s.remove(s.choose()))
    }
}

} // verus!
thread '<unnamed>' panicked at vir/src/sst_to_air.rs:168:29:
abstract datatype should be boxed Datatype(Path(Path(Some("vstd"), ["set" :: "Set"])), [TypParam("A")], [])
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at rust_verify/src/verifier.rs:2123:29:
worker thread panicked
@tjhance
Copy link
Collaborator

tjhance commented Jan 9, 2025

The panic, of course, is a bug.

However, it doesn't look like we have the relevant axiom that would make this useful (b.finite() && a.subset(b) && a != b ==> decreases_to!(b => a)). I do think such an axiom would be sound, though.

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

No branches or pull requests

2 participants