簡體   English   中英

獲取SMT2格式的求解器

[英]Getting solver in SMT2 format

我正在使用Java API生成代碼,但是我想向用戶展示SMT2格式的代碼,有什么辦法可以從Java API中獲取代碼?

可以說我想要一些這樣的生成代碼...

(forall ((task Task)) (not (mustPrecede task task)))
(forall ((t1 Task) (t2 Task) (t3 Task))
(=> (and (mustPrecede t1 t2) (mustPrecede t2 t3)) (mustPrecede t1 t3)))

可以解析成這樣的東西

(declare-fun TaskUser (Task User) Bool)
(declare-fun mustPrecede (Task Task) Bool)
(assert(forall((t Task)) (not (mustPrecede t t))))
(assert(forall((t1 Task)(t2 Task)(t3 Task)) (implies (and (mustPrecede t1 t2)     (mustPrecede t2 t3)) (mustPrecede t1 t3))))
(assert(forall((t Task)(u User)) (TaskUser t u)))

如果我們將AST的打印模式設置為相應的選項,則將以SMT2語法打印表達式。

ctx.setPrintMode(Z3_PRINT_SMTLIB2_COMPLIANT);

每當調用AST或Expr上的.toString()函數時,它就會符合SMT2。

請注意, .toString()函數將僅打印表達式本身,而不打印它們可能依賴的任何聲明。 如果需要聲明,則可能在客戶端代碼中的某處存在它們的列表,但是如果不是這樣,則需要遍歷表達式以查找它們所依賴的所有函數聲明。 可以通過在Expr上調用.getFuncDecl()獲得函數聲明。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM