-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SyGuS, find SMT array write of a fixed size (#2037)
* Find SMT array write of a fixed size. * Load SMT array with concrete size. * Add test. * Add noSatisfyingWriteFreshConstant option. * Add invariant substitution to getPoststateObligations. * Bump what4. * wip * wip * Use simplified term in resolveSAWPred. * Bump crucible. * Remove unused sc. * Use simplified term in resolveSAWPred. * Bump crucible. * Update src/SAWScript/Crucible/LLVM/Builtins.hs Co-authored-by: Ryan Scott <[email protected]> * Fix -Wunused-matches warning * Bump crucible, what4 submodules This bumps: * The `crucible` submodule to bring in the changes from GaloisInc/crucible#1178 * The `what4` submodule to bring in the changes from GaloisInc/what4#256 * Remove debugging-only code * Bump cryptol-specs to incorporate GaloisInc/cryptol-specs#72 * Repair AES example to work with `type Nk = AES256` * Add expert options for enabling What4-, Crucible-related SyGuS features * Split off separate llvm_verify_fixpoint_chc_x86 command * Only enable doPtrCmp optimizations with SimpleFixpointCHC * crucible: Revert popFrame refactoring * Uniformly apply pushMuxOps option to all ExprBuilders SAW creates a variety of different ExprBuilders in the course of a typical SAW script, but we were only applying the pushMuxOps option to some of them. This patch makes the treatment a bit more comprehensive. Unfortunately, doing so requires a rather uncomfortable amount of extra plumbing in `SAWScript.Proof`, but I'm not sure how to do better without refactoring all of `SAWScript.Proof` to use `TopLevel` instead of `IO` (and it's unclear if that is desirable). * Bump cryptol-specs, what4, crucible submodules to latest * Bump what4, crucible submodules * Adapt to recent crucible-llvm API changes --------- Co-authored-by: Andrei Stefanescu <[email protected]>
- Loading branch information
1 parent
1722a84
commit 70fe999
Showing
27 changed files
with
511 additions
and
104 deletions.
There are no files selected for viewing
Submodule crucible
updated
93 files
Submodule cryptol-specs
updated
14 files
Submodule what4
updated
28 files
+5 −1 | .github/workflows/gen_matrix.pl | |
+24 −0 | .github/workflows/lint.yml | |
+4 −1 | .github/workflows/test.yml | |
+11 −72 | .hlint.yaml | |
+5 −5 | README.md | |
+1 −1 | dependencies/aig | |
+1 −1 | what4-abc/what4-abc.cabal | |
+1 −1 | what4-blt/what4-blt.cabal | |
+1 −1 | what4-transition-system/what4-transition-system.cabal | |
+9 −0 | what4/CHANGES.md | |
+1 −0 | what4/README.md | |
+1 −0 | what4/src/What4/Expr.hs | |
+2 −2 | what4/src/What4/Expr/App.hs | |
+540 −45 | what4/src/What4/Expr/Builder.hs | |
+2 −2 | what4/src/What4/Expr/MATLAB.hs | |
+44 −4 | what4/src/What4/Interface.hs | |
+56 −4 | what4/src/What4/Protocol/SMTLib2.hs | |
+5 −3 | what4/src/What4/Protocol/SMTWriter.hs | |
+11 −0 | what4/src/What4/Solver.hs | |
+158 −0 | what4/src/What4/Solver/Bitwuzla.hs | |
+88 −9 | what4/src/What4/Solver/Z3.hs | |
+50 −3 | what4/test/AdapterTest.hs | |
+3 −1 | what4/test/ConfigTest.hs | |
+3 −3 | what4/test/ExprBuilderSMTLib2.hs | |
+4 −3 | what4/test/InvariantSynthesis.hs | |
+3 −0 | what4/test/OnlineSolverTest.hs | |
+3 −1 | what4/test/ProbeSolvers.hs | |
+3 −2 | what4/what4.cabal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CC = clang | ||
CFLAGS = -g -emit-llvm -frecord-command-line -O1 | ||
|
||
all: test.bc | ||
|
||
test.bc: test.c | ||
$(CC) $(CFLAGS) -c $< -o $@ | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f test.bc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Mix where | ||
|
||
import Array | ||
|
||
type ByteArray = Array[64][8] | ||
|
||
mix : {l} (width l <= 64) => ByteArray -> [64] -> [l][8] -> ByteArray | ||
mix block n data = arrayCopy block n (arrayRangeUpdate (arrayConstant 0) 0 data) 0 `(l) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <stdint.h> | ||
#include <string.h> | ||
|
||
int mix(uint8_t block[128], uint32_t n, uint8_t *data, size_t len) { | ||
size_t left = 128 - n; | ||
|
||
if (len < left) { | ||
memcpy(block + n, data, len); | ||
} else { | ||
memcpy(block + n, data, left); | ||
} | ||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
enable_experimental; | ||
|
||
import "Mix.cry"; | ||
let arrayRangeEq = parse_core "arrayRangeEq 64 (Vec 8 Bool)"; | ||
|
||
m <- llvm_load_module "test.bc"; | ||
|
||
let i8 = llvm_int 8; | ||
let i32 = llvm_int 32; | ||
|
||
let alloc_init_readonly ty v = do { | ||
p <- llvm_alloc_readonly ty; | ||
llvm_points_to p v; | ||
return p; | ||
}; | ||
|
||
let ptr_to_fresh_readonly n ty = do { | ||
x <- llvm_fresh_var n ty; | ||
p <- alloc_init_readonly ty (llvm_term x); | ||
return (x, p); | ||
}; | ||
|
||
let mix_spec len res_block_len range_eq_len = do { | ||
block <- llvm_fresh_cryptol_var "block" {| ByteArray |}; | ||
block_ptr <- llvm_symbolic_alloc false 1 {{ 128:[64] }}; | ||
llvm_points_to_array_prefix block_ptr block {{ 128:[64] }}; | ||
|
||
(data, data_ptr) <- ptr_to_fresh_readonly "data" (llvm_array len i8); | ||
|
||
n <- llvm_fresh_var "n" i32; | ||
llvm_precond({{ n < 128 }}); | ||
|
||
llvm_execute_func [block_ptr, (llvm_term n), data_ptr, (llvm_term {{ `len : [64] }})]; | ||
|
||
let res = {{ mix block (0 # n) data }}; | ||
res_block <- llvm_fresh_cryptol_var "res_block" {| ByteArray |}; | ||
llvm_points_to_array_prefix block_ptr res_block {{ `res_block_len:[64] }}; | ||
llvm_postcond {{ arrayRangeEq res_block 0 res 0 `range_eq_len }}; | ||
|
||
llvm_return (llvm_term {{ 1 : [32]}}); | ||
}; | ||
|
||
llvm_verify m "mix" | ||
[] | ||
true | ||
(mix_spec 1 128 128) | ||
(do { | ||
w4_unint_z3 []; | ||
}); | ||
|
||
llvm_verify m "mix" | ||
[] | ||
true | ||
(mix_spec 1 0 0) | ||
(do { | ||
w4_unint_z3 []; | ||
}); | ||
|
||
fails (llvm_verify m "mix" | ||
[] | ||
true | ||
(mix_spec 1 129 0) | ||
(do { | ||
w4_unint_z3 []; | ||
})); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
$SAW test.saw | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.