-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bitv] Add support for model generation
This patch adds support for model generation in the bitvector theory. To generate a value for a model, a simple brute-force backtracking search amongst all possible bitvector values is performed to find one that is different from the values that were asserted distinct. If none can be found (or if exactly one is found, in which case the value is forced) the `case_split` flag is set so that we report `unsat` instead of looping during model generation. In the future, this should be augmented with proper support for case splits / bit-blasting in the relational theory. Note that even if we add support for case splits in the relational theory, having an enumeration in model generation is useful, because we may not always want to perform case splits on large bitvector types.
- Loading branch information
1 parent
c1e4387
commit 99f867e
Showing
9 changed files
with
234 additions
and
10 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,2 @@ | ||
|
||
unsat |
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,9 @@ | ||
(set-logic BV) | ||
(set-option :produce-models true) | ||
|
||
; Without :produce-models we say 'unknown', not 'unsat' | ||
(declare-const a (_ BitVec 1)) | ||
(declare-const b (_ BitVec 1)) | ||
(declare-const c (_ BitVec 1)) | ||
(assert (distinct a b c)) | ||
(check-sat) |
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 @@ | ||
|
||
unknown | ||
( | ||
(define-fun z () (_ BitVec 1) #b0) | ||
(define-fun a () (_ BitVec 2) #b11) | ||
(define-fun b () (_ BitVec 3) #b111) | ||
(define-fun c () (_ BitVec 6) #b111011) | ||
) |
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,18 @@ | ||
(set-logic BV) | ||
(set-option :produce-models true) | ||
|
||
(declare-const a (_ BitVec 2)) | ||
(declare-const b (_ BitVec 3)) | ||
(declare-const c (_ BitVec 6)) | ||
(declare-const z (_ BitVec 1)) | ||
|
||
(assert (= ((_ extract 0 0) c) #b1)) | ||
(assert (= ((_ extract 5 5) c) #b1)) | ||
(assert (= (concat (concat b z) a) c)) | ||
|
||
(assert (= ((_ extract 1 1) a) #b1)) | ||
(assert (= ((_ extract 1 0) b) #b11)) | ||
(assert (= z #b0)) | ||
|
||
(check-sat) | ||
(get-model) |
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,5 @@ | ||
|
||
unknown | ||
( | ||
(define-fun x () (_ BitVec 4) #b0101) | ||
) |
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,10 @@ | ||
(set-logic BV) | ||
(set-option :produce-models true) | ||
|
||
(declare-const x (_ BitVec 4)) | ||
(assert (= ((_ extract 0 0) x) #b1)) | ||
(assert (= ((_ extract 1 1) x) #b0)) | ||
(assert (= ((_ extract 2 2) x) #b1)) | ||
(assert (= ((_ extract 3 3) x) #b0)) | ||
(check-sat) | ||
(get-model) |