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

Soundness issue in sequence axioms (axiom_seq_add_index2) #990

Closed
tchajed opened this issue Feb 16, 2024 · 2 comments
Closed

Soundness issue in sequence axioms (axiom_seq_add_index2) #990

tchajed opened this issue Feb 16, 2024 · 2 comments
Assignees

Comments

@tchajed
Copy link
Collaborator

tchajed commented Feb 16, 2024

The axiom axiom_seq_add_index2 is unsound:

pub proof fn axiom_seq_add_index2<A>(s1: Seq<A>, s2: Seq<A>, i: int)
requires
0 <= s1.len(),
i < s1.len() as int + s2.len(),
ensures
s1.add(s2)[i] == s2[i - s1.len()],

Here's a proof of false:

use vstd::prelude::*;

verus! {
    proof fn seq_bad()
        ensures false
    {
        let s1: Seq<int> = seq![1];
        let s1_2: Seq<int> = seq![1, 2];
        let s2: Seq<int> = seq![];
        assert(s1.add(s2)[0] == s2[-1]);
        assert(s1_2.add(s2)[1] == s2[-1]);
    }

    fn main() {}
}

The lemma becomes true if the precondition is changed to 0 <= s1.len() <= i.

@Chris-Hawblitzel Chris-Hawblitzel self-assigned this Feb 16, 2024
Chris-Hawblitzel added a commit that referenced this issue Feb 16, 2024
@Chris-Hawblitzel
Copy link
Collaborator

Oops. That's a good motivation for #988 .

@Chris-Hawblitzel
Copy link
Collaborator

Fixed by bf057b6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants