How can I specify the multiset and tuple in alloy?
Hello
In defining sig, the set relation can be specified as follows:
sig B
sig A
{
r: set B
}
I want to model my project which is in the base of multiset (a set can have repeated member such as {1,1,2,2,2}) and tuple (an ordered set such as (1,2) which differ with (2,1)).
How can I specify the multiset and tuple in alloy?
In your way, cardinality (number of member) of tuple is constant. But I need the tuple with variable cardinality. It may be 2-tuple in first time and after a while is 4-tuple.
Please, help me again.
Thanks a lot.
Another possibility (with different scope and scalability behaviors)
might be to explicitly list out the different arities:
abstract sig Tuple { }
sig Pair extends Tuple { a, b: X }
sig Tripple extends Tuple { a, b, c: X }
sig Quad extends Tuple { a, b, c, d: X }
sig Something { someField: set Tuple }
(My example lists up to arity 4. I omit arity 5 and above,
because with the other approach, Alloy Analyzer typically
won't perform well with arity 5 or above anyway...)
sig Bag{ // multiset, absence treated as zero occurences
content : Element ->one Nat
}
sig Pair{
first, second : Element
}
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
In your way, cardinality (number of member) of tuple is constant. But I need the tuple with variable cardinality. It may be 2-tuple in first time and after a while is 4-tuple.
Please, help me again.
Thanks a lot.
sig A{
field : seq B
}
sig B{}
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
might be to explicitly list out the different arities:
abstract sig Tuple { }
sig Pair extends Tuple { a, b: X }
sig Tripple extends Tuple { a, b, c: X }
sig Quad extends Tuple { a, b, c, d: X }
sig Something { someField: set Tuple }
(My example lists up to arity 4. I omit arity 5 and above,
because with the other approach, Alloy Analyzer typically
won't perform well with arity 5 or above anyway...)
I thought all things about alloy can be found in tutorial slide in address:
http://alloy.mit.edu/alloy4/tutorial/
But, there is not any things about seq in tutorial slide. Although I found it in what's new section:
http://alloy.mit.edu/alloy4/kb/seq.html
I suggest seq and another features which probably is not in tutorial slide, should be added to it.
Thanks a lot.