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

Need to repeat function body to prove #5756

Open
txiang61 opened this issue Sep 6, 2024 · 2 comments
Open

Need to repeat function body to prove #5756

txiang61 opened this issue Sep 6, 2024 · 2 comments
Labels
incompleteness Things that Dafny should be able to prove, but can't kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label

Comments

@txiang61
Copy link

txiang61 commented Sep 6, 2024

Dafny version

4.4.0

Code to produce this issue

lemma Proof<A>(x: seq<A>, b: A) {
  if |x| == 1 {
    assert x == [x[0]];
    var p := a => [b];
    // assert p(x[0]) == [b]; // useless
    
    // var _ := Concat(Map(x, p)); // useless

    assert Map(x, p) == [[b]]; // This line and the next are both neccessary
    assert Concat([[b]]) == [b];

    // The following assertions can replace the two previous assertions
    // assert Foo(x, p) == Concat(Map(x, p));

    assert Foo(x, p) == [b];
  }
}

function Foo<A>(actions: seq<A>, b: A -> seq<A>): seq<A> {
  Concat(
    Map(
      actions,
      b
	  ))
}

function Map<T, U>(s: seq<T>, f: T -> U): (res: seq<U>) {
  if s == [] then []
  else [f(s[0])] + Map(s[1..], f)
}

function Concat<A>(s: seq<seq<A>>): (res: seq<A>) {
  if s == [] then []
  else s[0] + Concat(s[1..])
}

Command to run and resulting output

No response

What happened?

Sometimes copying over the function body can prove the assertions. The example above is a short and simple but in practice the function aren't as small as the one above. The real pain comes from having to copy over the whole function body in order to prove some assertions.

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

Mac

@txiang61 txiang61 added the kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label label Sep 6, 2024
@dschoepe
Copy link
Collaborator

dschoepe commented Sep 6, 2024

Verifies successfully for me using 4.7.0

@robin-aws robin-aws added the incompleteness Things that Dafny should be able to prove, but can't label Sep 10, 2024
@robin-aws
Copy link
Member

@txiang61 - just to confirm, are you stuck on Dafny 4.4 or can you upgrade as @dschoepe suggests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompleteness Things that Dafny should be able to prove, but can't kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label
Projects
None yet
Development

No branches or pull requests

3 participants