use of edu.mit.csail.sdg.alloy4.ErrorFatal in project org.alloytools.alloy by AlloyTools.
the class SimInstance method visit.
/**
* {@inheritDoc}
*/
@Override
public Object visit(ExprVar x) throws Err {
Object ans = env.get(x);
if (ans == null)
ans = sfs.get(x);
if (ans == null) {
SimAtom a = SimAtom.make(x.label);
if (!hasAtom(a))
throw new ErrorFatal(x.pos, "Variable \"" + x + "\" is not bound to a legal value during translation.\n");
ans = SimTupleset.make(SimTuple.make(a));
}
return ans;
}
use of edu.mit.csail.sdg.alloy4.ErrorFatal in project org.alloytools.alloy by AlloyTools.
the class A4Solution method shrink.
/**
* Shrink the bounds for the given relation; throws an exception if the new
* bounds is not sameAs/subsetOf the old bounds.
*/
void shrink(Relation relation, TupleSet lowerBound, TupleSet upperBound) throws Err {
if (solved)
throw new ErrorFatal("Cannot shrink a Kodkod relation since solve() has completed.");
TupleSet oldL = bounds.lowerBound(relation);
TupleSet oldU = bounds.upperBound(relation);
if (oldU.containsAll(upperBound) && upperBound.containsAll(lowerBound) && lowerBound.containsAll(oldL)) {
bounds.bound(relation, lowerBound, upperBound);
} else {
throw new ErrorAPI("Inconsistent bounds shrinking on relation: " + relation);
}
}
use of edu.mit.csail.sdg.alloy4.ErrorFatal in project org.alloytools.alloy by AlloyTools.
the class A4Solution method k2pos.
/**
* Associates the Kodkod formula to a particular Alloy Expr (if the Kodkod
* formula is not already associated with an Alloy Expr or Alloy Pos)
*/
Formula k2pos(Formula formula, Expr expr) throws Err {
if (solved)
throw new ErrorFatal("Cannot alter the k->pos mapping since solve() has completed.");
if (formula == null || expr == null || k2pos.containsKey(formula))
return formula;
k2pos.put(formula, expr);
if (formula instanceof BinaryFormula) {
BinaryFormula b = (BinaryFormula) formula;
if (b.op() == FormulaOperator.AND) {
k2pos(b.left(), expr);
k2pos(b.right(), expr);
}
}
return formula;
}
use of edu.mit.csail.sdg.alloy4.ErrorFatal in project org.alloytools.alloy by AlloyTools.
the class A4Solution method addSkolem.
/**
* Add a new skolem to this solution and associate it with the given expression.
* <br>
* The expression must contain only constant Relations or Relations that are
* already bound in this solution.
*/
private ExprVar addSkolem(String label, Type type, Expression expr) throws Err {
if (solved)
throw new ErrorFatal("Cannot add an additional skolem since solve() has completed.");
int a = type.arity();
if (a < 1)
throw new ErrorFatal("Skolem " + label + " must be associated with a relational value.");
if (a != expr.arity())
throw new ErrorFatal("Skolem " + label + " must be associated with an " + a + "-ary relational value.");
ExprVar v = ExprVar.make(Pos.UNKNOWN, label, type);
a2k.put(v, expr);
skolems.add(v);
return v;
}
use of edu.mit.csail.sdg.alloy4.ErrorFatal in project org.alloytools.alloy by AlloyTools.
the class A4Solution method k2pos.
/**
* Associates the Kodkod formula to a particular Alloy Pos (if the Kodkod
* formula is not already associated with an Alloy Expr or Alloy Pos)
*/
Formula k2pos(Formula formula, Pos pos) throws Err {
if (solved)
throw new ErrorFatal("Cannot alter the k->pos mapping since solve() has completed.");
if (formula == null || pos == null || pos == Pos.UNKNOWN || k2pos.containsKey(formula))
return formula;
k2pos.put(formula, pos);
if (formula instanceof BinaryFormula) {
BinaryFormula b = (BinaryFormula) formula;
if (b.op() == FormulaOperator.AND) {
k2pos(b.left(), pos);
k2pos(b.right(), pos);
}
}
return formula;
}
Aggregations