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

spurious proof obligations generated from subset types #6053

Open
erniecohen opened this issue Jan 14, 2025 · 0 comments
Open

spurious proof obligations generated from subset types #6053

erniecohen opened this issue Jan 14, 2025 · 0 comments
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label

Comments

@erniecohen
Copy link

Dafny version

4.9.1

Code to produce this issue

datatype List<T> = Nil | Cons(hd:T,tl:List<T>) 
predicate c(x:T_,y:T_) decreases x.sz() + y.sz() requires x.i() && y.i()
type T = t:T_ | t.i() witness *       
datatype T_ = N | P(x:T_,y:T_) {
    function sz():nat { if N? then 1 else 1 + x.sz() + y.sz() }
    predicate i() decreases sz() { N? || (x.i() && y.i() && c(x,y))}
}
function lSz(l:List<T>):nat { if l.Nil? then 0 else l.hd.sz() + lSz(l.tl) }
function f(ts:List<T>):List<T> decreases lSz(ts) { // flatten
    if ts.Nil? then Nil else if ts.hd.N? then List<T>.Cons(ts.hd,f(ts.tl)) 
    else Cons(ts.hd.x,Cons(ts.hd.y,ts.tl as List<T_>))
}

Command to run and resulting output

In `f`, removing either the `as List<T_>` or the `List<T>.` prefix of the preceding `Cons` causes verification to fail.

What happened?

Neither of these annotations should be necessary. Note that normally T_ would be hidden from clients, so even the evil as workaround above would not be sufficient.

What type of operating system are you experiencing the problem on?

Mac

@erniecohen erniecohen added the kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label
Projects
None yet
Development

No branches or pull requests

1 participant