Skip to content

Commit

Permalink
Buggy example of nil vs empty slice
Browse files Browse the repository at this point in the history
  • Loading branch information
upamanyus committed Mar 12, 2024
1 parent 772faf8 commit 322c48d
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/program_proof/bad_nil_slice.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
(*
package test
import (
"github.com/tchajed/goose/machine"
)
func test() {
slEmpt := make([]byte, 0)
machine.Assert((slEmpt == nil) == true)
}
*)
(* autogenerated from test *)
From Perennial.goose_lang Require Import prelude.

Section code.
Context `{ext_ty: ext_types}.
Local Coercion Var' s: expr := Var s.

(* FIXME: should not be possible to prove this assert *)
Definition test: val :=
rec: "test" <> :=
let: "slEmpt" := NewSlice byteT #0 in
control.impl.Assert (("slEmpt" = slice.nil) = #true);;
#().

End code.

From Perennial.program_proof Require Import grove_prelude.
From Perennial.goose_lang.lib Require Import slice.
Section proof.
Context `{!heapGS Σ}.
Lemma wp_test :
{{{
True
}}}
test #()
{{{
RET #(); True
}}}
.
Proof.
iIntros (Φ) "_ HΦ".
wp_lam. wp_pures.
rewrite /NewSlice.
rewrite /slice.nil.
wp_pures.
wp_pure1.
{ done. }
wp_apply wp_Assert.
2:{ wp_pures; by iApply "HΦ". }
done.
Qed.

End proof.

0 comments on commit 322c48d

Please sign in to comment.