Skip to content

Commit

Permalink
fix: Add missing model for to_int coercion (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
bclement-ocp authored Oct 1, 2024
1 parent 76fb043 commit ec32e34
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
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)

0 comments on commit ec32e34

Please sign in to comment.