-
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.
[models] Add support for printing arrays (#659)
This patch adds the support for printing arrays in the models output. Rather than printing default values, we print smtlib abstract values (@xxx) for the unknown elements, because we don't have a default value available easily otherwise. The example model in #555 now displays as: ```smtlib2 ( (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 also removes the "Functions" / "Constants" / "Arrays" sections because they were now wrong (some arrays were in constants, other in arrays) and hence somewhat confusing. Instead, the "values" section is added then printing with `--model-type constraints`. Uses of Printer.print_fmt have also been replaced with Format.fprintf because they were causing weird looking outputs with some combinations of options. Only the final value is printer with `print_fmt`, which should do the appropriate (actually, I don't think it is needed here, but better safe than sorry) cleanup dance only once. Fixes #555
- Loading branch information
1 parent
2036a5f
commit a749843
Showing
12 changed files
with
114 additions
and
113 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 |
---|---|---|
|
@@ -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)) | ||
) |