在Z3定理证明中设置

时间:2015-07-03 16:59:12

标签: java z3 alloy

我在Alloy中有声明

sig Card{}
sig ATM {card :  disj  set Card}

我将它转换成Z3:

1- (declare-sort ATM) 
2- (declare-fun isATM (ATM) Bool)
3- (declare-sort Card)
4- (declare-fun isCard (Card) Bool)
5- (declare-fun card (ATM Card) Bool)
6- (assert(forall ((c Card) (atm ATM)) (=> (card atm c) (and(isATM atm) (isCard c))))) 
7- (declare-fun disjSetCard (ATM) Card)
8- (assert(forall ((atm ATM) (c Card))  (=> (card atm c)(= c(disjSetCard atm)))))
check sat

问题是,在第7行中,如何使函数disjSetCard返回(disj set)个卡而不是一张卡。我的代码是正确的还是有不同的解决方案,请?

1 个答案:

答案 0 :(得分:0)

您可以使用返回集合的函数对关系进行编码:

soup.find("td", text="PHONE :").find_next_sibling("td").text

将ATM的不同成员的字段值限制为不相交,使用:

(define-sort Set (T) (Array T Bool))    
(declare-sort ATM)     
(declare-sort Card)    
(declare-fun ATMtoCard (ATM) (Set Card))

对应于Alloy表达式:

(forall ((a Card) (x ATM) (y ATM))
(=>
  (and (select (ATMtoCard x) a) (select (ATMtoCard y) a))
  (= x y)
))