我有一个Z3的(get-model)查询,它返回这个函数:
(define-fun rules ((x!0 Tree)) Bool
(ite (= x!0 (node "mann" (cons (node "adam" nil) nil))) true
(ite (= x!0 (node "mensch" (cons (node "adam" nil) nil))) true
true)))
使用此代码时:
(declare-datatypes () ((Tree leaf (node (value String) (children TreeList)))
(TreeList nil (cons (car Tree) (cdr TreeList)))))
(declare-const list TreeList)
(declare-const fact1 Tree)
(declare-const fact2 Tree)
(assert (not (is-leaf fact1)))
(assert (not (is-leaf fact2)))
(assert (not (= list nil)))
(assert (= (value fact1) "mann"))
(assert (= (value fact2) "adam"))
(assert (= (children fact1) list))
(assert (= fact2 (car list)))
(declare-const list2 TreeList)
(declare-const fact3 Tree)
(declare-const fact4 Tree)
(assert (not (is-leaf fact3)))
(assert (not (is-leaf fact4)))
(assert (not (= list2 nil)))
(assert (= (value fact3) "mensch"))
(assert (= (value fact4) "adam"))
(assert (= (children fact3) list2))
(assert (= fact4 (car list2)))
(declare-fun rules (Tree) Bool)
(assert (= (rules fact1) true))
(assert (=> (rules fact1) (rules fact3)))
(check-sat)
(get-model)
问题是我需要函数“rules”来返回false,每当参数不是我声明的规则之一的树是真的,但我找不到编辑最后一个“其他”的方法“在功能中。 (get-model)似乎总是使用函数的最常见答案,因为如果没有规则可以解决它的答案,因为我只有树的规则使得答案为真,它对其他人也使用true,但我可以不要那样使用这个功能。
答案 0 :(得分:0)
您似乎正在尝试模仿Prolog,例如"封闭世界"假设在这里。这不是SMT求解器的工作方式:他们会找到一个满足所有要求的模型,其他一切都是公平的游戏。也就是说,如果您不希望其他值满足rules
,那么您必须明确说明。
您可能希望查看数据记录建模,这似乎更接近您要表达的内容:https://rise4fun.com/z3/tutorialcontent/fixedpoints