Open philzook58 opened 3 years ago
(assert library-defined-thing)
in order for anything to change at all. I kind of think the default behavior of assuming registers equal should be turned off personally and instead create a library predicate called init-registers-equal
if you want this behavior.on-stack
was a bit confusing since a local variable is "on the stack" but really the predicate is about pointers that point to the stack. I could expand the name to points-to-stack
. Perhaps the clarity is worth the verbosity* The prelude is added if the user uses custom pre/post conds. I am not currently replicating the assumption that registers are equal, in fact I add no assuptions. The user needs to `(assert library-defined-thing)` in order for anything to change at all. I kind of think the default behavior of assuming registers equal should be turned off personally and instead create a library predicate called `init-registers-equal` if you want this behavior. * Hyphens vs underscores. Lisp convention is hyphens, our convention for init_ mod_ is underscores. That is the difference. I tried to stick to hyphens for anything that wasn't init_ _mod _orig. main_argv is a bap generated name for which I kind of think we might like to strip the `main_`. * pto is short for "points to" I'm channeling a bit this: https://cvc4.github.io/separation-logic.html I thought that the original name of `on-stack` was a bit confusing since a local variable is "on the stack" but really the predicate is about pointers that point to the stack. I could expand the name to `points-to-stack`. Perhaps the clarity is worth the verbosity
Cool! This answers all of my questions. I think we should document when the prelude gets added and a list of the pre-defined predicates somewhere.
I'm good with this, as soon as it's rebased.
Initial pass at adding a smtlib prelude. Ready for discussion at least I think. Currently on the test example, it prepends the following string to both the precond and postcond
Note that bap prepends the name of the subroutine to the variable names. Perhaps we want to trim this off. We also want to inject the prelude for single binary mode.
Features that could still be added to the prelude:
(define-fun store8 ((mem memsort) (p pointer) (v ( BitVec 8))) (store mem p v)) (define-fun store16 ((mem memsort) (p pointer) (v ( BitVec 8))) (store8 (store mem p (extract 7 0 v)) (bvadd p (_ bv1 64)) (extract 15 8 v)) )
(define-fun pto-stack ((addr pointer)) Bool
(and (bvule addr #x0000000040000000) (bvuge addr #x000000003F800000)))
(define-fun pto-heap ((addr pointer)) Bool (bvule addr (bvsub #x000000003F800000 #x0000000000000100)))
(define-fun args-equal () Bool (and (= arg0_orig arg0_mod) (= arg1_orig arg1_mod))); and so on (define-fun same-env () Bool (and mem-equal args-equal)) (define-fun retval-equal () Bool (= retval_orig retval_mod))