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

Add maximize/minimize terms for matching #1166

Merged
merged 1 commit into from
Jul 16, 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
6 changes: 4 additions & 2 deletions src/lib/reasoners/theory.ml
Original file line number Diff line number Diff line change
Expand Up @@ -927,12 +927,14 @@ module Main_Default : S = struct

let add_objective env fn value =
(* We have to add the term [fn] and its subterms as the MaxSMT
syntax allows to optimize expressions that aren't part of
syntax allows to optimize expressions that are not part of
the current context. *)
let expr = fn.Objective.Function.e in
let env = add_term env ~add_in_cs:false expr in
(* We also have to add the term for matching. *)
let terms = Expr.Set.add expr env.terms in
let objectives = Objective.Model.add fn value env.objectives in
{ env with objectives }
{ env with objectives; terms }

let reinit_cpt () =
Debug.reinit_cpt ()
Expand Down
21 changes: 21 additions & 0 deletions tests/dune.inc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests/issues/1163.models.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

unknown
(
(define-fun x () Int (- 9999))
)
(objectives
((myabs x) 9999)
)
11 changes: 11 additions & 0 deletions tests/issues/1163.models.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(set-logic ALL)
(set-option :produce-models true)
(declare-const x Int)
(define-fun myabs ((x Int)) Int (ite (< x 0) (- x) x))
(maximize (myabs x))
(assert (< x 0))
(assert (> x (- 10000)))
; (assert (or (>= (myabs x) 0) (<= (myabs x) 0)))
(check-sat)
(get-model)
(get-objectives)
Loading