Alloy Community

User login

Please help me solve this.

 
Posted on: Tue, 10/13/2009 - 13:00
Joined: 2009-10-13
Points: 6
User is offline
Please help me solve this.
Sorry. I post it again to get quicker answers.

I am new to Alloy.

I want to use Alloy to describe a simple number comparing relation. This is what I did.

sig Numbers { Small :  Numbers}

sig One, Two, Three, Four, Five in Numbers{
                    }
fact {Numbers = One + Two + Three + Four + Five}

//Initial relation in Small
fact { Small = One -> Two + Two ->Three + Three -> Four + Four -> Five}

//the transitive property
fact { all x, y, z: Numbers | x -> y in Small && y -> z in Small => x->z in Small}  

assert P {One -> Three in Small}

check P

The assertion should be right. Why Alloy tool keeps telling the assertion is invalid?

Basically, I want to specify a model with certain relations and then check if some relation will appear. Can Alloy do that?

Thank you all for your help.
 
Posted on: Wed, 10/14/2009 - 02:51    #1
Joined: 2008-06-06
Points: 93
User is offline
Alloy is correct in telling you that the assertion is invalid.

You give a fact that defines Small exactly:

Small = One -> Two + Two ->Three + Three -> Four + Four -> Five

There is no One->Three in there, so unless Two=Three in all models of your specification (it does not) this will be false.

What you probably mean is

sig Number{smaller : Number}
one sig One, Two, Three, Four, Five extends Number{} // `one' to ensure a single atom for each; `extend' rather than `in' to make disjoint
fact smaller_definition{smaller = *(One -> Two + Two ->Three + Three -> Four + Four -> Five)}// transitive closure of kernel.
check {One->Three in smaller}

Jeremy L. Jacob        Tel: +44-1904-43-2747    Fax: +44-1904-43-2767
Jeremy.Jacob@cs.york.ac.uk    http://www-users.cs.york.ac.uk/~jeremy/
Dept. of Computer Science, The University of York, YORK, YO10 5DD, UK
 
Posted on: Wed, 10/14/2009 - 11:55    #2
Joined: 2009-10-13
Points: 6
User is offline
Thank you for your help.

I tried your specification, and it works for the relation One -> Three. But for the relation such as

check {Five -> Three in smaller}

Why it does not say the assertion is invalid?
 
Posted on: Thu, 10/15/2009 - 03:44    #3
Joined: 2008-06-06
Points: 93
User is offline
Off hand, I am not sure:

The way I prefer to code your problem is:

enum Nat {One, Two, Three, Four, Five}
fun smaller : Nat -> Nat{*(One -> Two + Two ->Three + Three -> Four + Four -> Five):>Nat}

run{}
check {One->Three in smaller}
check {Three->One in smaller}

which does what you would expect.  

Jeremy L. Jacob        Tel: +44-1904-43-2747    Fax: +44-1904-43-2767
Jeremy.Jacob@cs.york.ac.uk    http://www-users.cs.york.ac.uk/~jeremy/
Dept. of Computer Science, The University of York, YORK, YO10 5DD, UK

Syndicate content  

The development of this site is supported by the National Science Foundation under Computing Research Infrastructure Grant No. 0707612.

Theme originally designed by Chris Herberte