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

Add the axiom stating that Seq#Take(s, Seq#Length(s)) == s) for all… #4195

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MikaelMayer
Copy link
Member

@MikaelMayer MikaelMayer commented Jun 19, 2023

… sequence s (#4194)

A trivial axiom stating Seq#Take(s, Seq#Length(s)) == s) for all sequence s. This will help deducing automatically and without using any workaround that "multiset(arr[..]) == multiset(arr[..arr.Length])" for any array arr.

Fixes #4184

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT
license
.

… sequence `s` (#4194)

A trivial axiom stating `Seq#Take(s, Seq#Length(s)) == s)` for all
sequence `s`. This will help deducing automatically and without using
any workaround that "multiset(arr[..]) == multiset(arr[..arr.Length])"
for any array `arr`.

Fixes #4184

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
@btwael
Copy link

btwael commented Jun 19, 2023

I think the file Test/git-issues/git-issue-4184.dfy should be modified to the following to avoid the non-initialization of arr:

method main(arr: array<int>) {
  assert(multiset(arr[..]) == multiset(arr[..arr.Length]));
}

I don't know how to modify that in your PR.

@btwael
Copy link

btwael commented Jun 20, 2023

It looks that the [some-proofs-only-work-without-autoTriggers.dfy](https://github.com/dafny-lang/dafny/blob/5679b3dbbba3f9f4ed3acc139e659d26a9c19aff/Test/triggers/some-proofs-only-work-without-autoTriggers.dfy] is what cause the failure of test, adding the axiom in line 23 to the prelude make the whole test file verified (with the added axiom in this PR):

axiom (forall<T> s: Seq T, i: int ::
  { Seq#Index(s, i) }
  0 <= i && i < Seq#Length(s) ==>
  Seq#Contains(s, Seq#Index(s, i)));

If we add this axiom, maybe we should just modify "some-proofs-only-work-without-autoTriggers.dfy.expect"!?
I wonder why those axioms are not already part of the default prelude file?

@MikaelMayer MikaelMayer self-assigned this Jun 27, 2023
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

Successfully merging this pull request may close these issues.

assert(multiset(arr[..]) == multiset(arr[..arr.Length])) fails!
2 participants