Skip to content
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

fix: Add missing model for to_int coercion #221

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/model/real.ml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ let builtins ~eval env (cst : Dolmen.Std.Expr.Term.Const.t) =
| B.Modulo_f `Real -> op2 ~cst mod_f
| B.Is_rat `Real -> Some (Bool.mk true)
| B.Floor `Real -> op1 ~cst floor
| B.Floor_to_int `Real -> Some (fun1 ~cst (fun x -> Int.mk (Int.floor x)))
| B.Ceiling `Real -> op1 ~cst ceil
| B.Truncate `Real -> op1 ~cst truncate
| B.Round `Real -> op1 ~cst round
Expand Down
32 changes: 32 additions & 0 deletions tests/model/coercion/dune
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,36 @@
(action (diff int_to_real.expected int_to_real.full)))


; Test for real_to_int.smt2
; Incremental test

(rule
(target real_to_int.incremental)
(deps (:response real_to_int.rsmt2) (:input real_to_int.smt2))
(package dolmen_bin)
(action (chdir %{workspace_root}
(with-outputs-to %{target}
(with-accepted-exit-codes (or 0 (not 0))
(run dolmen --check-model=true -r %{response} --mode=incremental --color=never %{input} %{read-lines:flags.dune}))))))
(rule
(alias runtest)
(package dolmen_bin)
(action (diff real_to_int.expected real_to_int.incremental)))

; Full mode test

(rule
(target real_to_int.full)
(deps (:response real_to_int.rsmt2) (:input real_to_int.smt2))
(package dolmen_bin)
(action (chdir %{workspace_root}
(with-outputs-to %{target}
(with-accepted-exit-codes (or 0 (not 0))
(run dolmen --check-model=true -r %{response} --mode=full --color=never %{input} %{read-lines:flags.dune}))))))
(rule
(alias runtest)
(package dolmen_bin)
(action (diff real_to_int.expected real_to_int.full)))


; Auto-generated part end
Empty file.
4 changes: 4 additions & 0 deletions tests/model/coercion/real_to_int.rsmt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sat
(
(define-fun x () Real 2.2)
)
6 changes: 6 additions & 0 deletions tests/model/coercion/real_to_int.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(set-option :produce-models)
(set-logic QF_LIRA)
(declare-const x Real)
(assert (= (to_int x) 2))
(check-sat)
(get-model)
Loading