Skip to content

Commit fef1087

Browse files
committed
saw-core: Use bvNat_bvToNat over bvNat_bvToNat_id
To avoid unnecessary breakage in the Coq support libraries, we keep `bvNat_bvToNat_id` around as a deprecated alias for `bvNat_bvToNat`. Fixes #1785.
1 parent 8f72532 commit fef1087

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

heapster-saw/examples/mbox_proofs.v

+10-10
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ Import mbox.
2828

2929
(* QOL: nicer names for bitvector and mbox arguments *)
3030
#[local] Hint Extern 901 (IntroArg Any (bitvector _) _) =>
31-
let e := fresh "x" in IntroArg_intro e : refines prepostcond.
31+
let e := fresh "x" in IntroArg_intro e : refines prepostcond.
3232
#[local] Hint Extern 901 (IntroArg Any Mbox _) =>
33-
let e := fresh "m" in IntroArg_intro e : refines prepostcond.
33+
let e := fresh "m" in IntroArg_intro e : refines prepostcond.
3434
#[local] Hint Extern 901 (IntroArg Any Mbox_def _) =>
3535
let e := fresh "m" in IntroArg_intro e : refines prepostcond.
3636

3737
#[local] Hint Extern 901 (IntroArg RetAny (bitvector _) _) =>
38-
let e := fresh "r_x" in IntroArg_intro e : refines prepostcond.
38+
let e := fresh "r_x" in IntroArg_intro e : refines prepostcond.
3939
#[local] Hint Extern 901 (IntroArg RetAny Mbox _) =>
40-
let e := fresh "r_m" in IntroArg_intro e : refines prepostcond.
40+
let e := fresh "r_m" in IntroArg_intro e : refines prepostcond.
4141
#[local] Hint Extern 901 (IntroArg RetAny Mbox_def _) =>
4242
let e := fresh "r_m" in IntroArg_intro e : refines prepostcond.
4343

@@ -194,7 +194,7 @@ Polymorphic Lemma bvuleWithProof_not_IntroArg n w a b goal :
194194
IntroArg n (~ (isBvule w a b)) (fun _ => goal) ->
195195
IntroArg n (bvuleWithProof w a b = Nothing _) (fun _ => goal).
196196
Proof. intros H eq; apply H; apply bvuleWithProof_not; eauto. Qed.
197-
197+
198198
#[local] Hint Extern 101 (IntroArg _ (bvuleWithProof _ _ _ = Nothing _) _) =>
199199
simple apply bvuleWithProof_not_IntroArg || shelve : refines.
200200

@@ -288,9 +288,9 @@ Global Instance QuantType_bitvector {w} : QuantType (bitvector w) :=
288288
{ quantEnc := QEnc_nat;
289289
quantEnum := bvNat w;
290290
quantEnumInv := bvToNat w;
291-
quantEnumSurjective := bvNat_bvToNat_id w }.
291+
quantEnumSurjective := bvNat_bvToNat w }.
292292

293-
Lemma gen_sawAt_eq n a v `{Inhabited a} :
293+
Lemma gen_sawAt_eq n a v `{Inhabited a} :
294294
gen n a (sawAt n a v) = v.
295295
Proof. dependent induction v; simpl; f_equal. apply IHv. Qed.
296296

@@ -441,7 +441,7 @@ Tactic Notation "rewrite_transMbox_Mbox_nil_r_dep" "in" ident(H1) ident(H2) :=
441441
Tactic Notation "rewrite_transMbox_Mbox_nil_r_dep" "in" ident(H1) ident(H2) ident(H3) :=
442442
revert H1 H2 H3; rewrite transMbox_Mbox_nil_r; intros H1 H2 H3.
443443

444-
Definition mbox_chain_length :=
444+
Definition mbox_chain_length :=
445445
Mbox_rect (fun _ => nat) O (fun _ _ _ rec _ => S rec).
446446

447447
Lemma mbox_chain_length_transMbox m1 m2 :
@@ -500,7 +500,7 @@ Time Qed.
500500

501501
Lemma mbox_rect_identity m :
502502
Mbox_rect _ Mbox_nil (fun strt len _ rec d => Mbox_cons strt len rec d) m = m.
503-
Proof. induction m; simpl; try f_equal; eauto. Qed.
503+
Proof. induction m; simpl; try f_equal; eauto. Qed.
504504

505505
Definition mbox_concat_chains_spec (m1 m2 : Mbox) : Mbox :=
506506
if mbox_chain_length m1 =? 0 then Mbox_nil else transMbox m1 m2.
@@ -1131,7 +1131,7 @@ Proof.
11311131
Ltac busywork a e_assert := simpl in *;
11321132
repeat rewrite_transMbox_Mbox_nil_r_dep in a e_assert.
11331133
+ unshelve instantiate (1 := _).
1134-
{ busywork a e_assert. apply a. }
1134+
{ busywork a e_assert. apply a. }
11351135
busywork a e_assert.
11361136
rewrite -> e_assert.
11371137
reflexivity.

saw-core-coq/coq/handwritten/CryptolToCoq/SAWCoreBitvectors.v

+7
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,13 @@ Definition isBvult_to_bvEq_false w a b : isBvult w a b -> bvEq w a b = false.
241241
Proof. holds_for_bits_up_to_3. Qed.
242242

243243

244+
(** Other lemmas about bitvector equalities **)
245+
246+
(** DEPRECATED: Use [bvNat_bvToNat] instead. *)
247+
Definition bvNat_bvToNat_id w a : bvNat w (bvToNat w a) = a :=
248+
bvNat_bvToNat w a.
249+
250+
244251
(** Other lemmas about bitvector inequalities **)
245252

246253
Definition not_isBvslt_bvsmin w a : ~ isBvslt w a (bvsmin w).

saw-core-coq/src/Verifier/SAW/Translation/Coq/SpecialTreatment.hs

-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@ sawCorePreludeSpecialTreatmentMap configuration =
472472
, ("bveq_sameL", skip)
473473
, ("bveq_sameR", skip)
474474
, ("bveq_same2", skip)
475-
, ("bvNat_bvToNat", skip)
476475
, ("ite_split_cong", skip)
477476
, ("ite_join_cong", skip)
478477
, ("map_map", skip)

saw-core/prelude/Prelude.sawcore

+1-4
Original file line numberDiff line numberDiff line change
@@ -1218,9 +1218,6 @@ primitive bvNat : (n : Nat) -> Nat -> Vec n Bool;
12181218
-- | Satisfies @bvNat n (bvToNat n x) = x@.
12191219
primitive bvToNat : (n : Nat) -> Vec n Bool -> Nat;
12201220

1221-
axiom bvNat_bvToNat_id : (n : Nat) -> (x : Vec n Bool) ->
1222-
Eq (Vec n Bool) (bvNat n (bvToNat n x)) x;
1223-
12241221
bvAt : (n : Nat) -> (a : isort 0) -> (w : Nat) -> Vec n a -> Vec w Bool
12251222
-> a;
12261223
bvAt n a w xs i = at n a xs (bvToNat w i);
@@ -1946,7 +1943,7 @@ atBVVec n len a x ix pf =
19461943
(bvult_to_IsLtNat n len (bvToNat n ix)
19471944
(trans Bool (bvult n (bvNat n (bvToNat n ix)) len) (bvult n ix len) True
19481945
(eq_cong (Vec n Bool) (bvNat n (bvToNat n ix)) ix
1949-
(bvNat_bvToNat_id n ix) Bool (\ (y:Vec n Bool) -> bvult n y len))
1946+
(bvNat_bvToNat n ix) Bool (\ (y:Vec n Bool) -> bvult n y len))
19501947
pf));
19511948

19521949
-- Indexing a generated BVVec just returns the generating function

0 commit comments

Comments
 (0)