Skip to content

Commit f648b72

Browse files
authored
Merge pull request #2610 from GaloisInc/bh/sawcore-prelude
Remove unused definitions from SAWCore prelude
2 parents 3f515e8 + bfaa597 commit f648b72

File tree

7 files changed

+12
-458
lines changed

7 files changed

+12
-458
lines changed

intTests/test2049/test.log.1.good

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ Literal equality postcondition
1313
Expected term:
1414
let { x@1 = Prelude.Vec 8 Prelude.Bool
1515
}
16-
in fresh:zero::table#1583
16+
in fresh:zero::table#1523
1717
Actual term:
1818
let { x@1 = Prelude.Vec 8 Prelude.Bool
1919
}
20-
in Cryptol.ecArrayUpdate x@1 x@1 fresh:zero::table#1583
21-
fresh:zero::k#1584
20+
in Cryptol.ecArrayUpdate x@1 x@1 fresh:zero::table#1523
21+
fresh:zero::k#1524
2222
(Prelude.bvNat 8 0)
2323

2424
SolverStats {solverStatsSolvers = fromList ["W4 ->z3"], solverStatsGoalSize = N}

intTests/test2049/test.log.2.good

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ Literal equality postcondition
1313
Expected term:
1414
let { x@1 = Prelude.Vec 8 Prelude.Bool
1515
}
16-
in fresh:zero::table#1583
16+
in fresh:zero::table#1523
1717
Actual term:
1818
let { x@1 = Prelude.Vec 8 Prelude.Bool
1919
}
20-
in Cryptol.ecArrayUpdate x@1 x@1 fresh:zero::table#1583
21-
fresh:zero::k#1584
20+
in Cryptol.ecArrayUpdate x@1 x@1 fresh:zero::table#1523
21+
fresh:zero::k#1524
2222
(Prelude.bvNat 8 0)
2323

2424
SolverStats {solverStatsSolvers = fromList ["W4 ->z3"], solverStatsGoalSize = N}

intTests/test_llvm_errors/err001.log.good

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Expected term:
88
let { x@1 = Prelude.Vec 32 Prelude.Bool
99
x@2 = Cryptol.TCNum 32
1010
}
11-
in Cryptol.ecMul x@1 (Cryptol.PRingSeqBool x@2) fresh:x#1580
11+
in Cryptol.ecMul x@1 (Cryptol.PRingSeqBool x@2) fresh:x#1520
1212
(Cryptol.ecNumber (Cryptol.TCNum 3) x@1
1313
(Cryptol.PLiteralSeqBool x@2))
1414
Actual term:
15-
Prelude.bvMul 32 (Prelude.bvNat 32 2) fresh:x#1580
15+
Prelude.bvMul 32 (Prelude.bvNat 32 2) fresh:x#1520
1616

1717
SolverStats {solverStatsSolvers = fromList ["SBV->Z3"], solverStatsGoalSize = N}
1818
----------Counterexample----------

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

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -83,47 +83,3 @@ Lemma bvToNat_bounds (w : nat) (x : bitvector w) :
8383
Proof.
8484
holds_for_bits_up_to_3; try repeat constructor.
8585
Qed.
86-
87-
Theorem at_gen_BVVec :
88-
forall (n : nat) (len : bitvector n) (a : Type)
89-
(f : forall i : bitvector n, is_bvult n i len -> a)
90-
(ix : bitvector n) (pf : is_bvult n ix len),
91-
atBVVec n len a (genBVVec n len a f) ix pf = f ix pf.
92-
Proof.
93-
intros n len a f ix pf.
94-
unfold atBVVec, genBVVec.
95-
rewrite at_gen_Vec.
96-
generalize (IsLtNat_to_bvult n len (bvToNat n ix)
97-
(bvult_to_IsLtNat n len (bvToNat n ix)
98-
(trans bool (bvult n (bvNat n (bvToNat n ix)) len) (bvult n ix len) 1%bool
99-
(eq_cong (bitvector n) (bvNat n (bvToNat n ix)) ix (bvNat_bvToNat n ix) bool
100-
(fun y : bitvector n => bvult n y len)) pf))) as pf2.
101-
rewrite (bvNat_bvToNat n ix).
102-
intros pf2.
103-
rewrite (UIP_dec Bool.bool_dec pf2 pf).
104-
reflexivity.
105-
Qed.
106-
107-
Lemma gen_at_BVVec :
108-
forall (n : nat) (len : bitvector n) (a : Type) (x : BVVec n len a),
109-
genBVVec n len a (atBVVec n len a x) = x.
110-
Proof.
111-
intros n len a x.
112-
unfold genBVVec, atBVVec.
113-
rewrite <- (gen_at_Vec _ _ x) at 1.
114-
f_equal. extensionality i. extensionality pf.
115-
generalize (bvult_to_IsLtNat n len (bvToNat n (bvNat n i))
116-
(trans bool (bvult n (bvNat n (bvToNat n (bvNat n i))) len) (bvult n (bvNat n i) len) 1%bool
117-
(eq_cong (bitvector n) (bvNat n (bvToNat n (bvNat n i))) (bvNat n i)
118-
(bvNat_bvToNat n (bvNat n i)) bool (fun y : bitvector n => bvult n y len))
119-
(IsLtNat_to_bvult n len i pf))) as pf2.
120-
assert (X : bvToNat n (bvNat n i) = i).
121-
{ apply bvToNat_bvNat.
122-
transitivity (bvToNat n len).
123-
- exact pf.
124-
- apply bvToNat_bounds.
125-
}
126-
rewrite X. intros pf2.
127-
rewrite (le_unique _ _ pf2 pf).
128-
reflexivity.
129-
Qed.

saw-core-coq/src/SAWCoreCoq/SpecialTreatment.hs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ sawCorePreludeSpecialTreatmentMap configuration =
375375
++
376376
[ ("EmptyVec", mapsTo vectorsModule "EmptyVec")
377377
, ("at", rename "sawAt") -- `at` is a reserved keyword in Coq
378-
, ("at_gen_BVVec", mapsTo preludeExtraModule "at_gen_BVVec")
379378
, ("atWithDefault", mapsTo vectorsModule "atWithDefault")
380379
, ("atWithProof", mapsTo vectorsModule "atWithProof")
381380
, ("at_single", skip) -- is boring, could be proved on the Coq side
@@ -405,7 +404,6 @@ sawCorePreludeSpecialTreatmentMap configuration =
405404
, ("foldl", mapsTo vectorsModule "foldl")
406405
, ("foldl_nil", mapsTo vectorsModule "foldl_nil")
407406
, ("foldl_cons", mapsTo vectorsModule "foldl_cons")
408-
, ("gen_at_BVVec", mapsTo preludeExtraModule "gen_at_BVVec")
409407
, ("genWithProof", mapsTo vectorsModule "genWithProof")
410408
, ("scanl", mapsTo vectorsModule "scanl")
411409
, ("gen", mapsTo vectorsModule "gen")
@@ -508,15 +506,6 @@ sawCorePreludeSpecialTreatmentMap configuration =
508506
, ("Right", mapsToExpl datatypesModule "inr")
509507
]
510508

511-
-- Dependent pairs
512-
++
513-
[ ("Sigma", replace (Coq.ExplVar "sigT"))
514-
, ("exists", replace (Coq.ExplVar "existT"))
515-
, ("Sigma__rec", replace (Coq.ExplVar "sigT_rect"))
516-
, ("Sigma_proj1", replace (Coq.ExplVar "projT1"))
517-
, ("Sigma_proj2", replace (Coq.ExplVar "projT2"))
518-
]
519-
520509
-- Lists
521510
++
522511
[ ("List", mapsToExpl datatypesModule "list")
@@ -525,16 +514,6 @@ sawCorePreludeSpecialTreatmentMap configuration =
525514
, ("List__rec", mapsToExpl datatypesModule "list_rect")
526515
]
527516

528-
-- Lists at sort 1
529-
{- FIXME: in order to support lists at a higher sort, we need a universe
530-
polymorphic version of them
531-
++
532-
[ ("List1", mapsToExpl polyListModule "plist")
533-
, ("Nil1", mapsToExpl polyListModule "pnil")
534-
, ("Cons1", mapsToExpl polyListModule "pcons")
535-
]
536-
-}
537-
538517
escapeIdent :: Coq.Ident -> Coq.Ident
539518
escapeIdent (Coq.Ident str)
540519
| all okChar str = Coq.Ident str

0 commit comments

Comments
 (0)