Skip to content

get-model returns not all variables #2502

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

Closed
pjljvandelaar opened this issue Aug 19, 2019 · 0 comments
Closed

get-model returns not all variables #2502

pjljvandelaar opened this issue Aug 19, 2019 · 0 comments

Comments

@pjljvandelaar
Copy link

pjljvandelaar commented Aug 19, 2019

Running z3 with the following model

(get-info :name)
(get-info :version)
(set-logic ALL)
(set-option :produce-models true)
(set-info :smt-lib-version 2.5)

(push)
(declare-fun s1() String)
(assert (str.in.re s1 (re.+ (re.range "a" "z"))))
(check-sat)
(get-model)
(pop)
(check-sat)
(get-model)

on windows 10
provides the expected output:

PS C:\experiments\z3> z3 .\nest.smt2
(:name "Z3")
(:version "4.8.5")
sat
(model
  (define-fun s1 () String
    "b")
)
sat
(model
)

However, when the nineth line is removed, I get a model I did not expect.
Thus z3 with this model

(get-info :name)
(get-info :version)
(set-logic ALL)
(set-option :produce-models true)
(set-info :smt-lib-version 2.5)

(push)
(declare-fun s1() String)
(check-sat)
(get-model)
(pop)
(check-sat)
(get-model)

produces

(:name "Z3")
(:version "4.8.5")
sat
(model
)
sat
(model
)

Why does the model not contain variable s1 with a value?

According to the standard on page 61,
(get-model) returns a list (d1 ··· dk) of definitions specifying **all** and only the current userdeclared function symbols {g1,...,gm} in the current model A

Note that get-value works as expected:

(get-info :name)
(get-info :version)
(set-logic ALL)
(set-option :produce-models true)
(set-info :smt-lib-version 2.5)

(push)
(declare-fun s1() String)
(check-sat)
(get-model)
(get-value (s1))
(pop)
(check-sat)
(get-model)

provides

(:name "Z3")
(:version "4.8.5")
sat
(model
)
((s1 ""))
sat
(model
)

Note that cvc4 does include s1 in its model:

PS C:\experiments\z3> cvc4 --incremental .\nest.smt2
(:name "cvc4")
(:version "1.7")
sat
(model
(define-fun s1 () String "")
)
sat
(model
)
@pjljvandelaar pjljvandelaar changed the title Model contains not all variables get-model returns not all variables Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant