added flag --weak: if activated only check weak safety (default false)

This commit is contained in:
clararod9
2022-08-30 17:07:40 -07:00
parent f3ae1203df
commit b592ed70a6
2 changed files with 27 additions and 11 deletions

View File

@@ -156,15 +156,15 @@
(cond
; replace as p
[(= config:p v) (r1cs:rvar "p")]
[(= (- config:p 1) v) (r1cs:rvar "ps1")]
[(= (- config:p 2) v) (r1cs:rvar "ps2")]
[(= (- config:p 3) v) (r1cs:rvar "ps3")]
[(= (- config:p 4) v) (r1cs:rvar "ps4")]
[(= (- config:p 5) v) (r1cs:rvar "ps5")]
;[(= (- config:p 1) v) (r1cs:rvar "ps1")]
;[(= (- config:p 2) v) (r1cs:rvar "ps2")]
;[(= (- config:p 3) v) (r1cs:rvar "ps3")]
;[(= (- config:p 4) v) (r1cs:rvar "ps4")]
;[(= (- config:p 5) v) (r1cs:rvar "ps5")]
; replace as zero
[(= 0 v) (r1cs:rvar "zero")]
;[(= 0 v) (r1cs:rvar "zero")]
; replace as one
[(= 1 v) (r1cs:rvar "one")]
;[(= 1 v) (r1cs:rvar "one")]
; do nothing
[else (r1cs:rint v)]
)

View File

@@ -34,6 +34,7 @@
(define arg-solver "z3")
(define arg-timeout 5000)
(define arg-smt #f)
(define arg-weak #f)
(command-line
#:once-each
[("--r1cs") p-r1cs "path to target r1cs"
@@ -60,11 +61,17 @@
(set! arg-smt #t)
)
]
[("--weak") "only check weak safety, not strong safety (default: false)"
(begin
(set! arg-weak #t)
)
]
)
(printf "# r1cs file: ~a\n" arg-r1cs)
(printf "# timeout: ~a\n" arg-timeout)
(printf "# solver: ~a\n" arg-solver)
; =========================================
; ======== solver specific methods ========
; =========================================
@@ -371,7 +378,13 @@
)
(if (null? ukn)
null
(apply-complete-iteration kn ukn c2ukn (list-ref signal2constraints signal-smt) new-failures)
(if arg-weak
(if (utils:empty_inter? ukn output-list)
ukn
(apply-complete-iteration kn ukn c2ukn (list-ref signal2constraints signal-smt) new-failures)
)
(apply-complete-iteration kn ukn c2ukn (list-ref signal2constraints signal-smt) new-failures)
)
)
]
[else ukn]
@@ -468,9 +481,12 @@
(define res-ul (apply-complete-iteration known-list unknown-list initial-constraint2ukn (range mconstraints) '()))
(printf "# final unknown list: ~a\n" res-ul)
(if (empty? res-ul)
(printf "# Strong safety verified.\n")
(printf "# Strong safey failed.\n")
(if (not arg-weak)
(if (empty? res-ul)
(printf "# Strong safety verified.\n")
(printf "# Strong safey failed.\n")
)
(printf "# Weak flag activated: skipping check strong safey\n")
)
(if (utils:empty_inter? res-ul output-list)