use of kodkod.instance.Universe in project org.alloytools.alloy by AlloyTools.
the class OverflowSigTest method createBounds.
protected void createBounds() {
Collection<String> atoms = new ArrayList<String>(sAtoms.size() + xAtoms.size());
atoms.addAll(sAtoms);
atoms.addAll(xAtoms);
final Universe universe = new Universe(atoms);
this.factory = universe.factory();
this.bounds = new Bounds(universe);
TupleSet sTs = factory.setOf(sAtoms.toArray());
TupleSet xTs = factory.setOf(xAtoms.toArray());
bounds.bound(s, sTs);
bounds.bound(x, xTs);
bounds.bound(sa, sTs.product(xTs));
bounds.bound(sb, sTs.product(xTs));
bounds.bound(sc, sTs.product(xTs));
}
use of kodkod.instance.Universe in project org.alloytools.alloy by AlloyTools.
the class OverflowTheoremTest method setupBounds.
protected void setupBounds() {
Relation ret = Relation.unary("ret");
int min = min(bw);
int max = max(bw);
List<String> atoms = new ArrayList<String>(max - min + 1);
for (int i = min; i <= max; i++) {
atoms.add(String.valueOf(i));
}
final Universe universe = new Universe(atoms);
TupleFactory factory = universe.factory();
this.bounds = new Bounds(factory.universe());
for (int i = min; i <= max; i++) {
bounds.boundExactly(i, factory.setOf(String.valueOf(i)));
}
bounds.bound(ret, factory.noneOf(1), factory.allOf(1));
}
use of kodkod.instance.Universe in project org.alloytools.alloy by AlloyTools.
the class Handshake method bounds.
/**
* Returns a bounds for the given number of persons.
*
* @return a bounds for the given number of persons.
*/
public Bounds bounds(int persons) {
final List<String> atoms = new ArrayList<String>(persons);
atoms.add("Hilary");
atoms.add("Jocelyn");
for (int i = 2; i < persons; i++) {
atoms.add("Person" + i);
}
final Universe u = new Universe(atoms);
final TupleFactory f = u.factory();
final Bounds b = new Bounds(u);
b.boundExactly(Person, f.allOf(1));
b.boundExactly(Hilary, f.setOf("Hilary"));
b.boundExactly(Jocelyn, f.setOf("Jocelyn"));
b.bound(spouse, f.allOf(2));
b.bound(shaken, f.allOf(2));
return b;
}
use of kodkod.instance.Universe in project org.alloytools.alloy by AlloyTools.
the class ToyFilesystem method bounds.
/**
* Returns the toy filesystem bounds.
*
* @return toy filesystem bounds
*/
public final Bounds bounds() {
final Universe universe = new Universe("d0", "d1", "f0", "f1", "f2");
final Bounds bounds = new Bounds(universe);
final TupleFactory factory = universe.factory();
bounds.boundExactly(root, factory.setOf("d0"));
bounds.bound(dir, factory.setOf("d0", "d1"));
bounds.bound(file, factory.setOf("f0", "f1", "f2"));
bounds.bound(contents, factory.setOf(factory.tuple("d0", "d1")), bounds.upperBound(dir).product(factory.allOf(1)));
return bounds;
}
use of kodkod.instance.Universe in project org.alloytools.alloy by AlloyTools.
the class AbstractWorldDefinitions method bounds.
/**
* Returns the bounds for the given scope.
*
* @return bounds for the given scope
*/
public final Bounds bounds(int scope) {
final List<String> atoms = new LinkedList<String>();
final int max = scope - 1;
for (int i = 0; i < scope; i++) {
atoms.add("Coin" + i);
}
for (int i = 0; i < scope; i++) {
atoms.add("Purse" + i);
}
for (int i = 0; i < scope; i++) {
atoms.add("TransferDetails" + i);
}
atoms.add("aNullIn");
for (int i = 0; i < scope; i++) {
atoms.add("AbWorld" + i);
}
for (int i = 0; i < max; i++) {
atoms.add("AOUT" + i);
}
atoms.add("aNullOut");
final Universe u = new Universe(atoms);
final TupleFactory f = u.factory();
final Bounds b = new Bounds(u);
b.bound(Coin, f.range(f.tuple("Coin0"), f.tuple("Coin" + max)));
b.bound(Purse, f.range(f.tuple("Purse0"), f.tuple("Purse" + max)));
b.bound(TransferDetails, f.range(f.tuple("TransferDetails0"), f.tuple("TransferDetails" + max)));
b.bound(AbWorld, f.range(f.tuple("AbWorld0"), f.tuple("AbWorld" + max)));
b.bound(AbPurse, b.upperBound(Purse));
b.bound(AOUT, f.range(f.tuple("AOUT0"), f.tuple("aNullOut")));
b.bound(AIN, f.range(f.tuple("TransferDetails0"), f.tuple("aNullIn")));
b.boundExactly(aNullIn, f.setOf("aNullIn"));
b.boundExactly(aNullOut, f.setOf("aNullOut"));
b.bound(from, b.upperBound(TransferDetails).product(b.upperBound(Purse)));
b.bound(to, b.upperBound(TransferDetails).product(b.upperBound(Purse)));
b.bound(value, b.upperBound(TransferDetails).product(b.upperBound(Coin)));
b.bound(abAuthPurse, b.upperBound(AbWorld).product(b.upperBound(AbPurse)));
b.bound(abBalance, b.upperBound(AbPurse).product(b.upperBound(Coin)).product(b.upperBound(AbWorld)));
b.bound(abLost, b.upperBound(AbPurse).product(b.upperBound(Coin)).product(b.upperBound(AbWorld)));
return b;
}
Aggregations