Skip to content

Commit

Permalink
Merge pull request #1216 from GaloisInc/proof-summary
Browse files Browse the repository at this point in the history
Proof summary improvements
  • Loading branch information
mergify[bot] authored Jun 2, 2021
2 parents 7ee6c7d + bf68aac commit cf78257
Show file tree
Hide file tree
Showing 25 changed files with 1,193 additions and 410 deletions.
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ packages:
crux-mir-comp
cryptol-saw-core
rme
verif-viewer
saw-core
saw-core-aig
saw-core-sbv
Expand Down
6 changes: 3 additions & 3 deletions cryptol-saw-core/src/Verifier/SAW/Cryptol.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1624,9 +1624,9 @@ scCryptolType sc t =
scCryptolEq :: SharedContext -> Term -> Term -> IO Term
scCryptolEq sc x y =
do rules <- concat <$> traverse defRewrites defs
let ss = addConvs natConversions (addRules rules emptySimpset)
tx <- scTypeOf sc x >>= rewriteSharedTerm sc ss >>= scCryptolType sc
ty <- scTypeOf sc y >>= rewriteSharedTerm sc ss >>= scCryptolType sc
let ss = addConvs natConversions (addRules rules emptySimpset :: Simpset ())
tx <- scTypeOf sc x >>= rewriteSharedTerm sc ss >>= scCryptolType sc . snd
ty <- scTypeOf sc y >>= rewriteSharedTerm sc ss >>= scCryptolType sc . snd
unless (tx == ty) $
panic "scCryptolEq"
[ "scCryptolEq: type mismatch between"
Expand Down
2 changes: 1 addition & 1 deletion cryptol-saw-core/src/Verifier/SAW/Cryptol/Simpset.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Verifier.SAW.Rewriter
import Verifier.SAW.SharedTerm
import Verifier.SAW.Term.Functor

mkCryptolSimpset :: SharedContext -> IO Simpset
mkCryptolSimpset :: SharedContext -> IO (Simpset a)
mkCryptolSimpset sc =
do m <- scFindModule sc cryptolModuleName
scSimpset sc (cryptolDefs m) [] []
Expand Down
15 changes: 9 additions & 6 deletions examples/ecdsa/ecdsa.saw
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ let ss0 = add_prelude_eqs [ "bvShiftL_bvShl"
, "bvShiftR_bvShr"
] cry_ss;

let crule t = rewrite ss0 t;
let assume_rule t = prove_print (admit "assume rule") (rewrite ss0 t);
let prove_rule t = prove_print abc (rewrite ss0 t);

let ss1 = add_prelude_eqs
Expand Down Expand Up @@ -365,16 +365,19 @@ ec_join_split_768 <- prove_rule {{ \x -> ec_join768 (ec_split768 x) == x }};
ec_split_join_768 <- prove_rule {{ \x -> ec_split768 (ec_join768 x) == x }};

// Axiomatic rules: For now, we assume these without proof.
let mul_java_elim = crule {{ \(a:[768]) -> \(x:[384]) -> \(y:[384]) ->
mul_java::mul_java (a, x, y) == p384_field::p384_safe_product (x, y) }};
let sq_java_elim = crule {{ \(a:[768]) -> \(x:[384]) ->
mul_java::sq_java (a, x) == p384_field::p384_safe_product (x, x) }};
mul_java_elim <- assume_rule
{{ \(a:[768]) -> \(x:[384]) -> \(y:[384]) ->
mul_java::mul_java (a, x, y) == p384_field::p384_safe_product (x, y) }};

sq_java_elim <- assume_rule
{{ \(a:[768]) -> \(x:[384]) ->
mul_java::sq_java (a, x) == p384_field::p384_safe_product (x, x) }};

let basic_simps = [ ec_join_split
, at12, at24
];
let ss3 = addsimps basic_simps ss2;
let ss4 = addsimps' [mul_java_elim, sq_java_elim] ss3;
let ss4 = addsimps [mul_java_elim, sq_java_elim] ss3;
let ss = add_prelude_defs
[ "bvUpd"
, "bvAt"
Expand Down
7 changes: 5 additions & 2 deletions examples/misc/rewrite.saw
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
let crule t = do { ss <- cryptol_ss ; rewrite ss t; };
let ss = cryptol_ss ();
let crule t = rewrite ss t;

rule <- crule {{ \(x:[384]) -> join ((split x) : [12][32]) == x }};
rule_thm <- prove_print (admit "assume rule") rule;

print "== Original version of rule:";
print_term rule;
let rule_ss = addsimps' [rule] empty_ss;
let rule_ss = addsimps [rule_thm] empty_ss;
t <- rewrite rule_ss rule;
print "== Rule rewritten with itself:";
print_term t;
Expand Down
2 changes: 1 addition & 1 deletion saw-core/src/Verifier/SAW/Constant.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ import Verifier.SAW.Conversion
scConst :: SharedContext -> Text -> Term -> IO Term
scConst sc name t = do
ty <- scTypeOf sc t
ty' <- rewriteSharedTerm sc (addConvs natConversions emptySimpset) ty
(_,ty') <- rewriteSharedTerm sc (addConvs natConversions emptySimpset :: Simpset ()) ty
scConstant sc name t ty'
Loading

0 comments on commit cf78257

Please sign in to comment.