在ATM合金需要帮助

时间:2015-05-13 00:02:02

标签: alloy

我正在尝试建模,ATM系统在验证卡和引脚是否正确后提供可用的金额,否则,不提供金额。 此外,如果卡不正确,它将被拒绝 如果引脚不正确,则会被拒绝

在第一个模型中,出现了一个反例,我在下面的第二个模型中修复了它。

我的问题是,我只是想知道我的模特是否合适? 并解决反例是正确的吗? 感谢

具有反例的模型:

module ATM_Sys
one sig Enter_Card {}
abstract sig ATM_Operation {}
one sig  Reject_Pin, Reject_Card, Provides_Amount,Dont_Provides_Amount extends ATM_Operation{}


sig ATM {
card : lone Card , 
userOp :  Enter_Card lone -> card, 
AtmOp:   userOp-> lone ATM_Operation  
} 

sig Card
{
pin : one Int,
balance: one Int
}

fact   {all  crd,pn:Card| crd.balance >0 && pn.pin >0 } 

pred Start[atm,atm':ATM,crd:Card]
{
atm.userOp=Enter_Card->crd &&
atm'.card=crd && atm'.card=atm.card && TypePin [atm,atm']
}

pred TypePin[atm,atm':ATM]
{
 atm'.card.pin=Int && atm'.card.pin=atm.card.pin implies SelectAmount[atm,atm']
}

pred SelectAmount[atm,atm':ATM]
{
 atm'.card.balance=Int  implies atm'.AtmOp=atm.userOp->Provides_Amount
}

assert ATM_System
{all atm,atm':ATM,crd:Card|
Start[atm,atm',crd]  =>( 
atm'.card!=atm.card  && atm'.AtmOp=atm.userOp->Reject_Card ||
atm'.card.pin!=atm.card.pin &&atm'.AtmOp=atm.userOp->Reject_Pin || 
atm'.card.balance!=atm.card.balance  && atm'.AtmOp=atm.userOp->Dont_Provides_Amount )
}

check ATM_System for 1
run Start 

没有反例的模型:

module ATM_Sys
one sig Enter_Card {}
abstract sig ATM_Operation {}
one sig  Reject_Pin, Reject_Card, Provides_Amount,Dont_Provides_Amount extends ATM_Operation{}


sig ATM {
card : lone Card , 
userOp :  Enter_Card lone -> card, 
AtmOp:   userOp-> lone ATM_Operation  
} 

sig Card
{
pin : one Int,
balance: one Int
}

fact   {all  crd,pn:Card| crd.balance >0 && pn.pin >0 } 

pred Start[atm,atm':ATM,crd:Card]
{
atm.userOp=Enter_Card->crd &&
atm'.card=crd && atm'.card=atm.card && TypePin [atm,atm']
}

pred TypePin[atm,atm':ATM]
{
 atm'.card.pin=Int && atm'.card.pin=atm.card.pin implies SelectAmount[atm,atm']
}

pred SelectAmount[atm,atm':ATM]
{
 atm'.card.balance=Int  implies atm'.AtmOp=atm.userOp->Provides_Amount
}

assert ATM_System
{all atm,atm':ATM,crd:Card|
Start[atm,atm',crd]  =>( 
atm'.card!=atm.card  => atm'.AtmOp=atm.userOp->Reject_Card ||
atm'.card.pin!=atm.card.pin =>atm'.AtmOp=atm.userOp->Reject_Pin || 
atm'.card.balance!=atm.card.balance  => atm'.AtmOp=atm.userOp->Dont_Provides_Amount )
}

check ATM_System for 1
run Start 

另外,当我修复反例时,我注意到,在任何数量的情况下 范围,仍然没有反例。这是对的吗?

由于

0 个答案:

没有答案