-
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.
Associate syntactic terms to bitvector variables (#685)
This is a new version of #679, which itself was a new version of #472. A similar fix is also in #553 as bb55438 The crux of it is that the bitvector theory returns *interpreted* values as leaves, where the rest of the solver requires leaves to be *uninterpreted terms*. The main difference of this patch with the other patches above is that here we only create the fresh terms associated with variables *after* solving, so we only create fresh terms that we do expose. On the other hand, the solver may create many variables internally that gets split or otherwise merged and whose associated terms would never get used. Fixes #350 Fixes #664
- Loading branch information
1 parent
acbc648
commit 6046928
Showing
7 changed files
with
127 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
(** Constants of bitv[1] *) | ||
|
||
logic b0:bitv[1] | ||
axiom b0_def: b0=[|0|] | ||
logic b1:bitv[1] | ||
axiom b1_def: b1=[|1|] | ||
|
||
(** Conversion functions bool<->bitv[|1|] *) | ||
|
||
function bit_of_bool(x:bool):bitv[1] = | ||
if x then b1 else b0 | ||
|
||
function bool_of_bit(x:bitv[1]):bool = | ||
x=b1 | ||
|
||
(** Boolean functions on bitv[|1|] *) | ||
|
||
function bnot(x:bitv[1]):bitv[1] = | ||
bit_of_bool(not bool_of_bit(x)) | ||
|
||
function band(x:bitv[1], y:bitv[1]):bitv[1] = | ||
bit_of_bool(bool_of_bit(x) and bool_of_bit(y)) | ||
|
||
function bor(x:bitv[1], y:bitv[1]):bitv[1] = | ||
bit_of_bool(bool_of_bit(x) or bool_of_bit(y)) | ||
|
||
(** Boolean functions on bitv *) | ||
|
||
(** Not *) | ||
function b2not(x:bitv[2]):bitv[2] = | ||
bnot(x^{1,1})@bnot(x^{0,0}) | ||
function b4not(x:bitv[4]):bitv[4] = | ||
b2not(x^{2,3})@b2not(x^{0,1}) | ||
function b8not(x:bitv[8]):bitv[8] = | ||
b4not(x^{4,7})@b4not(x^{0,3}) | ||
function b16not(x:bitv[16]):bitv[16] = | ||
b8not(x^{8,15})@b8not(x^{0,7}) | ||
|
||
goal gn: bnot([|1|]) = [|0|] | ||
goal gn2: not(b2not([|10|])=[|00|]) | ||
goal gn4: b4not([|1001|])=[|0110|] | ||
(* Start bugging at this line *) | ||
goal gn8: b8not([|10001111|])=[|01110000|] | ||
(* goal gn16: b16not([|1000100011111111|])=[|0111011100000000|] *) |
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 @@ | ||
|
||
unsat | ||
|
||
unsat | ||
|
||
unsat | ||
|
||
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,6 @@ | ||
logic T: bitv[2] | ||
|
||
goal g: | ||
( T = [|00|] ) | ||
or | ||
( [|00|] <> ( [|0|] @ T^{0,0}) ) |
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 @@ | ||
|
||
unknown |
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 @@ | ||
|
||
unknown |
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,7 @@ | ||
(set-logic QF_BV) | ||
(declare-fun T () (_ BitVec 2)) | ||
(assert | ||
(and | ||
(distinct T (_ bv0 2)) | ||
(= (_ bv0 2) (concat (_ bv0 1) ((_ extract 0 0) T))))) | ||
(check-sat) |