-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[models] Add support for printing arrays #659
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -1085,4 +1085,3 @@ let save_cache () = | |
|
||
let reinit_cache () = | ||
LX.reinit_cache () | ||
|
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 @@ | ||
; From https://github.com/OCamlPro/alt-ergo/issues/555 | ||
(set-logic ALL) | ||
(declare-const x Int) | ||
(declare-const y Int) | ||
(declare-const a1 (Array Int Int)) | ||
(declare-const a2 (Array Int Int)) | ||
(assert (= (select a1 x) x)) | ||
(assert (= (store a1 x y) a1)) | ||
(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
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 @@ | ||
|
||
unknown | ||
( | ||
(define-fun x () Int 0) | ||
(define-fun y () Int 0) | ||
(define-fun a1 () (Array Int Int) (store (as @a1 (Array Int Int)) 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,10 @@ | ||
(set-logic ALL) | ||
(set-option :produce-models true) | ||
(declare-const x Int) | ||
(declare-const y Int) | ||
(declare-const a1 (Array Int Int)) | ||
(declare-const a2 (Array Int Int)) | ||
(assert (= (select a1 x) x)) | ||
(assert (= (store a1 x y) a1)) | ||
(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 |
---|---|---|
@@ -1,14 +1,5 @@ | ||
|
||
unknown | ||
( | ||
|
||
; Functions | ||
|
||
; Constants | ||
|
||
(define-fun x () Int 0) | ||
|
||
; Arrays not yet supported | ||
|
||
|
||
(define-fun x () Int 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 |
---|---|---|
@@ -1,16 +1,6 @@ | ||
|
||
unknown | ||
( | ||
|
||
; Functions | ||
|
||
; Constants | ||
|
||
(define-fun x () Int 8) | ||
|
||
(define-fun y () Int 42) | ||
|
||
; Arrays not yet supported | ||
|
||
|
||
(define-fun x () Int 8) | ||
(define-fun y () Int 42) | ||
) |
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 |
---|---|---|
@@ -1,30 +1,11 @@ | ||
|
||
unknown | ||
( | ||
|
||
; Functions | ||
|
||
; Constants | ||
|
||
; Arrays not yet supported | ||
|
||
|
||
) | ||
|
||
unknown | ||
( | ||
|
||
; Functions | ||
|
||
; Constants | ||
|
||
(define-fun p () Bool true) | ||
|
||
(define-fun q () Bool true) | ||
|
||
(define-fun nq () Bool true) | ||
|
||
; Arrays not yet supported | ||
|
||
|
||
(define-fun p () Bool true) | ||
(define-fun q () Bool true) | ||
(define-fun nq () Bool true) | ||
) |
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 |
---|---|---|
@@ -1,12 +1,4 @@ | ||
|
||
unknown | ||
( | ||
|
||
; Functions | ||
|
||
; Constants | ||
|
||
; Arrays not yet supported | ||
|
||
|
||
) |
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 |
---|---|---|
@@ -1,18 +1,7 @@ | ||
|
||
unknown | ||
( | ||
|
||
; Functions | ||
|
||
(define-fun f ((arg_0 Int)) Int 0) | ||
|
||
; Constants | ||
|
||
(define-fun a () Int 0) | ||
|
||
(define-fun b () Int 0) | ||
|
||
; Arrays not yet supported | ||
|
||
|
||
(define-fun f ((arg_0 Int)) Int 0) | ||
(define-fun a () Int 0) | ||
(define-fun b () Int 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 |
---|---|---|
@@ -1,18 +1,7 @@ | ||
|
||
unknown | ||
( | ||
|
||
; Functions | ||
|
||
(define-fun f ((arg_0 Int)) Int (ite (= arg_0 a) 2 0)) | ||
|
||
; Constants | ||
|
||
(define-fun a () Int 0) | ||
|
||
(define-fun b () Int (- 2)) | ||
|
||
; Arrays not yet supported | ||
|
||
|
||
(define-fun f ((arg_0 Int)) Int (ite (= arg_0 a) 2 0)) | ||
(define-fun a () Int 0) | ||
(define-fun b () Int (- 2)) | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure to understand this comment. If the constant is present in the arrays map, then it is present in
arrays_symbols
and ignored by the functionoutput_constants_counterexample
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure to understand why some arrays will be printed as constant and other by
output_arrays_counterexample
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly, this is because arrays for which there has been no get/set are not added to the
array_symbols
.I didn't think it was very important to keep this distinction, but it should not be too hard to iterate over the constant array symbols in
output_arrays_counterexample
instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a version that does what I described above, but it's not very pretty because:
constants
portion. This is the case where an array is defined to be equal to another array.arrays
portion. This is the case of an array that is defined (i.e. has get/set on them) but does not appear in the original problem and was synthesized by the solver.Here is a (slightly overcomplicated) example:
A model is:
In this example,
a1
anda4
are in bothconstants
andarrays
;a2
is only inconstants
; and!k2
is only inarrays
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I will push the code but am waiting on the merge of #703 to include tests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said I am not convinced that keeping the separation while printing is worth the added code complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. All the values are functions. We should remove the difference. I suggest to keep the code as simple as possible and remove the pointless SMTLIB comments in the output model. We will produce a better code for the next release.