Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
259 views
in Technique[技术] by (71.8m points)

(get-unsat-core) returns empty in Z3

I am using Z3 to extract the unsat-core of an unsatisfiable formula. I am using Z3@Rise interface (web based) to write the following code,

(set-logic QF_LIA)
(set-option :produce-unsat-cores true)

(declare-fun ph1 () Int)
(declare-fun ph1p () Int)
(declare-fun ph3 () Int)
(declare-fun ph3p () Int)
(declare-fun ph4 () Int)
(declare-fun ph4p () Int)

(define-fun one () Bool (= ph3p (+ ph1 1)))
(define-fun two () Bool (= ph3 (+ ph1 1)))
(define-fun three () Bool (= ph1p (+ ph1 1)))
(define-fun four () Bool (= ph4p (+ ph1p 1)))
(define-fun five () Bool (>= ph1 0))
(define-fun six () Bool (>= ph4 0))

(define-fun secondpartA () Bool (or (= ph4 0) (<= ph3 ph4) ))
(define-fun secondpartB () Bool (or (= ph3p 0) (<= ph4p ph3p) ))


(assert one)
(assert two)
(assert three)
(assert four)
(assert five)
(assert six)
(assert secondpartA)
(assert secondpartB)
(check-sat)
(get-unsat-core)

check-sat correctly returns 'unsat' but (get-unsat-core) returns empty. Am I missing some configuration/option? Or have I made the example complicated?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to add name labels to your assertions so get-unsat-core has labels to use in the unsat core output. Write your assertions like this:

(assert (! one :named a1))
(assert (! two :named a2))
(assert (! three :named a3))
(assert (! four :named a4))
(assert (! five :named a5))
(assert (! six :named a6))
(assert (! secondpartA :named spA))
(assert (! secondpartB :named spB))

and get-unsat-core will print an unsat core.

Documentation for this syntax can be found in the SMTLIB tutorial (PDF file).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...