-
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.
This PR fixes the issue #926 about printing reals in models. The current printer always displays positive reals as rational numbers of the form `(/ x y)` where `x` and `y` are positive integers. Negative reals are represented by the expression `(/ (- x) y)` where `x` and `y` are positive integers. The printer simplifies the expression if the denominator is one. Notice that by the current implementation of Zarith: ```ocaml type t = { num: Z.t; (** Numerator. *) den: Z.t; (** Denominator, >= 0 *) } (* Type of rationals. Invariants: - den is always >= 0; - num and den have no common factor; - if den=0, then num is -1, 0 or 1. - if num=0, then den is -1, 0 or 1. *) ``` Any rational number of the form `0/q` satisfies `q = -1` or `q = 0` or `q = 1`. Thus the printer will always output `0.0` in this case but for the case `0/0` which shouldn't occur.
- Loading branch information
Showing
11 changed files
with
80 additions
and
28 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
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,10 @@ | ||
|
||
unknown | ||
( | ||
(define-fun x1 () Int 5) | ||
(define-fun x2 () Int (- 5)) | ||
(define-fun y1 () Real (/ 3 2)) | ||
(define-fun y2 () Real 4.0) | ||
(define-fun y3 () Real (/ 16 5)) | ||
(define-fun y4 () Real (/ (- 3) 2)) | ||
) |
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,16 @@ | ||
(set-logic ALL) | ||
(set-option :produce-models true) | ||
(declare-const x1 Int) | ||
(declare-const x2 Int) | ||
(declare-const y1 Real) | ||
(declare-const y2 Real) | ||
(declare-const y3 Real) | ||
(declare-const y4 Real) | ||
(assert (= x1 5)) | ||
(assert (= x2 (- 5))) | ||
(assert (= y1 (/ (- 3.0) (- 2.0)))) | ||
(assert (= y2 (/ (- 4.0) (- 1.0)))) | ||
(assert (= y3 3.2)) | ||
(assert (= y4 (/ 3.0 (- 2.0)))) | ||
(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,6 +1,6 @@ | ||
|
||
unknown | ||
( | ||
(define-fun x () Real 0) | ||
(define-fun y () Real 10) | ||
(define-fun x () Real 0.0) | ||
(define-fun y () Real 10.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,7 +1,7 @@ | ||
|
||
unknown | ||
( | ||
(define-fun x () Real 2) | ||
(define-fun x () Real 2.0) | ||
(define-fun p1 () Bool false) | ||
(define-fun p2 () 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,7 +1,7 @@ | ||
|
||
unknown | ||
( | ||
(define-fun x () Real (- (/ 1 18))) | ||
(define-fun y () Real (- (/ 1 36))) | ||
(define-fun z () Real (- (/ 7 9))) | ||
(define-fun x () Real (/ (- 1) 18)) | ||
(define-fun y () Real (/ (- 1) 36)) | ||
(define-fun z () Real (/ (- 7) 9)) | ||
) |
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,10 +1,10 @@ | ||
|
||
unknown | ||
( | ||
(define-fun x () Real 0) | ||
(define-fun x () Real 0.0) | ||
) | ||
|
||
unknown | ||
( | ||
(define-fun x () Real (- (/ 3 2))) | ||
(define-fun x () Real (/ (- 3) 2)) | ||
) |
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,6 +1,6 @@ | ||
|
||
unknown | ||
( | ||
(define-fun x () Real 4) | ||
(define-fun y () Real 4) | ||
(define-fun x () Real 4.0) | ||
(define-fun y () Real 4.0) | ||
) |